Skip to content

Commit

Permalink
feat(provider): implement checkhealth and oil providers
Browse files Browse the repository at this point in the history
  • Loading branch information
bwpge committed May 31, 2024
1 parent 69bc8a2 commit 1ff66ba
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,18 @@ The following are the default component options:
-- to avoid messing with the global nvim-web-devicon config, you can provide custom icons to be
-- used only by this plugin. entries must be a list of strings `{ icon, highlight_name }`
custom_icons = {
trouble = { "󰔫", "DevIconGitConfig" },
Trouble = { "󰔫", "DevIconGitConfig" },
gitrebase = { "", "DevIconGitCommit" },
help = { "󰋖", "DevIconTxt" },
oil = { "", "OilDir" },
trouble = { "󰔫", "DevIconGitConfig" },
Trouble = { "󰔫", "DevIconGitConfig" },
},
-- some icons may need additional padding depending on your font and terminal.
-- refer to nvim-web-devicons for the correct key (icon):
-- https://github.com/nvim-tree/nvim-web-devicons/blob/master/lua/nvim-web-devicons/icons-default.lua
icon_padding = {
[""] = 1, -- value here adds *additional* spaces (use 0 or negative to disable)
[""] = 1,
},
providers = {}, -- see *providers* section
}
Expand Down Expand Up @@ -221,6 +223,8 @@ providers = {
"fugitive",
"toggleterm",
"terminal",
"health",
"oil",
"trouble",
}
```
Expand Down
17 changes: 17 additions & 0 deletions lua/lualine-pretty-path/providers/health.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---@class PrettyPath.HealthProvider: PrettyPath.Provider
---@field super PrettyPath.Provider
local M = require("lualine-pretty-path.providers.base"):extend()

function M.can_handle()
return vim.bo.filetype == "checkhealth"
end

function M:extract_scheme() end

function M:render_symbols() end

function M:extract_name()
return "Health"
end

return M
29 changes: 29 additions & 0 deletions lua/lualine-pretty-path/providers/oil.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---@class PrettyPath.OilProvider: PrettyPath.Provider
---@field super PrettyPath.Provider
local M = require("lualine-pretty-path.providers.base"):extend()

function M.can_handle()
return vim.bo.filetype == "oil"
end

function M:format_path(_)
return require("oil").get_current_dir()
end

---Renders the oil current directory as if it was the "filename" part.
---@return string
function M:render_dir()
local dir = self.super.render_dir(self) or ""
dir = dir:sub(1, #dir - #self.path_sep) -- remove trailing separator

return self.hl(dir, self.opts.highlights.filename)
end

function M:render()
return table.concat({
self:render_dir() or "",
self:render_symbols() or "",
}, "")
end

return M
4 changes: 4 additions & 0 deletions lua/lualine/components/pretty_path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ local default_options = {
custom_icons = {
gitrebase = { "", "DevIconGitCommit" },
help = { "󰋖", "DevIconTxt" },
oil = { "", "OilDir" },
trouble = { "󰔫", "DevIconGitConfig" },
Trouble = { "󰔫", "DevIconGitConfig" },
},
icon_padding = {
[""] = 1,
[""] = 1,
},
providers = {},
}
Expand All @@ -85,6 +87,8 @@ local builtin_providers = {
require("lualine-pretty-path.providers.fugitive"),
require("lualine-pretty-path.providers.toggleterm"),
require("lualine-pretty-path.providers.terminal"),
require("lualine-pretty-path.providers.health"),
require("lualine-pretty-path.providers.oil"),
require("lualine-pretty-path.providers.trouble"),
}

Expand Down

0 comments on commit 1ff66ba

Please sign in to comment.