From 3f83961bbd0a03b1064d6538769b526d04fca9e9 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sat, 23 Jan 2021 14:34:49 +0100 Subject: LspInfo: make output more compact to save screen estate --- lua/lspconfig/lspinfo.lua | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'lua') 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\\|" .. -- cgit v1.2.3-70-g09d2