From 8460677953576de36667a480544be46b839e2aed Mon Sep 17 00:00:00 2001 From: Fabrice Mouhartem Date: Tue, 1 Apr 2025 23:37:18 +0200 Subject: [PATCH] feat(lsp): Move LSP config for godot and rust for 0.11 --- lsp/gdscript.lua | 17 +++++++++++++++++ lsp/rust-analyzer.lua | 21 +++++++++++++++++++++ lua/lsp.lua | 33 +-------------------------------- 3 files changed, 39 insertions(+), 32 deletions(-) create mode 100644 lsp/gdscript.lua create mode 100644 lsp/rust-analyzer.lua diff --git a/lsp/gdscript.lua b/lsp/gdscript.lua new file mode 100644 index 0000000..c9603c6 --- /dev/null +++ b/lsp/gdscript.lua @@ -0,0 +1,17 @@ +local port = os.getenv 'GDScript_Port' or '6005' +local cmd = vim.lsp.rpc.connect('127.0.0.1', tonumber(port)) + +return { + default_config = { + cmd = cmd, + filetypes = { 'gd', 'gdscript', 'gdscript3' }, + root_markers = { '.git', 'project.godot' }, + }, + docs = { + description = [[ +https://github.com/godotengine/godot + +Language server for GDScript, used by Godot Engine. +]], + }, +} diff --git a/lsp/rust-analyzer.lua b/lsp/rust-analyzer.lua new file mode 100644 index 0000000..3a52eaf --- /dev/null +++ b/lsp/rust-analyzer.lua @@ -0,0 +1,21 @@ +return { + cmd = { 'rust-analyzer' }, + filetypes = { 'rust' }, + root_markers = { '.git', 'cargo.toml' }, + settings = { + imports = { + granularity = { + group = "module", + }, + prefix = "self", + }, + cargo = { + buildScripts = { + enable = true, + }, + }, + procMacro = { + enable = true + }, + } +} diff --git a/lua/lsp.lua b/lua/lsp.lua index a4da61b..b564fa2 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -137,37 +137,6 @@ mason_lspconfig.setup_handlers { } -- [[ System LSPs ]] -local lspconfig = require('lspconfig') -servers = { - rust_analyzer = { - ["rust-analyzer"] = { - imports = { - granularity = { - group = "module", - }, - prefix = "self", - }, - cargo = { - buildScripts = { - enable = true, - }, - }, - procMacro = { - enable = true - }, - } - }, - gdscript = {}, -} - -for server_name, server_settings in pairs(servers) do - lspconfig[server_name].setup { - capabilities = capabilities, - settings = server_settings, - filetypes = (servers[server_name] or {}).filetypes, - } -end - local setup_godot_dap = function() local dap = require("dap") @@ -190,6 +159,6 @@ local setup_godot_dap = function() end vim.diagnostic.config({ virtual_text = true }) -vim.lsp.enable({ "ltex_plus" }) +vim.lsp.enable({ "ltex_plus", "rust-analyzer", "gdscript" }) setup_godot_dap()