-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnvim-lspconfig.lua
More file actions
184 lines (169 loc) · 5.15 KB
/
nvim-lspconfig.lua
File metadata and controls
184 lines (169 loc) · 5.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
return {
"neovim/nvim-lspconfig",
dependencies = {
"nvim-tree/nvim-web-devicons",
"folke/trouble.nvim",
"saghen/blink.cmp",
"williamboman/mason-lspconfig.nvim",
},
event = "VeryLazy",
config = function()
-- Prepare completion
local on_attach = function(client, _)
-- Mappings.
vim.keymap.set("n", "<leader><space>c", vim.lsp.buf.declaration, { desc = "Go to declaration" })
vim.keymap.set("n", "<leader><space>D", function()
require("telescope.builtin").lsp_definitions({ jump_type = "never" })
end, { desc = "Go to definition" })
vim.keymap.set("n", "<leader><space>h", vim.lsp.buf.hover, { desc = "Show hover" })
vim.keymap.set("n", "<leader><space>i", vim.lsp.buf.implementation, { desc = "Go to implementation" })
vim.keymap.set("n", "<leader><space>S", vim.lsp.buf.signature_help, { desc = "Show signature help" })
vim.keymap.set("n", "<leader><space>R", vim.lsp.buf.rename, { desc = "Rename" })
vim.keymap.set("n", "<leader><space>r", function()
require("telescope.builtin").lsp_references()
end, { desc = "Show references" })
vim.keymap.set("n", "<leader><space>d", vim.diagnostic.open_float, { desc = "Show diagnostics" })
vim.keymap.set("n", "<leader><space>i", vim.lsp.buf.code_action, { desc = "Show code actions" })
-- Set some keybinds conditional on server capabilities
if client.server_capabilities.document_formatting then
vim.keymap.set("n", "<space>=", vim.lsp.buf.formatting, { desc = "Format" })
elseif client.server_capabilities.document_range_formatting then
vim.keymap.set("n", "<space>=", vim.lsp.buf.formatting, { desc = "Format" })
end
-- Virtual line stuff
vim.diagnostic.config({
virtual_lines = { current_line = true },
underline = { severity = vim.diagnostic.severity.WARN }, -- underlines for warnings and errors only
virtual_text = {
prefix = function(diagnostic)
if diagnostic.severity == vim.diagnostic.severity.ERROR then
return ""
elseif diagnostic.severity == vim.diagnostic.severity.WARN then
return ""
elseif diagnostic.severity == vim.diagnostic.severity.INFO then
return ""
else
return ""
end
end,
source = "if_many",
spacing = 4,
},
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "",
[vim.diagnostic.severity.WARN] = "",
[vim.diagnostic.severity.INFO] = "",
[vim.diagnostic.severity.HINT] = "",
},
},
})
end
local capabilities = require("blink.cmp").get_lsp_capabilities()
local yaml_capabilities = vim.lsp.protocol.make_client_capabilities()
---@diagnostic disable: undefined-field
yaml_capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true,
}
---@diagnostic enable: undefined-field
vim.lsp.config("ts_ls", {
on_attach = on_attach,
capabilities = capabilities,
})
vim.lsp.enable("ts_ls")
vim.lsp.config("gopls", {
on_attach = on_attach,
capabilities = capabilities,
settings = {
gopls = {
gofumpt = true,
staticcheck = true,
usePlaceholders = true,
analyses = {
unusedparams = true,
fieldalignment = true,
shadow = true,
},
codelenses = {
test = true,
tidy = true,
upgrade_dependency = true,
},
completeUnimported = true,
directoryFilters = { "-vendor" },
buildFlags = { "-tags=integration" },
},
},
})
vim.lsp.enable("gopls")
-- local ruby_cmd = { "ruby-lsp" }
-- vim.lsp.config("ruby_lsp", {
-- on_attach = on_attach,
-- cmd = ruby_cmd,
-- capabilities = capabilities,
-- })
-- vim.lsp.enable("ruby_lsp")
vim.env.SRB_SKIP_GEM_RBIS = 1
vim.lsp.config("sorbet", {
cmd = { "bundle", "exec", "srb", "tc", "--lsp" },
on_attach = on_attach,
capabilities = capabilities,
})
vim.lsp.enable("sorbet")
vim.lsp.config("vale_ls", {
on_attach = on_attach,
capabilities = capabilities,
})
vim.lsp.enable("vale_ls")
vim.lsp.config("eslint", {
on_attach = on_attach,
capabilities = capabilities,
})
vim.lsp.enable("eslint")
vim.lsp.config("lua_ls", {
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
diagnostics = {
globals = { "vim" },
},
workspace = {
-- Make the server aware of Neovim runtime files
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
-- Depending on the usage, you might want to add additional paths here.
"${3rd}/luv/library",
-- "${3rd}/busted/library",
},
},
telemetry = {
enable = false,
},
},
},
on_attach = on_attach,
capabilities = capabilities,
})
vim.lsp.enable("lua_ls")
vim.lsp.config("yamlls", {
on_attach = on_attach,
capabilities = yaml_capabilities,
})
vim.lsp.enable("yamlls")
vim.lsp.config("jqls", {
on_attach = on_attach,
capabilities = capabilities,
})
vim.lsp.enable("jqls")
vim.lsp.config("jsonls", {
on_attach = on_attach,
capabilities = capabilities,
})
vim.lsp.enable("jsonls")
end,
}