From 19b1f317b176b702a95fd82d9992f5d35be46796 Mon Sep 17 00:00:00 2001 From: "Gustavo L de Mello (Guz)" Date: Thu, 5 Dec 2024 19:26:15 -0300 Subject: [PATCH] feat: add lspconfig support, with wrapped lsp's --- lua/dot013/plugins/lsp.lua | 40 ++++++++++++++++++++++++++++++++++++++ neovim.nix | 12 +++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 lua/dot013/plugins/lsp.lua diff --git a/lua/dot013/plugins/lsp.lua b/lua/dot013/plugins/lsp.lua new file mode 100644 index 0000000..db331a0 --- /dev/null +++ b/lua/dot013/plugins/lsp.lua @@ -0,0 +1,40 @@ +local lsps = { + ["lua_ls"] = { + on_init = function(client) + if client.workspace_folders then + local path = client.workspace_folders[1].name + if vim.loop.fs_stat(path .. "/.luarc.json") or vim.loop.fs_stat(path .. "/.luarc.jsonc") then + return + end + end + + client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, { + runtime = { + version = "LuaJIT", + }, + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME, + }, + }, + }) + end, + settings = { + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + }, + }, + }, +} + +return { + "nvim-lspconfig", + after = function() + local lsp = require("lspconfig") + for k, v in pairs(lsps) do + lsp[k].setup(v) + end + end, +} diff --git a/neovim.nix b/neovim.nix index a629dd2..ab500e3 100644 --- a/neovim.nix +++ b/neovim.nix @@ -12,6 +12,7 @@ catppuccin-nvim indent-blankline-nvim lze + nvim-lspconfig nvim-treesitter.withAllGrammars nvim-treesitter-textobjects nvim-treesitter-textsubjects @@ -32,6 +33,10 @@ tmux-nvim ]; + languageServers = with pkgs; [ + lua-language-server + ]; + foldPlugins = builtins.foldl' (acc: next: acc ++ [next] ++ (foldPlugins (next.dependencies or []))) []; startPluginsWithDeps = lib.unique (foldPlugins startPlugins); @@ -76,7 +81,12 @@ in name = "neovim-custom"; pname = "nvim"; - paths = [nvimPkg]; + paths = let + wrappedNvim = pkgs.writeShellScriptBin "nvim" '' + export PATH=${lib.makeBinPath languageServers}:$PATH + ${lib.getExe nvimPkg} "$@" + ''; + in [wrappedNvim]; nativeBuildInputs = [makeWrapper]; postBuild = '' wrapProgram $out/bin/nvim \