aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig.lua
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2021-01-15 00:40:25 -0800
committerGitHub <noreply@github.com>2021-01-15 00:40:25 -0800
commit4e8b8de1b32e248eb5e14f498310dd6ebeabb26a (patch)
tree7286e0c861449e767d1cd9e6fc7e78402963ebe3 /lua/lspconfig.lua
parentMerge pull request #669 from mjlbach/fix_filetypes (diff)
parent[docgen] Update README.md (diff)
downloadnvim-lspconfig-4e8b8de1b32e248eb5e14f498310dd6ebeabb26a.tar
nvim-lspconfig-4e8b8de1b32e248eb5e14f498310dd6ebeabb26a.tar.gz
nvim-lspconfig-4e8b8de1b32e248eb5e14f498310dd6ebeabb26a.tar.bz2
nvim-lspconfig-4e8b8de1b32e248eb5e14f498310dd6ebeabb26a.tar.lz
nvim-lspconfig-4e8b8de1b32e248eb5e14f498310dd6ebeabb26a.tar.xz
nvim-lspconfig-4e8b8de1b32e248eb5e14f498310dd6ebeabb26a.tar.zst
nvim-lspconfig-4e8b8de1b32e248eb5e14f498310dd6ebeabb26a.zip
Merge pull request #661 from mjlbach/lspinfo_fix_display
LspInfo: fix display when client cmd contains newlines
Diffstat (limited to 'lua/lspconfig.lua')
-rw-r--r--lua/lspconfig.lua38
1 files changed, 26 insertions, 12 deletions
diff --git a/lua/lspconfig.lua b/lua/lspconfig.lua
index d84b8a01..78916010 100644
--- a/lua/lspconfig.lua
+++ b/lua/lspconfig.lua
@@ -40,15 +40,36 @@ function M._root._setup()
}
vim.list_extend(buf_lines, header)
- for _, client in ipairs(buf_clients) do
- local client_info = {
+ local function trim_whitespace(cmd)
+ local trimmed_cmd = {}
+ for _, str in ipairs(cmd) do
+ 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 = trim_whitespace(cmd)
+ cmd = table.concat(cmd, ' ')
+ return cmd
+ end
+
+ 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, ', '),
- "\tcmd: "..table.concat(client.config.cmd, ', '),
+ "\tcmd: "..remove_newlines(client.config.cmd),
}
+ end
+
+ for _, client in ipairs(buf_clients) do
+ local client_info = make_client_info(client)
vim.list_extend(buf_lines, client_info)
end
@@ -58,14 +79,7 @@ function M._root._setup()
}
vim.list_extend(buf_lines, active_section_header)
for _, client in ipairs(clients) do
- local client_info = {
- "",
- "Client: "..tostring(client.id),
- "\tname: "..client.name,
- "\troot: "..client.workspaceFolders[1].name,
- "\tfiletypes: "..table.concat(client.config.filetypes, ', '),
- "\tcmd: "..table.concat(client.config.cmd, ', '),
- }
+ local client_info = make_client_info(client)
vim.list_extend(buf_lines, client_info)
end
local matching_config_header = {
@@ -77,7 +91,7 @@ function M._root._setup()
for _, config in pairs(configs) do
local cmd_is_executable, cmd
if config.cmd then
- cmd = table.concat(config.cmd, " ")
+ cmd = remove_newlines(config.cmd)
if vim.fn.executable(config.cmd[1]) == 1 then
cmd_is_executable = "True"
else