mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-26 15:06:45 +00:00
Compare commits
38 commits
f6500bbd05
...
78203a1bce
Author | SHA1 | Date | |
---|---|---|---|
|
78203a1bce | ||
|
0976df3a2e | ||
|
44e16dc3fc | ||
|
09b89c809a | ||
|
d8f3b73b2c | ||
|
fcc360c3ce | ||
|
324cfed759 | ||
|
1eae8c8d55 | ||
|
11dca73b37 | ||
|
88de04e94c | ||
|
5ba5fa29ff | ||
|
1781b6d8c3 | ||
|
cdda400905 | ||
|
a0f4e6a942 | ||
|
c49f0c25c5 | ||
|
b5d2a10d25 | ||
|
5ed6f11880 | ||
|
ce10162f17 | ||
|
bcd5ab38d7 | ||
|
91e2df6a93 | ||
|
054e60edf0 | ||
|
06f11946fd | ||
|
fab27790ea | ||
|
bbec94cf77 | ||
|
7910f87811 | ||
|
f280ca9e76 | ||
|
703aaecbde | ||
|
f05411c4e0 | ||
|
5f517cae34 | ||
|
45d8a9ec13 | ||
|
a586c7cba6 | ||
|
a3379d8fe8 | ||
|
ecf1ae31f2 | ||
3ca7e3b841 | |||
|
7d824d6711 | ||
|
b71bf75dcd | ||
|
de20ff2c51 | ||
|
fd65c83956 |
21 changed files with 655 additions and 349 deletions
|
@ -83,7 +83,7 @@ Release notes for release 0.5
|
||||||
|
|
||||||
- Updated indent-blankine.nvim to v3 - this comes with a few option changes, which will be migrated with `renamedOptionModule`
|
- Updated indent-blankine.nvim to v3 - this comes with a few option changes, which will be migrated with `renamedOptionModule`
|
||||||
|
|
||||||
[jacekpoz](https://github.com/jacekpoz):
|
[jacekpoz](https://jacekpoz.pl):
|
||||||
|
|
||||||
- Fixed scrollOffset not being used
|
- Fixed scrollOffset not being used
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ vim.api.nvim_set_keymap('n', '<leader>a', ':lua camelToSnake()<CR>', { noremap =
|
||||||
|
|
||||||
- Added rose-pine theme.
|
- Added rose-pine theme.
|
||||||
|
|
||||||
[jacekpoz](https://github.com/jacekpoz):
|
[jacekpoz](https://jacekpoz.pl):
|
||||||
|
|
||||||
- Added `vim.autocomplete.alwaysComplete`. Allows users to have the autocomplete window popup only when manually activated.
|
- Added `vim.autocomplete.alwaysComplete`. Allows users to have the autocomplete window popup only when manually activated.
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ Release notes for release 0.7
|
||||||
|
|
||||||
## Breaking Changes and Migration Guide {#sec-breaking-changes-and-migration-guide-0-7}
|
## Breaking Changes and Migration Guide {#sec-breaking-changes-and-migration-guide-0-7}
|
||||||
|
|
||||||
|
### `vim.configRC` removed
|
||||||
|
|
||||||
In v0.7 we are removing `vim.configRC` in favor of making `vim.luaConfigRC` the
|
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
|
top-level DAG, and thereby making the entire configuration Lua based. This
|
||||||
change introduces a few breaking changes:
|
change introduces a few breaking changes:
|
||||||
|
@ -24,6 +26,28 @@ making good use of its extensive Lua API. Additionally, Vimscript is slow and
|
||||||
brings unnecessary performance overhead while working with different
|
brings unnecessary performance overhead while working with different
|
||||||
configuration formats.
|
configuration formats.
|
||||||
|
|
||||||
|
### `vim.maps` rewrite
|
||||||
|
|
||||||
|
Instead of specifying map modes using submodules (eg.: `vim.maps.normal`), a new
|
||||||
|
`mode` option has mode has been introduced. It can be either a string, or a list
|
||||||
|
of strings, where a string represents the short-name of the map mode(s), that
|
||||||
|
the mapping should be set for. See `:help map-modes` for more information.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
vim.maps.normal."<leader>m" = { ... };
|
||||||
|
```
|
||||||
|
|
||||||
|
has to be replaced by
|
||||||
|
|
||||||
|
```nix
|
||||||
|
vim.maps."<leader>m" = {
|
||||||
|
mode = "n";
|
||||||
|
...
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
## Changelog {#sec-release-0.7-changelog}
|
## Changelog {#sec-release-0.7-changelog}
|
||||||
|
|
||||||
[ItsSorae](https://github.com/ItsSorae):
|
[ItsSorae](https://github.com/ItsSorae):
|
||||||
|
@ -62,14 +86,17 @@ configuration formats.
|
||||||
recommended to go through rustacean.nvim's README to take a closer look at its
|
recommended to go through rustacean.nvim's README to take a closer look at its
|
||||||
features and usage
|
features and usage
|
||||||
|
|
||||||
[jacekpoz](https://github.com/jacekpoz):
|
[jacekpoz](https://jacekpoz.pl):
|
||||||
|
|
||||||
[ocaml-lsp]: https://github.com/ocaml/ocaml-lsp
|
[ocaml-lsp]: https://github.com/ocaml/ocaml-lsp
|
||||||
|
[new-file-template.nvim]: https://github.com/otavioschwanck/new-file-template.nvim
|
||||||
|
|
||||||
- Add [ocaml-lsp] support
|
- Add [ocaml-lsp] support
|
||||||
|
|
||||||
- Fix "Emac" typo
|
- Fix "Emac" typo
|
||||||
|
|
||||||
|
- Add [new-file-template.nvim] to automatically fill new file contents using templates.
|
||||||
|
|
||||||
[diniamo](https://github.com/diniamo):
|
[diniamo](https://github.com/diniamo):
|
||||||
|
|
||||||
- Move the `theme` dag entry to before `luaScript`.
|
- Move the `theme` dag entry to before `luaScript`.
|
||||||
|
@ -111,6 +138,8 @@ configuration formats.
|
||||||
has been introduced for setting up internal plugins. See the "DAG entries in
|
has been introduced for setting up internal plugins. See the "DAG entries in
|
||||||
nvf" manual page for more information.
|
nvf" manual page for more information.
|
||||||
|
|
||||||
|
- Rewrite `vim.maps`, see the breaking changes section above.
|
||||||
|
|
||||||
[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
|
||||||
|
@ -140,10 +169,10 @@ configuration formats.
|
||||||
- Add [neo-tree.nvim] as an alternative file-tree plugin. It will be available
|
- Add [neo-tree.nvim] as an alternative file-tree plugin. It will be available
|
||||||
under `vim.filetree.neo-tree`, similar to nvimtree.
|
under `vim.filetree.neo-tree`, similar to nvimtree.
|
||||||
|
|
||||||
- Add `print-nvf-config` & `print-nvf-config-path` helper scripts to Neovim
|
- Add `nvf-print-config` & `nvf-print-config-path` helper scripts to Neovim
|
||||||
closure. Both of those scripts have been automatically added to your PATH upon
|
closure. Both of those scripts have been automatically added to your PATH upon
|
||||||
using neovimConfig or `programs.nvf.enable`.
|
using neovimConfig or `programs.nvf.enable`.
|
||||||
- `print-nvf-config` will display your `init.lua`, in full.
|
- `nvf-print-config` will display your `init.lua`, in full.
|
||||||
- `print-nvf-config-path` will display the path to _a clone_ of your
|
- `nvf-print-config-path` will display the path to _a clone_ of your
|
||||||
`init.lua`. This is not the path used by the Neovim wrapper, but an
|
`init.lua`. This is not the path used by the Neovim wrapper, but an
|
||||||
identical clone.
|
identical clone.
|
||||||
|
|
57
flake.lock
57
flake.lock
|
@ -69,11 +69,11 @@
|
||||||
},
|
},
|
||||||
"mnw": {
|
"mnw": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722191188,
|
"lastModified": 1723419050,
|
||||||
"narHash": "sha256-YF//iMALbrd2Ni9aju7w8NniH16Qz6RFTRD6md5UkDc=",
|
"narHash": "sha256-Eb8jBUgHwpte+bGsqeXNbKMBfZaDB7RiPQwyb1vzJK8=",
|
||||||
"owner": "Gerg-L",
|
"owner": "Gerg-L",
|
||||||
"repo": "mnw",
|
"repo": "mnw",
|
||||||
"rev": "c7b289f3f5a31b6e744be37d83fc231816621231",
|
"rev": "e625f5965567f16102bc52897c7600dcde53c6c3",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -843,6 +843,38 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"plugin-lz-n": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1719989949,
|
||||||
|
"narHash": "sha256-oHwmlLgdJJDz5+gs1KLAa2MHQAadM/JYmHGfep9yl28=",
|
||||||
|
"owner": "nvim-neorocks",
|
||||||
|
"repo": "lz.n",
|
||||||
|
"rev": "4c790ba2c3789f580aa019712bbe3112f85e73a0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nvim-neorocks",
|
||||||
|
"repo": "lz.n",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"plugin-lzn-auto-require": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1722727896,
|
||||||
|
"narHash": "sha256-h7Dx3zBkUYamQY6lcuQrwAMgBpPqskLnA6WsbefHzMU=",
|
||||||
|
"owner": "horriblename",
|
||||||
|
"repo": "lzn-auto-require",
|
||||||
|
"rev": "c6b47e148a1ff9709e802f68c2c8b558a9a8de9b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "horriblename",
|
||||||
|
"repo": "lzn-auto-require",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"plugin-mind-nvim": {
|
"plugin-mind-nvim": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
@ -939,6 +971,22 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"plugin-new-file-template-nvim": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1721518222,
|
||||||
|
"narHash": "sha256-g0IjJrHRXw7U9goVLzVYUyHBSsDZGHMpi3YZPhg64zA=",
|
||||||
|
"owner": "otavioschwanck",
|
||||||
|
"repo": "new-file-template.nvim",
|
||||||
|
"rev": "6ac66669dbf2dc5cdee184a4fe76d22465ca67e8",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "otavioschwanck",
|
||||||
|
"repo": "new-file-template.nvim",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"plugin-noice-nvim": {
|
"plugin-noice-nvim": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
@ -1856,12 +1904,15 @@
|
||||||
"plugin-lspkind": "plugin-lspkind",
|
"plugin-lspkind": "plugin-lspkind",
|
||||||
"plugin-lspsaga": "plugin-lspsaga",
|
"plugin-lspsaga": "plugin-lspsaga",
|
||||||
"plugin-lualine": "plugin-lualine",
|
"plugin-lualine": "plugin-lualine",
|
||||||
|
"plugin-lz-n": "plugin-lz-n",
|
||||||
|
"plugin-lzn-auto-require": "plugin-lzn-auto-require",
|
||||||
"plugin-mind-nvim": "plugin-mind-nvim",
|
"plugin-mind-nvim": "plugin-mind-nvim",
|
||||||
"plugin-minimap-vim": "plugin-minimap-vim",
|
"plugin-minimap-vim": "plugin-minimap-vim",
|
||||||
"plugin-modes-nvim": "plugin-modes-nvim",
|
"plugin-modes-nvim": "plugin-modes-nvim",
|
||||||
"plugin-neo-tree-nvim": "plugin-neo-tree-nvim",
|
"plugin-neo-tree-nvim": "plugin-neo-tree-nvim",
|
||||||
"plugin-neocord": "plugin-neocord",
|
"plugin-neocord": "plugin-neocord",
|
||||||
"plugin-neodev-nvim": "plugin-neodev-nvim",
|
"plugin-neodev-nvim": "plugin-neodev-nvim",
|
||||||
|
"plugin-new-file-template-nvim": "plugin-new-file-template-nvim",
|
||||||
"plugin-noice-nvim": "plugin-noice-nvim",
|
"plugin-noice-nvim": "plugin-noice-nvim",
|
||||||
"plugin-none-ls": "plugin-none-ls",
|
"plugin-none-ls": "plugin-none-ls",
|
||||||
"plugin-nui-nvim": "plugin-nui-nvim",
|
"plugin-nui-nvim": "plugin-nui-nvim",
|
||||||
|
|
19
flake.nix
19
flake.nix
|
@ -102,6 +102,17 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
## Plugins
|
## Plugins
|
||||||
|
# Lazy loading
|
||||||
|
plugin-lz-n = {
|
||||||
|
url = "github:nvim-neorocks/lz.n";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
plugin-lzn-auto-require = {
|
||||||
|
url = "github:horriblename/lzn-auto-require";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
# LSP plugins
|
# LSP plugins
|
||||||
plugin-nvim-lspconfig = {
|
plugin-nvim-lspconfig = {
|
||||||
url = "github:neovim/nvim-lspconfig";
|
url = "github:neovim/nvim-lspconfig";
|
||||||
|
@ -628,9 +639,15 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
plugin-nvim-nio = {
|
plugin-nvim-nio = {
|
||||||
# (required nvim-dap-ui)
|
# (required by nvim-dap-ui)
|
||||||
url = "github:nvim-neotest/nvim-nio";
|
url = "github:nvim-neotest/nvim-nio";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
plugin-new-file-template-nvim = {
|
||||||
|
# (required by new-file-template.nvim)
|
||||||
|
url = "github:otavioschwanck/new-file-template.nvim";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,31 +3,31 @@
|
||||||
inherit (lib.modules) mkIf mkDefault;
|
inherit (lib.modules) mkIf mkDefault;
|
||||||
inherit (lib.types) nullOr str;
|
inherit (lib.types) nullOr str;
|
||||||
inherit (lib.attrsets) isAttrs mapAttrs;
|
inherit (lib.attrsets) isAttrs mapAttrs;
|
||||||
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
|
||||||
binds = rec {
|
mkLuaBinding = mode: key: action: desc:
|
||||||
mkLuaBinding = key: action: desc:
|
|
||||||
mkIf (key != null) {
|
mkIf (key != null) {
|
||||||
"${key}" = {
|
${key} = {
|
||||||
inherit action desc;
|
inherit mode action desc;
|
||||||
lua = true;
|
lua = true;
|
||||||
silent = true;
|
silent = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
mkExprBinding = key: action: desc:
|
mkExprBinding = mode: key: action: desc:
|
||||||
mkIf (key != null) {
|
mkIf (key != null) {
|
||||||
"${key}" = {
|
${key} = {
|
||||||
inherit action desc;
|
inherit mode action desc;
|
||||||
lua = true;
|
lua = true;
|
||||||
silent = true;
|
silent = true;
|
||||||
expr = true;
|
expr = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
mkBinding = key: action: desc:
|
mkBinding = mode: key: action: desc:
|
||||||
mkIf (key != null) {
|
mkIf (key != null) {
|
||||||
"${key}" = {
|
${key} = {
|
||||||
inherit action desc;
|
inherit mode action desc;
|
||||||
silent = true;
|
silent = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -38,6 +38,34 @@
|
||||||
inherit default description;
|
inherit default description;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Utility function that takes two attrsets:
|
||||||
|
# { someKey = "some_value" } and
|
||||||
|
# { someKey = { description = "Some Description"; }; }
|
||||||
|
# and merges them into
|
||||||
|
# { someKey = { value = "some_value"; description = "Some Description"; }; }
|
||||||
|
addDescriptionsToMappings = actualMappings: mappingDefinitions:
|
||||||
|
mapAttrs (name: value: let
|
||||||
|
isNested = isAttrs value;
|
||||||
|
returnedValue =
|
||||||
|
if isNested
|
||||||
|
then addDescriptionsToMappings actualMappings.${name} mappingDefinitions.${name}
|
||||||
|
else {
|
||||||
|
inherit value;
|
||||||
|
inherit (mappingDefinitions.${name}) description;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
returnedValue)
|
||||||
|
actualMappings;
|
||||||
|
|
||||||
|
mkSetBinding = mode: binding: action:
|
||||||
|
mkBinding mode binding.value action binding.description;
|
||||||
|
|
||||||
|
mkSetExprBinding = mode: binding: action:
|
||||||
|
mkExprBinding mode binding.value action binding.description;
|
||||||
|
|
||||||
|
mkSetLuaBinding = mode: binding: action:
|
||||||
|
mkLuaBinding mode binding.value action binding.description;
|
||||||
|
|
||||||
# Utility function that takes two attrsets:
|
# Utility function that takes two attrsets:
|
||||||
# { someKey = "some_value" } and
|
# { someKey = "some_value" } and
|
||||||
# { someKey = { description = "Some Description"; }; }
|
# { someKey = { description = "Some Description"; }; }
|
||||||
|
@ -67,6 +95,22 @@
|
||||||
mkLuaBinding binding.value action binding.description;
|
mkLuaBinding binding.value action binding.description;
|
||||||
|
|
||||||
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
|
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
|
||||||
|
|
||||||
|
mkLznBinding = mode: lhs: rhs: desc: {
|
||||||
|
inherit mode lhs rhs desc;
|
||||||
|
};
|
||||||
|
|
||||||
|
mkSetLznBinding = binding: action: {
|
||||||
|
lhs = binding.value;
|
||||||
|
rhs = action;
|
||||||
|
desc = binding.description;
|
||||||
|
};
|
||||||
|
|
||||||
|
mkSetLuaLznBinding = binding: action: {
|
||||||
|
lhs = binding.value;
|
||||||
|
rhs = mkLuaInline "function() ${action} end";
|
||||||
|
desc = binding.description;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
binds
|
binds
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
typesCustom = import ./custom.nix {inherit lib;};
|
typesCustom = import ./custom.nix {inherit lib;};
|
||||||
in {
|
in {
|
||||||
inherit (typesDag) dagOf;
|
inherit (typesDag) dagOf;
|
||||||
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType;
|
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType lznPluginType lznPluginTableType;
|
||||||
inherit (typesLanguage) diagnostics mkGrammarOption;
|
inherit (typesLanguage) diagnostics mkGrammarOption;
|
||||||
inherit (typesCustom) anythingConcatLists char;
|
inherit (typesCustom) anythingConcatLists char;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,7 @@
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.options) mkOption;
|
||||||
inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair;
|
inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair;
|
||||||
inherit (lib.strings) hasPrefix removePrefix;
|
inherit (lib.strings) hasPrefix removePrefix;
|
||||||
inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr;
|
inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr oneOf bool;
|
||||||
|
|
||||||
# Get the names of all flake inputs that start with the given prefix.
|
# Get the names of all flake inputs that start with the given prefix.
|
||||||
fromInputs = {
|
fromInputs = {
|
||||||
inputs,
|
inputs,
|
||||||
|
@ -51,8 +50,156 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
luaInline = lib.mkOptionType {
|
||||||
|
name = "luaInline";
|
||||||
|
check = x: lib.nvim.lua.isLuaInline x;
|
||||||
|
};
|
||||||
|
|
||||||
|
lznKeysSpec = submodule {
|
||||||
|
options = {
|
||||||
|
desc = mkOption {
|
||||||
|
description = "Description of the key map";
|
||||||
|
type = nullOr str;
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
noremap = mkOption {
|
||||||
|
description = "TBD";
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
expr = mkOption {
|
||||||
|
description = "TBD";
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
nowait = mkOption {
|
||||||
|
description = "TBD";
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
ft = mkOption {
|
||||||
|
description = "TBD";
|
||||||
|
type = nullOr (listOf str);
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
lhs = mkOption {
|
||||||
|
type = str;
|
||||||
|
description = "Key to bind to";
|
||||||
|
};
|
||||||
|
|
||||||
|
rhs = mkOption {
|
||||||
|
type = nullOr (either str luaInline);
|
||||||
|
default = null;
|
||||||
|
# FIXME: use a separate flag to indicate lua instead of luaInline
|
||||||
|
description = "Action to trigger. luaInline code will be wrapped in a function.";
|
||||||
|
};
|
||||||
|
|
||||||
|
mode = mkOption {
|
||||||
|
description = "Modes to bind in";
|
||||||
|
type = listOf str;
|
||||||
|
default = ["n" "x" "s" "o"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
lznPluginTableType = attrsOf lznPluginType;
|
||||||
|
lznPluginType = submodule {
|
||||||
|
options = {
|
||||||
|
## Should probably infer from the actual plugin somehow
|
||||||
|
## In general this is the name passed to packadd, so the dir name of the plugin
|
||||||
|
# name = mkOption {
|
||||||
|
# type= str;
|
||||||
|
# }
|
||||||
|
|
||||||
|
# Non-lz.n options
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
type = pluginType;
|
||||||
|
description = "Plugin package";
|
||||||
|
};
|
||||||
|
|
||||||
|
setupModule = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
description = "Lua module to run setup function on.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
setupOpts = mkOption {
|
||||||
|
type = submodule {freeformType = attrsOf anything;};
|
||||||
|
description = "Options to pass to the setup function";
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
# lz.n options
|
||||||
|
|
||||||
|
before = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
description = "Lua code to run before plugin is loaded. This will be wrapped in a function.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
after = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
description = "Lua code to run after plugin is loaded. This will be wrapped in a function.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
event = mkOption {
|
||||||
|
description = "Lazy-load on event";
|
||||||
|
default = null;
|
||||||
|
type = let
|
||||||
|
event = submodule {
|
||||||
|
options = {
|
||||||
|
event = mkOption {
|
||||||
|
type = nullOr (either str (listOf str));
|
||||||
|
description = "Exact event name";
|
||||||
|
example = "BufEnter";
|
||||||
|
};
|
||||||
|
pattern = mkOption {
|
||||||
|
type = nullOr (either str (listOf str));
|
||||||
|
description = "Event pattern";
|
||||||
|
example = "BufEnter *.lua";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
nullOr (oneOf [str (listOf str) event]);
|
||||||
|
};
|
||||||
|
|
||||||
|
cmd = mkOption {
|
||||||
|
description = "Lazy-load on command";
|
||||||
|
default = null;
|
||||||
|
type = nullOr (either str (listOf str));
|
||||||
|
};
|
||||||
|
|
||||||
|
ft = mkOption {
|
||||||
|
description = "Lazy-load on filetype";
|
||||||
|
default = null;
|
||||||
|
type = nullOr (either str (listOf str));
|
||||||
|
};
|
||||||
|
|
||||||
|
keys = mkOption {
|
||||||
|
description = "Lazy-load on key mapping";
|
||||||
|
default = null;
|
||||||
|
type = nullOr (oneOf [str (listOf lznKeysSpec) (listOf str)]);
|
||||||
|
example = ''
|
||||||
|
keys = [
|
||||||
|
{lhs = "<leader>s"; rhs = ":NvimTreeToggle<cr>"; desc = "Toggle NvimTree"}
|
||||||
|
]
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# TODO: enabled, beforeAll, colorscheme, priority, load
|
||||||
|
};
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
inherit extraPluginType fromInputs pluginType;
|
inherit extraPluginType fromInputs pluginType luaInline lznPluginType lznPluginTableType;
|
||||||
|
|
||||||
pluginsOpt = {
|
pluginsOpt = {
|
||||||
description,
|
description,
|
||||||
|
@ -64,11 +211,6 @@ in {
|
||||||
type = pluginsType;
|
type = pluginsType;
|
||||||
};
|
};
|
||||||
|
|
||||||
luaInline = lib.mkOptionType {
|
|
||||||
name = "luaInline";
|
|
||||||
check = x: lib.nvim.lua.isLuaInline x;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
opts is a attrset of options, example:
|
opts is a attrset of options, example:
|
||||||
```
|
```
|
||||||
|
|
|
@ -7,94 +7,72 @@ inputs: {
|
||||||
extraModules ? [],
|
extraModules ? [],
|
||||||
}: let
|
}: let
|
||||||
inherit (pkgs) vimPlugins;
|
inherit (pkgs) vimPlugins;
|
||||||
inherit (pkgs.vimUtils) buildVimPlugin;
|
|
||||||
inherit (lib.strings) isString toString;
|
inherit (lib.strings) isString toString;
|
||||||
inherit (lib.lists) filter map concatLists;
|
inherit (lib.lists) filter map concatLists;
|
||||||
inherit (lib.attrsets) recursiveUpdate getAttr;
|
|
||||||
inherit (lib.asserts) assertMsg;
|
|
||||||
|
|
||||||
# import modules.nix with `check`, `pkgs` and `lib` as arguments
|
# import modules.nix with `check`, `pkgs` and `lib` as arguments
|
||||||
# check can be disabled while calling this file is called
|
# check can be disabled while calling this file is called
|
||||||
# to avoid checking in all modules
|
# to avoid checking in all modules
|
||||||
nvimModules = import ./modules.nix {
|
nvimModules = import ./modules.nix {inherit pkgs check lib;};
|
||||||
inherit pkgs check lib;
|
|
||||||
};
|
|
||||||
|
|
||||||
# evaluate the extended library with the modules
|
# evaluate the extended library with the modules
|
||||||
# optionally with any additional modules passed by the user
|
# optionally with any additional modules passed by the user
|
||||||
module = lib.evalModules {
|
module = lib.evalModules {
|
||||||
specialArgs = recursiveUpdate {modulesPath = toString ./.;} extraSpecialArgs;
|
specialArgs = extraSpecialArgs // {modulesPath = toString ./.;};
|
||||||
modules = concatLists [[configuration] nvimModules extraModules];
|
modules = concatLists [[configuration] nvimModules extraModules];
|
||||||
};
|
};
|
||||||
|
|
||||||
# alias to the internal configuration
|
# alias to the internal configuration
|
||||||
vimOptions = module.config.vim;
|
vimOptions = module.config.vim;
|
||||||
|
|
||||||
# build a vim plugin with the given name and arguments
|
|
||||||
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
|
|
||||||
# instead
|
|
||||||
buildPlug = {pname, ...} @ attrs: let
|
|
||||||
src = getAttr ("plugin-" + pname) inputs;
|
|
||||||
in
|
|
||||||
pkgs.stdenvNoCC.mkDerivation ({
|
|
||||||
inherit src;
|
|
||||||
version = src.shortRev or src.shortDirtyRev or "dirty";
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
|
|
||||||
mkdir -p $out
|
|
||||||
cp -r . $out
|
|
||||||
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
// attrs);
|
|
||||||
|
|
||||||
noBuildPlug = {pname, ...} @ attrs: let
|
noBuildPlug = {pname, ...} @ attrs: let
|
||||||
input = getAttr ("plugin-" + pname) inputs;
|
src = inputs."plugin-${attrs.pname}";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
version = input.shortRev or input.shortDirtyRev or "dirty";
|
version = src.shortRev or src.shortDirtyRev or "dirty";
|
||||||
outPath = getAttr ("plugin-" + pname) inputs;
|
outPath = src;
|
||||||
|
passthru.vimPlugin = false;
|
||||||
}
|
}
|
||||||
// attrs;
|
// attrs;
|
||||||
|
|
||||||
|
# build a vim plugin with the given name and arguments
|
||||||
|
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
|
||||||
|
# instead
|
||||||
|
buildPlug = attrs: let
|
||||||
|
src = inputs."plugin-${attrs.pname}";
|
||||||
|
in
|
||||||
|
pkgs.vimUtils.buildVimPlugin (
|
||||||
|
{
|
||||||
|
version = src.shortRev or src.shortDirtyRev or "dirty";
|
||||||
|
inherit src;
|
||||||
|
}
|
||||||
|
// attrs
|
||||||
|
);
|
||||||
|
|
||||||
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
|
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
|
||||||
|
|
||||||
buildConfigPlugins = plugins:
|
pluginBuilders = {
|
||||||
map
|
nvim-treesitter = buildTreesitterPlug vimOptions.treesitter.grammars;
|
||||||
(plug: (
|
flutter-tools-patched = buildPlug {
|
||||||
if (isString plug)
|
|
||||||
then
|
|
||||||
(
|
|
||||||
if (plug == "nvim-treesitter")
|
|
||||||
then (buildTreesitterPlug vimOptions.treesitter.grammars)
|
|
||||||
else if (plug == "flutter-tools-patched")
|
|
||||||
then
|
|
||||||
(
|
|
||||||
buildPlug
|
|
||||||
{
|
|
||||||
pname = "flutter-tools";
|
pname = "flutter-tools";
|
||||||
patches = [../patches/flutter-tools.patch];
|
patches = [../patches/flutter-tools.patch];
|
||||||
}
|
};
|
||||||
)
|
};
|
||||||
else noBuildPlug {pname = plug;}
|
|
||||||
)
|
buildConfigPlugins = plugins:
|
||||||
|
map (
|
||||||
|
plug:
|
||||||
|
if (isString plug)
|
||||||
|
then pluginBuilders.${plug} or (noBuildPlug {pname = plug;})
|
||||||
else plug
|
else plug
|
||||||
))
|
) (filter (f: f != null) plugins);
|
||||||
(filter
|
|
||||||
(f: f != null)
|
|
||||||
plugins);
|
|
||||||
|
|
||||||
# built (or "normalized") plugins that are modified
|
# built (or "normalized") plugins that are modified
|
||||||
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
||||||
builtOptPlugins = map (package: {
|
builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins);
|
||||||
plugin = package;
|
|
||||||
optional = true;
|
|
||||||
}) (buildConfigPlugins vimOptions.optPlugins);
|
|
||||||
|
|
||||||
# additional Lua and Python3 packages, mapped to their respective functions
|
# additional Lua and Python3 packages, mapped to their respective functions
|
||||||
# to conform to the format makeNeovimConfig expects. end user should
|
# to conform to the format mnw expects. end user should
|
||||||
# only ever need to pass a list of packages, which are modified
|
# only ever need to pass a list of packages, which are modified
|
||||||
# here
|
# here
|
||||||
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
|
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
|
||||||
|
@ -104,7 +82,7 @@ inputs: {
|
||||||
# generate a wrapped Neovim package.
|
# generate a wrapped Neovim package.
|
||||||
neovim-wrapped = inputs.mnw.lib.wrap pkgs {
|
neovim-wrapped = inputs.mnw.lib.wrap pkgs {
|
||||||
neovim = vimOptions.package;
|
neovim = vimOptions.package;
|
||||||
plugins = concatLists [builtStartPlugins builtOptPlugins];
|
plugins = builtStartPlugins ++ builtOptPlugins;
|
||||||
appName = "nvf";
|
appName = "nvf";
|
||||||
extraBinPath = vimOptions.extraPackages;
|
extraBinPath = vimOptions.extraPackages;
|
||||||
initLua = vimOptions.builtLuaConfigRC;
|
initLua = vimOptions.builtLuaConfigRC;
|
||||||
|
@ -114,20 +92,11 @@ inputs: {
|
||||||
inherit extraLuaPackages extraPython3Packages;
|
inherit extraLuaPackages extraPython3Packages;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dummyInit = pkgs.writeText "nvf-init.lua" vimOptions.builtLuaConfigRC;
|
||||||
# Additional helper scripts for printing and displaying nvf configuration
|
# Additional helper scripts for printing and displaying nvf configuration
|
||||||
# in your commandline.
|
# in your commandline.
|
||||||
printConfig = pkgs.writers.writeDashBin "print-nvf-config" ''
|
printConfig = pkgs.writers.writeDashBin "nvf-print-config" "cat ${dummyInit}";
|
||||||
cat << EOF
|
printConfigPath = pkgs.writers.writeDashBin "nvf-print-config-path" "echo -n ${dummyInit}";
|
||||||
${vimOptions.builtLuaConfigRC}
|
|
||||||
EOF
|
|
||||||
'';
|
|
||||||
|
|
||||||
printConfigPath = pkgs.writers.writeDashBin "print-nvf-config-path" ''
|
|
||||||
realpath ${pkgs.writeTextFile {
|
|
||||||
name = "nvf-init.lua";
|
|
||||||
text = vimOptions.builtLuaConfigRC;
|
|
||||||
}}
|
|
||||||
'';
|
|
||||||
in {
|
in {
|
||||||
inherit (module) options config;
|
inherit (module) options config;
|
||||||
inherit (module._module.args) pkgs;
|
inherit (module._module.args) pkgs;
|
||||||
|
@ -137,7 +106,7 @@ in {
|
||||||
neovim = pkgs.symlinkJoin {
|
neovim = pkgs.symlinkJoin {
|
||||||
name = "nvf-with-helpers";
|
name = "nvf-with-helpers";
|
||||||
paths = [neovim-wrapped printConfig printConfigPath];
|
paths = [neovim-wrapped printConfig printConfigPath];
|
||||||
postBuild = "echo helpers added";
|
postBuild = "echo Helpers added";
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "Wrapped version of Neovim with additional helper scripts";
|
description = "Wrapped version of Neovim with additional helper scripts";
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
wrapper = map (p: ./wrapper + "/${p}") [
|
wrapper = map (p: ./wrapper + "/${p}") [
|
||||||
"build"
|
"build"
|
||||||
"rc"
|
"rc"
|
||||||
|
"lazy"
|
||||||
"warnings"
|
"warnings"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -8,46 +8,27 @@
|
||||||
cfg = config.vim;
|
cfg = config.vim;
|
||||||
in {
|
in {
|
||||||
config = {
|
config = {
|
||||||
vim.maps = {
|
vim.maps = mkIf cfg.disableArrows {
|
||||||
normal = mkIf cfg.disableArrows {
|
|
||||||
"<up>" = {
|
|
||||||
action = "<nop>";
|
|
||||||
|
|
||||||
noremap = false;
|
|
||||||
};
|
|
||||||
"<down>" = {
|
|
||||||
action = "<nop>";
|
|
||||||
|
|
||||||
noremap = false;
|
|
||||||
};
|
|
||||||
"<left>" = {
|
|
||||||
action = "<nop>";
|
|
||||||
noremap = false;
|
|
||||||
};
|
|
||||||
"<right>" = {
|
|
||||||
action = "<nop>";
|
|
||||||
noremap = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
insert = mkIf cfg.disableArrows {
|
|
||||||
"<up>" = {
|
"<up>" = {
|
||||||
|
mode = ["n" "i"];
|
||||||
action = "<nop>";
|
action = "<nop>";
|
||||||
noremap = false;
|
noremap = false;
|
||||||
};
|
};
|
||||||
"<down>" = {
|
"<down>" = {
|
||||||
|
mode = ["n" "i"];
|
||||||
action = "<nop>";
|
action = "<nop>";
|
||||||
noremap = false;
|
noremap = false;
|
||||||
};
|
};
|
||||||
"<left>" = {
|
"<left>" = {
|
||||||
|
mode = ["n" "i"];
|
||||||
action = "<nop>";
|
action = "<nop>";
|
||||||
noremap = false;
|
noremap = false;
|
||||||
};
|
};
|
||||||
"<right>" = {
|
"<right>" = {
|
||||||
|
mode = ["n" "i"];
|
||||||
action = "<nop>";
|
action = "<nop>";
|
||||||
noremap = false;
|
noremap = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,96 +1,49 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.options) mkOption;
|
||||||
inherit (lib.types) bool str attrsOf nullOr submodule;
|
inherit (lib.types) either str listOf attrsOf nullOr submodule;
|
||||||
inherit (lib.nvim.config) mkBool;
|
inherit (lib.nvim.config) mkBool;
|
||||||
# Most of the keybindings code is highly inspired by pta2002/nixvim.
|
|
||||||
# Thank you!
|
|
||||||
mapConfigOptions = {
|
|
||||||
silent =
|
|
||||||
mkBool false
|
|
||||||
"Whether this mapping should be silent. Equivalent to adding <silent> to a map.";
|
|
||||||
|
|
||||||
nowait =
|
mapType = submodule {
|
||||||
mkBool false
|
mode = mkOption {
|
||||||
"Whether to wait for extra input on ambiguous mappings. Equivalent to adding <nowait> to a map.";
|
type = either str (listOf str);
|
||||||
|
description = ''
|
||||||
script =
|
The short-name of the mode to set the keymapping for. Passing an empty string is the equivalent of `:map`.
|
||||||
mkBool false
|
|
||||||
"Equivalent to adding <script> to a map.";
|
|
||||||
|
|
||||||
expr =
|
|
||||||
mkBool false
|
|
||||||
"Means that the action is actually an expression. Equivalent to adding <expr> to a map.";
|
|
||||||
|
|
||||||
unique =
|
|
||||||
mkBool false
|
|
||||||
"Whether to fail if the map is already defined. Equivalent to adding <unique> to a map.";
|
|
||||||
|
|
||||||
noremap =
|
|
||||||
mkBool true
|
|
||||||
"Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
|
|
||||||
|
|
||||||
|
See `:help map-modes` for a list of modes.
|
||||||
|
'';
|
||||||
|
};
|
||||||
desc = mkOption {
|
desc = mkOption {
|
||||||
type = nullOr str;
|
type = nullOr str;
|
||||||
default = null;
|
default = null;
|
||||||
description = "A description of this keybind, to be shown in which-key, if you have it enabled.";
|
description = "A description of this keybind, to be shown in which-key, if you have it enabled.";
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
mapOption = submodule {
|
|
||||||
options =
|
|
||||||
mapConfigOptions
|
|
||||||
// {
|
|
||||||
action = mkOption {
|
action = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
description = "The action to execute.";
|
description = "The command to execute.";
|
||||||
};
|
};
|
||||||
|
lua = mkBool false ''
|
||||||
lua = mkOption {
|
|
||||||
type = bool;
|
|
||||||
description = ''
|
|
||||||
If true, `action` is considered to be lua code.
|
If true, `action` is considered to be lua code.
|
||||||
Thus, it will not be wrapped in `""`.
|
Thus, it will not be wrapped in `""`.
|
||||||
'';
|
'';
|
||||||
default = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
mapOptions = mode:
|
silent = mkBool true "Whether this mapping should be silent. Equivalent to adding <silent> to a map.";
|
||||||
mkOption {
|
nowait = mkBool false "Whether to wait for extra input on ambiguous mappings. Equivalent to adding <nowait> to a map.";
|
||||||
description = "Mappings for ${mode} mode";
|
script = mkBool false "Equivalent to adding <script> to a map.";
|
||||||
type = attrsOf mapOption;
|
expr = mkBool false "Means that the action is actually an expression. Equivalent to adding <expr> to a map.";
|
||||||
default = {};
|
unique = mkBool false "Whether to fail if the map is already defined. Equivalent to adding <unique> to a map.";
|
||||||
|
noremap = mkBool true "Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
options.vim = {
|
options.vim = {
|
||||||
maps = mkOption {
|
maps = mkOption {
|
||||||
type = submodule {
|
type = attrsOf mapType;
|
||||||
options = {
|
|
||||||
normal = mapOptions "normal";
|
|
||||||
insert = mapOptions "insert";
|
|
||||||
select = mapOptions "select";
|
|
||||||
visual = mapOptions "visual and select";
|
|
||||||
terminal = mapOptions "terminal";
|
|
||||||
normalVisualOp = mapOptions "normal, visual, select and operator-pending (same as plain 'map')";
|
|
||||||
|
|
||||||
visualOnly = mapOptions "visual only";
|
|
||||||
operator = mapOptions "operator-pending";
|
|
||||||
insertCommand = mapOptions "insert and command-line";
|
|
||||||
lang = mapOptions "insert, command-line and lang-arg";
|
|
||||||
command = mapOptions "command-line";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
default = {};
|
default = {};
|
||||||
description = ''
|
description = "Custom keybindings.";
|
||||||
Custom keybindings for any mode.
|
|
||||||
|
|
||||||
For plain maps (e.g. just 'map' or 'remap') use `maps.normalVisualOp`.
|
|
||||||
'';
|
|
||||||
|
|
||||||
example = ''
|
example = ''
|
||||||
maps = {
|
maps = {
|
||||||
normal."<leader>m" = {
|
"<leader>m" = {
|
||||||
|
mode = "n";
|
||||||
silent = true;
|
silent = true;
|
||||||
action = "<cmd>make<CR>";
|
action = "<cmd>make<CR>";
|
||||||
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR>
|
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR>
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
inherit (builtins) filter;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.nvim.binds) mkBinding;
|
inherit (lib.nvim.binds) mkLznBinding;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
|
||||||
inherit (lib.nvim.binds) pushDownDefault;
|
inherit (lib.nvim.binds) pushDownDefault;
|
||||||
|
|
||||||
cfg = config.vim.filetree.nvimTree;
|
cfg = config.vim.filetree.nvimTree;
|
||||||
|
@ -16,19 +16,28 @@
|
||||||
inherit (self.options.vim.filetree.nvimTree) mappings;
|
inherit (self.options.vim.filetree.nvimTree) mappings;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = ["nvim-tree-lua"];
|
|
||||||
|
|
||||||
vim.maps.normal = mkMerge [
|
|
||||||
(mkBinding cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
|
||||||
(mkBinding cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
|
|
||||||
(mkBinding cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
|
||||||
(mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
|
||||||
];
|
|
||||||
|
|
||||||
vim.binds.whichKey.register = pushDownDefault {
|
vim.binds.whichKey.register = pushDownDefault {
|
||||||
"<leader>t" = "+NvimTree";
|
"<leader>t" = "+NvimTree";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vim.lazy = {
|
||||||
|
plugins = {
|
||||||
|
nvim-tree-lua = {
|
||||||
|
package = "nvim-tree-lua";
|
||||||
|
setupModule = "nvim-tree";
|
||||||
|
inherit (cfg) setupOpts;
|
||||||
|
cmd = ["NvimTreeClipboard" "NvimTreeClose" "NvimTreeCollapse" "NvimTreeCollapseKeepBuffers" "NvimTreeFindFile" "NvimTreeFindFileToggle" "NvimTreeFocus" "NvimTreeHiTest" "NvimTreeOpen" "NvimTreeRefresh" "NvimTreeResize" "NvimTreeToggle"];
|
||||||
|
|
||||||
|
keys = filter ({lhs, ...}: lhs != null) [
|
||||||
|
(mkLznBinding ["n"] cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
||||||
|
(mkLznBinding ["n"] cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
|
||||||
|
(mkLznBinding ["n"] cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
||||||
|
(mkLznBinding ["n"] cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
vim.pluginRC.nvimtreelua = entryAnywhere ''
|
vim.pluginRC.nvimtreelua = entryAnywhere ''
|
||||||
${
|
${
|
||||||
optionalString cfg.setupOpts.disable_netrw ''
|
optionalString cfg.setupOpts.disable_netrw ''
|
||||||
|
@ -38,10 +47,9 @@ in {
|
||||||
''
|
''
|
||||||
}
|
}
|
||||||
|
|
||||||
require'nvim-tree'.setup(${toLuaObject cfg.setupOpts})
|
|
||||||
|
|
||||||
${
|
${
|
||||||
optionalString cfg.openOnSetup ''
|
optionalString cfg.openOnSetup ''
|
||||||
|
require('lz.n').trigger_load("nvim-tree-lua")
|
||||||
-- autostart behaviour
|
-- autostart behaviour
|
||||||
-- Open on startup has been deprecated
|
-- Open on startup has been deprecated
|
||||||
-- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
|
-- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
./ccc
|
./ccc
|
||||||
./gestures
|
./gestures
|
||||||
./motion
|
./motion
|
||||||
|
./new-file-template
|
||||||
./telescope
|
./telescope
|
||||||
./icon-picker
|
./icon-picker
|
||||||
./images
|
./images
|
||||||
|
|
23
modules/plugins/utility/new-file-template/config.nix
Normal file
23
modules/plugins/utility/new-file-template/config.nix
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
|
||||||
|
cfg = config.vim.utility.new-file-template;
|
||||||
|
in {
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
vim = {
|
||||||
|
startPlugins = [
|
||||||
|
"new-file-template-nvim"
|
||||||
|
];
|
||||||
|
|
||||||
|
pluginRC.new-file-template = entryAnywhere ''
|
||||||
|
require('new-file-template').setup(${toLuaObject cfg.setupOpts})
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
6
modules/plugins/utility/new-file-template/default.nix
Normal file
6
modules/plugins/utility/new-file-template/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./config.nix
|
||||||
|
./new-file-template.nix
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
{lib, ...}: let
|
||||||
|
inherit (lib.options) mkOption;
|
||||||
|
inherit (lib.types) attrsOf bool listOf str;
|
||||||
|
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||||
|
in {
|
||||||
|
options.vim.utility.new-file-template = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
new-file-template.nvim: Automatically insert a template on new files in neovim.
|
||||||
|
::: {.note}
|
||||||
|
For custom templates add a directory containing `lua/templates/*.lua`
|
||||||
|
to `vim.additionalRuntimePaths`.
|
||||||
|
:::
|
||||||
|
[custom-template-docs]: https://github.com/otavioschwanck/new-file-template.nvim?tab=readme-ov-file#creating-new-templates
|
||||||
|
More documentation on the templates available at [custom-template-docs]
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
setupOpts = mkPluginSetupOption "nvim-file-template.nvim" {
|
||||||
|
disableInsert = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
description = "Enter insert mode after inserting the template";
|
||||||
|
};
|
||||||
|
|
||||||
|
disableAutocmd = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
description = "Disable the autocmd that creates the template";
|
||||||
|
};
|
||||||
|
|
||||||
|
disableFiletype = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
default = [];
|
||||||
|
description = "Disable default templates for specific filetypes";
|
||||||
|
};
|
||||||
|
|
||||||
|
disableSpecific = mkOption {
|
||||||
|
type = attrsOf (listOf str);
|
||||||
|
default = {};
|
||||||
|
description = "Disable specific regexp for the default templates.";
|
||||||
|
example = "{ ruby = [\".*\"]; }";
|
||||||
|
};
|
||||||
|
|
||||||
|
suffixAsFiletype = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false;
|
||||||
|
description = "Use suffix of filename rather than `vim.bo.filetype` as filetype";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
74
modules/wrapper/lazy/config.nix
Normal file
74
modules/wrapper/lazy/config.nix
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (builtins) toJSON typeOf head length;
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.attrsets) mapAttrsToList;
|
||||||
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
inherit (lib.strings) optionalString;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
inherit (lib.nvim.dag) entryBefore;
|
||||||
|
cfg = config.vim.lazy;
|
||||||
|
|
||||||
|
toLuzLznKeySpec = {
|
||||||
|
desc,
|
||||||
|
noremap,
|
||||||
|
expr,
|
||||||
|
nowait,
|
||||||
|
ft,
|
||||||
|
lhs,
|
||||||
|
rhs,
|
||||||
|
mode,
|
||||||
|
}: {
|
||||||
|
"@1" = lhs;
|
||||||
|
"@2" = rhs;
|
||||||
|
inherit desc noremap expr nowait ft mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
toLuaLznSpec = name: spec:
|
||||||
|
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
|
||||||
|
// {
|
||||||
|
"@1" = name;
|
||||||
|
before =
|
||||||
|
if spec.before != null
|
||||||
|
then
|
||||||
|
mkLuaInline ''
|
||||||
|
function()
|
||||||
|
${spec.before}
|
||||||
|
end
|
||||||
|
''
|
||||||
|
else null;
|
||||||
|
|
||||||
|
after =
|
||||||
|
if spec.setupModule == null && spec.after == null
|
||||||
|
then null
|
||||||
|
else
|
||||||
|
mkLuaInline ''
|
||||||
|
function()
|
||||||
|
${
|
||||||
|
optionalString (spec.setupModule != null)
|
||||||
|
"require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"
|
||||||
|
}
|
||||||
|
${optionalString (spec.after != null) spec.after}
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
|
||||||
|
keys =
|
||||||
|
if typeOf spec.keys == "list" && length spec.keys > 0 && typeOf (head spec.keys) == "set"
|
||||||
|
then map toLuzLznKeySpec spec.keys
|
||||||
|
else spec.keys;
|
||||||
|
};
|
||||||
|
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
|
||||||
|
in {
|
||||||
|
config.vim = mkIf cfg.enable {
|
||||||
|
startPlugins = ["lz-n" "lzn-auto-require"];
|
||||||
|
|
||||||
|
optPlugins = mapAttrsToList (_: plugin: plugin.package) cfg.plugins;
|
||||||
|
|
||||||
|
luaConfigRC.lzn-load = entryBefore ["pluginConfigs"] ''
|
||||||
|
require('lz.n').load(${toLuaObject lznSpecs})
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
6
modules/wrapper/lazy/default.nix
Normal file
6
modules/wrapper/lazy/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
_: {
|
||||||
|
imports = [
|
||||||
|
./lazy.nix
|
||||||
|
./config.nix
|
||||||
|
];
|
||||||
|
}
|
29
modules/wrapper/lazy/lazy.nix
Normal file
29
modules/wrapper/lazy/lazy.nix
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{lib, ...}: let
|
||||||
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
|
inherit (lib.types) enum;
|
||||||
|
inherit (lib.nvim.types) lznPluginTableType;
|
||||||
|
in {
|
||||||
|
options.vim.lazy = {
|
||||||
|
enable = mkEnableOption "plugin lazy-loading" // {default = true;};
|
||||||
|
loader = mkOption {
|
||||||
|
description = "Lazy loader to use";
|
||||||
|
type = enum ["lz.n"];
|
||||||
|
default = "lz.n";
|
||||||
|
};
|
||||||
|
|
||||||
|
plugins = mkOption {
|
||||||
|
default = {};
|
||||||
|
type = lznPluginTableType;
|
||||||
|
description = "list of plugins to lazy load";
|
||||||
|
example = ''
|
||||||
|
{
|
||||||
|
toggleterm-nvim = {
|
||||||
|
package = "toggleterm-nvim";
|
||||||
|
after = lib.generators.mkLuaInline "function() require('toggleterm').setup{} end";
|
||||||
|
cmd = ["ToggleTerm"];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -4,86 +4,19 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) map mapAttrs filter;
|
inherit (builtins) map mapAttrs filter;
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.attrsets) mapAttrsToList filterAttrs attrsToList;
|
||||||
inherit (lib.attrsets) filterAttrs getAttrs attrValues attrNames;
|
inherit (lib.strings) concatLines concatMapStringsSep optionalString;
|
||||||
inherit (lib.strings) concatLines concatMapStringsSep;
|
|
||||||
inherit (lib.misc) mapAttrsFlatten;
|
|
||||||
inherit (lib.trivial) showWarnings;
|
inherit (lib.trivial) showWarnings;
|
||||||
inherit (lib.types) str nullOr;
|
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere;
|
inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (lib.nvim.config) mkBool;
|
|
||||||
|
|
||||||
cfg = config.vim;
|
cfg = config.vim;
|
||||||
|
|
||||||
# Most of the keybindings code is highly inspired by pta2002/nixvim.
|
|
||||||
# Thank you!
|
|
||||||
mapConfigOptions = {
|
|
||||||
silent =
|
|
||||||
mkBool false
|
|
||||||
"Whether this mapping should be silent. Equivalent to adding <silent> to a map.";
|
|
||||||
|
|
||||||
nowait =
|
|
||||||
mkBool false
|
|
||||||
"Whether to wait for extra input on ambiguous mappings. Equivalent to adding <nowait> to a map.";
|
|
||||||
|
|
||||||
script =
|
|
||||||
mkBool false
|
|
||||||
"Equivalent to adding <script> to a map.";
|
|
||||||
|
|
||||||
expr =
|
|
||||||
mkBool false
|
|
||||||
"Means that the action is actually an expression. Equivalent to adding <expr> to a map.";
|
|
||||||
|
|
||||||
unique =
|
|
||||||
mkBool false
|
|
||||||
"Whether to fail if the map is already defined. Equivalent to adding <unique> to a map.";
|
|
||||||
|
|
||||||
noremap =
|
|
||||||
mkBool true
|
|
||||||
"Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
|
|
||||||
|
|
||||||
desc = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
default = null;
|
|
||||||
description = "A description of this keybind, to be shown in which-key, if you have it enabled.";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
genMaps = mode: maps: let
|
|
||||||
/*
|
|
||||||
Take a user-defined action (string or attrs) and return the following attribute set:
|
|
||||||
{
|
|
||||||
action = (string) the actual action to map to this key
|
|
||||||
config = (attrs) the configuration options for this mapping (noremap, silent...)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
normalizeAction = action: {
|
|
||||||
# Extract the values of the config options that have been explicitly set by the user
|
|
||||||
config =
|
|
||||||
filterAttrs (_: v: v != null)
|
|
||||||
(getAttrs (attrNames mapConfigOptions) action);
|
|
||||||
action =
|
|
||||||
if action.lua
|
|
||||||
then mkLuaInline action.action
|
|
||||||
else action.action;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
attrValues (mapAttrs
|
|
||||||
(key: action: let
|
|
||||||
normalizedAction = normalizeAction action;
|
|
||||||
in {
|
|
||||||
inherit (normalizedAction) action config;
|
|
||||||
inherit key;
|
|
||||||
inherit mode;
|
|
||||||
})
|
|
||||||
maps);
|
|
||||||
in {
|
in {
|
||||||
config = let
|
config = let
|
||||||
filterNonNull = attrs: filterAttrs (_: value: value != null) attrs;
|
filterNonNull = filterAttrs (_: value: value != null);
|
||||||
globalsScript =
|
globalsScript =
|
||||||
mapAttrsFlatten (name: value: "vim.g.${name} = ${toLuaObject value}")
|
mapAttrsToList (name: value: "vim.g.${name} = ${toLuaObject value}")
|
||||||
(filterNonNull cfg.globals);
|
(filterNonNull cfg.globals);
|
||||||
|
|
||||||
extraPluginConfigs = resolveDag {
|
extraPluginConfigs = resolveDag {
|
||||||
|
@ -98,38 +31,21 @@ in {
|
||||||
mapResult = result: concatLines (map mkLuarcSection result);
|
mapResult = result: concatLines (map mkLuarcSection result);
|
||||||
};
|
};
|
||||||
|
|
||||||
toLuaBindings = mode: maps:
|
getAction = keymap:
|
||||||
map (value: ''
|
if keymap.lua
|
||||||
vim.keymap.set(${toLuaObject mode}, ${toLuaObject value.key}, ${toLuaObject value.action}, ${toLuaObject value.config})
|
then mkLuaInline keymap.action
|
||||||
'') (genMaps mode maps);
|
else keymap.action;
|
||||||
|
|
||||||
# I'm not sure if every one of these will work.
|
getOpts = keymap: {
|
||||||
allmap = toLuaBindings "" config.vim.maps.normalVisualOp;
|
inherit (keymap) silent nowait script expr unique noremap;
|
||||||
nmap = toLuaBindings "n" config.vim.maps.normal;
|
};
|
||||||
vmap = toLuaBindings "v" config.vim.maps.visual;
|
|
||||||
xmap = toLuaBindings "x" config.vim.maps.visualOnly;
|
|
||||||
smap = toLuaBindings "s" config.vim.maps.select;
|
|
||||||
imap = toLuaBindings "i" config.vim.maps.insert;
|
|
||||||
cmap = toLuaBindings "c" config.vim.maps.command;
|
|
||||||
tmap = toLuaBindings "t" config.vim.maps.terminal;
|
|
||||||
lmap = toLuaBindings "l" config.vim.maps.lang;
|
|
||||||
omap = toLuaBindings "o" config.vim.maps.operator;
|
|
||||||
icmap = toLuaBindings "ic" config.vim.maps.insertCommand;
|
|
||||||
|
|
||||||
maps = [
|
toLuaKeymap = {
|
||||||
nmap
|
name,
|
||||||
imap
|
value,
|
||||||
vmap
|
}: "vim.keymap.set(${toLuaObject value.mode}, ${toLuaObject name}, ${toLuaObject (getAction value)}, ${toLuaObject (getOpts value)})";
|
||||||
xmap
|
|
||||||
smap
|
keymaps = concatLines (map toLuaKeymap (attrsToList (filterNonNull config.maps)));
|
||||||
cmap
|
|
||||||
omap
|
|
||||||
tmap
|
|
||||||
lmap
|
|
||||||
icmap
|
|
||||||
allmap
|
|
||||||
];
|
|
||||||
mappings = concatLines (map concatLines maps);
|
|
||||||
in {
|
in {
|
||||||
vim = {
|
vim = {
|
||||||
luaConfigRC = {
|
luaConfigRC = {
|
||||||
|
@ -137,7 +53,9 @@ in {
|
||||||
# basic, theme
|
# basic, theme
|
||||||
pluginConfigs = entryAfter ["theme"] pluginConfigs;
|
pluginConfigs = entryAfter ["theme"] pluginConfigs;
|
||||||
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
|
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
|
||||||
mappings = entryAfter ["extraPluginConfigs"] mappings;
|
mappings = entryAfter ["extraPluginConfigs"] keymaps;
|
||||||
|
# FIXME: put this somewhere less stupid
|
||||||
|
footer = entryAfter ["mappings"] (optionalString config.vim.lazy.enable "require('lzn-auto-require.loader').register_loader()");
|
||||||
};
|
};
|
||||||
|
|
||||||
builtLuaConfigRC = let
|
builtLuaConfigRC = let
|
||||||
|
|
Loading…
Reference in a new issue