diff options
| author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-07-03 14:45:08 -0700 |
|---|---|---|
| committer | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-07-03 15:49:27 -0700 |
| commit | ec11b85df73cce4edb2925cb7f1d0e8db3a07b1c (patch) | |
| tree | 77d533dc9606ca7e9b30d1a96baebf3de325d2a8 /lua/lspconfig/lspinfo.lua | |
| parent | [docgen] Update CONFIG.md (diff) | |
| download | nvim-lspconfig-ec11b85df73cce4edb2925cb7f1d0e8db3a07b1c.tar nvim-lspconfig-ec11b85df73cce4edb2925cb7f1d0e8db3a07b1c.tar.gz nvim-lspconfig-ec11b85df73cce4edb2925cb7f1d0e8db3a07b1c.tar.bz2 nvim-lspconfig-ec11b85df73cce4edb2925cb7f1d0e8db3a07b1c.tar.lz nvim-lspconfig-ec11b85df73cce4edb2925cb7f1d0e8db3a07b1c.tar.xz nvim-lspconfig-ec11b85df73cce4edb2925cb7f1d0e8db3a07b1c.tar.zst nvim-lspconfig-ec11b85df73cce4edb2925cb7f1d0e8db3a07b1c.zip | |
ci: lint and format with stylua
Diffstat (limited to 'lua/lspconfig/lspinfo.lua')
| -rw-r--r-- | lua/lspconfig/lspinfo.lua | 101 |
1 files changed, 52 insertions, 49 deletions
diff --git a/lua/lspconfig/lspinfo.lua b/lua/lspconfig/lspinfo.lua index 34320e46..02b5fff0 100644 --- a/lua/lspconfig/lspinfo.lua +++ b/lua/lspconfig/lspinfo.lua @@ -1,13 +1,13 @@ -local configs = require 'lspconfig/configs' -local lspui = require 'lspconfig/_lspui' +local configs = require "lspconfig/configs" +local lspui = require "lspconfig/_lspui" -return function () +return function() -- These options need to be cached before switching to the floating -- buffer. local buf_clients = vim.lsp.buf_get_clients() local clients = vim.lsp.get_active_clients() local buffer_filetype = vim.bo.filetype - local buffer_dir = vim.fn.expand('%:p:h') + local buffer_dir = vim.fn.expand "%:p:h" local win_info = lspui.percentage_range_window(0.8, 0.7) local bufnr, win_id = win_info.bufnr, win_info.win_id @@ -20,27 +20,30 @@ return function () end local header = { - "Configured servers: "..table.concat(vim.tbl_keys(configs), ', '), - "Neovim logs at: "..(vim.lsp.get_log_path()), + "Configured servers: " .. table.concat(vim.tbl_keys(configs), ", "), + "Neovim logs at: " .. (vim.lsp.get_log_path()), "", - tostring(#vim.tbl_keys(buf_clients)).." client(s) attached to this buffer: "..table.concat(buf_client_names, ', '), + tostring(#vim.tbl_keys(buf_clients)) .. " client(s) attached to this buffer: " .. table.concat( + buf_client_names, + ", " + ), } vim.list_extend(buf_lines, header) local function trim_whitespace(cmd) local trimmed_cmd = {} for _, str in pairs(cmd) do - table.insert(trimmed_cmd, str:match'^%s*(.*)') + table.insert(trimmed_cmd, str:match "^%s*(.*)") end return trimmed_cmd end local function remove_newlines(cmd) cmd = trim_whitespace(cmd) - cmd = table.concat(cmd, ' ') - cmd = vim.split(cmd, '\n') + cmd = table.concat(cmd, " ") + cmd = vim.split(cmd, "\n") cmd = trim_whitespace(cmd) - cmd = table.concat(cmd, ' ') + cmd = table.concat(cmd, " ") return cmd end @@ -52,32 +55,32 @@ return function () end return { "", - 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), - indent.."\t"..server_specific_info, - "" + 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), + indent .. "\t" .. server_specific_info, + "", } end for _, client in pairs(buf_clients) do - local client_info = make_client_info(client) - vim.list_extend(buf_lines, client_info) + local client_info = make_client_info(client) + vim.list_extend(buf_lines, client_info) end local active_section_header = { "", - tostring(#clients).." active client(s): ", + tostring(#clients) .. " active client(s): ", } vim.list_extend(buf_lines, active_section_header) for _, client in pairs(clients) do - local client_info = make_client_info(client) - vim.list_extend(buf_lines, client_info) + local client_info = make_client_info(client) + vim.list_extend(buf_lines, client_info) end local matching_config_header = { "", - "Clients that match the filetype "..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) @@ -98,36 +101,36 @@ return function () for _, filetype_match in pairs(config.filetypes) do if buffer_filetype == filetype_match then local matching_config_info = { - 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), ", "), + 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) + vim.list_extend(buf_lines, matching_config_info) end end else - local matching_config_info = { - "", - "Config: "..config.name, - "\tfiletype: ".."No filetypes defined, please define filetypes in setup().", - } - vim.list_extend(buf_lines, matching_config_info) + local matching_config_info = { + "", + "Config: " .. config.name, + "\tfiletype: " .. "No filetypes defined, please define filetypes in setup().", + } + vim.list_extend(buf_lines, matching_config_info) end end buf_lines = vim.lsp.util._trim(buf_lines, {}) - vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, buf_lines ) - vim.api.nvim_buf_set_option(bufnr,'modifiable',false) - vim.api.nvim_buf_set_option(bufnr,'filetype','lspinfo') - local configs_pattern = '\\%(' .. table.concat(vim.tbl_keys(configs), '\\|') .. '\\)' - vim.cmd('syntax match Title /\\%(Client\\|Config\\):.*\\zs' .. configs_pattern .. '/') - vim.cmd('syntax match Identifier /filetypes:.*\\zs\\<' .. buffer_filetype .. '\\>/') - vim.fn.matchadd("Error", - "No filetypes defined, please define filetypes in setup().\\|".. - "cmd not defined\\|" .. - cmd_not_found_msg) - vim.api.nvim_buf_set_keymap(bufnr, 'n', '<esc>', '<cmd>bd<CR>', { noremap = true}) - vim.lsp.util.close_preview_autocmd({"BufHidden", "BufLeave"}, win_id) -end; + vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, buf_lines) + vim.api.nvim_buf_set_option(bufnr, "modifiable", false) + vim.api.nvim_buf_set_option(bufnr, "filetype", "lspinfo") + local configs_pattern = "\\%(" .. table.concat(vim.tbl_keys(configs), "\\|") .. "\\)" + vim.cmd("syntax match Title /\\%(Client\\|Config\\):.*\\zs" .. configs_pattern .. "/") + vim.cmd("syntax match Identifier /filetypes:.*\\zs\\<" .. buffer_filetype .. "\\>/") + vim.fn.matchadd( + "Error", + "No filetypes defined, please define filetypes in setup().\\|" .. "cmd not defined\\|" .. cmd_not_found_msg + ) + vim.api.nvim_buf_set_keymap(bufnr, "n", "<esc>", "<cmd>bd<CR>", { noremap = true }) + vim.lsp.util.close_preview_autocmd({ "BufHidden", "BufLeave" }, win_id) +end |
