diff --git a/ci/OWNERS b/ci/OWNERS index 99972715f8e4..a37d9b33ae67 100644 --- a/ci/OWNERS +++ b/ci/OWNERS @@ -361,7 +361,8 @@ pkgs/development/python-modules/buildcatrust/ @ajs124 @lukegb @mweinelt /pkgs/development/lua-modules @NixOS/lua # Neovim -/pkgs/applications/editors/neovim @NixOS/neovim +/pkgs/applications/editors/neovim @NixOS/neovim +/doc/languages-frameworks/neovim.section.md @NixOS/neovim # VimPlugins /pkgs/applications/editors/vim/plugins @NixOS/neovim diff --git a/doc/languages-frameworks/neovim.section.md b/doc/languages-frameworks/neovim.section.md index e0c22d8ccba5..78e9bf714013 100644 --- a/doc/languages-frameworks/neovim.section.md +++ b/doc/languages-frameworks/neovim.section.md @@ -25,7 +25,7 @@ neovim.override { withRuby = false; configure = { customRC = '' - # here your custom viml configuration goes! + " here your custom viml configuration goes! ''; packages.myVimPackage = with pkgs.vimPlugins; { # See examples below on how to use custom packages. @@ -47,7 +47,7 @@ neovim-qt.override { neovim = neovim.override { configure = { customRC = '' - # your custom viml configuration + " your custom viml configuration ''; }; }; @@ -64,11 +64,14 @@ For instance, `sqlite-lua` needs `g:sqlite_clib_path` to be set to work. Nixpkgs - `wrapRc`: Nix, not being able to write in your `$HOME`, loads the generated Neovim configuration via the `$VIMINIT` environment variable, i.e. : `export VIMINIT='lua dofile("/nix/store/…-init.lua")'`. This has side effects like preventing Neovim from sourcing your `init.lua` in `$XDG_CONFIG_HOME/nvim` (see bullet 7 of [`:help startup`](https://neovim.io/doc/user/starting.html#startup) in Neovim). Disable it if you want to generate your own wrapper. You can still reuse the generated vimscript init code via `neovim.passthru.initRc`. - `plugins`: A list of plugins to add to the wrapper. -- `extraLuaPackages`: A function passed on to `lua.withPackages` -- `withPython3`, `withNodeJs`, `withRuby` control when to enable neovim +- `extraLuaPackages`: A function passed on to `lua.withPackages`. +- `extraPython3Packages`: A function passed on to `python3.withPackages`. +- `withPython3`, `withNodeJs`, `withRuby`, `withPerl` control when to enable neovim providers (see `:h provider`). +- `vimAlias` and `viAlias` control whether to symlink the `vim` and `vi` binaries to `nvim` respectively. +- `extraName` is a string appended to the package name and derivation name. -``` +```nix wrapNeovimUnstable neovim-unwrapped { autoconfigure = true; autowrapRuntimeDeps = true; @@ -80,7 +83,8 @@ wrapNeovimUnstable neovim-unwrapped { vim.opt.colorcolumn = { 100 } vim.opt.termguicolors = true ''; - # plugins accepts a list of either plugins or { plugin = ...; config = ..vimscript.. }; + # plugins accepts a list of either plugins or attribute sets containing: + # { plugin = ...; config = ...; type = "viml"|"lua"; } (type defaults to "viml") plugins = with vimPlugins; [ { plugin = vim-obsession; @@ -88,7 +92,19 @@ wrapNeovimUnstable neovim-unwrapped { map $ Obsession ''; } - (nvim-treesitter.withPlugins (p: [ p.nix p.python ])) + { + plugin = grug-far-nvim; + type = "lua"; + config = '' + require('grug-far').setup({ + startInInsertMode = false, + }) + ''; + } + (nvim-treesitter.withPlugins (p: [ + p.nix + p.python + ])) hex-nvim ]; extraLuaPackages = lp: [ lp.mpack ]; @@ -98,12 +114,12 @@ wrapNeovimUnstable neovim-unwrapped { } ``` -You can explore the configuration with`nix repl` to discover these options and +You can explore the configuration with `nix repl` to discover these options and override them. For instance: ```nix -neovim.overrideAttrs (oldAttrs: { +neovim.override { autowrapRuntimeDeps = false; -}) +} ``` ## Specificities for some plugins {#neovim-plugin-specificities} diff --git a/pkgs/applications/editors/neovim/tests/default.nix b/pkgs/applications/editors/neovim/tests/default.nix index 5bc2730da87b..c17957ffbe3a 100644 --- a/pkgs/applications/editors/neovim/tests/default.nix +++ b/pkgs/applications/editors/neovim/tests/default.nix @@ -204,23 +204,23 @@ pkgs.lib.recurseIntoAttrs rec { ${nvim_with_plug}/bin/nvim -V3log.txt -i NONE -c 'color base16-tomorrow-night' +quit! -e ''; - nvim_with_autoconfigure = pkgs.neovim.overrideAttrs { - plugins = [ - vimPlugins.unicode-vim - vimPlugins.fzf-hoogle-vim - ]; + nvim_with_autoconfigure = pkgs.neovim.override { + configure = { + packages.myPlugins.start = [ + vimPlugins.unicode-vim + vimPlugins.fzf-hoogle-vim + ]; + }; autoconfigure = true; - # legacy wrapper sets it to false - wrapRc = true; }; - nvim_with_runtimeDeps = pkgs.neovim.overrideAttrs { - plugins = [ - pkgs.vimPlugins.hex-nvim - ]; + nvim_with_runtimeDeps = pkgs.neovim.override { + configure = { + packages.myPlugins.start = [ + pkgs.vimPlugins.hex-nvim + ]; + }; autowrapRuntimeDeps = true; - # legacy wrapper sets it to false - wrapRc = true; }; nvim_with_ftplugin =