diff options
| author | Filip Wandzio <contact@philw.dev> | 2025-10-12 13:56:19 +0200 |
|---|---|---|
| committer | Filip Wandzio <contact@philw.dev> | 2025-10-12 13:56:19 +0200 |
| commit | 1cebfd8c89a469abc06420293f879427337a138e (patch) | |
| tree | 5c8455930f7080b49240285033e497498ad3a29e /init.lua | |
| parent | b2f30008cdd0c959100e1cb8dc6cbe47cea1b408 (diff) | |
| download | neovim-1cebfd8c89a469abc06420293f879427337a138e.tar.gz neovim-1cebfd8c89a469abc06420293f879427337a138e.zip | |
Ensure nvim v3.0.0 LSP api compliance
Diffstat (limited to 'init.lua')
| -rw-r--r-- | init.lua | 53 |
1 files changed, 42 insertions, 11 deletions
| @@ -241,28 +241,59 @@ require("lazy").setup( | |||
| 241 | local lsp_servers = { | 241 | local lsp_servers = { |
| 242 | clangd = {filetypes = {"c", "h"}}, | 242 | clangd = {filetypes = {"c", "h"}}, |
| 243 | svelte = {filetypes = {"svelte"}}, | 243 | svelte = {filetypes = {"svelte"}}, |
| 244 | ts_ls = {filetypes = {"typescript", "typescriptreact", "javascript", "javascriptreact"}}, | 244 | ts_ls = {filetypes = { |
| 245 | rust_analyzer = {filetypes = {"rust"}} | 245 | "typescript", |
| 246 | "typescriptreact", | ||
| 247 | "javascript", | ||
| 248 | "javascriptreact"} | ||
| 249 | }, | ||
| 250 | rust_analyzer = { | ||
| 251 | filetypes = {"rust"}, | ||
| 252 | imports = { | ||
| 253 | granularity = { | ||
| 254 | group = "module", | ||
| 255 | }, | ||
| 256 | prefix = "self", | ||
| 257 | }, | ||
| 258 | cargo = { | ||
| 259 | buildScripts = { | ||
| 260 | enable = true, | ||
| 261 | }, | ||
| 262 | }, | ||
| 263 | procMacro = { | ||
| 264 | enable = true | ||
| 265 | }, | ||
| 266 | } | ||
| 246 | } | 267 | } |
| 247 | 268 | ||
| 248 | local function server_maps(opts) | 269 | local function server_maps(opts) |
| 249 | local buf = opts.buffer | 270 | local buf = opts.buffer |
| 250 | end | 271 | end |
| 251 | 272 | ||
| 273 | |||
| 274 | |||
| 275 | local capabilities = vim.lsp.protocol.make_client_capabilities() | ||
| 276 | capabilities = require("coq").lsp_ensure_capabilities(capabilities) | ||
| 277 | |||
| 252 | for server_name, config in pairs(lsp_servers) do | 278 | for server_name, config in pairs(lsp_servers) do |
| 253 | require("lspconfig")[server_name].setup( | 279 | vim.api.nvim_create_autocmd("FileType", { |
| 254 | coq.lsp_ensure_capabilities( | 280 | pattern = config.filetypes, |
| 255 | { | 281 | callback = function() |
| 282 | vim.lsp.start({ | ||
| 283 | name = server_name, | ||
| 284 | cmd = vim.lsp.get_server_capabilities(server_name).cmd or { server_name }, | ||
| 285 | root_dir = vim.fs.dirname(vim.api.nvim_buf_get_name(0)), | ||
| 286 | capabilities = capabilities, | ||
| 287 | settings = config.settings, | ||
| 256 | on_attach = function(client, bufnr) | 288 | on_attach = function(client, bufnr) |
| 257 | server_maps({buffer = bufnr}) | 289 | server_maps({buffer = bufnr}) |
| 258 | end, | 290 | end |
| 259 | filetypes = config.filetypes, | 291 | }) |
| 260 | settings = config.settings or {} | 292 | end |
| 261 | } | 293 | }) |
| 262 | ) | ||
| 263 | ) | ||
| 264 | end | 294 | end |
| 265 | 295 | ||
| 296 | |||
| 266 | set_highlights() | 297 | set_highlights() |
| 267 | 298 | ||
| 268 | vim.g.mapleader = " " | 299 | vim.g.mapleader = " " |
