mirror of
https://github.com/He4eT/dotfiles.git
synced 2026-05-04 23:47:23 +00:00
nvim: inline mason-lsp config
This commit is contained in:
parent
78ca7e04d4
commit
41805c8b0f
1 changed files with 52 additions and 62 deletions
|
|
@ -531,6 +531,10 @@ local on_attach = function(_, bufnr)
|
||||||
end, { desc = 'Format current buffer with LSP' })
|
end, { desc = 'Format current buffer with LSP' })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
||||||
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
||||||
|
|
||||||
-- Enable the following language servers
|
-- Enable the following language servers
|
||||||
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
||||||
--
|
--
|
||||||
|
|
@ -538,6 +542,7 @@ end
|
||||||
-- the `settings` field of the server config. You must look up that documentation yourself.
|
-- the `settings` field of the server config. You must look up that documentation yourself.
|
||||||
local servers = {
|
local servers = {
|
||||||
lua_ls = {
|
lua_ls = {
|
||||||
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
workspace = { checkThirdParty = false },
|
workspace = { checkThirdParty = false },
|
||||||
telemetry = { enable = false },
|
telemetry = { enable = false },
|
||||||
|
|
@ -550,35 +555,8 @@ local servers = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
volar = {},
|
},
|
||||||
}
|
tsserver = {
|
||||||
|
|
||||||
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
||||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
|
||||||
|
|
||||||
-- Ensure the servers above are installed
|
|
||||||
local mason_lspconfig = require 'mason-lspconfig'
|
|
||||||
|
|
||||||
mason_lspconfig.setup {
|
|
||||||
ensure_installed = vim.tbl_keys(servers),
|
|
||||||
}
|
|
||||||
|
|
||||||
mason_lspconfig.setup_handlers {
|
|
||||||
function(server_name)
|
|
||||||
require('lspconfig')[server_name].setup {
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
settings = servers[server_name],
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
|
|
||||||
border = 'solid',
|
|
||||||
})
|
|
||||||
|
|
||||||
require('lspconfig').tsserver.setup {
|
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
init_options = {
|
init_options = {
|
||||||
|
|
@ -598,11 +576,6 @@ require('lspconfig').tsserver.setup {
|
||||||
-- like in moving an anonymous function to outer scope
|
-- like in moving an anonymous function to outer scope
|
||||||
-- https://github.com/jose-elias-alvarez/typescript.nvim/issues/17
|
-- https://github.com/jose-elias-alvarez/typescript.nvim/issues/17
|
||||||
['_typescript.rename'] = function(_, result)
|
['_typescript.rename'] = function(_, result)
|
||||||
local line = result.position.line
|
|
||||||
local character = result.position.character
|
|
||||||
local column = vim.str_byteindex(vim.fn.getline '.', character, true)
|
|
||||||
vim.api.nvim_win_set_cursor(0, { line + 1, column })
|
|
||||||
vim.lsp.buf.rename()
|
|
||||||
return result
|
return result
|
||||||
end,
|
end,
|
||||||
-- 'Go to definition' workaround
|
-- 'Go to definition' workaround
|
||||||
|
|
@ -612,8 +585,25 @@ require('lspconfig').tsserver.setup {
|
||||||
vim.lsp.handlers['textDocument/definition'](err, result, ...)
|
vim.lsp.handlers['textDocument/definition'](err, result, ...)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
volar = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require('mason-lspconfig').setup {
|
||||||
|
ensure_installed = vim.tbl_keys(servers),
|
||||||
|
handlers = {
|
||||||
|
function(server_name)
|
||||||
|
local server = servers[server_name] or {}
|
||||||
|
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
|
||||||
|
require('lspconfig')[server_name].setup(server)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||||
|
border = 'solid',
|
||||||
|
})
|
||||||
|
|
||||||
-- nvim-cmp setup
|
-- nvim-cmp setup
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require 'luasnip'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue