Closed uhooi closed 1 year ago
local conditions = require 'heirline.conditions' return { condition = conditions.lsp_attached, update = { 'LspAttach', 'LspDetach', 'WinEnter' }, provider = function(_) -- ' [lua_ls null-ls(stylua)]' return (' [%s]'):format(table.concat( vim .iter(vim.lsp.get_active_clients { bufnr = 0 }) :map(function(server) if server.name == 'null-ls' then -- null-lsの場合は実際に使っているソースを羅列して表示する return ('null-ls(%s)'):format(table.concat( vim .iter(require('null-ls.sources').get_available(vim.bo.filetype)) :map(function(source) return source.name end) :totable(), ',' )) else -- null-ls以外の場合はサーバー名をそのまま表示する return server.name end end) :totable(), ' ' )) end, hl = { fg = 'green', bold = true }, }
https://github.com/uga-rosa/dotfiles/blob/main/nvim/lua/rc/heirline/lsp.lua
local conditions = require("heirline.conditions") return { condition = conditions.lsp_attached, update = { "LspAttach", "LspDetach" }, provider = function() local names = {} for _, server in ipairs(vim.lsp.get_active_clients({ bufnr = 0 })) do table.insert(names, server.name) end return " " .. table.concat(names, ", ") end, hl = { fg = "green" }, }
https://vim-jp.slack.com/archives/C01LXT3BWBU/p1684745184367369
local lsp_names = { function() local servers = vim .iter(vim.lsp.get_active_clients({ bufnr = 0 })) :map(function(server) if server.name == 'null-ls' then return ('null-ls(%s)'):format(table.concat( vim .iter(require('null-ls.sources').get_available(vim.bo.filetype)) :map(function(source) return source.name end) :totable(), ',' )) else return server.name end end) :totable() return table.concat(servers, ', ') end, } lualine_x = { -- ... lsp_names, -- ... },
References
Heirline.nvim
https://github.com/uga-rosa/dotfiles/blob/main/nvim/lua/rc/heirline/lsp.lua
lualine.nvim
https://vim-jp.slack.com/archives/C01LXT3BWBU/p1684745184367369