Skip to content

Commit

Permalink
feat: add Lualine component (#279)
Browse files Browse the repository at this point in the history
chore: autoformat with stylua
  • Loading branch information
BingCoke authored and NTBBloodbath committed Feb 12, 2024
1 parent e862e72 commit 3e0d86d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,35 @@ require("telescope").extensions.rest.select_env()
- env_pattern: For env file pattern
- env_edit_command: For env file edit command

## Lualine

We also have lualine component to get what env file you select!
And dont't worry, it will only show up under http files.

```lua
-- Juse add a component in your lualine config
{
sections = {
lualine_x = {
"rest"
}
}
}

-- To custom icon and color
{
sections = {
lualine_x = {
{
"rest",
icon = "",
fg = "#428890"
}
}
}
}
```

## Contribute

1. Fork it (https://github.com/rest-nvim/rest.nvim/fork)
Expand Down
31 changes: 31 additions & 0 deletions lua/lualine/components/rest.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
local lualine_require = require("lualine_require")
local M = lualine_require.require("lualine.component"):extend()
local config = require("rest-nvim.config")

local default_options = {
fg = "#428890",
icon = "",
}

function M:init(options)
M.super.init(self, options)
self.options = vim.tbl_deep_extend("keep", self.options or {}, default_options)
self.icon = self.options.icon

self.highlight_color = self:create_hl({ fg = self.options.fg }, "Rest")
end

function M:apply_icon()
local default_highlight = self:get_default_hl()
self.status = self:format_hl(self.highlight_color) .. self.icon .. " " .. default_highlight .. self.status
end

function M.update_status()
local current_filetype = vim.bo.filetype
if current_filetype == "http" then
return config.get("env_file")
end
return ""
end

return M

0 comments on commit 3e0d86d

Please sign in to comment.