aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/ui
diff options
context:
space:
mode:
authorRaphael <glepnir@neovim.pro>2022-09-14 22:48:23 +0800
committerGitHub <noreply@github.com>2022-09-14 22:48:23 +0800
commit51775b12cfbf1b6462c7b13cd020cc09e6767aea (patch)
tree88a10d5ed337f43457aa5cb4e155aff9a7dcd166 /lua/lspconfig/ui
parentdocs: update server_configurations.md (diff)
downloadnvim-lspconfig-51775b12cfbf1b6462c7b13cd020cc09e6767aea.tar
nvim-lspconfig-51775b12cfbf1b6462c7b13cd020cc09e6767aea.tar.gz
nvim-lspconfig-51775b12cfbf1b6462c7b13cd020cc09e6767aea.tar.bz2
nvim-lspconfig-51775b12cfbf1b6462c7b13cd020cc09e6767aea.tar.lz
nvim-lspconfig-51775b12cfbf1b6462c7b13cd020cc09e6767aea.tar.xz
nvim-lspconfig-51775b12cfbf1b6462c7b13cd020cc09e6767aea.tar.zst
nvim-lspconfig-51775b12cfbf1b6462c7b13cd020cc09e6767aea.zip
fix: check cmd type equals function (#2142)
* fix: check cmd type equals function * fix: set meg in cmd field when is function * fix: format with stylua * fix: remove unused variable * fix: improve cmd check * fix: check executable in a table * fix: improve * fix: use underline instead of unused param
Diffstat (limited to 'lua/lspconfig/ui')
-rw-r--r--lua/lspconfig/ui/lspinfo.lua23
1 files changed, 16 insertions, 7 deletions
diff --git a/lua/lspconfig/ui/lspinfo.lua b/lua/lspconfig/ui/lspinfo.lua
index 2ece965c..611d8006 100644
--- a/lua/lspconfig/ui/lspinfo.lua
+++ b/lua/lspconfig/ui/lspinfo.lua
@@ -36,17 +36,26 @@ local function remove_newlines(cmd)
return cmd
end
+local cmd_type = {
+ ['function'] = function(_)
+ return '<function>', 'NA'
+ end,
+ ['table'] = function(config)
+ local cmd = remove_newlines(config.cmd)
+ if vim.fn.executable(config.cmd[1]) == 1 then
+ return cmd, 'true'
+ end
+ return cmd, error_messages.cmd_not_found
+ end,
+}
+
local function make_config_info(config, bufnr)
local config_info = {}
config_info.name = config.name
config_info.helptags = {}
+
if config.cmd then
- config_info.cmd = remove_newlines(config.cmd)
- if vim.fn.executable(config.cmd[1]) == 1 then
- config_info.cmd_is_executable = 'true'
- else
- config_info.cmd_is_executable = error_messages.cmd_not_found
- end
+ config_info.cmd, config_info.cmd_is_executable = cmd_type[type(config.cmd)](config)
else
config_info.cmd = 'cmd not defined'
config_info.cmd_is_executable = 'NA'
@@ -104,7 +113,7 @@ end
local function make_client_info(client)
local client_info = {}
- client_info.cmd = remove_newlines(client.config.cmd)
+ client_info.cmd = cmd_type[type(client.config.cmd)](client.config)
if client.workspaceFolders then
client_info.root_dir = client.workspaceFolders[1].name
else