mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-24 12:28:32 +00:00
Compare commits
27 commits
51fb4c40ed
...
a3f4b7b147
Author | SHA1 | Date | |
---|---|---|---|
a3f4b7b147 | |||
8e4b632280 | |||
![]() |
b39b84490f | ||
![]() |
7a8b95cf7c | ||
![]() |
b637f921d5 | ||
649f5513f9 | |||
18ae3e1f6c | |||
614ad33a60 | |||
fdd0642c7d | |||
379d2a9f16 | |||
![]() |
f01e404b2e | ||
3299facbaa | |||
![]() |
bdf777dc8a | ||
![]() |
cc14a1c1f6 | ||
![]() |
108cfd8383 | ||
9ea9995b92 | |||
7417c6e4f3 | |||
3cba3ca30c | |||
![]() |
6670d752c7 | ||
5826aebdd3 | |||
a6c879e8a3 | |||
141a272747 | |||
![]() |
941a2a6f2e | ||
![]() |
e40cce5653 | ||
![]() |
2fc7dc798b | ||
3ca7e3b841 | |||
![]() |
b71bf75dcd |
20 changed files with 643 additions and 641 deletions
8
.github/README.md
vendored
8
.github/README.md
vendored
|
@ -124,10 +124,16 @@ The _recommended_ way of installing **nvf** is using either the NixOS or the
|
||||||
Home-Manager module, though it is completely possible and no less supported to
|
Home-Manager module, though it is completely possible and no less supported to
|
||||||
install **nvf** as a standalone package, or a flake output.
|
install **nvf** as a standalone package, or a flake output.
|
||||||
|
|
||||||
See the [**nvf** manual] for detailed and up-to-date installation guides,
|
See the rendered [nvf manual] for detailed and up-to-date installation guides,
|
||||||
configurations, available options, release notes and more. Tips for installing
|
configurations, available options, release notes and more. Tips for installing
|
||||||
userspace plugins is also contained in the documentation.
|
userspace plugins is also contained in the documentation.
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> While using NixOS or Home-Manager modules,
|
||||||
|
> `programs.nvf.enableManpages = true;` will allow you to view option
|
||||||
|
> documentation from the comfort of your terminal via `man 5 nvf`. The more you
|
||||||
|
> know.
|
||||||
|
|
||||||
Please create an issue on the [issue tracker] if you find the documentation
|
Please create an issue on the [issue tracker] if you find the documentation
|
||||||
lacking or confusing. Any improvements to the documentation through pull
|
lacking or confusing. Any improvements to the documentation through pull
|
||||||
requests are also welcome, and appreciated.
|
requests are also welcome, and appreciated.
|
||||||
|
|
74
.github/pull_request_template.md
vendored
74
.github/pull_request_template.md
vendored
|
@ -1,39 +1,57 @@
|
||||||
# Description
|
<!--
|
||||||
|
^ Please include a clear and concise description of the aim of your Pull Request above this line ^
|
||||||
|
|
||||||
A clear and concise description of the aim of your Pull Request.
|
For plugin dependency/module additions, please make sure to link the source link of the added plugin
|
||||||
|
or dependency in this section.
|
||||||
|
|
||||||
**If your pull request aims to fix an open issue or a present bug, please link the relevant issue below. If not, please remove this section**
|
If your pull request aims to fix an open issue or a please bug, please also link the relevant issue
|
||||||
Fixes #(issue)
|
below this line. You may attach an issue to your pull request with `Fixes #<issue number>` outside
|
||||||
|
this comment.
|
||||||
|
-->
|
||||||
|
|
||||||
## Type of change
|
## Sanity Checking
|
||||||
|
|
||||||
Please delete any options that are not relevant.
|
<!--
|
||||||
|
Please check all that apply. As before, this section is not a hard requirement but checklists with more checked
|
||||||
|
items are likely to be merged faster. You may save some time in maintainer review by performing self-reviews here
|
||||||
|
before submitting your pull request.
|
||||||
|
|
||||||
- Bug fix (non-breaking change which fixes an issue)
|
If your pull request includes any change or unexpected behaviour not covered below, please do make sure to include
|
||||||
- New feature (non-breaking change which adds functionality)
|
it above in your description.
|
||||||
- Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
-->
|
||||||
- Translation/Language update
|
|
||||||
- Docs
|
|
||||||
- Other
|
|
||||||
|
|
||||||
## Checklist
|
[editorconfig]: https://editorconfig.org
|
||||||
|
[changelog]: https://github.com/NotAShelf/nvf/tree/main/docs/release-notes
|
||||||
|
|
||||||
Please try to check at least a majority of the checklist before opening your pull request. Exceptions to this will be reviewed on a case by case basis.
|
- [ ] I have updated the [changelog] as per my changes.
|
||||||
|
- [ ] I have tested, and self-reviewed my code.
|
||||||
|
- Style and consistency
|
||||||
|
- [ ] I ran **Alejandra** to format my code (`nix fmt`).
|
||||||
|
- [ ] My code conforms to the [editorconfig] configuration of the project.
|
||||||
|
- [ ] My changes are consistent with the rest of the codebase.
|
||||||
|
- If new changes are particularly complex:
|
||||||
|
- [ ] My code includes comments in particularly complex areas
|
||||||
|
- [ ] I have added a section in the manual.
|
||||||
|
- [ ] _(For breaking changes)_ I have included a migration guide.
|
||||||
|
- Package(s) built:
|
||||||
|
- [ ] `.#nix` (default package)
|
||||||
|
- [ ] `.#maximal`
|
||||||
|
- [ ] `.#docs-html`
|
||||||
|
- Tested on platform(s)
|
||||||
|
- [ ] `x86_64-linux`
|
||||||
|
- [ ] `aarch64-linux`
|
||||||
|
- [ ] `x86_64-darwin`
|
||||||
|
- [ ] `aarch64-darwin`
|
||||||
|
|
||||||
- [ ] My code follows the style and contributing guidelines of this project.
|
<!--
|
||||||
- [ ] I ran Alejandra to format my code (`nix fmt`).
|
If your changes touch upon a portion of the codebase that you do not understand well, please make sure to consult
|
||||||
- [ ] I have performed a self-review of my own code and tested it.
|
the maintainers on your changes. In most cases, making an issue before creating your PR will help you avoid duplicate
|
||||||
- [ ] I have commented my code, particularly in hard-to-understand areas.
|
efforts in the long run.
|
||||||
- [ ] My changes generate no new warnings.
|
-->
|
||||||
- [ ] This change requires a documentation update.
|
|
||||||
- [ ] I have updated the documentation accordingly.
|
|
||||||
|
|
||||||
## Screenshots & Logs
|
---
|
||||||
|
|
||||||
You are kindly requested to attach screenshots of your changes in actions and preferably your build/run logs for all available packages. If you are not sure how to do this, you can refer to the [documentation](https://notashelf.github.io/neovim-flake/).
|
Add a :+1: [reaction] to [pull requests you find important].
|
||||||
|
|
||||||
**Please do not use any external image service. Instead, just paste in or drag and drop the image here, and it will be uploaded automatically.**
|
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
|
||||||
|
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc
|
||||||
```console
|
|
||||||
# Paste your logs here
|
|
||||||
```
|
|
||||||
|
|
|
@ -7,37 +7,26 @@ section contains a general overview to how you may utilize said functions.
|
||||||
|
|
||||||
## Custom Key Mappings Support for a Plugin {#sec-custom-key-mappings}
|
## Custom Key Mappings Support for a Plugin {#sec-custom-key-mappings}
|
||||||
|
|
||||||
To set a mapping, you should define it in `vim.maps.<<mode>>`.
|
To set a mapping, you should define it in `vim.keymaps`.
|
||||||
The available modes are:
|
|
||||||
|
|
||||||
- normal
|
|
||||||
- insert
|
|
||||||
- select
|
|
||||||
- visual
|
|
||||||
- terminal
|
|
||||||
- normalVisualOp
|
|
||||||
- visualOnly
|
|
||||||
- operator
|
|
||||||
- insertCommand
|
|
||||||
- lang
|
|
||||||
- command
|
|
||||||
|
|
||||||
An example, simple keybinding, can look like this:
|
An example, simple keybinding, can look like this:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
{
|
||||||
vim.maps.normal = {
|
vim.keymaps = [
|
||||||
"<leader>wq" = {
|
{
|
||||||
|
key = "<leader>wq";
|
||||||
|
mode = ["n"];
|
||||||
action = ":wq<CR>";
|
action = ":wq<CR>";
|
||||||
silent = true;
|
silent = true;
|
||||||
desc = "Save file and quit";
|
desc = "Save file and quit";
|
||||||
};
|
}
|
||||||
};
|
];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
There are many settings available in the options. Please refer to the
|
There are many settings available in the options. Please refer to the
|
||||||
[documentation](https://notashelf.github.io/nvf/options.html#opt-vim.maps.command._name_.action)
|
[documentation](https://notashelf.github.io/nvf/options.html#opt-vim.keymaps)
|
||||||
to see a list of them.
|
to see a list of them.
|
||||||
|
|
||||||
**nvf** provides a list of helper commands, so that you don't have to write the
|
**nvf** provides a list of helper commands, so that you don't have to write the
|
||||||
|
|
|
@ -26,6 +26,31 @@ 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 {#sec-vim-maps-rewrite}
|
||||||
|
|
||||||
|
Instead of specifying map modes using submodules (eg.: `vim.maps.normal`), a new `vim.keymaps`
|
||||||
|
submodule with support for a `mode` option 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.keymaps = [
|
||||||
|
{
|
||||||
|
key = "<leader>m";
|
||||||
|
mode = "n";
|
||||||
|
}
|
||||||
|
...
|
||||||
|
];
|
||||||
|
```
|
||||||
|
|
||||||
### `vim.lsp.nvimCodeActionMenu` removed in favor of `vim.ui.fastaction` {#sec-nvim-code-action-menu-deprecation}
|
### `vim.lsp.nvimCodeActionMenu` removed in favor of `vim.ui.fastaction` {#sec-nvim-code-action-menu-deprecation}
|
||||||
|
|
||||||
The nvim-code-action-menu plugin has been archived and broken for a long time,
|
The nvim-code-action-menu plugin has been archived and broken for a long time,
|
||||||
|
@ -37,6 +62,7 @@ Note that we are looking to add more alternatives in the future like
|
||||||
dressing.nvim and actions-preview.nvim, in case fastaction doesn't work for
|
dressing.nvim and actions-preview.nvim, in case fastaction doesn't work for
|
||||||
everyone.
|
everyone.
|
||||||
|
|
||||||
|
|
||||||
## Changelog {#sec-release-0.7-changelog}
|
## Changelog {#sec-release-0.7-changelog}
|
||||||
|
|
||||||
[ItsSorae](https://github.com/ItsSorae):
|
[ItsSorae](https://github.com/ItsSorae):
|
||||||
|
@ -80,13 +106,17 @@ everyone.
|
||||||
|
|
||||||
[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
|
[new-file-template.nvim]: https://github.com/otavioschwanck/new-file-template.nvim
|
||||||
|
[neo-tree.nvim]: https://github.com/nvim-neo-tree/neo-tree.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
|
- Add [new-file-template.nvim] to automatically fill new file contents using
|
||||||
templates.
|
templates
|
||||||
|
|
||||||
|
- Make [neo-tree.nvim] display file icons properly by enabling
|
||||||
|
`visuals.nvimWebDevicons`
|
||||||
|
|
||||||
[diniamo](https://github.com/diniamo):
|
[diniamo](https://github.com/diniamo):
|
||||||
|
|
||||||
|
@ -120,6 +150,8 @@ everyone.
|
||||||
- Replace `vim.lsp.nvimCodeActionMenu` with `vim.ui.fastaction`, see the
|
- Replace `vim.lsp.nvimCodeActionMenu` with `vim.ui.fastaction`, see the
|
||||||
breaking changes section above for more details
|
breaking changes section above for more details
|
||||||
|
|
||||||
|
- Add a `setupOpts` option to nvim-surround, which allows modifying options that aren't defined in nvf. Move the alternate nvim-surround keybinds to use `setupOpts`.
|
||||||
|
|
||||||
[Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd()
|
[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
|
- Make Neovim's configuration file entirely Lua based. This comes with a few
|
||||||
|
@ -132,6 +164,8 @@ everyone.
|
||||||
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
|
||||||
|
@ -193,14 +227,25 @@ everyone.
|
||||||
- Add [](#opt-vim.dashboard.dashboard-nvim.setupOpts) to allow user
|
- Add [](#opt-vim.dashboard.dashboard-nvim.setupOpts) to allow user
|
||||||
configuration for [dashboard.nvim](https://github.com/nvimdev/dashboard-nvim)
|
configuration for [dashboard.nvim](https://github.com/nvimdev/dashboard-nvim)
|
||||||
|
|
||||||
|
- Update `lualine.nvim` input and add missing themes:
|
||||||
|
- Adds `ayu`, `gruvbox_dark`, `iceberg`, `moonfly`, `onedark`,
|
||||||
|
`powerline_dark` and `solarized_light` themes.
|
||||||
|
|
||||||
[ppenguin](https://github.com/ppenguin):
|
[ppenguin](https://github.com/ppenguin):
|
||||||
|
|
||||||
- Telescope:
|
- Telescope:
|
||||||
- Fixed `project-nvim` command and keybinding
|
- Fixed `project-nvim` command and keybinding
|
||||||
- Added default ikeybind/command for `Telescope resume` (`<leader>fr`)
|
- Added default ikeybind/command for `Telescope resume` (`<leader>fr`)
|
||||||
|
|
||||||
[Soliprem](https://github.com/Soliprem)
|
[Soliprem](https://github.com/Soliprem):
|
||||||
|
|
||||||
- Add LSP and Treesitter support for R under `vim.languages.R`.
|
- Add LSP and Treesitter support for R under `vim.languages.R`.
|
||||||
- Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with
|
- Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with
|
||||||
ccc
|
ccc
|
||||||
|
|
||||||
|
[Bloxx12](https://github.com/Bloxx12)
|
||||||
|
|
||||||
|
- Add support for [base16 theming](https://github.com/RRethy/base16-nvim) under
|
||||||
|
`vim.theme`
|
||||||
|
- Fix internal breakage in `elixir-tools` setup.
|
||||||
|
|
||||||
|
|
497
flake.lock
generated
497
flake.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -349,6 +349,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
# Themes
|
# Themes
|
||||||
|
plugin-base16 = {
|
||||||
|
url = "github:rrethy/base16-nvim";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
|
||||||
plugin-tokyonight = {
|
plugin-tokyonight = {
|
||||||
url = "github:folke/tokyonight.nvim";
|
url = "github:folke/tokyonight.nvim";
|
||||||
flake = false;
|
flake = false;
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
typesDag = import ./dag.nix {inherit lib;};
|
typesDag = import ./dag.nix {inherit lib;};
|
||||||
typesPlugin = import ./plugins.nix {inherit inputs lib;};
|
typesPlugin = import ./plugins.nix {inherit inputs lib;};
|
||||||
typesLanguage = import ./languages.nix {inherit lib;};
|
typesLanguage = import ./languages.nix {inherit lib;};
|
||||||
typesCustom = import ./custom.nix {inherit lib;};
|
typesTypes = import ./types.nix {inherit lib;};
|
||||||
in {
|
in {
|
||||||
inherit (typesDag) dagOf;
|
inherit (typesDag) dagOf;
|
||||||
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType;
|
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType;
|
||||||
inherit (typesLanguage) diagnostics mkGrammarOption;
|
inherit (typesLanguage) diagnostics mkGrammarOption;
|
||||||
inherit (typesCustom) anythingConcatLists char;
|
inherit (typesTypes) anythingConcatLists char hexColor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
{lib}: let
|
{lib}: let
|
||||||
inherit (lib) isStringLike showOption showFiles getFiles mergeOneOption mergeEqualOption mkOptionType;
|
inherit (lib) isStringLike showOption showFiles getFiles mergeOneOption mergeEqualOption mkOptionType;
|
||||||
|
inherit (lib.strings) isString;
|
||||||
inherit (lib.types) anything attrsOf;
|
inherit (lib.types) anything attrsOf;
|
||||||
inherit (lib.nvim.types) anythingConcatLists;
|
inherit (lib.nvim.types) anythingConcatLists;
|
||||||
inherit (builtins) typeOf isAttrs any head concatLists stringLength;
|
inherit (builtins) typeOf isAttrs any head concatLists stringLength match;
|
||||||
in {
|
in {
|
||||||
# HACK: Does this break anything in our case?
|
# HACK: Does this break anything in our case?
|
||||||
# A modified version of the nixpkgs anything type that concatenates lists
|
# A modified version of the nixpkgs anything type that concatenates lists
|
||||||
|
@ -58,4 +59,11 @@ in {
|
||||||
check = value: stringLength value < 2;
|
check = value: stringLength value < 2;
|
||||||
merge = mergeEqualOption;
|
merge = mergeEqualOption;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
hexColor = mkOptionType {
|
||||||
|
name = "hex-color";
|
||||||
|
descriptionClass = "noun";
|
||||||
|
description = "RGB color in hex format";
|
||||||
|
check = v: isString v && (match "#?[0-9a-fA-F]{6}" v) != null;
|
||||||
|
};
|
||||||
}
|
}
|
|
@ -3,51 +3,75 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib.trivial) pipe;
|
||||||
|
inherit (lib.attrsets) mapAttrsToList;
|
||||||
|
inherit (lib.lists) flatten;
|
||||||
|
|
||||||
|
legacyMapModes = {
|
||||||
|
normal = ["n"];
|
||||||
|
insert = ["i"];
|
||||||
|
select = ["s"];
|
||||||
|
visual = ["v"];
|
||||||
|
terminal = ["t"];
|
||||||
|
normalVisualOp = ["n" "v" "o"];
|
||||||
|
visualOnly = ["n" "x"];
|
||||||
|
operator = ["o"];
|
||||||
|
insertCommand = ["i" "c"];
|
||||||
|
lang = ["l"];
|
||||||
|
command = ["c"];
|
||||||
|
};
|
||||||
|
|
||||||
cfg = config.vim;
|
cfg = config.vim;
|
||||||
in {
|
in {
|
||||||
config = {
|
config = {
|
||||||
vim.maps = {
|
vim.keymaps = mkMerge [
|
||||||
normal = mkIf cfg.disableArrows {
|
(
|
||||||
"<up>" = {
|
mkIf cfg.disableArrows [
|
||||||
action = "<nop>";
|
{
|
||||||
|
key = "<up>";
|
||||||
noremap = false;
|
mode = ["n" "i"];
|
||||||
};
|
|
||||||
"<down>" = {
|
|
||||||
action = "<nop>";
|
|
||||||
|
|
||||||
noremap = false;
|
|
||||||
};
|
|
||||||
"<left>" = {
|
|
||||||
action = "<nop>";
|
action = "<nop>";
|
||||||
noremap = false;
|
noremap = false;
|
||||||
};
|
}
|
||||||
"<right>" = {
|
{
|
||||||
|
key = "<down>";
|
||||||
|
mode = ["n" "i"];
|
||||||
action = "<nop>";
|
action = "<nop>";
|
||||||
noremap = false;
|
noremap = false;
|
||||||
};
|
}
|
||||||
};
|
{
|
||||||
|
key = "<left>";
|
||||||
insert = mkIf cfg.disableArrows {
|
mode = ["n" "i"];
|
||||||
"<up>" = {
|
|
||||||
action = "<nop>";
|
action = "<nop>";
|
||||||
noremap = false;
|
noremap = false;
|
||||||
};
|
}
|
||||||
"<down>" = {
|
{
|
||||||
|
key = "<right>";
|
||||||
|
mode = ["n" "i"];
|
||||||
action = "<nop>";
|
action = "<nop>";
|
||||||
noremap = false;
|
noremap = false;
|
||||||
};
|
}
|
||||||
"<left>" = {
|
]
|
||||||
action = "<nop>";
|
)
|
||||||
noremap = false;
|
(
|
||||||
};
|
pipe cfg.maps
|
||||||
"<right>" = {
|
[
|
||||||
action = "<nop>";
|
(mapAttrsToList (
|
||||||
noremap = false;
|
oldMode: keybinds:
|
||||||
};
|
mapAttrsToList (
|
||||||
};
|
key: bind:
|
||||||
};
|
bind
|
||||||
|
// {
|
||||||
|
inherit key;
|
||||||
|
mode = legacyMapModes.${oldMode};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
keybinds
|
||||||
|
))
|
||||||
|
flatten
|
||||||
|
]
|
||||||
|
)
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,101 +1,97 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.options) mkOption literalMD;
|
||||||
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 = {
|
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 {
|
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;
|
|
||||||
|
silent = mkBool true "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.";
|
||||||
|
};
|
||||||
|
|
||||||
|
mapType = submodule {
|
||||||
|
options =
|
||||||
|
mapConfigOptions
|
||||||
|
// {
|
||||||
|
key = mkOption {
|
||||||
|
type = str;
|
||||||
|
description = "The key that triggers this keybind.";
|
||||||
|
};
|
||||||
|
mode = mkOption {
|
||||||
|
type = either str (listOf str);
|
||||||
|
description = ''
|
||||||
|
The short-name of the mode to set the keymapping for. Passing an empty string is the equivalent of `:map`.
|
||||||
|
|
||||||
|
See `:help map-modes` for a list of modes.
|
||||||
|
'';
|
||||||
|
example = literalMD ''`["n" "v" "c"]` for normal, visual and command mode'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
mapOptions = mode:
|
legacyMapOption = mode:
|
||||||
mkOption {
|
mkOption {
|
||||||
description = "Mappings for ${mode} mode";
|
description = "Mappings for ${mode} mode";
|
||||||
type = attrsOf mapOption;
|
type = attrsOf (submodule {
|
||||||
|
options = mapConfigOptions;
|
||||||
|
});
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
options.vim = {
|
options.vim = {
|
||||||
maps = mkOption {
|
keymaps = mkOption {
|
||||||
type = submodule {
|
type = listOf mapType;
|
||||||
options = {
|
description = "Custom keybindings.";
|
||||||
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 = {};
|
|
||||||
description = ''
|
|
||||||
Custom keybindings for any mode.
|
|
||||||
|
|
||||||
For plain maps (e.g. just 'map' or 'remap') use `maps.normalVisualOp`.
|
|
||||||
'';
|
|
||||||
|
|
||||||
example = ''
|
example = ''
|
||||||
maps = {
|
vim.keymaps = [
|
||||||
normal."<leader>m" = {
|
{
|
||||||
|
key = "<leader>m";
|
||||||
|
mode = "n";
|
||||||
silent = true;
|
silent = true;
|
||||||
action = "<cmd>make<CR>";
|
action = ":make<CR>";
|
||||||
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR>
|
}
|
||||||
};
|
{
|
||||||
|
key = "<leader>l";
|
||||||
|
mode = ["n" "x"];
|
||||||
|
silent = true;
|
||||||
|
action = "<cmd>cnext<CR>";
|
||||||
|
}
|
||||||
|
];
|
||||||
'';
|
'';
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
maps = {
|
||||||
|
normal = legacyMapOption "normal";
|
||||||
|
insert = legacyMapOption "insert";
|
||||||
|
select = legacyMapOption "select";
|
||||||
|
visual = legacyMapOption "visual and select";
|
||||||
|
terminal = legacyMapOption "terminal";
|
||||||
|
normalVisualOp = legacyMapOption "normal, visual, select and operator-pending (same as plain 'map')";
|
||||||
|
|
||||||
|
visualOnly = legacyMapOption "visual only";
|
||||||
|
operator = legacyMapOption "operator-pending";
|
||||||
|
insertCommand = legacyMapOption "insert and command-line";
|
||||||
|
lang = legacyMapOption "insert, command-line and lang-arg";
|
||||||
|
command = legacyMapOption "command-line";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ in {
|
||||||
"neo-tree-nvim"
|
"neo-tree-nvim"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
visuals.nvimWebDevicons.enable = true;
|
||||||
|
|
||||||
pluginRC.neo-tree = entryAnywhere ''
|
pluginRC.neo-tree = entryAnywhere ''
|
||||||
require("neo-tree").setup(${toLuaObject cfg.setupOpts})
|
require("neo-tree").setup(${toLuaObject cfg.setupOpts})
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -114,12 +114,12 @@ in {
|
||||||
(mkIf cfg.elixir-tools.enable {
|
(mkIf cfg.elixir-tools.enable {
|
||||||
vim.startPlugins = ["elixir-tools"];
|
vim.startPlugins = ["elixir-tools"];
|
||||||
vim.pluginRC.elixir-tools = entryAnywhere ''
|
vim.pluginRC.elixir-tools = entryAnywhere ''
|
||||||
local elixir-tools = require("elixir")
|
local elixir = require("elixir")
|
||||||
local elixirls = require("elixir-tools.elixirls")
|
local elixirls = require("elixir.elixirls")
|
||||||
|
|
||||||
-- disable imperative insstallations of various
|
-- disable imperative insstallations of various
|
||||||
-- elixir related tools installed by elixir-tools
|
-- elixir related tools installed by elixir-tools
|
||||||
elixir-tools.setup {
|
elixir.setup {
|
||||||
nextls = {
|
nextls = {
|
||||||
enable = false -- defaults to false
|
enable = false -- defaults to false
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,29 +17,36 @@
|
||||||
"ayu_dark"
|
"ayu_dark"
|
||||||
"ayu_light"
|
"ayu_light"
|
||||||
"ayu_mirage"
|
"ayu_mirage"
|
||||||
|
"ayu"
|
||||||
"codedark"
|
"codedark"
|
||||||
"dracula"
|
"dracula"
|
||||||
"everforest"
|
"everforest"
|
||||||
"gruvbox"
|
"gruvbox"
|
||||||
|
"gruvbox_dark"
|
||||||
"gruvbox_light"
|
"gruvbox_light"
|
||||||
"gruvbox_material"
|
"gruvbox_material"
|
||||||
"horizon"
|
"horizon"
|
||||||
"iceberg_dark"
|
"iceberg_dark"
|
||||||
"iceberg_light"
|
"iceberg_light"
|
||||||
|
"iceberg"
|
||||||
"jellybeans"
|
"jellybeans"
|
||||||
"material"
|
"material"
|
||||||
"modus_vivendi"
|
"modus_vivendi"
|
||||||
"molokai"
|
"molokai"
|
||||||
|
"moonfly"
|
||||||
"nightfly"
|
"nightfly"
|
||||||
"nord"
|
"nord"
|
||||||
"oceanicnext"
|
"oceanicnext"
|
||||||
|
"onedark"
|
||||||
"onelight"
|
"onelight"
|
||||||
"palenight"
|
"palenight"
|
||||||
"papercolor_dark"
|
"papercolor_dark"
|
||||||
"papercolor_light"
|
"papercolor_light"
|
||||||
|
"powerline_dark"
|
||||||
"powerline"
|
"powerline"
|
||||||
"seoul256"
|
"seoul256"
|
||||||
"solarized_dark"
|
"solarized_dark"
|
||||||
|
"solarized_light"
|
||||||
"tomorrow"
|
"tomorrow"
|
||||||
"wombat"
|
"wombat"
|
||||||
];
|
];
|
||||||
|
@ -224,7 +231,7 @@ in {
|
||||||
local buf_ft = vim.api.nvim_get_option_value('filetype', {})
|
local buf_ft = vim.api.nvim_get_option_value('filetype', {})
|
||||||
|
|
||||||
-- List of buffer types to exclude
|
-- List of buffer types to exclude
|
||||||
local excluded_buf_ft = {"toggleterm", "NvimTree", "TelescopePrompt"}
|
local excluded_buf_ft = {"toggleterm", "NvimTree", "neo-tree", "TelescopePrompt"}
|
||||||
|
|
||||||
-- Check if the current buffer type is in the excluded list
|
-- Check if the current buffer type is in the excluded list
|
||||||
for _, excluded_type in ipairs(excluded_buf_ft) do
|
for _, excluded_type in ipairs(excluded_buf_ft) do
|
||||||
|
|
|
@ -4,7 +4,14 @@
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
inherit (lib.trivial) boolToString warnIf;
|
inherit (lib.trivial) boolToString warnIf;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
in {
|
in {
|
||||||
|
base16 = {
|
||||||
|
setup = {base16-colors, ...}: ''
|
||||||
|
-- Base16 theme
|
||||||
|
require('base16-colorscheme').setup(${toLuaObject base16-colors})
|
||||||
|
'';
|
||||||
|
};
|
||||||
onedark = {
|
onedark = {
|
||||||
setup = {style ? "dark", ...}: ''
|
setup = {style ? "dark", ...}: ''
|
||||||
-- OneDark theme
|
-- OneDark theme
|
||||||
|
@ -20,6 +27,7 @@ in {
|
||||||
setup = {
|
setup = {
|
||||||
style ? "night",
|
style ? "night",
|
||||||
transparent,
|
transparent,
|
||||||
|
...
|
||||||
}: ''
|
}: ''
|
||||||
require('tokyonight').setup {
|
require('tokyonight').setup {
|
||||||
transparent = ${boolToString transparent};
|
transparent = ${boolToString transparent};
|
||||||
|
@ -42,6 +50,7 @@ in {
|
||||||
setup = {
|
setup = {
|
||||||
style ? "mocha",
|
style ? "mocha",
|
||||||
transparent ? false,
|
transparent ? false,
|
||||||
|
...
|
||||||
}: ''
|
}: ''
|
||||||
-- Catppuccin theme
|
-- Catppuccin theme
|
||||||
require('catppuccin').setup {
|
require('catppuccin').setup {
|
||||||
|
@ -69,7 +78,7 @@ in {
|
||||||
notify = true, -- nvim-notify
|
notify = true, -- nvim-notify
|
||||||
which_key = true,
|
which_key = true,
|
||||||
navic = {
|
navic = {
|
||||||
enabled = false,
|
enabled = true,
|
||||||
custom_bg = "NONE", -- "lualine" will set background to mantle
|
custom_bg = "NONE", -- "lualine" will set background to mantle
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,32 +4,51 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.options) mkOption;
|
||||||
inherit (lib.attrsets) attrNames;
|
inherit (lib.attrsets) attrNames listToAttrs;
|
||||||
|
inherit (lib.strings) hasPrefix;
|
||||||
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) entryBefore;
|
||||||
|
inherit (lib.nvim.types) hexColor;
|
||||||
|
|
||||||
cfg = config.vim.theme;
|
cfg = config.vim.theme;
|
||||||
supportedThemes = import ./supported-themes.nix {
|
supportedThemes = import ./supported-themes.nix {
|
||||||
inherit lib config;
|
inherit lib config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
numbers = ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F"];
|
||||||
|
base16Options = listToAttrs (map (n: {
|
||||||
|
name = "base0${n}";
|
||||||
|
value = mkOption {
|
||||||
|
description = "The base0${n} color to use";
|
||||||
|
type = hexColor;
|
||||||
|
apply = v:
|
||||||
|
if hasPrefix "#" v
|
||||||
|
then v
|
||||||
|
else "#${v}";
|
||||||
|
};
|
||||||
|
})
|
||||||
|
numbers);
|
||||||
in {
|
in {
|
||||||
options.vim.theme = {
|
options.vim.theme = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
description = "Enable theming";
|
description = "Enable theming";
|
||||||
};
|
};
|
||||||
|
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
type = enum (attrNames supportedThemes);
|
type = enum (attrNames supportedThemes);
|
||||||
description = "Supported themes can be found in `supportedThemes.nix`";
|
description = ''
|
||||||
|
Supported themes can be found in {file}`supportedThemes.nix`.
|
||||||
|
Setting the theme to "base16" enables base16 theming and
|
||||||
|
requires all of the colors in {option}`vim.theme.base16-colors` to be set.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
base16-colors = base16Options;
|
||||||
|
|
||||||
style = mkOption {
|
style = mkOption {
|
||||||
type = enum supportedThemes.${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";
|
||||||
};
|
};
|
||||||
|
|
||||||
transparent = mkOption {
|
transparent = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
@ -47,7 +66,7 @@ in {
|
||||||
startPlugins = [cfg.name];
|
startPlugins = [cfg.name];
|
||||||
luaConfigRC.theme = entryBefore ["pluginConfigs"] ''
|
luaConfigRC.theme = entryBefore ["pluginConfigs"] ''
|
||||||
${cfg.extraConfig}
|
${cfg.extraConfig}
|
||||||
${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent;}}
|
${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent base16-colors;}}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,33 +4,21 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.strings) optionalString;
|
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
|
||||||
cfg = config.vim.binds.whichKey;
|
cfg = config.vim.binds.whichKey;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = ["which-key"];
|
vim = {
|
||||||
|
startPlugins = ["which-key"];
|
||||||
|
|
||||||
vim.pluginRC.whichkey = entryAnywhere ''
|
pluginRC.whichkey = entryAnywhere ''
|
||||||
local wk = require("which-key")
|
local wk = require("which-key")
|
||||||
wk.setup ({
|
|
||||||
key_labels = {
|
|
||||||
["<space>"] = "SPACE",
|
|
||||||
["<leader>"] = "SPACE",
|
|
||||||
["<cr>"] = "RETURN",
|
|
||||||
["<tab>"] = "TAB",
|
|
||||||
},
|
|
||||||
|
|
||||||
${optionalString config.vim.ui.borders.plugins.which-key.enable ''
|
|
||||||
window = {
|
|
||||||
border = ${toLuaObject config.vim.ui.borders.plugins.which-key.style},
|
|
||||||
},
|
|
||||||
''}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
wk.setup (${toLuaObject cfg.setupOpts})
|
||||||
wk.register(${toLuaObject cfg.register})
|
wk.register(${toLuaObject cfg.register})
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
{lib, ...}: let
|
{
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
config,
|
||||||
inherit (lib.types) attrsOf nullOr str;
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
|
inherit (lib.types) attrsOf nullOr str attrs enum bool;
|
||||||
|
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||||
in {
|
in {
|
||||||
options.vim.binds.whichKey = {
|
options.vim.binds.whichKey = {
|
||||||
enable = mkEnableOption "which-key keybind helper menu";
|
enable = mkEnableOption "which-key keybind helper menu";
|
||||||
|
@ -10,5 +15,38 @@ in {
|
||||||
type = attrsOf (nullOr str);
|
type = attrsOf (nullOr str);
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setupOpts = mkPluginSetupOption "which-key" {
|
||||||
|
preset = mkOption {
|
||||||
|
type = enum ["classic" "modern" "helix"];
|
||||||
|
default = "modern";
|
||||||
|
description = "The default preset for the which-key window";
|
||||||
|
};
|
||||||
|
|
||||||
|
notify = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = false; # FIXME: this should be true before the merge
|
||||||
|
description = "Show a warning when issues were detected with mappings";
|
||||||
|
};
|
||||||
|
|
||||||
|
replace = mkOption {
|
||||||
|
type = attrs;
|
||||||
|
default = {
|
||||||
|
"<space>" = "SPACE";
|
||||||
|
"<leader>" = "SPACE";
|
||||||
|
"<cr>" = "RETURN";
|
||||||
|
"<tab>" = "TAB";
|
||||||
|
};
|
||||||
|
description = "Functions/Lua Patterns for formatting the labels";
|
||||||
|
};
|
||||||
|
|
||||||
|
win = {
|
||||||
|
border = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = config.vim.ui.borders.plugins.which-key.style;
|
||||||
|
description = "Which-key window border style";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,42 +3,29 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
|
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
|
||||||
cfg = config.vim.utility.surround;
|
cfg = config.vim.utility.surround;
|
||||||
self = import ./surround.nix {inherit lib config;};
|
|
||||||
mappingDefinitions = self.options.vim.utility.surround.mappings;
|
|
||||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim = {
|
vim = {
|
||||||
startPlugins = [
|
startPlugins = ["nvim-surround"];
|
||||||
"nvim-surround"
|
pluginRC.surround = entryAnywhere "require('nvim-surround').setup(${toLuaObject cfg.setupOpts})";
|
||||||
];
|
|
||||||
|
|
||||||
pluginRC.surround = entryAnywhere ''
|
utility.surround.setupOpts.keymaps = mkIf cfg.useVendoredKeybindings {
|
||||||
require('nvim-surround').setup()
|
insert = "<C-g>z";
|
||||||
'';
|
insert_line = "<C-g>Z";
|
||||||
|
normal = "gz";
|
||||||
maps = {
|
normal_cur = "gZ";
|
||||||
insert = mkMerge [
|
normal_line = "gzz";
|
||||||
(mkIf (mappings.insert != null) (mkSetBinding mappings.insert "<Plug>(nvim-surround-insert)"))
|
normal_cur_line = "gZZ";
|
||||||
(mkIf (mappings.insertLine != null) (mkSetBinding mappings.insertLine "<Plug>(nvim-surround-insert-line)"))
|
visual = "gz";
|
||||||
];
|
visual_line = "gZ";
|
||||||
normal = mkMerge [
|
delete = "gzd";
|
||||||
(mkIf (mappings.normal != null) (mkSetBinding mappings.normal "<Plug>(nvim-surround-normal)"))
|
change = "gzr";
|
||||||
(mkIf (mappings.normalCur != null) (mkSetBinding mappings.normalCur "<Plug>(nvim-surround-normal-cur)"))
|
change_line = "gZR";
|
||||||
(mkIf (mappings.normalLine != null) (mkSetBinding mappings.normalLine "<Plug>(nvim-surround-normal-line)"))
|
|
||||||
(mkIf (mappings.normalCurLine != null) (mkSetBinding mappings.normalCurLine "<Plug>(nvim-surround-normal-cur-line)"))
|
|
||||||
(mkIf (mappings.delete != null) (mkSetBinding mappings.delete "<Plug>(nvim-surround-delete)"))
|
|
||||||
(mkIf (mappings.change != null) (mkSetBinding mappings.change "<Plug>(nvim-surround-change)"))
|
|
||||||
];
|
|
||||||
visualOnly = mkMerge [
|
|
||||||
(mkIf (mappings.visual != null) (mkSetBinding mappings.visual "<Plug>(nvim-surround-visual)"))
|
|
||||||
(mkIf (mappings.visualLine != null) (mkSetBinding mappings.visualLine "<Plug>(nvim-surround-visual-line)"))
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,90 +1,24 @@
|
||||||
{
|
{lib, ...}: let
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit (lib.modules) mkIf mkDefault;
|
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.options) mkOption;
|
||||||
inherit (lib.types) bool nullOr str;
|
inherit (lib.types) bool;
|
||||||
|
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||||
in {
|
in {
|
||||||
options.vim.utility.surround = {
|
options.vim.utility.surround = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "nvim-surround: add/change/delete surrounding delimiter pairs with ease. Note that the default mappings deviate from upstreeam to avoid conflicts with nvim-leap.";
|
description = ''
|
||||||
|
nvim-surround: add/change/delete surrounding delimiter pairs with ease.
|
||||||
|
Note that the default mappings deviate from upstreeam to avoid conflicts
|
||||||
|
with nvim-leap.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
setupOpts = mkPluginSetupOption "nvim-surround" {};
|
||||||
|
|
||||||
useVendoredKeybindings = mkOption {
|
useVendoredKeybindings = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "Use alternative set of keybindings that avoids conflicts with other popular plugins, e.g. nvim-leap";
|
description = "Use alternative set of keybindings that avoids conflicts with other popular plugins, e.g. nvim-leap";
|
||||||
};
|
};
|
||||||
mappings = {
|
|
||||||
insert = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
default = "<C-g>z";
|
|
||||||
description = "Add surround character around the cursor";
|
|
||||||
};
|
|
||||||
insertLine = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
default = "<C-g>Z";
|
|
||||||
description = "Add surround character around the cursor on new lines";
|
|
||||||
};
|
|
||||||
normal = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
default = "gz";
|
|
||||||
description = "Surround motion with character";
|
|
||||||
};
|
|
||||||
normalCur = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
default = "gZ";
|
|
||||||
description = "Surround motion with character on new lines";
|
|
||||||
};
|
|
||||||
normalLine = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
default = "gzz";
|
|
||||||
description = "Surround line with character";
|
|
||||||
};
|
|
||||||
normalCurLine = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
default = "gZZ";
|
|
||||||
description = "Surround line with character on new lines";
|
|
||||||
};
|
|
||||||
visual = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
default = "gz";
|
|
||||||
description = "Surround selection with character";
|
|
||||||
};
|
|
||||||
visualLine = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
default = "gZ";
|
|
||||||
description = "Surround selection with character on new lines";
|
|
||||||
};
|
|
||||||
delete = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
default = "gzd";
|
|
||||||
description = "Delete surrounding character";
|
|
||||||
};
|
|
||||||
change = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
default = "gzr";
|
|
||||||
description = "Change surrounding character";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
config.vim.utility.surround = let
|
|
||||||
cfg = config.vim.utility.surround;
|
|
||||||
in {
|
|
||||||
mappings = mkIf (! cfg.useVendoredKeybindings) (mkDefault {
|
|
||||||
insert = null;
|
|
||||||
insertLine = null;
|
|
||||||
normal = null;
|
|
||||||
normalCur = null;
|
|
||||||
normalLine = null;
|
|
||||||
normalCurLine = null;
|
|
||||||
visual = null;
|
|
||||||
visualLine = null;
|
|
||||||
delete = null;
|
|
||||||
change = null;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,80 +4,14 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) map mapAttrs filter;
|
inherit (builtins) map mapAttrs filter;
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.attrsets) mapAttrsToList filterAttrs;
|
||||||
inherit (lib.attrsets) mapAttrsToList filterAttrs getAttrs attrValues attrNames;
|
|
||||||
inherit (lib.strings) concatLines concatMapStringsSep;
|
inherit (lib.strings) concatLines concatMapStringsSep;
|
||||||
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
|
||||||
globalsScript =
|
globalsScript =
|
||||||
|
@ -98,38 +32,18 @@ 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) desc 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 = bind: "vim.keymap.set(${toLuaObject bind.mode}, ${toLuaObject bind.key}, ${toLuaObject (getAction bind)}, ${toLuaObject (getOpts bind)})";
|
||||||
nmap
|
|
||||||
imap
|
keymaps = concatLines (map toLuaKeymap cfg.keymaps);
|
||||||
vmap
|
|
||||||
xmap
|
|
||||||
smap
|
|
||||||
cmap
|
|
||||||
omap
|
|
||||||
tmap
|
|
||||||
lmap
|
|
||||||
icmap
|
|
||||||
allmap
|
|
||||||
];
|
|
||||||
mappings = concatLines (map concatLines maps);
|
|
||||||
in {
|
in {
|
||||||
vim = {
|
vim = {
|
||||||
luaConfigRC = {
|
luaConfigRC = {
|
||||||
|
@ -140,7 +54,7 @@ in {
|
||||||
# Basic
|
# Basic
|
||||||
pluginConfigs = entryAfter ["optionsScript"] pluginConfigs;
|
pluginConfigs = entryAfter ["optionsScript"] pluginConfigs;
|
||||||
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
|
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
|
||||||
mappings = entryAfter ["extraPluginConfigs"] mappings;
|
mappings = entryAfter ["extraPluginConfigs"] keymaps;
|
||||||
};
|
};
|
||||||
|
|
||||||
builtLuaConfigRC = let
|
builtLuaConfigRC = let
|
||||||
|
|
Loading…
Add table
Reference in a new issue