aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2021-01-24 09:32:20 -0800
committerGitHub <noreply@github.com>2021-01-24 09:32:20 -0800
commit4c7eb86badd6480dec3caa4cee1da67bb2819428 (patch)
tree55d8706ac9c65e547a23f7cd93a7848a36a81859 /lua
parent[docgen] Update CONFIG.md (diff)
parent[docgen] Update README.md (diff)
downloadnvim-lspconfig-4c7eb86badd6480dec3caa4cee1da67bb2819428.tar
nvim-lspconfig-4c7eb86badd6480dec3caa4cee1da67bb2819428.tar.gz
nvim-lspconfig-4c7eb86badd6480dec3caa4cee1da67bb2819428.tar.bz2
nvim-lspconfig-4c7eb86badd6480dec3caa4cee1da67bb2819428.tar.lz
nvim-lspconfig-4c7eb86badd6480dec3caa4cee1da67bb2819428.tar.xz
nvim-lspconfig-4c7eb86badd6480dec3caa4cee1da67bb2819428.tar.zst
nvim-lspconfig-4c7eb86badd6480dec3caa4cee1da67bb2819428.zip
Merge pull request #690 from teto/compact-lsp-info
chore: make LspInfo output more compact
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/lspinfo.lua38
1 files changed, 22 insertions, 16 deletions
diff --git a/lua/lspconfig/lspinfo.lua b/lua/lspconfig/lspinfo.lua
index 902cd87e..5da8d2df 100644
--- a/lua/lspconfig/lspinfo.lua
+++ b/lua/lspconfig/lspinfo.lua
@@ -13,11 +13,16 @@ return function ()
local bufnr, win_id = win_info.bufnr, win_info.win_id
local buf_lines = {}
+
+ local buf_client_names = {}
+ for _, client in ipairs(buf_clients) do
+ table.insert(buf_client_names, client.name)
+ end
+
local header = {
- "Available servers:",
- "\t"..table.concat(vim.tbl_keys(configs), ', '),
+ "Configured servers: "..table.concat(vim.tbl_keys(configs), ', '),
"",
- "Clients attached to this buffer: "..tostring(#buf_clients)
+ tostring(#buf_clients).." client(s) attached to this buffer: "..table.concat(buf_client_names, ', '),
}
vim.list_extend(buf_lines, header)
@@ -38,14 +43,14 @@ return function ()
return cmd
end
+ local indent = " "
local function make_client_info(client)
return {
"",
- "Client: "..tostring(client.id),
- "\tname: "..client.name,
- "\troot: "..client.workspaceFolders[1].name,
- "\tfiletypes: "..table.concat(client.config.filetypes or {}, ', '),
- "\tcmd: "..remove_newlines(client.config.cmd),
+ indent.."Client: "..client.name.." (id "..tostring(client.id)..")",
+ indent.."\troot: "..client.workspaceFolders[1].name,
+ indent.."\tfiletypes: "..table.concat(client.config.filetypes or {}, ', '),
+ indent.."\tcmd: "..remove_newlines(client.config.cmd),
}
end
@@ -56,7 +61,7 @@ return function ()
local active_section_header = {
"",
- "Total active clients: "..tostring(#clients),
+ tostring(#clients).." active client(s): ",
}
vim.list_extend(buf_lines, active_section_header)
for _, client in ipairs(clients) do
@@ -65,7 +70,7 @@ return function ()
end
local matching_config_header = {
"",
- "Clients that match the current buffer filetype:",
+ "Clients that match the filetype "..buffer_filetype..":",
}
local cmd_not_found_msg = "False. Please check your path and ensure the server is installed"
vim.list_extend(buf_lines, matching_config_header)
@@ -86,12 +91,12 @@ return function ()
for _, filetype_match in ipairs(config.filetypes) do
if buffer_filetype == filetype_match then
local matching_config_info = {
- "",
- "Config: "..config.name,
- "\tcmd: "..cmd,
- "\tcmd is executable: ".. cmd_is_executable,
- "\tidentified root: "..(config.get_root_dir(buffer_dir) or "None"),
- "\tcustom handlers: "..table.concat(vim.tbl_keys(config.handlers), ", "),
+ indent.."",
+ indent.."Config: "..config.name,
+ indent.."\tcmd: "..cmd,
+ indent.."\tcmd is executable: ".. cmd_is_executable,
+ indent.."\tidentified root: "..(config.get_root_dir(buffer_dir) or "None"),
+ indent.."\tcustom handlers: "..table.concat(vim.tbl_keys(config.handlers), ", "),
}
vim.list_extend(buf_lines, matching_config_info)
end
@@ -108,6 +113,7 @@ return function ()
buf_lines = vim.lsp.util._trim_and_pad(buf_lines, { pad_left = 2, pad_top = 1})
vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, buf_lines )
vim.fn.matchadd("Title", table.concat(vim.tbl_keys(configs), '\\|'))
+ vim.fn.matchadd("Title", buffer_filetype)
vim.fn.matchadd("Error",
"No filetypes defined, please define filetypes in setup().\\|"..
"cmd not defined\\|" ..