diff options
Diffstat (limited to '.config/nvim/lua/plugins/lsp.lua')
-rw-r--r-- | .config/nvim/lua/plugins/lsp.lua | 153 |
1 files changed, 117 insertions, 36 deletions
diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 029a0f1..e710fd7 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua | |||
@@ -1,9 +1,10 @@ | |||
1 | return { | 1 | return { |
2 | { | 2 | { |
3 | "neovim/nvim-lspconfig", | 3 | "neovim/nvim-lspconfig", |
4 | event = { "BufReadPost", "BufNewFile" }, | ||
5 | cmd = { "LspInfo", "LspInstall", "LspUninstall" }, | ||
4 | dependencies = { | 6 | dependencies = { |
5 | "j-hui/fidget.nvim", | 7 | "j-hui/fidget.nvim", |
6 | "folke/neodev.nvim", | ||
7 | "RRethy/vim-illuminate", | 8 | "RRethy/vim-illuminate", |
8 | "hrsh7th/cmp-nvim-lsp", | 9 | "hrsh7th/cmp-nvim-lsp", |
9 | }, | 10 | }, |
@@ -14,9 +15,6 @@ return { | |||
14 | map('n', '[d', vim.diagnostic.goto_prev, "lsp: goto previous diagnostic") | 15 | map('n', '[d', vim.diagnostic.goto_prev, "lsp: goto previous diagnostic") |
15 | map('n', ']d', vim.diagnostic.goto_next, "lsp: goto next diagnostic") | 16 | map('n', ']d', vim.diagnostic.goto_next, "lsp: goto next diagnostic") |
16 | 17 | ||
17 | -- neodev setup before lsp config | ||
18 | require("neodev").setup() | ||
19 | |||
20 | -- set up cool signs for diagnostics | 18 | -- set up cool signs for diagnostics |
21 | local signs = { Error = " ", Warn = "", Hint = "", Info = "" } | 19 | local signs = { Error = " ", Warn = "", Hint = "", Info = "" } |
22 | for type, icon in pairs(signs) do | 20 | for type, icon in pairs(signs) do |
@@ -72,6 +70,29 @@ return { | |||
72 | local capabilities = vim.lsp.protocol.make_client_capabilities() | 70 | local capabilities = vim.lsp.protocol.make_client_capabilities() |
73 | capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) | 71 | capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) |
74 | 72 | ||
73 | -- misc. | ||
74 | local lspconfig = require('lspconfig') | ||
75 | local servers = { 'ts_ls', 'jsonls', 'eslint', 'cssls', 'html', 'vala_ls', 'gopls' } | ||
76 | for _, lsp in pairs(servers) do | ||
77 | lspconfig[lsp].setup { | ||
78 | on_attach = on_attach, | ||
79 | capabilites = capabilities, | ||
80 | } | ||
81 | end | ||
82 | |||
83 | -- typst/tinymist | ||
84 | require("lspconfig")["tinymist"].setup({ | ||
85 | on_attach = on_attach, | ||
86 | capabilities = capabilities, | ||
87 | single_file_support = true, | ||
88 | root_dir = function() | ||
89 | return vim.fn.getcwd() | ||
90 | end, | ||
91 | settings = { | ||
92 | formatterMode = "typstyle", | ||
93 | } | ||
94 | }) | ||
95 | |||
75 | -- lua | 96 | -- lua |
76 | require("lspconfig")["lua_ls"].setup({ | 97 | require("lspconfig")["lua_ls"].setup({ |
77 | on_attach = on_attach, | 98 | on_attach = on_attach, |
@@ -120,10 +141,52 @@ return { | |||
120 | -- efm | 141 | -- efm |
121 | require("lspconfig")["efm"].setup({ | 142 | require("lspconfig")["efm"].setup({ |
122 | on_attach = on_attach, | 143 | on_attach = on_attach, |
123 | filetypes = { 'sh' }, | 144 | settings = { |
124 | capabilities = capabilities | 145 | initializationOptions = { |
146 | documentFormatting = true, | ||
147 | documentRangeFormatting = true, | ||
148 | hover = true, | ||
149 | documentSymbol = true, | ||
150 | codeAction = true, | ||
151 | completion = true | ||
152 | } | ||
153 | }, | ||
154 | capabilities = capabilities, | ||
155 | filetypes = { 'sh', 'tex' }, | ||
125 | }) | 156 | }) |
126 | 157 | ||
158 | require("lspconfig")["harper_ls"].setup { | ||
159 | on_attach = on_attach, | ||
160 | capabilities = capabilities, | ||
161 | settings = { | ||
162 | ["harper-ls"] = { | ||
163 | linters = { | ||
164 | spell_check = true, | ||
165 | spelled_numbers = false, | ||
166 | an_a = true, | ||
167 | sentence_capitalization = true, | ||
168 | unclosed_quotes = true, | ||
169 | wrong_quotes = false, | ||
170 | long_sentences = true, | ||
171 | repeated_words = true, | ||
172 | spaces = true, | ||
173 | matcher = true, | ||
174 | correct_number_suffix = true, | ||
175 | number_suffix_capitalization = true, | ||
176 | multiple_sequential_pronouns = true, | ||
177 | linking_verbs = false, | ||
178 | avoid_curses = true, | ||
179 | } | ||
180 | } | ||
181 | }, | ||
182 | filetypes = { | ||
183 | "markdown", "rust", "typescript", "typescriptreact", "javascript", "python", "c", "cpp", "ruby", "swift", "csharp", "toml", "lua", "gitcommit", "java", "html", "vimwiki", "tex" | ||
184 | }, | ||
185 | root_dir = function(fname) | ||
186 | return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1]) | ||
187 | end, | ||
188 | } | ||
189 | |||
127 | -- ltex | 190 | -- ltex |
128 | require("lspconfig")["ltex"].setup({ | 191 | require("lspconfig")["ltex"].setup({ |
129 | capabilities = capabilities, | 192 | capabilities = capabilities, |
@@ -135,51 +198,38 @@ return { | |||
135 | log_level = "none", | 198 | log_level = "none", |
136 | } | 199 | } |
137 | end, | 200 | end, |
201 | filetypes = { "bib", "gitcommit", "markdown", "org", "plaintex", "rst", "rnoweb", "tex", "pandoc", "quarto", "rmd", "context", "mail", "text" }, | ||
138 | settings = { | 202 | settings = { |
139 | ltex = { | 203 | ltex = { |
140 | -- my settings here | 204 | enabled = { "bibtex", "gitcommit", "markdown", "org", "tex", "restructuredtext", "rsweave", "latex", "quarto", "rmd", "context", "mail", "plaintext" } |
141 | } | 205 | } |
142 | } | 206 | } |
143 | }) | 207 | }) |
144 | 208 | ||
145 | -- rust-tools | 209 | vim.g.rustaceanvim = { |
146 | local rust_opts = { | 210 | -- Plugin configuration |
147 | tools = { | 211 | tools = { |
148 | runnables = { | ||
149 | use_telescope = true, | ||
150 | }, | ||
151 | inlay_hints = { | ||
152 | auto = true, | ||
153 | show_parameter_hints = true, | ||
154 | parameter_hints_prefix = "↸ ", | ||
155 | other_hints_prefix = "❱ ", | ||
156 | }, | ||
157 | }, | 212 | }, |
158 | 213 | -- LSP configuration | |
159 | -- all the opts to send to nvim-lspconfig | ||
160 | -- these override the defaults set by rust-tools.nvim | ||
161 | -- see https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#rust_analyzer | ||
162 | server = { | 214 | server = { |
163 | on_attach = on_attach, | 215 | on_attach = on_attach, |
164 | settings = { | 216 | vim.lsp.inlay_hint.enable(true), |
165 | -- to enable rust-analyzer settings visit: | 217 | default_settings = { |
166 | -- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc | 218 | -- rust-analyzer language server configuration |
167 | ["rust-analyzer"] = { | 219 | ['rust-analyzer'] = { |
168 | -- enable clippy on save | ||
169 | checkOnSave = { | ||
170 | command = "clippy", | ||
171 | }, | ||
172 | }, | 220 | }, |
173 | }, | 221 | }, |
174 | }, | 222 | }, |
223 | -- DAP configuration | ||
224 | dap = { | ||
225 | }, | ||
175 | } | 226 | } |
176 | |||
177 | require('rust-tools').setup(rust_opts) | ||
178 | end, | 227 | end, |
179 | }, | 228 | }, |
180 | { | 229 | { |
181 | "barreiroleo/ltex-extra.nvim", | 230 | "barreiroleo/ltex_extra.nvim", |
182 | event = "LspAttach", | 231 | ft = { "markdown", "tex" }, |
232 | dependencies = { "neovim/nvim-lspconfig" }, | ||
183 | }, | 233 | }, |
184 | { | 234 | { |
185 | "j-hui/fidget.nvim", | 235 | "j-hui/fidget.nvim", |
@@ -199,7 +249,38 @@ return { | |||
199 | }, | 249 | }, |
200 | }, | 250 | }, |
201 | { | 251 | { |
202 | "simrat39/rust-tools.nvim", | 252 | 'mrcjkb/rustaceanvim', |
203 | event = "LspAttach", | 253 | version = '^5', -- Recommended |
254 | lazy = false, -- This plugin is already lazy | ||
255 | }, | ||
256 | { | ||
257 | "folke/lazydev.nvim", | ||
258 | ft = "lua", | ||
259 | }, | ||
260 | { | ||
261 | 'fatih/vim-go' | ||
204 | }, | 262 | }, |
263 | { | ||
264 | "danymat/neogen", | ||
265 | config = true, | ||
266 | opts = { | ||
267 | snippet_engine = "luasnip", | ||
268 | languages = { | ||
269 | python = { | ||
270 | template = { | ||
271 | annotation_convention = "reST", | ||
272 | } | ||
273 | } | ||
274 | } | ||
275 | } | ||
276 | }, | ||
277 | { | ||
278 | 'marcelofern/vale.nvim', | ||
279 | config = function() | ||
280 | require("vale").setup({ | ||
281 | bin = "/usr/bin/vale", | ||
282 | vale_config_path = "$HOME/.config/vale/.vale.ini", | ||
283 | }) | ||
284 | end, | ||
285 | } | ||
205 | } | 286 | } |