Skip to content

Commit 26ff8f4

Browse files
github-actions[bot]b-src
authored andcommitted
Auto generate docs
1 parent fd09206 commit 26ff8f4

File tree

1 file changed

+58
-30
lines changed

1 file changed

+58
-30
lines changed

doc/lazy-nix-helper.nvim.txt

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*lazy-nix-helper.nvim.txt* For Neovim >= 0.9.0? Last change: 2023 December 27
1+
*lazy-nix-helper.nvim.txt* For Neovim >= 0.9.0? Last change: 2023 December 29
22

33
==============================================================================
44
Table of Contents *lazy-nix-helper.nvim-table-of-contents*
@@ -57,10 +57,9 @@ the configuration.
5757

5858
HOW IT WORKS *lazy-nix-helper.nvim-lazy-nix-helper-how-it-works*
5959

60-
Lazy-Nix-Helper searches the nix store for all installed vim plugins and builds
61-
a table associating each plugin’s name with its nix store path. The
62-
`get_plugin_path()` function will return the nix store path corresponding to a
63-
given plugin name.
60+
Lazy-Nix-Helper accepts a table mapping plugin names to nix-store plugin paths
61+
as input. The `get_plugin_path()` function will return the nix store path
62+
corresponding to a given plugin name if the path exists on the system.
6463

6564

6665
REQUIREMENTS *lazy-nix-helper.nvim-lazy-nix-helper-requirements*
@@ -101,19 +100,23 @@ LAZY-NIX-HELPER CONFIGURATION ~
101100
{
102101
lazypath = nil,
103102
friendly_plugin_names = true,
103+
auto_plugin_discovery = false,
104+
input_plugin_table = {}
104105
}
105106
<
106107

107-
**Config Options** - `lazypath`: the default lazypath. Must be set in plugin
108+
**Config Options** - `lazypath`: the default lazypath. must be set in plugin
108109
config - `friendly_plugin_names`: when set to `true` provides less-strict
109110
plugin name matching for get_plugin_path(): + not case sensitive + treats `-`
110111
and `_` as identical + add or subtracts `.nvim` from the plugin name as needed
111112

112-
in most cases setting this to true will make updating your configuration much
113-
easier. if there is a plugin name collision with these rules applied then
113+
if there is a plugin name collision with these rules applied then
114114
lazy-nix-helper will thrown an error. in that case you will have to set this
115115
option to false and match plugin names exactly.
116116

117+
- `auto_plugin_discovery`: when set to `true` enables the automatic plugin discovery originally included in Lazy-Nix-Helper. the automatic plugin discovery is a nix anti-pattern and only works for a subset of nix/nixos use cases and config arrangements. this option has been left in place to let early adopters of Lazy-Nix-Helper keep their original configuration, but it should be set to `false` for all new configurations
118+
- `input_plugin_table`: the plugin table mapping plugin names to plugin paths generated by your nix config. instructions for generating this table are provided in the NixOS Configuration section
119+
117120
**Lazy-Nix-Helper’s own Nix Store Path**
118121

119122
The nix store path for the Lazy-Nix-Helper plugin itself cannot be provided by
@@ -170,8 +173,14 @@ Lazy-Nix-Helper `setup()` function - set the lazypath using Lazy-Nix-Helper
170173
Update the configuration as follows:
171174

172175
>lua
173-
-- See the NixOS Configuration section for more details
176+
-- THIS PLUGIN LIST SHOULD BE GENERATED BY YOUR NIX CONFIG. See the NixOS Configuration section for more details on plugins table and lazy_nix_helper_path
177+
local plugins = {
178+
["plugin-name.nvim"] = "nix/store/hash1234-vimplugin-plugin-name.nvim",
179+
...
180+
}
181+
174182
local lazy_nix_helper_path = <lazy_nix_helper/nix/store/path>
183+
175184
-- if we are not on a nix-based system, bootstrap lazy_nix_helper in the same way lazy is bootstrapped
176185
if not vim.loop.fs_stat(lazy_nix_helper_path) then
177186
lazy_nix_helper_path = vim.fn.stdpath("data") .. "/lazy_nix_helper/lazy_nix_helper.nvim"
@@ -191,7 +200,7 @@ Update the configuration as follows:
191200

192201
-- call the Lazy-Nix-Helper setup function. pass a default lazypath for non-nix systems as an argument
193202
local non_nix_lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
194-
require("lazy-nix-helper").setup({ lazypath = non_nix_lazypath })
203+
require("lazy-nix-helper").setup({ lazypath = non_nix_lazypath, input_plugin_table = plugins })
195204

196205
-- get the lazypath from Lazy-Nix-Helper
197206
local lazypath = require("lazy-nix-helper").lazypath()
@@ -344,7 +353,8 @@ instructions for additional information
344353
https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/vim.section.md#what-if-your-favourite-vim-plugin-isnt-already-packaged-what-if-your-favourite-vim-plugin-isnt-already-packaged
345354
2. Put your existing `init.lua` within `programs.neovim.extraLuaConfig`. 3.
346355
Update your `init.lua` to provide the nix store path of Lazy-Nix-Helper 4.
347-
Include the rest of your config files with `xdg.configFile`.
356+
Generate the plugins table 5. Include the rest of your config files with
357+
`xdg.configFile`.
348358

349359
`neovim.nix` module:
350360

@@ -362,6 +372,15 @@ Include the rest of your config files with `xdg.configFile`.
362372
};
363373
};
364374

375+
sanitizePluginName = input:
376+
let
377+
name = lib.strings.getName input;
378+
intermediate = lib.strings.removePrefix "vimplugin-" name;
379+
result = lib.strings.removePrefix "lua5.1-" intermediate;
380+
in result;
381+
382+
pluginList = plugins: lib.strings.concatMapStrings (plugin: " [\"${sanitizePluginName plugin.name}\"] = \"${plugin.outPath}\",\n") plugins;
383+
365384
in
366385
{
367386
xdg.configFile."nvim/lua" = {
@@ -381,6 +400,9 @@ Include the rest of your config files with `xdg.configFile`.
381400
<other plugins>
382401
];
383402
extraLuaConfig = ''
403+
local plugins = {
404+
${pluginList config.programs.neovim.plugins}
405+
}
384406
local lazy_nix_helper_path = "${lazy-nix-helper-nvim}"
385407
if not vim.loop.fs_stat(lazy_nix_helper_path) then
386408
lazy_nix_helper_path = vim.fn.stdpath("data") .. "/lazy_nix_helper/lazy_nix_helper.nvim"
@@ -398,9 +420,9 @@ Include the rest of your config files with `xdg.configFile`.
398420
-- add the Lazy Nix Helper plugin to the vim runtime
399421
vim.opt.rtp:prepend(lazy_nix_helper_path)
400422

401-
-- call the Lazy Nix Helper setup function. pass a default lazypath for non-nix systems as an argument
423+
-- call the Lazy Nix Helper setup function
402424
local non_nix_lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
403-
local lazy_nix_helper_opts = { lazypath = non_nix_lazypath }
425+
local lazy_nix_helper_opts = { lazypath = non_nix_lazypath, input_plugin_table = plugins }
404426
require("lazy-nix-helper").setup(lazy_nix_helper_opts)
405427

406428
-- get the lazypath from Lazy Nix Helper
@@ -434,27 +456,27 @@ system.
434456

435457
KNOWN LIMITATIONS *lazy-nix-helper.nvim-lazy-nix-helper-known-limitations*
436458

437-
Lazy-Nix-Helper can’t currently find plugins installed by Nix on non-NixOS
438-
platforms.
439-
440-
Lazy-Nix-Helper’s plugin discovery mechanism searches the current system’s
441-
installed packages for packages prefixed with `vimplugin` or `lua5.1`. As of
442-
2023-12-27 these are the only two prefixes used by the vimPlugin packageset in
443-
the unstable branch of nixpkgs. This works for now, but may break if a new
444-
prefix is added or existing prefixes are changed. It would be best to allow a
445-
list of plugin paths to be passed into the `setup()` function so that the nix
446-
store paths of neovim plugins could be provided declaratively by the NixOS
447-
config.
459+
I have not tested Lazy-Nix-Helper with: - Nix-installed neovim/plugins on a
460+
non-NixOS system - Nix-darwin
448461

449462

450463
ALTERNATIVES *lazy-nix-helper.nvim-lazy-nix-helper-alternatives*
451464

452465
Besides Lazy-Nix-Helper there are other tools and strategies you might choose
453466
to manage your neovim configuration under NixOS:
454467

468+
469+
NIX-BASED SOLUTIONS ~
470+
455471
- Home-Manager <https://nix-community.github.io/home-manager/> provides options for installing and configuring neovim plugins
456472
- NixVim <https://github.com/nix-community/nixvim/> is a neovim distribution built around Nix modules. It provides nix-style configuration options for every neovim configuration option as well as options for many plugins
457-
- Using your existing config as-is. Depending on how complicated your current config is and what it includes, you may be able to copy your dotfiles and have everything work out of the box. The main downside is that you lose the reproducability benefits of nix by using a different package manager
473+
474+
### Prebuilt flakes TODO: include some examples
475+
476+
### Non-nix - Using your existing config as-is. Depending on how complicated
477+
your current config is and what it includes, you may be able to copy your
478+
dotfiles and have everything work out of the box. The main downside is that you
479+
lose the reproducability benefits of nix by using a different package manager
458480

459481

460482
TROUBLESHOOTING *lazy-nix-helper.nvim-lazy-nix-helper-troubleshooting*
@@ -466,23 +488,29 @@ Use the `:Lazy` command to open the Lazy dashboard. The source directory is
466488
listed for each plugin
467489

468490

469-
HOW DO I CHECK WHICH PATH LAZY-NIX-HELPER HAS FOUND FOR A PLUGIN? ~
491+
HOW DO I CHECK THE PLUGIN LIST THAT WAS SUPPLIED TO LAZY-NIX-HELPER? ~
470492

471-
Run the `get_plugin_path` function manually: `:lua
472-
print(require("lazy-nix-helper").get_plugin_path("<plugin-name>"))`
493+
Run the `list_input_plugins` function manually: `lua
494+
require("lazy-nix-helper").list_input_plugins()`
473495

474496

475-
HOW DO I CHECK ALL OF THE PLUGINS THAT LAZY-NIX-HELPER HAS FOUND? ~
497+
HOW DO I CHECK WHICH PLUGINS WERE FOUND ON THE SYSTEM BY LAZY-NIX-HELPER? ~
476498

477499
Run the `list_discovered_plugins` function manually: `lua
478500
require("lazy-nix-helper").list_discovered_plugins()`
479501

480502

503+
HOW DO I CHECK WHICH PATH LAZY-NIX-HELPER HAS FOUND FOR A PLUGIN? ~
504+
505+
Run the `get_plugin_path` function manually: `:lua
506+
print(require("lazy-nix-helper").get_plugin_path("<plugin-name>"))`
507+
508+
481509
I DON’T THINK LAZY-NIX-HELPER IS CORRECTLY DETECTING WHEN I’M ON NIXOS ~
482510

483511
Run the `print_environment_info` function manually to see: - if Lazy-Nix-Helper
484512
thinks you’re on NixOS or not - if Lazy-Nix-Helper thinks nix-store is
485-
installed or not
513+
installed or not (only relevant for legacy automatic plugin discovery)
486514

487515
`lua require("lazy-nix-helper").print_environment_info()`
488516

0 commit comments

Comments
 (0)