aboutsummaryrefslogtreecommitdiffstats
path: root/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
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')
-rw-r--r--lua/lspconfig.lua38
-rw-r--r--lua/lspconfig/julials.lua43
2 files changed, 49 insertions, 32 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
diff --git a/lua/lspconfig/julials.lua b/lua/lspconfig/julials.lua
index c72ae52e..35a1c2a1 100644
--- a/lua/lspconfig/julials.lua
+++ b/lua/lspconfig/julials.lua
@@ -1,29 +1,32 @@
local configs = require 'lspconfig/configs'
local util = require 'lspconfig/util'
+local cmd = {
+ "julia",
+ "--startup-file=no",
+ "--history-file=no",
+ "-e", [[
+ using Pkg;
+ Pkg.instantiate()
+ using LanguageServer; using SymbolServer;
+ depot_path = get(ENV, "JULIA_DEPOT_PATH", "")
+ project_path = dirname(something(Base.current_project(pwd()), Base.load_path_expand(LOAD_PATH[2])))
+ # Make sure that we only load packages from this environment specifically.
+ @info "Running language server" env=Base.load_path()[1] pwd() project_path depot_path
+ server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path);
+ server.runlinter = true;
+ run(server);
+ ]]
+};
+
configs.julials = {
default_config = {
- on_new_config = function(new_config,new_root_dir)
+ cmd = cmd;
+ on_new_config = function(new_config, _)
local server_path = vim.fn.system("julia -e 'print(Base.find_package(\"LanguageServer\"))'")
- local cmd = {
- "julia",
- "--project="..server_path:sub(0,-19),
- "--startup-file=no",
- "--history-file=no",
- "-e", [[
- using Pkg;
- Pkg.instantiate()
- using LanguageServer; using SymbolServer;
- depot_path = get(ENV, "JULIA_DEPOT_PATH", "")
- project_path = dirname(something(Base.current_project(pwd()), Base.load_path_expand(LOAD_PATH[2])))
- # Make sure that we only load packages from this environment specifically.
- @info "Running language server" env=Base.load_path()[1] pwd() project_path depot_path
- server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path);
- server.runlinter = true;
- run(server);
- ]]
- };
- new_config.cmd = cmd
+ local new_cmd = vim.deepcopy(cmd)
+ table.insert(new_cmd, 2, "--project="..server_path:sub(0,-19))
+ new_config.cmd = new_cmd
end,
filetypes = {'julia'};
root_dir = function(fname)