From 10c58ce06dfff90bab47b9b23dacb12c4d8711b4 Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Wed, 29 Nov 2023 04:27:07 +0000 Subject: [PATCH] nixvim: Make configuration proper module --- flake.nix | 9 +++++++-- sets/nixvim.nix | 13 ++++++++++--- sets/nvim.nix | 32 +++++++++++++++++--------------- system/gallus/default.nix | 8 ++------ 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/flake.nix b/flake.nix index 59b9f85..7683f4a 100644 --- a/flake.nix +++ b/flake.nix @@ -86,8 +86,13 @@ formatter = pkgs.nixfmt; packages = { jlink = pkgs.callPackage ./externals/packages/jlink { }; - nvim = inputs.nixvim.legacyPackages."${system}".makeNixvim - (import ./sets/nvim.nix { inherit pkgs inputs; }); + nvim = inputs.nixvim.legacyPackages."${system}".makeNixvimWithModule { + extraSpecialArgs = { inherit inputs; }; + module = import ./sets/nvim.nix { + path = [ ]; + inherit (pkgs) lib; + }; + }; }; }); } diff --git a/sets/nixvim.nix b/sets/nixvim.nix index 8b7cef1..6b727ee 100644 --- a/sets/nixvim.nix +++ b/sets/nixvim.nix @@ -1,4 +1,11 @@ -{ inputs, pkgs, ... }@args: { - imports = [ inputs.nixvim.nixosModules.nixvim ]; - programs.nixvim = import ./nvim.nix args // { enable = true; }; +{ inputs, lib, ... }@args: { + imports = [ + inputs.nixvim.nixosModules.nixvim + (import ./nvim.nix { + inherit lib; + path = [ "programs" "nixvim" ]; + }) + ]; + + programs.nixvim.enable = true; } diff --git a/sets/nvim.nix b/sets/nvim.nix index a4f5198..3e7950e 100644 --- a/sets/nvim.nix +++ b/sets/nvim.nix @@ -1,6 +1,8 @@ -{ pkgs, ... }: - -{ +{ lib, path }: +{ pkgs, config, ... }: +let setPath = if path == [ ] then [ "config" ] else path; +in lib.setAttrByPath setPath (let cfg = lib.getAttrFromPath path config; +in { vimAlias = true; enableMan = false; @@ -59,21 +61,21 @@ # LSP plugins.rust-tools = { - enable = true; + enable = cfg.plugins.lsp.enable; server.standalone = false; }; - plugins.clangd-extensions.enable = true; + plugins.clangd-extensions.enable = cfg.plugins.lsp.enable; plugins.lsp = { - enable = true; + enable = lib.mkDefault true; servers = { - clangd.enable = true; - java-language-server.enable = true; - jsonls.enable = true; - nil_ls.enable = true; - pylsp.enable = true; - texlab.enable = true; - tsserver.enable = true; - typst-lsp.enable = true; + clangd.enable = cfg.plugins.lsp.enable; + java-language-server.enable = cfg.plugins.lsp.enable; + jsonls.enable = cfg.plugins.lsp.enable; + nil_ls.enable = cfg.plugins.lsp.enable; + pylsp.enable = cfg.plugins.lsp.enable; + texlab.enable = cfg.plugins.lsp.enable; + tsserver.enable = cfg.plugins.lsp.enable; + typst-lsp.enable = cfg.plugins.lsp.enable; }; keymaps = { @@ -169,4 +171,4 @@ }) end ''; -} +}) diff --git a/system/gallus/default.nix b/system/gallus/default.nix index 61b36ca..06d508e 100644 --- a/system/gallus/default.nix +++ b/system/gallus/default.nix @@ -39,12 +39,8 @@ publish.enable = true; }; - # Require a lot of dependencies we don't use - programs.nixvim.plugins = { - rust-tools.enable = lib.mkForce false; - clangd-extensions.enable = lib.mkForce false; - lsp.enable = lib.mkForce false; - }; + # Requires a lot of dependencies we don't use + programs.nixvim.plugins.lsp.enable = false; environment.systemPackages = with pkgs; [ magic-wormhole