aboutsummaryrefslogtreecommitdiffstats
path: root/plugin
diff options
context:
space:
mode:
authorRaphael <glepnir@neovim.pro>2022-08-26 20:38:35 +0800
committerGitHub <noreply@github.com>2022-08-26 20:38:35 +0800
commit03981bd991fe700c5a870d0a1422812045426781 (patch)
tree3e492986231b3f89aefbd8b379e1cec99838f56d /plugin
parentfix: lspstart should be work without arg (#2090) (diff)
downloadnvim-lspconfig-03981bd991fe700c5a870d0a1422812045426781.tar
nvim-lspconfig-03981bd991fe700c5a870d0a1422812045426781.tar.gz
nvim-lspconfig-03981bd991fe700c5a870d0a1422812045426781.tar.bz2
nvim-lspconfig-03981bd991fe700c5a870d0a1422812045426781.tar.lz
nvim-lspconfig-03981bd991fe700c5a870d0a1422812045426781.tar.xz
nvim-lspconfig-03981bd991fe700c5a870d0a1422812045426781.tar.zst
nvim-lspconfig-03981bd991fe700c5a870d0a1422812045426781.zip
feat: improve LspInfo (#2081)
* feat: improve LspInfo * feat: update README for highlight * fix: wrong typo * fix: ci failed * fix: remove unnecessary block * fix: stylua format * fix: set default border to none * fix: update the doc * fix: define names in if statement * fix: use default_options to set border * fix: use available servers list * fix: fixup * fix: format by stylua * fix: use bufdelete event * fix: format * fix: add tips * fix: stylua format * fix: use wrap * fix: add 122 to luacheck ignore * fix: reset the default options * fix: merge master * fix: remove unecessary code * feat: update the highlight group * feat: update doc for highlight * fix: remove highlig from README * fix: remae highlight group in doc
Diffstat (limited to 'plugin')
-rw-r--r--plugin/lspconfig.lua25
1 files changed, 19 insertions, 6 deletions
diff --git a/plugin/lspconfig.lua b/plugin/lspconfig.lua
index 5d4a8c92..05f42199 100644
--- a/plugin/lspconfig.lua
+++ b/plugin/lspconfig.lua
@@ -1,3 +1,5 @@
+local api = vim.api
+
if vim.g.lspconfig ~= nil then
return
end
@@ -22,7 +24,7 @@ end
local lsp_complete_configured_servers = function(arg)
return completion_sort(vim.tbl_filter(function(s)
return s:sub(1, #arg) == arg
- end, vim.tbl_keys(require 'lspconfig.configs')))
+ end, require('lspconfig.util').available_servers()))
end
local lsp_get_active_client_ids = function(arg)
@@ -46,15 +48,25 @@ local get_clients_from_cmd_args = function(arg)
return vim.tbl_values(result)
end
+for group, hi in pairs {
+ LspInfoBorder = { link = 'Label', default = true },
+ LspInfoList = { link = 'Function', default = true },
+ LspInfoTip = { link = 'Comment', default = true },
+ LspInfoTitle = { link = 'Title', default = true },
+ LspInfoFiletype = { link = 'Type', default = true },
+} do
+ api.nvim_set_hl(0, group, hi)
+end
+
-- Called from plugin/lspconfig.vim because it requires knowing that the last
-- script in scriptnames to be executed is lspconfig.
-vim.api.nvim_create_user_command('LspInfo', function()
+api.nvim_create_user_command('LspInfo', function()
require 'lspconfig.ui.lspinfo'()
end, {
desc = 'Displays attached, active, and configured language servers',
})
-vim.api.nvim_create_user_command('LspStart', function(info)
+api.nvim_create_user_command('LspStart', function(info)
local server_name = string.len(info.args) > 0 and info.args or nil
if server_name then
local config = require('lspconfig.configs')[server_name]
@@ -73,7 +85,8 @@ end, {
nargs = '?',
complete = lsp_complete_configured_servers,
})
-vim.api.nvim_create_user_command('LspRestart', function(info)
+
+api.nvim_create_user_command('LspRestart', function(info)
for _, client in ipairs(get_clients_from_cmd_args(info.args)) do
client.stop()
vim.defer_fn(function()
@@ -86,7 +99,7 @@ end, {
complete = lsp_get_active_client_ids,
})
-vim.api.nvim_create_user_command('LspStop', function(info)
+api.nvim_create_user_command('LspStop', function(info)
local current_buf = vim.api.nvim_get_current_buf()
for _, client in ipairs(get_clients_from_cmd_args(info.args)) do
local filetypes = client.config.filetypes
@@ -100,7 +113,7 @@ end, {
complete = lsp_get_active_client_ids,
})
-vim.api.nvim_create_user_command('LspLog', function()
+api.nvim_create_user_command('LspLog', function()
vim.cmd(string.format('tabnew %s', vim.lsp.get_log_path()))
end, {
desc = 'Opens the Nvim LSP client log.',