summaryrefslogtreecommitdiffstats
path: root/common/vim.nix
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2023-01-18 13:39:42 +0100
committerMinijackson <minijackson@riseup.net>2023-01-18 13:39:42 +0100
commitcfdb14cf768f2971f6efe2e333c620571f30fad1 (patch)
tree7cf802c821abd12bf47a336784d444791ced6f83 /common/vim.nix
parent087b8756a6113c78ae20ee00c96c38f5922287a0 (diff)
downloadnixos-config-reborn-cfdb14cf768f2971f6efe2e333c620571f30fad1.tar.gz
nixos-config-reborn-cfdb14cf768f2971f6efe2e333c620571f30fad1.zip
vim: refactor, allowing different files like ftplugin
Diffstat (limited to 'common/vim.nix')
-rw-r--r--common/vim.nix48
1 files changed, 27 insertions, 21 deletions
diff --git a/common/vim.nix b/common/vim.nix
index 2f36958..bebfb0e 100644
--- a/common/vim.nix
+++ b/common/vim.nix
@@ -12,8 +12,8 @@ inputs: {
12 12
13 cfg = config.vim; 13 cfg = config.vim;
14 14
15 myConfigPackage = with lib; let 15 variables = with lib;
16 config = '' 16 pkgs.writeTextDir "lua/myVariables.lua" ''
17 -- Autogenerated variables from the NixOS configuration 17 -- Autogenerated variables from the NixOS configuration
18 18
19 ${(concatStringsSep 19 ${(concatStringsSep
@@ -21,35 +21,32 @@ inputs: {
21 (mapAttrsToList 21 (mapAttrsToList
22 (variable: value: "vim.g.${variable} = ${luaFormat.generate value}") 22 (variable: value: "vim.g.${variable} = ${luaFormat.generate value}")
23 cfg.variables))} 23 cfg.variables))}
24 '';
24 25
25 -- vim.lua from the NixOS configuration 26 extraConfig = pkgs.writeTextDir "lua/myExtraConfig.lua" ''
27 -- luaConfig from the NixOS configuration
26 28
27 ${builtins.readFile ../dotfiles/vim.lua} 29 ${cfg.luaConfig}
30 '';
28 31
29 -- luaConfig from the NixOS configuration 32 myGeneratedConfigPackage = pkgs.symlinkJoin {
33 name = "myGeneratedConfig-nvim";
34 paths = [variables extraConfig];
35 };
30 36
31 ${cfg.luaConfig} 37 myConfigPackage = pkgs.unstable.vimUtils.buildVimPluginFrom2Nix {
32 ''; 38 name = "myConfig-nvim";
33 in 39 src = ../dotfiles/vim;
34 pkgs.runCommand 40 };
35 "myConfig"
36 {
37 pname = "myConfig";
38 inherit config;
39 passAsFile = ["config"];
40 runLocal = true;
41 }
42 ''
43 mkdir -p "$out/lua"
44 mv "$configPath" "$out/lua/myConfig.lua"
45 '';
46 41
47 myNeovim = wrapNeovim neovim-unwrapped { 42 myNeovim = wrapNeovim neovim-unwrapped {
48 configure = { 43 configure = {
49 inherit (config.vim) beforePlugins; 44 inherit (config.vim) beforePlugins;
50 45
51 customRC = '' 46 customRC = ''
47 lua require("myVariables")
52 lua require("myConfig") 48 lua require("myConfig")
49 lua require("myExtraConfig")
53 50
54 ${cfg.extraConfig} 51 ${cfg.extraConfig}
55 ''; 52 '';
@@ -57,6 +54,7 @@ inputs: {
57 packages.myVimPackage = with vimPlugins; { 54 packages.myVimPackage = with vimPlugins; {
58 start = 55 start =
59 [ 56 [
57 myGeneratedConfigPackage
60 myConfigPackage 58 myConfigPackage
61 59
62 # Dependencies 60 # Dependencies
@@ -72,6 +70,15 @@ inputs: {
72 diffview-nvim 70 diffview-nvim
73 nvim-notify 71 nvim-notify
74 indent-blankline-nvim 72 indent-blankline-nvim
73 (pkgs.unstable.vimUtils.buildVimPluginFrom2Nix {
74 name = "oil.nvim";
75 src = pkgs.fetchFromGitHub {
76 owner = "stevearc";
77 repo = "oil.nvim";
78 rev = "abfc455f62dac385b0fc816f37c64dffead0bcf3";
79 hash = "sha256-oA220nzaBlFnJ0s23oabIW3XV1tWml5kBuBkTImOPjM=";
80 };
81 })
75 82
76 # Completion 83 # Completion
77 nvim-cmp 84 nvim-cmp
@@ -92,7 +99,6 @@ inputs: {
92 99
93 # Telescope 100 # Telescope
94 telescope-nvim 101 telescope-nvim
95 telescope-file-browser-nvim
96 telescope-ui-select-nvim 102 telescope-ui-select-nvim
97 103
98 # Treesitter 104 # Treesitter