.config/nvim/lua/plugins/lsp.lua

changeset 1179
b0a0ba3240b5
parent 1178
8993dc4128de
equal deleted inserted replaced
1178:8993dc4128de 1179:b0a0ba3240b5
8 event = { "BufReadPre", "BufNewFile" }, 8 event = { "BufReadPre", "BufNewFile" },
9 dependencies = { 9 dependencies = {
10 { "williamboman/mason-lspconfig.nvim", config = true }, 10 { "williamboman/mason-lspconfig.nvim", config = true },
11 }, 11 },
12 config = function(_, _) 12 config = function(_, _)
13 local capabilities = require("cmp_nvim_lsp").default_capabilities() 13 local lspconfig = require("lspconfig")
14
15 lspconfig.util.default_config.capabilities = vim.tbl_deep_extend("force",
16 lspconfig.util.default_config.capabilities,
17 require("cmp_nvim_lsp").default_capabilities()
18 )
19
20 -- allow view / -R to also stop autostart. no other global flag for this.
21 lspconfig.util.default_config.autostart = not vim.list_contains(vim.v.argv, "-R")
14 22
15 require("mason-lspconfig").setup_handlers({ 23 require("mason-lspconfig").setup_handlers({
16 function(server) 24 function(server) lspconfig[server].setup({}) end,
17 require("lspconfig")[server].setup({ capabilities = capabilities })
18 end,
19 gopls = function() 25 gopls = function()
20 require("lspconfig").gopls.setup({ 26 lspconfig.gopls.setup({
21 capabilities = capabilities,
22 settings = { 27 settings = {
23 -- https://github.com/golang/tools/blob/master/gopls/doc/settings.md 28 -- https://github.com/golang/tools/blob/master/gopls/doc/settings.md
24 gopls = { 29 gopls = {
25 analyses = { 30 analyses = {
26 unusedvariable = true, 31 unusedvariable = true,
37 }, 42 },
38 }, 43 },
39 }) 44 })
40 end, 45 end,
41 solargraph = function() 46 solargraph = function()
42 require("lspconfig").solargraph.setup({ 47 lspconfig.solargraph.setup({
43 capabilities = capabilities,
44 init_options = { formatting = false }, 48 init_options = { formatting = false },
45 }) 49 })
46 end, 50 end,
47 }) 51 })
48 end, 52 end,

mercurial