|
22 | 22 | passthru.vimPlugin = false; |
23 | 23 | }; |
24 | 24 |
|
25 | | - # build a vim plugin with the given name and arguments |
26 | | - # if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug |
27 | | - # instead |
| 25 | + # Build a Vim plugin with the given name and arguments. |
28 | 26 | buildPlug = attrs: let |
29 | 27 | pin = getPin attrs.pname; |
30 | 28 | in |
|
36 | 34 | // attrs |
37 | 35 | ); |
38 | 36 |
|
| 37 | + # Build a given Treesitter grammar. |
39 | 38 | buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars); |
40 | 39 |
|
41 | 40 | pluginBuilders = { |
|
48 | 47 | doCheck = false; |
49 | 48 | }; |
50 | 49 |
|
| 50 | + # Get plugins built from source from self.packages |
| 51 | + # If adding a new plugin to be built from source, it must also be inherited |
| 52 | + # here. |
51 | 53 | inherit (inputs.self.packages.${pkgs.stdenv.system}) blink-cmp avante-nvim; |
52 | 54 | }; |
53 | 55 |
|
|
71 | 73 | # Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to |
72 | 74 | # generate a wrapped Neovim package. |
73 | 75 | neovim-wrapped = inputs.mnw.lib.wrap {inherit pkgs;} { |
| 76 | + appName = "nvf"; |
74 | 77 | neovim = config.vim.package; |
| 78 | + initLua = config.vim.builtLuaConfigRC; |
| 79 | + luaFiles = config.vim.extraLuaFiles; |
| 80 | + |
| 81 | + # Plugin configurations |
75 | 82 | plugins = { |
76 | 83 | start = buildConfigPlugins config.vim.startPlugins; |
77 | 84 | opt = buildConfigPlugins config.vim.optPlugins; |
78 | 85 | }; |
79 | | - appName = "nvf"; |
80 | | - extraBinPath = config.vim.extraPackages; |
81 | | - initLua = config.vim.builtLuaConfigRC; |
82 | | - luaFiles = config.vim.extraLuaFiles; |
| 86 | + |
| 87 | + # Providers for Neovim |
83 | 88 | providers = { |
| 89 | + ruby.enable = config.vim.withRuby; |
| 90 | + nodeJs.enable = config.vim.withNodeJs; |
84 | 91 | python3 = { |
85 | 92 | enable = config.vim.withPython3; |
86 | 93 | extraPackages = ps: map (flip builtins.getAttr ps) config.vim.python3Packages; |
87 | 94 | }; |
88 | | - ruby.enable = config.vim.withRuby; |
89 | | - nodeJs.enable = config.vim.withNodeJs; |
90 | 95 | }; |
| 96 | + |
| 97 | + # Aliases to link `nvim` to |
91 | 98 | aliases = lib.optional config.vim.viAlias "vi" ++ lib.optional config.vim.vimAlias "vim"; |
92 | 99 |
|
| 100 | + # Additional packages or Lua packages to be made available to Neovim |
| 101 | + extraBinPath = config.vim.extraPackages; |
93 | 102 | extraLuaPackages = ps: map (flip builtins.getAttr ps) config.vim.luaPackages; |
94 | 103 | }; |
95 | 104 |
|
| 105 | + # A store path representing the built Lua configuration. |
96 | 106 | dummyInit = pkgs.writeText "nvf-init.lua" config.vim.builtLuaConfigRC; |
| 107 | + |
97 | 108 | # Additional helper scripts for printing and displaying nvf configuration |
98 | 109 | # in your commandline. |
99 | 110 | printConfig = pkgs.writers.writeDashBin "nvf-print-config" "cat ${dummyInit}"; |
|
106 | 117 | paths = [neovim-wrapped printConfig printConfigPath]; |
107 | 118 | postBuild = "echo Helpers added"; |
108 | 119 |
|
109 | | - # Allow evaluating config.vim, i.e., config.vim from the packages' passthru |
110 | | - # attribute. For example, packages.x86_64-linux.neovim.passthru.neovimConfig |
111 | | - # will return the configuration in full. |
112 | | - passthru.neovimConfig = config.vim; |
| 120 | + passthru = { |
| 121 | + # Allow evaluating config.vim, i.e., config.vim from the packages' passthru |
| 122 | + # attribute. For example, packages.x86_64-linux.neovim.passthru.neovimConfig |
| 123 | + # will return the configuration in full. |
| 124 | + neovimConfig = config.vim; |
| 125 | + |
| 126 | + # Also expose the helper scripts in passthru. |
| 127 | + nvfPrintConfig = printConfig; |
| 128 | + nvfPrintConfigPath = printConfigPath; |
| 129 | + |
| 130 | + # In systems where we only have a package and no module, this can be used |
| 131 | + # to access the built init.lua |
| 132 | + initLua = dummyInit; |
| 133 | + }; |
113 | 134 |
|
114 | 135 | meta = |
115 | 136 | neovim-wrapped.meta |
|
0 commit comments