From 346077c0e0e6630dc2d55a8826cebdc7151617a7 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sun, 22 Dec 2024 00:04:13 -0500 Subject: [PATCH] refactor(nvim): move packages out of config to devShells --- .../neovim/langs/bash/default.nix | 1 + .../langs/c-lang/{devShell.nix => shell.nix} | 0 .../neovim/langs/csharp/default.nix | 91 ++++++++++--------- .../neovim/langs/csharp/shell.nix | 12 +++ .../neovim/langs/java/default.nix | 17 +--- .../neovim/langs/json/default.nix | 11 +-- .../neovim/langs/json/shell.nix | 12 +++ .../neovim/langs/lua/default.nix | 9 +- homeManagerModules/neovim/langs/lua/shell.nix | 10 ++ .../neovim/langs/markdown/default.nix | 12 +-- .../neovim/langs/markdown/shell.nix | 16 ++++ .../neovim/langs/nix-lang/default.nix | 1 + .../neovim/langs/python/default.nix | 1 + .../neovim/langs/rust/shell.nix | 16 ++++ .../neovim/langs/web/default.nix | 21 +---- homeManagerModules/neovim/langs/web/shell.nix | 21 +++++ 16 files changed, 144 insertions(+), 107 deletions(-) rename homeManagerModules/neovim/langs/c-lang/{devShell.nix => shell.nix} (100%) create mode 100644 homeManagerModules/neovim/langs/csharp/shell.nix create mode 100644 homeManagerModules/neovim/langs/json/shell.nix create mode 100644 homeManagerModules/neovim/langs/lua/shell.nix create mode 100644 homeManagerModules/neovim/langs/markdown/shell.nix create mode 100644 homeManagerModules/neovim/langs/rust/shell.nix create mode 100644 homeManagerModules/neovim/langs/web/shell.nix diff --git a/homeManagerModules/neovim/langs/bash/default.nix b/homeManagerModules/neovim/langs/bash/default.nix index 3e4167f2..19625147 100644 --- a/homeManagerModules/neovim/langs/bash/default.nix +++ b/homeManagerModules/neovim/langs/bash/default.nix @@ -21,6 +21,7 @@ in { viAlias = true; vimAlias = true; + # We keep the packages here because shell scripts are too common extraPackages = attrValues { inherit (pkgs.nodePackages) diff --git a/homeManagerModules/neovim/langs/c-lang/devShell.nix b/homeManagerModules/neovim/langs/c-lang/shell.nix similarity index 100% rename from homeManagerModules/neovim/langs/c-lang/devShell.nix rename to homeManagerModules/neovim/langs/c-lang/shell.nix diff --git a/homeManagerModules/neovim/langs/csharp/default.nix b/homeManagerModules/neovim/langs/csharp/default.nix index f38c05f4..3ad470ce 100644 --- a/homeManagerModules/neovim/langs/csharp/default.nix +++ b/homeManagerModules/neovim/langs/csharp/default.nix @@ -4,22 +4,16 @@ self: { pkgs, ... }: let - inherit (lib) attrValues mkIf; inherit (self.lib.${pkgs.system}) buildPlugin; inherit (self.inputs) vimplugin-roslyn-nvim-src; + inherit (lib) mkIf; + cfg = config.programs.neovim; in { config = mkIf cfg.enable { programs = { neovim = { - extraPackages = attrValues { - inherit - (pkgs) - roslyn-ls - ; - }; - extraLuaConfig = # lua '' @@ -27,46 +21,53 @@ in { pattern = { 'cs' }, command = 'setlocal ts=4 sw=4 sts=0 expandtab', }); - - vim.api.nvim_create_autocmd('User', { - pattern = 'RoslynInitialized', - callback = function() - vim.lsp.inlay_hint.enable(); - end, - }); - - require('roslyn').setup({ - config = { - capabilities = require('cmp_nvim_lsp').default_capabilities(), - - on_attach = function() - vim.lsp.inlay_hint.enable(); - end, - - settings = { - ["csharp|inlay_hints"] = { - csharp_enable_inlay_hints_for_implicit_object_creation = true, - csharp_enable_inlay_hints_for_implicit_variable_types = true, - csharp_enable_inlay_hints_for_lambda_parameter_types = true, - csharp_enable_inlay_hints_for_types = true, - dotnet_enable_inlay_hints_for_indexer_parameters = true, - dotnet_enable_inlay_hints_for_literal_parameters = true, - dotnet_enable_inlay_hints_for_object_creation_parameters = true, - dotnet_enable_inlay_hints_for_other_parameters = true, - dotnet_enable_inlay_hints_for_parameters = true, - dotnet_suppress_inlay_hints_for_parameters_that_differ_only_by_suffix = true, - dotnet_suppress_inlay_hints_for_parameters_that_match_argument_name = true, - dotnet_suppress_inlay_hints_for_parameters_that_match_method_intent = true, - }, - }, - }, - - exe = 'Microsoft.CodeAnalysis.LanguageServer', - }); ''; plugins = [ - (buildPlugin "roslyn-nvim" vimplugin-roslyn-nvim-src) + { + plugin = buildPlugin "roslyn-nvim" vimplugin-roslyn-nvim-src; + type = "lua"; + config = + # lua + '' + vim.api.nvim_create_autocmd('User', { + pattern = 'RoslynInitialized', + + callback = function() + vim.lsp.inlay_hint.enable(); + end, + }); + + require('roslyn').setup({ + config = { + capabilities = require('cmp_nvim_lsp').default_capabilities(), + + on_attach = function() + vim.lsp.inlay_hint.enable(); + end, + + settings = { + ["csharp|inlay_hints"] = { + csharp_enable_inlay_hints_for_implicit_object_creation = true, + csharp_enable_inlay_hints_for_implicit_variable_types = true, + csharp_enable_inlay_hints_for_lambda_parameter_types = true, + csharp_enable_inlay_hints_for_types = true, + dotnet_enable_inlay_hints_for_indexer_parameters = true, + dotnet_enable_inlay_hints_for_literal_parameters = true, + dotnet_enable_inlay_hints_for_object_creation_parameters = true, + dotnet_enable_inlay_hints_for_other_parameters = true, + dotnet_enable_inlay_hints_for_parameters = true, + dotnet_suppress_inlay_hints_for_parameters_that_differ_only_by_suffix = true, + dotnet_suppress_inlay_hints_for_parameters_that_match_argument_name = true, + dotnet_suppress_inlay_hints_for_parameters_that_match_method_intent = true, + }, + }, + }, + + exe = 'Microsoft.CodeAnalysis.LanguageServer', + }); + ''; + } ]; }; }; diff --git a/homeManagerModules/neovim/langs/csharp/shell.nix b/homeManagerModules/neovim/langs/csharp/shell.nix new file mode 100644 index 00000000..220f4e4a --- /dev/null +++ b/homeManagerModules/neovim/langs/csharp/shell.nix @@ -0,0 +1,12 @@ +{ + mkShell, + dotnetCorePackages, + roslyn-ls, + ... +}: +mkShell { + packages = [ + dotnetCorePackages.sdk_9_0 + roslyn-ls + ]; +} diff --git a/homeManagerModules/neovim/langs/java/default.nix b/homeManagerModules/neovim/langs/java/default.nix index b0a7d24d..e245e7e9 100644 --- a/homeManagerModules/neovim/langs/java/default.nix +++ b/homeManagerModules/neovim/langs/java/default.nix @@ -4,29 +4,21 @@ pkgs, ... }: let - inherit (lib) attrValues getExe mkIf; + inherit (lib) getExe mkIf; cfg = config.programs.neovim; - javaSdk = pkgs.temurin-bin-17; - javaPkgs = attrValues {inherit (pkgs) gradle maven;}; + javaSdk = pkgs.temurin-bin-21; in { config = mkIf cfg.enable { - home.packages = javaPkgs; - - xdg.dataFile.".gradle/gradle.properties".text = '' - org.gradle.java.home = ${javaSdk} - ''; - programs = { + # We keep the packages here because java is a bit complicated java = { enable = true; package = javaSdk; }; neovim = { - extraPackages = javaPkgs; - extraLuaConfig = # lua '' @@ -44,7 +36,6 @@ in { config = # lua '' - -- local startJdtls = function() local config = { capabilities = require('cmp_nvim_lsp').default_capabilities(), @@ -60,7 +51,7 @@ in { configuration = { runtimes = { { - name = 'JavaSE-17', + name = 'JavaSE-21', path = '${javaSdk}', }, }, diff --git a/homeManagerModules/neovim/langs/json/default.nix b/homeManagerModules/neovim/langs/json/default.nix index 93d45405..4e0b7cb6 100644 --- a/homeManagerModules/neovim/langs/json/default.nix +++ b/homeManagerModules/neovim/langs/json/default.nix @@ -1,24 +1,15 @@ { config, lib, - pkgs, ... }: let - inherit (lib) attrValues mkIf; + inherit (lib) mkIf; cfg = config.programs.neovim; in { config = mkIf cfg.enable { programs = { neovim = { - extraPackages = attrValues { - inherit - (pkgs) - vscode-langservers-extracted - yaml-language-server - ; - }; - extraLuaConfig = # lua '' diff --git a/homeManagerModules/neovim/langs/json/shell.nix b/homeManagerModules/neovim/langs/json/shell.nix new file mode 100644 index 00000000..d0f02c84 --- /dev/null +++ b/homeManagerModules/neovim/langs/json/shell.nix @@ -0,0 +1,12 @@ +{ + mkShell, + vscode-langservers-extracted, + yaml-language-server, + ... +}: +mkShell { + packages = [ + vscode-langservers-extracted + yaml-language-server + ]; +} diff --git a/homeManagerModules/neovim/langs/lua/default.nix b/homeManagerModules/neovim/langs/lua/default.nix index fe43a8df..454b76ab 100644 --- a/homeManagerModules/neovim/langs/lua/default.nix +++ b/homeManagerModules/neovim/langs/lua/default.nix @@ -4,7 +4,7 @@ pkgs, ... }: let - inherit (lib) attrValues mkIf; + inherit (lib) mkIf; cfg = config.programs.neovim; @@ -13,13 +13,6 @@ in { config = mkIf cfg.enable { programs = { neovim = { - extraPackages = attrValues { - inherit - (pkgs) - lua-language-server - ; - }; - plugins = [ { plugin = pkgs.vimPlugins.neodev-nvim; diff --git a/homeManagerModules/neovim/langs/lua/shell.nix b/homeManagerModules/neovim/langs/lua/shell.nix new file mode 100644 index 00000000..97af32b7 --- /dev/null +++ b/homeManagerModules/neovim/langs/lua/shell.nix @@ -0,0 +1,10 @@ +{ + mkShell, + lua-language-server, + ... +}: +mkShell { + packages = [ + lua-language-server + ]; +} diff --git a/homeManagerModules/neovim/langs/markdown/default.nix b/homeManagerModules/neovim/langs/markdown/default.nix index da1544ea..dd7b0f61 100644 --- a/homeManagerModules/neovim/langs/markdown/default.nix +++ b/homeManagerModules/neovim/langs/markdown/default.nix @@ -9,7 +9,7 @@ self: { inherit (self.inputs) vimplugin-easytables-src; inherit (self.lib.${pkgs.system}) buildPlugin; - inherit (lib) attrValues concatStringsSep mkIf; + inherit (lib) concatStringsSep mkIf; cfg = config.programs.neovim; isServer = osConfig.roles.server.sshd.enable or false; @@ -22,16 +22,6 @@ in { config = mkIf cfg.enable { programs = { neovim = { - extraPackages = attrValues { - inherit - (pkgs) - pandoc - texlab - texliveFull - rubber - ; - }; - extraLuaConfig = # lua '' diff --git a/homeManagerModules/neovim/langs/markdown/shell.nix b/homeManagerModules/neovim/langs/markdown/shell.nix new file mode 100644 index 00000000..d26c2d93 --- /dev/null +++ b/homeManagerModules/neovim/langs/markdown/shell.nix @@ -0,0 +1,16 @@ +{ + mkShell, + pandoc, + texlab, + texliveFull, + rubber, + ... +}: +mkShell { + packages = [ + pandoc + texlab + texliveFull + rubber + ]; +} diff --git a/homeManagerModules/neovim/langs/nix-lang/default.nix b/homeManagerModules/neovim/langs/nix-lang/default.nix index bc3f251a..272c30e4 100644 --- a/homeManagerModules/neovim/langs/nix-lang/default.nix +++ b/homeManagerModules/neovim/langs/nix-lang/default.nix @@ -29,6 +29,7 @@ in { } ]; + # We keep the packages here home.packages = attrValues { inherit defaultFormatter diff --git a/homeManagerModules/neovim/langs/python/default.nix b/homeManagerModules/neovim/langs/python/default.nix index d727afdd..c4dd2634 100644 --- a/homeManagerModules/neovim/langs/python/default.nix +++ b/homeManagerModules/neovim/langs/python/default.nix @@ -8,6 +8,7 @@ cfg = config.programs.neovim; + # We keep the packages here because python is a bit complicated and common pythonPkgs = py: (attrValues { inherit (py) python-lsp-server; diff --git a/homeManagerModules/neovim/langs/rust/shell.nix b/homeManagerModules/neovim/langs/rust/shell.nix new file mode 100644 index 00000000..3360aeb5 --- /dev/null +++ b/homeManagerModules/neovim/langs/rust/shell.nix @@ -0,0 +1,16 @@ +{ + mkShell, + cargo, + rustc, + rust-analyzer, + rustfmt, + ... +}: +mkShell { + packages = [ + cargo + rustc + rust-analyzer + rustfmt + ]; +} diff --git a/homeManagerModules/neovim/langs/web/default.nix b/homeManagerModules/neovim/langs/web/default.nix index 414b725a..08d4c77e 100644 --- a/homeManagerModules/neovim/langs/web/default.nix +++ b/homeManagerModules/neovim/langs/web/default.nix @@ -7,7 +7,7 @@ self: { inherit (self.inputs) vimplugin-ts-error-translator-src; inherit (self.lib.${pkgs.system}) buildPlugin; - inherit (lib) attrValues mkIf; + inherit (lib) mkIf; cfg = config.programs.neovim; in { @@ -16,25 +16,6 @@ in { neovim = { withNodeJs = true; - extraPackages = attrValues { - inherit - (pkgs) - neovim-node-client - nodejs_latest - vscode-langservers-extracted - ; - - inherit - (pkgs.nodePackages) - npm - ; - - inherit - (self.packages.${pkgs.system}) - some-sass-language-server - ; - }; - extraLuaConfig = # lua '' diff --git a/homeManagerModules/neovim/langs/web/shell.nix b/homeManagerModules/neovim/langs/web/shell.nix new file mode 100644 index 00000000..7866b255 --- /dev/null +++ b/homeManagerModules/neovim/langs/web/shell.nix @@ -0,0 +1,21 @@ +{ + mkShell, + neovim-node-client, + nodejs_latest, + vscode-langservers-extracted, + nodePackages, + self, + system, + ... +}: +mkShell { + packages = [ + neovim-node-client + nodejs_latest + vscode-langservers-extracted + + nodePackages.npm + + self.packages.${system}.some-sass-language-server + ]; +}