Skip to content

Commit

Permalink
feat(feline): improve feline lsp display (#688)
Browse files Browse the repository at this point in the history
* feat(feline): improve feline lsp display

* docs: auto generate vimdoc

* fix(feline): show the lsp names for the current buffer only

---------

Co-authored-by: 89iuv <89iuv@users.noreply.github.com>
  • Loading branch information
89iuv and 89iuv committed Mar 27, 2024
1 parent 30930f9 commit f66654d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 5 deletions.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -572,6 +572,14 @@ ctp_feline.setup({
["rm"] = { "MORE", clrs.teal },
["r?"] = { "CONFIRM", clrs.mauve },
["!"] = { "SHELL", clrs.green },
},
view = {
lsp = {
progress = true, -- if true the status bar will display an lsp progress indicator
name = false, -- if true the status bar will display the lsp servers name, otherwise it will display the text "Lsp"
exclude_lsp_names = {}, -- lsp server names that should not be displayed when name is set to true
separator = "|", -- the separator used when there are multiple lsp servers
},
}
})
```
Expand Down
8 changes: 8 additions & 0 deletions doc/catppuccin.txt
Expand Up @@ -465,6 +465,14 @@ Here are the defaults:
["rm"] = { "MORE", clrs.teal },
["r?"] = { "CONFIRM", clrs.mauve },
["!"] = { "SHELL", clrs.green },
},
view = {
lsp = {
progress = true, -- if true the status bar will display an lsp progress indicator
name = false, -- if true the status bar will display the lsp servers name, otherwise it will display the text "Lsp"
exclude_lsp_names = {}, -- lsp server names that should not be displayed when name is set to true
separator = "|", -- the separator used when there are multiple lsp servers
},
}
})
<
Expand Down
46 changes: 41 additions & 5 deletions lua/catppuccin/groups/integrations/feline.lua
Expand Up @@ -65,21 +65,40 @@ local mode_colors = {
["!"] = { "SHELL", C.green },
}

local view = {
lsp = {
progress = true,
name = false,
exclude_lsp_names = {},
separator = "|",
},
}

local is_lsp_in_excluded_list = function(lsp_name)
for _, excluded_lsp in ipairs(view.lsp.exclude_lsp_names) do
if lsp_name == excluded_lsp then return true end
end
return false
end

function M.setup(opts)
if opts then
opts.assets = opts.assets or {}
opts.sett = opts.sett or {}
opts.mode_colors = opts.mode_colors or {}
opts.view = opts.view or {}
else
opts = {
assets = {},
sett = {},
mode_colors = {},
view = {},
}
end
assets = vim.tbl_deep_extend("force", assets, opts.assets)
sett = vim.tbl_deep_extend("force", sett, opts.sett)
mode_colors = vim.tbl_deep_extend("force", mode_colors, opts.mode_colors)
view = vim.tbl_deep_extend("force", view, opts.view)
end

function M.get()
Expand Down Expand Up @@ -326,7 +345,7 @@ function M.get()

return ""
end,
enabled = is_enabled(80),
enabled = is_enabled(80) and view.lsp.progress == true,
hl = {
fg = C.rosewater,
bg = sett.bkg,
Expand Down Expand Up @@ -393,16 +412,33 @@ function M.get()

components.active[3][2] = {
provider = function()
if next(vim.lsp.buf_get_clients()) ~= nil then
return assets.lsp.server .. " " .. "Lsp"
else
return ""
local active_clients = vim.lsp.get_active_clients { bufnr = 0 }

-- show an indicator that we have running lsps
if view.lsp.name == false and next(active_clients) ~= nil then return assets.lsp.server .. " " .. "Lsp" end

-- show the actual name of the runing lsps
local lsp_names = ""
for index, lsp_config in ipairs(active_clients) do
if is_lsp_in_excluded_list(lsp_config.name) then goto continue end

if index == 1 then
lsp_names = assets.lsp.server .. " " .. lsp_config.name
else
lsp_names = lsp_names .. view.lsp.separator .. lsp_config.name
end

::continue::
end

return lsp_names
end,

hl = {
fg = sett.extras,
bg = sett.bkg,
},

right_sep = invi_sep,
}

Expand Down

0 comments on commit f66654d

Please sign in to comment.