display LSP client info in lualine

This commit is contained in:
Oliver Ladner 2024-01-25 17:38:26 +01:00
commit c6dac4f865
2 changed files with 34 additions and 0 deletions

View file

@ -107,3 +107,4 @@ formatters installed here are used via `conform.nvim`.
- ollama integration <https://github.com/nomnivore/ollama.nvim>
- <https://github.com/folke/trouble.nvim>
- <https://github.com/axkirillov/hbac.nvim>

View file

@ -1,8 +1,32 @@
-- status line like vim-airline
-- Display attached LSP client
local function lsp_clients()
local clients = vim.lsp.get_active_clients()
local client_names = {}
local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name
end
end
if next(client_names) == nil then
return "no LS"
end
--return "[" .. table.concat(client_names, ", ") .. "]"
end
-- hide content on narrow windows
local function hide_in_width()
return vim.fn.winwidth(0) > 80
end
return {
"nvim-lualine/lualine.nvim",
lazy = true,
event = { "BufReadPre", "BufNewFile" },
opts = {
options = {
icons_enabled = true,
@ -13,5 +37,14 @@ return {
--section_separators = { left = '', right = '' },
section_separators = { left = "", right = "" },
},
sections = {
lualine_x = {
-- specify full list of elements when adding custom things
{ "encoding" },
{ "fileformat" },
{ "filetype" },
{ lsp_clients, cond = hide_in_width },
},
},
},
}