Compare commits

..

2 commits

Author SHA1 Message Date
51fb4c40ed
binds/which-key: start migrating to setupOpts 2024-09-29 03:33:48 +03:00
56366ace38
flake: update all plugin inputs 2024-09-29 03:33:47 +03:00
18 changed files with 473 additions and 453 deletions

8
.github/README.md vendored
View file

@ -124,16 +124,10 @@ 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
install **nvf** as a standalone package, or a flake output.
See the rendered [nvf manual] for detailed and up-to-date installation guides,
See the [**nvf** manual] for detailed and up-to-date installation guides,
configurations, available options, release notes and more. Tips for installing
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
lacking or confusing. Any improvements to the documentation through pull
requests are also welcome, and appreciated.

View file

@ -1,57 +1,39 @@
<!--
^ Please include a clear and concise description of the aim of your Pull Request above this line ^
# Description
For plugin dependency/module additions, please make sure to link the source link of the added plugin
or dependency in this section.
A clear and concise description of the aim of your Pull Request.
If your pull request aims to fix an open issue or a please bug, please also link the relevant issue
below this line. You may attach an issue to your pull request with `Fixes #<issue number>` outside
this comment.
-->
**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**
Fixes #(issue)
## Sanity Checking
## Type of change
<!--
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.
Please delete any options that are not relevant.
If your pull request includes any change or unexpected behaviour not covered below, please do make sure to include
it above in your description.
-->
- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing functionality to not work as expected)
- Translation/Language update
- Docs
- Other
[editorconfig]: https://editorconfig.org
[changelog]: https://github.com/NotAShelf/nvf/tree/main/docs/release-notes
## Checklist
- [ ] 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`
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.
<!--
If your changes touch upon a portion of the codebase that you do not understand well, please make sure to consult
the maintainers on your changes. In most cases, making an issue before creating your PR will help you avoid duplicate
efforts in the long run.
-->
- [ ] My code follows the style and contributing guidelines of this project.
- [ ] I ran Alejandra to format my code (`nix fmt`).
- [ ] I have performed a self-review of my own code and tested it.
- [ ] I have commented my code, particularly in hard-to-understand areas.
- [ ] My changes generate no new warnings.
- [ ] This change requires a documentation update.
- [ ] I have updated the documentation accordingly.
---
## Screenshots & Logs
Add a :+1: [reaction] to [pull requests you find important].
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/).
[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
**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.**
```console
# Paste your logs here
```

View file

@ -7,26 +7,37 @@ section contains a general overview to how you may utilize said functions.
## Custom Key Mappings Support for a Plugin {#sec-custom-key-mappings}
To set a mapping, you should define it in `vim.keymaps`.
To set a mapping, you should define it in `vim.maps.<<mode>>`.
The available modes are:
- normal
- insert
- select
- visual
- terminal
- normalVisualOp
- visualOnly
- operator
- insertCommand
- lang
- command
An example, simple keybinding, can look like this:
```nix
{
vim.keymaps = [
{
key = "<leader>wq";
mode = ["n"];
vim.maps.normal = {
"<leader>wq" = {
action = ":wq<CR>";
silent = true;
desc = "Save file and quit";
}
];
};
};
}
```
There are many settings available in the options. Please refer to the
[documentation](https://notashelf.github.io/nvf/options.html#opt-vim.keymaps)
[documentation](https://notashelf.github.io/nvf/options.html#opt-vim.maps.command._name_.action)
to see a list of them.
**nvf** provides a list of helper commands, so that you don't have to write the

View file

@ -26,31 +26,6 @@ making good use of its extensive Lua API. Additionally, Vimscript is slow and
brings unnecessary performance overhead while working with different
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}
The nvim-code-action-menu plugin has been archived and broken for a long time,
@ -62,7 +37,6 @@ 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
everyone.
## Changelog {#sec-release-0.7-changelog}
[ItsSorae](https://github.com/ItsSorae):
@ -106,17 +80,13 @@ everyone.
[ocaml-lsp]: https://github.com/ocaml/ocaml-lsp
[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
- Fix "Emac" typo
- Add [new-file-template.nvim] to automatically fill new file contents using
templates
- Make [neo-tree.nvim] display file icons properly by enabling
`visuals.nvimWebDevicons`
templates.
[diniamo](https://github.com/diniamo):
@ -150,8 +120,6 @@ everyone.
- Replace `vim.lsp.nvimCodeActionMenu` with `vim.ui.fastaction`, see the
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()
- Make Neovim's configuration file entirely Lua based. This comes with a few
@ -164,8 +132,6 @@ everyone.
has been introduced for setting up internal plugins. See the "DAG entries in
nvf" manual page for more information.
- Rewrite `vim.maps`, see the breaking changes section above.
[NotAShelf](https://github.com/notashelf):
[ts-error-translator.nvim]: https://github.com/dmmulroy/ts-error-translator.nvim
@ -227,25 +193,14 @@ everyone.
- Add [](#opt-vim.dashboard.dashboard-nvim.setupOpts) to allow user
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):
- Telescope:
- Fixed `project-nvim` command and keybinding
- 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 Otter support under `vim.lsp.otter` and an assert to prevent conflict with
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.

211
flake.lock generated
View file

@ -5,11 +5,11 @@
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1727826117,
"narHash": "sha256-K5ZLCyfO/Zj9mPFldf3iwS6oZStJcU4tSpiXTMYaaL0=",
"lastModified": 1726153070,
"narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "3d04084d54bedc3d6b8b736c70ef449225c361b1",
"rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a",
"type": "github"
},
"original": {
@ -38,11 +38,11 @@
},
"mnw": {
"locked": {
"lastModified": 1727568629,
"narHash": "sha256-mr6VhivnpENjGHHPhF9vwtxh5Iy0VJ1oU1PVsGAITd0=",
"lastModified": 1727043208,
"narHash": "sha256-blaQYqSYZX+e0AVLmwn/SZq9qH1fakajHRL6cAid3sk=",
"owner": "Gerg-L",
"repo": "mnw",
"rev": "8e80e53d4aa1a651fb1d8bd32aa7809833870d15",
"rev": "b2939ce377f471f4fb07f2d9fbb9220010b52efb",
"type": "github"
},
"original": {
@ -98,11 +98,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1728217273,
"narHash": "sha256-p/gvyVf24WFs0bted3c71uSQk++ZOYRWbg3bjRoePu4=",
"lastModified": 1726871744,
"narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "50b3bd3fed0442bcbf7f58355e990da84af1749d",
"rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2",
"type": "github"
},
"original": {
@ -114,14 +114,14 @@
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1727825735,
"narHash": "sha256-0xHYkMkeLVQAMa7gvkddbPqpxph+hDzdu1XdGPJR+Os=",
"lastModified": 1725233747,
"narHash": "sha256-Ss8QWLXdr2JCBPcYChJhz4xJm+h/xjl4G0c0XlP6a74=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz"
"url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/fb192fec7cc7a4c26d51779e9bab07ce6fa5597a.tar.gz"
"url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz"
}
},
"nixpkgs_2": {
@ -159,11 +159,11 @@
"plugin-alpha-nvim": {
"flake": false,
"locked": {
"lastModified": 1727720738,
"narHash": "sha256-33lhPP1C4TGo0UQJ61bwRHaiOMAB7XNehcZGaFXOPjQ=",
"lastModified": 1724084627,
"narHash": "sha256-gvPEmjM36Z7Q8K83/0ZVLN6J/2mDfEZJ7cW1u+FWf/8=",
"owner": "goolord",
"repo": "alpha-nvim",
"rev": "bf3c8bb8c02ed3d9644cc5bbc48e2bdc39349cd7",
"rev": "b6f4129302db197a7249e67a90de3f2b676de13e",
"type": "github"
},
"original": {
@ -172,22 +172,6 @@
"type": "github"
}
},
"plugin-base16": {
"flake": false,
"locked": {
"lastModified": 1716483968,
"narHash": "sha256-GRF/6AobXHamw8TZ3FjL7SI6ulcpwpcohsIuZeCSh2A=",
"owner": "rrethy",
"repo": "base16-nvim",
"rev": "6ac181b5733518040a33017dde654059cd771b7c",
"type": "github"
},
"original": {
"owner": "rrethy",
"repo": "base16-nvim",
"type": "github"
}
},
"plugin-bufdelete-nvim": {
"flake": false,
"locked": {
@ -207,11 +191,11 @@
"plugin-catppuccin": {
"flake": false,
"locked": {
"lastModified": 1728131011,
"narHash": "sha256-j6F078taxuGzr3jngrc+Pc5I1kDdxTLMETgq6Xn4w/4=",
"lastModified": 1726377217,
"narHash": "sha256-9fEESnT8KSlng+naqVlyrRJnnbRGE0RxTSSGO0gcSKw=",
"owner": "catppuccin",
"repo": "nvim",
"rev": "7be452ee067978cdc8b2c5f3411f0c71ffa612b9",
"rev": "63685e1562ef53873c9764b483d7ac5c7a608922",
"type": "github"
},
"original": {
@ -223,11 +207,11 @@
"plugin-ccc": {
"flake": false,
"locked": {
"lastModified": 1727935067,
"narHash": "sha256-OhdR2sAQV5PvlhaKQ6rYneMmvQiN3QfymOeanpAs9wY=",
"lastModified": 1724982444,
"narHash": "sha256-wixdlzKo1ilea7SMichKjTwe8DhqHB4cI/SG9aciBnc=",
"owner": "uga-rosa",
"repo": "ccc.nvim",
"rev": "7c639042583c7bdc7ce2e37e5a0e0aa6d0659c6a",
"rev": "790aa881d7f47bc7cc07ad03f1216bb7caf9ef67",
"type": "github"
},
"original": {
@ -447,11 +431,11 @@
"plugin-crates-nvim": {
"flake": false,
"locked": {
"lastModified": 1727384188,
"narHash": "sha256-DIG0MXRTit4iEVoLlgsTK4znjam/QDjeZEpIDn6KHiE=",
"lastModified": 1726238268,
"narHash": "sha256-86plXzEBSkqV4F0LnhmM+Sy/m0xCKFOMILIMBpl6Eas=",
"owner": "Saecki",
"repo": "crates.nvim",
"rev": "8bf8358ee326d5d8c11dcd7ac0bcc9ff97dbc785",
"rev": "5a24e3ba60e28e0cfde540696630b3c5a4db6dfd",
"type": "github"
},
"original": {
@ -527,11 +511,11 @@
"plugin-elixir-tools": {
"flake": false,
"locked": {
"lastModified": 1727872243,
"narHash": "sha256-7gIvoV6myqbkjLnIhHuyNPix1DFkKEeeND2o6VDxDWc=",
"lastModified": 1720582280,
"narHash": "sha256-Wyste1eDZF9wTnCwUrYjXjD74z49n/30yQzCWtBDZyY=",
"owner": "elixir-tools",
"repo": "elixir-tools.nvim",
"rev": "b465f6aff50257fa466de3886fc3e7de2dcff0de",
"rev": "5e7596be469be0800e9cbe3415de971f7286c3d0",
"type": "github"
},
"original": {
@ -543,11 +527,11 @@
"plugin-fastaction-nvim": {
"flake": false,
"locked": {
"lastModified": 1727988914,
"narHash": "sha256-gYTBuFL2NnT+yIYPM17EWWGF50wGJ/78HiT1SiYf83k=",
"lastModified": 1726007462,
"narHash": "sha256-QCPE2hmSnNLO1/EfZXTc/PP8Q0QRw5D8T8EN+NyUv2s=",
"owner": "Chaitanyabsprip",
"repo": "fastaction.nvim",
"rev": "45ce9a6ef9c8c1db80bf48383a18e1c1c4a488ea",
"rev": "0a908a55e69814c5ef5b9f20dca7657c8639ee2c",
"type": "github"
},
"original": {
@ -575,11 +559,11 @@
"plugin-flutter-tools": {
"flake": false,
"locked": {
"lastModified": 1727357653,
"narHash": "sha256-snImg0Kn4OZQW7IM4u5G3pkYgnfLKlbEPAXzbsWHh58=",
"lastModified": 1727108698,
"narHash": "sha256-ID47S04SIfAtZnNAzdxqOOOfSRQvsJ9yqC9zS17O3Bg=",
"owner": "akinsho",
"repo": "flutter-tools.nvim",
"rev": "ce18f5da5f9c458cd26eef5c3accb0c37b2263c2",
"rev": "6610090a4e68d10fd73b68450004dafd26e7cc34",
"type": "github"
},
"original": {
@ -607,11 +591,11 @@
"plugin-gitsigns-nvim": {
"flake": false,
"locked": {
"lastModified": 1727424886,
"narHash": "sha256-o2Y57z7IuIa9wvLlzyslcs3/+iaZzuqM1NImlKAPt5Y=",
"lastModified": 1725453693,
"narHash": "sha256-s3y8ZuLV00GIhizcK/zqsJOTKecql7Xn3LGYmH7NLsQ=",
"owner": "lewis6991",
"repo": "gitsigns.nvim",
"rev": "863903631e676b33e8be2acb17512fdc1b80b4fb",
"rev": "1ef74b546732f185d0f806860fa5404df7614f28",
"type": "github"
},
"original": {
@ -639,11 +623,11 @@
"plugin-gruvbox": {
"flake": false,
"locked": {
"lastModified": 1727809136,
"narHash": "sha256-/kgZuNJ1vHyOpvFHiJKCb1HzjSPgqis9Ng4aT7jHXG4=",
"lastModified": 1720105192,
"narHash": "sha256-+t9jdpvykfBDgXelDc/3bAOCN7cmu6/TwFoZy47zKUM=",
"owner": "ellisonleao",
"repo": "gruvbox.nvim",
"rev": "49d9c0b150ba70efcd831ec7b3cb8ee740067045",
"rev": "7a1b23e4edf73a39642e77508ee6b9cbb8c60f9e",
"type": "github"
},
"original": {
@ -655,11 +639,11 @@
"plugin-highlight-undo": {
"flake": false,
"locked": {
"lastModified": 1727683895,
"narHash": "sha256-m4ZJZIraV+4W31obnSLHXi8Xq3rcormbvWc/oe+q2ME=",
"lastModified": 1714982601,
"narHash": "sha256-yGw1SxcUmGQxqKhMb2SJAai07g+rOpEJy2CqIX2h9dM=",
"owner": "tzachar",
"repo": "highlight-undo.nvim",
"rev": "baae9094a826ce60580d66b1478dfe727bceb1b9",
"rev": "1ea1c79372d7d93c88fd97543880927b7635e3d2",
"type": "github"
},
"original": {
@ -703,11 +687,11 @@
"plugin-image-nvim": {
"flake": false,
"locked": {
"lastModified": 1727910935,
"narHash": "sha256-s1inWqWYiuH5oWaye8+KWrbBE7D0F8FWut75F+Zk/64=",
"lastModified": 1727039232,
"narHash": "sha256-1Q7YOFdvV4E37SbHe+HyrXgL6DB8VjLHFjcgkg57DDY=",
"owner": "3rd",
"repo": "image.nvim",
"rev": "88e9693e188b8464b1c426aebb4389fd9db2fcbf",
"rev": "f95cb9cca3a05033d5e94cfd760a48ec9a7d4719",
"type": "github"
},
"original": {
@ -719,11 +703,11 @@
"plugin-indent-blankline": {
"flake": false,
"locked": {
"lastModified": 1728043754,
"narHash": "sha256-oFex6MpUDw3ZupNojdKRMDi8CIFiGhpwJx806crBqDU=",
"lastModified": 1725325339,
"narHash": "sha256-5+RulvASXwO2y8owz+6NbPK925llpkACSjC5TuAnUUk=",
"owner": "lukas-reineke",
"repo": "indent-blankline.nvim",
"rev": "3af6493bf69e4a857a8b1fab36f333629d413a18",
"rev": "18603eb949eba08300799f64027af11ef922283f",
"type": "github"
},
"original": {
@ -783,11 +767,11 @@
"plugin-lspkind": {
"flake": false,
"locked": {
"lastModified": 1727343567,
"narHash": "sha256-72j9A16OGm90eL/iQPEuNSvFh7mSUMKQhbTGpSjbnKM=",
"lastModified": 1721915252,
"narHash": "sha256-1KK6JhQUtA5mxwRSKU5e3pTQzZwaoAjzycBLx5X/xlA=",
"owner": "onsails",
"repo": "lspkind-nvim",
"rev": "59c3f419af48a2ffb2320cea85e44e5a95f71664",
"rev": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec",
"type": "github"
},
"original": {
@ -943,11 +927,11 @@
"plugin-noice-nvim": {
"flake": false,
"locked": {
"lastModified": 1727897551,
"narHash": "sha256-9ivgP145phRzu6OD2nwqjgD8glCThnDjS31XHsjbVuM=",
"lastModified": 1726684593,
"narHash": "sha256-pEqwY5myzknlgI3PO8xX1m/I27zgrB6kST/u7BDLCWM=",
"owner": "folke",
"repo": "noice.nvim",
"rev": "df448c649ef6bc5a6a633a44f2ad0ed8d4442499",
"rev": "c1ba80ccf6b3bd8c7fc88fe2e61085131d44ad65",
"type": "github"
},
"original": {
@ -992,11 +976,11 @@
"plugin-nvim-autopairs": {
"flake": false,
"locked": {
"lastModified": 1727742362,
"narHash": "sha256-pqYOaEjKUd5YLVWX0Bf/kYT+sBlN1D24rOBuIz2BIqk=",
"lastModified": 1726659764,
"narHash": "sha256-svW9UUgmu8ZOD5yKAnrNCEq0nDUxAmrLyU7N0pn9EV4=",
"owner": "windwp",
"repo": "nvim-autopairs",
"rev": "ee297f215e95a60b01fde33275cc3c820eddeebe",
"rev": "f158dcb865c36f72c92358f87787dab2c272eaf3",
"type": "github"
},
"original": {
@ -1072,11 +1056,11 @@
"plugin-nvim-dap": {
"flake": false,
"locked": {
"lastModified": 1727540183,
"narHash": "sha256-zN0GTcnUBDfSmvmZd9kBrgW/k3aqbzUlVzgf7wNih40=",
"lastModified": 1726145318,
"narHash": "sha256-4Mp787VTH5Vfg+Ox/MkMUHJ+GL/qzpmqUy1Sc0/FpR8=",
"owner": "mfussenegger",
"repo": "nvim-dap",
"rev": "7ff6936010b7222fea2caea0f67ed77f1b7c60dd",
"rev": "90616ae6ae40053103dc66872886fc26b94c70c8",
"type": "github"
},
"original": {
@ -1088,11 +1072,11 @@
"plugin-nvim-dap-go": {
"flake": false,
"locked": {
"lastModified": 1727922873,
"narHash": "sha256-wcGp5df1ER5T5oLVitWE02OywgJs3V4pazcGU5qVaUY=",
"lastModified": 1722908284,
"narHash": "sha256-VYRq1c3/83gcc/6jyHfQaLlS4LlTXhYlZrq0Y/1S9SE=",
"owner": "leoluz",
"repo": "nvim-dap-go",
"rev": "6aa88167ea1224bcef578e8c7160fe8afbb44848",
"rev": "5511788255c92bdd845f8d9690f88e2e0f0ff9f2",
"type": "github"
},
"original": {
@ -1104,11 +1088,11 @@
"plugin-nvim-dap-ui": {
"flake": false,
"locked": {
"lastModified": 1727897692,
"narHash": "sha256-kg7lyVBeuBqPCVzvt3pBoonQupgf1nGh3EvCF/astf4=",
"lastModified": 1724694165,
"narHash": "sha256-2ysLTiX2664QhFtEmpqM/sdao1+MLSTukxmaRTQv6UE=",
"owner": "rcarriga",
"repo": "nvim-dap-ui",
"rev": "ffa89839f97bad360e78428d5c740fdad9a0ff02",
"rev": "1c351e4e417d4691da12948b6ecf966936a56d28",
"type": "github"
},
"original": {
@ -1152,11 +1136,11 @@
"plugin-nvim-lspconfig": {
"flake": false,
"locked": {
"lastModified": 1728240108,
"narHash": "sha256-oD48kjEMIORjPb5dHmpmbEa1AGJbfZawSuUSbS6Fi9A=",
"lastModified": 1727085470,
"narHash": "sha256-IPpUZEMIL7+4mmqQLy9JeT0cW15/SH3Hx8kyksVcqC0=",
"owner": "neovim",
"repo": "nvim-lspconfig",
"rev": "3805bb215ca2eb3e047c947fc4bf2434ca473ff6",
"rev": "dd329912c8d446240584a2dbcd3802af3a19105a",
"type": "github"
},
"original": {
@ -1280,11 +1264,11 @@
"plugin-nvim-tree-lua": {
"flake": false,
"locked": {
"lastModified": 1727674441,
"narHash": "sha256-BSEaW6Xp0tdmYNI5/YojVQY74lCxwCsSvOS7dG0mMkw=",
"lastModified": 1726982622,
"narHash": "sha256-6OVVjt9g8Hmprw4j138jLsyhyN4vCZqE020cbzT8N3s=",
"owner": "nvim-tree",
"repo": "nvim-tree.lua",
"rev": "c9104a5d079db5a158c9562c54689df27d52dccc",
"rev": "8405ecfbd6bb08a94ffc9c68fef211eea56e8a3b",
"type": "github"
},
"original": {
@ -1296,11 +1280,11 @@
"plugin-nvim-treesitter-context": {
"flake": false,
"locked": {
"lastModified": 1728032522,
"narHash": "sha256-7NrWuN8uzS8fS9WGp3tBF6IpA7oeK64+f8+euCkPbqc=",
"lastModified": 1726947805,
"narHash": "sha256-5oN/vyhSqDqjLEzECj01A7A+Yq7U1H1HXLbzkC1Ljqw=",
"owner": "nvim-treesitter",
"repo": "nvim-treesitter-context",
"rev": "78a81c7494e7d1a08dd1200b556933e513fd9f29",
"rev": "3d5390c49e3f8fe457b376df2a49aa39d75b7911",
"type": "github"
},
"original": {
@ -1328,11 +1312,11 @@
"plugin-nvim-web-devicons": {
"flake": false,
"locked": {
"lastModified": 1728082969,
"narHash": "sha256-2NHhQq3W/OnyhK29WJHepgLXdOsddxlq4MTIs0akpaA=",
"lastModified": 1726878294,
"narHash": "sha256-9jof2xfh8Ett7KtXqPnWMh60bPQSM1mfWQv2QeD/zYY=",
"owner": "nvim-tree",
"repo": "nvim-web-devicons",
"rev": "56f17def81478e406e3a8ec4aa727558e79786f3",
"rev": "26220156aafb198b2de6a4cf80c1b120a3768da0",
"type": "github"
},
"original": {
@ -1376,11 +1360,11 @@
"plugin-orgmode-nvim": {
"flake": false,
"locked": {
"lastModified": 1727262189,
"narHash": "sha256-SrOGqjjDOyKrOu+rTdBWy+nXphuw1a+V9XC0Idb7rd4=",
"lastModified": 1727124422,
"narHash": "sha256-/VCOi8xd2Dp7J5nW1+JPq2YiUg5hGHyOEOknvp3nd74=",
"owner": "nvim-orgmode",
"repo": "orgmode",
"rev": "8ead368a78c7e1df0c15432dfb41d95dd4365f5c",
"rev": "08d763df12f4a03e704c25254ae0de0a95e26eaf",
"type": "github"
},
"original": {
@ -1488,11 +1472,11 @@
"plugin-rustaceanvim": {
"flake": false,
"locked": {
"lastModified": 1728173909,
"narHash": "sha256-BHSxf08OQoLjoa5Ae+57QrFn4wUglDFaCcj5+klnIp4=",
"lastModified": 1727116416,
"narHash": "sha256-4/tOgHwAY+r5lBEqVk5l4YGksRUR49jwKzudMhKkXw8=",
"owner": "mrcjkb",
"repo": "rustaceanvim",
"rev": "d2d9e02ce2c9ffd3746c99925de40e9b3d872f9b",
"rev": "dc0ab4e36f9944901ed8a59878f92c2f818799a7",
"type": "github"
},
"original": {
@ -1568,11 +1552,11 @@
"plugin-telescope": {
"flake": false,
"locked": {
"lastModified": 1728180665,
"narHash": "sha256-bhGlFAJIWJw/jrNWTJs2ywJkX/W+0EP5L4CX6M78dko=",
"lastModified": 1727056928,
"narHash": "sha256-j+BAufOZKUhPC0xSXOAaALJBdLNw2fgB1rGDskz4AIE=",
"owner": "nvim-telescope",
"repo": "telescope.nvim",
"rev": "dc6fc321a5ba076697cca89c9d7ea43153276d81",
"rev": "b324469959908c1c7434eb65d80e87895e6828f7",
"type": "github"
},
"original": {
@ -1616,11 +1600,11 @@
"plugin-tokyonight": {
"flake": false,
"locked": {
"lastModified": 1728047312,
"narHash": "sha256-AUIoU/0vfpIsY+cLCbZ23FfwNIubl6JjTsuhND1nHuc=",
"lastModified": 1726469029,
"narHash": "sha256-d0izq6GCa5XWigiQMY3ODrdJ3jV8Lw8KCTADQA6GbXc=",
"owner": "folke",
"repo": "tokyonight.nvim",
"rev": "2c85fad417170d4572ead7bf9fdd706057bd73d7",
"rev": "817bb6ffff1b9ce72cdd45d9fcfa8c9cd1ad3839",
"type": "github"
},
"original": {
@ -1632,11 +1616,11 @@
"plugin-trouble": {
"flake": false,
"locked": {
"lastModified": 1727856084,
"narHash": "sha256-DR3zRwGkjEFzXcssXsX6Iw7R5uLKOt/OKFN+tnxfyS4=",
"lastModified": 1721651093,
"narHash": "sha256-db/riM3Kq+QgGUqRxJHA4HYXJE31276hrUrDj4UhC2g=",
"owner": "folke",
"repo": "trouble.nvim",
"rev": "254145ffd528b98eb20be894338e2d5c93fa02c2",
"rev": "6efc446226679fda0547c0fd6a7892fd5f5b15d8",
"type": "github"
},
"original": {
@ -1776,11 +1760,11 @@
"plugin-which-key": {
"flake": false,
"locked": {
"lastModified": 1727856297,
"narHash": "sha256-crECQnWpptz1A/hOndHPEduK6MqWQH8kyf58h+4snHo=",
"lastModified": 1726684657,
"narHash": "sha256-P3Uugc+RPsRVD/kFCmHDow3PLeb2oXEbNX3WzoZ9xlw=",
"owner": "folke",
"repo": "which-key.nvim",
"rev": "8badb359f7ab8711e2575ef75dfe6fbbd87e4821",
"rev": "fb070344402cfc662299d9914f5546d840a22126",
"type": "github"
},
"original": {
@ -1818,7 +1802,6 @@
"nixpkgs": "nixpkgs",
"nmd": "nmd",
"plugin-alpha-nvim": "plugin-alpha-nvim",
"plugin-base16": "plugin-base16",
"plugin-bufdelete-nvim": "plugin-bufdelete-nvim",
"plugin-catppuccin": "plugin-catppuccin",
"plugin-ccc": "plugin-ccc",

View file

@ -349,11 +349,6 @@
};
# Themes
plugin-base16 = {
url = "github:rrethy/base16-nvim";
flake = false;
};
plugin-tokyonight = {
url = "github:folke/tokyonight.nvim";
flake = false;

View file

@ -1,9 +1,8 @@
{lib}: let
inherit (lib) isStringLike showOption showFiles getFiles mergeOneOption mergeEqualOption mkOptionType;
inherit (lib.strings) isString;
inherit (lib.types) anything attrsOf;
inherit (lib.nvim.types) anythingConcatLists;
inherit (builtins) typeOf isAttrs any head concatLists stringLength match;
inherit (builtins) typeOf isAttrs any head concatLists stringLength;
in {
# HACK: Does this break anything in our case?
# A modified version of the nixpkgs anything type that concatenates lists
@ -59,11 +58,4 @@ in {
check = value: stringLength value < 2;
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;
};
}

View file

@ -6,10 +6,10 @@
typesDag = import ./dag.nix {inherit lib;};
typesPlugin = import ./plugins.nix {inherit inputs lib;};
typesLanguage = import ./languages.nix {inherit lib;};
typesTypes = import ./types.nix {inherit lib;};
typesCustom = import ./custom.nix {inherit lib;};
in {
inherit (typesDag) dagOf;
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType;
inherit (typesLanguage) diagnostics mkGrammarOption;
inherit (typesTypes) anythingConcatLists char hexColor;
inherit (typesCustom) anythingConcatLists char;
}

View file

@ -3,75 +3,51 @@
lib,
...
}: let
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"];
};
inherit (lib.modules) mkIf;
cfg = config.vim;
in {
config = {
vim.keymaps = mkMerge [
(
mkIf cfg.disableArrows [
{
key = "<up>";
mode = ["n" "i"];
action = "<nop>";
noremap = false;
}
{
key = "<down>";
mode = ["n" "i"];
action = "<nop>";
noremap = false;
}
{
key = "<left>";
mode = ["n" "i"];
action = "<nop>";
noremap = false;
}
{
key = "<right>";
mode = ["n" "i"];
action = "<nop>";
noremap = false;
}
]
)
(
pipe cfg.maps
[
(mapAttrsToList (
oldMode: keybinds:
mapAttrsToList (
key: bind:
bind
// {
inherit key;
mode = legacyMapModes.${oldMode};
}
)
keybinds
))
flatten
]
)
];
vim.maps = {
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>" = {
action = "<nop>";
noremap = false;
};
"<down>" = {
action = "<nop>";
noremap = false;
};
"<left>" = {
action = "<nop>";
noremap = false;
};
"<right>" = {
action = "<nop>";
noremap = false;
};
};
};
};
}

View file

@ -1,97 +1,101 @@
{lib, ...}: let
inherit (lib.options) mkOption literalMD;
inherit (lib.types) either str listOf attrsOf nullOr submodule;
inherit (lib.options) mkOption;
inherit (lib.types) bool str attrsOf nullOr submodule;
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 =
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.";
};
action = mkOption {
type = str;
description = "The command to execute.";
};
lua = mkBool false ''
If true, `action` is considered to be lua code.
Thus, it will not be wrapped in `""`.
'';
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 {
mapOption = submodule {
options =
mapConfigOptions
// {
key = mkOption {
action = mkOption {
type = str;
description = "The key that triggers this keybind.";
description = "The action to execute.";
};
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.
lua = mkOption {
type = bool;
description = ''
If true, `action` is considered to be lua code.
Thus, it will not be wrapped in `""`.
'';
example = literalMD ''`["n" "v" "c"]` for normal, visual and command mode'';
default = false;
};
};
};
legacyMapOption = mode:
mapOptions = mode:
mkOption {
description = "Mappings for ${mode} mode";
type = attrsOf (submodule {
options = mapConfigOptions;
});
type = attrsOf mapOption;
default = {};
};
in {
options.vim = {
keymaps = mkOption {
type = listOf mapType;
description = "Custom keybindings.";
example = ''
vim.keymaps = [
{
key = "<leader>m";
mode = "n";
silent = true;
action = ":make<CR>";
}
{
key = "<leader>l";
mode = ["n" "x"];
silent = true;
action = "<cmd>cnext<CR>";
}
];
'';
maps = mkOption {
type = submodule {
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 = {};
};
description = ''
Custom keybindings for any mode.
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')";
For plain maps (e.g. just 'map' or 'remap') use `maps.normalVisualOp`.
'';
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";
example = ''
maps = {
normal."<leader>m" = {
silent = true;
action = "<cmd>make<CR>";
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR>
};
'';
};
};
}

View file

@ -20,8 +20,6 @@ in {
"neo-tree-nvim"
];
visuals.nvimWebDevicons.enable = true;
pluginRC.neo-tree = entryAnywhere ''
require("neo-tree").setup(${toLuaObject cfg.setupOpts})
'';

View file

@ -114,12 +114,12 @@ in {
(mkIf cfg.elixir-tools.enable {
vim.startPlugins = ["elixir-tools"];
vim.pluginRC.elixir-tools = entryAnywhere ''
local elixir = require("elixir")
local elixirls = require("elixir.elixirls")
local elixir-tools = require("elixir")
local elixirls = require("elixir-tools.elixirls")
-- disable imperative insstallations of various
-- elixir related tools installed by elixir-tools
elixir.setup {
elixir-tools.setup {
nextls = {
enable = false -- defaults to false
},

View file

@ -17,36 +17,29 @@
"ayu_dark"
"ayu_light"
"ayu_mirage"
"ayu"
"codedark"
"dracula"
"everforest"
"gruvbox"
"gruvbox_dark"
"gruvbox_light"
"gruvbox_material"
"horizon"
"iceberg_dark"
"iceberg_light"
"iceberg"
"jellybeans"
"material"
"modus_vivendi"
"molokai"
"moonfly"
"nightfly"
"nord"
"oceanicnext"
"onedark"
"onelight"
"palenight"
"papercolor_dark"
"papercolor_light"
"powerline_dark"
"powerline"
"seoul256"
"solarized_dark"
"solarized_light"
"tomorrow"
"wombat"
];
@ -231,7 +224,7 @@ in {
local buf_ft = vim.api.nvim_get_option_value('filetype', {})
-- List of buffer types to exclude
local excluded_buf_ft = {"toggleterm", "NvimTree", "neo-tree", "TelescopePrompt"}
local excluded_buf_ft = {"toggleterm", "NvimTree", "TelescopePrompt"}
-- Check if the current buffer type is in the excluded list
for _, excluded_type in ipairs(excluded_buf_ft) do

View file

@ -4,14 +4,7 @@
}: let
inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString warnIf;
inherit (lib.nvim.lua) toLuaObject;
in {
base16 = {
setup = {base16-colors, ...}: ''
-- Base16 theme
require('base16-colorscheme').setup(${toLuaObject base16-colors})
'';
};
onedark = {
setup = {style ? "dark", ...}: ''
-- OneDark theme
@ -27,7 +20,6 @@ in {
setup = {
style ? "night",
transparent,
...
}: ''
require('tokyonight').setup {
transparent = ${boolToString transparent};
@ -50,7 +42,6 @@ in {
setup = {
style ? "mocha",
transparent ? false,
...
}: ''
-- Catppuccin theme
require('catppuccin').setup {
@ -78,7 +69,7 @@ in {
notify = true, -- nvim-notify
which_key = true,
navic = {
enabled = true,
enabled = false,
custom_bg = "NONE", -- "lualine" will set background to mantle
},
},

View file

@ -4,51 +4,32 @@
...
}: let
inherit (lib.options) mkOption;
inherit (lib.attrsets) attrNames listToAttrs;
inherit (lib.strings) hasPrefix;
inherit (lib.attrsets) attrNames;
inherit (lib.types) bool lines enum;
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryBefore;
inherit (lib.nvim.types) hexColor;
cfg = config.vim.theme;
supportedThemes = import ./supported-themes.nix {
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 {
options.vim.theme = {
enable = mkOption {
type = bool;
description = "Enable theming";
};
name = mkOption {
type = enum (attrNames supportedThemes);
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.
'';
description = "Supported themes can be found in `supportedThemes.nix`";
};
base16-colors = base16Options;
style = mkOption {
type = enum supportedThemes.${cfg.name}.styles;
description = "Specific style for theme if it supports it";
};
transparent = mkOption {
type = bool;
default = false;
@ -66,7 +47,7 @@ in {
startPlugins = [cfg.name];
luaConfigRC.theme = entryBefore ["pluginConfigs"] ''
${cfg.extraConfig}
${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent base16-colors;}}
${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent;}}
'';
};
};

View file

@ -3,29 +3,42 @@
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
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 {
config = mkIf cfg.enable {
vim = {
startPlugins = ["nvim-surround"];
pluginRC.surround = entryAnywhere "require('nvim-surround').setup(${toLuaObject cfg.setupOpts})";
startPlugins = [
"nvim-surround"
];
utility.surround.setupOpts.keymaps = mkIf cfg.useVendoredKeybindings {
insert = "<C-g>z";
insert_line = "<C-g>Z";
normal = "gz";
normal_cur = "gZ";
normal_line = "gzz";
normal_cur_line = "gZZ";
visual = "gz";
visual_line = "gZ";
delete = "gzd";
change = "gzr";
change_line = "gZR";
pluginRC.surround = entryAnywhere ''
require('nvim-surround').setup()
'';
maps = {
insert = mkMerge [
(mkIf (mappings.insert != null) (mkSetBinding mappings.insert "<Plug>(nvim-surround-insert)"))
(mkIf (mappings.insertLine != null) (mkSetBinding mappings.insertLine "<Plug>(nvim-surround-insert-line)"))
];
normal = mkMerge [
(mkIf (mappings.normal != null) (mkSetBinding mappings.normal "<Plug>(nvim-surround-normal)"))
(mkIf (mappings.normalCur != null) (mkSetBinding mappings.normalCur "<Plug>(nvim-surround-normal-cur)"))
(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)"))
];
};
};
};

View file

@ -1,24 +1,90 @@
{lib, ...}: let
{
lib,
config,
...
}: let
inherit (lib.modules) mkIf mkDefault;
inherit (lib.options) mkOption;
inherit (lib.types) bool;
inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.types) bool nullOr str;
in {
options.vim.utility.surround = {
enable = mkOption {
type = bool;
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 {
type = bool;
default = true;
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;
});
};
}

View file

@ -4,14 +4,80 @@
...
}: let
inherit (builtins) map mapAttrs filter;
inherit (lib.attrsets) mapAttrsToList filterAttrs;
inherit (lib.options) mkOption;
inherit (lib.attrsets) mapAttrsToList filterAttrs getAttrs attrValues attrNames;
inherit (lib.strings) concatLines concatMapStringsSep;
inherit (lib.trivial) showWarnings;
inherit (lib.types) str nullOr;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.config) mkBool;
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 {
config = let
globalsScript =
@ -32,18 +98,38 @@ in {
mapResult = result: concatLines (map mkLuarcSection result);
};
getAction = keymap:
if keymap.lua
then mkLuaInline keymap.action
else keymap.action;
toLuaBindings = mode: maps:
map (value: ''
vim.keymap.set(${toLuaObject mode}, ${toLuaObject value.key}, ${toLuaObject value.action}, ${toLuaObject value.config})
'') (genMaps mode maps);
getOpts = keymap: {
inherit (keymap) desc silent nowait script expr unique noremap;
};
# I'm not sure if every one of these will work.
allmap = toLuaBindings "" config.vim.maps.normalVisualOp;
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;
toLuaKeymap = bind: "vim.keymap.set(${toLuaObject bind.mode}, ${toLuaObject bind.key}, ${toLuaObject (getAction bind)}, ${toLuaObject (getOpts bind)})";
keymaps = concatLines (map toLuaKeymap cfg.keymaps);
maps = [
nmap
imap
vmap
xmap
smap
cmap
omap
tmap
lmap
icmap
allmap
];
mappings = concatLines (map concatLines maps);
in {
vim = {
luaConfigRC = {
@ -54,7 +140,7 @@ in {
# Basic
pluginConfigs = entryAfter ["optionsScript"] pluginConfigs;
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
mappings = entryAfter ["extraPluginConfigs"] keymaps;
mappings = entryAfter ["extraPluginConfigs"] mappings;
};
builtLuaConfigRC = let