From 14b3dab47666fa53ff7aaa4a25354ce9096840f6 Mon Sep 17 00:00:00 2001 From: Julia Lange Date: Wed, 17 Apr 2024 20:59:21 -0700 Subject: [PATCH] Neovim, Add c language support --- hmModules/apps/neovim/default.nix | 2 ++ hmModules/apps/neovim/plugin/lsp.nix | 2 ++ hmModules/apps/neovim/plugin/treesitter.nix | 7 ++++++- systems/pan/default.nix | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hmModules/apps/neovim/default.nix b/hmModules/apps/neovim/default.nix index 91b38c6..4407176 100644 --- a/hmModules/apps/neovim/default.nix +++ b/hmModules/apps/neovim/default.nix @@ -5,6 +5,7 @@ enable = lib.mkEnableOption "Enables neovim"; languages = { nix.enable = lib.mkEnableOption "Enables nix support"; + c.enable = lib.mkEnableOption "Enables c support"; }; plugins = { comments.enable = lib.mkEnableOption "Enables nvim-comment"; @@ -45,6 +46,7 @@ extraPackages = with pkgs; [ (lib.mkIf config.neovim.languages.nix.enable nil) + (lib.mkIf config.neovim.languages.c.enable libclang) ]; # Additional packages are added through imports diff --git a/hmModules/apps/neovim/plugin/lsp.nix b/hmModules/apps/neovim/plugin/lsp.nix index ae3806a..849c9cc 100644 --- a/hmModules/apps/neovim/plugin/lsp.nix +++ b/hmModules/apps/neovim/plugin/lsp.nix @@ -37,6 +37,8 @@ local capabilities = vim.lsp.protocol.make_client_capabilities() '' + lib.strings.optionalString cfgl.nix.enable '' require('lspconfig').nil_ls.setup {} + '' + lib.strings.optionalString cfgl.c.enable '' + require('lspconfig').clangd.setup {} ''; in with pkgs.vimPlugins; [ { diff --git a/hmModules/apps/neovim/plugin/treesitter.nix b/hmModules/apps/neovim/plugin/treesitter.nix index bf828b8..667fb3d 100644 --- a/hmModules/apps/neovim/plugin/treesitter.nix +++ b/hmModules/apps/neovim/plugin/treesitter.nix @@ -18,7 +18,12 @@ in { } ''; - treeplugs = p: lib.lists.optional cfgl.nix.enable p.tree-sitter-nix; + # 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 + ]; in with pkgs.vimPlugins; [ { plugin = (nvim-treesitter.withPlugins treeplugs); diff --git a/systems/pan/default.nix b/systems/pan/default.nix index fa85073..48daee2 100644 --- a/systems/pan/default.nix +++ b/systems/pan/default.nix @@ -29,6 +29,7 @@ neovim.enable = true; neovim.languages = { nix.enable = true; + c.enable = true; }; neovim.plugins = { comments.enable = true;