feat(nvim): add lsp client module for lualine

This commit is contained in:
Sergio Laín 2024-02-23 01:07:32 +01:00
parent a1c64a76c9
commit c6912fb80f
No known key found for this signature in database
GPG key ID: 14C9B8080681777B

View file

@ -1,3 +1,24 @@
local lsp = function()
local buf_clients = vim.lsp.get_active_clients({ bufnr = 0 })
if #buf_clients == 0 then
return "LSP Inactive"
end
local buf_client_names = {}
-- add client
for _, client in pairs(buf_clients) do
if client.name ~= "null-ls" and client.name ~= "copilot" then
table.insert(buf_client_names, client.name)
end
end
local unique_client_names = table.concat(buf_client_names, ", ")
local language_servers = string.format(" %s", unique_client_names)
return language_servers
end
return {
"nvim-lualine/lualine.nvim",
opts = function(_, opts)
@ -5,6 +26,7 @@ return {
opts.options.section_separators = { left = "", right = "" }
table.remove(opts.sections.lualine_x, 1)
table.insert(opts.sections.lualine_x, 2, lsp)
opts.sections.lualine_a = { { "mode", icon = "" } }
opts.sections.lualine_y = { { "progress", icon = "", separator = " ", padding = { left = 1, right = 1 } } }
opts.sections.lualine_z = { { "location", icon = "", padding = { left = 1, right = 1 } } }