Merge branch 'main' into main

This commit is contained in:
raf 2024-07-20 08:31:57 +00:00 committed by GitHub
commit 8f1dda4446
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
85 changed files with 391 additions and 405 deletions

View file

@ -5,4 +5,5 @@ configuring/custom-package.md
configuring/custom-plugins.md configuring/custom-plugins.md
configuring/languages.md configuring/languages.md
configuring/dags.md configuring/dags.md
configuring/dag-entries.md
``` ```

View file

@ -1,16 +1,38 @@
# Configuring {#sec-configuring-plugins} # Configuring {#sec-configuring-plugins}
Just making the plugin to your Neovim configuration available might not always Just making the plugin to your Neovim configuration available might not always
be enough. In that case, you can write custom vimscript or lua config, using be enough. In that case, you can write custom lua config using either
either `config.vim.configRC` or `config.vim.luaConfigRC` respectively. Both of `config.vim.extraPlugins` (which has the `setup` field) or
these options are attribute sets, and you need to give the configuration you're `config.vim.luaConfigRC`. The first option uses an attribute set, which maps DAG
adding some name, like this: section names to a custom type, which has the fields `package`, `after`,
`setup`. They allow you to set the package of the plugin, the sections its setup
code should be after (note that the `extraPlugins` option has its own DAG
scope), and the its setup code respectively. For example:
```nix
config.vim.extraPlugins = with pkgs.vimPlugins; {
aerial = {
package = aerial-nvim;
setup = "require('aerial').setup {}";
};
harpoon = {
package = harpoon;
setup = "require('harpoon').setup {}";
after = ["aerial"]; # place harpoon configuration after aerial
};
}
```
The second option also uses an attribute set, but this one is resolved as a DAG
directly. The attribute names denote the section names, and the values lua code.
For example:
```nix ```nix
{ {
# this will create an "aquarium" section in your init.vim with the contents of your custom config # this will create an "aquarium" section in your init.lua with the contents of your custom config
# which will be *appended* to the rest of your configuration, inside your init.vim # which will be *appended* to the rest of your configuration, inside your init.vim
config.vim.configRC.aquarium = "colorscheme aquiarum"; config.vim.luaConfigRC.aquarium = "vim.cmd('colorscheme aquiarum')";
} }
``` ```

View file

@ -0,0 +1,20 @@
# DAG entries in nvf {#ch-dag-entries}
From the previous chapter, it should be clear that DAGs are useful, because you
can add code that relies on other code. However, if you don't know what the
entries are called, it's hard to do that, so here is a list of the internal
entries in nvf:
`vim.luaConfigRC` (top-level DAG):
1. (`luaConfigPre`) - not a part of the actual DAG, instead, it's simply
inserted before the rest of the DAG
2. `globalsScript` - used to set globals defined in `vim.globals`
3. `basic` - used to set basic configuration options
4. `theme` - used to set up the theme, which has to be done before other plugins
5. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option,
see the [Custom Plugins](/index.xhtml#ch-custom-plugins) page for adding your own
plugins) DAG, used to set up internal plugins
6. `extraPluginConfigs` - the result of `vim.extraPlugins`, which is not a
direct DAG, but is converted to, and resolved as one internally
7. `mappings` - the result of `vim.maps`

View file

@ -6,8 +6,8 @@ addition for certain options is the [**DAG
type which is borrowed from home-manager's extended library. This type is most type which is borrowed from home-manager's extended library. This type is most
used for topologically sorting strings. The DAG type allows the attribute set used for topologically sorting strings. The DAG type allows the attribute set
entries to express dependency relations among themselves. This can, for entries to express dependency relations among themselves. This can, for
example, be used to control the order of configuration sections in your example, be used to control the order of configuration sections in your
`configRC` or `luaConfigRC`. `luaConfigRC`.
The below section, mostly taken from the [home-manager The below section, mostly taken from the [home-manager
manual](https://raw.githubusercontent.com/nix-community/home-manager/master/docs/manual/writing-modules/types.md) manual](https://raw.githubusercontent.com/nix-community/home-manager/master/docs/manual/writing-modules/types.md)

View file

@ -2,6 +2,28 @@
Release notes for release 0.7 Release notes for release 0.7
## Breaking Changes and Migration Guide {#sec-breaking-changes-and-migration-guide-0-7}
In v0.7 we are removing `vim.configRC` in favor of making `vim.luaConfigRC` the
top-level DAG, and thereby making the entire configuration Lua based. This
change introduces a few breaking changes:
[DAG entries in nvf manual]: /index.xhtml#ch-dag-entries
- `vim.configRC` has been removed, which means that you have to convert all of
your custom vimscript-based configuration to Lua. As for how to do that, you
will have to consult the Neovim documentation and your search engine.
- After migrating your Vimscript-based configuration to Lua, you might not be
able to use the same entry names in `vim.luaConfigRC`, because those have also
slightly changed. See the new [DAG entries in nvf manual] for more details.
**Why?**
Neovim being an aggressive refactor of Vim, is designed to be mainly Lua based;
making good use of its extensive Lua API. Additionally, Vimscript is slow and
brings unnecessary performance overhead while working with different
configuration formats.
## Changelog {#sec-release-0.7-changelog} ## Changelog {#sec-release-0.7-changelog}
[ItsSorae](https://github.com/ItsSorae): [ItsSorae](https://github.com/ItsSorae):
@ -12,8 +34,8 @@ Release notes for release 0.7
[frothymarrow](https://github.com/frothymarrow): [frothymarrow](https://github.com/frothymarrow):
- Modified type for - Modified type for
[vim.visuals.fidget-nvim.setupOpts.progress.display.overrides](#opt-vim.visuals.fidget-nvim.setupOpts.progress.display.overrides) [](#opt-vim.visuals.fidget-nvim.setupOpts.progress.display.overrides) from
from `anything` to a `submodule` for better type checking. `anything` to a `submodule` for better type checking.
- Fix null `vim.lsp.mappings` generating an error and not being filtered out. - Fix null `vim.lsp.mappings` generating an error and not being filtered out.
@ -21,28 +43,32 @@ Release notes for release 0.7
group for `Normal`, `NormalFloat`, `LineNr`, `SignColumn` and optionally group for `Normal`, `NormalFloat`, `LineNr`, `SignColumn` and optionally
`NvimTreeNormal` to `none`. `NvimTreeNormal` to `none`.
- Fix - Fix [](#opt-vim.ui.smartcolumn.setupOpts.custom_colorcolumn) using the wrong
[vim.ui.smartcolumn.setupOpts.custom_colorcolumn](#opt-vim.ui.smartcolumn.setupOpts.custom_colorcolumn) type `int` instead of the expected type `string`.
using the wrong type `int` instead of the expected type `string`.
[horriblename](https://github.com/horriblename): [horriblename](https://github.com/horriblename):
- Fix broken treesitter-context keybinds in visual mode - Fix broken treesitter-context keybinds in visual mode
- Deprecate use of `__empty` to define empty tables in lua. Empty attrset are no - Deprecate use of `__empty` to define empty tables in Lua. Empty attrset are no
longer filtered and thus should be used instead. longer filtered and thus should be used instead.
- Add dap-go for better dap configurations - Add dap-go for better dap configurations
- Make noice.nvim customizable - Make noice.nvim customizable
- Switch from [rust-tools.nvim](https://github.com/simrat39/rust-tools.nvim)
to the more feature-packed [rustacean.nvim](https://github.com/mrcjkb/rustaceanvim. [rust-tools.nvim]: https://github.com/simrat39/rust-tools.nvim
This switch entails a whole bunch of new features and options, so you are [rustaceanvim]: https://github.com/mrcjkb/rustaceanvim
recommended to go through rustacean.nvim's README to take a closer look at
its features and usage. - Switch from [rust-tools.nvim] to the more feature-packed [rustaceanvim]. This
switch entails a whole bunch of new features and options, so you are
recommended to go through rustacean.nvim's README to take a closer look at its
features and usage
[jacekpoz](https://github.com/jacekpoz): [jacekpoz](https://github.com/jacekpoz):
- Add [ocaml-lsp](https://github.com/ocaml/ocaml-lsp) support. [ocaml-lsp]: https://github.com/ocaml/ocaml-lsp
- Fix Emac typo - Add [ocaml-lsp] support
- Fix "Emac" typo
[diniamo](https://github.com/diniamo): [diniamo](https://github.com/diniamo):
@ -64,6 +90,7 @@ Release notes for release 0.7
plugin's options can now be found under `indentBlankline.setupOpts`, the plugin's options can now be found under `indentBlankline.setupOpts`, the
previous iteration of the module also included out of place/broken options, previous iteration of the module also included out of place/broken options,
which have been removed for the time being. These are: which have been removed for the time being. These are:
- `listChar` - this was already unused - `listChar` - this was already unused
- `fillChar` - this had nothing to do with the plugin, please configure it - `fillChar` - this had nothing to do with the plugin, please configure it
yourself by adding `vim.opt.listchars:append({ space = '<char>' })` to your yourself by adding `vim.opt.listchars:append({ space = '<char>' })` to your
@ -72,9 +99,22 @@ Release notes for release 0.7
yourself by adding `vim.opt.listchars:append({ eol = '<char>' })` to your yourself by adding `vim.opt.listchars:append({ eol = '<char>' })` to your
lua configuration lua configuration
[Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd()
- Make Neovim's configuration file entirely Lua based. This comes with a few
breaking changes:
- `vim.configRC` has been removed. You will need to migrate your entries to
Neovim-compliant Lua code, and add them to `vim.luaConfigRC` instead.
Existing vimscript configurations may be preserved in `vim.cmd` functions.
Please see [Neovim documentation on `vim.cmd`]
- `vim.luaScriptRC` is now the top-level DAG, and the internal `vim.pluginRC`
has been introduced for setting up internal plugins. See the "DAG entries in
nvf" manual page for more information.
[NotAShelf](https://github.com/notashelf): [NotAShelf](https://github.com/notashelf):
[ts-error-translator.nvim]: https://github.com/dmmulroy/ts-error-translator.nvim [ts-error-translator.nvim]: https://github.com/dmmulroy/ts-error-translator.nvim
[credo]: https://github.com/rrrene/credo
- Add `deno fmt` as the default Markdown formatter. This will be enabled - Add `deno fmt` as the default Markdown formatter. This will be enabled
automatically if you have autoformatting enabled, but can be disabled manually automatically if you have autoformatting enabled, but can be disabled manually
@ -85,8 +125,8 @@ Release notes for release 0.7
- Refactor `programs.languages.elixir` to use lspconfig and none-ls for LSP and - Refactor `programs.languages.elixir` to use lspconfig and none-ls for LSP and
formatter setups respectively. Diagnostics support is considered, and may be formatter setups respectively. Diagnostics support is considered, and may be
added once the [credo](https://github.com/rrrene/credo) linter has been added added once the [credo] linter has been added to nixpkgs. A pull request is
to nixpkgs. A pull request is currently open. currently open.
- Remove vim-tidal and friends. - Remove vim-tidal and friends.

View file

@ -25,7 +25,8 @@
flake = { flake = {
lib = { lib = {
inherit (lib) nvim neovimConfiguration; inherit (lib) nvim;
inherit (lib.nvim) neovimConfiguration;
}; };
homeManagerModules = { homeManagerModules = {

View file

@ -8,10 +8,10 @@
# - the addition of the function `entryBefore` indicating a "wanted # - the addition of the function `entryBefore` indicating a "wanted
# by" relationship. # by" relationship.
{lib}: let {lib}: let
inherit (builtins) isAttrs attrValues attrNames elem all head tail length; inherit (builtins) isAttrs attrValues attrNames elem all head tail length toJSON isString;
inherit (lib.attrsets) filterAttrs mapAttrs; inherit (lib.attrsets) filterAttrs mapAttrs;
inherit (lib.lists) toposort; inherit (lib.lists) toposort;
inherit (lib.nvim.dag) empty isEntry entryBetween entryAfter entriesBetween; inherit (lib.nvim.dag) empty isEntry entryBetween entryAfter entriesBetween entryAnywhere topoSort;
in { in {
empty = {}; empty = {};
@ -147,8 +147,22 @@ in {
${section.data} ${section.data}
''; '';
mkVimrcSection = section: '' resolveDag = {
" SECTION: ${section.name} name,
${section.data} dag,
''; mapResult,
}: let
# When the value is a string, default it to dag.entryAnywhere
finalDag = mapAttrs (_: value:
if isString value
then entryAnywhere value
else value)
dag;
sortedDag = topoSort finalDag;
result =
if sortedDag ? result
then mapResult sortedDag.result
else abort ("Dependency cycle in ${name}: " + toJSON sortedDag);
in
result;
} }

View file

@ -11,6 +11,5 @@
languages = import ./languages.nix {inherit lib;}; languages = import ./languages.nix {inherit lib;};
lists = import ./lists.nix {inherit lib;}; lists = import ./lists.nix {inherit lib;};
lua = import ./lua.nix {inherit lib;}; lua = import ./lua.nix {inherit lib;};
vim = import ./vim.nix;
neovimConfiguration = import ./configuration.nix {inherit inputs lib;}; neovimConfiguration = import ./configuration.nix {inherit inputs lib;};
} }

View file

@ -5,16 +5,6 @@
inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters concatLines; inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters concatLines;
inherit (lib.trivial) boolToString warn; inherit (lib.trivial) boolToString warn;
in rec { in rec {
wrapLuaConfig = {
luaBefore ? "",
luaConfig,
luaAfter ? "",
}: ''
lua << EOF
${concatLines [luaBefore luaConfig luaAfter]}
EOF
'';
# Convert a null value to lua's nil # Convert a null value to lua's nil
nullString = value: nullString = value:
if value == null if value == null

View file

@ -1,26 +0,0 @@
let
inherit (builtins) isInt isBool toJSON toString;
in rec {
# yes? no.
yesNo = value:
if value
then "yes"
else "no";
# convert a boolean to a vim compliant boolean string
mkVimBool = val:
if val
then "1"
else "0";
# convert a literal value to a vim compliant value
valToVim = val:
if (isInt val)
then (toString val)
else
(
if (isBool val)
then (mkVimBool val)
else (toJSON val)
);
}

View file

@ -106,8 +106,9 @@ inputs: {
neovim = vimOptions.package; neovim = vimOptions.package;
plugins = concatLists [builtStartPlugins builtOptPlugins]; plugins = concatLists [builtStartPlugins builtOptPlugins];
appName = "nvf"; appName = "nvf";
initViml = vimOptions.builtConfigRC;
extraBinPath = vimOptions.extraPackages; extraBinPath = vimOptions.extraPackages;
initLua = vimOptions.builtLuaConfigRC;
luaFiles = vimOptions.extraLuaFiles;
inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3; inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
inherit extraLuaPackages extraPython3Packages; inherit extraLuaPackages extraPython3Packages;

View file

@ -5,16 +5,17 @@
}: let }: let
inherit (lib.options) mkOption literalExpression; inherit (lib.options) mkOption literalExpression;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.types) enum bool str int nullOr; inherit (lib.types) enum bool str int;
inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim; cfg = config.vim;
in { in {
options.vim = { options.vim = {
leaderKey = mkOption { leaderKey = mkOption {
type = nullOr str; type = str;
default = null; default = " ";
description = "The leader key to be used internally"; description = "The leader key used for `<leader>` mappings";
}; };
colourTerm = mkOption { colourTerm = mkOption {
@ -53,12 +54,6 @@ in {
description = "Enable syntax highlighting"; description = "Enable syntax highlighting";
}; };
mapLeaderSpace = mkOption {
type = bool;
default = true;
description = "Map the space key to leader key";
};
useSystemClipboard = mkOption { useSystemClipboard = mkOption {
type = bool; type = bool;
default = false; default = false;
@ -165,117 +160,110 @@ in {
}; };
}; };
config.vim.configRC.basic = entryAfter ["globalsScript"] '' config.vim.luaConfigRC.basic = entryAfter ["globalsScript"] ''
" Settings that are set for everything -- Settings that are set for everything
set encoding=utf-8 vim.o.encoding = "utf-8"
set hidden vim.o.hidden = true
set shortmess+=c vim.opt.shortmess:append("c")
set expandtab vim.o.expandtab = true
set mouse=${cfg.mouseSupport} vim.o.mouse = ${toLuaObject cfg.mouseSupport}
set tabstop=${toString cfg.tabWidth} vim.o.tabstop = ${toLuaObject cfg.tabWidth}
set shiftwidth=${toString cfg.tabWidth} vim.o.shiftwidth = ${toLuaObject cfg.tabWidth}
set softtabstop=${toString cfg.tabWidth} vim.o.softtabstop = ${toLuaObject cfg.tabWidth}
set cmdheight=${toString cfg.cmdHeight} vim.o.cmdheight = ${toLuaObject cfg.cmdHeight}
set updatetime=${toString cfg.updateTime} vim.o.updatetime = ${toLuaObject cfg.updateTime}
set tm=${toString cfg.mapTimeout} vim.o.tm = ${toLuaObject cfg.mapTimeout}
set cursorlineopt=${toString cfg.cursorlineOpt} vim.o.cursorlineopt = ${toLuaObject cfg.cursorlineOpt}
set scrolloff=${toString cfg.scrollOffset} vim.o.scrolloff = ${toLuaObject cfg.scrollOffset}
vim.g.mapleader = ${toLuaObject cfg.leaderKey}
vim.g.maplocalleader = ${toLuaObject cfg.leaderKey}
${optionalString cfg.splitBelow '' ${optionalString cfg.splitBelow ''
set splitbelow vim.o.splitbelow = true
''} ''}
${optionalString cfg.splitRight '' ${optionalString cfg.splitRight ''
set splitright vim.o.splitright = true
''} ''}
${optionalString cfg.showSignColumn '' ${optionalString cfg.showSignColumn ''
set signcolumn=yes vim.o.signcolumn = "yes"
''} ''}
${optionalString cfg.autoIndent '' ${optionalString cfg.autoIndent ''
set autoindent vim.o.autoindent = true
''} ''}
${optionalString cfg.preventJunkFiles '' ${optionalString cfg.preventJunkFiles ''
set noswapfile vim.o.swapfile = false
set nobackup vim.o.backup = false
set nowritebackup vim.o.writebackup = false
''} ''}
${optionalString (cfg.bell == "none") '' ${optionalString (cfg.bell == "none") ''
set noerrorbells vim.o.errorbells = false
set novisualbell vim.o.visualbell = false
''} ''}
${optionalString (cfg.bell == "on") '' ${optionalString (cfg.bell == "on") ''
set novisualbell vim.o.visualbell = false
''} ''}
${optionalString (cfg.bell == "visual") '' ${optionalString (cfg.bell == "visual") ''
set noerrorbells vim.o.errorbells = false
''} ''}
${optionalString (cfg.lineNumberMode == "relative") '' ${optionalString (cfg.lineNumberMode == "relative") ''
set relativenumber vim.o.relativenumber = true
''} ''}
${optionalString (cfg.lineNumberMode == "number") '' ${optionalString (cfg.lineNumberMode == "number") ''
set number vim.o.number = true
''} ''}
${optionalString (cfg.lineNumberMode == "relNumber") '' ${optionalString (cfg.lineNumberMode == "relNumber") ''
set number relativenumber vim.o.number = true
vim.o.relativenumber = true
''} ''}
${optionalString cfg.useSystemClipboard '' ${optionalString cfg.useSystemClipboard ''
set clipboard+=unnamedplus vim.opt.clipboard:append("unnamedplus")
''}
${optionalString cfg.mapLeaderSpace ''
let mapleader=" "
let maplocalleader=" "
''} ''}
${optionalString cfg.syntaxHighlighting '' ${optionalString cfg.syntaxHighlighting ''
syntax on vim.cmd("syntax on")
''} ''}
${optionalString (!cfg.wordWrap) '' ${optionalString (!cfg.wordWrap) ''
set nowrap vim.o.wrap = false
''} ''}
${optionalString cfg.hideSearchHighlight '' ${optionalString cfg.hideSearchHighlight ''
set nohlsearch vim.o.hlsearch = false
set incsearch vim.o.incsearch = true
''} ''}
${optionalString cfg.colourTerm '' ${optionalString cfg.colourTerm ''
set termguicolors vim.o.termguicolors = true
set t_Co=256
''} ''}
${optionalString (!cfg.enableEditorconfig) '' ${optionalString (!cfg.enableEditorconfig) ''
let g:editorconfig = v:false vim.g.editorconfig = false
''}
${optionalString (cfg.leaderKey != null) ''
let mapleader = "${toString cfg.leaderKey}"
''} ''}
${optionalString (cfg.searchCase == "ignore") '' ${optionalString (cfg.searchCase == "ignore") ''
set nosmartcase vim.o.smartcase = false
set ignorecase vim.o.ignorecase = true
''} ''}
${optionalString (cfg.searchCase == "smart") '' ${optionalString (cfg.searchCase == "smart") ''
set smartcase vim.o.smartcase = true
set ignorecase vim.o.ignorecase = true
''} ''}
${optionalString (cfg.searchCase == "sensitive") '' ${optionalString (cfg.searchCase == "sensitive") ''
set nosmartcase vim.o.smartcase = false
set noignorecase vim.o.ignorecase = false
''} ''}
''; '';
} }

View file

@ -9,32 +9,26 @@
in { in {
config = { config = {
vim.maps = { vim.maps = {
normal = normal = mkIf cfg.disableArrows {
mkIf cfg.disableArrows { "<up>" = {
"<up>" = { action = "<nop>";
action = "<nop>";
noremap = false; noremap = false;
};
"<down>" = {
action = "<nop>";
noremap = false;
};
"<left>" = {
action = "<nop>";
noremap = false;
};
"<right>" = {
action = "<nop>";
noremap = false;
};
}
// mkIf cfg.mapLeaderSpace {
"<space>" = {
action = "<nop>";
};
}; };
"<down>" = {
action = "<nop>";
noremap = false;
};
"<left>" = {
action = "<nop>";
noremap = false;
};
"<right>" = {
action = "<nop>";
noremap = false;
};
};
insert = mkIf cfg.disableArrows { insert = mkIf cfg.disableArrows {
"<up>" = { "<up>" = {

View file

@ -33,7 +33,7 @@ in {
startPlugins = [ startPlugins = [
"chatgpt" "chatgpt"
]; ];
luaConfigRC.chagpt = entryAnywhere '' pluginRC.chagpt = entryAnywhere ''
require("chatgpt").setup(${toLuaObject cfg.setupOpts}) require("chatgpt").setup(${toLuaObject cfg.setupOpts})
''; '';
maps.normal = mkMerge [ maps.normal = mkMerge [

View file

@ -34,7 +34,7 @@ in {
"copilot-cmp" "copilot-cmp"
]; ];
vim.luaConfigRC.copilot = entryAnywhere '' vim.pluginRC.copilot = entryAnywhere ''
require("copilot").setup(${toLuaObject cfg.setupOpts}) require("copilot").setup(${toLuaObject cfg.setupOpts})
${lib.optionalString cfg.cmp.enable '' ${lib.optionalString cfg.cmp.enable ''

View file

@ -12,7 +12,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["nvim-autopairs"]; vim.startPlugins = ["nvim-autopairs"];
vim.luaConfigRC.autopairs = entryAnywhere '' vim.pluginRC.autopairs = entryAnywhere ''
require("nvim-autopairs").setup({ map_cr = ${boolToString (!config.vim.autocomplete.enable)} }) require("nvim-autopairs").setup({ map_cr = ${boolToString (!config.vim.autocomplete.enable)} })
''; '';
}; };

View file

@ -41,7 +41,7 @@ in {
(mkBinding cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description) (mkBinding cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description)
]; ];
vim.luaConfigRC.comment-nvim = entryAnywhere '' vim.pluginRC.comment-nvim = entryAnywhere ''
require('Comment').setup({ require('Comment').setup({
mappings = { basic = false, extra = false, }, mappings = { basic = false, extra = false, },
}) })

View file

@ -186,7 +186,7 @@ in {
# TODO: alternative snippet engines to vsnip # TODO: alternative snippet engines to vsnip
# https://github.com/hrsh7th/nvim-cmp/blob/main/doc/cmp.txt#L82 # https://github.com/hrsh7th/nvim-cmp/blob/main/doc/cmp.txt#L82
vim.luaConfigRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement '' vim.pluginRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement ''
local nvim_cmp_menu_map = function(entry, vim_item) local nvim_cmp_menu_map = function(entry, vim_item)
-- name for each source -- name for each source
vim_item.menu = ({ vim_item.menu = ({

View file

@ -16,7 +16,7 @@ in {
# the entire credit for this dashboard configuration to https://github.com/Rishabh672003 # the entire credit for this dashboard configuration to https://github.com/Rishabh672003
# honestly, excellent work # honestly, excellent work
vim.luaConfigRC.alpha = entryAnywhere '' vim.pluginRC.alpha = entryAnywhere ''
local alpha = require("alpha") local alpha = require("alpha")
local plenary_path = require("plenary.path") local plenary_path = require("plenary.path")
local dashboard = require("alpha.themes.dashboard") local dashboard = require("alpha.themes.dashboard")

View file

@ -13,7 +13,7 @@ in {
"dashboard-nvim" "dashboard-nvim"
]; ];
vim.luaConfigRC.dashboard-nvim = entryAnywhere '' vim.pluginRC.dashboard-nvim = entryAnywhere ''
require("dashboard").setup{} require("dashboard").setup{}
''; '';
}; };

View file

@ -5,7 +5,6 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.vim) mkVimBool;
cfg = config.vim.dashboard.startify; cfg = config.vim.dashboard.startify;
in { in {
@ -23,28 +22,28 @@ in {
else cfg.customFooter; else cfg.customFooter;
"startify_bookmarks" = cfg.bookmarks; "startify_bookmarks" = cfg.bookmarks;
"startify_lists" = cfg.lists; "startify_lists" = cfg.lists;
"startify_change_to_dir" = mkVimBool cfg.changeToDir; "startify_change_to_dir" = cfg.changeToDir;
"startify_change_to_vcs_root" = mkVimBool cfg.changeToVCRoot; "startify_change_to_vcs_root" = cfg.changeToVCRoot;
"startify_change_cmd" = cfg.changeDirCmd; "startify_change_cmd" = cfg.changeDirCmd;
"startify_skiplist" = cfg.skipList; "startify_skiplist" = cfg.skipList;
"startify_update_oldfiles" = mkVimBool cfg.updateOldFiles; "startify_update_oldfiles" = cfg.updateOldFiles;
"startify_session_autoload" = mkVimBool cfg.sessionAutoload; "startify_session_autoload" = cfg.sessionAutoload;
"startify_commands" = cfg.commands; "startify_commands" = cfg.commands;
"startify_files_number" = cfg.filesNumber; "startify_files_number" = cfg.filesNumber;
"startify_custom_indices" = cfg.customIndices; "startify_custom_indices" = cfg.customIndices;
"startify_disable_at_vimenter" = mkVimBool cfg.disableOnStartup; "startify_disable_at_vimenter" = cfg.disableOnStartup;
"startify_enable_unsafe" = mkVimBool cfg.unsafe; "startify_enable_unsafe" = cfg.unsafe;
"startify_padding_left" = cfg.paddingLeft; "startify_padding_left" = cfg.paddingLeft;
"startify_use_env" = mkVimBool cfg.useEnv; "startify_use_env" = cfg.useEnv;
"startify_session_before_save" = cfg.sessionBeforeSave; "startify_session_before_save" = cfg.sessionBeforeSave;
"startify_session_persistence" = mkVimBool cfg.sessionPersistence; "startify_session_persistence" = cfg.sessionPersistence;
"startify_session_delete_buffers" = mkVimBool cfg.sessionDeleteBuffers; "startify_session_delete_buffers" = cfg.sessionDeleteBuffers;
"startify_session_dir" = cfg.sessionDir; "startify_session_dir" = cfg.sessionDir;
"startify_skiplist_server" = cfg.skipListServer; "startify_skiplist_server" = cfg.skipListServer;
"startify_session_remove_lines" = cfg.sessionRemoveLines; "startify_session_remove_lines" = cfg.sessionRemoveLines;
"startify_session_savevars" = cfg.sessionSavevars; "startify_session_savevars" = cfg.sessionSavevars;
"startify_session_savecmds" = cfg.sessionSavecmds; "startify_session_savecmds" = cfg.sessionSavecmds;
"startify_session_sort" = mkVimBool cfg.sessionSort; "startify_session_sort" = cfg.sessionSort;
}; };
}; };
} }

View file

@ -18,7 +18,7 @@ in {
(mkIf cfg.enable { (mkIf cfg.enable {
vim.startPlugins = ["nvim-dap"]; vim.startPlugins = ["nvim-dap"];
vim.luaConfigRC = vim.pluginRC =
{ {
# TODO customizable keymaps # TODO customizable keymaps
nvim-dap = entryAnywhere '' nvim-dap = entryAnywhere ''
@ -51,7 +51,7 @@ in {
(mkIf (cfg.enable && cfg.ui.enable) { (mkIf (cfg.enable && cfg.ui.enable) {
vim.startPlugins = ["nvim-dap-ui" "nvim-nio"]; vim.startPlugins = ["nvim-dap-ui" "nvim-nio"];
vim.luaConfigRC.nvim-dap-ui = entryAfter ["nvim-dap"] ('' vim.pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] (''
local dapui = require("dapui") local dapui = require("dapui")
dapui.setup() dapui.setup()
'' ''

View file

@ -20,7 +20,7 @@ in {
"neo-tree-nvim" "neo-tree-nvim"
]; ];
luaConfigRC.neo-tree = entryAnywhere '' pluginRC.neo-tree = entryAnywhere ''
require("neo-tree").setup(${toLuaObject cfg.setupOpts}) require("neo-tree").setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -29,7 +29,7 @@ in {
"<leader>t" = "+NvimTree"; "<leader>t" = "+NvimTree";
}; };
vim.luaConfigRC.nvimtreelua = entryAnywhere '' vim.pluginRC.nvimtreelua = entryAnywhere ''
${ ${
optionalString cfg.setupOpts.disable_netrw '' optionalString cfg.setupOpts.disable_netrw ''
-- disable netrew completely -- disable netrew completely

View file

@ -69,7 +69,7 @@ in {
"<leader>g" = "+Gitsigns"; "<leader>g" = "+Gitsigns";
}; };
luaConfigRC.gitsigns = entryAnywhere '' pluginRC.gitsigns = entryAnywhere ''
require('gitsigns').setup{} require('gitsigns').setup{}
''; '';
}; };

View file

@ -12,7 +12,7 @@
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption; inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAfter;
packageToCmd = package: defaultCmd: packageToCmd = package: defaultCmd:
if isList cfg.lsp.package if isList cfg.lsp.package
@ -141,7 +141,7 @@ in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
(mkIf cfg.cHeader { (mkIf cfg.cHeader {
vim.configRC.c-header = entryAnywhere "let g:c_syntax_for_h = 1"; vim.pluginRC.c-header = entryAfter ["basic"] "vim.g.c_syntax_for_h = 1";
}) })
(mkIf cfg.treesitter.enable { (mkIf cfg.treesitter.enable {

View file

@ -140,7 +140,7 @@ in {
then ["flutter-tools-patched"] then ["flutter-tools-patched"]
else ["flutter-tools"]; else ["flutter-tools"];
vim.luaConfigRC.flutter-tools = entryAnywhere '' vim.pluginRC.flutter-tools = entryAnywhere ''
require('flutter-tools').setup { require('flutter-tools').setup {
lsp = { lsp = {
color = { -- show the derived colours for dart variables color = { -- show the derived colours for dart variables

View file

@ -113,7 +113,7 @@ in {
(mkIf cfg.elixir-tools.enable { (mkIf cfg.elixir-tools.enable {
vim.startPlugins = ["elixir-tools"]; vim.startPlugins = ["elixir-tools"];
vim.luaConfigRC.elixir-tools = entryAnywhere '' vim.pluginRC.elixir-tools = entryAnywhere ''
local elixir-tools = require("elixir") local elixir-tools = require("elixir")
local elixirls = require("elixir-tools.elixirls") local elixirls = require("elixir-tools.elixirls")

View file

@ -102,7 +102,7 @@ in {
(mkIf cfg.dap.enable { (mkIf cfg.dap.enable {
vim = { vim = {
startPlugins = ["nvim-dap-go"]; startPlugins = ["nvim-dap-go"];
luaConfigRC.nvim-dap-go = entryAfter ["nvim-dap"] '' pluginRC.nvim-dap-go = entryAfter ["nvim-dap"] ''
require('dap-go').setup { require('dap-go').setup {
delve = { delve = {
path = '${getExe cfg.dap.package}', path = '${getExe cfg.dap.package}',

View file

@ -36,7 +36,7 @@ in {
grammars = [cfg.treesitter.package]; grammars = [cfg.treesitter.package];
}; };
luaConfigRC.html-autotag = mkIf cfg.treesitter.autotagHtml (entryAnywhere '' pluginRC.html-autotag = mkIf cfg.treesitter.autotagHtml (entryAnywhere ''
require('nvim-ts-autotag').setup() require('nvim-ts-autotag').setup()
''); '');
}; };

View file

@ -61,7 +61,7 @@ in {
(mkIf cfg.lsp.neodev.enable { (mkIf cfg.lsp.neodev.enable {
vim.startPlugins = ["neodev-nvim"]; vim.startPlugins = ["neodev-nvim"];
vim.luaConfigRC.neodev = entryBefore ["lua-lsp"] '' vim.pluginRC.neodev = entryBefore ["lua-lsp"] ''
require("neodev").setup({}) require("neodev").setup({})
''; '';
}) })

View file

@ -11,7 +11,6 @@
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.types) enum either listOf package str; inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.types) mkGrammarOption diagnostics; inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.languages) diagnosticsToLua; inherit (lib.nvim.languages) diagnosticsToLua;
@ -176,8 +175,16 @@ in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
{ {
vim.configRC.nix = entryAnywhere '' vim.pluginRC.nix = ''
autocmd filetype nix setlocal tabstop=2 shiftwidth=2 softtabstop=2 vim.api.nvim_create_autocmd("FileType", {
pattern = "nix",
callback = function(opts)
local bo = vim.bo[opts.buf]
bo.tabstop = 2
bo.shiftwidth = 2
bo.softtabstop = 2
end
})
''; '';
} }

View file

@ -102,7 +102,7 @@ in {
startPlugins = ["crates-nvim"]; startPlugins = ["crates-nvim"];
lsp.null-ls.enable = mkIf cfg.crates.codeActions true; lsp.null-ls.enable = mkIf cfg.crates.codeActions true;
autocomplete.sources = {"crates" = "[Crates]";}; autocomplete.sources = {"crates" = "[Crates]";};
luaConfigRC.rust-crates = entryAnywhere '' pluginRC.rust-crates = entryAnywhere ''
require('crates').setup { require('crates').setup {
null_ls = { null_ls = {
enabled = ${boolToString cfg.crates.codeActions}, enabled = ${boolToString cfg.crates.codeActions},

View file

@ -192,7 +192,7 @@ in {
(mkIf cfg.extensions."ts-error-translator".enable { (mkIf cfg.extensions."ts-error-translator".enable {
vim.startPlugins = ["ts-error-translator"]; vim.startPlugins = ["ts-error-translator"];
vim.luaConfigRC.ts-error-translator = entryAnywhere '' vim.pluginRC.ts-error-translator = entryAnywhere ''
require("ts-error-translator").setup(${toLuaObject cfg.extensions.ts-error-translator.setupOpts}) require("ts-error-translator").setup(${toLuaObject cfg.extensions.ts-error-translator.setupOpts})
''; '';
}) })

View file

@ -27,7 +27,7 @@ in {
autocomplete.sources = {"nvim_lsp" = "[LSP]";}; autocomplete.sources = {"nvim_lsp" = "[LSP]";};
luaConfigRC.lsp-setup = '' pluginRC.lsp-setup = ''
vim.g.formatsave = ${boolToString cfg.formatOnSave}; vim.g.formatsave = ${boolToString cfg.formatOnSave};
local attach_keymaps = function(client, bufnr) local attach_keymaps = function(client, bufnr)

View file

@ -12,7 +12,7 @@ in {
vim = { vim = {
startPlugins = ["nvim-lightbulb"]; startPlugins = ["nvim-lightbulb"];
luaConfigRC.lightbulb = entryAnywhere '' pluginRC.lightbulb = entryAnywhere ''
vim.api.nvim_command('autocmd CursorHold,CursorHoldI * lua require\'nvim-lightbulb\'.update_lightbulb()') vim.api.nvim_command('autocmd CursorHold,CursorHoldI * lua require\'nvim-lightbulb\'.update_lightbulb()')
-- Enable trouble diagnostics viewer -- Enable trouble diagnostics viewer

View file

@ -20,7 +20,7 @@ in {
handler_opts.border = config.vim.ui.borders.plugins.lsp-signature.style; handler_opts.border = config.vim.ui.borders.plugins.lsp-signature.style;
}; };
luaConfigRC.lsp-signature = entryAnywhere '' pluginRC.lsp-signature = entryAnywhere ''
-- Enable lsp signature viewer -- Enable lsp signature viewer
require("lsp_signature").setup(${toLuaObject cfg.lspSignature.setupOpts}) require("lsp_signature").setup(${toLuaObject cfg.lspSignature.setupOpts})
''; '';

View file

@ -17,7 +17,7 @@ in {
startPlugins = ["nvim-lspconfig"]; startPlugins = ["nvim-lspconfig"];
luaConfigRC.lspconfig = entryAfter ["lsp-setup"] '' pluginRC.lspconfig = entryAfter ["lsp-setup"] ''
local lspconfig = require('lspconfig') local lspconfig = require('lspconfig')
${ ${
@ -29,7 +29,7 @@ in {
}; };
} }
{ {
vim.luaConfigRC = mapAttrs (_: v: (entryAfter ["lspconfig"] v)) cfg.lspconfig.sources; vim.pluginRC = mapAttrs (_: v: (entryAfter ["lspconfig"] v)) cfg.lspconfig.sources;
} }
]); ]);
} }

View file

@ -10,7 +10,7 @@
in { in {
config = mkIf (cfg.enable && cfg.lspkind.enable) { config = mkIf (cfg.enable && cfg.lspkind.enable) {
vim.startPlugins = ["lspkind"]; vim.startPlugins = ["lspkind"];
vim.luaConfigRC.lspkind = entryAnywhere '' vim.pluginRC.lspkind = entryAnywhere ''
local lspkind = require'lspkind' local lspkind = require'lspkind'
local lspkind_opts = { local lspkind_opts = {
mode = '${cfg.lspkind.mode}' mode = '${cfg.lspkind.mode}'

View file

@ -10,7 +10,7 @@
in { in {
config = mkIf (cfg.enable && cfg.lsplines.enable) { config = mkIf (cfg.enable && cfg.lsplines.enable) {
vim.startPlugins = ["lsp-lines"]; vim.startPlugins = ["lsp-lines"];
vim.luaConfigRC.lsplines = entryAfter ["lspconfig"] '' vim.pluginRC.lsplines = entryAfter ["lspconfig"] ''
require("lsp_lines").setup() require("lsp_lines").setup()
vim.diagnostic.config({ vim.diagnostic.config({

View file

@ -41,7 +41,7 @@ in {
]; ];
}; };
luaConfigRC.lspsaga = entryAnywhere '' pluginRC.lspsaga = entryAnywhere ''
require('lspsaga').init_lsp_saga({ require('lspsaga').init_lsp_saga({
${optionalString config.vim.ui.borders.plugins.lspsaga.enable '' ${optionalString config.vim.ui.borders.plugins.lspsaga.enable ''
border_style = '${config.vim.ui.borders.plugins.lspsaga.style}', border_style = '${config.vim.ui.borders.plugins.lspsaga.style}',

View file

@ -22,7 +22,7 @@ in {
# since it will hook into LSPs to receive information # since it will hook into LSPs to receive information
lsp.enable = true; lsp.enable = true;
luaConfigRC = { pluginRC = {
# early setup for null-ls # early setup for null-ls
null_ls-setup = entryAnywhere '' null_ls-setup = entryAnywhere ''
local null_ls = require("null-ls") local null_ls = require("null-ls")
@ -46,7 +46,7 @@ in {
}; };
} }
{ {
vim.luaConfigRC = mapAttrs (_: v: (entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources; vim.pluginRC = mapAttrs (_: v: (entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources;
} }
]); ]);
} }

View file

@ -23,7 +23,7 @@ in {
"<leader>c" = "+CodeAction"; "<leader>c" = "+CodeAction";
}; };
luaConfigRC.code-action-menu = entryAnywhere '' pluginRC.code-action-menu = entryAnywhere ''
-- border configuration -- border configuration
vim.g.code_action_menu_window_border = '${config.vim.ui.borders.plugins.code-action-menu.style}' vim.g.code_action_menu_window_border = '${config.vim.ui.borders.plugins.code-action-menu.style}'

View file

@ -19,7 +19,7 @@ in {
lsp.enable = true; lsp.enable = true;
startPlugins = ["nvim-docs-view"]; startPlugins = ["nvim-docs-view"];
luaConfigRC.nvim-docs-view = entryAnywhere '' pluginRC.nvim-docs-view = entryAnywhere ''
require("docs-view").setup ${toLuaObject cfg.setupOpts} require("docs-view").setup ${toLuaObject cfg.setupOpts}
''; '';

View file

@ -32,7 +32,7 @@ in {
"<leader>lw" = "Workspace"; "<leader>lw" = "Workspace";
}; };
luaConfigRC.trouble = entryAnywhere '' pluginRC.trouble = entryAnywhere ''
-- Enable trouble diagnostics viewer -- Enable trouble diagnostics viewer
require("trouble").setup {} require("trouble").setup {}
''; '';

View file

@ -31,7 +31,7 @@ in {
"<leader>m" = "+Minimap"; "<leader>m" = "+Minimap";
}; };
luaConfigRC.codewindow = entryAnywhere '' pluginRC.codewindow = entryAnywhere ''
local codewindow = require('codewindow') local codewindow = require('codewindow')
codewindow.setup({ codewindow.setup({
exclude_filetypes = { 'NvimTree', 'orgagenda', 'Alpha'}, exclude_filetypes = { 'NvimTree', 'orgagenda', 'Alpha'},

View file

@ -25,7 +25,7 @@ in {
"<leader>o" = "+Notes"; "<leader>o" = "+Notes";
}; };
luaConfigRC.mind-nvim = entryAnywhere '' pluginRC.mind-nvim = entryAnywhere ''
require'mind'.setup() require'mind'.setup()
''; '';
}; };

View file

@ -22,7 +22,7 @@ in {
"<leader>o" = "+Notes"; "<leader>o" = "+Notes";
}; };
luaConfigRC.obsidian = entryAnywhere '' pluginRC.obsidian = entryAnywhere ''
require("obsidian").setup(${toLuaObject cfg.setupOpts}) require("obsidian").setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -21,7 +21,7 @@ in {
"<leader>o" = "+Notes"; "<leader>o" = "+Notes";
}; };
luaConfigRC.orgmode = entryAnywhere '' pluginRC.orgmode = entryAnywhere ''
-- Treesitter configuration -- Treesitter configuration
require('nvim-treesitter.configs').setup { require('nvim-treesitter.configs').setup {

View file

@ -24,7 +24,7 @@ in {
(mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble<CR>" mappings.trouble.description)) (mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble<CR>" mappings.trouble.description))
]; ];
luaConfigRC.todo-comments = '' pluginRC.todo-comments = ''
require('todo-comments').setup(${toLuaObject cfg.setupOpts}) require('todo-comments').setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -14,7 +14,7 @@ in {
"project-nvim" "project-nvim"
]; ];
vim.luaConfigRC.project-nvim = entryAnywhere '' vim.pluginRC.project-nvim = entryAnywhere ''
require('project_nvim').setup(${toLuaObject cfg.setupOpts}) require('project_nvim').setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -12,7 +12,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["neocord"]; vim.startPlugins = ["neocord"];
vim.luaConfigRC.neocord = entryAnywhere '' vim.pluginRC.neocord = entryAnywhere ''
-- Description of each option can be found in https://github.com/IogaMaster/neocord#lua -- Description of each option can be found in https://github.com/IogaMaster/neocord#lua
require("neocord").setup(${toLuaObject cfg.setupOpts}) require("neocord").setup(${toLuaObject cfg.setupOpts})
''; '';

View file

@ -28,7 +28,7 @@ in {
# TODO: load_current_dir_session # TODO: load_current_dir_session
]; ];
luaConfigRC.nvim-session-manager = entryAnywhere '' pluginRC.nvim-session-manager = entryAnywhere ''
local Path = require('plenary.path') local Path = require('plenary.path')
local sm = require('session_manager.config') local sm = require('session_manager.config')
require('session_manager').setup(${toLuaObject cfg.setupOpts}) require('session_manager').setup(${toLuaObject cfg.setupOpts})

View file

@ -14,7 +14,7 @@ in {
# vim-dirtytalk doesn't have any setup # vim-dirtytalk doesn't have any setup
# but we would like to append programming to spelllang # but we would like to append programming to spelllang
# as soon as possible while the plugin is enabled # as soon as possible while the plugin is enabled
luaConfigRC.vim-dirtytalk = entryAfter ["basic"] '' pluginRC.vim-dirtytalk = entryAfter ["basic"] ''
-- append programming to spelllang -- append programming to spelllang
vim.opt.spelllang:append("programming") vim.opt.spelllang:append("programming")
''; '';

View file

@ -35,7 +35,7 @@ in {
vim = { vim = {
startPlugins = ["lualine"]; startPlugins = ["lualine"];
luaConfigRC.lualine = entryAnywhere '' pluginRC.lualine = entryAnywhere ''
local lualine = require('lualine') local lualine = require('lualine')
lualine.setup ${toLuaObject cfg.setupOpts} lualine.setup ${toLuaObject cfg.setupOpts}
''; '';

View file

@ -39,7 +39,7 @@ in {
"<leader>bsi" = "BufferLineSortById"; "<leader>bsi" = "BufferLineSortById";
}; };
luaConfigRC.nvimBufferline = entryAnywhere '' pluginRC.nvimBufferline = entryAnywhere ''
require("bufferline").setup(${toLuaObject cfg.setupOpts}) require("bufferline").setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -23,7 +23,7 @@ in {
maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal"; maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal";
luaConfigRC.toggleterm = entryAnywhere '' pluginRC.toggleterm = entryAnywhere ''
require("toggleterm").setup(${toLuaObject cfg.setupOpts}) require("toggleterm").setup(${toLuaObject cfg.setupOpts})
''; '';
}; };
@ -35,7 +35,7 @@ in {
vim.startPlugins = optionals (cfg.lazygit.package != null) [ vim.startPlugins = optionals (cfg.lazygit.package != null) [
cfg.lazygit.package cfg.lazygit.package
]; ];
vim.luaConfigRC.toggleterm-lazygit = entryAfter ["toggleterm"] '' vim.pluginRC.toggleterm-lazygit = entryAfter ["toggleterm"] ''
local terminal = require 'toggleterm.terminal' local terminal = require 'toggleterm.terminal'
local lazygit = terminal.Terminal:new({ local lazygit = terminal.Terminal:new({
cmd = '${ cmd = '${

View file

@ -7,10 +7,10 @@
inherit (lib.attrsets) attrNames; inherit (lib.attrsets) attrNames;
inherit (lib.types) bool lines enum; inherit (lib.types) bool lines enum;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryBefore; inherit (lib.nvim.dag) entryAfter;
cfg = config.vim.theme; cfg = config.vim.theme;
supported_themes = import ./supported_themes.nix { supportedThemes = import ./supported-themes.nix {
inherit lib config; inherit lib config;
}; };
in { in {
@ -21,12 +21,12 @@ in {
}; };
name = mkOption { name = mkOption {
type = enum (attrNames supported_themes); type = enum (attrNames supportedThemes);
description = "Supported themes can be found in `supported_themes.nix`"; description = "Supported themes can be found in `supportedThemes.nix`";
}; };
style = mkOption { style = mkOption {
type = enum supported_themes.${cfg.name}.styles; type = enum supportedThemes.${cfg.name}.styles;
description = "Specific style for theme if it supports it"; description = "Specific style for theme if it supports it";
}; };
@ -45,11 +45,9 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
startPlugins = [cfg.name]; startPlugins = [cfg.name];
configRC.theme = entryBefore ["luaScript"] '' luaConfigRC.theme = entryAfter ["basic"] ''
lua << EOF
${cfg.extraConfig} ${cfg.extraConfig}
${supported_themes.${cfg.name}.setup (with cfg; {inherit style transparent;})} ${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent;}}
EOF
''; '';
}; };
}; };

View file

@ -37,18 +37,18 @@ in {
}; };
# For some reason treesitter highlighting does not work on start if this is set before syntax on # For some reason treesitter highlighting does not work on start if this is set before syntax on
configRC.treesitter-fold = mkIf cfg.fold (entryBefore ["basic"] '' pluginRC.treesitter-fold = mkIf cfg.fold (entryBefore ["basic"] ''
" This is required by treesitter-context to handle folds -- This is required by treesitter-context to handle folds
set foldmethod=expr vim.o.foldmethod = "expr"
set foldexpr=nvim_treesitter#foldexpr() vim.o.foldexpr = "nvim_treesitter#foldexpr()"
" This is optional, but is set rather as a sane default. -- This is optional, but is set rather as a sane default.
" If unset, opened files will be folded by automatically as -- If unset, opened files will be folded by automatically as
" the files are opened -- the files are opened
set nofoldenable vim.o.foldenable = false
''); '');
luaConfigRC.treesitter = entryAfter ["basic"] '' pluginRC.treesitter = entryAfter ["basic"] ''
require('nvim-treesitter.configs').setup { require('nvim-treesitter.configs').setup {
-- Disable imperative treesitter options that would attempt to fetch -- Disable imperative treesitter options that would attempt to fetch
-- grammars into the read-only Nix store. To add additional grammars here -- grammars into the read-only Nix store. To add additional grammars here

View file

@ -16,7 +16,7 @@ in {
# set up treesitter-context after Treesitter. The ordering # set up treesitter-context after Treesitter. The ordering
# should not matter, but there is no harm in doing this # should not matter, but there is no harm in doing this
luaConfigRC.treesitter-context = entryAfter ["treesitter"] '' pluginRC.treesitter-context = entryAfter ["treesitter"] ''
require("treesitter-context").setup(${toLuaObject cfg.setupOpts}) require("treesitter-context").setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -78,7 +78,7 @@ in {
}; };
}; };
vim.luaConfigRC.breadcrumbs = entryAfter ["lspconfig"] '' vim.pluginRC.breadcrumbs = entryAfter ["lspconfig"] ''
${optionalString (cfg.source == "nvim-navic") '' ${optionalString (cfg.source == "nvim-navic") ''
local navic = require("nvim-navic") local navic = require("nvim-navic")

View file

@ -14,7 +14,7 @@ in {
"nvim-colorizer-lua" "nvim-colorizer-lua"
]; ];
vim.luaConfigRC.colorizer = entryAnywhere '' vim.pluginRC.colorizer = entryAnywhere ''
require('colorizer').setup(${toLuaObject cfg.setupOpts}) require('colorizer').setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -11,7 +11,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["vim-illuminate"]; vim.startPlugins = ["vim-illuminate"];
vim.luaConfigRC.vim-illuminate = entryAnywhere '' vim.pluginRC.vim-illuminate = entryAnywhere ''
require('illuminate').configure({ require('illuminate').configure({
filetypes_denylist = { filetypes_denylist = {
'dirvish', 'dirvish',

View file

@ -14,7 +14,7 @@ in {
"modes-nvim" "modes-nvim"
]; ];
vim.luaConfigRC.modes-nvim = entryAnywhere '' vim.pluginRC.modes-nvim = entryAnywhere ''
require('modes').setup(${toLuaObject cfg.setupOpts}) require('modes').setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -23,7 +23,7 @@ in {
treesitter.grammars = optionals tscfg.addDefaultGrammars defaultGrammars; treesitter.grammars = optionals tscfg.addDefaultGrammars defaultGrammars;
luaConfigRC.noice-nvim = entryAnywhere '' pluginRC.noice-nvim = entryAnywhere ''
require("noice").setup(${toLuaObject cfg.setupOpts}) require("noice").setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -13,7 +13,7 @@ in {
vim = { vim = {
startPlugins = ["nvim-notify"]; startPlugins = ["nvim-notify"];
luaConfigRC.nvim-notify = entryAnywhere '' pluginRC.nvim-notify = entryAnywhere ''
require('notify').setup(${toLuaObject cfg.setupOpts}) require('notify').setup(${toLuaObject cfg.setupOpts})
-- required to fix offset_encoding errors -- required to fix offset_encoding errors

View file

@ -13,7 +13,7 @@ in {
vim = { vim = {
startPlugins = ["smartcolumn"]; startPlugins = ["smartcolumn"];
luaConfigRC.smartcolumn = entryAnywhere '' pluginRC.smartcolumn = entryAnywhere ''
require("smartcolumn").setup(${toLuaObject cfg.setupOpts}) require("smartcolumn").setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -11,7 +11,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["cheatsheet-nvim"]; vim.startPlugins = ["cheatsheet-nvim"];
vim.luaConfigRC.cheaetsheet-nvim = entryAnywhere '' vim.pluginRC.cheaetsheet-nvim = entryAnywhere ''
require('cheatsheet').setup({}) require('cheatsheet').setup({})
''; '';
}; };

View file

@ -13,7 +13,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["which-key"]; vim.startPlugins = ["which-key"];
vim.luaConfigRC.whichkey = entryAnywhere '' vim.pluginRC.whichkey = entryAnywhere ''
local wk = require("which-key") local wk = require("which-key")
wk.setup ({ wk.setup ({
key_labels = { key_labels = {

View file

@ -13,7 +13,7 @@ in {
"ccc" "ccc"
]; ];
vim.luaConfigRC.ccc = entryAnywhere '' vim.pluginRC.ccc = entryAnywhere ''
local ccc = require("ccc") local ccc = require("ccc")
ccc.setup { ccc.setup {
highlighter = { highlighter = {

View file

@ -25,7 +25,7 @@ in {
}) })
]; ];
vim.luaConfigRC.gesture-nvim = entryAnywhere '' vim.pluginRC.gesture-nvim = entryAnywhere ''
vim.opt.mouse = "a" vim.opt.mouse = "a"
local gesture = require("gesture") local gesture = require("gesture")

View file

@ -14,7 +14,7 @@ in {
"dressing-nvim" "dressing-nvim"
]; ];
vim.luaConfigRC.icon-picker = entryAnywhere '' vim.pluginRC.icon-picker = entryAnywhere ''
require("icon-picker").setup({ require("icon-picker").setup({
disable_legacy_commands = true disable_legacy_commands = true
}) })

View file

@ -19,7 +19,7 @@ in {
"magick" "magick"
]; ];
luaConfigRC.image-nvim = entryAnywhere '' pluginRC.image-nvim = entryAnywhere ''
require("image").setup( require("image").setup(
${toLuaObject cfg.setupOpts} ${toLuaObject cfg.setupOpts}
) )

View file

@ -19,7 +19,7 @@ in {
vim.maps.normal = mkSetBinding mappings.hop "<cmd> HopPattern<CR>"; vim.maps.normal = mkSetBinding mappings.hop "<cmd> HopPattern<CR>";
vim.luaConfigRC.hop-nvim = entryAnywhere '' vim.pluginRC.hop-nvim = entryAnywhere ''
require('hop').setup() require('hop').setup()
''; '';
}; };

View file

@ -37,7 +37,7 @@ in {
(mkBinding cfg.mappings.leapFromWindow "<Plug>(leap-from-window)" "Leap from window") (mkBinding cfg.mappings.leapFromWindow "<Plug>(leap-from-window)" "Leap from window")
]; ];
vim.luaConfigRC.leap-nvim = entryAnywhere '' vim.pluginRC.leap-nvim = entryAnywhere ''
require('leap').opts = { require('leap').opts = {
max_phase_one_targets = nil, max_phase_one_targets = nil,
highlight_unlabeled_phase_one_targets = false, highlight_unlabeled_phase_one_targets = false,

View file

@ -25,7 +25,7 @@ in {
"<leader>pm" = "+Preview Markdown"; "<leader>pm" = "+Preview Markdown";
}; };
vim.luaConfigRC.glow = entryAnywhere '' vim.pluginRC.glow = entryAnywhere ''
require('glow').setup({ require('glow').setup({
glow_path = "${pkgs.glow}/bin/glow" glow_path = "${pkgs.glow}/bin/glow"
}); });

View file

@ -4,25 +4,23 @@
lib, lib,
... ...
}: let }: let
inherit (lib.strings) optionalString stringLength concatMapStringsSep; inherit (lib.strings) stringLength concatMapStringsSep;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.vim) mkVimBool;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.preview.markdownPreview; cfg = config.vim.utility.preview.markdownPreview;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = [pkgs.vimPlugins.markdown-preview-nvim]; vim.startPlugins = [pkgs.vimPlugins.markdown-preview-nvim];
vim.configRC.markdown-preview = entryAnywhere '' vim.globals = {
let g:mkdp_auto_start = ${mkVimBool cfg.autoStart} mkdp_auto_start = cfg.autoStart;
let g:mkdp_auto_close = ${mkVimBool cfg.autoClose} mkdp_auto_close = cfg.autoClose;
let g:mkdp_refresh_slow = ${mkVimBool cfg.lazyRefresh} mkdp_refresh_slow = cfg.lazyRefresh;
let g:mkdp_filetypes = [${concatMapStringsSep ", " (x: "'" + x + "'") cfg.filetypes}] mkdp_filetypes = [(concatMapStringsSep ", " (x: "'" + x + "'") cfg.filetypes)];
let g:mkdp_command_for_global = ${mkVimBool cfg.alwaysAllowPreview} mkdp_command_for_global = cfg.alwaysAllowPreview;
let g:mkdp_open_to_the_world = ${mkVimBool cfg.broadcastServer} mkdp_open_to_the_world = cfg.broadcastServer;
${optionalString (stringLength cfg.customIP > 0) "let g:mkdp_open_ip = '${cfg.customIP}'"} mkdp_open_ip = mkIf (stringLength cfg.customIP > 0) cfg.customIP;
${optionalString (stringLength cfg.customPort > 0) "let g:mkdp_port = '${cfg.customPort}'"} mkdp_port = mkIf (stringLength cfg.customPort > 0) cfg.customPort;
''; };
}; };
} }

View file

@ -18,7 +18,7 @@ in {
"nvim-surround" "nvim-surround"
]; ];
luaConfigRC.surround = entryAnywhere '' pluginRC.surround = entryAnywhere ''
require('nvim-surround').setup() require('nvim-surround').setup()
''; '';

View file

@ -65,7 +65,7 @@ in {
"<leader>fvc" = "Commits"; "<leader>fvc" = "Commits";
}; };
vim.luaConfigRC.telescope = entryAnywhere '' vim.pluginRC.telescope = entryAnywhere ''
local telescope = require('telescope') local telescope = require('telescope')
telescope.setup(${toLuaObject cfg.setupOpts}) telescope.setup(${toLuaObject cfg.setupOpts})

View file

@ -5,21 +5,14 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.vim-wakatime; cfg = config.vim.utility.vim-wakatime;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = [ vim.startPlugins = [pkgs.vimPlugins.vim-wakatime];
pkgs.vimPlugins.vim-wakatime
];
vim.configRC.vim-wakatime = entryAnywhere '' vim.pluginRC.vim-wakatime = mkIf (cfg.cli-package != null) ''
${ vim.g.wakatime_CLIPath = "${cfg.cli-package}"
if cfg.cli-package == null
then ""
else ''let g:wakatime_CLIPath = "${cfg.cli-package}"''
}
''; '';
}; };
} }

View file

@ -14,14 +14,14 @@ in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
(mkIf cfg.indentBlankline.enable { (mkIf cfg.indentBlankline.enable {
vim.startPlugins = ["indent-blankline"]; vim.startPlugins = ["indent-blankline"];
vim.luaConfigRC.indent-blankline = entryAnywhere '' vim.pluginRC.indent-blankline = entryAnywhere ''
require("ibl").setup(${toLuaObject cfg.indentBlankline.setupOpts}) require("ibl").setup(${toLuaObject cfg.indentBlankline.setupOpts})
''; '';
}) })
(mkIf cfg.cursorline.enable { (mkIf cfg.cursorline.enable {
vim.startPlugins = ["nvim-cursorline"]; vim.startPlugins = ["nvim-cursorline"];
vim.luaConfigRC.cursorline = entryAnywhere '' vim.pluginRC.cursorline = entryAnywhere ''
require('nvim-cursorline').setup { require('nvim-cursorline').setup {
cursorline = { cursorline = {
timeout = ${toString cfg.cursorline.lineTimeout}, timeout = ${toString cfg.cursorline.lineTimeout},
@ -37,7 +37,7 @@ in {
(mkIf cfg.scrollBar.enable { (mkIf cfg.scrollBar.enable {
vim.startPlugins = ["scrollbar-nvim"]; vim.startPlugins = ["scrollbar-nvim"];
vim.luaConfigRC.scrollBar = entryAnywhere '' vim.pluginRC.scrollBar = entryAnywhere ''
require('scrollbar').setup{ require('scrollbar').setup{
excluded_filetypes = { excluded_filetypes = {
'prompt', 'prompt',
@ -56,7 +56,7 @@ in {
(mkIf cfg.smoothScroll.enable { (mkIf cfg.smoothScroll.enable {
vim.startPlugins = ["cinnamon-nvim"]; vim.startPlugins = ["cinnamon-nvim"];
vim.luaConfigRC.smoothScroll = entryAnywhere '' vim.pluginRC.smoothScroll = entryAnywhere ''
require('cinnamon').setup() require('cinnamon').setup()
''; '';
}) })
@ -66,7 +66,7 @@ in {
vim.maps.normal = mkBinding cfg.cellularAutomaton.mappings.makeItRain "<cmd>CellularAutomaton make_it_rain<CR>" "Make it rain"; vim.maps.normal = mkBinding cfg.cellularAutomaton.mappings.makeItRain "<cmd>CellularAutomaton make_it_rain<CR>" "Make it rain";
vim.luaConfigRC.cellularAUtomaton = entryAnywhere '' vim.pluginRC.cellularAUtomaton = entryAnywhere ''
local config = { local config = {
fps = 50, fps = 50,
name = 'slide', name = 'slide',
@ -94,7 +94,7 @@ in {
(mkIf cfg.highlight-undo.enable { (mkIf cfg.highlight-undo.enable {
vim.startPlugins = ["highlight-undo"]; vim.startPlugins = ["highlight-undo"];
vim.luaConfigRC.highlight-undo = entryAnywhere '' vim.pluginRC.highlight-undo = entryAnywhere ''
require('highlight-undo').setup({ require('highlight-undo').setup({
duration = ${toString cfg.highlight-undo.duration}, duration = ${toString cfg.highlight-undo.duration},
highlight_for_count = ${boolToString cfg.highlight-undo.highlightForCount}, highlight_for_count = ${boolToString cfg.highlight-undo.highlightForCount},

View file

@ -12,7 +12,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["fidget-nvim"]; vim.startPlugins = ["fidget-nvim"];
vim.luaConfigRC.fidget-nvim = entryAnywhere '' vim.pluginRC.fidget-nvim = entryAnywhere ''
require'fidget'.setup(${toLuaObject cfg.setupOpts}) require'fidget'.setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -3,17 +3,16 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) map mapAttrs toJSON filter; inherit (builtins) map mapAttrs filter;
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.attrsets) filterAttrs getAttrs attrValues attrNames; inherit (lib.attrsets) filterAttrs getAttrs attrValues attrNames;
inherit (lib.strings) isString concatLines concatMapStringsSep; inherit (lib.strings) concatLines concatMapStringsSep;
inherit (lib.misc) mapAttrsFlatten; inherit (lib.misc) mapAttrsFlatten;
inherit (lib.trivial) showWarnings; inherit (lib.trivial) showWarnings;
inherit (lib.types) str nullOr; inherit (lib.types) str nullOr;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.dag) entryAnywhere entryAfter topoSort mkLuarcSection mkVimrcSection; inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere;
inherit (lib.nvim.lua) toLuaObject wrapLuaConfig; inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.vim) valToVim;
inherit (lib.nvim.config) mkBool; inherit (lib.nvim.config) mkBool;
cfg = config.vim; cfg = config.vim;
@ -82,11 +81,23 @@
maps); maps);
in { in {
config = let config = let
filterNonNull = mappings: filterAttrs (_name: value: value != null) mappings; filterNonNull = attrs: filterAttrs (_: value: value != null) attrs;
globalsScript = globalsScript =
mapAttrsFlatten (name: value: "let g:${name}=${valToVim value}") mapAttrsFlatten (name: value: "vim.g.${name} = ${toLuaObject value}")
(filterNonNull cfg.globals); (filterNonNull cfg.globals);
extraPluginConfigs = resolveDag {
name = "extra plugin configs";
dag = mapAttrs (_: value: entryAfter value.after value.setup) cfg.extraPlugins;
mapResult = result: concatLines (map mkLuarcSection result);
};
pluginConfigs = resolveDag {
name = "plugin configs";
dag = cfg.pluginRC;
mapResult = result: concatLines (map mkLuarcSection result);
};
toLuaBindings = mode: maps: toLuaBindings = mode: maps:
map (value: '' map (value: ''
vim.keymap.set(${toLuaObject mode}, ${toLuaObject value.key}, ${toLuaObject value.action}, ${toLuaObject value.config}) vim.keymap.set(${toLuaObject mode}, ${toLuaObject value.key}, ${toLuaObject value.action}, ${toLuaObject value.config})
@ -105,96 +116,31 @@ in {
omap = toLuaBindings "o" config.vim.maps.operator; omap = toLuaBindings "o" config.vim.maps.operator;
icmap = toLuaBindings "ic" config.vim.maps.insertCommand; icmap = toLuaBindings "ic" config.vim.maps.insertCommand;
resolveDag = { maps = [
name, nmap
dag, imap
mapResult, vmap
}: let xmap
# When the value is a string, default it to dag.entryAnywhere smap
finalDag = mapAttrs (_: value: cmap
if isString value omap
then entryAnywhere value tmap
else value) lmap
dag; icmap
sortedDag = topoSort finalDag; allmap
result = ];
if sortedDag ? result mappings = concatLines (map concatLines maps);
then mapResult sortedDag.result
else abort ("Dependency cycle in ${name}: " + toJSON sortedDag);
in
result;
in { in {
vim = { vim = {
configRC = { luaConfigRC = {
globalsScript = entryAnywhere (concatLines globalsScript); globalsScript = entryAnywhere (concatLines globalsScript);
# basic, theme
# Call additional lua files with :luafile in Vimscript pluginConfigs = entryAfter ["theme"] pluginConfigs;
# section of the configuration, only after extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
# the luaScript section has been evaluated mappings = entryAfter ["extraPluginConfigs"] mappings;
extraLuaFiles = let
callLuaFiles = map (file: "luafile ${file}") cfg.extraLuaFiles;
in
entryAfter ["globalScript"] (concatLines callLuaFiles);
# wrap the lua config in a lua block
# using the wrapLuaConfic function from the lib
luaScript = let
mapResult = result: (wrapLuaConfig {
luaBefore = "${cfg.luaConfigPre}";
luaConfig = concatLines (map mkLuarcSection result);
luaAfter = "${cfg.luaConfigPost}";
});
luaConfig = resolveDag {
name = "lua config script";
dag = cfg.luaConfigRC;
inherit mapResult;
};
in
entryAnywhere luaConfig;
extraPluginConfigs = let
mapResult = result: (wrapLuaConfig {
luaConfig = concatLines (map mkLuarcSection result);
});
extraPluginsDag = mapAttrs (_: {
after,
setup,
...
}:
entryAfter after setup)
cfg.extraPlugins;
pluginConfig = resolveDag {
name = "extra plugins config";
dag = extraPluginsDag;
inherit mapResult;
};
in
entryAfter ["luaScript"] pluginConfig;
# This is probably not the right way to set the config. I'm not sure how it should look like.
mappings = let
maps = [
nmap
imap
vmap
xmap
smap
cmap
omap
tmap
lmap
icmap
allmap
];
mapConfig = wrapLuaConfig {luaConfig = concatLines (map concatLines maps);};
in
entryAfter ["globalsScript"] mapConfig;
}; };
builtConfigRC = let builtLuaConfigRC = let
# Catch assertions and warnings # Catch assertions and warnings
# and throw for each failed assertion. If no assertions are found, show warnings. # and throw for each failed assertion. If no assertions are found, show warnings.
failedAssertions = map (x: x.message) (filter (x: !x.assertion) config.assertions); failedAssertions = map (x: x.message) (filter (x: !x.assertion) config.assertions);
@ -203,14 +149,18 @@ in {
then throw "\nFailed assertions:\n${concatMapStringsSep "\n" (x: "- ${x}") failedAssertions}" then throw "\nFailed assertions:\n${concatMapStringsSep "\n" (x: "- ${x}") failedAssertions}"
else showWarnings config.warnings; else showWarnings config.warnings;
mapResult = result: concatMapStringsSep "\n" mkVimrcSection result; luaConfig = resolveDag {
vimConfig = resolveDag { name = "lua config script";
name = "vim config script"; dag = cfg.luaConfigRC;
dag = cfg.configRC; mapResult = result:
inherit mapResult; concatLines [
cfg.luaConfigPre
(concatMapStringsSep "\n" mkLuarcSection result)
cfg.luaConfigPost
];
}; };
in in
baseSystemAssertWarn vimConfig; baseSystemAssertWarn luaConfig;
}; };
}; };
} }

View file

@ -3,13 +3,25 @@
lib, lib,
... ...
}: let }: let
inherit (lib.modules) mkRemovedOptionModule;
inherit (lib.options) mkOption mkEnableOption literalMD literalExpression; inherit (lib.options) mkOption mkEnableOption literalMD literalExpression;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.types) str oneOf attrs lines listOf either path bool; inherit (lib.types) str attrs lines listOf either path bool;
inherit (lib.nvim.types) dagOf; inherit (lib.nvim.types) dagOf;
inherit (lib.nvim.lua) listToLuaTable; inherit (lib.nvim.lua) listToLuaTable;
cfg = config.vim; cfg = config.vim;
in { in {
imports = [
(mkRemovedOptionModule ["vim" "configRC"] ''
Please migrate your configRC sections to Neovim's Lua format, and
add them to luaConfigRC.
See the v0.7 release notes for more information on how to migrate
your existing configurations.
'')
];
options.vim = { options.vim = {
enableLuaLoader = mkEnableOption '' enableLuaLoader = mkEnableOption ''
the experimental Lua module loader to speed up the start up process the experimental Lua module loader to speed up the start up process
@ -120,35 +132,20 @@ in {
description = '' description = ''
An attribute set containing global variable values An attribute set containing global variable values
for storing vim variables as early as possible. If for storing vim variables as early as possible. If
populated, this soption will set vim variables in the populated, this option will set vim variables in the
built configRC as the first item. built luaConfigRC as the first item.
E.g. {foo = "bar"} will set `g:foo` to "bar" where E.g. {foo = "bar"} will set `vim.g.foo` to "bar" where
the type of `bar` in the resulting vimscript will be the type of `bar` in the resulting vimscript will be
infered from the type of the value in the `{name = value}` infered from the type of the value in the `{name = value}`
pair. pair.
''; '';
}; };
configRC = mkOption { pluginRC = mkOption {
type = oneOf [(dagOf lines) str]; type = either (dagOf lines) str;
default = {}; default = {};
description = '' description = "The DAG used to configure plugins. If a string is passed, entryAnywhere is automatically applied.";
Contents of vimrc, either as a string or a DAG.
If this option is passed as a DAG, it will be resolved
according to the DAG resolution rules (e.g. entryBefore
or entryAfter) as per the **nvf** extended library.
'';
example = literalMD ''
```vim
" Set the tab size to 4 spaces
set tabstop=4
set shiftwidth=4
set expandtab
```
'';
}; };
luaConfigPre = mkOption { luaConfigPre = mkOption {
@ -211,7 +208,7 @@ in {
}; };
luaConfigRC = mkOption { luaConfigRC = mkOption {
type = oneOf [(dagOf lines) str]; type = either (dagOf lines) str;
default = {}; default = {};
description = '' description = ''
Lua configuration, either as a string or a DAG. Lua configuration, either as a string or a DAG.
@ -245,10 +242,10 @@ in {
''; '';
}; };
builtConfigRC = mkOption { builtLuaConfigRC = mkOption {
internal = true; internal = true;
type = lines; type = lines;
description = "The built config for neovim after resolving the DAG"; description = "The built lua config for neovim after resolving the DAG";
}; };
}; };
} }