From 1b6627bcbe7f91f09b6d8f136b4328ea793592eb Mon Sep 17 00:00:00 2001 From: Julia Lange Date: Tue, 23 Apr 2024 23:17:10 -0700 Subject: [PATCH] neovim, add rust language support --- hmModules/apps/neovim/default.nix | 13 ++++++++++--- hmModules/apps/neovim/plugin/lsp.nix | 2 ++ hmModules/apps/neovim/plugin/treesitter.nix | 3 ++- systems/pan/default.nix | 3 ++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/hmModules/apps/neovim/default.nix b/hmModules/apps/neovim/default.nix index ecfb29b..3557f90 100644 --- a/hmModules/apps/neovim/default.nix +++ b/hmModules/apps/neovim/default.nix @@ -4,8 +4,9 @@ options.neovim = { enable = lib.mkEnableOption "Enables neovim"; languages = { - nix.enable = lib.mkEnableOption "Enables nix support"; c.enable = lib.mkEnableOption "Enables c support"; + nix.enable = lib.mkEnableOption "Enables nix support"; + rust.enable = lib.mkEnableOption "Enables rust support"; }; plugins = { comments.enable = lib.mkEnableOption "Enables nvim-comment"; @@ -46,8 +47,9 @@ ''; extraPackages = with pkgs; [ - (lib.mkIf config.neovim.languages.nix.enable nil) (lib.mkIf config.neovim.languages.c.enable libclang) + (lib.mkIf config.neovim.languages.nix.enable nil) + (lib.mkIf config.neovim.languages.rust.enable rust-analyzer) ]; # Additional packages are added through imports @@ -91,6 +93,10 @@ vim-nix ]); + rust-pkg = lopts cfgl.rust.enable (with pkgs.vimPlugins; [ + rustaceanvim + ]); + wiki = lopts cfgp.wiki.enable (with pkgs.vimPlugins; [ { plugin = vimwiki; @@ -107,7 +113,8 @@ ''; } ]); - in comments ++ fugitive ++ luasnip-pkg ++ lualine ++ nix-pkg ++ wiki; + in comments ++ fugitive ++ luasnip-pkg ++ lualine ++ + nix-pkg ++ rust-pkg ++ wiki; }; }; } diff --git a/hmModules/apps/neovim/plugin/lsp.nix b/hmModules/apps/neovim/plugin/lsp.nix index 849c9cc..bd06204 100644 --- a/hmModules/apps/neovim/plugin/lsp.nix +++ b/hmModules/apps/neovim/plugin/lsp.nix @@ -39,6 +39,8 @@ require('lspconfig').nil_ls.setup {} '' + lib.strings.optionalString cfgl.c.enable '' require('lspconfig').clangd.setup {} + '' + lib.strings.optionalString cfgl.rust.enable '' + require('lspconfig').rustaceanvim.setup {} ''; in with pkgs.vimPlugins; [ { diff --git a/hmModules/apps/neovim/plugin/treesitter.nix b/hmModules/apps/neovim/plugin/treesitter.nix index 667fb3d..43b2d28 100644 --- a/hmModules/apps/neovim/plugin/treesitter.nix +++ b/hmModules/apps/neovim/plugin/treesitter.nix @@ -21,8 +21,9 @@ in { # I've tried many things, and can't get treesitter plugins changing # dynamically. For not just have them always loaded regardless of config treeplugs = p: [ - p.tree-sitter-nix p.tree-sitter-c + p.tree-sitter-nix + p.tree-sitter-rust ]; in with pkgs.vimPlugins; [ { diff --git a/systems/pan/default.nix b/systems/pan/default.nix index d05f21e..ebe826b 100644 --- a/systems/pan/default.nix +++ b/systems/pan/default.nix @@ -29,8 +29,9 @@ neovim.enable = true; neovim.languages = { - nix.enable = true; c.enable = true; + nix.enable = true; + rust.enable = true; }; neovim.plugins = { comments.enable = true;