Skip to content

Commit 77296cc

Browse files
authored
feat(wrapperModules.neovim): config.hosts.ruby.gemdir (#194)
also improved tips and tricks documentation
1 parent 0f68698 commit 77296cc

File tree

2 files changed

+87
-5
lines changed

2 files changed

+87
-5
lines changed

wrapperModules/n/neovim/default-config.nix

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,12 @@
339339
config.package = lib.makeOverridable pkgs.bundlerEnv {
340340
name = "neovim-ruby-host";
341341
postBuild = "ln -sf ${pkgs.ruby}/bin/* $out/bin";
342-
gemdir = "${pkgs.path}/pkgs/applications/editors/neovim/ruby_provider";
342+
gemdir = config.gemdir;
343+
};
344+
options.gemdir = lib.mkOption {
345+
type = wlib.types.stringable;
346+
default = "${pkgs.path}/pkgs/applications/editors/neovim/ruby_provider";
347+
description = "The path to the ruby gem directory with the neovim gem as required by `pkgs.bundlerEnv`";
343348
};
344349
config.exePath = "bin/neovim-ruby-host";
345350
config.binName = "neovim-ruby-host";

wrapperModules/n/neovim/post_desc.md

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@ By default, the specs will run after it. Add `before = [ "INIT_MAIN" ]` to the s
66

77
---
88

9+
- Your `config.settings.config_directory` can point to an impure path (or lua inline value)
10+
11+
Use this for a quick feedback mode while editing, and then switch it back to the pure path when you are done! (or make an option for it)
12+
13+
---
14+
15+
- lazy loading
16+
17+
If you mark a spec as lazy, (or mark a parent spec and don't override the value in the child spec by default),
18+
it will be placed in `pack/myNeovimPackages/opt/<pname>` on the runtime path.
19+
20+
It will not be loaded yet. Use `vim.cmd.packadd("<pname>")` to load it via `lua` (or `vimscript` or `fennel`) at a time of your choosing.
21+
22+
There are great plugins for this.
23+
24+
See [lze](https://github.com/BirdeeHub/lze) and [lz.n](https://github.com/nvim-neorocks/lz.n), which work beautifully with this method of installing plugins.
25+
26+
They also work great with the builtin `neovim` plugin manager, `vim.pack.add`!
27+
28+
---
29+
930
- Use `nvim-lib.mkPlugin` to build plugins from sources outside nixpkgs (e.g., git flake inputs)
1031

1132
```nix
@@ -21,10 +42,6 @@ config.specs.treesj = config.nvim-lib.mkPlugin "treesj" inputs.treesj;
2142

2243
---
2344

24-
- Use `specMaps` for advanced spec processing only when `specMods` and `specCollect` is not flexible enough
25-
26-
---
27-
2845
- Make a new host!
2946

3047
```nix
@@ -69,3 +86,63 @@ config.specMods = { parentSpec, ... }: {
6986
config.collateGrammars = lib.mkDefault (parentSpec.collateGrammars or true);
7087
};
7188
```
89+
90+
---
91+
92+
- Use `specMaps` for advanced spec processing only when `specMods` and `specCollect` is not flexible enough
93+
94+
---
95+
96+
- building many plugins from outside nixpkgs at once
97+
98+
In your flake inputs, if you named your inputs like so:
99+
100+
```nix
101+
inputs.plugins-treesitter-textobjects = {
102+
url = "github:nvim-treesitter/nvim-treesitter-textobjects/main";
103+
flake = false;
104+
};
105+
```
106+
107+
You could identify them and pre-build them as plugins all at once!
108+
109+
Here is a useful module to import which gives you a helper function
110+
in `config.nvim-lib` for that!
111+
112+
```nix
113+
{ config, lib, ... }: {
114+
options.nvim-lib.pluginsFromPrefix = lib.mkOption {
115+
type = lib.types.raw;
116+
readOnly = true;
117+
default =
118+
prefix: inputs:
119+
lib.pipe inputs [
120+
builtins.attrNames
121+
(builtins.filter (s: lib.hasPrefix prefix s))
122+
(map (
123+
input:
124+
let
125+
name = lib.removePrefix prefix input;
126+
in
127+
{
128+
inherit name;
129+
value = config.nvim-lib.mkPlugin name inputs.${input};
130+
}
131+
))
132+
builtins.listToAttrs
133+
];
134+
};
135+
}
136+
```
137+
138+
And then you have access to the plugins like this!:
139+
140+
```nix
141+
inputs:
142+
{ config, ... }: let
143+
neovimPlugins = config.nvim-lib.pluginsFromPrefix "plugins-" inputs;
144+
in {
145+
imports = [ ./the_above_module.nix ];
146+
specs.treesitter-textobjects = neovimPlugins.treesitter-textobjects;
147+
}
148+
```

0 commit comments

Comments
 (0)