nvim/plug: +nvim-lspconfig@master
This plugin provides the tools for initializing language servers, using the builtin neovim LSP client. It provides the major low level glue for actually starting and configuring a given language server; however it **does not** ensure that the actual language server is present on the system / in PATH. That function is handled by mason / mason-lspconfig, which will prompt the user to install the necessary server(s) upon calling `lspconfig[$server].setup { ... }`. We provide a default on_attach function the sets up some default key maps for LSP related functionality, loading a user overridable map of language servers and their associated setup objects or functions. Note that "setting up" a language server is not the same as loading it, which is a considerably more expensive operation. Hence, we make no effort to lazily setup language servers.
This commit is contained in:
parent
bb937f9db7
commit
6c34c88896
|
@ -74,4 +74,35 @@ M.Buffer.N {
|
|||
CloseNetrw = B { 'Force close netrw windows', key = '<ESC>' }
|
||||
}
|
||||
|
||||
-- ###################################
|
||||
-- ## NORMAL LSP on_attach bindings ##
|
||||
-- ###################################
|
||||
M.Buffer.Lsp.N {
|
||||
{ mode = 'n' },
|
||||
|
||||
-- #####################
|
||||
-- ## Leader Mappings ##
|
||||
-- #####################
|
||||
--
|
||||
Leader = G {
|
||||
{ prefix = '<Leader>' },
|
||||
|
||||
-- ##################
|
||||
-- ## LSP Mappings ##
|
||||
-- ##################
|
||||
--
|
||||
RenameSymbol = B { 'Rename <cword> symbol' , key = 'rn' , action = vim.lsp.buf.rename , } ,
|
||||
FormatDocument = B { 'Format current document' , key = 'F' , action = vim.lsp.buf.formatting , } ,
|
||||
ShowSignature = B { 'Display function signature help of <cword> symbol' , key = 'K' , action = vim.lsp.buf.signature_help , } ,
|
||||
|
||||
},
|
||||
|
||||
-- ##################
|
||||
-- ## LSP Mappings ##
|
||||
-- ##################
|
||||
--
|
||||
GotoDefinition = B { 'Jump to definition of <cword> symbol' , key = 'gd' , action = vim.lsp.buf.definition , } ,
|
||||
ShowDocumentation = B { 'Display documentation of <cword> symbol' , key = 'K' , action = vim.lsp.buf.hover , } ,
|
||||
}
|
||||
|
||||
return M
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
return function()
|
||||
local lspconfig, util = require 'lspconfig', require 'psoxizsh.util'
|
||||
local keys, servers = require 'psoxizsh.key', require 'psoxizsh.lsp.servers'
|
||||
|
||||
local defaults = {}
|
||||
|
||||
-- This is the default key mappings that are applied on attaching to a LSP.
|
||||
defaults.on_attach = function(_, bnum)
|
||||
keys.Buffer.Lsp:register({ buffer = bnum })
|
||||
end
|
||||
|
||||
-- Ideally, this would be registered on some Psoxizsh.Plug.Post autocmd
|
||||
-- but I don't feel like refactoring psoxizsh.plugin now.
|
||||
--
|
||||
-- This is needed because many other lsp plugins expect:
|
||||
--
|
||||
-- 1. To be able to call "require 'lspconfig'" and not blow up (after lspconfig is loaded)
|
||||
-- 2. To be able to configure lspconfig's defaults before servers are setup (before lspconfig is loaded)
|
||||
--
|
||||
-- Therefore, we must defer actually loading servers themselves until
|
||||
-- after all other relevant plugins have had their say... but before
|
||||
-- packer_compiled is finished as otherwise we risk starting too late
|
||||
-- and skipping the first buffer neovim opens because we haven't
|
||||
-- configured our servers yet. Fun.
|
||||
--
|
||||
-- Currently this is called during nlsp-settings's config, but we might
|
||||
-- need to move this around
|
||||
_G.PsoxizshLoadLSPServers = function()
|
||||
-- Ensure we exit any active language servers in case of reloads
|
||||
vim.cmd 'LspStop'
|
||||
|
||||
local user = util.try_mconfig('config.lsp.servers')
|
||||
|
||||
for server, spec in pairs(servers:extend(user):get()) do
|
||||
spec(lspconfig[server], defaults)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -88,6 +88,11 @@ local plugins = {
|
|||
after = 'mason',
|
||||
config = require 'psoxizsh.plugins.config.mason-lsp'
|
||||
},
|
||||
{ 'neovim/nvim-lspconfig',
|
||||
as = 'lspconfig',
|
||||
after = { 'mason-lspconfig', 'cmp-nvim-lsp' },
|
||||
config = require 'psoxizsh.plugins.config.lspconfig'
|
||||
},
|
||||
{ 'vim-perl/vim-perl',
|
||||
ft = 'perl',
|
||||
run = 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny'
|
||||
|
|
Loading…
Reference in New Issue