Properly configured vue language server finally
- all language servers now use on_attach to get proper keybindings
This commit is contained in:
69
lua/lsp.lua
69
lua/lsp.lua
@@ -17,18 +17,10 @@ require('mason-lspconfig').setup({
|
|||||||
'yamlls',
|
'yamlls',
|
||||||
'tsserver',
|
'tsserver',
|
||||||
'gopls',
|
'gopls',
|
||||||
'vuels'
|
-- 'volar',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- Set different settings for different languages' LSP
|
|
||||||
-- LSP list: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
|
||||||
-- How to use setup({}): https://github.com/neovim/nvim-lspconfig/wiki/Understanding-setup-%7B%7D
|
|
||||||
-- - the settings table is sent to the LSP
|
|
||||||
-- - on_attach: a lua callback function to run after LSP attaches to a given buffer
|
|
||||||
local lspconfig = require('lspconfig')
|
|
||||||
|
|
||||||
-- Customized on_attach function
|
-- Customized on_attach function
|
||||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||||
local opts = { noremap = true, silent = true }
|
local opts = { noremap = true, silent = true }
|
||||||
@@ -64,28 +56,43 @@ local on_attach = function(client, bufnr)
|
|||||||
end, bufopts)
|
end, bufopts)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Configure each language
|
-- Set different settings for different languages' LSP
|
||||||
-- How to add LSP for a specific language?
|
-- LSP list: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
||||||
-- 1. use `:Mason` to install corresponding LSP
|
-- How to use setup({}): https://github.com/neovim/nvim-lspconfig/wiki/Understanding-setup-%7B%7D
|
||||||
-- 2. add configuration below
|
-- - the settings table is sent to the LSP
|
||||||
lspconfig.pylsp.setup({
|
-- - on_attach: a lua callback function to run after LSP attaches to a given buffer
|
||||||
|
local lspconfig = require('lspconfig')
|
||||||
|
|
||||||
|
-- from :h mason-lspconfig-automatic-server-setup
|
||||||
|
require('mason-lspconfig').setup_handlers({
|
||||||
|
-- The first entry (without a key) will be the default handler
|
||||||
|
-- and will be called for each installed server that doesn't have
|
||||||
|
-- a dedicated handler.
|
||||||
|
function(server_name) -- default handler (optional)
|
||||||
|
if server_name == 'tsserver' then
|
||||||
|
-- taken from https://github.com/vuejs/language-tools
|
||||||
|
-- If you are using mason.nvim, you can get the ts_plugin_path like this
|
||||||
|
local mason_registry = require('mason-registry')
|
||||||
|
local vue_language_server_path = mason_registry.get_package('vue-language-server'):get_install_path() ..
|
||||||
|
'/node_modules/@vue/language-server'
|
||||||
|
|
||||||
|
lspconfig[server_name].setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
})
|
init_options = {
|
||||||
lspconfig.vuels.setup({
|
plugins = {
|
||||||
on_attach = on_attach
|
{
|
||||||
})
|
name = '@vue/typescript-plugin',
|
||||||
lspconfig.rust_analyzer.setup({
|
location = vue_language_server_path,
|
||||||
on_attach = on_attach
|
languages = { 'vue' },
|
||||||
})
|
},
|
||||||
lspconfig.lua_ls.setup({
|
},
|
||||||
on_attach = on_attach
|
},
|
||||||
})
|
filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
|
||||||
lspconfig.yamlls.setup({
|
}
|
||||||
on_attach = on_attach
|
else
|
||||||
})
|
lspconfig[server_name].setup {
|
||||||
lspconfig.tsserver.setup({
|
|
||||||
on_attach = on_attach
|
|
||||||
})
|
|
||||||
lspconfig.gopls.setup({
|
|
||||||
on_attach = on_attach
|
on_attach = on_attach
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user