better
This commit is contained in:
+15
-10
@@ -1,16 +1,21 @@
|
||||
local fn = vim.fn
|
||||
|
||||
local function get_coc_lsp_client()
|
||||
local clients = vim.g.coc_service_initialized and vim.fn['CocAction']('services') or {}
|
||||
for _, client in pairs(clients) do
|
||||
if client['state'] == 'running' then
|
||||
local client_name = client['id']
|
||||
-- Remove 'languageserver.' prefix if it exists
|
||||
client_name = client_name:gsub('^languageserver%.', '')
|
||||
return client_name
|
||||
local get_active_lsp = function()
|
||||
local msg = "🚫"
|
||||
local buf_ft = vim.api.nvim_get_option_value("filetype", {})
|
||||
local clients = vim.lsp.get_clients { bufnr = 0 }
|
||||
if next(clients) == nil then
|
||||
return msg
|
||||
end
|
||||
|
||||
for _, client in ipairs(clients) do
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local filetypes = client.config.filetypes
|
||||
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||
return client.name
|
||||
end
|
||||
end
|
||||
return ''
|
||||
return msg
|
||||
end
|
||||
|
||||
local function spell()
|
||||
@@ -127,7 +132,7 @@ require("lualine").setup {
|
||||
color = { fg = "black", bg = "#f46868" },
|
||||
},
|
||||
{
|
||||
get_coc_lsp_client,
|
||||
get_active_lsp,
|
||||
icon = " LSP:",
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user