From d2d2c2a227b098ccfed989dafb0b8e53555a426b Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 28 Apr 2024 20:35:15 +0300 Subject: [PATCH 0001/1178] CI: remove docker builds --- .github/workflows/docker.yml | 50 ------------------------------------ 1 file changed, 50 deletions(-) delete mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 1edfb05c..00000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: "Publish Docker Image" -on: - workflow_dispatch: - push: - tags: ["v*"] - -jobs: - build-docker-image: - name: "Build Docker Image" - runs-on: ubuntu-latest - - permissions: - contents: read - packages: write - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Nix - uses: DeterminateSystems/nix-installer-action@main - - name: Magic Nix Cache - uses: DeterminateSystems/magic-nix-cache-action@main - - - name: Build Docker Image - run: nix build .#docker-nix --print-build-logs - - - name: Load & Tag Built Docker Image - run: | - docker load -i result && - docker tag neovim-flake:latest notashelf/neovim-flake:latest - - - name: Log into DockerHub - uses: docker/login-action@master - with: - username: notashelf - password: ${{ secrets.DOCKER_ACCESS_TOKEN }} - - - name: Push to DockerHub - run: docker push notashelf/neovim-flake:latest - - - name: Log into ghcr - uses: docker/login-action@master - with: - registry: "ghcr.io" - username: "${{ github.actor }}" - password: "${{ secrets.GITHUB_TOKEN }}" - - - name: Publish Docker Image (Github Packages) - run: docker push notashelf/neovim-flake:latest From a12a26e40598e3976e9ad6b1400e9077610b0bd8 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 28 Apr 2024 20:35:31 +0300 Subject: [PATCH 0002/1178] CI: use the correct path in pages --- .github/workflows/check-docs.yml | 2 +- .github/workflows/manual.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-docs.yml b/.github/workflows/check-docs.yml index 9a651962..18e6a2ef 100644 --- a/.github/workflows/check-docs.yml +++ b/.github/workflows/check-docs.yml @@ -48,4 +48,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: "${{ matrix.package }}" - path: result/share/doc/neovim-flake/ + path: result/share/doc/nvf diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml index 855ee9c4..34c11ffe 100644 --- a/.github/workflows/manual.yml +++ b/.github/workflows/manual.yml @@ -33,7 +33,7 @@ jobs: - name: Build run: | nix build '.#docs' - cp -r result/share/doc/neovim-flake public + cp -r result/share/doc/nvf public - name: Deploy uses: peaceiris/actions-gh-pages@v4 From 2a37873f8abc74ae4e8cc543c2d6805ca04d024c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 28 Apr 2024 20:41:54 +0300 Subject: [PATCH 0003/1178] docs: move maintenance notice to FAQ --- .github/README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/README.md b/.github/README.md index 7418d27d..c12f8b60 100644 --- a/.github/README.md +++ b/.github/README.md @@ -38,13 +38,6 @@
-> [!WARNING] -> Main branch is only updated for small, non-breaking changes. For the latest version of neovim-flake, please see -> [the list of branches](https://github.com/NotAShelf/neovim-flake/branches) or -> [open pull requests](https://github.com/NotAShelf/neovim-flake/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc). -> neovim-flake, at the time, is still being actively developed - and will continue to be so for the foreseeable -> future. - ---

@@ -147,6 +140,15 @@ consider a module addition. plugin configurations! Please see the documentation on how you may do this. +**Q**: Main branch is awfully silent, is the project dead? +
+**A**: No! Sometimes we branch out (e.g. v0.6) to avoid breaking userspace +and work in a separate branch until we make sure the new additions are +implemented in the most comfortable way available to the end user. If you have +not noticed any activity on the main branch, consider taking a look at the [list +of branches](https://github.com/NotAShelf/nvf/branches=) or the [list of open +pull requests](https://github.com/NotAShelf/nvf) + ## Credits ### Contributors @@ -180,7 +182,7 @@ recommend checking their work out. Following the [original neovim-flake](https://github.com/jordanisaacs/neovim-flake) **nvf** has been made available under the **MIT License**. However, all assets -are published under the [CC BY License]. +and documentation are published under the [CC BY License]. --- From 6e8bb14567a16b1a9250cc86ad62f1321cf4184d Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 28 Apr 2024 21:00:57 +0300 Subject: [PATCH 0004/1178] docs: fix alignment issues in README --- .github/README.md | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/README.md b/.github/README.md index c12f8b60..26fcdc55 100644 --- a/.github/README.md +++ b/.github/README.md @@ -1,9 +1,10 @@

nvf Logo +

-

❄️ nvf

+
-

+

Latest release @@ -22,7 +23,8 @@ Repo Size -

+

+

@@ -36,12 +38,18 @@ Nix code.

-
---

+[Get Started]: #get-started +[Documentation]: #documentation +[Help]: #help +[Contribute]: #contributing +[FAQ]: #faq +[Credits]: #credits + **[
 Get Started 
][Get Started]** **[
 Documentation 
][Documentation]** **[
 Help 
][Help]** @@ -51,13 +59,6 @@

-[Get Started]: #get-started -[Documentation]: #documentation -[Help]: #help -[Contribute]: #contributing -[FAQ]: #faq -[Credits]: #credits - --- ## Get Started @@ -106,13 +107,15 @@ featured configuration with `nix` language support by running: nix run github:notashelf/nvf#nix ``` -Please create an issue on the [issue tracker](../../../issues) if you find +[Issues]: https://github.com/NotAShelf/nvf/issues + +Please create an issue on the [issue tracker](issues) if you find the documentation lacking or confusing. I also appreciate any contributions to the documentation. ## Help -You can create an issue on the [issue tracker](../../../issues) to ask questions +You can create an issue on the [issue tracker](issues) to ask questions or report bugs. I am not yet on spaces like matrix or IRC, so please use the issue tracker for now. @@ -121,7 +124,7 @@ tracker for now. I am always looking for new ways to help improve this flake. If you would like to contribute, please read the [contributing guide](CONTRIBUTING.md) before submitting a pull request. You can also create an issue on the -[issue tracker](../../../issues) before submitting a pull request if you would +[issue tracker](issues) before submitting a pull request if you would like to discuss a feature or bug fix. ## FAQ @@ -130,8 +133,7 @@ like to discuss a feature or bug fix.
**A**: Maybe! It is not one of our goals to support each and every Neovim plugin, however, I am always open to new modules and plugin setup additions -to **nvf**. Use the [appropritate issue -template](https://github.com/NotAShelf/nvf/issues/new/choose) and I will +to **nvf**. Use the [appropritate issue template](issues/new/choose) and I will consider a module addition. **Q**: A plugin I need is not available in **nvf**. What to do? From 4056deb411191dd69d8b673106b579f25b17a4c3 Mon Sep 17 00:00:00 2001 From: ItsSorae <> Date: Sun, 28 Apr 2024 15:07:41 -0400 Subject: [PATCH 0005/1178] languages/typst: add typst language support --- configuration.nix | 1 + modules/plugins/languages/default.nix | 1 + modules/plugins/languages/typst.nix | 100 ++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 modules/plugins/languages/typst.nix diff --git a/configuration.nix b/configuration.nix index 95320467..b7d9330d 100644 --- a/configuration.nix +++ b/configuration.nix @@ -74,6 +74,7 @@ inputs: let terraform.enable = isMaximal; nim.enable = false; tailwind.enable = isMaximal; + typst.enable = isMaximal; clang = { enable = isMaximal; lsp.server = "clangd"; diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 08fda19d..8597b722 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -24,6 +24,7 @@ in { ./tailwind.nix ./terraform.nix ./ts.nix + ./typst.nix ./zig.nix ]; diff --git a/modules/plugins/languages/typst.nix b/modules/plugins/languages/typst.nix new file mode 100644 index 00000000..da63c54e --- /dev/null +++ b/modules/plugins/languages/typst.nix @@ -0,0 +1,100 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.types) enum either listOf package str; + inherit (lib.attrsets) attrNames; + inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.types) mkGrammarOption; + + cfg = config.vim.languages.typst; + + defaultFormat = "typstfmt"; + formats = { + typstfmt = { + package = pkgs.typstfmt; + nullConfig = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.typstfmt.with({ + command = "${cfg.format.package}/bin/typstfmt", + }) + ) + ''; + }; + # https://github.com/Enter-tainer/typstyle + typstyle = { + package = pkgs.typstyle; + nullConfig = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.typstfmt.with({ + command = "${cfg.format.package}/bin/typstyle", + }) + ) + ''; + }; + }; +in { + options.vim.languages.typst = { + enable = mkEnableOption "Typst language support"; + + treesitter = { + enable = mkEnableOption "Typst treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "typst"; + }; + + lsp = { + enable = mkEnableOption "Typst LSP support (typst-lsp)" // {default = config.vim.languages.enableLSP;}; + + package = mkOption { + description = "typst-lsp package, or the command to run as a list of strings"; + example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]''; + type = either package (listOf str); + default = pkgs.typst-lsp; + }; + }; + + format = { + enable = mkEnableOption "Typst document formatting" // {default = config.vim.languages.enableFormat;}; + + type = mkOption { + description = "Typst formatter to use"; + type = enum (attrNames formats); + default = defaultFormat; + }; + + package = mkOption { + description = "Typst formatter package"; + type = package; + default = formats.${cfg.format.type}.package; + }; + }; + }; + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.typst-lsp = '' + lspconfig.typst_lsp.setup { + capabilities = capabilities, + on_attach=default_on_attach, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${cfg.lsp.package}/bin/typst-lsp"}'' + }, + } + ''; + }) + ]); +} From ee240a1483f6fb643dcba0aa5169c4d9d3b112cb Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Sun, 28 Apr 2024 22:33:00 -0400 Subject: [PATCH 0006/1178] configuration: disable wakatime in maximal output --- configuration.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration.nix b/configuration.nix index 95320467..dfae458b 100644 --- a/configuration.nix +++ b/configuration.nix @@ -175,7 +175,7 @@ inputs: let utility = { ccc.enable = isMaximal; - vim-wakatime.enable = isMaximal; + vim-wakatime.enable = false; icon-picker.enable = isMaximal; surround.enable = isMaximal; diffview-nvim.enable = true; From 90ee038794637aecbee2556fc8c73f7c2c75844d Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Sun, 28 Apr 2024 22:08:28 -0400 Subject: [PATCH 0007/1178] docs: add entry for typst language support --- docs/release-notes/release-notes.md | 1 + docs/release-notes/rl-0.7.md | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 docs/release-notes/rl-0.7.md diff --git a/docs/release-notes/release-notes.md b/docs/release-notes/release-notes.md index ae115bfe..4f896aab 100644 --- a/docs/release-notes/release-notes.md +++ b/docs/release-notes/release-notes.md @@ -10,4 +10,5 @@ rl-0.3.md rl-0.4.md rl-0.5.md rl-0.6.md +rl-0.7.md ``` diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md new file mode 100644 index 00000000..28e47712 --- /dev/null +++ b/docs/release-notes/rl-0.7.md @@ -0,0 +1,9 @@ +# Release 0.7 {#sec-release-0.7} + +Release notes for release 0.7 + +## Changelog {#sec-release-0.7-changelog} + +[ItsSorae](https://github.com/ItsSorae): + +- Added typst language support with `typst-lsp` LSP and `typstfmt` as the default formatter. It can be enabled by setting `languages.typst` to `true`. From d5fde3f4453c68d51baaf402b4a2f70145a83ffa Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 1 May 2024 16:05:12 +0000 Subject: [PATCH 0008/1178] docs: wording --- docs/release-notes/rl-0.7.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 28e47712..83bf8cea 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -6,4 +6,5 @@ Release notes for release 0.7 [ItsSorae](https://github.com/ItsSorae): -- Added typst language support with `typst-lsp` LSP and `typstfmt` as the default formatter. It can be enabled by setting `languages.typst` to `true`. +- Added support for [typst](https://typst.app/) under `vim.languages.typst`. + This will enable the `typst-lsp` language server, and the `typstfmt` formatter. From 4d41469b3d3d774cc95dc48a36cc72570ce2878b Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 1 May 2024 18:49:47 +0000 Subject: [PATCH 0009/1178] nvf: let people pay me I initially removed the ability to fund me due to this project being a soft-fork of JordanIsaac's neovim-flake. However, the project has changed *enough* to justify it being a standalone and therefore unaffiliated project. With the number of commits and the time spent in mind, I am allowing funding again. --- .github/FUNDING.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..739d2d2c --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +github: NotAShelf +ko_fi: NotAShelf +liberapay: NotAShelf + From 32615fca69ffe5d4786fb425e15be1a8a1cda790 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 1 May 2024 18:51:50 +0000 Subject: [PATCH 0010/1178] docs: fix license URLs --- .github/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/README.md b/.github/README.md index 26fcdc55..7aa05675 100644 --- a/.github/README.md +++ b/.github/README.md @@ -182,9 +182,10 @@ recommend checking their work out. ## License -Following the [original neovim-flake](https://github.com/jordanisaacs/neovim-flake) -**nvf** has been made available under the **MIT License**. However, all assets -and documentation are published under the [CC BY License]. +Following the license of the [original neovim-flake](https://github.com/jordanisaacs/neovim-flake), +**nvf** has been made available under the [**MIT License**](LICENSE). However, all assets +and documentation are published under the +[**CC BY License**](https://github.com/NotAShelf/nvf/blob/main/.github/assets/LICENSE). --- From 4df41ae0d08178a22e4d9d29b2425d4ad8fe1583 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Sun, 28 Apr 2024 16:04:27 -0400 Subject: [PATCH 0011/1178] visuals/fidget: use submodule for notification group overrides --- modules/plugins/visuals/fidget/fidget.nix | 185 +++++++++++++++++++++- 1 file changed, 179 insertions(+), 6 deletions(-) diff --git a/modules/plugins/visuals/fidget/fidget.nix b/modules/plugins/visuals/fidget/fidget.nix index 481dfeb0..c5f4eb66 100644 --- a/modules/plugins/visuals/fidget/fidget.nix +++ b/modules/plugins/visuals/fidget/fidget.nix @@ -4,10 +4,9 @@ ... }: let inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule; - inherit (lib.options) mkEnableOption mkOption; - inherit (lib.attrsets) mapAttrs; + inherit (lib.options) mkEnableOption mkOption literalExpression; inherit (lib.strings) toUpper; - inherit (lib.types) int float bool str enum listOf attrsOf anything; + inherit (lib.types) int float bool str enum listOf attrsOf oneOf nullOr submodule; inherit (lib.nvim.types) mkPluginSetupOption luaInline; inherit (lib.generators) mkLuaInline; in { @@ -176,9 +175,183 @@ in { ''; }; overrides = mkOption { - description = "Override options from the default notification config"; - type = attrsOf (attrsOf anything); - default = {rust_analyzer = {name = "rust-analyzer";};}; + description = '' + Overrides the default configuration for a notification group defined + in [](#opt-vim.visuals.fidget-nvim.setupOpts.notification.configs). + + If any of the fields are null, the value from the default + configuration is used. + + If default configuration is not defined, the following defaults are used: + ```lua + { + name = "Notifications", + icon = "❰❰", + ttl = 5, + group_style = "Title", + icon_style = "Special", + annote_style = "Question", + debug_style = "Comment", + info_style = "Question", + warn_style = "WarningMsg", + error_style = "ErrorMsg", + debug_annote = "DEBUG", + info_annote = "INFO", + warn_annote = "WARN", + error_annote = "ERROR", + update_hook = function(item) + notification.set_content_key(item) + end, + } + ``` + ''; + type = attrsOf (submodule { + options = { + name = mkOption { + description = '' + Name of the group, displayed in the notification window. + Can be a string or a function that returns a string. + + If a function, it is invoked every render cycle with the items + list, useful for rendering animations and other dynamic content. + + ::: {.note} + If you're looking for detailed information into the function + signature, you can refer to the fidget API documentation available + [here](https://github.com/j-hui/fidget.nvim/blob/1ba38e4cbb24683973e00c2e36f53ae64da38ef5/doc/fidget-api.txt#L70-L77) + ::: + ''; + type = nullOr (oneOf [str luaInline]); + default = null; + }; + icon = mkOption { + description = '' + Icon of the group, displayed in the notification window. + Can be a string or a function that returns a string. + + If a function, it is invoked every render cycle with the items + list, useful for rendering animations and other dynamic content. + + ::: {.note} + If you're looking for detailed information into the function + signature, you can refer to the fidget API documentation available + [here](https://github.com/j-hui/fidget.nvim/blob/1ba38e4cbb24683973e00c2e36f53ae64da38ef5/doc/fidget-api.txt#L70-L77) + ::: + ''; + type = nullOr (oneOf [str luaInline]); + default = null; + }; + icon_on_left = mkOption { + description = "If true, icon is rendered on the left instead of right"; + type = nullOr bool; + default = null; + }; + annote_separator = mkOption { + description = "Separator between message from annote"; + type = nullOr str; + default = " "; + }; + ttl = mkOption { + description = "How long a notification item should exist"; + type = nullOr int; + default = 5; + }; + render_limit = mkOption { + description = "How many notification items to show at once"; + type = nullOr int; + default = null; + }; + group_style = mkOption { + description = "Style used to highlight group name"; + type = nullOr str; + default = "Title"; + }; + icon_style = mkOption { + description = "Style used to highlight icon, if null, use group_style"; + type = nullOr str; + default = null; + }; + annote_style = mkOption { + description = "Default style used to highlight item annotes"; + type = nullOr str; + default = "Question"; + }; + debug_style = mkOption { + description = "Style used to highlight debug item annotes"; + type = nullOr str; + default = null; + }; + info_style = mkOption { + description = "Style used to highlight info item annotes"; + type = nullOr str; + default = null; + }; + warn_style = mkOption { + description = "Style used to highlight warn item annotes"; + type = nullOr str; + default = null; + }; + error_style = mkOption { + description = "Style used to highlight error item annotes"; + type = nullOr str; + default = null; + }; + debug_annote = mkOption { + description = "Default annotation for debug items"; + type = nullOr str; + default = null; + }; + info_annote = mkOption { + description = "Default annotation for info items"; + type = nullOr str; + default = null; + }; + warn_annote = mkOption { + description = "Default annotation for warn items"; + type = nullOr str; + default = null; + }; + error_annote = mkOption { + description = "Default annotation for error items"; + type = nullOr str; + default = null; + }; + priority = mkOption { + description = "Order in which group should be displayed"; + type = nullOr int; + default = 50; + }; + skip_history = mkOption { + description = "Whether messages should be preserved in history"; + type = nullOr bool; + default = null; + }; + update_hook = mkOption { + description = '' + Called when an item is updated. + + If false, no action is taken. + If a function, it is invoked with the item being updated. + + ::: {.note} + If you're looking for detailed information into the function + signature, you can refer to the fidget API documentation available + [here](https://github.com/j-hui/fidget.nvim/blob/1ba38e4cbb24683973e00c2e36f53ae64da38ef5/doc/fidget-api.txt#L114) + ::: + ''; + type = nullOr (oneOf [bool luaInline]); + default = false; + }; + }; + }); + default = {}; + example = literalExpression '' + { + rust_analyzer = { + name = "Rust Analyzer"; + }; + } + ''; }; }; From e1edeb5189867154defcf88a07fdae410025d35b Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Mon, 29 Apr 2024 08:11:02 -0400 Subject: [PATCH 0012/1178] docs: entry for modified type in fidget display overrides --- docs/release-notes/rl-0.7.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 83bf8cea..33cf66dc 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -8,3 +8,8 @@ Release notes for release 0.7 - Added support for [typst](https://typst.app/) under `vim.languages.typst`. This will enable the `typst-lsp` language server, and the `typstfmt` formatter. + +[frothymarrow](https://github.com/frothymarrow): + +- Modified type for [](#opt-vim.visuals.fidget-nvim.setupOpts.progress.display.overrides) + from `anything` to a `submodule` for better type checking. From 5b982fafa07b449299ce9898f0f9a7a0f8b75bb4 Mon Sep 17 00:00:00 2001 From: raf Date: Fri, 3 May 2024 09:56:57 +0000 Subject: [PATCH 0013/1178] docs: fix missing header in README --- .github/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/README.md b/.github/README.md index 7aa05675..06c9eb7d 100644 --- a/.github/README.md +++ b/.github/README.md @@ -1,6 +1,7 @@
nvf Logo -

+
+

nvf

From ab2685579a918bb48c998ed57009436e7c9fd4e2 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 4 May 2024 13:27:50 +0300 Subject: [PATCH 0014/1178] flake/modules: alias `programs.nvf` to `programs.neovim-flake` I will deprecate it in a future date, but for now it is fine. --- flake/modules/home-manager.nix | 22 +++++++++++++--------- flake/modules/nixos.nix | 22 +++++++++++++--------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/flake/modules/home-manager.nix b/flake/modules/home-manager.nix index bcefcf1e..585f3ce3 100644 --- a/flake/modules/home-manager.nix +++ b/flake/modules/home-manager.nix @@ -6,12 +6,12 @@ packages: inputs: { ... }: let inherit (lib) maintainers; - inherit (lib.modules) mkIf; + inherit (lib.modules) mkIf mkAliasOptionModule; inherit (lib.lists) optional; inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.types) attrsOf anything bool; - cfg = config.programs.neovim-flake; + cfg = config.programs.nvf; inherit (import ../../configuration.nix inputs) neovimConfiguration; neovimConfigured = neovimConfiguration { @@ -19,22 +19,26 @@ packages: inputs: { modules = [cfg.settings]; }; in { + imports = [ + (mkAliasOptionModule ["programs" "neovim-flake"] ["programs" "nvf"]) + ]; + meta.maintainers = with maintainers; [NotAShelf]; - options.programs.neovim-flake = { - enable = mkEnableOption "neovim-flake, the extensible neovim configuration wrapper"; + options.programs.nvf = { + enable = mkEnableOption "nvf, the extensible neovim configuration wrapper"; enableManpages = mkOption { type = bool; default = false; - description = "Whether to enable manpages for neovim-flake."; + description = "Whether to enable manpages for nvf."; }; defaultEditor = mkOption { type = bool; default = false; description = '' - Whether to set `neovim-flake` as the default editor. + Whether to set `nvf` as the default editor. This will set the `EDITOR` environment variable as `nvim` if set to true. @@ -46,14 +50,14 @@ in { visible = false; readOnly = true; description = '' - The built neovim-flake package, wrapped with the user's configuration. + The built nvf package, wrapped with the user's configuration. ''; }; settings = mkOption { type = attrsOf anything; default = {}; - description = "Attribute set of neovim-flake preferences."; + description = "Attribute set of nvf preferences."; example = literalExpression '' { vim.viAlias = false; @@ -75,7 +79,7 @@ in { }; config = mkIf cfg.enable { - programs.neovim-flake.finalPackage = neovimConfigured.neovim; + programs.nvf.finalPackage = neovimConfigured.neovim; home = { sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";}; diff --git a/flake/modules/nixos.nix b/flake/modules/nixos.nix index de234c73..3a1bf766 100644 --- a/flake/modules/nixos.nix +++ b/flake/modules/nixos.nix @@ -6,12 +6,12 @@ packages: inputs: { ... }: let inherit (lib) maintainers; - inherit (lib.modules) mkIf mkOverride; + inherit (lib.modules) mkIf mkOverride mkAliasOptionModule; inherit (lib.lists) optional; inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.types) attrsOf anything bool; - cfg = config.programs.neovim-flake; + cfg = config.programs.nvf; inherit (import ../../configuration.nix inputs) neovimConfiguration; neovimConfigured = neovimConfiguration { @@ -19,22 +19,26 @@ packages: inputs: { modules = [cfg.settings]; }; in { + imports = [ + (mkAliasOptionModule ["programs" "neovim-flake"] ["programs" "nvf"]) + ]; + meta.maintainers = with maintainers; [NotAShelf]; - options.programs.neovim-flake = { - enable = mkEnableOption "neovim-flake, the extensible neovim configuration wrapper"; + options.programs.nvf = { + enable = mkEnableOption "nvf, the extensible neovim configuration wrapper"; enableManpages = mkOption { type = bool; default = false; - description = "Whether to enable manpages for neovim-flake."; + description = "Whether to enable manpages for nvf."; }; defaultEditor = mkOption { type = bool; default = false; description = '' - Whether to set `neovim-flake` as the default editor. + Whether to set `nvf` as the default editor. This will set the `EDITOR` environment variable as `nvim` if set to true. @@ -46,14 +50,14 @@ in { visible = false; readOnly = true; description = '' - The built neovim-flake package, wrapped with the user's configuration. + The built nvf package, wrapped with the user's configuration. ''; }; settings = mkOption { type = attrsOf anything; default = {}; - description = "Attribute set of neovim-flake preferences."; + description = "Attribute set of nvf preferences."; example = literalExpression '' { vim.viAlias = false; @@ -75,7 +79,7 @@ in { }; config = mkIf cfg.enable { - programs.neovim-flake.finalPackage = neovimConfigured.neovim; + programs.nvf.finalPackage = neovimConfigured.neovim; environment = { variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim"); From 2c375130122033c8ffb9a3bed1a333b68e92d8af Mon Sep 17 00:00:00 2001 From: Pei Yang Ching Date: Sun, 5 May 2024 02:10:14 +0200 Subject: [PATCH 0015/1178] colorizer: fix nonsense options --- modules/plugins/ui/colorizer/colorizer.nix | 118 ++++++--------------- modules/plugins/ui/colorizer/config.nix | 2 +- 2 files changed, 35 insertions(+), 85 deletions(-) diff --git a/modules/plugins/ui/colorizer/colorizer.nix b/modules/plugins/ui/colorizer/colorizer.nix index 364abb99..bbbad37e 100644 --- a/modules/plugins/ui/colorizer/colorizer.nix +++ b/modules/plugins/ui/colorizer/colorizer.nix @@ -4,100 +4,50 @@ ... }: let inherit (lib.options) mkOption mkEnableOption; - inherit (lib.types) attrsOf attrs bool enum; + inherit (lib.types) attrsOf enum nullOr submodule; inherit (lib.modules) mkRenamedOptionModule; - inherit (lib.nvim.types) mkPluginSetupOption; + inherit (lib.nvim.config) mkBool; + + settingSubmodule = submodule { + options = { + RGB = mkBool true "Colorize #RGB hex codes"; + RRGGBB = mkBool true "Colorize #RRGGBB hex codes"; + names = mkBool true ''Colorize "Name" codes like Blue''; + RRGGBBAA = mkBool false "Colorize #RRGGBBAA hex codes"; + rgb_fn = mkBool false "Colorize CSS rgb() and rgba() functions"; + hsl_fn = mkBool false "Colorize CSS hsl() and hsla() functions"; + css = mkBool false "Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB"; + css_fn = mkBool false "Enable all CSS *functions*: rgb_fn, hsl_fn"; + mode = mkOption { + description = "Set the display mode"; + type = nullOr (enum ["foreground" "background"]); + default = null; + }; + }; + }; in { imports = [ - (mkRenamedOptionModule ["vim" "ui" "colorizer" "options"] ["vim" "ui" "colorizer" "setupOpts" "user_default_options"]) + (mkRenamedOptionModule ["vim" "ui" "colorizer" "options"] ["vim" "ui" "colorizer" "setupOpts" "defaultOptions"]) (mkRenamedOptionModule ["vim" "ui" "colorizer" "filetypes"] ["vim" "ui" "colorizer" "setupOpts" "filetypes"]) ]; options.vim.ui.colorizer = { enable = mkEnableOption "color highlighting [nvim-colorizer.lua]"; - setupOpts = mkPluginSetupOption "nvim-colorizer" { - filetypes = mkOption { - type = attrsOf attrs; - default = { - css = {}; - scss = {}; - }; - description = "Filetypes to highlight on"; - }; + defaultOptions = mkOption { + description = '' + Default options that apply to all filetypes. Filetype specific settings from + [filetypeSettings](#opt-vim.ui.colorizer.filetypeSettings) take precedence. + ''; + default = {}; + type = settingSubmodule; + }; - user_default_options = { - rgb = mkOption { - type = bool; - default = true; - description = "#RGB hex codes"; - }; - - rrggbb = mkOption { - type = bool; - default = true; - description = "#RRGGBB hex codes"; - }; - - names = mkOption { - type = bool; - default = true; - description = ''"Name" codes such as "Blue"''; - }; - - rgb_fn = mkOption { - type = bool; - default = false; - description = "CSS rgb() and rgba() functions"; - }; - - rrggbbaa = mkOption { - type = bool; - default = false; - description = "#RRGGBBAA hex codes"; - }; - - hsl_fn = mkOption { - type = bool; - default = false; - description = "CSS hsl() and hsla() functions"; - }; - - css = mkOption { - type = bool; - default = false; - description = "Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB"; - }; - - css_fn = mkOption { - type = bool; - default = false; - description = "Enable all CSS *functions*: rgb_fn, hsl_fn"; - }; - - mode = mkOption { - type = enum ["foreground" "background"]; - default = "background"; - description = "Set the display mode"; - }; - - tailwind = mkOption { - type = bool; - default = false; - description = "Enable tailwind colors"; - }; - - sass = mkOption { - type = bool; - default = false; - description = "Enable sass colors"; - }; - - alwaysUpdate = mkOption { - type = bool; - default = false; - description = "Update color values even if buffer is not focused, like when using cmp_menu, cmp_docs"; - }; + filetypeOptions = mkOption { + description = "Filetype specific settings"; + default = {}; + type = submodule { + freeformType = attrsOf settingSubmodule; }; }; }; diff --git a/modules/plugins/ui/colorizer/config.nix b/modules/plugins/ui/colorizer/config.nix index 1ff45f6b..d96920d7 100644 --- a/modules/plugins/ui/colorizer/config.nix +++ b/modules/plugins/ui/colorizer/config.nix @@ -15,7 +15,7 @@ in { ]; vim.luaConfigRC.colorizer = entryAnywhere '' - require('colorizer').setup(${toLuaObject cfg.setupOpts}) + require('colorizer').setup(${toLuaObject cfg.filetypeOptions}, ${toLuaObject cfg.defaultOptions}) ''; }; } From 3ad560ea30c5975d0f582622ccd2f5f2605af7e8 Mon Sep 17 00:00:00 2001 From: Pei Yang Ching Date: Thu, 2 May 2024 12:37:44 +0200 Subject: [PATCH 0016/1178] treesitter: fix ts context keybinds --- modules/plugins/treesitter/config.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/plugins/treesitter/config.nix b/modules/plugins/treesitter/config.nix index 61bfefe7..6bee0a22 100644 --- a/modules/plugins/treesitter/config.nix +++ b/modules/plugins/treesitter/config.nix @@ -30,9 +30,9 @@ in { normal = mkSetBinding mappings.incrementalSelection.init ":lua require('nvim-treesitter.incremental_selection').init_selection()"; visualOnly = mkMerge [ - (mkSetBinding mappings.incrementalSelection.incrementByNode ":lua require('nvim-treesitter.incremental_selection').node_incremental()") - (mkSetBinding mappings.incrementalSelection.incrementByScope ":lua require('nvim-treesitter.incremental_selection').scope_incremental()") - (mkSetBinding mappings.incrementalSelection.decrementByNode ":lua require('nvim-treesitter.incremental_selection').node_decremental()") + (mkSetBinding mappings.incrementalSelection.incrementByNode "lua require('nvim-treesitter.incremental_selection').node_incremental()") + (mkSetBinding mappings.incrementalSelection.incrementByScope "lua require('nvim-treesitter.incremental_selection').scope_incremental()") + (mkSetBinding mappings.incrementalSelection.decrementByNode "lua require('nvim-treesitter.incremental_selection').node_decremental()") ]; }; From 666de6a5bef6ede8bf93e459b1a2b7cb4715befa Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Thu, 2 May 2024 19:41:44 +0200 Subject: [PATCH 0017/1178] docs: update changelog --- docs/release-notes/rl-0.7.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 33cf66dc..ab6f9da8 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -13,3 +13,7 @@ Release notes for release 0.7 - Modified type for [](#opt-vim.visuals.fidget-nvim.setupOpts.progress.display.overrides) from `anything` to a `submodule` for better type checking. + +[horriblename](https://github.com/horriblename) + +- Fix broken treesitter-context keybinds in visual mode From 9fe96ce01061117e9f500b5e51bd847b36805ded Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Mon, 6 May 2024 08:46:04 -0400 Subject: [PATCH 0018/1178] utility/telescope: remove duplicate telescope module --- modules/utility/telescope/telescope.nix | 53 ------------------------- 1 file changed, 53 deletions(-) delete mode 100644 modules/utility/telescope/telescope.nix diff --git a/modules/utility/telescope/telescope.nix b/modules/utility/telescope/telescope.nix deleted file mode 100644 index 9cfd0926..00000000 --- a/modules/utility/telescope/telescope.nix +++ /dev/null @@ -1,53 +0,0 @@ -{ - pkgs, - lib, - ... -}: let - inherit (lib) mkMappingOption mkEnableOption mkOption types; -in { - options.vim.telescope = { - mappings = { - findProjects = mkMappingOption "Find files [Telescope]" "fp"; - - findFiles = mkMappingOption "Find files [Telescope]" "ff"; - liveGrep = mkMappingOption "Live grep [Telescope]" "fg"; - buffers = mkMappingOption "Buffers [Telescope]" "fb"; - helpTags = mkMappingOption "Help tags [Telescope]" "fh"; - open = mkMappingOption "Open [Telescope]" "ft"; - - gitCommits = mkMappingOption "Git commits [Telescope]" "fvcw"; - gitBufferCommits = mkMappingOption "Git buffer commits [Telescope]" "fvcb"; - gitBranches = mkMappingOption "Git branches [Telescope]" "fvb"; - gitStatus = mkMappingOption "Git status [Telescope]" "fvs"; - gitStash = mkMappingOption "Git stash [Telescope]" "fvx"; - - lspDocumentSymbols = mkMappingOption "LSP Document Symbols [Telescope]" "flsb"; - lspWorkspaceSymbols = mkMappingOption "LSP Workspace Symbols [Telescope]" "flsw"; - lspReferences = mkMappingOption "LSP References [Telescope]" "flr"; - lspImplementations = mkMappingOption "LSP Implementations [Telescope]" "fli"; - lspDefinitions = mkMappingOption "LSP Definitions [Telescope]" "flD"; - lspTypeDefinitions = mkMappingOption "LSP Type Definitions [Telescope]" "flt"; - diagnostics = mkMappingOption "Diagnostics [Telescope]" "fld"; - - treesitter = mkMappingOption "Treesitter [Telescope]" "fs"; - }; - - enable = mkEnableOption "telescope.nvim: multi-purpose search and picker utility"; - - vimgrep_arguments = mkOption { - description = "Arguments to use for the grep command"; - type = types.listOf types.str; - default = [ - "${pkgs.ripgrep}/bin/rg" - "--color=never" - "--no-heading" - "--with-filename" - "--line-number" - "--column" - "--smart-case" - "--hidden" - "--no-ignore" - ]; - }; - }; -} From 83583e9b6477ec92bceba56fa3ef7f4f325c33e9 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Mon, 6 May 2024 16:05:43 -0400 Subject: [PATCH 0019/1178] plugins/lsp: filter out null mappings --- modules/plugins/lsp/config.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/plugins/lsp/config.nix b/modules/plugins/lsp/config.nix index ba93b287..d91a4fb7 100644 --- a/modules/plugins/lsp/config.nix +++ b/modules/plugins/lsp/config.nix @@ -16,7 +16,10 @@ mappingDefinitions = self.options.vim.lsp.mappings; mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; - mkBinding = binding: action: "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', 'lua ${action}', {noremap=true, silent=true, desc='${binding.description}'})"; + mkBinding = binding: action: + if binding.value != null + then "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', 'lua ${action}', {noremap=true, silent=true, desc='${binding.description}'})" + else ""; in { config = mkIf cfg.enable { vim = { From d06ff3d7db7f92d64083207a4ff63ff3de2d7a2c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 6 May 2024 22:22:43 +0300 Subject: [PATCH 0020/1178] languages/markdown: move to standalone file; add deno formatter --- configuration.nix | 8 ++-- modules/plugins/languages/default.nix | 2 +- .../languages/{markdown => }/markdown.nix | 40 ++++++++++++++++++- modules/plugins/languages/markdown/config.nix | 40 ------------------- .../plugins/languages/markdown/default.nix | 6 --- 5 files changed, 45 insertions(+), 51 deletions(-) rename modules/plugins/languages/{markdown => }/markdown.nix (62%) delete mode 100644 modules/plugins/languages/markdown/config.nix delete mode 100644 modules/plugins/languages/markdown/default.nix diff --git a/configuration.nix b/configuration.nix index 421fa8c4..916f2bb3 100644 --- a/configuration.nix +++ b/configuration.nix @@ -58,7 +58,12 @@ inputs: let enableTreesitter = true; enableExtraDiagnostics = true; + nim.enable = false; + elixir.enable = false; + nix.enable = true; + markdown.enable = true; + html.enable = isMaximal; css.enable = isMaximal; sql.enable = isMaximal; @@ -69,10 +74,7 @@ inputs: let zig.enable = isMaximal; python.enable = isMaximal; dart.enable = isMaximal; - elixir.enable = isMaximal; bash.enable = isMaximal; - terraform.enable = isMaximal; - nim.enable = false; tailwind.enable = isMaximal; typst.enable = isMaximal; clang = { diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 8597b722..3a33ad06 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -5,7 +5,6 @@ in { ./bash ./dart ./elixir - ./markdown ./tidal ./clang.nix @@ -14,6 +13,7 @@ in { ./html.nix ./java.nix ./lua.nix + ./markdown.nix ./nim.nix ./nix.nix ./php.nix diff --git a/modules/plugins/languages/markdown/markdown.nix b/modules/plugins/languages/markdown.nix similarity index 62% rename from modules/plugins/languages/markdown/markdown.nix rename to modules/plugins/languages/markdown.nix index a58be2a9..7fcc364c 100644 --- a/modules/plugins/languages/markdown/markdown.nix +++ b/modules/plugins/languages/markdown.nix @@ -4,7 +4,7 @@ lib, ... }: let - inherit (builtins) attrNames; + inherit (builtins) attrNames concatLists; inherit (lib.options) mkEnableOption mkOption; inherit (lib.lists) isList; inherit (lib.types) bool enum either package listOf str; @@ -29,6 +29,22 @@ ''; }; }; + + defaultFormat = "denofmt"; + formats = { + denofmt = { + package = pkgs.deno; + nullConfig = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.deno_fmt.with({ + filetypes = ${concatLists cfg.format.extraFiletypes ["markdown"]}, + command = "${cfg.format.package}/bin/deno", + }) + ) + ''; + }; + }; in { options.vim.languages.markdown = { enable = mkEnableOption "Markdown markup language support"; @@ -59,5 +75,27 @@ in { default = servers.${cfg.lsp.server}.package; }; }; + + format = { + enable = mkEnableOption "Markdown formatting" // {default = config.vim.languages.enableFormat;}; + + type = mkOption { + description = "Markdown formatter to use"; + type = enum (attrNames formats); + default = defaultFormat; + }; + + package = mkOption { + description = "Markdown formatter package"; + type = package; + default = formats.${cfg.format.type}.package; + }; + + extraFiletypes = mkOption { + description = "Extra filetypes to format with the Markdown formatter"; + type = listOf str; + default = []; + }; + }; }; } diff --git a/modules/plugins/languages/markdown/config.nix b/modules/plugins/languages/markdown/config.nix deleted file mode 100644 index ccc88368..00000000 --- a/modules/plugins/languages/markdown/config.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: let - inherit (lib.nvim.lua) expToLua; - inherit (lib.modules) mkIf mkMerge; - inherit (lib.lists) isList; - - cfg = config.vim.languages.markdown; - servers = { - marksman = { - package = pkgs.marksman; - lspConfig = '' - lspconfig.marksman.setup{ - capabilities = capabilities; - on_attach = default_on_attach; - cmd = ${ - if isList cfg.lsp.package - then expToLua cfg.lsp.package - else ''{"${cfg.lsp.package}/bin/marksman", "server"}'' - }, - } - ''; - }; - }; -in { - config = mkIf cfg.enable (mkMerge [ - (mkIf cfg.treesitter.enable { - vim.treesitter.enable = true; - vim.treesitter.grammars = [cfg.treesitter.mdPackage cfg.treesitter.mdInlinePackage]; - }) - - (mkIf cfg.lsp.enable { - vim.lsp.lspconfig.enable = true; - vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig; - }) - ]); -} diff --git a/modules/plugins/languages/markdown/default.nix b/modules/plugins/languages/markdown/default.nix deleted file mode 100644 index 38345893..00000000 --- a/modules/plugins/languages/markdown/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{...}: { - imports = [ - ./config.nix - ./markdown.nix - ]; -} From 1847b9f1bf65bbed9af4381c38f1b3cd9752868b Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 6 May 2024 22:30:06 +0300 Subject: [PATCH 0021/1178] languages/tidal: remove --- configuration.nix | 6 +- docs/release-notes/rl-0.7.md | 13 +- flake.lock | 160 +------------------- flake.nix | 9 +- flake/apps.nix | 28 ++-- flake/legacyPackages.nix | 1 - flake/overlays.nix | 2 - flake/packages.nix | 86 +++++------ modules/plugins/languages/default.nix | 1 - modules/plugins/languages/tidal/config.nix | 23 --- modules/plugins/languages/tidal/default.nix | 6 - modules/plugins/languages/tidal/tidal.nix | 24 --- 12 files changed, 63 insertions(+), 296 deletions(-) delete mode 100644 modules/plugins/languages/tidal/config.nix delete mode 100644 modules/plugins/languages/tidal/default.nix delete mode 100644 modules/plugins/languages/tidal/tidal.nix diff --git a/configuration.nix b/configuration.nix index 916f2bb3..5c0095b5 100644 --- a/configuration.nix +++ b/configuration.nix @@ -15,10 +15,6 @@ inputs: let configuration.imports = modules; }; - tidalConfig = { - config.vim.languages.tidal.enable = true; - }; - mainConfig = isMaximal: { config.vim = { viAlias = true; @@ -254,5 +250,5 @@ inputs: let }; }; in { - inherit neovimConfiguration mainConfig tidalConfig; + inherit neovimConfiguration mainConfig; } diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index ab6f9da8..b5047a4b 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -6,14 +6,21 @@ Release notes for release 0.7 [ItsSorae](https://github.com/ItsSorae): -- Added support for [typst](https://typst.app/) under `vim.languages.typst`. - This will enable the `typst-lsp` language server, and the `typstfmt` formatter. +- Added support for [typst](https://typst.app/) under `vim.languages.typst` + This will enable the `typst-lsp` language server, and the `typstfmt` formatter [frothymarrow](https://github.com/frothymarrow): - Modified type for [](#opt-vim.visuals.fidget-nvim.setupOpts.progress.display.overrides) - from `anything` to a `submodule` for better type checking. + from `anything` to a `submodule` for better type checking [horriblename](https://github.com/horriblename) - Fix broken treesitter-context keybinds in visual mode + +[NotAShelf](https://github.com/notashelf) + +- Add `deno fmt` as the default Markdown formatter. This will be enabled + automatically if you have autoformatting enabled, but can be disabled manually + if you choose to. +- Remove vim-tidal and friends diff --git a/flake.lock b/flake.lock index f590525a..e7060017 100644 --- a/flake.lock +++ b/flake.lock @@ -1,22 +1,5 @@ { "nodes": { - "dirt-samples-src": { - "flake": false, - "locked": { - "lastModified": 1667426233, - "narHash": "sha256-Zl2bi9QofcrhU63eMtg+R6lhV9ExQS/0XNTJ+oq65Uo=", - "owner": "tidalcycles", - "repo": "dirt-samples", - "rev": "92f2145e661b397e62ca0ff3965819e7c7db0dad", - "type": "github" - }, - "original": { - "owner": "tidalcycles", - "ref": "master", - "repo": "dirt-samples", - "type": "github" - } - }, "flake-compat": { "flake": false, "locked": { @@ -180,22 +163,6 @@ } }, "nixpkgs_3": { - "locked": { - "lastModified": 1693844670, - "narHash": "sha256-t69F2nBB8DNQUWHD809oJZJVE+23XBrth4QZuVd6IE0=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "3c15feef7770eb5500a4b8792623e2d6f598c9c1", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_4": { "locked": { "lastModified": 1702350026, "narHash": "sha256-A+GNZFZdfl4JdDphYKBJ5Ef1HOiFsP18vQe9mqjmUis=", @@ -1906,7 +1873,6 @@ "plugin-which-key": "plugin-which-key", "rnix-lsp": "rnix-lsp", "systems": "systems_2", - "tidalcycles": "tidalcycles", "zig": "zig" } }, @@ -1935,23 +1901,6 @@ "type": "github" } }, - "superdirt-src": { - "flake": false, - "locked": { - "lastModified": 1611740180, - "narHash": "sha256-GtnqZeMFqFkVhgx2Exu0wY687cHa7mNnVCgjQd6fiIA=", - "owner": "musikinformatik", - "repo": "superdirt", - "rev": "7abb62e89649daa1232b9cbd6427241868abd30e", - "type": "github" - }, - "original": { - "owner": "musikinformatik", - "ref": "master", - "repo": "superdirt", - "type": "github" - } - }, "systems": { "locked": { "lastModified": 1681028828, @@ -1982,62 +1931,6 @@ "type": "github" } }, - "systems_3": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "tidal-src": { - "flake": false, - "locked": { - "lastModified": 1654350756, - "narHash": "sha256-tONM5SYYBca0orTLH1EUOilSC1FCluWrFt8AetUx+YQ=", - "owner": "tidalcycles", - "repo": "tidal", - "rev": "fda9c1ecb3722698935245e5409ef8ccdfca16c8", - "type": "github" - }, - "original": { - "owner": "tidalcycles", - "ref": "main", - "repo": "tidal", - "type": "github" - } - }, - "tidalcycles": { - "inputs": { - "dirt-samples-src": "dirt-samples-src", - "nixpkgs": "nixpkgs_3", - "superdirt-src": "superdirt-src", - "tidal-src": "tidal-src", - "utils": "utils_2", - "vim-tidal-src": "vim-tidal-src", - "vowel-src": "vowel-src" - }, - "locked": { - "lastModified": 1694087816, - "narHash": "sha256-GMV5ONQhLwa6xRYhZkmwc2W2jbjAfHfB/OR9vR0+PFA=", - "owner": "mitchmindtree", - "repo": "tidalcycles.nix", - "rev": "1b1c4df5303e07930d23e8361ab8253ebec0c7bb", - "type": "github" - }, - "original": { - "owner": "mitchmindtree", - "repo": "tidalcycles.nix", - "type": "github" - } - }, "utils": { "locked": { "lastModified": 1656928814, @@ -2053,62 +1946,11 @@ "type": "github" } }, - "utils_2": { - "inputs": { - "systems": "systems_3" - }, - "locked": { - "lastModified": 1692799911, - "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "vim-tidal-src": { - "flake": false, - "locked": { - "lastModified": 1685703852, - "narHash": "sha256-8gyk17YLeKpLpz3LRtxiwbpsIbZka9bb63nK5/9IUoA=", - "owner": "tidalcycles", - "repo": "vim-tidal", - "rev": "e440fe5bdfe07f805e21e6872099685d38e8b761", - "type": "github" - }, - "original": { - "owner": "tidalcycles", - "repo": "vim-tidal", - "type": "github" - } - }, - "vowel-src": { - "flake": false, - "locked": { - "lastModified": 1641306144, - "narHash": "sha256-zfF6cvAGDNYWYsE8dOIo38b+dIymd17Pexg0HiPFbxM=", - "owner": "supercollider-quarks", - "repo": "vowel", - "rev": "ab59caa870201ecf2604b3efdd2196e21a8b5446", - "type": "github" - }, - "original": { - "owner": "supercollider-quarks", - "ref": "master", - "repo": "vowel", - "type": "github" - } - }, "zig": { "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_4" + "nixpkgs": "nixpkgs_3" }, "locked": { "lastModified": 1713960597, diff --git a/flake.nix b/flake.nix index e63f7ca6..3425addc 100644 --- a/flake.nix +++ b/flake.nix @@ -76,6 +76,7 @@ # Flake inputs inputs = { + ## Basic Inputs nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; flake-utils.url = "github:numtide/flake-utils"; @@ -98,13 +99,7 @@ inputs.flake-utils.follows = "flake-utils"; }; - ### Plugins - # Tidal cycles - tidalcycles = { - url = "github:mitchmindtree/tidalcycles.nix"; - inputs.vim-tidal-src.url = "github:tidalcycles/vim-tidal"; - }; - + ## Plugins # LSP plugins plugin-nvim-lspconfig = { url = "github:neovim/nvim-lspconfig"; diff --git a/flake/apps.nix b/flake/apps.nix index 6b53adf9..583e297e 100644 --- a/flake/apps.nix +++ b/flake/apps.nix @@ -1,21 +1,11 @@ -{lib, ...}: { - perSystem = { - system, - config, - ... - }: { - apps = - { - nix.program = lib.getExe config.packages.nix; - maximal.program = lib.getExe config.packages.maximal; - default = config.apps.nix; - } - // ( - if !(builtins.elem system ["aarch64-darwin" "x86_64-darwin"]) - then { - tidal.program = lib.getExe config.packages.tidal; - } - else {} - ); +{lib, ...}: let + inherit (lib.meta) getExe; +in { + perSystem = {config, ...}: { + apps = { + nix.program = getExe config.packages.nix; + maximal.program = getExe config.packages.maximal; + default = config.apps.nix; + }; }; } diff --git a/flake/legacyPackages.nix b/flake/legacyPackages.nix index d6fb73c7..389ca0ce 100644 --- a/flake/legacyPackages.nix +++ b/flake/legacyPackages.nix @@ -7,7 +7,6 @@ legacyPackages = import inputs.nixpkgs { inherit system; overlays = [ - inputs.tidalcycles.overlays.default inputs.self.overlays.default (_: _: { rnix-lsp = inputs'.rnix-lsp.defaultPackage; diff --git a/flake/overlays.nix b/flake/overlays.nix index c73f2c0b..3c5434d6 100644 --- a/flake/overlays.nix +++ b/flake/overlays.nix @@ -9,13 +9,11 @@ nixConfig = mainConfig false; maximalConfig = mainConfig true; - tidalConfig = {config.vim.tidal.enable = true;}; in { flake.overlays.default = _final: prev: { inherit neovimConfiguration; neovim-nix = buildPkg prev [nixConfig]; neovim-maximal = buildPkg prev [maximalConfig]; - neovim-tidal = buildPkg prev [tidalConfig]; devPkg = buildPkg pkgs [nixConfig {config.vim.languages.html.enable = pkgs.lib.mkForce true;}]; }; } diff --git a/flake/packages.nix b/flake/packages.nix index eb6c9461..3724905a 100644 --- a/flake/packages.nix +++ b/flake/packages.nix @@ -7,56 +7,50 @@ }: let docs = import ../docs {inherit pkgs inputs;}; in { - packages = - { - # Documentation - docs = docs.manual.html; - docs-html = docs.manual.html; - docs-manpages = docs.manPages; - docs-json = docs.options.json; + packages = { + # Documentation + docs = docs.manual.html; + docs-html = docs.manual.html; + docs-manpages = docs.manPages; + docs-json = docs.options.json; - # Build and open the built manual in your system browser - docs-html-wrapped = pkgs.writeScriptBin "docs-html-wrapped" '' - #!${pkgs.stdenv.shell} - # use xdg-open to open the docs in the browser - ${pkgs.xdg_utils}/bin/xdg-open ${docs.manual.html} - ''; + # Build and open the built manual in your system browser + docs-html-wrapped = pkgs.writeScriptBin "docs-html-wrapped" '' + #!${pkgs.stdenv.shell} + # use xdg-open to open the docs in the browser + ${pkgs.xdg_utils}/bin/xdg-open ${docs.manual.html} + ''; - # Exposed neovim configurations - nix = config.legacyPackages.neovim-nix; - maximal = config.legacyPackages.neovim-maximal; - default = config.legacyPackages.neovim-nix; + # Exposed neovim configurations + nix = config.legacyPackages.neovim-nix; + maximal = config.legacyPackages.neovim-maximal; + default = config.legacyPackages.neovim-nix; - # Published docker images - docker-nix = let - inherit (pkgs) bash gitFull buildEnv dockerTools; - inherit (config.legacyPackages) neovim-nix; - in - dockerTools.buildImage { - name = "nvf"; - tag = "latest"; + # Published docker images + docker-nix = let + inherit (pkgs) bash gitFull buildEnv dockerTools; + inherit (config.legacyPackages) neovim-nix; + in + dockerTools.buildImage { + name = "nvf"; + tag = "latest"; - copyToRoot = buildEnv { - name = "neovim-root"; - pathsToLink = ["/bin"]; - paths = [ - neovim-nix - gitFull - bash - ]; - }; - - config = { - Cmd = ["${neovim-nix}/bin/nvim"]; - WorkingDir = "/home/neovim/demo"; - Volumes = {"/home/neovim/demo" = {};}; - }; + copyToRoot = buildEnv { + name = "neovim-root"; + pathsToLink = ["/bin"]; + paths = [ + neovim-nix + gitFull + bash + ]; }; - } - // ( - if !(builtins.elem system ["aarch64-darwin" "x86_64-darwin"]) - then {tidal = config.legacyPackages.neovim-tidal;} - else {} - ); + + config = { + Cmd = ["${neovim-nix}/bin/nvim"]; + WorkingDir = "/home/neovim/demo"; + Volumes = {"/home/neovim/demo" = {};}; + }; + }; + }; }; } diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 3a33ad06..eb5125ab 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -5,7 +5,6 @@ in { ./bash ./dart ./elixir - ./tidal ./clang.nix ./css.nix diff --git a/modules/plugins/languages/tidal/config.nix b/modules/plugins/languages/tidal/config.nix deleted file mode 100644 index 344c1a77..00000000 --- a/modules/plugins/languages/tidal/config.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: let - inherit (lib.modules) mkIf; - - cfg = config.vim.tidal; -in { - config = mkIf (cfg.enable) { - vim.startPlugins = [ - # From tidalcycles flake - pkgs.vimPlugins.vim-tidal - ]; - - vim.globals = { - "tidal_target" = "terminal"; - "tidal_flash_duration" = 150; - "tidal_sc_enable" = cfg.openSC; - }; - }; -} diff --git a/modules/plugins/languages/tidal/default.nix b/modules/plugins/languages/tidal/default.nix deleted file mode 100644 index da6dd5ae..00000000 --- a/modules/plugins/languages/tidal/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{...}: { - imports = [ - ./tidal.nix - ./config.nix - ]; -} diff --git a/modules/plugins/languages/tidal/tidal.nix b/modules/plugins/languages/tidal/tidal.nix deleted file mode 100644 index ebfe4a0f..00000000 --- a/modules/plugins/languages/tidal/tidal.nix +++ /dev/null @@ -1,24 +0,0 @@ -{ - config, - lib, - ... -}: let - inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) int bool; -in { - options.vim.tidal = { - enable = mkEnableOption "tidalcycles tools and plugins"; - - flash = mkOption { - description = ''When sending a paragraph or a single line, vim-tidal will "flash" the selection for some milliseconds''; - type = int; - default = 150; - }; - - openSC = mkOption { - description = "Automatically run the supercollider CLI, sclang, alongside the Tidal GHCI terminal."; - type = bool; - default = true; - }; - }; -} From 6eba2a5585e3cb479a85cac0cd0c125d19fe28a9 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 6 May 2024 22:57:27 +0300 Subject: [PATCH 0022/1178] languages: move bash & dart configurations to standalone files --- modules/plugins/languages/{bash => }/bash.nix | 33 +++++++- modules/plugins/languages/bash/config.nix | 83 ------------------- modules/plugins/languages/bash/default.nix | 6 -- modules/plugins/languages/{dart => }/dart.nix | 74 ++++++++++++++--- modules/plugins/languages/dart/config.nix | 76 ----------------- modules/plugins/languages/dart/default.nix | 6 -- 6 files changed, 94 insertions(+), 184 deletions(-) rename modules/plugins/languages/{bash => }/bash.nix (78%) delete mode 100644 modules/plugins/languages/bash/config.nix delete mode 100644 modules/plugins/languages/bash/default.nix rename modules/plugins/languages/{dart => }/dart.nix (61%) delete mode 100644 modules/plugins/languages/dart/config.nix delete mode 100644 modules/plugins/languages/dart/default.nix diff --git a/modules/plugins/languages/bash/bash.nix b/modules/plugins/languages/bash.nix similarity index 78% rename from modules/plugins/languages/bash/bash.nix rename to modules/plugins/languages/bash.nix index 7b5de0fa..1d7e1ce8 100644 --- a/modules/plugins/languages/bash/bash.nix +++ b/modules/plugins/languages/bash.nix @@ -1,15 +1,17 @@ { - pkgs, config, + pkgs, lib, ... }: let inherit (builtins) attrNames; inherit (lib.options) mkOption mkEnableOption literalExpression; + inherit (lib.modules) mkIf mkMerge; inherit (lib.lists) isList; inherit (lib.types) enum either package listOf str bool; - inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.languages) diagnosticsToLua; inherit (lib.nvim.types) diagnostics mkGrammarOption; + inherit (lib.nvim.lua) expToLua; cfg = config.vim.languages.bash; @@ -55,6 +57,7 @@ ls_sources, null_ls.builtins.diagnostics.shellcheck.with({ command = "${pkg}/bin/shellcheck", + diagnostics_format = "#{m} [#{c}]" }) ) ''; @@ -114,4 +117,30 @@ in { }; }; }; + + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.bash-lsp = servers.${cfg.lsp.server}.lspConfig; + }) + + (mkIf cfg.format.enable { + vim.lsp.null-ls.enable = true; + vim.lsp.null-ls.sources.bash-format = formats.${cfg.format.type}.nullConfig; + }) + + (mkIf cfg.extraDiagnostics.enable { + vim.lsp.null-ls.enable = true; + vim.lsp.null-ls.sources = diagnosticsToLua { + lang = "bash"; + config = cfg.extraDiagnostics.types; + inherit diagnosticsProviders; + }; + }) + ]); } diff --git a/modules/plugins/languages/bash/config.nix b/modules/plugins/languages/bash/config.nix deleted file mode 100644 index 7f2a70a5..00000000 --- a/modules/plugins/languages/bash/config.nix +++ /dev/null @@ -1,83 +0,0 @@ -{ - pkgs, - config, - lib, - ... -}: let - inherit (lib.lists) isList; - inherit (lib.modules) mkIf mkMerge; - inherit (lib.nvim.lua) expToLua; - inherit (lib.nvim.languages) diagnosticsToLua; - - cfg = config.vim.languages.bash; - diagnosticsProviders = { - shellcheck = { - package = pkgs.shellcheck; - nullConfig = pkg: '' - table.insert( - ls_sources, - null_ls.builtins.diagnostics.shellcheck.with({ - command = "${pkg}/bin/shellcheck", - }) - ) - ''; - }; - }; - - formats = { - shfmt = { - package = pkgs.shfmt; - nullConfig = '' - table.insert( - ls_sources, - null_ls.builtins.formatting.shfmt.with({ - command = "${pkgs.shfmt}/bin/shfmt", - }) - ) - ''; - }; - }; - - servers = { - bash-ls = { - package = pkgs.nodePackages.bash-language-server; - lspConfig = '' - lspconfig.bashls.setup{ - capabilities = capabilities; - on_attach = default_on_attach; - cmd = ${ - if isList cfg.lsp.package - then expToLua cfg.lsp.package - else ''{"${cfg.lsp.package}/bin/bash-language-server", "start"}'' - }; - } - ''; - }; - }; -in { - config = mkIf cfg.enable (mkMerge [ - (mkIf cfg.treesitter.enable { - vim.treesitter.enable = true; - vim.treesitter.grammars = [cfg.treesitter.package]; - }) - - (mkIf cfg.lsp.enable { - vim.lsp.lspconfig.enable = true; - vim.lsp.lspconfig.sources.bash-lsp = servers.${cfg.lsp.server}.lspConfig; - }) - - (mkIf cfg.format.enable { - vim.lsp.null-ls.enable = true; - vim.lsp.null-ls.sources.bash-format = formats.${cfg.format.type}.nullConfig; - }) - - (mkIf cfg.extraDiagnostics.enable { - vim.lsp.null-ls.enable = true; - vim.lsp.null-ls.sources = diagnosticsToLua { - lang = "bash"; - config = cfg.extraDiagnostics.types; - inherit diagnosticsProviders; - }; - }) - ]); -} diff --git a/modules/plugins/languages/bash/default.nix b/modules/plugins/languages/bash/default.nix deleted file mode 100644 index 7bb1ea2d..00000000 --- a/modules/plugins/languages/bash/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - imports = [ - ./bash.nix - ./config.nix - ]; -} diff --git a/modules/plugins/languages/dart/dart.nix b/modules/plugins/languages/dart.nix similarity index 61% rename from modules/plugins/languages/dart/dart.nix rename to modules/plugins/languages/dart.nix index 13ce3d95..8f957c90 100644 --- a/modules/plugins/languages/dart/dart.nix +++ b/modules/plugins/languages/dart.nix @@ -1,18 +1,23 @@ { config, - lib, pkgs, + lib, ... }: let inherit (builtins) attrNames; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.trivial) boolToString; inherit (lib.lists) isList; inherit (lib.options) mkEnableOption mkOption; inherit (lib.types) enum either listOf package nullOr str bool; inherit (lib.strings) optionalString; inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.languages.dart; + ftcfg = cfg.flutter-tools; + defaultServer = "dart"; servers = { dart = { @@ -48,15 +53,16 @@ in { default = defaultServer; }; package = mkOption { - description = "Dart LSP server package, or the command to run as a list of strings"; - example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]''; type = either package (listOf str); default = servers.${cfg.lsp.server}.package; + example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]''; + description = "Dart LSP server package, or the command to run as a list of strings"; }; + opts = mkOption { - description = "Options to pass to Dart LSP server"; type = nullOr str; default = null; + description = "Options to pass to Dart LSP server"; }; }; @@ -70,23 +76,26 @@ in { flutter-tools = { enable = mkOption { - description = "Enable flutter-tools for flutter support"; type = bool; default = config.vim.languages.enableLSP; + description = "Enable flutter-tools for flutter support"; }; enableNoResolvePatch = mkOption { - description = '' - Patch flutter-tools so that it doesn't resolve symlinks when detecting flutter path. - This is required if you want to use a flutter package built with nix. - If you are using a flutter SDK installed from a different source and encounter the error "`dart` missing from PATH", disable this option. - ''; type = bool; default = true; + description = '' + Whether to patch flutter-tools so that it doesn't resolve + symlinks when detecting flutter path. + + This is required if you want to use a flutter package built with nix. + If you are using a flutter SDK installed from a different source + and encounter the error "`dart` missing from PATH", disable this option. + ''; }; color = { - enable = mkEnableOption "Whether or mot to highlight color variables at all"; + enable = mkEnableOption "highlighting color variables"; highlightBackground = mkOption { type = bool; @@ -112,4 +121,47 @@ in { }; }; }; + + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + + vim.lsp.lspconfig.sources.dart-lsp = servers.${cfg.lsp.server}.lspConfig; + }) + + (mkIf ftcfg.enable { + vim.startPlugins = + if ftcfg.enableNoResolvePatch + then ["flutter-tools-patched"] + else ["flutter-tools"]; + + vim.luaConfigRC.flutter-tools = entryAnywhere '' + require('flutter-tools').setup { + lsp = { + color = { -- show the derived colours for dart variables + enabled = ${boolToString ftcfg.color.enable}, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10 + background = ${boolToString ftcfg.color.highlightBackground}, -- highlight the background + foreground = ${boolToString ftcfg.color.highlightForeground}, -- highlight the foreground + virtual_text = ${boolToString ftcfg.color.virtualText.enable}, -- show the highlight using virtual text + virtual_text_str = ${ftcfg.color.virtualText.character} -- the virtual text character to highlight + }, + + capabilities = capabilities, + on_attach = default_on_attach; + flags = lsp_flags, + }, + ${optionalString cfg.dap.enable '' + debugger = { + enabled = true, + }, + ''} + } + ''; + }) + ]); } diff --git a/modules/plugins/languages/dart/config.nix b/modules/plugins/languages/dart/config.nix deleted file mode 100644 index be7c111b..00000000 --- a/modules/plugins/languages/dart/config.nix +++ /dev/null @@ -1,76 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - inherit (lib.lists) isList; - inherit (lib.modules) mkIf mkMerge; - inherit (lib.strings) optionalString; - inherit (lib.trivial) boolToString; - inherit (lib.nvim.lua) expToLua; - inherit (lib.nvim.dag) entryAnywhere; - - cfg = config.vim.languages.dart; - ftcfg = cfg.flutter-tools; - servers = { - dart = { - package = pkgs.dart; - lspConfig = '' - lspconfig.dartls.setup{ - capabilities = capabilities; - on_attach=default_on_attach; - cmd = ${ - if isList cfg.lsp.package - then expToLua cfg.lsp.package - else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}'' - }; - ${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"} - } - ''; - }; - }; -in { - config = mkIf cfg.enable (mkMerge [ - (mkIf cfg.treesitter.enable { - vim.treesitter.enable = true; - vim.treesitter.grammars = [cfg.treesitter.package]; - }) - - (mkIf cfg.lsp.enable { - vim.lsp.lspconfig.enable = true; - - vim.lsp.lspconfig.sources.dart-lsp = servers.${cfg.lsp.server}.lspConfig; - }) - - (mkIf ftcfg.enable { - vim.startPlugins = - if ftcfg.enableNoResolvePatch - then ["flutter-tools-patched"] - else ["flutter-tools"]; - - vim.luaConfigRC.flutter-tools = entryAnywhere '' - require('flutter-tools').setup { - lsp = { - color = { -- show the derived colours for dart variables - enabled = ${boolToString ftcfg.color.enable}, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10 - background = ${boolToString ftcfg.color.highlightBackground}, -- highlight the background - foreground = ${boolToString ftcfg.color.highlightForeground}, -- highlight the foreground - virtual_text = ${boolToString ftcfg.color.virtualText.enable}, -- show the highlight using virtual text - virtual_text_str = ${ftcfg.color.virtualText.character} -- the virtual text character to highlight - }, - - capabilities = capabilities, - on_attach = default_on_attach; - flags = lsp_flags, - }, - ${optionalString cfg.dap.enable '' - debugger = { - enabled = true, - }, - ''} - } - ''; - }) - ]); -} diff --git a/modules/plugins/languages/dart/default.nix b/modules/plugins/languages/dart/default.nix deleted file mode 100644 index 2ad34f34..00000000 --- a/modules/plugins/languages/dart/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - imports = [ - ./dart.nix - ./config.nix - ]; -} From 7481423bed82c3d869cb6a67a4bd572e8fe84dd2 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 6 May 2024 22:57:36 +0300 Subject: [PATCH 0023/1178] docs: update 0.7 release notes --- docs/release-notes/rl-0.7.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index b5047a4b..8f61a893 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -23,4 +23,10 @@ Release notes for release 0.7 - Add `deno fmt` as the default Markdown formatter. This will be enabled automatically if you have autoformatting enabled, but can be disabled manually if you choose to. + - Remove vim-tidal and friends + +- Remove unmaintained Elixir language module. This has been long broken, and was + unmaintained due to my disinterest in using Elixir. If you depend on Elixir + language support, please create an issue. Do keep in mind that elixirls **does + not exist in nixpkgs**. From bf090172d2aaed2731a7c2661f4cc68791eb0e87 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 6 May 2024 23:09:40 +0300 Subject: [PATCH 0024/1178] modules/extra: init deprecations module; warn for elixir & vim-tidal --- modules/extra/deprecations.nix | 16 ++++++++++++++++ modules/modules.nix | 8 +++++++- modules/plugins/languages/default.nix | 6 ++---- 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 modules/extra/deprecations.nix diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix new file mode 100644 index 00000000..b2bf522b --- /dev/null +++ b/modules/extra/deprecations.nix @@ -0,0 +1,16 @@ +{lib, ...}: let + inherit (lib.modules) mkRemovedOptionModule; +in { + imports = [ + # 2024-06-06 + (mkRemovedOptionModule ["vim" "languages" "elixir"] '' + Elixir language support has been removed as of 2024-06-06 as it was long unmaintained. If + you dependend on this language support, please consider contributing to its maintenance. + '') + + (mkRemovedOptionModule ["vim" "tidal"] '' + Tidalcycles language support has been removed as of 2024-06-06 as it was long unmaintained. If + you depended on this functionality, please open an issue. + '') + ]; +} diff --git a/modules/modules.nix b/modules/modules.nix index 620111f8..0de5984d 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -53,7 +53,13 @@ "warnings" ]; - allModules = concatLists [neovim plugins wrapper]; + # Extra modules, such as deprecation warnings + # or renames in one place. + extra = map (p: ./extra + "/${p}") [ + "deprecations.nix" + ]; + + allModules = concatLists [neovim plugins wrapper extra]; pkgsModule = {config, ...}: { config = { diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index eb5125ab..802dfe7f 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -2,10 +2,8 @@ inherit (lib.nvim.languages) mkEnable; in { imports = [ - ./bash - ./dart - ./elixir - + ./bash.nix + ./dart.nix ./clang.nix ./css.nix ./go.nix From e0790f2bdb132c77a23dae3626601be1bb960321 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 6 May 2024 23:09:59 +0300 Subject: [PATCH 0025/1178] docs: remove remaining references to elixir & vim-tidal related pkgs --- configuration.nix | 2 -- docs/manual/try-it-out.md | 6 ------ flake.lock | 34 ---------------------------------- flake.nix | 10 ---------- 4 files changed, 52 deletions(-) diff --git a/configuration.nix b/configuration.nix index 5c0095b5..82f86ccb 100644 --- a/configuration.nix +++ b/configuration.nix @@ -55,8 +55,6 @@ inputs: let enableExtraDiagnostics = true; nim.enable = false; - elixir.enable = false; - nix.enable = true; markdown.enable = true; diff --git a/docs/manual/try-it-out.md b/docs/manual/try-it-out.md index 70aee50c..bd8c69bb 100644 --- a/docs/manual/try-it-out.md +++ b/docs/manual/try-it-out.md @@ -5,7 +5,6 @@ Below are the commands you may run to try out different configurations provided configurations are provided: - Nix -- Tidal - Maximal You may try out any of the provided configurations using the `nix run` command on a system where Nix is installed. @@ -22,7 +21,6 @@ once you garbage collect. ```console $ nix run github:notashelf/nvf#nix -$ nix run github:notashelf/nvf#tidal $ nix run github:notashelf/nvf#maximal ``` @@ -33,10 +31,6 @@ $ nix run github:notashelf/nvf#maximal `Nix` configuration by default provides LSP/diagnostic support for Nix alongisde a set of visual and functional plugins. By running `nix run .#`, which is the default package, you will build Neovim with this config. -#### Tidal {#sec-configs-tidal} - -Tidal is an alternative config that adds vim-tidal on top of the plugins from the Nix configuration. - #### Maximal {#sec-configs-maximal} `Maximal` is the ultimate configuration that will enable support for more commonly used language as well as additional diff --git a/flake.lock b/flake.lock index e7060017..cd2a3eee 100644 --- a/flake.lock +++ b/flake.lock @@ -546,38 +546,6 @@ "type": "github" } }, - "plugin-elixir-ls": { - "flake": false, - "locked": { - "lastModified": 1713724318, - "narHash": "sha256-1kLMxznNRRJ7M10zkuWexA/sPFaN449M0SKUjLrnc8c=", - "owner": "elixir-lsp", - "repo": "elixir-ls", - "rev": "8486de473a219dcdb72408702f8d56d0227c7366", - "type": "github" - }, - "original": { - "owner": "elixir-lsp", - "repo": "elixir-ls", - "type": "github" - } - }, - "plugin-elixir-tools": { - "flake": false, - "locked": { - "lastModified": 1713617654, - "narHash": "sha256-pJgtW51FLs+Yr+tlQckRmGkRnSUQNI3fEROn3D51mMs=", - "owner": "elixir-tools", - "repo": "elixir-tools.nvim", - "rev": "3c4f8344a341818417b3d75c04eb96d894cb4640", - "type": "github" - }, - "original": { - "owner": "elixir-tools", - "repo": "elixir-tools.nvim", - "type": "github" - } - }, "plugin-fidget-nvim": { "flake": false, "locked": { @@ -1796,8 +1764,6 @@ "plugin-diffview-nvim": "plugin-diffview-nvim", "plugin-dracula": "plugin-dracula", "plugin-dressing-nvim": "plugin-dressing-nvim", - "plugin-elixir-ls": "plugin-elixir-ls", - "plugin-elixir-tools": "plugin-elixir-tools", "plugin-fidget-nvim": "plugin-fidget-nvim", "plugin-flutter-tools": "plugin-flutter-tools", "plugin-gesture-nvim": "plugin-gesture-nvim", diff --git a/flake.nix b/flake.nix index 3425addc..d51617a5 100644 --- a/flake.nix +++ b/flake.nix @@ -178,16 +178,6 @@ flake = false; }; - plugin-elixir-ls = { - url = "github:elixir-lsp/elixir-ls"; - flake = false; - }; - - plugin-elixir-tools = { - url = "github:elixir-tools/elixir-tools.nvim"; - flake = false; - }; - plugin-glow-nvim = { url = "github:ellisonleao/glow.nvim"; flake = false; From dc0fa7629564f9481b03a4be358557868befa0a4 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Mon, 6 May 2024 17:01:16 -0400 Subject: [PATCH 0026/1178] docs: entry for fixed null lsp mappings --- docs/release-notes/rl-0.7.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index ab6f9da8..3582cd26 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -13,7 +13,8 @@ Release notes for release 0.7 - Modified type for [](#opt-vim.visuals.fidget-nvim.setupOpts.progress.display.overrides) from `anything` to a `submodule` for better type checking. +- Fix null `vim.lsp.mappings` generating an error and not being filtered out. -[horriblename](https://github.com/horriblename) +[horriblename](https://github.com/horriblename): - Fix broken treesitter-context keybinds in visual mode From e96897f6b3e60183e81a04a45593f837f4e101d8 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 7 May 2024 00:52:33 +0300 Subject: [PATCH 0027/1178] languages/elixir: readd; format module options --- configuration.nix | 3 +- docs/release-notes/rl-0.7.md | 10 +- flake.lock | 17 +++ flake.nix | 19 ++- modules/extra/deprecations.nix | 5 - modules/plugins/languages/default.nix | 1 + modules/plugins/languages/elixir.nix | 138 ++++++++++++++++++ modules/plugins/languages/elixir/config.nix | 67 --------- modules/plugins/languages/elixir/default.nix | 6 - .../plugins/languages/elixir/elixir-tools.nix | 7 - 10 files changed, 175 insertions(+), 98 deletions(-) create mode 100644 modules/plugins/languages/elixir.nix delete mode 100644 modules/plugins/languages/elixir/config.nix delete mode 100644 modules/plugins/languages/elixir/default.nix delete mode 100644 modules/plugins/languages/elixir/elixir-tools.nix diff --git a/configuration.nix b/configuration.nix index 82f86ccb..56e5d90d 100644 --- a/configuration.nix +++ b/configuration.nix @@ -54,7 +54,6 @@ inputs: let enableTreesitter = true; enableExtraDiagnostics = true; - nim.enable = false; nix.enable = true; markdown.enable = true; @@ -65,12 +64,14 @@ inputs: let ts.enable = isMaximal; svelte.enable = isMaximal; go.enable = isMaximal; + elixir.enable = isMaximal; zig.enable = isMaximal; python.enable = isMaximal; dart.enable = isMaximal; bash.enable = isMaximal; tailwind.enable = isMaximal; typst.enable = isMaximal; + nim.enable = isMaximal; clang = { enable = isMaximal; lsp.server = "clangd"; diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 8f61a893..0cf265fb 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -24,9 +24,9 @@ Release notes for release 0.7 automatically if you have autoformatting enabled, but can be disabled manually if you choose to. -- Remove vim-tidal and friends +- Refactor `programs.languages.elixir` to use lspconfig and none-ls for LSP and + formatter setups respectively. Diagnostics support is considered, and may be + added once the [credo](https://github.com/rrrene/credo) linter has been added + to nixpkgs. A pull request is currently open. -- Remove unmaintained Elixir language module. This has been long broken, and was - unmaintained due to my disinterest in using Elixir. If you depend on Elixir - language support, please create an issue. Do keep in mind that elixirls **does - not exist in nixpkgs**. +- Remove vim-tidal and friends diff --git a/flake.lock b/flake.lock index cd2a3eee..c34ef948 100644 --- a/flake.lock +++ b/flake.lock @@ -546,6 +546,22 @@ "type": "github" } }, + "plugin-elixir-tools": { + "flake": false, + "locked": { + "lastModified": 1714657398, + "narHash": "sha256-U6db1n/RIpT7Dd54e9iI/PjO1BhDpMyNPfaph+dUk7k=", + "owner": "elixir-tools", + "repo": "elixir-tools.nvim", + "rev": "51eddb03a7a8c9f00d6415b356a4d3b75d8e75b6", + "type": "github" + }, + "original": { + "owner": "elixir-tools", + "repo": "elixir-tools.nvim", + "type": "github" + } + }, "plugin-fidget-nvim": { "flake": false, "locked": { @@ -1764,6 +1780,7 @@ "plugin-diffview-nvim": "plugin-diffview-nvim", "plugin-dracula": "plugin-dracula", "plugin-dressing-nvim": "plugin-dressing-nvim", + "plugin-elixir-tools": "plugin-elixir-tools", "plugin-fidget-nvim": "plugin-fidget-nvim", "plugin-flutter-tools": "plugin-flutter-tools", "plugin-gesture-nvim": "plugin-gesture-nvim", diff --git a/flake.nix b/flake.nix index d51617a5..ae6885ac 100644 --- a/flake.nix +++ b/flake.nix @@ -178,13 +178,8 @@ flake = false; }; - plugin-glow-nvim = { - url = "github:ellisonleao/glow.nvim"; - flake = false; - }; - - plugin-image-nvim = { - url = "github:3rd/image.nvim"; + plugin-elixir-tools = { + url = "github:elixir-tools/elixir-tools.nvim"; flake = false; }; @@ -487,6 +482,16 @@ flake = false; }; + plugin-glow-nvim = { + url = "github:ellisonleao/glow.nvim"; + flake = false; + }; + + plugin-image-nvim = { + url = "github:3rd/image.nvim"; + flake = false; + }; + # Note-taking plugin-obsidian-nvim = { url = "github:epwalsh/obsidian.nvim"; diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index b2bf522b..cb063800 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -3,11 +3,6 @@ in { imports = [ # 2024-06-06 - (mkRemovedOptionModule ["vim" "languages" "elixir"] '' - Elixir language support has been removed as of 2024-06-06 as it was long unmaintained. If - you dependend on this language support, please consider contributing to its maintenance. - '') - (mkRemovedOptionModule ["vim" "tidal"] '' Tidalcycles language support has been removed as of 2024-06-06 as it was long unmaintained. If you depended on this functionality, please open an issue. diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 802dfe7f..279d46b7 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -6,6 +6,7 @@ in { ./dart.nix ./clang.nix ./css.nix + ./elixir.nix ./go.nix ./html.nix ./java.nix diff --git a/modules/plugins/languages/elixir.nix b/modules/plugins/languages/elixir.nix new file mode 100644 index 00000000..7f969ad4 --- /dev/null +++ b/modules/plugins/languages/elixir.nix @@ -0,0 +1,138 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (builtins) attrNames; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.types) enum either listOf package str; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.lua) expToLua; + inherit (lib.nvim.dag) entryAnywhere; + + cfg = config.vim.languages.elixir; + + defaultServer = "elixirls"; + servers = { + elixirls = { + package = pkgs.elixir-ls; + lspConfig = '' + -- elixirls setup + lspconfig.elixirls.setup { + capabilities = capabilities, + on_attach = default_on_attach, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${cfg.lsp.package}/bin/elixir-ls"}'' + } + } + ''; + }; + }; + + defaultFormat = "mix"; + formats = { + mix = { + package = pkgs.elixir; + nullConfig = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.mix.with({ + command = "${cfg.format.package}/bin/mix", + }) + ) + ''; + }; + }; +in { + options.vim.languages.elixir = { + enable = mkEnableOption "Elixir language support"; + + treesitter = { + enable = mkEnableOption "Elixir treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "elixir"; + }; + + lsp = { + enable = mkEnableOption "Elixir LSP support" // {default = config.vim.languages.enableLSP;}; + + server = mkOption { + description = "Elixir LSP server to use"; + type = enum (attrNames servers); + default = defaultServer; + }; + + package = mkOption { + description = "Elixir LSP server package, or the command to run as a list of strings"; + example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]''; + type = either package (listOf str); + default = servers.${cfg.lsp.server}.package; + }; + }; + + format = { + enable = mkEnableOption "Elixir formatting" // {default = config.vim.languages.enableFormat;}; + + type = mkOption { + description = "Elixir formatter to use"; + type = enum (attrNames formats); + default = defaultFormat; + }; + + package = mkOption { + description = "Elixir formatter package"; + type = package; + default = formats.${cfg.format.type}.package; + }; + }; + + elixir-tools = { + enable = mkEnableOption "Elixir tools"; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.elixir-lsp = servers.${cfg.lsp.server}.lspConfig; + }) + + (mkIf cfg.format.enable { + vim.lsp.null-ls.enable = true; + vim.lsp.null-ls.sources.elixir-format = formats.${cfg.format.type}.nullConfig; + }) + + (mkIf cfg.elixir-tools.enable { + vim.startPlugins = ["elixir-tools"]; + vim.luaConfigRC.elixir-tools = entryAnywhere '' + local elixir-tools = require("elixir") + local elixirls = require("elixir-tools.elixirls") + + -- disable imperative insstallations of various + -- elixir related tools installed by elixir-tools + elixir-tools.setup { + nextls = { + enable = false -- defaults to false + }, + + credo = { + enable = false -- defaults to true + }, + + elixirls = { + enable = false, -- defaults to true + } + } + ''; + }) + ]); +} diff --git a/modules/plugins/languages/elixir/config.nix b/modules/plugins/languages/elixir/config.nix deleted file mode 100644 index eaf26ea6..00000000 --- a/modules/plugins/languages/elixir/config.nix +++ /dev/null @@ -1,67 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: let - inherit (lib.modules) mkIf; - inherit (lib.meta) getExe; - inherit (lib.nvim.dag) entryAnywhere; - - cfg = config.vim.languages.elixir; -in { - config = mkIf (cfg.enable) { - vim.startPlugins = [ - "elixir-tools" - ]; - - vim.luaConfigRC.elixir-tools = entryAnywhere '' - local elixir = require("elixir") - local elixirls = require("elixir.elixirls") - - elixir.setup { - elixirls = { - -- alternatively, point to an existing elixir-ls installation (optional) - -- not currently supported by elixirls, but can be a table if you wish to pass other args `{"path/to/elixirls", "--foo"}` - cmd = "${getExe pkgs.elixir-ls}", - - -- default settings, use the `settings` function to override settings - settings = elixirls.settings { - dialyzerEnabled = true, - fetchDeps = false, - enableTestLenses = false, - suggestSpecs = false, - }, - - on_attach = function(client, bufnr) - local map_opts = { buffer = true, noremap = true} - - -- run the codelens under the cursor - vim.keymap.set("n", "r", vim.lsp.codelens.run, map_opts) - -- remove the pipe operator - vim.keymap.set("n", "fp", ":ElixirFromPipe", map_opts) - -- add the pipe operator - vim.keymap.set("n", "tp", ":ElixirToPipe", map_opts) - vim.keymap.set("v", "em", ":ElixirExpandMacro", map_opts) - - -- bindings for standard LSP functions. - vim.keymap.set("n", "df", "lua vim.lsp.buf.format()", map_opts) - vim.keymap.set("n", "gd", "lua vim.diagnostic.open_float()", map_opts) - vim.keymap.set("n", "dt", "lua vim.lsp.buf.definition()", map_opts) - vim.keymap.set("n", "K", "lua vim.lsp.buf.hover()", map_opts) - vim.keymap.set("n", "gD","lua vim.lsp.buf.implementation()", map_opts) - vim.keymap.set("n", "1gD","lua vim.lsp.buf.type_definition()", map_opts) - - -- keybinds for fzf-lsp.nvim: https://github.com/gfanto/fzf-lsp.nvim - -- you could also use telescope.nvim: https://github.com/nvim-telescope/telescope.nvim - -- there are also core vim.lsp functions that put the same data in the loclist - vim.keymap.set("n", "gr", ":References", map_opts) - vim.keymap.set("n", "g0", ":DocumentSymbols", map_opts) - vim.keymap.set("n", "gW", ":WorkspaceSymbols", map_opts) - vim.keymap.set("n", "d", ":Diagnostics", map_opts) - end - } - } - ''; - }; -} diff --git a/modules/plugins/languages/elixir/default.nix b/modules/plugins/languages/elixir/default.nix deleted file mode 100644 index c84acf0c..00000000 --- a/modules/plugins/languages/elixir/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ - imports = [ - ./config.nix - ./elixir-tools.nix - ]; -} diff --git a/modules/plugins/languages/elixir/elixir-tools.nix b/modules/plugins/languages/elixir/elixir-tools.nix deleted file mode 100644 index 05273593..00000000 --- a/modules/plugins/languages/elixir/elixir-tools.nix +++ /dev/null @@ -1,7 +0,0 @@ -{lib, ...}: let - inherit (lib.options) mkEnableOption; -in { - options.vim.languages.elixir = { - enable = mkEnableOption "Elixir language support"; - }; -} From 96b92b5652cfd192a953b01f34630714b48a96b9 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 7 May 2024 15:40:08 +0300 Subject: [PATCH 0028/1178] configuration.nix: disable nim by default It is broken on Darwin, and pkgs is not in scope here to check --- configuration.nix | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/configuration.nix b/configuration.nix index 56e5d90d..e2c02f7b 100644 --- a/configuration.nix +++ b/configuration.nix @@ -54,9 +54,16 @@ inputs: let enableTreesitter = true; enableExtraDiagnostics = true; - nix.enable = true; - markdown.enable = true; + # Nim LSP is broken on Darwin and therefore + # should be disabled by default. Users may still enable + # `vim.languages.vim` to enable it, this does not restrict + # that. + # See: + nim.enable = false; + nix.enable = true; + + markdown.enable = isMaximal; html.enable = isMaximal; css.enable = isMaximal; sql.enable = isMaximal; @@ -71,7 +78,6 @@ inputs: let bash.enable = isMaximal; tailwind.enable = isMaximal; typst.enable = isMaximal; - nim.enable = isMaximal; clang = { enable = isMaximal; lsp.server = "clangd"; @@ -79,14 +85,14 @@ inputs: let rust = { enable = isMaximal; - crates.enable = true; + crates.enable = isMaximal; }; }; visuals = { enable = true; nvimWebDevicons.enable = true; - scrollBar.enable = true; + scrollBar.enable = isMaximal; smoothScroll.enable = true; cellularAutomaton.enable = false; fidget-nvim.enable = true; From a85bf963e6c3725d813667c8233d0a4ee3dcd9ee Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 7 May 2024 23:57:09 +0300 Subject: [PATCH 0029/1178] CI: don't build tidal output --- .github/workflows/cachix.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/cachix.yml b/.github/workflows/cachix.yml index 5ecf45a0..1142adce 100644 --- a/.github/workflows/cachix.yml +++ b/.github/workflows/cachix.yml @@ -19,7 +19,6 @@ jobs: package: - default - nix - - tidal - maximal steps: - uses: easimon/maximize-build-space@v10 From 41f7abcdc3cf9dfea9a865666b568fb3b4a3ebe8 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 8 May 2024 00:22:12 +0300 Subject: [PATCH 0030/1178] languagess/markdown: add missing `config` section --- modules/plugins/languages/markdown.nix | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/modules/plugins/languages/markdown.nix b/modules/plugins/languages/markdown.nix index 7fcc364c..06ba66bb 100644 --- a/modules/plugins/languages/markdown.nix +++ b/modules/plugins/languages/markdown.nix @@ -5,6 +5,7 @@ ... }: let inherit (builtins) attrNames concatLists; + inherit (lib.modules) mkIf mkMerge; inherit (lib.options) mkEnableOption mkOption; inherit (lib.lists) isList; inherit (lib.types) bool enum either package listOf str; @@ -51,9 +52,9 @@ in { treesitter = { enable = mkOption { - description = "Enable Markdown treesitter"; type = bool; default = config.vim.languages.enableTreesitter; + description = "Enable Markdown treesitter"; }; mdPackage = mkGrammarOption pkgs "markdown"; mdInlinePackage = mkGrammarOption pkgs "markdown-inline"; @@ -63,16 +64,16 @@ in { enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.languages.enableLSP;}; server = mkOption { - description = "Markdown LSP server to use"; type = enum (attrNames servers); default = defaultServer; + description = "Markdown LSP server to use"; }; package = mkOption { - description = "Markdown LSP server package, or the command to run as a list of strings"; - example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]''; type = either package (listOf str); default = servers.${cfg.lsp.server}.package; + example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]''; + description = "Markdown LSP server package, or the command to run as a list of strings"; }; }; @@ -98,4 +99,21 @@ in { }; }; }; + + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.mdPackage cfg.treesitter.mdInlinePackage]; + }) + + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig; + }) + + (mkIf cfg.format.enable { + vim.lsp.null-ls.enable = true; + vim.lsp.null-ls.sources.markdown-format = formats.${cfg.format.type}.nullConfig; + }) + ]); } From ea5f229efd65ba565728a98e6e994a917fb3fd73 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 8 May 2024 00:31:23 +0300 Subject: [PATCH 0031/1178] languages/markdown: convert extra ft list to lua table --- modules/plugins/languages/markdown.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/plugins/languages/markdown.nix b/modules/plugins/languages/markdown.nix index 06ba66bb..e0164771 100644 --- a/modules/plugins/languages/markdown.nix +++ b/modules/plugins/languages/markdown.nix @@ -39,7 +39,7 @@ table.insert( ls_sources, null_ls.builtins.formatting.deno_fmt.with({ - filetypes = ${concatLists cfg.format.extraFiletypes ["markdown"]}, + filetypes = ${expToLua (concatLists [cfg.format.extraFiletypes ["markdown"]])}, command = "${cfg.format.package}/bin/deno", }) ) @@ -81,21 +81,21 @@ in { enable = mkEnableOption "Markdown formatting" // {default = config.vim.languages.enableFormat;}; type = mkOption { - description = "Markdown formatter to use"; type = enum (attrNames formats); default = defaultFormat; + description = "Markdown formatter to use"; }; package = mkOption { - description = "Markdown formatter package"; type = package; default = formats.${cfg.format.type}.package; + description = "Markdown formatter package"; }; extraFiletypes = mkOption { - description = "Extra filetypes to format with the Markdown formatter"; type = listOf str; default = []; + description = "Extra filetypes to format with the Markdown formatter"; }; }; }; From 7c1a8e2c1e6cdd37ee079531eeaf0ae6c6569aee Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 8 May 2024 23:05:58 +0300 Subject: [PATCH 0032/1178] flake: bump inputs --- flake.lock | 216 ++++++++++++++++++++++++++--------------------------- 1 file changed, 105 insertions(+), 111 deletions(-) diff --git a/flake.lock b/flake.lock index c34ef948..b072646a 100644 --- a/flake.lock +++ b/flake.lock @@ -21,11 +21,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1712014858, - "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", + "lastModified": 1714641030, + "narHash": "sha256-yzcRNDoyVP7+SCNX0wmuDju1NUCt8Dz9+lyUXEI0dbI=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", + "rev": "e5d10a24b66c3ea8f150e47dfdb0416ab7c3390e", "type": "github" }, "original": { @@ -99,11 +99,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1704611696, - "narHash": "sha256-4ZCgV5oHdEc3q+XaIzy//gh20uC/aSuAtMU9bsfgLZk=", + "lastModified": 1714571717, + "narHash": "sha256-o4tqlTzi9kcVub167kTGXgCac9jM3kW4+v9MH/ue4Hk=", "owner": "oxalica", "repo": "nil", - "rev": "059d33a24bb76d2048740bcce936362bf54b5bc9", + "rev": "2f3ed6348bbf1440fcd1ab0411271497a0fbbfa4", "type": "github" }, "original": { @@ -114,11 +114,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1713895582, - "narHash": "sha256-cfh1hi+6muQMbi9acOlju3V1gl8BEaZBXBR9jQfQi4U=", + "lastModified": 1715087517, + "narHash": "sha256-CLU5Tsg24Ke4+7sH8azHWXKd0CFd4mhLWfhYgUiDBpQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "572af610f6151fd41c212f897c71f7056e3fb518", + "rev": "b211b392b8486ee79df6cdfb1157ad2133427a29", "type": "github" }, "original": { @@ -130,20 +130,14 @@ }, "nixpkgs-lib": { "locked": { - "dir": "lib", - "lastModified": 1711703276, - "narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "d8fe5e6c92d0d190646fb9f1056741a229980089", - "type": "github" + "lastModified": 1714640452, + "narHash": "sha256-QBx10+k6JWz6u7VsohfSw8g8hjdBZEf8CFzXH1/1Z94=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz" }, "original": { - "dir": "lib", - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz" } }, "nixpkgs_2": { @@ -229,11 +223,11 @@ "plugin-catppuccin": { "flake": false, "locked": { - "lastModified": 1713105352, - "narHash": "sha256-yTVou/WArEWygBBs2NFPI9Dm9iSGfwVftKFbOAGl8tk=", + "lastModified": 1715167632, + "narHash": "sha256-aRrhVHQSCyo1Ti1j8ogWJ8e0eJWiTw5+abIpyUxky/M=", "owner": "catppuccin", "repo": "nvim", - "rev": "a1439ad7c584efb3d0ce14ccb835967f030450fe", + "rev": "d97387aea8264f484bb5d5e74f2182a06c83e0d8", "type": "github" }, "original": { @@ -245,11 +239,11 @@ "plugin-ccc": { "flake": false, "locked": { - "lastModified": 1712580766, - "narHash": "sha256-G96++Bmuklb3eDfmyKPKFUDHuopTMmIFa/ILdf11N/I=", + "lastModified": 1714299582, + "narHash": "sha256-QRq9hQF5vLnOTzQGbOWC2ykMdMsQDlDlb6XC17dJG7Q=", "owner": "uga-rosa", "repo": "ccc.nvim", - "rev": "1283eef5494c092a047baa34ed3e667f3cb2715e", + "rev": "f388f1981d222967c741fe9927edf9ba5fa3bcbe", "type": "github" }, "original": { @@ -309,11 +303,11 @@ "plugin-cinnamon-nvim": { "flake": false, "locked": { - "lastModified": 1711005384, - "narHash": "sha256-LNikkGldBpUsfyH8ThtX7RS1p/z3JzSPonT9qUU84jw=", + "lastModified": 1714107684, + "narHash": "sha256-cMP9WRZzevxaWgpILyDh1JwNukm3Jl3JKJYPT2HnFns=", "owner": "declancm", "repo": "cinnamon.nvim", - "rev": "559fe02fae00ffd78377e9c242b2faa25a428592", + "rev": "a011e84b624cd7b609ea928237505d31b987748a", "type": "github" }, "original": { @@ -469,11 +463,11 @@ "plugin-crates-nvim": { "flake": false, "locked": { - "lastModified": 1713995074, - "narHash": "sha256-09+mBhh5hAXENPzrvwNNQEyM7ZtuPYAWrtAG/pzBOV8=", + "lastModified": 1715069896, + "narHash": "sha256-AhjnPo3SM7o7foj5ppv0CW+jfJe6ACerq4YFgJfY3/8=", "owner": "Saecki", "repo": "crates.nvim", - "rev": "f00e11e8282b94f2a2e938d32712c99f0e0bdeb4", + "rev": "7d8541ec0e3b30ac2c43864d3ee13a632e1231ed", "type": "github" }, "original": { @@ -485,11 +479,11 @@ "plugin-dashboard-nvim": { "flake": false, "locked": { - "lastModified": 1713420371, - "narHash": "sha256-zcWBgDM409n6rmb06FqVXbC+HU9HJN0+ADoTJDWHvbA=", + "lastModified": 1714906999, + "narHash": "sha256-euIAtegnJTH2hpFP0OAuvl7VpEV0Xu91h+w9p1uC3+0=", "owner": "glepnir", "repo": "dashboard-nvim", - "rev": "6d06924b562de6f0bb136edf1bf549afbf6b7d00", + "rev": "a0a78099658c7d4be3714f657b18ca8285d5d106", "type": "github" }, "original": { @@ -597,11 +591,11 @@ "plugin-gesture-nvim": { "flake": false, "locked": { - "lastModified": 1713872849, - "narHash": "sha256-npryXJ92l65gOGltTd3jE3fdhiEgqbxCdK5w/C/BQV0=", + "lastModified": 1715081943, + "narHash": "sha256-h6alx5TjskXYQ3H9fFfC4QyxsGbpjQkoZFVvLi1sgFI=", "owner": "notomo", "repo": "gesture.nvim", - "rev": "47175ed2741ba46fe7f14d6ee37ebbc5b9614c5a", + "rev": "591b350bfc87932a748f4838ad724eea6fb073e0", "type": "github" }, "original": { @@ -613,11 +607,11 @@ "plugin-gitsigns-nvim": { "flake": false, "locked": { - "lastModified": 1713620636, - "narHash": "sha256-UK3DyvrQ0kLm9wrMQ6tLDoDunoThbY/Yfjn+eCZpuMw=", + "lastModified": 1715007445, + "narHash": "sha256-v21qTJfiv57vSUDGCJ4wM+L0Ixwh2b3pkoESFAHBrDM=", "owner": "lewis6991", "repo": "gitsigns.nvim", - "rev": "035da036e68e509ed158414416c827d022d914bd", + "rev": "805610a9393fa231f2c2b49cb521bfa413fadb3d", "type": "github" }, "original": { @@ -645,11 +639,11 @@ "plugin-gruvbox": { "flake": false, "locked": { - "lastModified": 1706538659, - "narHash": "sha256-jWnrRy/PT7D0UcPGL+XTbKHWvS0ixvbyqPtTzG9HY84=", + "lastModified": 1715085640, + "narHash": "sha256-2Ad5I+peKCD2BCm4m/QIjqpW08qQvrY+o3bK5UEy1x8=", "owner": "ellisonleao", "repo": "gruvbox.nvim", - "rev": "6e4027ae957cddf7b193adfaec4a8f9e03b4555f", + "rev": "c442515506caa166118e157980f62a9ac24fa8c3", "type": "github" }, "original": { @@ -661,11 +655,11 @@ "plugin-highlight-undo": { "flake": false, "locked": { - "lastModified": 1713721901, - "narHash": "sha256-5zYUpfSR56gCufR+Y18qo8ZpMRg8N3ejkRZNJswJ4wQ=", + "lastModified": 1714982601, + "narHash": "sha256-yGw1SxcUmGQxqKhMb2SJAai07g+rOpEJy2CqIX2h9dM=", "owner": "tzachar", "repo": "highlight-undo.nvim", - "rev": "a0dbc6afa19b438ca5a6f54bc7f1a10399f21a15", + "rev": "1ea1c79372d7d93c88fd97543880927b7635e3d2", "type": "github" }, "original": { @@ -709,11 +703,11 @@ "plugin-image-nvim": { "flake": false, "locked": { - "lastModified": 1713989303, - "narHash": "sha256-UBrusfIYWURI1Auo3XayswA8NXgZhqwazg6wmmgWygA=", + "lastModified": 1714464812, + "narHash": "sha256-UfJzROXnjaiF+kIaBYAt5GSL107vT5NrpXj+Gh535Yk=", "owner": "3rd", "repo": "image.nvim", - "rev": "2d4b479c59fd70cc26f63d48b5cd76a44dda8873", + "rev": "604692f493519128c58893c28273d4247bc71a4d", "type": "github" }, "original": { @@ -741,11 +735,11 @@ "plugin-leap-nvim": { "flake": false, "locked": { - "lastModified": 1712927908, - "narHash": "sha256-sSnofCInXuqaDEawT4vN1WdYl1cjK++BjSFnR1wXjr4=", + "lastModified": 1714857300, + "narHash": "sha256-RodnRoiQTH/+XoPk30neLiYIptPJnCvL94keIQXjq2g=", "owner": "ggandor", "repo": "leap.nvim", - "rev": "626be4c4ec040aeaf6466c9aae17ee0ab09f1a5b", + "rev": "f1f19fc268b406b00b50091f51f16d9634fbe449", "type": "github" }, "original": { @@ -917,11 +911,11 @@ "plugin-noice-nvim": { "flake": false, "locked": { - "lastModified": 1711471279, - "narHash": "sha256-y6gHNkWVsIuwBf7MblCTKTZSqjGDxqeFeQZWexzwk94=", + "lastModified": 1714737209, + "narHash": "sha256-jR9tX6AhY+DXPqGXqGqCkG/sL9+mLxpwOqfwjHHN0Ac=", "owner": "folke", "repo": "noice.nvim", - "rev": "0cbe3f88d038320bdbda3c4c5c95f43a13c3aa12", + "rev": "f4decbc7a80229ccc9f86026b74bdcf0c39e38a7", "type": "github" }, "original": { @@ -950,11 +944,11 @@ "plugin-nui-nvim": { "flake": false, "locked": { - "lastModified": 1710740032, - "narHash": "sha256-Zr5CNx6BIM6naCXW8YBc/Oj1qOtWV/3tuMoaaZjoSZA=", + "lastModified": 1714991123, + "narHash": "sha256-W5w8mWjZhf8rhFYDJX4vPAszxKX6uLgT7+8xg3dY4Ok=", "owner": "MunifTanjim", "repo": "nui.nvim", - "rev": "cbd2668414331c10039278f558630ed19b93e69b", + "rev": "a3597dc88b53489d3fddbddbbd13787355253bb0", "type": "github" }, "original": { @@ -966,11 +960,11 @@ "plugin-nvim-autopairs": { "flake": false, "locked": { - "lastModified": 1712441622, - "narHash": "sha256-ta+0jw7P0ESThP8q2c+CD+nCzPMyHH2Cy3kjjysH0TE=", + "lastModified": 1714895218, + "narHash": "sha256-LMRt1XEoeHB3blfjI0SsQr4goMUmwjoMGS2LcR3ye20=", "owner": "windwp", "repo": "nvim-autopairs", - "rev": "4f41e5940bc0443fdbe5f995e2a596847215cd2a", + "rev": "14e97371b2aab6ee70054c1070a123dfaa3e217e", "type": "github" }, "original": { @@ -998,11 +992,11 @@ "plugin-nvim-cmp": { "flake": false, "locked": { - "lastModified": 1713837627, - "narHash": "sha256-rz+JMd/hsUEDNVan2sCuEGtbsOVi6oRmPtps+7qSXQE=", + "lastModified": 1715160812, + "narHash": "sha256-/zTOFwCSBETBgkILpP8h82ZjN7LiMV0Uk5d2TEnQVU4=", "owner": "hrsh7th", "repo": "nvim-cmp", - "rev": "8f3c541407e691af6163e2447f3af1bd6e17f9a3", + "rev": "cd2cf0c124d3de577fb5449746568ee8e601afc8", "type": "github" }, "original": { @@ -1078,11 +1072,11 @@ "plugin-nvim-dap-ui": { "flake": false, "locked": { - "lastModified": 1710867604, - "narHash": "sha256-KAwCt8E3lC0fzXQ9GpPsdb9wdWC6G2P4C/YFQFY9AAM=", + "lastModified": 1714314733, + "narHash": "sha256-26g4dlxzTGaR5OrXpPo4A2erM/eSkgedb0Bl2pK362M=", "owner": "rcarriga", "repo": "nvim-dap-ui", - "rev": "edfa93f60b189e5952c016eee262d0685d838450", + "rev": "5934302d63d1ede12c0b22b6f23518bb183fc972", "type": "github" }, "original": { @@ -1126,11 +1120,11 @@ "plugin-nvim-lspconfig": { "flake": false, "locked": { - "lastModified": 1713908193, - "narHash": "sha256-VdIoInJj2u49WHN4+WX0kNHdbXgh0AqIPU+OAiUaBck=", + "lastModified": 1715152811, + "narHash": "sha256-LMzLDbkKVmRRhwaUaroCRGUsKe/fwzgwV1gbvr/t6WQ=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "cfa386fc4027e847156ee16141ea1f4c0bc2f0a4", + "rev": "a3d9395455f2b2e3b50a0b0f37b8b4c23683f44a", "type": "github" }, "original": { @@ -1190,11 +1184,11 @@ "plugin-nvim-nio": { "flake": false, "locked": { - "lastModified": 1712221544, - "narHash": "sha256-ZRYclqsgAvlRBwb59XHlqVat7CxUJTH1rD6QLwh1ang=", + "lastModified": 1714664267, + "narHash": "sha256-VfoJOXXtMhalFcnfhVzweq7TVmB8WjRP+Z5Z5Z24Pzc=", "owner": "nvim-neotest", "repo": "nvim-nio", - "rev": "5800f585def265d52f1d8848133217c800bcb25d", + "rev": "8765cbc4d0c629c8158a5341e1b4305fd93c3a90", "type": "github" }, "original": { @@ -1222,11 +1216,11 @@ "plugin-nvim-session-manager": { "flake": false, "locked": { - "lastModified": 1708284146, - "narHash": "sha256-+TDWY8mprJfUp9ZFKbz83to7XW8iiovja22jHms+N1A=", + "lastModified": 1714905094, + "narHash": "sha256-VduhmnnRPIdi6GZ+TZUnZfpY4Lt8z5JBTKgl7oobtdY=", "owner": "Shatur", "repo": "neovim-session-manager", - "rev": "d8e1ba3bbcf3fdc6a887bcfbd94c48ae4707b457", + "rev": "892c55f7256fe170301a1fdd21752982c75c3507", "type": "github" }, "original": { @@ -1238,11 +1232,11 @@ "plugin-nvim-surround": { "flake": false, "locked": { - "lastModified": 1712807644, - "narHash": "sha256-gXWSCAJhOJKzTFi6QiDqDWPNgBtG5KgyF2t4gposqSY=", + "lastModified": 1714506343, + "narHash": "sha256-PJdkmTzuRldPTdaoerdddOL0/+V/KyNSzFBBee6P4kU=", "owner": "kylechui", "repo": "nvim-surround", - "rev": "a4e30d33add8a9743b4f518b3a788b3c8e5def71", + "rev": "6d0dc3dbb557bcc6a024969da461df4ba803fc48", "type": "github" }, "original": { @@ -1254,11 +1248,11 @@ "plugin-nvim-tree-lua": { "flake": false, "locked": { - "lastModified": 1713946472, - "narHash": "sha256-iD8c/dXt/UcTYDK8/zkTkFW/1Ial8ulCUWojjyXpG8k=", + "lastModified": 1714794673, + "narHash": "sha256-rY4FbuqBM4zOUkaA3QBc+UrpfTha8uGtp+lIzrYK+cg=", "owner": "nvim-tree", "repo": "nvim-tree.lua", - "rev": "62008e5cf2e8745c9d23bb599ef642963131057e", + "rev": "64f61e4c913047a045ff90bd188dd3b54ee443cf", "type": "github" }, "original": { @@ -1270,11 +1264,11 @@ "plugin-nvim-treesitter-context": { "flake": false, "locked": { - "lastModified": 1713984790, - "narHash": "sha256-QAudKglQGDRJKrsEcMSjbrxTgQRXO60ZcfOvEnPLUoE=", + "lastModified": 1714689136, + "narHash": "sha256-gHbLt0ApyPPQU8Q+lde0Zv8XBR6pESKzvIzIXHkd5eI=", "owner": "nvim-treesitter", "repo": "nvim-treesitter-context", - "rev": "4fe0a54e86859744968e1a5c7867b49c86855774", + "rev": "2650e6431f7daba5d9c2c64134fa5eb2312eb3d7", "type": "github" }, "original": { @@ -1302,11 +1296,11 @@ "plugin-nvim-web-devicons": { "flake": false, "locked": { - "lastModified": 1713675782, - "narHash": "sha256-AW2W6H7OTv52hfZCcYQc5UjFArBWKLeVclrwMt13HOM=", + "lastModified": 1715028064, + "narHash": "sha256-DSUTxUFCesXuaJjrDNvurILUt1IrO5MI5ukbZ8D87zQ=", "owner": "nvim-tree", "repo": "nvim-web-devicons", - "rev": "beb6367ab8496c9e43f22e0252735fdadae1872d", + "rev": "5b9067899ee6a2538891573500e8fd6ff008440f", "type": "github" }, "original": { @@ -1318,11 +1312,11 @@ "plugin-obsidian-nvim": { "flake": false, "locked": { - "lastModified": 1713538455, - "narHash": "sha256-nIAaQa0DBYBQyfTEJi3Lzqs7QJqyw0Cemq6Hm704K60=", + "lastModified": 1715192893, + "narHash": "sha256-lGnEEFp/MU5sciq6bH5YKAiFx7kf9tTYqE+eB8zvf7A=", "owner": "epwalsh", "repo": "obsidian.nvim", - "rev": "ec0f44e1921d2701bd99a542031d280f1e3930b5", + "rev": "2e1f03416583232899dc1b6e27673da5e705abef", "type": "github" }, "original": { @@ -1350,11 +1344,11 @@ "plugin-orgmode-nvim": { "flake": false, "locked": { - "lastModified": 1713539113, - "narHash": "sha256-0Ayu2kVpnsxu/ER0nx+t7nyU9oNN8URLrGQtAKKb7Ls=", + "lastModified": 1715114055, + "narHash": "sha256-SmofuYt4fLhtl5qedYlmCRgOmZaw3nmlnMg0OMzyKnM=", "owner": "nvim-orgmode", "repo": "orgmode", - "rev": "389e91f6f935aa845bc0cd13dd80f75431c34751", + "rev": "cda615fa7c8607bfb7aaf7d2c9424dd5969f2625", "type": "github" }, "original": { @@ -1382,11 +1376,11 @@ "plugin-plenary-nvim": { "flake": false, "locked": { - "lastModified": 1713788468, - "narHash": "sha256-orGs1npIGIk7MUYadatYrcEXygK7JTj6OqQwy2TLDn0=", + "lastModified": 1714083960, + "narHash": "sha256-vy0MXEoSM4rvYpfwbc2PnilvMOA30Urv0FAxjXuvqQ8=", "owner": "nvim-lua", "repo": "plenary.nvim", - "rev": "5129a3693c482fcbc5ab99a7706ffc4360b995a0", + "rev": "08e301982b9a057110ede7a735dd1b5285eb341f", "type": "github" }, "original": { @@ -1526,11 +1520,11 @@ "plugin-telescope": { "flake": false, "locked": { - "lastModified": 1713665692, - "narHash": "sha256-wlRiwT1TCtwPXnIwnzqa6ZABUzJYn+lSRyvkqe6Dbsw=", + "lastModified": 1714700089, + "narHash": "sha256-SoEetPE7f7Y0kUa4+7dH+EOs/0WBsMDxeOkbVNuoSjE=", "owner": "nvim-telescope", "repo": "telescope.nvim", - "rev": "7d1698f3d88b448e0639974248cc17f49b7b8acf", + "rev": "fac83a556e7b710dc31433dec727361ca062dbe9", "type": "github" }, "original": { @@ -1622,11 +1616,11 @@ "plugin-vim-fugitive": { "flake": false, "locked": { - "lastModified": 1712554826, - "narHash": "sha256-pmY1EQbupKvsqok9O5omkOWi0BEZ8df7HL0F7ubdY9Q=", + "lastModified": 1714601825, + "narHash": "sha256-0ujueJ226zEmjkFwodSukO1Zu5gMvTmx/dCtT5VBhek=", "owner": "tpope", "repo": "vim-fugitive", - "rev": "dac8e5c2d85926df92672bf2afb4fc48656d96c7", + "rev": "ce882460cf3db12e99f8bf579cbf99e331f6dd4f", "type": "github" }, "original": { @@ -1871,11 +1865,11 @@ ] }, "locked": { - "lastModified": 1704593904, - "narHash": "sha256-nDoXZDTRdgF3b4n3m011y99nYFewvOl9UpzFvP8Rb3c=", + "lastModified": 1714529851, + "narHash": "sha256-YMKJW880f7LHXVRzu93xa6Ek+QLECIu0IRQbXbzZe38=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "c36fd70a99decfa6e110c86f296a97613034a680", + "rev": "9ca720fdcf7865385ae3b93ecdf65f1a64cb475e", "type": "github" }, "original": { @@ -1936,11 +1930,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1713960597, - "narHash": "sha256-WAryNIrMfZ48iZSTh8hcHIX9vwh78LMFUtewgY7kp1Y=", + "lastModified": 1715170163, + "narHash": "sha256-EuRzY3HI9sMMqPX7Yb7xkZaBoznP0mtS2O/Kk/r6fYk=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "71894accd2dd096f5a84166a628b1f075311aafe", + "rev": "9c0a853edcab5d60d28784c10b13392d7fabb9d7", "type": "github" }, "original": { From 407ecf00d5c7eca436c03498ffa04c03c79dc74d Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 8 May 2024 23:49:08 +0300 Subject: [PATCH 0033/1178] wrapper/rc: add `vim.additionaLuafiles` Allows the user to specify a list of lua files that will be called via `luafile`. All paths that are passed to this option are checked by `builtins.isPath` so attempting to source paths that do not exist do not result in a broken Lua configuration. --- docs/release-notes/rl-0.7.md | 12 ++++++---- modules/wrapper/rc/config.nix | 10 +++++++- modules/wrapper/rc/options.nix | 44 ++++++++++++++++++++++++++++++---- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index d822399f..9c5d395e 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -6,13 +6,14 @@ Release notes for release 0.7 [ItsSorae](https://github.com/ItsSorae): -- Added support for [typst](https://typst.app/) under `vim.languages.typst` - This will enable the `typst-lsp` language server, and the `typstfmt` formatter +- Added support for [typst](https://typst.app/) under `vim.languages.typst` This + will enable the `typst-lsp` language server, and the `typstfmt` formatter [frothymarrow](https://github.com/frothymarrow): -- Modified type for [](#opt-vim.visuals.fidget-nvim.setupOpts.progress.display.overrides) - from `anything` to a `submodule` for better type checking. +- Modified type for + [](#opt-vim.visuals.fidget-nvim.setupOpts.progress.display.overrides) from + `anything` to a `submodule` for better type checking. - Fix null `vim.lsp.mappings` generating an error and not being filtered out. [horriblename](https://github.com/horriblename): @@ -25,6 +26,9 @@ Release notes for release 0.7 automatically if you have autoformatting enabled, but can be disabled manually if you choose to. +- Add `vim.extraLuaFiles` for optionally sourcing additional lua files in your + configuration. + - Refactor `programs.languages.elixir` to use lspconfig and none-ls for LSP and formatter setups respectively. Diagnostics support is considered, and may be added once the [credo](https://github.com/rrrene/credo) linter has been added diff --git a/modules/wrapper/rc/config.nix b/modules/wrapper/rc/config.nix index f42f0400..b50531b1 100644 --- a/modules/wrapper/rc/config.nix +++ b/modules/wrapper/rc/config.nix @@ -133,6 +133,14 @@ in { configRC = { globalsScript = entryAnywhere (concatStringsSep "\n" globalsScript); + # Call additional lua files with :luafile in Vimscript + # section of the configuration, only after + # the luaScript section has been evaluated + extraLuaFiles = let + callLuaFiles = map (file: "luafile ${file}") cfg.extraLuaFiles; + in + entryAfter ["globalScript"] (concatStringsSep "\n" callLuaFiles); + # wrap the lua config in a lua block # using the wrapLuaConfic function from the lib luaScript = let @@ -148,7 +156,7 @@ in { inherit mapResult; }; in - entryAfter ["globalsScript"] luaConfig; + entryAnywhere luaConfig; extraPluginConfigs = let mapResult = result: (wrapLuaConfig { diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index 106701ef..bc14241a 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -37,8 +37,8 @@ in { To avoid leaking imperative user configuration into your configuration, this is enabled by default. If you wish to load configuration from user configuration directories - (e.g. `$HOME/.config/nvim`, `$HOME/.config/nvim/after` - and `$HOME/.local/share/nvim/site`) you may set this + (e.g. {file}`$HOME/.config/nvim`, {file}`$HOME/.config/nvim/after` + and {file}`$HOME/.local/share/nvim/site`) you may set this option to true. ::: ''; @@ -68,16 +68,52 @@ in { active runtimepath of the Neovim. This can be used to add additional lookup paths for configs, plugins, spell languages and other things you would generally place in - your `$HOME/.config/nvim`. + your {file}`$HOME/.config/nvim`. This is meant as a declarative alternative to throwing - files into `~/.config/nvim` and having the Neovim + files into {file}`~/.config/nvim` and having the Neovim wrapper pick them up. For more details on `vim.o.runtimepath`, and what paths to use; please see [the official documentation](https://neovim.io/doc/user/options.html#'runtimepath') ''; }; + extraLuaFiles = mkOption { + type = listOf (either path str); + default = []; + example = literalExpression '' + [ + # absolute path, as a string - impure + "$HOME/.config/nvim/my-lua-file.lua" + + # relative path, as a path - pure + ./nvim/my-lua-file.lua + + # source type path - pure and reproducible + (builtins.source { + path = ./nvim/my-lua-file.lua; + name = "my-lua-file"; + }) + ] + ''; + + description = '' + Additional lua files that will be sourced by Neovim. + Takes both absolute and relative paths, all of which + will be called via the `luafile` command in Neovim. + + See [lua-commands](https://neovim.io/doc/user/lua.html#lua-commands) + on the Neovim documentation for more details. + + ::: {.warning} + All paths passed to this option must be valid. If Neovim cannot + resolve the path you are attempting to sourcee, then your configuration + will error, and Neovim will not start. Please ensure that all paths + are correct before using this option. + ::: + ''; + }; + globals = mkOption { type = attrs; default = {}; From 981fe07075d2fe6e5a72e53f77179385f5685f91 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 12 May 2024 01:43:03 +0200 Subject: [PATCH 0034/1178] colorizer: allow null for all options --- modules/plugins/ui/colorizer/colorizer.nix | 59 ++++++++++++++++++---- 1 file changed, 49 insertions(+), 10 deletions(-) diff --git a/modules/plugins/ui/colorizer/colorizer.nix b/modules/plugins/ui/colorizer/colorizer.nix index bbbad37e..eb3d4914 100644 --- a/modules/plugins/ui/colorizer/colorizer.nix +++ b/modules/plugins/ui/colorizer/colorizer.nix @@ -4,20 +4,59 @@ ... }: let inherit (lib.options) mkOption mkEnableOption; - inherit (lib.types) attrsOf enum nullOr submodule; + inherit (lib.types) attrsOf enum nullOr submodule bool; inherit (lib.modules) mkRenamedOptionModule; - inherit (lib.nvim.config) mkBool; settingSubmodule = submodule { options = { - RGB = mkBool true "Colorize #RGB hex codes"; - RRGGBB = mkBool true "Colorize #RRGGBB hex codes"; - names = mkBool true ''Colorize "Name" codes like Blue''; - RRGGBBAA = mkBool false "Colorize #RRGGBBAA hex codes"; - rgb_fn = mkBool false "Colorize CSS rgb() and rgba() functions"; - hsl_fn = mkBool false "Colorize CSS hsl() and hsla() functions"; - css = mkBool false "Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB"; - css_fn = mkBool false "Enable all CSS *functions*: rgb_fn, hsl_fn"; + RGB = mkOption { + description = "Colorize #RGB hex codes"; + default = null; + type = nullOr bool; + }; + + RRGGBB = mkOption { + description = "Colorize #RRGGBB hex codes"; + default = null; + type = nullOr bool; + }; + + names = mkOption { + description = ''Colorize "Name" codes like Blue''; + default = null; + type = nullOr bool; + }; + + RRGGBBAA = mkOption { + description = "Colorize #RRGGBBAA hex codes"; + default = null; + type = nullOr bool; + }; + + rgb_fn = mkOption { + description = "Colorize CSS rgb() and rgba() functions"; + default = null; + type = nullOr bool; + }; + + hsl_fn = mkOption { + description = "Colorize CSS hsl() and hsla() functions"; + default = null; + type = nullOr bool; + }; + + css = mkOption { + description = "Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB"; + default = null; + type = nullOr bool; + }; + + css_fn = mkOption { + description = "Enable all CSS *functions*: rgb_fn, hsl_fn"; + default = null; + type = nullOr bool; + }; + mode = mkOption { description = "Set the display mode"; type = nullOr (enum ["foreground" "background"]); From 82e92a56da2a18dace58480bfed8bb01abb74e04 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 12 May 2024 02:11:59 +0200 Subject: [PATCH 0035/1178] colorizer: move back to setupOpts --- modules/plugins/ui/colorizer/colorizer.nix | 62 +++++++++++++++++----- modules/plugins/ui/colorizer/config.nix | 2 +- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/modules/plugins/ui/colorizer/colorizer.nix b/modules/plugins/ui/colorizer/colorizer.nix index eb3d4914..cf367b26 100644 --- a/modules/plugins/ui/colorizer/colorizer.nix +++ b/modules/plugins/ui/colorizer/colorizer.nix @@ -4,8 +4,9 @@ ... }: let inherit (lib.options) mkOption mkEnableOption; - inherit (lib.types) attrsOf enum nullOr submodule bool; + inherit (lib.types) attrsOf enum nullOr submodule bool str; inherit (lib.modules) mkRenamedOptionModule; + inherit (lib.nvim.types) mkPluginSetupOption; settingSubmodule = submodule { options = { @@ -33,6 +34,12 @@ type = nullOr bool; }; + AARRGGBB = mkOption { + description = "Colorize 0xAARRGGBB hex codes"; + default = null; + type = nullOr bool; + }; + rgb_fn = mkOption { description = "Colorize CSS rgb() and rgba() functions"; default = null; @@ -57,11 +64,35 @@ type = nullOr bool; }; + tailwind = mkOption { + description = "Enable tailwind colors"; + default = null; + type = nullOr bool; + }; + + sass = mkOption { + description = "Enable sass colors"; + default = null; + type = nullOr bool; + }; + + virtualtext = mkOption { + description = "String to display as virtualtext"; + type = nullOr str; + default = null; + }; + mode = mkOption { description = "Set the display mode"; type = nullOr (enum ["foreground" "background"]); default = null; }; + + always_update = mkOption { + description = "Update color values even if buffer is not focused. Example use: cmp_menu, cmp_docs"; + default = null; + type = nullOr bool; + }; }; }; in { @@ -73,20 +104,23 @@ in { options.vim.ui.colorizer = { enable = mkEnableOption "color highlighting [nvim-colorizer.lua]"; - defaultOptions = mkOption { - description = '' - Default options that apply to all filetypes. Filetype specific settings from - [filetypeSettings](#opt-vim.ui.colorizer.filetypeSettings) take precedence. - ''; - default = {}; - type = settingSubmodule; - }; + setupOpts = mkPluginSetupOption "colorizer" { + filetypes = mkOption { + description = '' + Filetypes to enable on and their option overrides. - filetypeOptions = mkOption { - description = "Filetype specific settings"; - default = {}; - type = submodule { - freeformType = attrsOf settingSubmodule; + The special filetype "*" means enable on all filetypes. + ''; + default = {}; + type = submodule { + freeformType = attrsOf settingSubmodule; + }; + }; + + user_default_options = mkOption { + description = "Default options"; + default = {}; + type = settingSubmodule; }; }; }; diff --git a/modules/plugins/ui/colorizer/config.nix b/modules/plugins/ui/colorizer/config.nix index d96920d7..1ff45f6b 100644 --- a/modules/plugins/ui/colorizer/config.nix +++ b/modules/plugins/ui/colorizer/config.nix @@ -15,7 +15,7 @@ in { ]; vim.luaConfigRC.colorizer = entryAnywhere '' - require('colorizer').setup(${toLuaObject cfg.filetypeOptions}, ${toLuaObject cfg.defaultOptions}) + require('colorizer').setup(${toLuaObject cfg.setupOpts}) ''; }; } From 7d9f1e04818c5cb39cfd08f03e83649bb01e7cad Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 12 May 2024 02:18:04 +0200 Subject: [PATCH 0036/1178] colorizer: add example --- modules/plugins/ui/colorizer/colorizer.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/plugins/ui/colorizer/colorizer.nix b/modules/plugins/ui/colorizer/colorizer.nix index cf367b26..62ea28ea 100644 --- a/modules/plugins/ui/colorizer/colorizer.nix +++ b/modules/plugins/ui/colorizer/colorizer.nix @@ -109,9 +109,16 @@ in { description = '' Filetypes to enable on and their option overrides. - The special filetype "*" means enable on all filetypes. + "*" means enable on all filetypes. Filetypes prefixed with "!" are disabled. ''; default = {}; + example = { + "*" = {}; + "!vim" = {}; + javascript = { + AARRGGBB = false; + }; + }; type = submodule { freeformType = attrsOf settingSubmodule; }; From 8aa3a23e9742babdbf98fab17b082fbf1cf1751c Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sun, 12 May 2024 03:17:04 +0200 Subject: [PATCH 0037/1178] lib: do not filter out empty attrs in toLuaObject --- lib/lua.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/lua.nix b/lib/lua.nix index 9e67b3f5..8cef5d59 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -65,6 +65,7 @@ in rec { then if isLuaInline args then args.expr + # if nobody is using this we should get rid of this else if hasAttr "__empty" args then "{ }" else @@ -76,10 +77,7 @@ in rec { then toLuaObject v else "[${toLuaObject n}] = " + (toLuaObject v)) (filterAttrs - ( - _: v: - (v != null) && (toLuaObject v != "{}") - ) + (_: v: v != null) args))) + "}" else if isList args From 355d4830e52ef9c2d378e612de38e0aee9f0ed7b Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 15 May 2024 13:09:19 +0300 Subject: [PATCH 0038/1178] flake: update inputs --- flake.lock | 118 ++++++++++++++++++++++++++--------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/flake.lock b/flake.lock index b072646a..32150d7a 100644 --- a/flake.lock +++ b/flake.lock @@ -114,11 +114,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1715087517, - "narHash": "sha256-CLU5Tsg24Ke4+7sH8azHWXKd0CFd4mhLWfhYgUiDBpQ=", + "lastModified": 1715534503, + "narHash": "sha256-5ZSVkFadZbFP1THataCaSf0JH2cAH3S29hU9rrxTEqk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "b211b392b8486ee79df6cdfb1157ad2133427a29", + "rev": "2057814051972fa1453ddfb0d98badbea9b83c06", "type": "github" }, "original": { @@ -367,11 +367,11 @@ "plugin-cmp-treesitter": { "flake": false, "locked": { - "lastModified": 1702163214, - "narHash": "sha256-K7F9iqmB13ONenwsbaND8F4010MvHQXp7DxMFfcsZ4A=", + "lastModified": 1715596479, + "narHash": "sha256-8WAk9S+/7vSz7bVHdEzjbKUokU144fvnByIeJ1gAWhU=", "owner": "ray-x", "repo": "cmp-treesitter", - "rev": "13e4ef8f4dd5639fca2eb9150e68f47639a9b37d", + "rev": "958fcfa0d8ce46d215e19cc3992c542f576c4123", "type": "github" }, "original": { @@ -463,11 +463,11 @@ "plugin-crates-nvim": { "flake": false, "locked": { - "lastModified": 1715069896, - "narHash": "sha256-AhjnPo3SM7o7foj5ppv0CW+jfJe6ACerq4YFgJfY3/8=", + "lastModified": 1715690194, + "narHash": "sha256-R1y1OIep4tcFd4mhylZ/A2zdwOmEQtCzuVBOBYu0qUI=", "owner": "Saecki", "repo": "crates.nvim", - "rev": "7d8541ec0e3b30ac2c43864d3ee13a632e1231ed", + "rev": "d556c00d60c9421c913ee54ff690df2a34f6264e", "type": "github" }, "original": { @@ -591,11 +591,11 @@ "plugin-gesture-nvim": { "flake": false, "locked": { - "lastModified": 1715081943, - "narHash": "sha256-h6alx5TjskXYQ3H9fFfC4QyxsGbpjQkoZFVvLi1sgFI=", + "lastModified": 1715211052, + "narHash": "sha256-vRXQBoKhmYid1M1d4OI/PolwQIwMn1x7EgxeW6Dzj0o=", "owner": "notomo", "repo": "gesture.nvim", - "rev": "591b350bfc87932a748f4838ad724eea6fb073e0", + "rev": "9b3d6361b37628f8869cd237416a1674103c0dc1", "type": "github" }, "original": { @@ -703,11 +703,11 @@ "plugin-image-nvim": { "flake": false, "locked": { - "lastModified": 1714464812, - "narHash": "sha256-UfJzROXnjaiF+kIaBYAt5GSL107vT5NrpXj+Gh535Yk=", + "lastModified": 1715712794, + "narHash": "sha256-7mZ7a9fU/6RxnzUiYxgIsZA2wGXTalfR2cPBp6kLO3Q=", "owner": "3rd", "repo": "image.nvim", - "rev": "604692f493519128c58893c28273d4247bc71a4d", + "rev": "b979fa1194443c97dd8cb6053a4cec163c9048f5", "type": "github" }, "original": { @@ -735,11 +735,11 @@ "plugin-leap-nvim": { "flake": false, "locked": { - "lastModified": 1714857300, - "narHash": "sha256-RodnRoiQTH/+XoPk30neLiYIptPJnCvL94keIQXjq2g=", + "lastModified": 1715716911, + "narHash": "sha256-vRL++RVDywO6nP5dHQiO1NSQ17SMmHm4AgjTQfv642o=", "owner": "ggandor", "repo": "leap.nvim", - "rev": "f1f19fc268b406b00b50091f51f16d9634fbe449", + "rev": "b1ecfb63c0b8babfd0dcd6b5ca6de37bbf3526cd", "type": "github" }, "original": { @@ -767,11 +767,11 @@ "plugin-lsp-signature": { "flake": false, "locked": { - "lastModified": 1710647656, - "narHash": "sha256-O7y7pcCvF0xUFamG+wMLe4mC6hUQ679rJV+ZUoWB0oY=", + "lastModified": 1715342515, + "narHash": "sha256-f4AuZnt2m2VA90baSbZt6+elzjXmJKPFTO28v8auoYc=", "owner": "ray-x", "repo": "lsp_signature.nvim", - "rev": "c6aeb2f1d2538bbdfdaab1664d9d4c3c75aa9db8", + "rev": "aed5d1162b0f07bb3af34bedcc5f70a2b6466ed8", "type": "github" }, "original": { @@ -911,11 +911,11 @@ "plugin-noice-nvim": { "flake": false, "locked": { - "lastModified": 1714737209, - "narHash": "sha256-jR9tX6AhY+DXPqGXqGqCkG/sL9+mLxpwOqfwjHHN0Ac=", + "lastModified": 1715763787, + "narHash": "sha256-sn8CiNq9JJXIxB6EEX98XaHhwyBPP7X1zqYMHLgdqd0=", "owner": "folke", "repo": "noice.nvim", - "rev": "f4decbc7a80229ccc9f86026b74bdcf0c39e38a7", + "rev": "61947de3d5904375ea94e0c13db2537488ad9829", "type": "github" }, "original": { @@ -992,11 +992,11 @@ "plugin-nvim-cmp": { "flake": false, "locked": { - "lastModified": 1715160812, - "narHash": "sha256-/zTOFwCSBETBgkILpP8h82ZjN7LiMV0Uk5d2TEnQVU4=", + "lastModified": 1715507122, + "narHash": "sha256-wyHbTXFqvt3kXo+EaHdrEggMDOnw4enAAf4pA9ZQm2g=", "owner": "hrsh7th", "repo": "nvim-cmp", - "rev": "cd2cf0c124d3de577fb5449746568ee8e601afc8", + "rev": "24122371810089d390847d8ba66325c1f1aa64c0", "type": "github" }, "original": { @@ -1056,11 +1056,11 @@ "plugin-nvim-dap": { "flake": false, "locked": { - "lastModified": 1713432622, - "narHash": "sha256-kEn2INrNMQSLHY3gpSVV+cTx9f1nFeUCM6by9WGn5Sg=", + "lastModified": 1715700682, + "narHash": "sha256-Gh1Vt8NLZ2MZUUB2EmTWYM0owUrpIpVyzxBgyBOwXWk=", "owner": "mfussenegger", "repo": "nvim-dap", - "rev": "6ae8a14828b0f3bff1721a35a1dfd604b6a933bb", + "rev": "559d0bbdbc4be4c7e774423061263771be1dbde8", "type": "github" }, "original": { @@ -1120,11 +1120,11 @@ "plugin-nvim-lspconfig": { "flake": false, "locked": { - "lastModified": 1715152811, - "narHash": "sha256-LMzLDbkKVmRRhwaUaroCRGUsKe/fwzgwV1gbvr/t6WQ=", + "lastModified": 1715682701, + "narHash": "sha256-kmo8UfTxarnxZLjL2qOeh4Jo/krxx3uqq073YnsFYxQ=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "a3d9395455f2b2e3b50a0b0f37b8b4c23683f44a", + "rev": "a27179f56c6f98a4cdcc79ee2971b514815a4940", "type": "github" }, "original": { @@ -1216,11 +1216,11 @@ "plugin-nvim-session-manager": { "flake": false, "locked": { - "lastModified": 1714905094, - "narHash": "sha256-VduhmnnRPIdi6GZ+TZUnZfpY4Lt8z5JBTKgl7oobtdY=", + "lastModified": 1715419340, + "narHash": "sha256-SrJJWC/newJRB879zMUbLzOJQ8qtcHfLF/7GLPFlSRQ=", "owner": "Shatur", "repo": "neovim-session-manager", - "rev": "892c55f7256fe170301a1fdd21752982c75c3507", + "rev": "a0b9d25154be573bc0f99877afb3f57cf881cce7", "type": "github" }, "original": { @@ -1248,11 +1248,11 @@ "plugin-nvim-tree-lua": { "flake": false, "locked": { - "lastModified": 1714794673, - "narHash": "sha256-rY4FbuqBM4zOUkaA3QBc+UrpfTha8uGtp+lIzrYK+cg=", + "lastModified": 1715647490, + "narHash": "sha256-YqHAEztx6gEEm0GoDXC5djnIP030oGGRcskp8LPqVoc=", "owner": "nvim-tree", "repo": "nvim-tree.lua", - "rev": "64f61e4c913047a045ff90bd188dd3b54ee443cf", + "rev": "2bc725a3ebc23f0172fb0ab4d1134b81bcc13812", "type": "github" }, "original": { @@ -1264,11 +1264,11 @@ "plugin-nvim-treesitter-context": { "flake": false, "locked": { - "lastModified": 1714689136, - "narHash": "sha256-gHbLt0ApyPPQU8Q+lde0Zv8XBR6pESKzvIzIXHkd5eI=", + "lastModified": 1715659155, + "narHash": "sha256-EYAIm8qicpfvOzg5xPWRwuWMPcUa/hg+q3so+s9sw5g=", "owner": "nvim-treesitter", "repo": "nvim-treesitter-context", - "rev": "2650e6431f7daba5d9c2c64134fa5eb2312eb3d7", + "rev": "df58c81237ffe2b277e14a1692212162a34e2e2a", "type": "github" }, "original": { @@ -1296,11 +1296,11 @@ "plugin-nvim-web-devicons": { "flake": false, "locked": { - "lastModified": 1715028064, - "narHash": "sha256-DSUTxUFCesXuaJjrDNvurILUt1IrO5MI5ukbZ8D87zQ=", + "lastModified": 1715644375, + "narHash": "sha256-1trRSUVyWFl3K+7xHXQGNl/EwE0ggyigQpZ+kmRPsk8=", "owner": "nvim-tree", "repo": "nvim-web-devicons", - "rev": "5b9067899ee6a2538891573500e8fd6ff008440f", + "rev": "e37bb1feee9e7320c76050a55443fa843b4b6f83", "type": "github" }, "original": { @@ -1328,11 +1328,11 @@ "plugin-onedark": { "flake": false, "locked": { - "lastModified": 1706527208, - "narHash": "sha256-1+aO8vrUGEe/NIVI1C1xJyuQVPQZ1s510lopkEVP7No=", + "lastModified": 1715454207, + "narHash": "sha256-GERMsVNELbeRrKsiPeSKcwNI+bH4C79koTBRtRMGqvc=", "owner": "navarasu", "repo": "onedark.nvim", - "rev": "1230aaf2a427b2c5b73aba6e4a9a5881d3e69429", + "rev": "8e4b79b0e6495ddf29552178eceba1e147e6cecf", "type": "github" }, "original": { @@ -1344,11 +1344,11 @@ "plugin-orgmode-nvim": { "flake": false, "locked": { - "lastModified": 1715114055, - "narHash": "sha256-SmofuYt4fLhtl5qedYlmCRgOmZaw3nmlnMg0OMzyKnM=", + "lastModified": 1715684611, + "narHash": "sha256-T/vjpYbrq1LTNitnSGGmguVr5UV83AFhNGmeNS2H9J0=", "owner": "nvim-orgmode", "repo": "orgmode", - "rev": "cda615fa7c8607bfb7aaf7d2c9424dd5969f2625", + "rev": "8ec0bcc6f6476d246159f738081256c97a7a9b2c", "type": "github" }, "original": { @@ -1424,11 +1424,11 @@ "plugin-rose-pine": { "flake": false, "locked": { - "lastModified": 1713451685, + "lastModified": 1715697761, "narHash": "sha256-AdPSz5+nCOnLWexBasHuxRxEKbL4WVg+uV78//W5nLs=", "owner": "rose-pine", "repo": "neovim", - "rev": "17b466e79479758b332a3cac12544a3ad2be6241", + "rev": "b6fe88c3282cf9f117a3e836d761c2d78d02f417", "type": "github" }, "original": { @@ -1520,11 +1520,11 @@ "plugin-telescope": { "flake": false, "locked": { - "lastModified": 1714700089, - "narHash": "sha256-SoEetPE7f7Y0kUa4+7dH+EOs/0WBsMDxeOkbVNuoSjE=", + "lastModified": 1715697240, + "narHash": "sha256-lHMbJAQ0ja2UrUantxQOVWMG502oo6QDod7AmpCw1yE=", "owner": "nvim-telescope", "repo": "telescope.nvim", - "rev": "fac83a556e7b710dc31433dec727361ca062dbe9", + "rev": "6f6bb8065567b56c42e283b06e8a1c670c0092a1", "type": "github" }, "original": { @@ -1616,11 +1616,11 @@ "plugin-vim-fugitive": { "flake": false, "locked": { - "lastModified": 1714601825, - "narHash": "sha256-0ujueJ226zEmjkFwodSukO1Zu5gMvTmx/dCtT5VBhek=", + "lastModified": 1715753556, + "narHash": "sha256-icKBJ/1J15h4dNS7NMfjMM/kjMPy8YMiyTI2pGTwYJY=", "owner": "tpope", "repo": "vim-fugitive", - "rev": "ce882460cf3db12e99f8bf579cbf99e331f6dd4f", + "rev": "5b0347b5231a0f40abc311ccaf7bbf02d3ce3a5a", "type": "github" }, "original": { From b5f38b8e5ed2656854acdb69ed95fc65c6d43a20 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 15 May 2024 12:51:07 +0300 Subject: [PATCH 0039/1178] lualine: increase theme compatibility; fix component definitions --- modules/plugins/statusline/lualine/config.nix | 71 +++++----- .../plugins/statusline/lualine/lualine.nix | 130 ++++++++---------- 2 files changed, 96 insertions(+), 105 deletions(-) diff --git a/modules/plugins/statusline/lualine/config.nix b/modules/plugins/statusline/lualine/config.nix index 9578842a..54795959 100644 --- a/modules/plugins/statusline/lualine/config.nix +++ b/modules/plugins/statusline/lualine/config.nix @@ -3,6 +3,7 @@ lib, ... }: let + inherit (builtins) map; inherit (lib.modules) mkIf mkMerge; inherit (lib.trivial) boolToString; inherit (lib.nvim.dag) entryAnywhere; @@ -31,44 +32,46 @@ in { }; }) (mkIf cfg.enable { - vim.startPlugins = [ - "lualine" - ]; + vim = { + startPlugins = ["lualine"]; - vim.luaConfigRC.lualine = entryAnywhere '' - local lualine = require('lualine') - lualine.setup ${toLuaObject cfg.setupOpts} - ''; + luaConfigRC.lualine = entryAnywhere '' + local lualine = require('lualine') + lualine.setup ${toLuaObject cfg.setupOpts} + ''; - # this is for backwards-compatibility - vim.statusline.lualine.setupOpts = { - options = { - icons_enabled = cfg.icons.enable; - theme = cfg.theme; - component_separators = [cfg.componentSeparator.left cfg.componentSeparator.right]; - section_separators = [cfg.sectionSeparator.left cfg.sectionSeparator.right]; - globalstatus = cfg.globalStatus; - refresh = cfg.refresh; - }; + # this is for backwards-compatibility + statusline.lualine.setupOpts = { + options = { + icons_enabled = cfg.icons.enable; + theme = cfg.theme; + component_separators = [cfg.componentSeparator.left cfg.componentSeparator.right]; + section_separators = [cfg.sectionSeparator.left cfg.sectionSeparator.right]; + globalstatus = cfg.globalStatus; + refresh = cfg.refresh; + }; - sections = { - lualine_a = builtins.map mkLuaInline (cfg.activeSection.a ++ cfg.extraActiveSection.a); - lualine_b = builtins.map mkLuaInline (cfg.activeSection.b ++ cfg.extraActiveSection.b); - lualine_c = builtins.map mkLuaInline (cfg.activeSection.c ++ cfg.extraActiveSection.c); - lualine_x = builtins.map mkLuaInline (cfg.activeSection.x ++ cfg.extraActiveSection.x); - lualine_y = builtins.map mkLuaInline (cfg.activeSection.y ++ cfg.extraActiveSection.y); - lualine_z = builtins.map mkLuaInline (cfg.activeSection.z ++ cfg.extraActiveSection.z); + sections = { + lualine_a = map mkLuaInline (cfg.activeSection.a ++ cfg.extraActiveSection.a); + lualine_b = map mkLuaInline (cfg.activeSection.b ++ cfg.extraActiveSection.b); + lualine_c = map mkLuaInline (cfg.activeSection.c ++ cfg.extraActiveSection.c); + lualine_x = map mkLuaInline (cfg.activeSection.x ++ cfg.extraActiveSection.x); + lualine_y = map mkLuaInline (cfg.activeSection.y ++ cfg.extraActiveSection.y); + lualine_z = map mkLuaInline (cfg.activeSection.z ++ cfg.extraActiveSection.z); + }; + + inactive_sections = { + lualine_a = map mkLuaInline (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a); + lualine_b = map mkLuaInline (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b); + lualine_c = map mkLuaInline (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c); + lualine_x = map mkLuaInline (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x); + lualine_y = map mkLuaInline (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y); + lualine_z = map mkLuaInline (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z); + }; + + # probably don't need this? + tabline = []; }; - inactive_sections = { - lualine_a = builtins.map mkLuaInline (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a); - lualine_b = builtins.map mkLuaInline (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b); - lualine_c = builtins.map mkLuaInline (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c); - lualine_x = builtins.map mkLuaInline (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x); - lualine_y = builtins.map mkLuaInline (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y); - lualine_z = builtins.map mkLuaInline (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z); - }; - # probably don't need this? - tabline = []; }; }) ]; diff --git a/modules/plugins/statusline/lualine/lualine.nix b/modules/plugins/statusline/lualine/lualine.nix index 7d1020f7..bf77a82a 100644 --- a/modules/plugins/statusline/lualine/lualine.nix +++ b/modules/plugins/statusline/lualine/lualine.nix @@ -10,19 +10,45 @@ inherit (lib.nvim.types) mkPluginSetupOption; supported_themes = import ./supported_themes.nix; - colorPuccin = - if config.vim.statusline.lualine.theme == "catppuccin" - then "#181825" - else "none"; + builtin_themes = [ + "auto" + "16color" + "gruvbox" + "ayu_dark" + "ayu_light" + "ayu_mirage" + "codedark" + "dracula" + "everforest" + "gruvbox" + "gruvbox_light" + "gruvbox_material" + "horizon" + "iceberg_dark" + "iceberg_light" + "jellybeans" + "material" + "modus_vivendi" + "molokai" + "nightfly" + "nord" + "oceanicnext" + "onelight" + "palenight" + "papercolor_dark" + "papercolor_light" + "powerline" + "seoul256" + "solarized_dark" + "tomorrow" + "wombat" + ]; in { options.vim.statusline.lualine = { + enable = mkEnableOption "lualine statusline plugin"; setupOpts = mkPluginSetupOption "Lualine" {}; - enable = mkEnableOption "lualine statusline plugin"; - - icons = { - enable = mkEnableOption "icons for lualine" // {default = true;}; - }; + icons.enable = mkEnableOption "icons for lualine" // {default = true;}; refresh = { statusline = mkOption { @@ -73,47 +99,15 @@ in { theme = let themeSupported = elem config.vim.theme.name supported_themes; + themesConcatted = builtin_themes ++ optional themeSupported config.vim.theme.name; in mkOption { - description = "Theme for lualine"; - type = enum ([ - "auto" - "16color" - "gruvbox" - "ayu_dark" - "ayu_light" - "ayu_mirage" - "codedark" - "dracula" - "everforest" - "gruvbox" - "gruvbox_light" - "gruvbox_material" - "horizon" - "iceberg_dark" - "iceberg_light" - "jellybeans" - "material" - "modus_vivendi" - "molokai" - "nightfly" - "nord" - "oceanicnext" - "onelight" - "palenight" - "papercolor_dark" - "papercolor_light" - "powerline" - "seoul256" - "solarized_dark" - "tomorrow" - "wombat" - ] - ++ optional themeSupported config.vim.theme.name); + type = enum themesConcatted; default = "auto"; # TODO: xml generation error if the closing '' is on a new line. # issue: https://gitlab.com/rycee/nmd/-/issues/10 defaultText = ''`config.vim.theme.name` if theme supports lualine else "auto"''; + description = "Theme for lualine"; }; sectionSeparator = { @@ -171,15 +165,14 @@ in { "filetype", colored = true, icon_only = true, - icon = { align = 'left' }, - color = {bg='${colorPuccin}', fg='lavender'}, + icon = { align = 'left' } } '' '' { "filename", - color = {bg='${colorPuccin}'}, - symbols = {modified = '', readonly = ''}, + symbols = {modified = ' ', readonly = ' '}, + separator = {right = ''} } '' ]; @@ -200,13 +193,7 @@ in { removed = 'DiffDelete', -- Changes the diff's removed color you }, symbols = {added = '+', modified = '~', removed = '-'}, -- Changes the diff symbols - color = { - bg='${colorPuccin}', - fg='lavender' - }, - separator = { - right = '' - }, + separator = {right = ''} } '' ]; @@ -251,10 +238,6 @@ in { return msg end, icon = ' ', - color = {bg='${colorPuccin}', fg='lavender'}, - separator = { - left = '', - }, } '' '' @@ -262,7 +245,6 @@ in { "diagnostics", sources = {'nvim_lsp', 'nvim_diagnostic', 'coc'}, symbols = {error = '󰅙 ', warn = ' ', info = ' ', hint = '󰌵 '}, - color = {bg='${colorPuccin}', fg='lavender'}, diagnostics_color = { color_error = { fg = 'red' }, color_warn = { fg = 'yellow' }, @@ -282,14 +264,16 @@ in { 'searchcount', maxcount = 999, timeout = 120, - color = {bg='${colorPuccin}', fg='lavender'} + } '' '' { "branch", icon = ' •', - color = {bg='${colorPuccin}', fg='lavender'}, + separator = { + left = '', + }, } '' ]; @@ -300,17 +284,10 @@ in { description = "active config for: | A | B | C X | Y | (Z) |"; default = [ '' - { - "progress", - separator = { - left = '', - }, - } + {"progress"} '' '' - { - "location", - } + {"location"} '' '' { @@ -326,32 +303,38 @@ in { ]; }; }; + extraActiveSection = { a = mkOption { type = listOf str; description = "Extra entries for activeSection.a"; default = []; }; + b = mkOption { type = listOf str; description = "Extra entries for activeSection.b"; default = []; }; + c = mkOption { type = listOf str; description = "Extra entries for activeSection.c"; default = []; }; + x = mkOption { type = listOf str; description = "Extra entries for activeSection.x"; default = []; }; + y = mkOption { type = listOf str; description = "Extra entries for activeSection.y"; default = []; }; + z = mkOption { type = listOf str; description = "Extra entries for activeSection.z"; @@ -402,26 +385,31 @@ in { description = "Extra entries for inactiveSection.a"; default = []; }; + b = mkOption { type = listOf str; description = "Extra entries for inactiveSection.b"; default = []; }; + c = mkOption { type = listOf str; description = "Extra entries for inactiveSection.c"; default = []; }; + x = mkOption { type = listOf str; description = "Extra entries for inactiveSection.x"; default = []; }; + y = mkOption { type = listOf str; description = "Extra entries for inactiveSection.y"; default = []; }; + z = mkOption { type = listOf str; description = "Extra entries for inactiveSection.z"; From 7cafa56cdba4b97df2b57b3ca88a9abe2f29f028 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 15 May 2024 12:53:19 +0300 Subject: [PATCH 0040/1178] docs: update 0.7 release notes --- docs/release-notes/rl-0.7.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 9c5d395e..8f3ffd2b 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -35,3 +35,6 @@ Release notes for release 0.7 to nixpkgs. A pull request is currently open. - Remove vim-tidal and friends + +- Cleaned up Lualine module to reduce theme dependency on Catppuccin, and fixed + blending issues in component separators. From db810bbf9f2d38ec92dc415aab7ac09fdca3913e Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Wed, 15 May 2024 19:37:27 +0200 Subject: [PATCH 0041/1178] languages/ocaml: init --- docs/release-notes/rl-0.7.md | 4 ++ modules/plugins/languages/default.nix | 1 + modules/plugins/languages/ocaml.nix | 56 +++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 modules/plugins/languages/ocaml.nix diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 8f3ffd2b..0a304dd3 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -38,3 +38,7 @@ Release notes for release 0.7 - Cleaned up Lualine module to reduce theme dependency on Catppuccin, and fixed blending issues in component separators. + +[jacekpoz](https://github.com/jacekpoz): + +- Added [ocaml-lsp](https://github.com/ocaml/ocaml-lsp) support. diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 279d46b7..e86a521b 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -14,6 +14,7 @@ in { ./markdown.nix ./nim.nix ./nix.nix + ./ocaml.nix ./php.nix ./python.nix ./rust.nix diff --git a/modules/plugins/languages/ocaml.nix b/modules/plugins/languages/ocaml.nix new file mode 100644 index 00000000..c6ff5a54 --- /dev/null +++ b/modules/plugins/languages/ocaml.nix @@ -0,0 +1,56 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.meta) getExe; + inherit (lib.lists) isList; + inherit (lib.types) either listOf package str; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.lua) expToLua; + + cfg = config.vim.languages.ocaml; +in { + options.vim.languages.ocaml = { + enable = mkEnableOption "OCaml language support"; + + treesitter = { + enable = mkEnableOption "OCaml treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "ocaml"; + }; + + lsp = { + enable = mkEnableOption "OCaml LSP support (ocaml-lsp)" // {default = config.vim.languages.enableLSP;}; + package = mkOption { + description = "ocaml language server package, or the command to run as a list of strings"; + type = either package (listOf str); + default = pkgs.ocamlPackages.ocaml-lsp; + }; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.ocaml-lsp = '' + lspconfig.ocamllsp.setup { + capabilities = capabilities, + on_attach = default_on_attach, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${getExe cfg.lsp.package}"}'' + }; + } + ''; + }) + + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + ]); +} From cc0aba4e218a17fd81b10d957fcd4b5caaf5572e Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Wed, 15 May 2024 20:55:04 +0200 Subject: [PATCH 0042/1178] languages/ocaml: add formatting support --- modules/plugins/languages/ocaml.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/modules/plugins/languages/ocaml.nix b/modules/plugins/languages/ocaml.nix index c6ff5a54..1817cc48 100644 --- a/modules/plugins/languages/ocaml.nix +++ b/modules/plugins/languages/ocaml.nix @@ -30,6 +30,15 @@ in { default = pkgs.ocamlPackages.ocaml-lsp; }; }; + + format = { + enable = mkEnableOption "OCaml formatting support (ocamlformat)" // {default = config.vim.languages.enableFormat;}; + package = mkOption { + description = "OCaml formatter package"; + type = package; + default = pkgs.ocamlPackages.ocamlformat; + }; + }; }; config = mkIf cfg.enable (mkMerge [ @@ -52,5 +61,17 @@ in { vim.treesitter.enable = true; vim.treesitter.grammars = [cfg.treesitter.package]; }) + + (mkIf cfg.format.enable { + vim.lsp.null-ls.enable = true; + vim.lsp.null-ls.sources.ocamlformat = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.ocamlformat.with({ + command = "${cfg.format.package}/bin/ocamlformat", + }) + ) + ''; + }) ]); } From 493854e44ff6860ed8c84aa8aa081d52e97e707f Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 16 May 2024 07:45:15 +0300 Subject: [PATCH 0043/1178] lualine: improve consistency between components; add more diagnostic sources --- .../plugins/statusline/lualine/lualine.nix | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/plugins/statusline/lualine/lualine.nix b/modules/plugins/statusline/lualine/lualine.nix index bf77a82a..ef4018a7 100644 --- a/modules/plugins/statusline/lualine/lualine.nix +++ b/modules/plugins/statusline/lualine/lualine.nix @@ -171,7 +171,7 @@ in { '' { "filename", - symbols = {modified = ' ', readonly = ' '}, + symbols = {modified = ' ', readonly = ' '}, separator = {right = ''} } '' @@ -238,13 +238,17 @@ in { return msg end, icon = ' ', + separator = {left = ''}, } '' '' { "diagnostics", - sources = {'nvim_lsp', 'nvim_diagnostic', 'coc'}, + sources = {'nvim_lsp', 'nvim_diagnostic', 'nvim_diagnostic', 'vim_lsp', 'coc'}, symbols = {error = '󰅙 ', warn = ' ', info = ' ', hint = '󰌵 '}, + colored = true, + update_in_insert = false, + always_visible = false, diagnostics_color = { color_error = { fg = 'red' }, color_warn = { fg = 'yellow' }, @@ -264,16 +268,13 @@ in { 'searchcount', maxcount = 999, timeout = 120, - } '' '' { "branch", icon = ' •', - separator = { - left = '', - }, + separator = {left = ''} } '' ]; @@ -284,7 +285,10 @@ in { description = "active config for: | A | B | C X | Y | (Z) |"; default = [ '' - {"progress"} + { + "progress", + separator = {left = ''} + } '' '' {"location"} @@ -297,7 +301,7 @@ in { unix = '', -- e712 dos = '', -- e70f mac = '', -- e711 - }, + } } '' ]; From 208d1e67414dc189168697a639f118d69b98efd1 Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Thu, 16 May 2024 14:25:07 +0200 Subject: [PATCH 0044/1178] languages/ocaml: follow other languages' format --- modules/plugins/languages/ocaml.nix | 73 ++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/modules/plugins/languages/ocaml.nix b/modules/plugins/languages/ocaml.nix index 1817cc48..4ab901b1 100644 --- a/modules/plugins/languages/ocaml.nix +++ b/modules/plugins/languages/ocaml.nix @@ -4,15 +4,49 @@ lib, ... }: let + inherit (builtins) attrNames; inherit (lib.options) mkEnableOption mkOption; inherit (lib.modules) mkIf mkMerge; inherit (lib.meta) getExe; inherit (lib.lists) isList; - inherit (lib.types) either listOf package str; + inherit (lib.types) either enum listOf package str; inherit (lib.nvim.types) mkGrammarOption; inherit (lib.nvim.lua) expToLua; cfg = config.vim.languages.ocaml; + + defaultServer = "ocaml-lsp"; + servers = { + ocaml-lsp = { + package = pkgs.ocamlPackages.ocaml-lsp; + lspConfig = '' + lspconfig.ocamllsp.setup { + capabilities = capabilities, + on_attach = default_on_attach, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${getExe cfg.lsp.package}"}'' + }; + } + ''; + }; + }; + + defaultFormat = "ocamlformat"; + formats = { + ocamlformat = { + package = pkgs.ocamlPackages.ocamlformat; + nullConfig = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.ocamlformat.with({ + command = "${cfg.format.package}/bin/ocamlformat", + }) + ) + ''; + }; + }; in { options.vim.languages.ocaml = { enable = mkEnableOption "OCaml language support"; @@ -24,19 +58,29 @@ in { lsp = { enable = mkEnableOption "OCaml LSP support (ocaml-lsp)" // {default = config.vim.languages.enableLSP;}; + server = mkOption { + description = "OCaml LSP server to user"; + type = enum (attrNames servers); + default = defaultServer; + }; package = mkOption { - description = "ocaml language server package, or the command to run as a list of strings"; + description = "OCaml language server package, or the command to run as a list of strings"; type = either package (listOf str); - default = pkgs.ocamlPackages.ocaml-lsp; + default = servers.${cfg.lsp.server}.package; }; }; format = { enable = mkEnableOption "OCaml formatting support (ocamlformat)" // {default = config.vim.languages.enableFormat;}; + type = mkOption { + description = "OCaml formatter to use"; + type = enum (attrNames formats); + default = defaultFormat; + }; package = mkOption { description = "OCaml formatter package"; type = package; - default = pkgs.ocamlPackages.ocamlformat; + default = formats.${cfg.format.type}.package; }; }; }; @@ -44,17 +88,7 @@ in { config = mkIf cfg.enable (mkMerge [ (mkIf cfg.lsp.enable { vim.lsp.lspconfig.enable = true; - vim.lsp.lspconfig.sources.ocaml-lsp = '' - lspconfig.ocamllsp.setup { - capabilities = capabilities, - on_attach = default_on_attach, - cmd = ${ - if isList cfg.lsp.package - then expToLua cfg.lsp.package - else ''{"${getExe cfg.lsp.package}"}'' - }; - } - ''; + vim.lsp.lspconfig.sources.ocaml-lsp = servers.${cfg.lsp.server}.lspConfig; }) (mkIf cfg.treesitter.enable { @@ -64,14 +98,7 @@ in { (mkIf cfg.format.enable { vim.lsp.null-ls.enable = true; - vim.lsp.null-ls.sources.ocamlformat = '' - table.insert( - ls_sources, - null_ls.builtins.formatting.ocamlformat.with({ - command = "${cfg.format.package}/bin/ocamlformat", - }) - ) - ''; + vim.lsp.null-ls.sources.ocamlformat = formats.${cfg.format.type}.nullConfig; }) ]); } From f343ab8b3ab42eb7cad63574ac2179d36e3d2578 Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Thu, 16 May 2024 14:25:23 +0200 Subject: [PATCH 0045/1178] languages/ocaml: add formatter to nvf's env --- modules/plugins/languages/ocaml.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/plugins/languages/ocaml.nix b/modules/plugins/languages/ocaml.nix index 4ab901b1..e7064ebf 100644 --- a/modules/plugins/languages/ocaml.nix +++ b/modules/plugins/languages/ocaml.nix @@ -99,6 +99,7 @@ in { (mkIf cfg.format.enable { vim.lsp.null-ls.enable = true; vim.lsp.null-ls.sources.ocamlformat = formats.${cfg.format.type}.nullConfig; + vim.extraPackages = [ formats.${cfg.format.type}.package ]; }) ]); } From 7224c1e6afd23535f8607d292c6d9c70699f752e Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Thu, 16 May 2024 14:36:01 +0200 Subject: [PATCH 0046/1178] languages/ocaml: add ocaml to maximal config --- configuration.nix | 1 + modules/plugins/languages/ocaml.nix | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/configuration.nix b/configuration.nix index e2c02f7b..1d81459d 100644 --- a/configuration.nix +++ b/configuration.nix @@ -73,6 +73,7 @@ inputs: let go.enable = isMaximal; elixir.enable = isMaximal; zig.enable = isMaximal; + ocaml.enable = isMaximal; python.enable = isMaximal; dart.enable = isMaximal; bash.enable = isMaximal; diff --git a/modules/plugins/languages/ocaml.nix b/modules/plugins/languages/ocaml.nix index e7064ebf..ddfa85e4 100644 --- a/modules/plugins/languages/ocaml.nix +++ b/modules/plugins/languages/ocaml.nix @@ -24,10 +24,10 @@ capabilities = capabilities, on_attach = default_on_attach, cmd = ${ - if isList cfg.lsp.package - then expToLua cfg.lsp.package - else ''{"${getExe cfg.lsp.package}"}'' - }; + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${getExe cfg.lsp.package}"}'' + }; } ''; }; @@ -99,7 +99,7 @@ in { (mkIf cfg.format.enable { vim.lsp.null-ls.enable = true; vim.lsp.null-ls.sources.ocamlformat = formats.${cfg.format.type}.nullConfig; - vim.extraPackages = [ formats.${cfg.format.type}.package ]; + vim.extraPackages = [formats.${cfg.format.type}.package]; }) ]); } From 74c94b8a5402e6e1276a22b8df73a2b48bfc1a7c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 16 May 2024 19:08:21 +0300 Subject: [PATCH 0047/1178] flake: fix recursive module alias --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index ae6885ac..cc741b4e 100644 --- a/flake.nix +++ b/flake.nix @@ -47,7 +47,7 @@ nixosModules.neovim-flake has been deprecated. Please use the nixosModules.nvf instead '' - self.nixosModules.neovim-flake; + self.nixosModules.nvf; nvf = { imports = [(import ./flake/modules/nixos.nix self.packages inputs)]; From eefc7a9d1dad0f619198956f8ba899d080ebf4cd Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 16 May 2024 19:09:20 +0300 Subject: [PATCH 0048/1178] lsp/null-lsp: allow null-ls options to be configured This should probably still be converted to setupOpts. Missing docs --- modules/plugins/lsp/null-ls/config.nix | 45 +++++++++++++++---------- modules/plugins/lsp/null-ls/null-ls.nix | 24 ++++++++++++- 2 files changed, 51 insertions(+), 18 deletions(-) diff --git a/modules/plugins/lsp/null-ls/config.nix b/modules/plugins/lsp/null-ls/config.nix index 83dada5b..e0d1694c 100644 --- a/modules/plugins/lsp/null-ls/config.nix +++ b/modules/plugins/lsp/null-ls/config.nix @@ -5,6 +5,7 @@ }: let inherit (lib.modules) mkIf mkMerge; inherit (lib.attrsets) mapAttrs; + inherit (lib.trivial) boolToString; inherit (lib.nvim.dag) entryAnywhere entryAfter entryBetween; cfg = config.vim.lsp; @@ -12,26 +13,36 @@ in { config = mkIf cfg.null-ls.enable (mkMerge [ { vim = { + startPlugins = [ + "none-ls" + "plenary-nvim" + ]; + + # null-ls implies LSP already being set up + # since it will hook into LSPs to receive information lsp.enable = true; - startPlugins = ["none-ls"]; - luaConfigRC.null_ls-setup = entryAnywhere '' - local null_ls = require("null-ls") - local null_helpers = require("null-ls.helpers") - local null_methods = require("null-ls.methods") - local ls_sources = {} - ''; + luaConfigRC = { + # early setup for null-ls + null_ls-setup = entryAnywhere '' + local null_ls = require("null-ls") + local null_helpers = require("null-ls.helpers") + local null_methods = require("null-ls.methods") + local ls_sources = {} + ''; - luaConfigRC.null_ls = entryAfter ["null_ls-setup" "lsp-setup"] '' - require('null-ls').setup({ - debug = false, - diagnostics_format = "[#{m}] #{s} (#{c})", - debounce = 250, - default_timeout = 5000, - sources = ls_sources, - on_attach = default_on_attach - }) - ''; + # null-ls setup + null_ls = entryAfter ["null_ls-setup" "lsp-setup"] '' + require('null-ls').setup({ + debug = ${boolToString cfg.null-ls.debug}, + diagnostics_format = "${cfg.null-ls.diagnostics_format}", + debounce = ${toString cfg.null-ls.debounce}, + default_timeout = ${toString cfg.null-ls.default_timeout}, + sources = ls_sources, + on_attach = default_on_attach + }) + ''; + }; }; } { diff --git a/modules/plugins/lsp/null-ls/null-ls.nix b/modules/plugins/lsp/null-ls/null-ls.nix index 8c63df27..8067e10c 100644 --- a/modules/plugins/lsp/null-ls/null-ls.nix +++ b/modules/plugins/lsp/null-ls/null-ls.nix @@ -1,10 +1,32 @@ {lib, ...}: let inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) attrsOf str; + inherit (lib.types) attrsOf str int; + inherit (lib.generators) mkLuaInline; + inherit (lib.nvim.types) luaInline; in { options.vim.lsp.null-ls = { enable = mkEnableOption "null-ls, also enabled automatically"; + debug = mkEnableOption "debugging information for `null-ls"; + + diagnostics_format = mkOption { + type = luaInline; + default = mkLuaInline "[#{m}] #{s} (#{c})"; + description = "Diagnostic output format for null-ls"; + }; + + debounce = mkOption { + type = int; + default = 250; + description = "Default debounce"; + }; + + default_timeout = mkOption { + type = int; + default = 5000; + description = "Default timeout value, in miliseconds"; + }; + sources = mkOption { description = "null-ls sources"; type = attrsOf str; From 1ce25d7ca3ba3c6d1e080fe36e5e26b85b5e718a Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 16 May 2024 19:11:18 +0300 Subject: [PATCH 0049/1178] modules: reorder args --- modules/default.nix | 2 +- modules/modules.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/default.nix b/modules/default.nix index fa72b9b4..0404bec5 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -25,7 +25,7 @@ inputs: { # check can be disabled while calling this file is called # to avoid checking in all modules nvimModules = import ./modules.nix { - inherit check pkgs; + inherit pkgs check; lib = extendedLib; }; diff --git a/modules/modules.nix b/modules/modules.nix index 0de5984d..a00cea69 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -1,7 +1,7 @@ { + check ? true, pkgs, lib, - check ? true, }: let inherit (lib.modules) mkDefault; inherit (lib.lists) concatLists; From cfbed8ceb1b371292b0c668be84a3aaf268406df Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 16 May 2024 19:13:44 +0300 Subject: [PATCH 0050/1178] modules/wrapper: remove redundant instances of `literalExpression` --- modules/wrapper/build/options.nix | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/modules/wrapper/build/options.nix b/modules/wrapper/build/options.nix index 8816cbeb..39b425db 100644 --- a/modules/wrapper/build/options.nix +++ b/modules/wrapper/build/options.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib.options) mkOption mkEnableOption literalExpression; + inherit (lib.options) mkOption mkEnableOption literalMD; inherit (lib.types) package bool str listOf attrsOf; inherit (lib.nvim.types) pluginsOpt extraPluginType; in { @@ -38,7 +38,7 @@ in { startPlugins = pluginsOpt { default = ["plenary-nvim"]; - example = literalExpression '' + example = '' [pkgs.vimPlugins.telescope-nvim] ''; @@ -54,7 +54,7 @@ in { optPlugins = pluginsOpt { default = []; - example = literalExpression '' + example = '' [pkgs.vimPlugins.vim-ghost] ''; description = '' @@ -80,7 +80,8 @@ in { your custom plugins using nvf's modified DAG library. ''; - example = literalExpression '' + example = literalMD '' + ```nix with pkgs.vimPlugins; { aerial = { package = aerial-nvim; @@ -93,13 +94,14 @@ in { after = ["aerial"]; # place harpoon configuration after aerial }; } + ``` ''; }; extraPackages = mkOption { type = listOf package; default = []; - example = literalExpression ''[pkgs.fzf pkgs.ripgrep]''; + example = ''[pkgs.fzf pkgs.ripgrep]''; description = '' List of additional packages to make available to the Neovim wrapper. @@ -107,7 +109,7 @@ in { }; # this defaults to `true` in the wrapper - # and since we passs this value to the wrapper + # and since we pass this value to the wrapper # with an inherit, it should be `true` here as well withRuby = mkEnableOption '' @@ -118,29 +120,25 @@ in { }; withNodeJs = mkEnableOption '' - NodeJs support in the Neovim wrapper. + NodeJs support in the Neovim wrapper ''; luaPackages = mkOption { type = listOf str; default = []; - example = literalExpression ''["magick" "serpent"]''; - description = '' - List of lua packages to install. - ''; + example = ''["magick" "serpent"]''; + description = "List of lua packages to install"; }; withPython3 = mkEnableOption '' - Python3 support in the Neovim wrapper. + Python3 support in the Neovim wrapper ''; python3Packages = mkOption { type = listOf str; default = []; - example = literalExpression ''["pynvim"]''; - description = '' - List of python packages to install. - ''; + example = ''["pynvim"]''; + description = "List of python packages to install"; }; }; } From f0f2c08e9ff934c19633371e760162b6a29fb67e Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 16 May 2024 19:35:19 +0300 Subject: [PATCH 0051/1178] lsp/null-ls: use string type for diagnostic format --- modules/plugins/lsp/null-ls/null-ls.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/plugins/lsp/null-ls/null-ls.nix b/modules/plugins/lsp/null-ls/null-ls.nix index 8067e10c..7de46a56 100644 --- a/modules/plugins/lsp/null-ls/null-ls.nix +++ b/modules/plugins/lsp/null-ls/null-ls.nix @@ -1,8 +1,6 @@ {lib, ...}: let inherit (lib.options) mkEnableOption mkOption; inherit (lib.types) attrsOf str int; - inherit (lib.generators) mkLuaInline; - inherit (lib.nvim.types) luaInline; in { options.vim.lsp.null-ls = { enable = mkEnableOption "null-ls, also enabled automatically"; @@ -10,8 +8,8 @@ in { debug = mkEnableOption "debugging information for `null-ls"; diagnostics_format = mkOption { - type = luaInline; - default = mkLuaInline "[#{m}] #{s} (#{c})"; + type = str; + default = "[#{m}] #{s} (#{c})"; description = "Diagnostic output format for null-ls"; }; From 9d0247c599fdb60cb5801f8addc478f8046a6caf Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 17 May 2024 19:10:58 +0300 Subject: [PATCH 0052/1178] statusline/lualine: add a left separator to the `searchcount` component --- modules/plugins/statusline/lualine/lualine.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/plugins/statusline/lualine/lualine.nix b/modules/plugins/statusline/lualine/lualine.nix index ef4018a7..7db43e0c 100644 --- a/modules/plugins/statusline/lualine/lualine.nix +++ b/modules/plugins/statusline/lualine/lualine.nix @@ -268,6 +268,7 @@ in { 'searchcount', maxcount = 999, timeout = 120, + separator = {left = ''} } '' '' From af72dc105d9aaef1d20e1dc36e6add4d18c60951 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Sat, 18 May 2024 14:52:40 +0200 Subject: [PATCH 0053/1178] lib: remove unused __empty special case in toLuaObject --- lib/lua.nix | 3 --- modules/wrapper/rc/config.nix | 7 +------ 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/lua.nix b/lib/lua.nix index 8cef5d59..e8713175 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -65,9 +65,6 @@ in rec { then if isLuaInline args then args.expr - # if nobody is using this we should get rid of this - else if hasAttr "__empty" args - then "{ }" else "{" + (concatStringsSep "," diff --git a/modules/wrapper/rc/config.nix b/modules/wrapper/rc/config.nix index b50531b1..c2785626 100644 --- a/modules/wrapper/rc/config.nix +++ b/modules/wrapper/rc/config.nix @@ -60,16 +60,11 @@ config = (attrs) the configuration options for this mapping (noremap, silent...) } */ - normalizeAction = action: let + 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); - in { - config = - if config == {} - then {"__empty" = null;} - else config; action = if action.lua then mkLuaInline action.action From bb06827474f0cc938ea4eecd7177fe467c4da93b Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 18 May 2024 16:45:56 +0300 Subject: [PATCH 0054/1178] flake: switch to nixos-unstable-small --- flake.lock | 8 ++++---- flake.nix | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 32150d7a..469fab70 100644 --- a/flake.lock +++ b/flake.lock @@ -114,16 +114,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1715534503, - "narHash": "sha256-5ZSVkFadZbFP1THataCaSf0JH2cAH3S29hU9rrxTEqk=", + "lastModified": 1715996989, + "narHash": "sha256-ObD9YSelkwCAylEXJHcNjrn3hLOfIVScB1tPz9zeDN8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2057814051972fa1453ddfb0d98badbea9b83c06", + "rev": "63d3e5d82edf5a138e7d0872231cc23ed4e740fd", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-unstable", + "ref": "nixos-unstable-small", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index cc741b4e..88f56154 100644 --- a/flake.nix +++ b/flake.nix @@ -77,7 +77,7 @@ # Flake inputs inputs = { ## Basic Inputs - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable-small"; flake-parts.url = "github:hercules-ci/flake-parts"; flake-utils.url = "github:numtide/flake-utils"; systems.url = "github:nix-systems/default"; From 60d9ebb3f0999e256d414dcd1f9f2523b90f448b Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 18 May 2024 16:49:55 +0300 Subject: [PATCH 0055/1178] flake: bump plugin inputs --- flake.lock | 180 ++++++++++++++++++++++++++--------------------------- 1 file changed, 90 insertions(+), 90 deletions(-) diff --git a/flake.lock b/flake.lock index 469fab70..eeb136e0 100644 --- a/flake.lock +++ b/flake.lock @@ -21,11 +21,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1714641030, - "narHash": "sha256-yzcRNDoyVP7+SCNX0wmuDju1NUCt8Dz9+lyUXEI0dbI=", + "lastModified": 1715865404, + "narHash": "sha256-/GJvTdTpuDjNn84j82cU6bXztE0MSkdnTWClUCRub78=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "e5d10a24b66c3ea8f150e47dfdb0416ab7c3390e", + "rev": "8dc45382d5206bd292f9c2768b8058a8fd8311d9", "type": "github" }, "original": { @@ -114,11 +114,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1715996989, - "narHash": "sha256-ObD9YSelkwCAylEXJHcNjrn3hLOfIVScB1tPz9zeDN8=", + "lastModified": 1716041078, + "narHash": "sha256-ewjE7eVBVmjh8faip3RW+I3WzQZ3iywQVyxZfjunfH0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "63d3e5d82edf5a138e7d0872231cc23ed4e740fd", + "rev": "04496f014fcf27fdcede464d5de8558e12b5710c", "type": "github" }, "original": { @@ -335,11 +335,11 @@ "plugin-cmp-nvim-lsp": { "flake": false, "locked": { - "lastModified": 1702205473, - "narHash": "sha256-/0sh9vJBD9pUuD7q3tNSQ1YLvxFMNykdg5eG+LjZAA8=", + "lastModified": 1715931395, + "narHash": "sha256-CT1+Z4XJBVsl/RqvJeGmyitD6x7So0ylXvvef5jh7I8=", "owner": "hrsh7th", "repo": "cmp-nvim-lsp", - "rev": "5af77f54de1b16c34b23cba810150689a3a90312", + "rev": "39e2eda76828d88b773cc27a3f61d2ad782c922d", "type": "github" }, "original": { @@ -479,11 +479,11 @@ "plugin-dashboard-nvim": { "flake": false, "locked": { - "lastModified": 1714906999, - "narHash": "sha256-euIAtegnJTH2hpFP0OAuvl7VpEV0Xu91h+w9p1uC3+0=", + "lastModified": 1715952164, + "narHash": "sha256-mLQHRzt9vUJLOO15+u7EaE2FGzIm1Ba7fqwdu5zaTYA=", "owner": "glepnir", "repo": "dashboard-nvim", - "rev": "a0a78099658c7d4be3714f657b18ca8285d5d106", + "rev": "5182c09ac8085dc73b78ad0ea9f5479c9a866fc4", "type": "github" }, "original": { @@ -495,11 +495,11 @@ "plugin-diffview-nvim": { "flake": false, "locked": { - "lastModified": 1700506468, - "narHash": "sha256-3EdnBUka9Rh5Brl6TWpN6GlD9z32mmY3Ip+wyiKob/8=", + "lastModified": 1716052902, + "narHash": "sha256-jbAeMJRybHQnsmTY2xeca4QJXXxdYVEK83d8NUSSnfQ=", "owner": "sindrets", "repo": "diffview.nvim", - "rev": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f", + "rev": "9bdd5537575c2ea7925b71ae06585b934beea13d", "type": "github" }, "original": { @@ -527,11 +527,11 @@ "plugin-dressing-nvim": { "flake": false, "locked": { - "lastModified": 1713925216, - "narHash": "sha256-46r7X8CNuMgSB9X1jFLTQAiiBVqszkBP6DPlo6nBAxI=", + "lastModified": 1715888396, + "narHash": "sha256-zL+u9SUwzPZEYxaGZiRnezNUkcr8ZkdOMyGKSXF5xcQ=", "owner": "stevearc", "repo": "dressing.nvim", - "rev": "5162edb1442a729a885c45455a07e9a89058be2f", + "rev": "572314728cb1ce012e825fd66331f52c94acac12", "type": "github" }, "original": { @@ -559,11 +559,11 @@ "plugin-fidget-nvim": { "flake": false, "locked": { - "lastModified": 1712242924, - "narHash": "sha256-fZhK5opGXRRryhNpdaEPLpBq4tTibZREelXmasMLHzw=", + "lastModified": 1716068358, + "narHash": "sha256-WT1KnFXC/jjd9tQEiJ7f5mU9FMK++TSOItxZyl6G8GM=", "owner": "j-hui", "repo": "fidget.nvim", - "rev": "1ba38e4cbb24683973e00c2e36f53ae64da38ef5", + "rev": "a2ece932b663898d4015f458ce7ad92c389690ba", "type": "github" }, "original": { @@ -575,11 +575,11 @@ "plugin-flutter-tools": { "flake": false, "locked": { - "lastModified": 1713525182, - "narHash": "sha256-krcaaDPJsftkrcEov1QdKQUQBH6+PgjNwFamWpmNFkU=", + "lastModified": 1716029468, + "narHash": "sha256-nMP1LVUViKeL2BaYr/oAbqVKmOZ1SomWozKz4OYaovU=", "owner": "akinsho", "repo": "flutter-tools.nvim", - "rev": "f04131d6b2c82c2a7624a8843642d6269b50b437", + "rev": "c19f94576f866888f1b84aa73c690b30de4b86fb", "type": "github" }, "original": { @@ -591,11 +591,11 @@ "plugin-gesture-nvim": { "flake": false, "locked": { - "lastModified": 1715211052, - "narHash": "sha256-vRXQBoKhmYid1M1d4OI/PolwQIwMn1x7EgxeW6Dzj0o=", + "lastModified": 1715776261, + "narHash": "sha256-XgF5BTKR5IiELNqYDvOPIGMw3HtkyNd3K5SOGfYFizY=", "owner": "notomo", "repo": "gesture.nvim", - "rev": "9b3d6361b37628f8869cd237416a1674103c0dc1", + "rev": "3750313a40a752629e3e90f3c3e591969fdab388", "type": "github" }, "original": { @@ -639,11 +639,11 @@ "plugin-gruvbox": { "flake": false, "locked": { - "lastModified": 1715085640, - "narHash": "sha256-2Ad5I+peKCD2BCm4m/QIjqpW08qQvrY+o3bK5UEy1x8=", + "lastModified": 1715974972, + "narHash": "sha256-BDBNeXf189K7l53IaWKWo0eta79cAuYKW0kP6jYfV1w=", "owner": "ellisonleao", "repo": "gruvbox.nvim", - "rev": "c442515506caa166118e157980f62a9ac24fa8c3", + "rev": "4f8e2dc9e8cdfdd3a988227c2c347043a46f51a4", "type": "github" }, "original": { @@ -703,11 +703,11 @@ "plugin-image-nvim": { "flake": false, "locked": { - "lastModified": 1715712794, - "narHash": "sha256-7mZ7a9fU/6RxnzUiYxgIsZA2wGXTalfR2cPBp6kLO3Q=", + "lastModified": 1715966662, + "narHash": "sha256-2f7ss/QTohYSp0EqaFnBtQeOjI+3fIn+Wmgy/TcfbDk=", "owner": "3rd", "repo": "image.nvim", - "rev": "b979fa1194443c97dd8cb6053a4cec163c9048f5", + "rev": "da64ce69598875c9af028afe129f916b02ccc42e", "type": "github" }, "original": { @@ -719,11 +719,11 @@ "plugin-indent-blankline": { "flake": false, "locked": { - "lastModified": 1710388427, - "narHash": "sha256-Xp8ZQBz0in2MX3l0bnLUsSbH0lDPE+QvdmFpBFry5yY=", + "lastModified": 1716042154, + "narHash": "sha256-qlFoZ/GDsbnIhMoT+esNxheC3I9guxiV2DQYlY9kcMM=", "owner": "lukas-reineke", "repo": "indent-blankline.nvim", - "rev": "3d08501caef2329aba5121b753e903904088f7e6", + "rev": "ece00d5fb44d196680a81fd2761062d2fa44663b", "type": "github" }, "original": { @@ -751,11 +751,11 @@ "plugin-lsp-lines": { "flake": false, "locked": { - "lastModified": 1709989705, - "narHash": "sha256-opViLzbwtyUgDoaVKz4z6SN06N8jCQ0YmoqPIht8e64=", + "lastModified": 1715965937, + "narHash": "sha256-C3m91uwldDwaZlYjb6j2sPlvO6ADqhl0AmUWZVYEDHo=", "owner": "~whynothugo", "repo": "lsp_lines.nvim", - "rev": "6f3defec73f7c87939e800e9afa5d0571b19b401", + "rev": "d2facc98064934ebd480cd563212a84d957075fe", "type": "sourcehut" }, "original": { @@ -911,11 +911,11 @@ "plugin-noice-nvim": { "flake": false, "locked": { - "lastModified": 1715763787, - "narHash": "sha256-sn8CiNq9JJXIxB6EEX98XaHhwyBPP7X1zqYMHLgdqd0=", + "lastModified": 1716037348, + "narHash": "sha256-/dtOpAjzgMJHSjV9AZcR991I/r9xaMnpg0/1c6NdItg=", "owner": "folke", "repo": "noice.nvim", - "rev": "61947de3d5904375ea94e0c13db2537488ad9829", + "rev": "9f6f6ba74f8bfbf7e43d6302cf86b070362f6203", "type": "github" }, "original": { @@ -944,11 +944,11 @@ "plugin-nui-nvim": { "flake": false, "locked": { - "lastModified": 1714991123, - "narHash": "sha256-W5w8mWjZhf8rhFYDJX4vPAszxKX6uLgT7+8xg3dY4Ok=", + "lastModified": 1716019714, + "narHash": "sha256-JRVVRT1CZZTjr58L+gAer7eCg9/fMdAD0YD5ljNwl0Q=", "owner": "MunifTanjim", "repo": "nui.nvim", - "rev": "a3597dc88b53489d3fddbddbbd13787355253bb0", + "rev": "b1b3dcd6ed8f355c78bad3d395ff645be5f8b6ae", "type": "github" }, "original": { @@ -960,11 +960,11 @@ "plugin-nvim-autopairs": { "flake": false, "locked": { - "lastModified": 1714895218, - "narHash": "sha256-LMRt1XEoeHB3blfjI0SsQr4goMUmwjoMGS2LcR3ye20=", + "lastModified": 1715818272, + "narHash": "sha256-qcfYChucUpRFKMfB+IphmIPzH/HgobVDK44wDtVXSnU=", "owner": "windwp", "repo": "nvim-autopairs", - "rev": "14e97371b2aab6ee70054c1070a123dfaa3e217e", + "rev": "b0b79e42a28f09719a7da9534c3731fa37319d9b", "type": "github" }, "original": { @@ -992,11 +992,11 @@ "plugin-nvim-cmp": { "flake": false, "locked": { - "lastModified": 1715507122, - "narHash": "sha256-wyHbTXFqvt3kXo+EaHdrEggMDOnw4enAAf4pA9ZQm2g=", + "lastModified": 1715954188, + "narHash": "sha256-GhXfnWqpXFVM7Yi9+qEXHfA6LIMILcMG9pP4VYXuptE=", "owner": "hrsh7th", "repo": "nvim-cmp", - "rev": "24122371810089d390847d8ba66325c1f1aa64c0", + "rev": "5260e5e8ecadaf13e6b82cf867a909f54e15fd07", "type": "github" }, "original": { @@ -1056,11 +1056,11 @@ "plugin-nvim-dap": { "flake": false, "locked": { - "lastModified": 1715700682, - "narHash": "sha256-Gh1Vt8NLZ2MZUUB2EmTWYM0owUrpIpVyzxBgyBOwXWk=", + "lastModified": 1715872903, + "narHash": "sha256-UZm2DA19uBeL2L5JKAZilqBTTPSA5X3ZEcAVJUq65p8=", "owner": "mfussenegger", "repo": "nvim-dap", - "rev": "559d0bbdbc4be4c7e774423061263771be1dbde8", + "rev": "5a2f7121869394502521c52b2bc581ab22c69447", "type": "github" }, "original": { @@ -1120,11 +1120,11 @@ "plugin-nvim-lspconfig": { "flake": false, "locked": { - "lastModified": 1715682701, - "narHash": "sha256-kmo8UfTxarnxZLjL2qOeh4Jo/krxx3uqq073YnsFYxQ=", + "lastModified": 1716002336, + "narHash": "sha256-Ofat8It2TCjxnMPHmQ5fZTeJDpMTIrDMGHXle66IWe8=", "owner": "neovim", "repo": "nvim-lspconfig", - "rev": "a27179f56c6f98a4cdcc79ee2971b514815a4940", + "rev": "6d2ae9fdc3111a6e8fd5db2467aca11737195a30", "type": "github" }, "original": { @@ -1200,11 +1200,11 @@ "plugin-nvim-notify": { "flake": false, "locked": { - "lastModified": 1708161547, - "narHash": "sha256-xJYPOX4YLcWojMCdP1RO22/7FMrbcBQxqxrcVCE2TrU=", + "lastModified": 1715959703, + "narHash": "sha256-wxyHwL/uFdp6w32CVHgSOWkzRrIRuFvWh+J2401RAAA=", "owner": "rcarriga", "repo": "nvim-notify", - "rev": "5371f4bfc1f6d3adf4fe9d62cd3a9d44356bfd15", + "rev": "d333b6f167900f6d9d42a59005d82919830626bf", "type": "github" }, "original": { @@ -1232,11 +1232,11 @@ "plugin-nvim-surround": { "flake": false, "locked": { - "lastModified": 1714506343, - "narHash": "sha256-PJdkmTzuRldPTdaoerdddOL0/+V/KyNSzFBBee6P4kU=", + "lastModified": 1715892699, + "narHash": "sha256-Mg60htwXPqNKu+JnexKiKF3Huvr7pBNdvc6f3Kt2FRA=", "owner": "kylechui", "repo": "nvim-surround", - "rev": "6d0dc3dbb557bcc6a024969da461df4ba803fc48", + "rev": "79aaa42da1f698ed31bcbe7f83081f69dca7ba17", "type": "github" }, "original": { @@ -1264,11 +1264,11 @@ "plugin-nvim-treesitter-context": { "flake": false, "locked": { - "lastModified": 1715659155, - "narHash": "sha256-EYAIm8qicpfvOzg5xPWRwuWMPcUa/hg+q3so+s9sw5g=", + "lastModified": 1715954279, + "narHash": "sha256-CriN45mFfyjTt14RJnmzXidACHJXUaA6XPwAoEtQUzg=", "owner": "nvim-treesitter", "repo": "nvim-treesitter-context", - "rev": "df58c81237ffe2b277e14a1692212162a34e2e2a", + "rev": "55e29081e73d2e4b2d62fb4dc3eebe21bf66a1e2", "type": "github" }, "original": { @@ -1280,11 +1280,11 @@ "plugin-nvim-ts-autotag": { "flake": false, "locked": { - "lastModified": 1707265789, - "narHash": "sha256-cPIEIjcYxX3ZkOyou2mYlHMdhBxCoVTpJVXZtiWe9Ks=", + "lastModified": 1716038325, + "narHash": "sha256-gh+DhC7+8O4z4lG/RIaMJgumnq/Vg5eWa6j/P8MQk0s=", "owner": "windwp", "repo": "nvim-ts-autotag", - "rev": "531f48334c422222aebc888fd36e7d109cb354cd", + "rev": "aeb7090098722ffce16597bd0331105495640153", "type": "github" }, "original": { @@ -1312,11 +1312,11 @@ "plugin-obsidian-nvim": { "flake": false, "locked": { - "lastModified": 1715192893, - "narHash": "sha256-lGnEEFp/MU5sciq6bH5YKAiFx7kf9tTYqE+eB8zvf7A=", + "lastModified": 1715965562, + "narHash": "sha256-PiaPmQ11Wx57ojCG4G50Rwr+phanvuoBqbPHg3N4eGw=", "owner": "epwalsh", "repo": "obsidian.nvim", - "rev": "2e1f03416583232899dc1b6e27673da5e705abef", + "rev": "7b59d907a3ee6952c58e07139cf021a205692338", "type": "github" }, "original": { @@ -1344,11 +1344,11 @@ "plugin-orgmode-nvim": { "flake": false, "locked": { - "lastModified": 1715684611, - "narHash": "sha256-T/vjpYbrq1LTNitnSGGmguVr5UV83AFhNGmeNS2H9J0=", + "lastModified": 1715953175, + "narHash": "sha256-vhygnZNJceJHq4gQm6h0zv/Cgp9+fSeWuL1Varrws1U=", "owner": "nvim-orgmode", "repo": "orgmode", - "rev": "8ec0bcc6f6476d246159f738081256c97a7a9b2c", + "rev": "dbcff9e8d9df48bfff95f7204ca483c11864a755", "type": "github" }, "original": { @@ -1520,11 +1520,11 @@ "plugin-telescope": { "flake": false, "locked": { - "lastModified": 1715697240, - "narHash": "sha256-lHMbJAQ0ja2UrUantxQOVWMG502oo6QDod7AmpCw1yE=", + "lastModified": 1715968939, + "narHash": "sha256-+h0L5vpwXFNDuzE5Dne5zWuKtZ1mquAhdplHcUxPg8w=", "owner": "nvim-telescope", "repo": "telescope.nvim", - "rev": "6f6bb8065567b56c42e283b06e8a1c670c0092a1", + "rev": "0c12735d5aff6a48ffd8111bf144dc2ff44e5975", "type": "github" }, "original": { @@ -1568,11 +1568,11 @@ "plugin-tokyonight": { "flake": false, "locked": { - "lastModified": 1713855116, - "narHash": "sha256-vUEPbgDen3ubcyJZdWCgnChOo1T0LFvZI++8RgGGx1Y=", + "lastModified": 1715879379, + "narHash": "sha256-lJjBsAguMDA765lfxfUwU0I0tWmAESLCv9yiVrhTYDo=", "owner": "folke", "repo": "tokyonight.nvim", - "rev": "67afeaf7fd6ebba000633e89f63c31694057edde", + "rev": "634015fff1457ed66cf5364213a2bbbc51a82d6c", "type": "github" }, "original": { @@ -1616,11 +1616,11 @@ "plugin-vim-fugitive": { "flake": false, "locked": { - "lastModified": 1715753556, - "narHash": "sha256-icKBJ/1J15h4dNS7NMfjMM/kjMPy8YMiyTI2pGTwYJY=", + "lastModified": 1715976636, + "narHash": "sha256-517q3oPvshwUBhXEDuB23S0RPuHvSZWK/1tr6wDhEyA=", "owner": "tpope", "repo": "vim-fugitive", - "rev": "5b0347b5231a0f40abc311ccaf7bbf02d3ce3a5a", + "rev": "5a9bd42dd8dd127779f3cd8982a0419b7ca9c7f5", "type": "github" }, "original": { @@ -1632,11 +1632,11 @@ "plugin-vim-illuminate": { "flake": false, "locked": { - "lastModified": 1713467568, - "narHash": "sha256-o0D1edrsHkaljrzBFZXjdxiK/5ziCGJxM/kYNJgBI1E=", + "lastModified": 1715960194, + "narHash": "sha256-DdJzTHxoOv+vjFymETa2MgXpM/qDwvZjpoo1W8OOBj0=", "owner": "RRethy", "repo": "vim-illuminate", - "rev": "e522e0dd742a83506db0a72e1ced68c9c130f185", + "rev": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa", "type": "github" }, "original": { @@ -1930,11 +1930,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1715170163, - "narHash": "sha256-EuRzY3HI9sMMqPX7Yb7xkZaBoznP0mtS2O/Kk/r6fYk=", + "lastModified": 1715775020, + "narHash": "sha256-CCqc3c3yvXgRaTW18epSHlF2HeikwNXqxnlrRs2sl3Y=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "9c0a853edcab5d60d28784c10b13392d7fabb9d7", + "rev": "03303bf01701b04ec87c55ce5d8d6f5ecf86d0a7", "type": "github" }, "original": { From 011f662fa09b842707afc51920ae8932c6544111 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 19:43:05 +0000 Subject: [PATCH 0056/1178] --- updated-dependencies: - dependency-name: cachix/cachix-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/cachix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cachix.yml b/.github/workflows/cachix.yml index 1142adce..4aa0b215 100644 --- a/.github/workflows/cachix.yml +++ b/.github/workflows/cachix.yml @@ -37,7 +37,7 @@ jobs: uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - - uses: cachix/cachix-action@v14 + - uses: cachix/cachix-action@v15 with: authToken: ${{ secrets.CACHIX_TOKEN }} extraPullNames: nix-community From ac20dfbdd4d1ff1752c6dd7fe10905a5cd8ef049 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Tue, 21 May 2024 06:51:56 -0400 Subject: [PATCH 0057/1178] lib: add deprecation warning for `__empty` --- lib/lua.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/lua.nix b/lib/lua.nix index e8713175..68056b17 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -65,6 +65,11 @@ in rec { then if isLuaInline args then args.expr + else if hasAttr "__empty" args + then + lib.warn '' + Using `__empty` to define an empty lua table is deprecated. Use an empty attrset instead. + '' "{ }" else "{" + (concatStringsSep "," From 69257c03a3a76135971f78ebab9cb54b9b1a823b Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Tue, 21 May 2024 06:55:46 -0400 Subject: [PATCH 0058/1178] docs: add entry for `__empty` deprecation --- docs/release-notes/rl-0.7.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 9c5d395e..5ca93275 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -19,6 +19,8 @@ Release notes for release 0.7 [horriblename](https://github.com/horriblename): - Fix broken treesitter-context keybinds in visual mode +- Depcrecate use of `__empty` to define empty tables in lua. Empty attrset are + no longer filtered and thus should be used instead. [NotAShelf](https://github.com/notashelf) From 68ca227a8767f2141e839b94a8137fa22965184c Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Tue, 21 May 2024 07:08:17 -0400 Subject: [PATCH 0059/1178] lib: remove alias `lib.warn` --- lib/lua.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/lua.nix b/lib/lua.nix index 68056b17..749e9a34 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -3,7 +3,7 @@ inherit (builtins) hasAttr head throw typeOf isList isAttrs isBool isInt isString isPath isFloat toJSON; inherit (lib.attrsets) mapAttrsToList filterAttrs; inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters; - inherit (lib.trivial) boolToString; + inherit (lib.trivial) boolToString warn; in rec { wrapLuaConfig = { luaBefore ? "", @@ -67,7 +67,7 @@ in rec { then args.expr else if hasAttr "__empty" args then - lib.warn '' + warn '' Using `__empty` to define an empty lua table is deprecated. Use an empty attrset instead. '' "{ }" else From 9baebb0d8221dea6effe51a4223558130b4b55ff Mon Sep 17 00:00:00 2001 From: Ching Pei Yang Date: Tue, 21 May 2024 22:55:54 +0200 Subject: [PATCH 0060/1178] colorizer: remove unneeded freeform module --- modules/plugins/ui/colorizer/colorizer.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/plugins/ui/colorizer/colorizer.nix b/modules/plugins/ui/colorizer/colorizer.nix index 62ea28ea..02ab9674 100644 --- a/modules/plugins/ui/colorizer/colorizer.nix +++ b/modules/plugins/ui/colorizer/colorizer.nix @@ -119,9 +119,7 @@ in { AARRGGBB = false; }; }; - type = submodule { - freeformType = attrsOf settingSubmodule; - }; + type = attrsOf settingSubmodule; }; user_default_options = mkOption { From f9343f1bc7f9ac6206ecf6402c29f7c13ea751c4 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 23 May 2024 03:20:05 +0300 Subject: [PATCH 0061/1178] statusline/lualine: equalize padding --- .../plugins/statusline/lualine/lualine.nix | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/plugins/statusline/lualine/lualine.nix b/modules/plugins/statusline/lualine/lualine.nix index 7db43e0c..51357941 100644 --- a/modules/plugins/statusline/lualine/lualine.nix +++ b/modules/plugins/statusline/lualine/lualine.nix @@ -153,6 +153,13 @@ in { }, } '' + '' + { + "", + draw_empty = true, + separator = { left = '', right = '' } + } + '' ]; }; @@ -175,6 +182,13 @@ in { separator = {right = ''} } '' + '' + { + "", + draw_empty = true, + separator = { left = '', right = '' } + } + '' ]; }; @@ -263,6 +277,13 @@ in { type = listOf str; description = "active config for: | A | B | C X | (Y) | Z |"; default = [ + '' + { + "", + draw_empty = true, + separator = { left = '', right = '' } + } + '' '' { 'searchcount', @@ -285,6 +306,13 @@ in { type = listOf str; description = "active config for: | A | B | C X | Y | (Z) |"; default = [ + '' + { + "", + draw_empty = true, + separator = { left = '', right = '' } + } + '' '' { "progress", From 9bbdb8d48a7dfb69937277b43ef00caf0f3f41ff Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 23 May 2024 03:27:23 +0300 Subject: [PATCH 0062/1178] docs/manual: add plugins page This should be helpful for listing known plugin behaviour where the behaviour is undesirable, but also unfixable --- docs/manual/manual.md | 4 ++++ docs/manual/plugins.md | 13 +++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 docs/manual/plugins.md diff --git a/docs/manual/manual.md b/docs/manual/manual.md index 3d80b0c8..905a7242 100644 --- a/docs/manual/manual.md +++ b/docs/manual/manual.md @@ -17,6 +17,10 @@ configuring.md hacking.md ``` +```{=include=} appendix html:into-file=//plugins.html +plugins.md +``` + ```{=include=} appendix html:into-file=//options.html options.md ``` diff --git a/docs/manual/plugins.md b/docs/manual/plugins.md new file mode 100644 index 00000000..e56e59fb --- /dev/null +++ b/docs/manual/plugins.md @@ -0,0 +1,13 @@ +# Plugin specific quirks {#ch-plugins} + +At times, certain plugins refuse to play nicely. Be it as a result of generating +lua from Nix, or the state of packaging. This page shall list any plugins that +are known to misbehave, and potential workarounds. + + From 1061c920beb46ea441624a5c9665a866a9a33228 Mon Sep 17 00:00:00 2001 From: Yoni Firroloni Date: Thu, 23 May 2024 01:32:12 +0000 Subject: [PATCH 0063/1178] docs: add quirk about using nodejs (#298) * doc: add quircks about nodejs * doc: make shorter sentences --- docs/manual/plugins.md | 3 +++ docs/manual/plugins/nodejs.md | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 docs/manual/plugins/nodejs.md diff --git a/docs/manual/plugins.md b/docs/manual/plugins.md index e56e59fb..fa464d18 100644 --- a/docs/manual/plugins.md +++ b/docs/manual/plugins.md @@ -4,6 +4,9 @@ At times, certain plugins refuse to play nicely. Be it as a result of generating lua from Nix, or the state of packaging. This page shall list any plugins that are known to misbehave, and potential workarounds. +```{=include=} chapters +plugins/nodejs.md +``` -## Type of change +## Sanity Checking -Please delete any options that are not relevant. + -- 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 -## Checklist +- 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. - -- [ ] 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 - -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/). - -**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 -``` + From fdd0642c7d83bf43eb2b69c7a7ef3955223342ce Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 6 Oct 2024 01:18:04 +0300 Subject: [PATCH 0176/1178] docs: update 0.7 release notes --- docs/release-notes/rl-0.7.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 0be6ef39..7023371c 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -89,7 +89,8 @@ everyone. - 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` +- Make [neo-tree.nvim] display file icons properly by enabling + `visuals.nvimWebDevicons` [diniamo](https://github.com/diniamo): @@ -206,8 +207,12 @@ everyone. - Fixed `project-nvim` command and keybinding - Added default ikeybind/command for `Telescope resume` (`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): + +- Fix internal breakage in `elixir-tools` setup. From 614ad33a60da7ce7dc61f09fad6afc45664a7cfd Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 6 Oct 2024 01:46:59 +0300 Subject: [PATCH 0177/1178] meta: add changelog reminder to the pull request template --- .github/pull_request_template.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 5f1e4b6c..7768d36e 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -15,10 +15,16 @@ this comment. 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. + +If your pull request includes any change or unexpected behaviour not covered below, please do make sure to include +it above in your description. --> [editorconfig]: https://editorconfig.org +[changelog]: https://github.com/NotAShelf/nvf/tree/main/docs/release-notes +- [ ] 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. @@ -42,3 +48,10 @@ If your changes touch upon a portion of the codebase that you do not understand 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. --> + +--- + +Add a :+1: [reaction] to [pull requests you find important]. + +[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 From 649f5513f942da45bdf66c8a46458992465a5b8c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 6 Oct 2024 02:41:05 +0300 Subject: [PATCH 0178/1178] flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'plugin-catppuccin': 'github:catppuccin/nvim/5215ea59df6d0a7e27da9a5cd1165e06d1b04cbe' (2024-05-26) → 'github:catppuccin/nvim/7be452ee067978cdc8b2c5f3411f0c71ffa612b9' (2024-10-05) --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index bc0859d7..3e267311 100644 --- a/flake.lock +++ b/flake.lock @@ -207,11 +207,11 @@ "plugin-catppuccin": { "flake": false, "locked": { - "lastModified": 1716704960, - "narHash": "sha256-UDPS+1o8FQGkfqiG4GX4DNUI2pU5hIvagmfnWTKDb44=", + "lastModified": 1728131011, + "narHash": "sha256-j6F078taxuGzr3jngrc+Pc5I1kDdxTLMETgq6Xn4w/4=", "owner": "catppuccin", "repo": "nvim", - "rev": "5215ea59df6d0a7e27da9a5cd1165e06d1b04cbe", + "rev": "7be452ee067978cdc8b2c5f3411f0c71ffa612b9", "type": "github" }, "original": { From b637f921d591118b4b60bdc2370b45a6daf0824b Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sun, 6 Oct 2024 11:23:01 +0200 Subject: [PATCH 0179/1178] maps: allow same key on multiple mode (#360) * mappings: add new keymap option * mappings: impl keymap option * doc: update release notes * map: fix misinformation * map: remove redundant variable * fixup! mappings: impl keymap option --- docs/release-notes/rl-0.7.md | 17 +++--- modules/neovim/mappings/config.nix | 89 +++++++++++++++++++++-------- modules/neovim/mappings/options.nix | 72 ++++++++++++----------- modules/wrapper/rc/config.nix | 39 ++----------- 4 files changed, 120 insertions(+), 97 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 060efbab..2ec691bd 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -28,10 +28,10 @@ configuration formats. ### `vim.maps` rewrite {#sec-vim-maps-rewrite} -Instead of specifying map modes using submodules (eg.: `vim.maps.normal`), a new -`mode` option has mode has been introduced. It can be either a string, or a list -of strings, where a string represents the short-name of the map mode(s), that -the mapping should be set for. See `:help map-modes` for more information. +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: @@ -42,10 +42,13 @@ vim.maps.normal."m" = { ... }; has to be replaced by ```nix -vim.maps."m" = { - mode = "n"; +vim.keymaps = [ + { + key = "m"; + mode = "n"; + } ... -}; +]; ``` ### `vim.lsp.nvimCodeActionMenu` removed in favor of `vim.ui.fastaction` {#sec-nvim-code-action-menu-deprecation} diff --git a/modules/neovim/mappings/config.nix b/modules/neovim/mappings/config.nix index 365e1242..4d7f2417 100644 --- a/modules/neovim/mappings/config.nix +++ b/modules/neovim/mappings/config.nix @@ -3,32 +3,75 @@ lib, ... }: 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; in { config = { - vim.maps = mkIf cfg.disableArrows { - "" = { - mode = ["n" "i"]; - action = ""; - noremap = false; - }; - "" = { - mode = ["n" "i"]; - action = ""; - noremap = false; - }; - "" = { - mode = ["n" "i"]; - action = ""; - noremap = false; - }; - "" = { - mode = ["n" "i"]; - action = ""; - noremap = false; - }; - }; + vim.keymaps = mkMerge [ + ( + mkIf cfg.disableArrows [ + { + key = ""; + mode = ["n" "i"]; + action = ""; + noremap = false; + } + { + key = ""; + mode = ["n" "i"]; + action = ""; + noremap = false; + } + { + key = ""; + mode = ["n" "i"]; + action = ""; + noremap = false; + } + { + key = ""; + mode = ["n" "i"]; + action = ""; + noremap = false; + } + ] + ) + ( + pipe cfg.maps + [ + (mapAttrsToList ( + oldMode: keybinds: + mapAttrsToList ( + key: bind: + bind + // { + inherit key; + mode = legacyMapModes.${oldMode}; + } + ) + keybinds + )) + flatten + ] + ) + ]; }; } diff --git a/modules/neovim/mappings/options.nix b/modules/neovim/mappings/options.nix index f4229916..f05de21b 100644 --- a/modules/neovim/mappings/options.nix +++ b/modules/neovim/mappings/options.nix @@ -1,6 +1,6 @@ {lib, ...}: let inherit (lib.options) mkOption; - inherit (lib.types) either str listOf attrsOf nullOr submodule bool; + inherit (lib.types) either str listOf attrsOf nullOr submodule; inherit (lib.nvim.config) mkBool; mapConfigOptions = { @@ -31,6 +31,10 @@ options = mapConfigOptions // { + key = mkOption { + type = str; + description = "The key that triggers this keybind."; + }; mode = mkOption { type = either str (listOf str); description = '' @@ -38,52 +42,56 @@ See `:help map-modes` for a list of modes. ''; + example = ''`["n" "v" "c"]` for normal, visual and command mode''; }; }; }; - # legacy stuff - mapOption = submodule { - options = mapConfigOptions; - }; - - mapOptions = mode: + legacyMapOption = mode: mkOption { description = "Mappings for ${mode} mode"; - type = attrsOf mapOption; + type = attrsOf (submodule { + options = mapConfigOptions; + }); default = {}; }; in { options.vim = { - maps = mkOption { - type = submodule { - freeformType = attrsOf mapType; - options = { - normal = mapOptions "normal"; - insert = mapOptions "insert"; - select = mapOptions "select"; - visual = mapOptions "visual and select"; - terminal = mapOptions "terminal"; - normalVisualOp = mapOptions "normal, visual, select and operator-pending (same as plain 'map')"; - - visualOnly = mapOptions "visual only"; - operator = mapOptions "operator-pending"; - insertCommand = mapOptions "insert and command-line"; - lang = mapOptions "insert, command-line and lang-arg"; - command = mapOptions "command-line"; - }; - }; - default = {}; + keymaps = mkOption { + type = listOf mapType; description = "Custom keybindings."; example = '' - maps = { - "m" = { + vim.keymaps = [ + { + key = "m"; mode = "n"; silent = true; - action = "make"; - }; # Same as nnoremap m make - }; + action = ":make"; + } + { + key = "l"; + mode = ["n" "x"]; + silent = true; + action = "cnext"; + } + ]; ''; + 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"; }; }; } diff --git a/modules/wrapper/rc/config.nix b/modules/wrapper/rc/config.nix index 6c1936e4..6f9ed1ce 100644 --- a/modules/wrapper/rc/config.nix +++ b/modules/wrapper/rc/config.nix @@ -3,8 +3,8 @@ lib, ... }: let - inherit (builtins) map mapAttrs filter removeAttrs attrNames; - inherit (lib.attrsets) mapAttrsToList filterAttrs attrsToList; + inherit (builtins) map mapAttrs filter; + inherit (lib.attrsets) mapAttrsToList filterAttrs; inherit (lib.strings) concatLines concatMapStringsSep; inherit (lib.trivial) showWarnings; inherit (lib.generators) mkLuaInline; @@ -41,40 +41,9 @@ in { inherit (keymap) desc silent nowait script expr unique noremap; }; - toLuaKeymap = { - name, - value, - }: "vim.keymap.set(${toLuaObject value.mode}, ${toLuaObject name}, ${toLuaObject (getAction value)}, ${toLuaObject (getOpts value)})"; + toLuaKeymap = bind: "vim.keymap.set(${toLuaObject bind.mode}, ${toLuaObject bind.key}, ${toLuaObject (getAction bind)}, ${toLuaObject (getOpts bind)})"; - namedModes = { - "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"]; - }; - - maps = - removeAttrs cfg.maps (attrNames namedModes) - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.normal;}) cfg.maps.normal - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.insert;}) cfg.maps.insert - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.select;}) cfg.maps.select - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.visual;}) cfg.maps.visual - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.terminal;}) cfg.maps.terminal - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.normalVisualOp;}) cfg.maps.normalVisualOp - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.visualOnly;}) cfg.maps.visualOnly - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.operator;}) cfg.maps.operator - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.insertCommand;}) cfg.maps.insertCommand - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.lang;}) cfg.maps.lang - // mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.command;}) cfg.maps.command; - - keymaps = concatLines (map toLuaKeymap (attrsToList (filterAttrs (_: value: value != null) maps))); + keymaps = concatLines (map toLuaKeymap cfg.keymaps); in { vim = { luaConfigRC = { From 7a8b95cf7c65e204ac9986ccf19a7594d737888f Mon Sep 17 00:00:00 2001 From: diniamo <55629891+diniamo@users.noreply.github.com> Date: Sun, 6 Oct 2024 13:35:07 +0200 Subject: [PATCH 0180/1178] Surround setupopts (#402) * surround: fix keymaps * surround: make description multi-line --- docs/release-notes/rl-0.7.md | 2 + modules/plugins/utility/surround/config.nix | 45 ++++------ modules/plugins/utility/surround/surround.nix | 86 +++---------------- 3 files changed, 28 insertions(+), 105 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 2ec691bd..bb9f3d36 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -150,6 +150,8 @@ 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 diff --git a/modules/plugins/utility/surround/config.nix b/modules/plugins/utility/surround/config.nix index 824b8c90..4c98c865 100644 --- a/modules/plugins/utility/surround/config.nix +++ b/modules/plugins/utility/surround/config.nix @@ -3,42 +3,29 @@ lib, ... }: let - inherit (lib.modules) mkIf mkMerge; - inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding; + inherit (lib.modules) mkIf; 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" - ]; + startPlugins = ["nvim-surround"]; + pluginRC.surround = entryAnywhere "require('nvim-surround').setup(${toLuaObject cfg.setupOpts})"; - pluginRC.surround = entryAnywhere '' - require('nvim-surround').setup() - ''; - - maps = { - insert = mkMerge [ - (mkIf (mappings.insert != null) (mkSetBinding mappings.insert "(nvim-surround-insert)")) - (mkIf (mappings.insertLine != null) (mkSetBinding mappings.insertLine "(nvim-surround-insert-line)")) - ]; - normal = mkMerge [ - (mkIf (mappings.normal != null) (mkSetBinding mappings.normal "(nvim-surround-normal)")) - (mkIf (mappings.normalCur != null) (mkSetBinding mappings.normalCur "(nvim-surround-normal-cur)")) - (mkIf (mappings.normalLine != null) (mkSetBinding mappings.normalLine "(nvim-surround-normal-line)")) - (mkIf (mappings.normalCurLine != null) (mkSetBinding mappings.normalCurLine "(nvim-surround-normal-cur-line)")) - (mkIf (mappings.delete != null) (mkSetBinding mappings.delete "(nvim-surround-delete)")) - (mkIf (mappings.change != null) (mkSetBinding mappings.change "(nvim-surround-change)")) - ]; - visualOnly = mkMerge [ - (mkIf (mappings.visual != null) (mkSetBinding mappings.visual "(nvim-surround-visual)")) - (mkIf (mappings.visualLine != null) (mkSetBinding mappings.visualLine "(nvim-surround-visual-line)")) - ]; + utility.surround.setupOpts.keymaps = mkIf cfg.useVendoredKeybindings { + insert = "z"; + insert_line = "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"; }; }; }; diff --git a/modules/plugins/utility/surround/surround.nix b/modules/plugins/utility/surround/surround.nix index 8024c9b4..7d006381 100644 --- a/modules/plugins/utility/surround/surround.nix +++ b/modules/plugins/utility/surround/surround.nix @@ -1,90 +1,24 @@ -{ - lib, - config, - ... -}: let - inherit (lib.modules) mkIf mkDefault; +{lib, ...}: let inherit (lib.options) mkOption; - inherit (lib.types) bool nullOr str; + inherit (lib.types) bool; + inherit (lib.nvim.types) mkPluginSetupOption; 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 = "z"; - description = "Add surround character around the cursor"; - }; - insertLine = mkOption { - type = nullOr str; - default = "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; - }); }; } From b39b84490ff21003358afd78ed5bce1cb83b4722 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Sun, 6 Oct 2024 16:03:21 +0200 Subject: [PATCH 0181/1178] Docs/map rewrite (#403) * doc: fix formatting * docs: update keymaps section --- docs/manual/hacking/keybinds.md | 27 ++++++++------------------- modules/neovim/mappings/options.nix | 4 ++-- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/docs/manual/hacking/keybinds.md b/docs/manual/hacking/keybinds.md index f4a51499..63a05d64 100644 --- a/docs/manual/hacking/keybinds.md +++ b/docs/manual/hacking/keybinds.md @@ -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} -To set a mapping, you should define it in `vim.maps.<>`. -The available modes are: - -- normal -- insert -- select -- visual -- terminal -- normalVisualOp -- visualOnly -- operator -- insertCommand -- lang -- command +To set a mapping, you should define it in `vim.keymaps`. An example, simple keybinding, can look like this: ```nix { - vim.maps.normal = { - "wq" = { + vim.keymaps = [ + { + key = "wq"; + mode = ["n"]; action = ":wq"; 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.maps.command._name_.action) +[documentation](https://notashelf.github.io/nvf/options.html#opt-vim.keymaps) to see a list of them. **nvf** provides a list of helper commands, so that you don't have to write the diff --git a/modules/neovim/mappings/options.nix b/modules/neovim/mappings/options.nix index f05de21b..8f0e8ebf 100644 --- a/modules/neovim/mappings/options.nix +++ b/modules/neovim/mappings/options.nix @@ -1,5 +1,5 @@ {lib, ...}: let - inherit (lib.options) mkOption; + inherit (lib.options) mkOption literalMD; inherit (lib.types) either str listOf attrsOf nullOr submodule; inherit (lib.nvim.config) mkBool; @@ -42,7 +42,7 @@ See `:help map-modes` for a list of modes. ''; - example = ''`["n" "v" "c"]` for normal, visual and command mode''; + example = literalMD ''`["n" "v" "c"]` for normal, visual and command mode''; }; }; }; From e77632e4eb2044acc58398eb7f6a14b1b8a4b184 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Mon, 7 Oct 2024 01:19:39 +0200 Subject: [PATCH 0182/1178] lib: remove pointless type restriction (#408) --- lib/types/plugins.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index 7d24163e..656b7ab8 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -97,7 +97,7 @@ in { default = {}; type = submodule { - freeformType = attrsOf anything; + freeformType = anything; options = opts; }; }; From 0947ab38c0bc79780eec599161306157b8de74a3 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Tue, 8 Oct 2024 11:16:19 +0200 Subject: [PATCH 0183/1178] configuration: enable lua for maximal (#411) * configuration: enable lua for maximal --- Co-authored-by: raf --- configuration.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/configuration.nix b/configuration.nix index b21b26aa..f56061bc 100644 --- a/configuration.nix +++ b/configuration.nix @@ -54,6 +54,7 @@ isMaximal: { ts.enable = isMaximal; svelte.enable = isMaximal; go.enable = isMaximal; + lua.enable = isMaximal; elixir.enable = isMaximal; zig.enable = isMaximal; ocaml.enable = isMaximal; From 7dbd1cd8d1542eb231dda82c7e33e29af450e30b Mon Sep 17 00:00:00 2001 From: diniamo <55629891+diniamo@users.noreply.github.com> Date: Wed, 9 Oct 2024 19:50:34 +0200 Subject: [PATCH 0184/1178] treewide: rewrite autocompletion module and related stuff (#404) * modules/completion: rewrite * treewide: remove vsnip, add luasnip * nvim-cmp: add default sorting * nvim-cmp: load after luasnip * lib: fix docs for mergelessListOf * docs: add changelog entires for rewrite * deprecations: add rewrite deprecations * nvim-cmp: clarify in format description * docs: fix option reference in release notes * treewide: remove reduant `// {default = false;}`s * luasnip: add missing `{option}` for option reference * deprecations: add entry for vsnip * nvim-autopairs: use multiline string * nvim-dap: use outer attribute --- configuration.nix | 8 +- docs/release-notes/rl-0.7.md | 32 +- flake.lock | 85 +++-- flake.nix | 19 +- lib/attrsets.nix | 5 + lib/default.nix | 1 + lib/languages.nix | 32 +- lib/types/{types.nix => custom.nix} | 16 +- lib/types/default.nix | 4 +- modules/extra/deprecations.nix | 23 +- modules/plugins/assistant/copilot/config.nix | 2 + .../autopairs/nvim-autopairs/config.nix | 15 +- .../nvim-autopairs/nvim-autopairs.nix | 17 +- .../plugins/completion/nvim-cmp/config.nix | 329 ++++++------------ .../plugins/completion/nvim-cmp/default.nix | 2 +- .../plugins/completion/nvim-cmp/nvim-cmp.nix | 151 ++++---- modules/plugins/debugger/nvim-dap/config.nix | 90 ++--- modules/plugins/languages/rust.nix | 4 +- modules/plugins/lsp/config.nix | 4 +- modules/plugins/lsp/lspkind/config.nix | 34 +- modules/plugins/lsp/lspkind/lspkind.nix | 16 +- modules/plugins/notes/obsidian/obsidian.nix | 4 +- modules/plugins/snippets/default.nix | 2 +- modules/plugins/snippets/luasnip/config.nix | 17 + modules/plugins/snippets/luasnip/default.nix | 6 + modules/plugins/snippets/luasnip/luasnip.nix | 36 ++ modules/plugins/snippets/vsnip/config.nix | 13 - modules/plugins/snippets/vsnip/default.nix | 5 - modules/plugins/snippets/vsnip/vsnip.nix | 7 - modules/plugins/theme/theme.nix | 8 +- modules/plugins/treesitter/config.nix | 4 +- modules/plugins/ui/noice/noice.nix | 2 +- modules/wrapper/rc/config.nix | 2 +- 33 files changed, 512 insertions(+), 483 deletions(-) create mode 100644 lib/attrsets.nix rename lib/types/{types.nix => custom.nix} (85%) create mode 100644 modules/plugins/snippets/luasnip/config.nix create mode 100644 modules/plugins/snippets/luasnip/default.nix create mode 100644 modules/plugins/snippets/luasnip/luasnip.nix delete mode 100644 modules/plugins/snippets/vsnip/config.nix delete mode 100644 modules/plugins/snippets/vsnip/default.nix delete mode 100644 modules/plugins/snippets/vsnip/vsnip.nix diff --git a/configuration.nix b/configuration.nix index b21b26aa..797edba3 100644 --- a/configuration.nix +++ b/configuration.nix @@ -105,12 +105,10 @@ isMaximal: { transparent = false; }; - autopairs.enable = true; + autopairs.nvim-autopairs.enable = true; - autocomplete = { - enable = true; - type = "nvim-cmp"; - }; + autocomplete.nvim-cmp.enable = true; + snippets.luasnip.enable = true; filetree = { nvimTree = { diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index bb9f3d36..673fcffc 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -28,10 +28,11 @@ 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. +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: @@ -62,7 +63,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): @@ -150,12 +150,29 @@ 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`. +- 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`. + +- Remove `autopairs.type`, and rename `autopairs.enable` to + `autopairs.nvim-autopairs.enable`. The new + [](#opt-vim.autopairs.nvim-autopairs.enable) supports `setupOpts` format by + default. + +- Refactor of `nvim-cmp` and completion related modules + - Remove `autocomplete.type` in favor of per-plugin enable options such as + [](#opt-vim.autocomplete.nvim-cmp.enable). + - Deprecate legacy Vimsnip in favor of Luasnip, and integrate + friendly-snippets for bundled snippets. [](#opt-vim.snippets.luasnip.enable) + can be used to toggle Luasnip. + - Add sorting function options for completion sources under + [](#opt-vim.autocomplete.nvim-cmp.setupOpts.sorting.comparators) [Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd() - Make Neovim's configuration file entirely Lua based. This comes with a few breaking changes: + - `vim.configRC` has been removed. You will need to migrate your entries to Neovim-compliant Lua code, and add them to `vim.luaConfigRC` instead. Existing vimscript configurations may be preserved in `vim.cmd` functions. @@ -242,10 +259,9 @@ everyone. - 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. - diff --git a/flake.lock b/flake.lock index 3e267311..ad9efefa 100644 --- a/flake.lock +++ b/flake.lock @@ -316,6 +316,22 @@ "type": "github" } }, + "plugin-cmp-luasnip": { + "flake": false, + "locked": { + "lastModified": 1696878902, + "narHash": "sha256-nUJJl2zyK/oSwz5RzI9j3gf9zpDfCImCYbPbVsyXgz8=", + "owner": "saadparwaiz1", + "repo": "cmp_luasnip", + "rev": "05a9ab28b53f71d1aece421ef32fee2cb857a843", + "type": "github" + }, + "original": { + "owner": "saadparwaiz1", + "repo": "cmp_luasnip", + "type": "github" + } + }, "plugin-cmp-nvim-lsp": { "flake": false, "locked": { @@ -364,22 +380,6 @@ "type": "github" } }, - "plugin-cmp-vsnip": { - "flake": false, - "locked": { - "lastModified": 1669100283, - "narHash": "sha256-2mkN03noOr5vBvRbSb35xZKorSH+8savQNZtgM9+QcM=", - "owner": "hrsh7th", - "repo": "cmp-vsnip", - "rev": "989a8a73c44e926199bfd05fa7a516d51f2d2752", - "type": "github" - }, - "original": { - "owner": "hrsh7th", - "repo": "cmp-vsnip", - "type": "github" - } - }, "plugin-codewindow-nvim": { "flake": false, "locked": { @@ -588,6 +588,22 @@ "type": "github" } }, + "plugin-friendly-snippets": { + "flake": false, + "locked": { + "lastModified": 1727061933, + "narHash": "sha256-yTsuV5unoujY0mhLINssYYBWCeefe+nJaxQHJKm7hlk=", + "owner": "rafamadriz", + "repo": "friendly-snippets", + "rev": "00ba9dd3df89509f95437b8d595553707c46d5ea", + "type": "github" + }, + "original": { + "owner": "rafamadriz", + "repo": "friendly-snippets", + "type": "github" + } + }, "plugin-gesture-nvim": { "flake": false, "locked": { @@ -828,6 +844,22 @@ "type": "github" } }, + "plugin-luasnip": { + "flake": false, + "locked": { + "lastModified": 1726165831, + "narHash": "sha256-nkaa1NGOI28Et2QitQB+Spv+J42QVdHE1oywteLcJJw=", + "owner": "L3MON4D3", + "repo": "LuaSnip", + "rev": "e808bee352d1a6fcf902ca1a71cee76e60e24071", + "type": "github" + }, + "original": { + "owner": "L3MON4D3", + "repo": "LuaSnip", + "type": "github" + } + }, "plugin-mind-nvim": { "flake": false, "locked": { @@ -1757,22 +1789,6 @@ "type": "github" } }, - "plugin-vim-vsnip": { - "flake": false, - "locked": { - "lastModified": 1704937299, - "narHash": "sha256-gvm6z4pgSULBVPukewRyjwxZ0vZgreQWbG/0kOB1QBo=", - "owner": "hrsh7th", - "repo": "vim-vsnip", - "rev": "02a8e79295c9733434aab4e0e2b8c4b7cea9f3a9", - "type": "github" - }, - "original": { - "owner": "hrsh7th", - "repo": "vim-vsnip", - "type": "github" - } - }, "plugin-which-key": { "flake": false, "locked": { @@ -1827,10 +1843,10 @@ "plugin-cheatsheet-nvim": "plugin-cheatsheet-nvim", "plugin-cinnamon-nvim": "plugin-cinnamon-nvim", "plugin-cmp-buffer": "plugin-cmp-buffer", + "plugin-cmp-luasnip": "plugin-cmp-luasnip", "plugin-cmp-nvim-lsp": "plugin-cmp-nvim-lsp", "plugin-cmp-path": "plugin-cmp-path", "plugin-cmp-treesitter": "plugin-cmp-treesitter", - "plugin-cmp-vsnip": "plugin-cmp-vsnip", "plugin-codewindow-nvim": "plugin-codewindow-nvim", "plugin-comment-nvim": "plugin-comment-nvim", "plugin-copilot-cmp": "plugin-copilot-cmp", @@ -1844,6 +1860,7 @@ "plugin-fastaction-nvim": "plugin-fastaction-nvim", "plugin-fidget-nvim": "plugin-fidget-nvim", "plugin-flutter-tools": "plugin-flutter-tools", + "plugin-friendly-snippets": "plugin-friendly-snippets", "plugin-gesture-nvim": "plugin-gesture-nvim", "plugin-gitsigns-nvim": "plugin-gitsigns-nvim", "plugin-glow-nvim": "plugin-glow-nvim", @@ -1859,6 +1876,7 @@ "plugin-lspkind": "plugin-lspkind", "plugin-lspsaga": "plugin-lspsaga", "plugin-lualine": "plugin-lualine", + "plugin-luasnip": "plugin-luasnip", "plugin-mind-nvim": "plugin-mind-nvim", "plugin-minimap-vim": "plugin-minimap-vim", "plugin-modes-nvim": "plugin-modes-nvim", @@ -1917,7 +1935,6 @@ "plugin-vim-markdown": "plugin-vim-markdown", "plugin-vim-repeat": "plugin-vim-repeat", "plugin-vim-startify": "plugin-vim-startify", - "plugin-vim-vsnip": "plugin-vim-vsnip", "plugin-which-key": "plugin-which-key", "rnix-lsp": "rnix-lsp", "systems": "systems_2" diff --git a/flake.nix b/flake.nix index c4a1a2a8..53e9e939 100644 --- a/flake.nix +++ b/flake.nix @@ -277,11 +277,6 @@ flake = false; }; - plugin-cmp-vsnip = { - url = "github:hrsh7th/cmp-vsnip"; - flake = false; - }; - plugin-cmp-path = { url = "github:hrsh7th/cmp-path"; flake = false; @@ -292,9 +287,19 @@ flake = false; }; + plugin-cmp-luasnip = { + url = "github:saadparwaiz1/cmp_luasnip"; + flake = false; + }; + # snippets - plugin-vim-vsnip = { - url = "github:hrsh7th/vim-vsnip"; + plugin-luasnip = { + url = "github:L3MON4D3/LuaSnip"; + flake = false; + }; + + plugin-friendly-snippets = { + url = "github:rafamadriz/friendly-snippets"; flake = false; }; diff --git a/lib/attrsets.nix b/lib/attrsets.nix new file mode 100644 index 00000000..59275af9 --- /dev/null +++ b/lib/attrsets.nix @@ -0,0 +1,5 @@ +{lib}: let + inherit (builtins) listToAttrs; +in { + mapListToAttrs = f: list: listToAttrs (map f list); +} diff --git a/lib/default.nix b/lib/default.nix index a418cff8..e6ccd2a7 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -10,6 +10,7 @@ dag = import ./dag.nix {inherit lib;}; languages = import ./languages.nix {inherit lib;}; lists = import ./lists.nix {inherit lib;}; + attrsets = import ./attrsets.nix {inherit lib;}; lua = import ./lua.nix {inherit lib;}; neovimConfiguration = import ../modules {inherit inputs lib;}; } diff --git a/lib/languages.nix b/lib/languages.nix index e47202ee..52f1b5b8 100644 --- a/lib/languages.nix +++ b/lib/languages.nix @@ -2,8 +2,8 @@ {lib}: let inherit (builtins) isString getAttr; inherit (lib.options) mkOption; - inherit (lib.attrsets) listToAttrs; inherit (lib.types) bool; + inherit (lib.nvim.attrsets) mapListToAttrs; in { # Converts a boolean to a yes/no string. This is used in lots of # configuration formats. @@ -12,21 +12,21 @@ in { config, diagnosticsProviders, }: - listToAttrs - (map (v: let - type = - if isString v - then v - else getAttr v.type; - package = - if isString v - then diagnosticsProviders.${type}.package - else v.package; - in { - name = "${lang}-diagnostics-${type}"; - value = diagnosticsProviders.${type}.nullConfig package; - }) - config); + mapListToAttrs + (v: let + type = + if isString v + then v + else getAttr v.type; + package = + if isString v + then diagnosticsProviders.${type}.package + else v.package; + in { + name = "${lang}-diagnostics-${type}"; + value = diagnosticsProviders.${type}.nullConfig package; + }) + config; mkEnable = desc: mkOption { diff --git a/lib/types/types.nix b/lib/types/custom.nix similarity index 85% rename from lib/types/types.nix rename to lib/types/custom.nix index 250d7636..3d4a2bcb 100644 --- a/lib/types/types.nix +++ b/lib/types/custom.nix @@ -1,7 +1,7 @@ {lib}: let - inherit (lib) isStringLike showOption showFiles getFiles mergeOneOption mergeEqualOption mkOptionType; - inherit (lib.strings) isString; - inherit (lib.types) anything attrsOf; + inherit (lib.options) showOption showFiles getFiles mergeOneOption mergeEqualOption; + inherit (lib.strings) isString isStringLike; + inherit (lib.types) anything attrsOf listOf mkOptionType; inherit (lib.nvim.types) anythingConcatLists; inherit (builtins) typeOf isAttrs any head concatLists stringLength match; in { @@ -52,6 +52,16 @@ in { (mergeFunctions.${commonType} or mergeEqualOption) loc defs; }; + mergelessListOf = elemType: let + super = listOf elemType; + in + super + // { + name = "mergelessListOf"; + description = "mergeless ${super.description}"; + merge = mergeEqualOption; + }; + char = mkOptionType { name = "char"; description = "character"; diff --git a/lib/types/default.nix b/lib/types/default.nix index 70ca6bef..73b35956 100644 --- a/lib/types/default.nix +++ b/lib/types/default.nix @@ -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;}; + customTypes = 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 (customTypes) anythingConcatLists char hexColor mergelessListOf; } diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index 388913a7..c4ff4d30 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -1,5 +1,5 @@ {lib, ...}: let - inherit (lib.modules) mkRemovedOptionModule; + inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule; in { imports = [ # 2024-06-06 @@ -14,5 +14,26 @@ in { available under `vim.ui.fastaction` as a replacement. Simply remove everything under `vim.lsp.nvimCodeActionMenu`, and set `vim.ui.fastaction.enable` to `true`. '') + + (mkRemovedOptionModule ["vim" "autopairs" "enable"] '' + vim.autopairs.enable has been removed in favor of per-plugin modules. + You can enable nvim-autopairs with vim.autopairs.nvim-autopairs.enable instead. + '') + (mkRemovedOptionModule ["vim" "autopairs" "type"] '' + vim.autopairs.type has been removed in favor of per-plugin modules. + You can enable nvim-autopairs with vim.autopairs.nvim-autopairs.enable instead. + '') + (mkRemovedOptionModule ["vim" "autocomplete" "enable"] '' + vim.autocomplete.enable has been removed in favor of per-plugin modules. + You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead. + '') + (mkRemovedOptionModule ["vim" "autocomplete" "type"] '' + vim.autocomplete.type has been removed in favor of per-plugin modules. + You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead. + '') + (mkRemovedOptionModule ["vim" "snippets" "vsnip" "enable"] '' + vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip. + '') + (mkRenamedOptionModule ["vim" "lsp" "lspkind" "mode"] ["vim" "lsp" "lspkind" "setupOpts" "mode"]) ]; } diff --git a/modules/plugins/assistant/copilot/config.nix b/modules/plugins/assistant/copilot/config.nix index c9e6f830..923a0c6d 100644 --- a/modules/plugins/assistant/copilot/config.nix +++ b/modules/plugins/assistant/copilot/config.nix @@ -34,6 +34,8 @@ in { "copilot-cmp" ]; + vim.autocomplete.nvim-cmp.sources = {copilot = "[Copilot]";}; + vim.pluginRC.copilot = entryAnywhere '' require("copilot").setup(${toLuaObject cfg.setupOpts}) diff --git a/modules/plugins/autopairs/nvim-autopairs/config.nix b/modules/plugins/autopairs/nvim-autopairs/config.nix index 6ef7cbfb..6566ec28 100644 --- a/modules/plugins/autopairs/nvim-autopairs/config.nix +++ b/modules/plugins/autopairs/nvim-autopairs/config.nix @@ -4,16 +4,17 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.trivial) boolToString; inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; - cfg = config.vim.autopairs; + cfg = config.vim.autopairs.nvim-autopairs; in { config = mkIf cfg.enable { - vim.startPlugins = ["nvim-autopairs"]; - - vim.pluginRC.autopairs = entryAnywhere '' - require("nvim-autopairs").setup({ map_cr = ${boolToString (!config.vim.autocomplete.enable)} }) - ''; + vim = { + startPlugins = ["nvim-autopairs"]; + pluginRC.autopairs = entryAnywhere '' + require('nvim-autopairs').setup(${toLuaObject cfg.setupOpts}) + ''; + }; }; } diff --git a/modules/plugins/autopairs/nvim-autopairs/nvim-autopairs.nix b/modules/plugins/autopairs/nvim-autopairs/nvim-autopairs.nix index 7e456063..d3a2bc7f 100644 --- a/modules/plugins/autopairs/nvim-autopairs/nvim-autopairs.nix +++ b/modules/plugins/autopairs/nvim-autopairs/nvim-autopairs.nix @@ -1,21 +1,14 @@ {lib, ...}: let inherit (lib) mkRemovedOptionModule; - inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) enum; + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.types) mkPluginSetupOption; in { imports = [ (mkRemovedOptionModule ["vim" "autopairs" "nvim-compe"] "nvim-compe is deprecated and no longer suported.") ]; - options.vim = { - autopairs = { - enable = mkEnableOption "autopairs" // {default = false;}; - - type = mkOption { - type = enum ["nvim-autopairs"]; - default = "nvim-autopairs"; - description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]"; - }; - }; + options.vim.autopairs.nvim-autopairs = { + enable = mkEnableOption "autopairs"; + setupOpts = mkPluginSetupOption "nvim-autopairs" {}; }; } diff --git a/modules/plugins/completion/nvim-cmp/config.nix b/modules/plugins/completion/nvim-cmp/config.nix index a28db3ed..ffd15fe4 100644 --- a/modules/plugins/completion/nvim-cmp/config.nix +++ b/modules/plugins/completion/nvim-cmp/config.nix @@ -3,246 +3,115 @@ config, ... }: let - inherit (builtins) toJSON; - inherit (lib.modules) mkIf mkMerge; - inherit (lib.attrsets) attrNames mapAttrsToList; - inherit (lib.strings) concatMapStringsSep concatStringsSep optionalString; - inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding; - inherit (lib.nvim.dag) entryAnywhere entryAfter; + inherit (lib.modules) mkIf; + inherit (lib.strings) optionalString; + inherit (lib.generators) mkLuaInline; + inherit (lib.nvim.binds) addDescriptionsToMappings; + inherit (lib.nvim.dag) entryAfter; + inherit (lib.nvim.lua) toLuaObject; + inherit (builtins) attrNames; - cfg = config.vim.autocomplete; - lspkindEnabled = config.vim.lsp.enable && config.vim.lsp.lspkind.enable; - - self = import ./nvim-cmp.nix {inherit lib;}; - mappingDefinitions = self.options.vim.autocomplete.mappings; + cfg = config.vim.autocomplete.nvim-cmp; + luasnipEnable = config.vim.snippets.luasnip.enable; + self = import ./nvim-cmp.nix {inherit lib config;}; + mappingDefinitions = self.options.vim.autocomplete.nvim-cmp.mappings; mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; - - builtSources = - concatMapStringsSep - "\n" - (n: "{ name = '${n}'},") - (attrNames cfg.sources); - - builtMaps = - concatStringsSep - "\n" - (mapAttrsToList - (n: v: - if v == null - then "" - else "${n} = '${v}',") - cfg.sources); - - dagPlacement = - if lspkindEnabled - then entryAfter ["lspkind"] - else entryAnywhere; in { config = mkIf cfg.enable { - vim.startPlugins = [ - "nvim-cmp" - "cmp-buffer" - "cmp-vsnip" - "cmp-path" - "vim-vsnip" - ]; + vim = { + startPlugins = [ + "nvim-cmp" + "cmp-buffer" + "cmp-path" + ]; - vim.autocomplete.sources = { - "nvim-cmp" = null; - "vsnip" = "[VSnip]"; - "buffer" = "[Buffer]"; - "crates" = "[Crates]"; - "path" = "[Path]"; - "copilot" = "[Copilot]"; - }; + autocomplete.nvim-cmp.sources = { + nvim-cmp = null; + buffer = "[Buffer]"; + path = "[Path]"; + }; - vim.maps.insert = mkMerge [ - (mkSetLuaBinding mappings.complete '' - require('cmp').complete - '') - (let - defaultKeys = - if config.vim.autopairs.enable - then "require('nvim-autopairs').autopairs_cr()" - else "vim.api.nvim_replace_termcodes(${toJSON mappings.confirm.value}, true, false, true)"; - in - mkSetLuaBinding mappings.confirm '' - function() - if not require('cmp').confirm({ select = true }) then - vim.fn.feedkeys(${defaultKeys}, 'n') + autocomplete.nvim-cmp.setupOpts = { + sources = map (s: {name = s;}) (attrNames cfg.sources); + + # TODO: try to get nvim-cmp to follow global border style + window = mkIf config.vim.ui.borders.enable { + completion = mkLuaInline "cmp.config.window.bordered()"; + documentation = mkLuaInline "cmp.config.window.bordered()"; + }; + + formatting.format = cfg.format; + }; + + pluginRC.nvim-cmp = mkIf cfg.enable (entryAfter ["autopairs" "luasnip"] '' + local luasnip = require("luasnip") + local cmp = require("cmp") + cmp.setup(${toLuaObject cfg.setupOpts}) + ''); + + # `cmp` and `luasnip` are defined above, in the `nvim-cmp` section + autocomplete.nvim-cmp.setupOpts.mapping = { + ${mappings.complete.value} = mkLuaInline "cmp.mapping.complete()"; + ${mappings.close.value} = mkLuaInline "cmp.mapping.abort()"; + ${mappings.scrollDocsUp.value} = mkLuaInline "cmp.mapping.scroll_docs(-4)"; + ${mappings.scrollDocsDown.value} = mkLuaInline "cmp.mapping.scroll_docs(4)"; + + ${mappings.confirm.value} = mkLuaInline '' + cmp.mapping(function(fallback) + if cmp.visible() then + ${ + if luasnipEnable + then '' + if luasnip.expandable() then + luasnip.expand() + else + cmp.confirm({ select = true }) + end + '' + else "cmp.confirm({ select = true })" + } + else + fallback() end - end - '') - (mkSetLuaBinding mappings.next '' - function() - local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil - end + end) + ''; - local cmp = require('cmp') + ${mappings.next.value} = mkLuaInline '' + cmp.mapping(function(fallback) + local has_words_before = function() + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + end - local feedkey = function(key, mode) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) - end + if cmp.visible() then + cmp.select_next_item() + ${optionalString luasnipEnable '' + elseif luasnip.locally_jumpable(1) then + luasnip.jump(1) + ''} + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end) + ''; - if cmp.visible() then - cmp.select_next_item() - elseif vim.fn['vsnip#available'](1) == 1 then - feedkey("(vsnip-expand-or-jump)", "") - elseif has_words_before() then - cmp.complete() - else - local termcode = vim.api.nvim_replace_termcodes(${toJSON mappings.next.value}, true, false, true) - - vim.fn.feedkeys(termcode, 'n') - end - end - '') - (mkSetLuaBinding mappings.previous '' - function() - local cmp = require('cmp') - - local feedkey = function(key, mode) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) - end - - if cmp.visible() then - cmp.select_prev_item() - elseif vim.fn['vsnip#available'](-1) == 1 then - feedkeys("(vsnip-jump-prev)", "") - end - end - '') - (mkSetLuaBinding mappings.close '' - require('cmp').mapping.abort() - '') - (mkSetLuaBinding mappings.scrollDocsUp '' - require('cmp').mapping.scroll_docs(-4) - '') - (mkSetLuaBinding mappings.scrollDocsDown '' - require('cmp').mapping.scroll_docs(4) - '') - ]; - - vim.maps.command = mkMerge [ - (mkSetLuaBinding mappings.complete '' - require('cmp').complete - '') - (mkSetLuaBinding mappings.close '' - require('cmp').mapping.close() - '') - (mkSetLuaBinding mappings.scrollDocsUp '' - require('cmp').mapping.scroll_docs(-4) - '') - (mkSetLuaBinding mappings.scrollDocsDown '' - require('cmp').mapping.scroll_docs(4) - '') - ]; - - vim.maps.select = mkMerge [ - (mkSetLuaBinding mappings.next '' - function() - local cmp = require('cmp') - local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil - end - - local feedkey = function(key, mode) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) - end - - if cmp.visible() then - cmp.select_next_item() - elseif vim.fn['vsnip#available'](1) == 1 then - feedkey("(vsnip-expand-or-jump)", "") - elseif has_words_before() then - cmp.complete() - else - local termcode = vim.api.nvim_replace_termcodes(${toJSON mappings.next.value}, true, false, true) - - vim.fn.feedkeys(termcode, 'n') - end - end - '') - (mkSetLuaBinding mappings.previous '' - function() - local cmp = require('cmp') - - local feedkey = function(key, mode) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) - end - - if cmp.visible() then - cmp.select_prev_item() - elseif vim.fn['vsnip#available'](-1) == 1 then - feedkeys("(vsnip-jump-prev)", "") - end - end - '') - ]; - - # TODO: alternative snippet engines to vsnip - # https://github.com/hrsh7th/nvim-cmp/blob/main/doc/cmp.txt#L82 - vim.pluginRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement '' - local nvim_cmp_menu_map = function(entry, vim_item) - -- name for each source - vim_item.menu = ({ - ${builtMaps} - })[entry.source.name] - return vim_item - end - - ${optionalString lspkindEnabled '' - lspkind_opts.before = ${cfg.formatting.format} - ''} - - local cmp = require'cmp' - cmp.setup({ - ${optionalString config.vim.ui.borders.enable '' - -- explicitly enabled by setting ui.borders.enable = true - -- TODO: try to get nvim-cmp to follow global border style - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - ''} - - snippet = { - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) - end, - }, - - sources = { - ${builtSources} - }, - - completion = { - completeopt = 'menu,menuone,noinsert', - ${optionalString (!cfg.alwaysComplete) "autocomplete = false"} - }, - - formatting = { - format = - ${ - if lspkindEnabled - then "lspkind.cmp_format(lspkind_opts)" - else cfg.formatting.format - }, - } - }) - ${optionalString (config.vim.autopairs.enable && config.vim.autopairs.type == "nvim-autopairs") '' - local cmp_autopairs = require('nvim-autopairs.completion.cmp') - cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { text = ""} })) - ''} - ''); - - vim.snippets.vsnip.enable = - if (cfg.type == "nvim-cmp") - then true - else config.vim.snippets.vsnip.enable; + ${mappings.previous.value} = mkLuaInline '' + cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + ${optionalString luasnipEnable '' + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + ''} + else + fallback() + end + end) + ''; + }; + }; }; } diff --git a/modules/plugins/completion/nvim-cmp/default.nix b/modules/plugins/completion/nvim-cmp/default.nix index 603347f4..65578c38 100644 --- a/modules/plugins/completion/nvim-cmp/default.nix +++ b/modules/plugins/completion/nvim-cmp/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./nvim-cmp.nix diff --git a/modules/plugins/completion/nvim-cmp/nvim-cmp.nix b/modules/plugins/completion/nvim-cmp/nvim-cmp.nix index 8efa649f..860a1c3f 100644 --- a/modules/plugins/completion/nvim-cmp/nvim-cmp.nix +++ b/modules/plugins/completion/nvim-cmp/nvim-cmp.nix @@ -1,72 +1,103 @@ -{lib, ...}: let - inherit (lib.options) mkEnableOption mkOption literalMD; +{ + lib, + config, + ... +}: let + inherit (lib.options) mkEnableOption mkOption literalExpression literalMD; + inherit (lib.types) str attrsOf nullOr either; + inherit (lib.generators) mkLuaInline; inherit (lib.nvim.binds) mkMappingOption; - inherit (lib.types) enum attrsOf nullOr str bool; + inherit (lib.nvim.types) mkPluginSetupOption luaInline mergelessListOf; + inherit (lib.nvim.lua) toLuaObject; + inherit (builtins) isString; + + cfg = config.vim.autocomplete.nvim-cmp; in { - options.vim = { - autocomplete = { - enable = mkEnableOption "autocomplete" // {default = false;}; - - alwaysComplete = mkOption { - type = bool; - description = "Automatically show completion."; - default = true; - }; - - mappings = { - complete = mkMappingOption "Complete [nvim-cmp]" ""; - confirm = mkMappingOption "Confirm [nvim-cmp]" ""; - next = mkMappingOption "Next item [nvim-cmp]" ""; - previous = mkMappingOption "Previous item [nvim-cmp]" ""; - close = mkMappingOption "Close [nvim-cmp]" ""; - scrollDocsUp = mkMappingOption "Scroll docs up [nvim-cmp]" ""; - scrollDocsDown = mkMappingOption "Scroll docs down [nvim-cmp]" ""; - }; - - type = mkOption { - type = enum ["nvim-cmp"]; - default = "nvim-cmp"; - description = "Set the autocomplete plugin. Options: [nvim-cmp]"; - }; - - sources = mkOption { + options.vim.autocomplete.nvim-cmp = { + enable = mkEnableOption "nvim-cmp"; + setupOpts = mkPluginSetupOption "the autocomplete plugin" { + completion.completeopt = mkOption { + type = str; + default = "menu,menuone,noinsert"; description = '' - Attribute set of source names for nvim-cmp. + A comma-separated list of options for completion. - If an attribute set is provided, then the menu value of - `vim_item` in the format will be set to the value (if - utilizing the `nvim_cmp_menu_map` function). - - Note: only use a single attribute name per attribute set - ''; - type = attrsOf (nullOr str); - default = {}; - example = '' - {nvim-cmp = null; buffer = "[Buffer]";} + See `:help completeopt` for the complete list. ''; }; - formatting = { - format = mkOption { - description = '' - The function used to customize the appearance of the completion menu. + sorting.comparators = mkOption { + type = mergelessListOf (either str luaInline); + default = [ + "offset" + "exact" + "score" + "kind" + "length" + "sort_text" + ]; + description = '' + The comparator functions used for sorting completions. - If [](#opt-vim.lsp.lspkind.enable) is true, then the function - will be called before modifications from lspkind. - - Default is to call the menu mapping function. - ''; - type = str; - default = "nvim_cmp_menu_map"; - example = literalMD '' - ```lua - function(entry, vim_item) - return vim_item - end - ``` - ''; - }; + You can either pass a valid inline lua function + (see `:help cmp-config.sorting.comparators`), + or a string, in which case the builtin comparator with that name will + be used. + ''; + apply = map ( + c: + if isString c + then mkLuaInline ("cmp.config.compare." + c) + else c + ); }; }; + + mappings = { + complete = mkMappingOption "Complete [nvim-cmp]" ""; + confirm = mkMappingOption "Confirm [nvim-cmp]" ""; + next = mkMappingOption "Next item [nvim-cmp]" ""; + previous = mkMappingOption "Previous item [nvim-cmp]" ""; + close = mkMappingOption "Close [nvim-cmp]" ""; + scrollDocsUp = mkMappingOption "Scroll docs up [nvim-cmp]" ""; + scrollDocsDown = mkMappingOption "Scroll docs down [nvim-cmp]" ""; + }; + + format = mkOption { + type = luaInline; + default = mkLuaInline '' + function(entry, vim_item) + vim_item.menu = (${toLuaObject cfg.sources})[entry.source.name] + return vim_item + end + ''; + defaultText = literalMD '' + ```lua + function(entry, vim_item) + vim_item.menu = (''${toLuaObject config.vim.autocomplete.nvim-cmp.sources})[entry.source.name] + return vim_item + end + ``` + ''; + description = '' + The function used to customize the completion menu entires. This is + outside of `setupOpts` to allow for an easier integration with + lspkind.nvim. + + See `:help cmp-config.formatting.format`. + ''; + }; + + sources = mkOption { + type = attrsOf (nullOr str); + default = {}; + description = "The list of sources used by nvim-cmp"; + example = literalExpression '' + { + nvim-cmp = null; + buffer = "[Buffer]"; + } + ''; + }; }; } diff --git a/modules/plugins/debugger/nvim-dap/config.nix b/modules/plugins/debugger/nvim-dap/config.nix index 072ad9af..358d7c86 100644 --- a/modules/plugins/debugger/nvim-dap/config.nix +++ b/modules/plugins/debugger/nvim-dap/config.nix @@ -16,57 +16,61 @@ in { config = mkMerge [ (mkIf cfg.enable { - vim.startPlugins = ["nvim-dap"]; + vim = { + startPlugins = ["nvim-dap"]; - vim.pluginRC = - { - # TODO customizable keymaps - nvim-dap = entryAnywhere '' - local dap = require("dap") - vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "ErrorMsg", linehl = "", numhl = "" }) - ''; - } - // mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources; + pluginRC = + { + # TODO customizable keymaps + nvim-dap = entryAnywhere '' + local dap = require("dap") + vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "ErrorMsg", linehl = "", numhl = "" }) + ''; + } + // mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources; - vim.maps.normal = mkMerge [ - (mkSetLuaBinding mappings.continue "require('dap').continue") - (mkSetLuaBinding mappings.restart "require('dap').restart") - (mkSetLuaBinding mappings.terminate "require('dap').terminate") - (mkSetLuaBinding mappings.runLast "require('dap').run_last") + maps.normal = mkMerge [ + (mkSetLuaBinding mappings.continue "require('dap').continue") + (mkSetLuaBinding mappings.restart "require('dap').restart") + (mkSetLuaBinding mappings.terminate "require('dap').terminate") + (mkSetLuaBinding mappings.runLast "require('dap').run_last") - (mkSetLuaBinding mappings.toggleRepl "require('dap').repl.toggle") - (mkSetLuaBinding mappings.hover "require('dap.ui.widgets').hover") - (mkSetLuaBinding mappings.toggleBreakpoint "require('dap').toggle_breakpoint") + (mkSetLuaBinding mappings.toggleRepl "require('dap').repl.toggle") + (mkSetLuaBinding mappings.hover "require('dap.ui.widgets').hover") + (mkSetLuaBinding mappings.toggleBreakpoint "require('dap').toggle_breakpoint") - (mkSetLuaBinding mappings.runToCursor "require('dap').run_to_cursor") - (mkSetLuaBinding mappings.stepInto "require('dap').step_into") - (mkSetLuaBinding mappings.stepOut "require('dap').step_out") - (mkSetLuaBinding mappings.stepOver "require('dap').step_over") - (mkSetLuaBinding mappings.stepBack "require('dap').step_back") + (mkSetLuaBinding mappings.runToCursor "require('dap').run_to_cursor") + (mkSetLuaBinding mappings.stepInto "require('dap').step_into") + (mkSetLuaBinding mappings.stepOut "require('dap').step_out") + (mkSetLuaBinding mappings.stepOver "require('dap').step_over") + (mkSetLuaBinding mappings.stepBack "require('dap').step_back") - (mkSetLuaBinding mappings.goUp "require('dap').up") - (mkSetLuaBinding mappings.goDown "require('dap').down") - ]; + (mkSetLuaBinding mappings.goUp "require('dap').up") + (mkSetLuaBinding mappings.goDown "require('dap').down") + ]; + }; }) (mkIf (cfg.enable && cfg.ui.enable) { - vim.startPlugins = ["nvim-dap-ui" "nvim-nio"]; + vim = { + startPlugins = ["nvim-dap-ui" "nvim-nio"]; - vim.pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] ('' - local dapui = require("dapui") - dapui.setup() - '' - + optionalString cfg.ui.autoStart '' - dap.listeners.after.event_initialized["dapui_config"] = function() - dapui.open() - end - dap.listeners.before.event_terminated["dapui_config"] = function() - dapui.close() - end - dap.listeners.before.event_exited["dapui_config"] = function() - dapui.close() - end - ''); - vim.maps.normal = mkSetLuaBinding mappings.toggleDapUI "require('dapui').toggle"; + pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] ('' + local dapui = require("dapui") + dapui.setup() + '' + + optionalString cfg.ui.autoStart '' + dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() + end + dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() + end + dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() + end + ''); + maps.normal = mkSetLuaBinding mappings.toggleDapUI "require('dapui').toggle"; + }; }) ]; } diff --git a/modules/plugins/languages/rust.nix b/modules/plugins/languages/rust.nix index 0f595761..9a388896 100644 --- a/modules/plugins/languages/rust.nix +++ b/modules/plugins/languages/rust.nix @@ -9,7 +9,7 @@ inherit (lib.options) mkOption mkEnableOption; inherit (lib.strings) optionalString; inherit (lib.trivial) boolToString; - inherit (lib.lists) isList optionals; + inherit (lib.lists) isList; inherit (lib.types) bool package str listOf either enum; inherit (lib.nvim.types) mkGrammarOption; inherit (lib.nvim.lua) expToLua; @@ -101,7 +101,7 @@ in { vim = { startPlugins = ["crates-nvim"]; lsp.null-ls.enable = mkIf cfg.crates.codeActions true; - autocomplete.sources = {"crates" = "[Crates]";}; + autocomplete.nvim-cmp.sources = {crates = "[Crates]";}; pluginRC.rust-crates = entryAnywhere '' require('crates').setup { null_ls = { diff --git a/modules/plugins/lsp/config.nix b/modules/plugins/lsp/config.nix index a0aa7fee..52dc15b4 100644 --- a/modules/plugins/lsp/config.nix +++ b/modules/plugins/lsp/config.nix @@ -11,7 +11,7 @@ inherit (lib.nvim.binds) addDescriptionsToMappings; cfg = config.vim.lsp; - usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp"; + usingNvimCmp = config.vim.autocomplete.nvim-cmp.enable; self = import ./module.nix {inherit config lib pkgs;}; mappingDefinitions = self.options.vim.lsp.mappings; @@ -25,7 +25,7 @@ in { vim = { startPlugins = optional usingNvimCmp "cmp-nvim-lsp"; - autocomplete.sources = {"nvim_lsp" = "[LSP]";}; + autocomplete.nvim-cmp.sources = {nvim_lsp = "[LSP]";}; pluginRC.lsp-setup = '' vim.g.formatsave = ${boolToString cfg.formatOnSave}; diff --git a/modules/plugins/lsp/lspkind/config.nix b/modules/plugins/lsp/lspkind/config.nix index 93426e0c..2ef20ff8 100644 --- a/modules/plugins/lsp/lspkind/config.nix +++ b/modules/plugins/lsp/lspkind/config.nix @@ -3,18 +3,32 @@ lib, ... }: let - inherit (lib.modules) mkIf; - inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.modules) mkIf mkForce; + inherit (lib.generators) mkLuaInline; + inherit (lib.nvim.lua) toLuaObject; - cfg = config.vim.lsp; + cfg = config.vim.lsp.lspkind; in { - config = mkIf (cfg.enable && cfg.lspkind.enable) { - vim.startPlugins = ["lspkind"]; - vim.pluginRC.lspkind = entryAnywhere '' - local lspkind = require'lspkind' - local lspkind_opts = { - mode = '${cfg.lspkind.mode}' + config = mkIf cfg.enable { + assertions = [ + { + assertion = config.vim.autocomplete.nvim-cmp.enable; + message = '' + While lspkind supports Neovim's native lsp upstream, using that over + nvim-cmp isn't recommended, nor supported by nvf. + + Please migrate to nvim-cmp if you want to use lspkind. + ''; } - ''; + ]; + + vim = { + startPlugins = ["lspkind"]; + + lsp.lspkind.setupOpts.before = config.vim.autocomplete.nvim-cmp.format; + autocomplete.nvim-cmp.setupOpts.formatting.format = mkForce (mkLuaInline '' + require("lspkind").cmp_format(${toLuaObject cfg.setupOpts}) + ''); + }; }; } diff --git a/modules/plugins/lsp/lspkind/lspkind.nix b/modules/plugins/lsp/lspkind/lspkind.nix index 8ae9f39a..595decd7 100644 --- a/modules/plugins/lsp/lspkind/lspkind.nix +++ b/modules/plugins/lsp/lspkind/lspkind.nix @@ -1,16 +1,22 @@ {lib, ...}: let inherit (lib.options) mkEnableOption mkOption; - inherit (lib.types) enum; + inherit (lib.types) enum nullOr; + inherit (lib.nvim.types) mkPluginSetupOption luaInline; in { - options.vim.lsp = { - lspkind = { - enable = mkEnableOption "vscode-like pictograms for lsp [lspkind]"; - + options.vim.lsp.lspkind = { + enable = mkEnableOption "vscode-like pictograms for lsp [lspkind]"; + setupOpts = mkPluginSetupOption "lspkind.nvim" { mode = mkOption { description = "Defines how annotations are shown"; type = enum ["text" "text_symbol" "symbol_text" "symbol"]; default = "symbol_text"; }; + + before = mkOption { + description = "The function that will be called before lspkind's modifications are applied"; + type = nullOr luaInline; + default = null; + }; }; }; } diff --git a/modules/plugins/notes/obsidian/obsidian.nix b/modules/plugins/notes/obsidian/obsidian.nix index 6727430a..2dae5a9c 100644 --- a/modules/plugins/notes/obsidian/obsidian.nix +++ b/modules/plugins/notes/obsidian/obsidian.nix @@ -45,10 +45,10 @@ in { completion = { nvim_cmp = mkOption { - # if using nvim-cmp, otherwise set to false + # If using nvim-cmp, otherwise set to false type = bool; description = "If using nvim-cmp, otherwise set to false"; - default = config.vim.autocomplete.type == "nvim-cmp"; + default = config.vim.autocomplete.nvim-cmp.enable; }; }; }; diff --git a/modules/plugins/snippets/default.nix b/modules/plugins/snippets/default.nix index 3f9758a1..1b97343f 100644 --- a/modules/plugins/snippets/default.nix +++ b/modules/plugins/snippets/default.nix @@ -1,5 +1,5 @@ { imports = [ - ./vsnip + ./luasnip ]; } diff --git a/modules/plugins/snippets/luasnip/config.nix b/modules/plugins/snippets/luasnip/config.nix new file mode 100644 index 00000000..541fd0fd --- /dev/null +++ b/modules/plugins/snippets/luasnip/config.nix @@ -0,0 +1,17 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + + cfg = config.vim.snippets.luasnip; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = ["luasnip" "cmp-luasnip"] ++ cfg.providers; + autocomplete.nvim-cmp.sources = {luasnip = "[LuaSnip]";}; + pluginRC.luasnip = cfg.loaders; + }; + }; +} diff --git a/modules/plugins/snippets/luasnip/default.nix b/modules/plugins/snippets/luasnip/default.nix new file mode 100644 index 00000000..f7e94d38 --- /dev/null +++ b/modules/plugins/snippets/luasnip/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./luasnip.nix + ./config.nix + ]; +} diff --git a/modules/plugins/snippets/luasnip/luasnip.nix b/modules/plugins/snippets/luasnip/luasnip.nix new file mode 100644 index 00000000..d9563a5b --- /dev/null +++ b/modules/plugins/snippets/luasnip/luasnip.nix @@ -0,0 +1,36 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption mkOption literalExpression literalMD; + inherit (lib.types) listOf lines; + inherit (lib.nvim.types) pluginType; +in { + options.vim.snippets.luasnip = { + enable = mkEnableOption "luasnip"; + providers = mkOption { + type = listOf pluginType; + default = ["friendly-snippets"]; + description = '' + The snippet provider packages. + + ::: {.note} + These are simply appended to {option} `vim.startPlugins`. + ::: + ''; + example = literalExpression "[\"vimPlugins.vim-snippets\"]"; + }; + loaders = mkOption { + type = lines; + default = "require('luasnip.loaders.from_vscode').lazy_load()"; + defaultText = literalMD '' + ```lua + require('luasnip.loaders.from_vscode').lazy_load() + ``` + ''; + description = "Lua code used to load snippet providers."; + example = literalMD '' + ```lua + require("luasnip.loaders.from_snipmate").lazy_load() + ``` + ''; + }; + }; +} diff --git a/modules/plugins/snippets/vsnip/config.nix b/modules/plugins/snippets/vsnip/config.nix deleted file mode 100644 index 5c6ba75f..00000000 --- a/modules/plugins/snippets/vsnip/config.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ - config, - lib, - ... -}: let - inherit (lib.modules) mkIf; - - cfg = config.vim.snippets.vsnip; -in { - config = mkIf cfg.enable { - vim.startPlugins = ["vim-vsnip"]; - }; -} diff --git a/modules/plugins/snippets/vsnip/default.nix b/modules/plugins/snippets/vsnip/default.nix deleted file mode 100644 index 87ef29e0..00000000 --- a/modules/plugins/snippets/vsnip/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - imports = [ - ./vsnip.nix - ]; -} diff --git a/modules/plugins/snippets/vsnip/vsnip.nix b/modules/plugins/snippets/vsnip/vsnip.nix deleted file mode 100644 index 5d3b6d97..00000000 --- a/modules/plugins/snippets/vsnip/vsnip.nix +++ /dev/null @@ -1,7 +0,0 @@ -{lib, ...}: let - inherit (lib.options) mkEnableOption; -in { - options.vim.snippets.vsnip = { - enable = mkEnableOption "vim-vsnip: snippet LSP/VSCode's format"; - }; -} diff --git a/modules/plugins/theme/theme.nix b/modules/plugins/theme/theme.nix index 95d15d40..0422c027 100644 --- a/modules/plugins/theme/theme.nix +++ b/modules/plugins/theme/theme.nix @@ -4,10 +4,11 @@ ... }: let inherit (lib.options) mkOption; - inherit (lib.attrsets) attrNames listToAttrs; + inherit (lib.attrsets) attrNames; inherit (lib.strings) hasPrefix; inherit (lib.types) bool lines enum; inherit (lib.modules) mkIf; + inherit (lib.nvim.attrsets) mapListToAttrs; inherit (lib.nvim.dag) entryBefore; inherit (lib.nvim.types) hexColor; @@ -17,7 +18,8 @@ }; numbers = ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F"]; - base16Options = listToAttrs (map (n: { + base16Options = + mapListToAttrs (n: { name = "base0${n}"; value = mkOption { description = "The base0${n} color to use"; @@ -28,7 +30,7 @@ else "#${v}"; }; }) - numbers); + numbers; in { options.vim.theme = { enable = mkOption { diff --git a/modules/plugins/treesitter/config.nix b/modules/plugins/treesitter/config.nix index 618da88e..ae093862 100644 --- a/modules/plugins/treesitter/config.nix +++ b/modules/plugins/treesitter/config.nix @@ -11,7 +11,7 @@ inherit (lib.nvim.dag) entryBefore entryAfter; cfg = config.vim.treesitter; - usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp"; + usingNvimCmp = config.vim.autocomplete.nvim-cmp.enable; self = import ./treesitter.nix {inherit pkgs lib;}; mappingDefinitions = self.options.vim.treesitter.mappings; @@ -21,7 +21,7 @@ in { vim = { startPlugins = ["nvim-treesitter"] ++ optional usingNvimCmp "cmp-treesitter"; - autocomplete.sources = {"treesitter" = "[Treesitter]";}; + autocomplete.nvim-cmp.sources = {treesitter = "[Treesitter]";}; treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars; maps = { diff --git a/modules/plugins/ui/noice/noice.nix b/modules/plugins/ui/noice/noice.nix index bf16e3f1..edd80ee1 100644 --- a/modules/plugins/ui/noice/noice.nix +++ b/modules/plugins/ui/noice/noice.nix @@ -21,7 +21,7 @@ in { mkBool true "override the lsp markdown formatter with Noice"; "cmp.entry.get_documentation" = - mkBool (config.vim.autocomplete.type == "nvim-cmp") "override cmp documentation with Noice"; + mkBool config.vim.autocomplete.nvim-cmp.enable "override cmp documentation with Noice"; }; signature = { diff --git a/modules/wrapper/rc/config.nix b/modules/wrapper/rc/config.nix index 6f9ed1ce..6cc1e4e9 100644 --- a/modules/wrapper/rc/config.nix +++ b/modules/wrapper/rc/config.nix @@ -4,7 +4,7 @@ ... }: let inherit (builtins) map mapAttrs filter; - inherit (lib.attrsets) mapAttrsToList filterAttrs; + inherit (lib.attrsets) mapAttrsToList; inherit (lib.strings) concatLines concatMapStringsSep; inherit (lib.trivial) showWarnings; inherit (lib.generators) mkLuaInline; From c0790c549468f78d6b3598f8f2851cd59fcb6c07 Mon Sep 17 00:00:00 2001 From: Soliprem <73885403+Soliprem@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:14:52 +0200 Subject: [PATCH 0185/1178] languages/kotlin: init (#390) * merge * created otter file merge * update merge * update merge * committing flake.lock merge * merge * haskell: added LSP and treesitter * haskell: default to isMaximal * haskell: haskell support * kotlin: LSP and treesitter * haskell: LSP cmd definition * haskell: LSP cmd definition (currently broken) * kotlin: LSP and treesitter working * removing haskell from kotlin branch * merge * merge * kotlin: capitalisation * kotlin: implemented formatter * kotlin: cleanup * kotlin: formatter and linter both work * kotlin: cleanup * kotlin: massive speedup in loadtimes for lsp * otter: cleanup * kotlin: changelog entry * flake.lock: reverting accidental formatting * kotlin: removed redundant description * kotlin: fixed typo * kotlin: using symlinkjoin better * kotlin: moved wrapper to example * kotlin: cleaning up and fixing docs render --------- Co-authored-by: raf --- configuration.nix | 1 + docs/release-notes/rl-0.7.md | 2 + modules/plugins/languages/default.nix | 1 + modules/plugins/languages/kotlin.nix | 107 ++++++++++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 modules/plugins/languages/kotlin.nix diff --git a/configuration.nix b/configuration.nix index 797edba3..2ef5e644 100644 --- a/configuration.nix +++ b/configuration.nix @@ -51,6 +51,7 @@ isMaximal: { css.enable = isMaximal; sql.enable = isMaximal; java.enable = isMaximal; + kotlin.enable = isMaximal; ts.enable = isMaximal; svelte.enable = isMaximal; go.enable = isMaximal; diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 673fcffc..d5133dd2 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -259,6 +259,8 @@ everyone. - 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 +- Add LSP, diagnostics, formatter and Treesitter support for Kotlin under + `vim.languages.kotlin` [Bloxx12](https://github.com/Bloxx12) diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 28c1fd8f..b46d992c 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -8,6 +8,7 @@ in { ./css.nix ./elixir.nix ./go.nix + ./kotlin.nix ./html.nix ./java.nix ./lua.nix diff --git a/modules/plugins/languages/kotlin.nix b/modules/plugins/languages/kotlin.nix new file mode 100644 index 00000000..5637b4f4 --- /dev/null +++ b/modules/plugins/languages/kotlin.nix @@ -0,0 +1,107 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (lib.options) mkEnableOption mkOption literalExpression; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.meta) getExe; + inherit (lib.nvim.languages) diagnosticsToLua; + inherit (lib.types) package; + inherit (lib.nvim.types) mkGrammarOption diagnostics; + inherit (lib.lists) isList; + inherit (lib.nvim.lua) expToLua; + + cfg = config.vim.languages.kotlin; + + defaultDiagnosticsProvider = ["ktlint"]; + diagnosticsProviders = { + ktlint = { + package = pkgs.ktlint; + nullConfig = pkg: '' + table.insert( + ls_sources, + null_ls.builtins.diagnostics.ktlint.with({ + command = "${getExe pkg}", + }) + ) + ''; + }; + }; +in { + options.vim.languages.kotlin = { + enable = mkEnableOption "Kotlin/HCL support"; + + treesitter = { + enable = mkEnableOption "Kotlin treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "kotlin"; + }; + + lsp = { + enable = mkEnableOption "Kotlin LSP support" // {default = config.vim.languages.enableLSP;}; + + package = mkOption { + description = "kotlin_language_server package with Kotlin runtime"; + type = package; + example = literalExpression '' + pkgs.symlinkJoin { + name = "kotlin-language-server-wrapped"; + paths = [pkgs.kotlin-language-server]; + nativeBuildInputs = [pkgs.makeWrapper]; + postBuild = ''' + wrapProgram $out/bin/kotlin-language-server \ + --prefix PATH : ''${pkgs.kotlin}/bin + '''; + }; + ''; + default = pkgs.kotlin-language-server; + }; + }; + + extraDiagnostics = { + enable = mkEnableOption "extra Kotlin diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; + + types = diagnostics { + langDesc = "Kotlin"; + inherit diagnosticsProviders; + inherit defaultDiagnosticsProvider; + }; + }; + }; + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + + (mkIf cfg.extraDiagnostics.enable { + vim.lsp.null-ls.enable = true; + vim.lsp.null-ls.sources = diagnosticsToLua { + lang = "kotlin"; + config = cfg.extraDiagnostics.types; + inherit diagnosticsProviders; + }; + }) + + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.kotlin_language_server = '' + lspconfig.kotlin_language_server.setup { + capabilities = capabilities, + root_dir = lspconfig.util.root_pattern("main.kt", ".git"), + on_attach=default_on_attach, + init_options = { + -- speeds up the startup time for the LSP + storagePath = vim.fn.stdpath('state') .. '/kotlin', + }, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${cfg.lsp.package}/bin/kotlin-language-server"}'' + }, + } + ''; + }) + ]); +} From caaacbf59c2d7514fc0d633f623ad55e005d1096 Mon Sep 17 00:00:00 2001 From: ksonj Date: Sat, 12 Oct 2024 05:43:33 +0200 Subject: [PATCH 0186/1178] languages/scala: Add scala language support (#399) * languages/scala: Add scala language support Adds LSP support for Scala via nvim-metals * Fix luaInline import * Add changelog entry for Scala support to 0.7 release notes --------- Co-authored-by: raf --- configuration.nix | 1 + docs/release-notes/rl-0.7.md | 4 + flake.lock | 17 +++ flake.nix | 5 + modules/plugins/languages/default.nix | 1 + modules/plugins/languages/scala.nix | 149 ++++++++++++++++++++++++++ 6 files changed, 177 insertions(+) create mode 100644 modules/plugins/languages/scala.nix diff --git a/configuration.nix b/configuration.nix index 2ef5e644..261d5555 100644 --- a/configuration.nix +++ b/configuration.nix @@ -69,6 +69,7 @@ isMaximal: { lsp.server = "clangd"; }; + scala.enable = isMaximal; rust = { enable = isMaximal; crates.enable = isMaximal; diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index d5133dd2..de0033db 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -267,3 +267,7 @@ everyone. - Add support for [base16 theming](https://github.com/RRethy/base16-nvim) under `vim.theme` - Fix internal breakage in `elixir-tools` setup. + +[ksonj](https://github.com/ksonj): + +- Add LSP support for Scala via [nvim-metals](https://github.com/scalameta/nvim-metals) diff --git a/flake.lock b/flake.lock index ad9efefa..843acb2a 100644 --- a/flake.lock +++ b/flake.lock @@ -1197,6 +1197,22 @@ "type": "github" } }, + "plugin-nvim-metals": { + "flake": false, + "locked": { + "lastModified": 1728295172, + "narHash": "sha256-ja/+MNxZ3H9io9jDwm5rhE6iKNi86a22eCOY75g19O8=", + "owner": "scalameta", + "repo": "nvim-metals", + "rev": "f861db9fda55939797ac1b05238c49b0dcdc3bdb", + "type": "github" + }, + "original": { + "owner": "scalameta", + "repo": "nvim-metals", + "type": "github" + } + }, "plugin-nvim-navbuddy": { "flake": false, "locked": { @@ -1898,6 +1914,7 @@ "plugin-nvim-docs-view": "plugin-nvim-docs-view", "plugin-nvim-lightbulb": "plugin-nvim-lightbulb", "plugin-nvim-lspconfig": "plugin-nvim-lspconfig", + "plugin-nvim-metals": "plugin-nvim-metals", "plugin-nvim-navbuddy": "plugin-nvim-navbuddy", "plugin-nvim-navic": "plugin-nvim-navic", "plugin-nvim-neoclip": "plugin-nvim-neoclip", diff --git a/flake.nix b/flake.nix index 53e9e939..8a9f93cc 100644 --- a/flake.nix +++ b/flake.nix @@ -206,6 +206,11 @@ flake = false; }; + plugin-nvim-metals = { + url = "github:scalameta/nvim-metals"; + flake = false; + }; + # Copying/Registers plugin-registers = { url = "github:tversteeg/registers.nvim"; diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index b46d992c..54a9e1c4 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -20,6 +20,7 @@ in { ./python.nix ./r.nix ./rust.nix + ./scala.nix ./sql.nix ./svelte.nix ./tailwind.nix diff --git a/modules/plugins/languages/scala.nix b/modules/plugins/languages/scala.nix new file mode 100644 index 00000000..f769d092 --- /dev/null +++ b/modules/plugins/languages/scala.nix @@ -0,0 +1,149 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (lib.generators) mkLuaInline; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.binds) mkMappingOption; + inherit (lib.nvim.dag) entryAfter; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.types) mkGrammarOption luaInline; + inherit (lib.options) mkOption mkEnableOption mkPackageOption; + inherit (lib.strings) optionalString; + inherit (lib.types) attrsOf anything bool; + + listCommandsAction = + if config.vim.telescope.enable + then ''require("telescope").extensions.metals.commands()'' + else ''require("metals").commands()''; + + cfg = config.vim.languages.scala; + + usingDap = config.vim.debugger.nvim-dap.enable && cfg.dap.enable; + usingLualine = config.vim.statusline.lualine.enable; +in { + options.vim.languages.scala = { + enable = mkEnableOption "Scala language support"; + + treesitter = { + enable = mkEnableOption "Scala treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "scala"; + }; + + lsp = { + enable = mkEnableOption "Scala LSP support (metals)" // {default = config.vim.languages.enableLSP;}; + package = mkPackageOption pkgs "metals" { + default = ["metals"]; + }; + + extraMappings = { + listCommands = mkMappingOption "List Metals commands" "lc"; + }; + + extraSettings = mkOption { + type = attrsOf anything; + description = "Extra settings passed to the metals config. Check nvim-metals docs for available options"; + default = { + showImplicitArguments = true; + showImplicitConversionsAndClasses = true; + showInferredType = true; + excludedPackages = [ + "akka.actor.typed.javadsl" + "com.github.swagger.akka.javadsl" + ]; + }; + }; + }; + + dap = { + enable = mkEnableOption "Scala Debug Adapter support (metals)" // {default = config.vim.languages.enableDAP;}; + config = mkOption { + description = "Lua configuration for dap"; + type = luaInline; + default = mkLuaInline '' + dap.configurations.scala = { + { + type = "scala", + request = "launch", + name = "RunOrTest", + metals = { + runType = "runOrTestFile", + --args = { "firstArg", "secondArg", "thirdArg" }, -- here just as an example + }, + }, + { + type = "scala", + request = "launch", + name = "Test Target", + metals = { + runType = "testTarget", + }, + }, + } + ''; + }; + }; + + fixShortmess = mkOption { + type = bool; + description = "Remove the 'F' flag from shortmess to allow messages to be shown. Without doing this, autocommands that deal with filetypes prohibit messages from being shown"; + default = true; + }; + }; + + config = mkIf cfg.enable ( + mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + (mkIf (cfg.lsp.enable || cfg.dap.enable) { + vim = { + startPlugins = ["nvim-metals"]; + pluginRC.nvim-metals = entryAfter ["lsp-setup"] '' + local metals_caps = capabilities -- from lsp-setup + + local attach_metals_keymaps = function(client, bufnr) + attach_keymaps(client, bufnr) -- from lsp-setup + vim.api.nvim_buf_set_keymap(bufnr, 'n', '${cfg.lsp.extraMappings.listCommands}', 'lua ${listCommandsAction}', {noremap=true, silent=true, desc='Show all Metals commands'}) + end + + metals_config = require('metals').bare_config() + ${optionalString usingLualine "metals_config.init_options.statusBarProvider = 'on'"} + + metals_config.capabilities = metals_caps + metals_config.on_attach = function(client, bufnr) + ${optionalString usingDap "require('metals').setup_dap()"} + attach_metals_keymaps(client, bufnr) + end + + metals_config.settings = ${toLuaObject cfg.lsp.extraSettings} + metals_config.settings.metalsBinaryPath = "${cfg.lsp.package}/bin/metals" + + metals_config.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = { + prefix = '⚠', + } + } + ) + + ${optionalString cfg.fixShortmess ''vim.opt_global.shortmess:remove("F")''} + + local lsp_group = vim.api.nvim_create_augroup('lsp', { clear = true }) + + vim.api.nvim_create_autocmd('FileType', { + group = lsp_group, + pattern = {'java', 'scala', 'sbt'}, + callback = function() + require('metals').initialize_or_attach(metals_config) + end, + }) + ''; + }; + }) + ] + ); +} From f5d33f6a53d52fc2e53e9cea0521ec1be9d0ae19 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Mon, 14 Oct 2024 14:21:35 +0300 Subject: [PATCH 0187/1178] wrapper: disableDefaultRuntimePaths --- Co-authored-by: NotAShelf --- docs/release-notes/rl-0.7.md | 6 +++- modules/extra/deprecations.nix | 14 +++++++++ modules/wrapper/rc/options.nix | 54 ++++------------------------------ 3 files changed, 25 insertions(+), 49 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index de0033db..f8cec50f 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -93,6 +93,9 @@ everyone. - Add dap-go for better dap configurations - Make noice.nvim customizable - Standardize border style options and add custom borders +- Remove `vim.disableDefaultRuntimePaths` in wrapper options. + - As nvf uses `$NVIM_APP_NAME` as of recent changes, we can safely assume any + configuration in `$XDG_CONFIG_HOME/nvf` is intentional. [rust-tools.nvim]: https://github.com/simrat39/rust-tools.nvim [rustaceanvim]: https://github.com/mrcjkb/rustaceanvim @@ -270,4 +273,5 @@ everyone. [ksonj](https://github.com/ksonj): -- Add LSP support for Scala via [nvim-metals](https://github.com/scalameta/nvim-metals) +- Add LSP support for Scala via + [nvim-metals](https://github.com/scalameta/nvim-metals) diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index c4ff4d30..779a7527 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -35,5 +35,19 @@ in { vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip. '') (mkRenamedOptionModule ["vim" "lsp" "lspkind" "mode"] ["vim" "lsp" "lspkind" "setupOpts" "mode"]) + + # 2024-10-14 + (mkRemovedOptionModule ["vim" "configRC"] '' + Please migrate your configRC sections to Neovim's Lua format, and + add them to `vim.luaConfigRC`. + + See the v0.7 release notes for more information on why and how to + migrate your existing configurations to the new format. + '') + + (mkRemovedOptionModule ["vim" "disableDefaultRuntimePaths"] '' + Nvf now uses $NVIM_APP_NAME so there is no longer the problem of + (accidental) leaking of user configuration. + '') ]; } diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index 70ab2a8a..1159b9fe 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -3,27 +3,18 @@ lib, ... }: let - inherit (lib.modules) mkRemovedOptionModule; inherit (lib.options) mkOption mkEnableOption literalMD literalExpression; inherit (lib.strings) optionalString; - inherit (lib.types) str attrs lines listOf either path bool; + inherit (lib.types) str attrs lines listOf either path; inherit (lib.nvim.types) dagOf; inherit (lib.nvim.lua) listToLuaTable; cfg = config.vim; in { - imports = [ - (mkRemovedOptionModule ["vim" "configRC"] '' - Please migrate your configRC sections to Neovim's Lua format, and - add them to luaConfigRC. - - See the v0.7 release notes for more information on how to migrate - your existing configurations. - '') - ]; - options.vim = { enableLuaLoader = mkEnableOption '' + [{option}`official documentation`]: https://neovim.io/doc/user/lua.html#vim.loader.enable() + the experimental Lua module loader to speed up the start up process If `true`, this will enable the experimental Lua module loader which: @@ -32,30 +23,12 @@ in { - adds the libs loader - removes the default Neovim loader + ::: {.note} This is disabled by default. Before setting this option, please - take a look at the [{option}`official documentation`](https://neovim.io/doc/user/lua.html#vim.loader.enable()). + take a look at the [{option}`official documentation`]. + ::: ''; - disableDefaultRuntimePaths = mkOption { - type = bool; - default = true; - example = false; - description = '' - Disables the default runtime paths that are set by Neovim - when it starts up. This is useful when you want to have - full control over the runtime paths that are set by Neovim. - - ::: {.note} - To avoid leaking imperative user configuration into your - configuration, this is enabled by default. If you wish - to load configuration from user configuration directories - (e.g. {file}`$HOME/.config/nvim`, {file}`$HOME/.config/nvim/after` - and {file}`$HOME/.local/share/nvim/site`) you may set this - option to true. - ::: - ''; - }; - additionalRuntimePaths = mkOption { type = listOf (either path str); default = []; @@ -180,21 +153,6 @@ in { vim.opt.runtimepath:append(${listToLuaTable cfg.additionalRuntimePaths}) ''} - ${optionalString cfg.disableDefaultRuntimePaths '' - -- Remove default user runtime paths from the - -- `runtimepath` option to avoid leaking user configuration - -- into the final neovim wrapper - local defaultRuntimePaths = { - vim.fn.stdpath('config'), -- $HOME/.config/nvim - vim.fn.stdpath('config') .. "/after", -- $HOME/.config/nvim/after - vim.fn.stdpath('data') .. "/site", -- $HOME/.local/share/nvim/site - } - - for _, path in ipairs(defaultRuntimePaths) do - vim.opt.runtimepath:remove(path) - end - ''} - ${optionalString cfg.enableLuaLoader "vim.loader.enable()"} ''; From 94d2b837cf20899df811dae1dbb02ddbc751b965 Mon Sep 17 00:00:00 2001 From: Soliprem <73885403+Soliprem@users.noreply.github.com> Date: Mon, 14 Oct 2024 22:47:44 +0200 Subject: [PATCH 0188/1178] leap: changing default binds (#416) * leap: changed default binds * leap: added changelog entry * leap: fixing requested change Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * Revert "leap: added changelog entry" This reverts commit 6aac9b2580d707aa28c6cf008f89580f8973ac48. * leap: added changelog entry * leap: fix inherits --------- Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> --- docs/release-notes/rl-0.7.md | 1 + modules/plugins/utility/motion/leap/config.nix | 4 +++- modules/plugins/utility/motion/leap/leap.nix | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index f8cec50f..87861e2d 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -264,6 +264,7 @@ everyone. ccc - Add LSP, diagnostics, formatter and Treesitter support for Kotlin under `vim.languages.kotlin` +- changed default keybinds for leap.nvim to avoid altering expected behavior [Bloxx12](https://github.com/Bloxx12) diff --git a/modules/plugins/utility/motion/leap/config.nix b/modules/plugins/utility/motion/leap/config.nix index 9ede98f3..687ed24d 100644 --- a/modules/plugins/utility/motion/leap/config.nix +++ b/modules/plugins/utility/motion/leap/config.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib.modules) mkIf mkMerge; + inherit (lib.modules) mkIf mkMerge mkDefault; inherit (lib.nvim.binds) mkBinding; inherit (lib.nvim.dag) entryAnywhere; @@ -37,6 +37,8 @@ in { (mkBinding cfg.mappings.leapFromWindow "(leap-from-window)" "Leap from window") ]; + vim.binds.whichKey.register."s" = mkDefault "+Leap"; + vim.pluginRC.leap-nvim = entryAnywhere '' require('leap').opts = { max_phase_one_targets = nil, diff --git a/modules/plugins/utility/motion/leap/leap.nix b/modules/plugins/utility/motion/leap/leap.nix index a5d72432..4e98f208 100644 --- a/modules/plugins/utility/motion/leap/leap.nix +++ b/modules/plugins/utility/motion/leap/leap.nix @@ -9,22 +9,22 @@ in { leapForwardTo = mkOption { type = nullOr str; description = "Leap forward to"; - default = "s"; + default = "ss"; }; leapBackwardTo = mkOption { type = nullOr str; description = "Leap backward to"; - default = "S"; + default = "sS"; }; leapForwardTill = mkOption { type = nullOr str; description = "Leap forward till"; - default = "x"; + default = "sx"; }; leapBackwardTill = mkOption { type = nullOr str; description = "Leap backward till"; - default = "X"; + default = "sX"; }; leapFromWindow = mkOption { type = nullOr str; From a7e0542fd028cc5648c988b3da9493f3e745a81e Mon Sep 17 00:00:00 2001 From: Soliprem <73885403+Soliprem@users.noreply.github.com> Date: Tue, 15 Oct 2024 17:31:18 +0200 Subject: [PATCH 0189/1178] neorg: init (#413) * neorg: init * neorg: setupOpts work * neorg: disable by default * neorg: added changelog entry * neorg: setupOpts setup correctly * neorg: sane default for setupOpts * neorg: changed description and removed reduntant treesitter activation * neorg: added vim.treesitter.enable * neorg: fixing capitalisation * neorg: adding descriptions * neorg: formatting * neorg: added newline at the end of docs --- configuration.nix | 1 + docs/release-notes/rl-0.7.md | 2 + flake.lock | 68 +++++++++++++++++++++++++ flake.nix | 20 ++++++++ modules/plugins/notes/default.nix | 1 + modules/plugins/notes/neorg/config.nix | 41 +++++++++++++++ modules/plugins/notes/neorg/default.nix | 6 +++ modules/plugins/notes/neorg/neorg.nix | 50 ++++++++++++++++++ 8 files changed, 189 insertions(+) create mode 100644 modules/plugins/notes/neorg/config.nix create mode 100644 modules/plugins/notes/neorg/default.nix create mode 100644 modules/plugins/notes/neorg/neorg.nix diff --git a/configuration.nix b/configuration.nix index df0b2b1c..832bf95c 100644 --- a/configuration.nix +++ b/configuration.nix @@ -174,6 +174,7 @@ isMaximal: { notes = { obsidian.enable = false; # FIXME: neovim fails to build if obsidian is enabled + neorg.enable = false; orgmode.enable = false; mind-nvim.enable = isMaximal; todo-comments.enable = true; diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 87861e2d..7cbdbaae 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -262,6 +262,7 @@ everyone. - 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 +- Add Neorg support under `vim.notes.neorg` - Add LSP, diagnostics, formatter and Treesitter support for Kotlin under `vim.languages.kotlin` - changed default keybinds for leap.nvim to avoid altering expected behavior @@ -276,3 +277,4 @@ everyone. - Add LSP support for Scala via [nvim-metals](https://github.com/scalameta/nvim-metals) + diff --git a/flake.lock b/flake.lock index 843acb2a..34a22430 100644 --- a/flake.lock +++ b/flake.lock @@ -828,6 +828,22 @@ "type": "github" } }, + "plugin-lua-utils-nvim": { + "flake": false, + "locked": { + "lastModified": 1708177208, + "narHash": "sha256-9ildzQEMkXKZ3LHq+khGFgRQFxlIXQclQ7QU3fcU1C4=", + "owner": "nvim-neorg", + "repo": "lua-utils.nvim", + "rev": "e565749421f4bbb5d2e85e37c3cef9d56553d8bd", + "type": "github" + }, + "original": { + "owner": "nvim-neorg", + "repo": "lua-utils.nvim", + "type": "github" + } + }, "plugin-lualine": { "flake": false, "locked": { @@ -956,6 +972,38 @@ "type": "github" } }, + "plugin-neorg": { + "flake": false, + "locked": { + "lastModified": 1727821831, + "narHash": "sha256-yfWQ6yKytu1jkWUtRZTVICslUWej6jVYv7frmSB7/6Q=", + "owner": "nvim-neorg", + "repo": "neorg", + "rev": "afc9a37bf021acb0853e95714c4c6436e1588286", + "type": "github" + }, + "original": { + "owner": "nvim-neorg", + "repo": "neorg", + "type": "github" + } + }, + "plugin-neorg-telescope": { + "flake": false, + "locked": { + "lastModified": 1722358034, + "narHash": "sha256-ei4uUqpIQjGKzu5ryu0Hlmis9TS9FJsYnjt4J4QdWlw=", + "owner": "nvim-neorg", + "repo": "neorg-telescope", + "rev": "ddb2556644cae922699a239bbb0fe16e25b084b7", + "type": "github" + }, + "original": { + "owner": "nvim-neorg", + "repo": "neorg-telescope", + "type": "github" + } + }, "plugin-new-file-template-nvim": { "flake": false, "locked": { @@ -1469,6 +1517,22 @@ "type": "github" } }, + "plugin-pathlib-nvim": { + "flake": false, + "locked": { + "lastModified": 1724943804, + "narHash": "sha256-YhCJeNKlcjgg3q51UWFhuIEPzNueC8YTpeuPPJDndvw=", + "owner": "pysan3", + "repo": "pathlib.nvim", + "rev": "57e5598af6fe253761c1b48e0b59b7cd6699e2c1", + "type": "github" + }, + "original": { + "owner": "pysan3", + "repo": "pathlib.nvim", + "type": "github" + } + }, "plugin-plenary-nvim": { "flake": false, "locked": { @@ -1891,6 +1955,7 @@ "plugin-lsp-signature": "plugin-lsp-signature", "plugin-lspkind": "plugin-lspkind", "plugin-lspsaga": "plugin-lspsaga", + "plugin-lua-utils-nvim": "plugin-lua-utils-nvim", "plugin-lualine": "plugin-lualine", "plugin-luasnip": "plugin-luasnip", "plugin-mind-nvim": "plugin-mind-nvim", @@ -1899,6 +1964,8 @@ "plugin-neo-tree-nvim": "plugin-neo-tree-nvim", "plugin-neocord": "plugin-neocord", "plugin-neodev-nvim": "plugin-neodev-nvim", + "plugin-neorg": "plugin-neorg", + "plugin-neorg-telescope": "plugin-neorg-telescope", "plugin-new-file-template-nvim": "plugin-new-file-template-nvim", "plugin-noice-nvim": "plugin-noice-nvim", "plugin-none-ls": "plugin-none-ls", @@ -1931,6 +1998,7 @@ "plugin-orgmode-nvim": "plugin-orgmode-nvim", "plugin-otter-nvim": "plugin-otter-nvim", "plugin-oxocarbon": "plugin-oxocarbon", + "plugin-pathlib-nvim": "plugin-pathlib-nvim", "plugin-plenary-nvim": "plugin-plenary-nvim", "plugin-project-nvim": "plugin-project-nvim", "plugin-registers": "plugin-registers", diff --git a/flake.nix b/flake.nix index 8a9f93cc..d12bdc57 100644 --- a/flake.nix +++ b/flake.nix @@ -646,6 +646,26 @@ flake = false; }; + plugin-lua-utils-nvim = { + url = "github:nvim-neorg/lua-utils.nvim"; + flake = false; + }; + + plugin-pathlib-nvim = { + url = "github:pysan3/pathlib.nvim"; + flake = false; + }; + + plugin-neorg = { + url = "github:nvim-neorg/neorg"; + flake = false; + }; + + plugin-neorg-telescope = { + url = "github:nvim-neorg/neorg-telescope"; + flake = false; + }; + plugin-nui-nvim = { # (required by noice.nvim) url = "github:MunifTanjim/nui.nvim"; diff --git a/modules/plugins/notes/default.nix b/modules/plugins/notes/default.nix index 88a70924..6c342728 100644 --- a/modules/plugins/notes/default.nix +++ b/modules/plugins/notes/default.nix @@ -2,6 +2,7 @@ imports = [ ./obsidian ./orgmode + ./neorg ./mind-nvim ./todo-comments ]; diff --git a/modules/plugins/notes/neorg/config.nix b/modules/plugins/notes/neorg/config.nix new file mode 100644 index 00000000..fab5079d --- /dev/null +++ b/modules/plugins/notes/neorg/config.nix @@ -0,0 +1,41 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf mkMerge; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.binds) pushDownDefault; + inherit (lib.nvim.lua) toLuaObject; + + cfg = config.vim.notes.neorg; +in { + config = mkIf cfg.enable (mkMerge [ + { + vim = { + startPlugins = [ + "lua-utils-nvim" + "nui-nvim" + "nvim-nio" + "pathlib-nvim" + "plenary-nvim" + "neorg" + "neorg-telescope" + ]; + + binds.whichKey.register = pushDownDefault { + "o" = "+Notes"; + }; + + pluginRC.neorg = entryAnywhere '' + require('neorg').setup(${toLuaObject cfg.setupOpts}) + ''; + }; + } + + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.norgPackage]; + }) + ]); +} diff --git a/modules/plugins/notes/neorg/default.nix b/modules/plugins/notes/neorg/default.nix new file mode 100644 index 00000000..409cee31 --- /dev/null +++ b/modules/plugins/notes/neorg/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./neorg.nix + ./config.nix + ]; +} diff --git a/modules/plugins/notes/neorg/neorg.nix b/modules/plugins/notes/neorg/neorg.nix new file mode 100644 index 00000000..6b5cf18e --- /dev/null +++ b/modules/plugins/notes/neorg/neorg.nix @@ -0,0 +1,50 @@ +{ + config, + lib, + pkgs, + ... +}: let + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) submodule listOf str; + inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption; +in { + options.vim.notes.neorg = { + enable = mkEnableOption '' + Neorg: An intuitive note-taking and organization tool with a structured nested syntax. + ''; + + setupOpts = mkPluginSetupOption "Neorg" { + load = { + "core.defaults" = mkOption { + default = {}; + description = '' + all of the most important modules that any user would want to have a "just works" experience + ''; + + type = submodule { + options = { + enable = mkEnableOption '' + all of the most important modules that any user would want to have a "just works" experience + ''; + config = { + disable = mkOption { + description = '' + list of modules from to be disabled from core.defaults + ''; + type = listOf str; + default = []; + example = ["core.autocommands" "core.itero"]; + }; + }; + }; + }; + }; + }; + }; + + treesitter = { + enable = mkEnableOption "Neorg treesitter" // {default = config.vim.languages.enableTreesitter;}; + norgPackage = mkGrammarOption pkgs "norg"; + }; + }; +} From 54ec473039f5337bd2be66a040528eebab15f11f Mon Sep 17 00:00:00 2001 From: diniamo <55629891+diniamo@users.noreply.github.com> Date: Tue, 15 Oct 2024 18:05:05 +0200 Subject: [PATCH 0190/1178] comment-nvim: fix visual mappings (#417) --- modules/plugins/comments/comment-nvim/config.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/plugins/comments/comment-nvim/config.nix b/modules/plugins/comments/comment-nvim/config.nix index e70e918c..e228d92c 100644 --- a/modules/plugins/comments/comment-nvim/config.nix +++ b/modules/plugins/comments/comment-nvim/config.nix @@ -12,9 +12,7 @@ inherit (self.options.vim.comments.comment-nvim) mappings; in { config = mkIf cfg.enable { - vim.startPlugins = [ - "comment-nvim" - ]; + vim.startPlugins = ["comment-nvim"]; vim.maps.normal = mkMerge [ (mkBinding cfg.mappings.toggleOpLeaderLine "(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description) @@ -36,7 +34,7 @@ in { mappings.toggleCurrentBlock.description) ]; - vim.maps.visualOnly = mkMerge [ + vim.maps.visual = mkMerge [ (mkBinding cfg.mappings.toggleSelectedLine "(comment_toggle_linewise_visual)" mappings.toggleSelectedLine.description) (mkBinding cfg.mappings.toggleSelectedBlock "(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description) ]; From ff9b0eeb1f8fa095c21a77b0f5c25b9c56405ea3 Mon Sep 17 00:00:00 2001 From: diniamo <55629891+diniamo@users.noreply.github.com> Date: Thu, 17 Oct 2024 07:57:29 +0200 Subject: [PATCH 0191/1178] nvim-cmp: fix rewrite remnants (#419) * fix: bad cmp confirm * nvim-cmp: simplify confirm bind and mapping definitions --------- Co-authored-by: Pei Yang Ching <59727193+horriblename@users.noreply.github.com> --- .../plugins/completion/nvim-cmp/config.nix | 41 ++++--------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/modules/plugins/completion/nvim-cmp/config.nix b/modules/plugins/completion/nvim-cmp/config.nix index ffd15fe4..5d20242d 100644 --- a/modules/plugins/completion/nvim-cmp/config.nix +++ b/modules/plugins/completion/nvim-cmp/config.nix @@ -6,17 +6,13 @@ inherit (lib.modules) mkIf; inherit (lib.strings) optionalString; inherit (lib.generators) mkLuaInline; - inherit (lib.nvim.binds) addDescriptionsToMappings; inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.lua) toLuaObject; inherit (builtins) attrNames; cfg = config.vim.autocomplete.nvim-cmp; luasnipEnable = config.vim.snippets.luasnip.enable; - - self = import ./nvim-cmp.nix {inherit lib config;}; - mappingDefinitions = self.options.vim.autocomplete.nvim-cmp.mappings; - mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; + inherit (cfg) mappings; in { config = mkIf cfg.enable { vim = { @@ -45,39 +41,20 @@ in { }; pluginRC.nvim-cmp = mkIf cfg.enable (entryAfter ["autopairs" "luasnip"] '' - local luasnip = require("luasnip") + ${optionalString luasnipEnable "local luasnip = require('luasnip')"} local cmp = require("cmp") cmp.setup(${toLuaObject cfg.setupOpts}) ''); # `cmp` and `luasnip` are defined above, in the `nvim-cmp` section autocomplete.nvim-cmp.setupOpts.mapping = { - ${mappings.complete.value} = mkLuaInline "cmp.mapping.complete()"; - ${mappings.close.value} = mkLuaInline "cmp.mapping.abort()"; - ${mappings.scrollDocsUp.value} = mkLuaInline "cmp.mapping.scroll_docs(-4)"; - ${mappings.scrollDocsDown.value} = mkLuaInline "cmp.mapping.scroll_docs(4)"; + ${mappings.complete} = mkLuaInline "cmp.mapping.complete()"; + ${mappings.close} = mkLuaInline "cmp.mapping.abort()"; + ${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)"; + ${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)"; + ${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })"; - ${mappings.confirm.value} = mkLuaInline '' - cmp.mapping(function(fallback) - if cmp.visible() then - ${ - if luasnipEnable - then '' - if luasnip.expandable() then - luasnip.expand() - else - cmp.confirm({ select = true }) - end - '' - else "cmp.confirm({ select = true })" - } - else - fallback() - end - end) - ''; - - ${mappings.next.value} = mkLuaInline '' + ${mappings.next} = mkLuaInline '' cmp.mapping(function(fallback) local has_words_before = function() local line, col = unpack(vim.api.nvim_win_get_cursor(0)) @@ -98,7 +75,7 @@ in { end) ''; - ${mappings.previous.value} = mkLuaInline '' + ${mappings.previous} = mkLuaInline '' cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() From 3c4eced9d17ec977b061b278e91d9e8b98a153e1 Mon Sep 17 00:00:00 2001 From: diniamo <55629891+diniamo@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:19:37 +0200 Subject: [PATCH 0192/1178] docs: add missing deprecation notes (#420) --- docs/release-notes/rl-0.7.md | 8 ++++++++ modules/extra/deprecations.nix | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 7cbdbaae..9d186d32 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -63,6 +63,14 @@ 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. +### `type` based modules removed {#sec-type-based-modules-removed} + +As part of the autocompletion rewrite, modules that used to use a `type` option +have been replaced by per-plugin modules instead. Since both modules only had +one type, you can simply change +- `vim.autocomplete.*` -> `vim.autocomplete.nvim-cmp.*` +- `vim.autopairs.enable` -> `vim.autopairs.nvim-autopairs.enable` + ## Changelog {#sec-release-0.7-changelog} [ItsSorae](https://github.com/ItsSorae): diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index 779a7527..5a30ef5e 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -31,6 +31,11 @@ in { vim.autocomplete.type has been removed in favor of per-plugin modules. You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead. '') + (mkRemovedOptionModule ["vim" "autocomplete" "sources"] '' + vim.autocomplete.sources has been removed in favor of per-plugin modules. + You can add nvim-cmp sources with vim.autocomplete.nvim-cmp.sources + instead. + '') (mkRemovedOptionModule ["vim" "snippets" "vsnip" "enable"] '' vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip. '') From e80520ddf34843cf4b3c42635e1b7337e2f67c34 Mon Sep 17 00:00:00 2001 From: Anthony Date: Tue, 22 Oct 2024 22:15:07 +0200 Subject: [PATCH 0193/1178] languages: add biome support for formatting (#423) --- docs/release-notes/rl-0.7.md | 7 +++++-- modules/plugins/languages/css.nix | 12 ++++++++++++ modules/plugins/languages/svelte.nix | 12 ++++++++++++ modules/plugins/languages/ts.nix | 12 ++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 9d186d32..721580d5 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -68,6 +68,7 @@ everyone. As part of the autocompletion rewrite, modules that used to use a `type` option have been replaced by per-plugin modules instead. Since both modules only had one type, you can simply change + - `vim.autocomplete.*` -> `vim.autocomplete.nvim-cmp.*` - `vim.autopairs.enable` -> `vim.autopairs.nvim-autopairs.enable` @@ -220,8 +221,7 @@ one type, you can simply change `vim.languages.ts.extensions.ts-error-translator` to aid with Typescript development. -- Add [neo-tree.nvim] as an alternative file-tree plugin. It will be available - under `vim.filetree.neo-tree`, similar to nvimtree. +- Add [neo-tree.nvim] as an alternative file-tree plugin. It will be available under `vim.filetree.neo-tree`, similar to nvimtree. - Add `nvf-print-config` & `nvf-print-config-path` helper scripts to Neovim closure. Both of those scripts have been automatically added to your PATH upon @@ -286,3 +286,6 @@ one type, you can simply change - Add LSP support for Scala via [nvim-metals](https://github.com/scalameta/nvim-metals) +[nezia1](https://github.com/nezia1): + +- Add [biome](https://github.com/biomejs/biome) support for Typescript, CSS and Svelte. Enable them via [](#opt-vim.languages.ts.format.type), [](#opt-vim.languages.css.format.type) and [](#opt-vim.languages.svelte.format.type) respectively. diff --git a/modules/plugins/languages/css.nix b/modules/plugins/languages/css.nix index 1535ecaf..8330a41a 100644 --- a/modules/plugins/languages/css.nix +++ b/modules/plugins/languages/css.nix @@ -63,6 +63,18 @@ ) ''; }; + + biome = { + package = pkgs.biome; + nullConfig = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.biome.with({ + command = "${cfg.format.package}/bin/biome", + }) + ) + ''; + }; }; in { options.vim.languages.css = { diff --git a/modules/plugins/languages/svelte.nix b/modules/plugins/languages/svelte.nix index e6c9d621..a3c55e10 100644 --- a/modules/plugins/languages/svelte.nix +++ b/modules/plugins/languages/svelte.nix @@ -48,6 +48,18 @@ ) ''; }; + + biome = { + package = pkgs.biome; + nullConfig = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.biome.with({ + command = "${cfg.format.package}/bin/biome", + }) + ) + ''; + }; }; # TODO: specify packages diff --git a/modules/plugins/languages/ts.nix b/modules/plugins/languages/ts.nix index 5ceccecf..726950ef 100644 --- a/modules/plugins/languages/ts.nix +++ b/modules/plugins/languages/ts.nix @@ -95,6 +95,18 @@ ) ''; }; + + biome = { + package = pkgs.biome; + nullConfig = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.biome.with({ + command = "${cfg.format.package}/bin/biome", + }) + ) + ''; + }; }; # TODO: specify packages From 71e2ae1db492b2c9e27ae53521a50dfbf426dc06 Mon Sep 17 00:00:00 2001 From: Anthony Date: Tue, 22 Oct 2024 23:44:18 +0200 Subject: [PATCH 0194/1178] languages/nix: change nixpkgs-fmt to nixfmt (rfc-style) (#383) --- docs/release-notes/rl-0.7.md | 10 ++++++++++ modules/plugins/languages/nix.nix | 26 +++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 721580d5..49e99df7 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -72,6 +72,15 @@ one type, you can simply change - `vim.autocomplete.*` -> `vim.autocomplete.nvim-cmp.*` - `vim.autopairs.enable` -> `vim.autopairs.nvim-autopairs.enable` +### `nixpkgs-fmt` removed in favor of `nixfmt` {#sec-nixpkgs-fmt-deprecation} + +`nixpkgs-fmt` has been archived for a while, and it's finally being removed in +favor of nixfmt (more information can be found +[here](https://github.com/nix-community/nixpkgs-fmt?tab=readme-ov-file#nixpkgs-fmt---nix-code-formatter-for-nixpkgs). + +To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to +`nixfmt`. + ## Changelog {#sec-release-0.7-changelog} [ItsSorae](https://github.com/ItsSorae): @@ -289,3 +298,4 @@ one type, you can simply change [nezia1](https://github.com/nezia1): - Add [biome](https://github.com/biomejs/biome) support for Typescript, CSS and Svelte. Enable them via [](#opt-vim.languages.ts.format.type), [](#opt-vim.languages.css.format.type) and [](#opt-vim.languages.svelte.format.type) respectively. +- Replace [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) with [nixfmt](https://github.com/NixOS/nixfmt) (nixfmt-rfc-style). diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index 6cf1f90b..82dded69 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -5,6 +5,7 @@ ... }: let inherit (builtins) attrNames; + inherit (lib) concatStringsSep; inherit (lib.options) mkEnableOption mkOption; inherit (lib.modules) mkIf mkMerge; inherit (lib.lists) isList; @@ -62,10 +63,10 @@ command = {"${cfg.format.package}/bin/alejandra", "--quiet"}, }, ''} - ${optionalString (cfg.format.type == "nixpkgs-fmt") + ${optionalString (cfg.format.type == "nixfmt") '' formatting = { - command = {"${cfg.format.package}/bin/nixpkgs-fmt"}, + command = {"${cfg.format.package}/bin/nixfmt"}, }, ''} }, @@ -90,10 +91,19 @@ ''; }; - nixpkgs-fmt = { - package = pkgs.nixpkgs-fmt; - # Never need to use null-ls for nixpkgs-fmt + nixfmt = { + package = pkgs.nixfmt-rfc-style; + nullConfig = '' + table.insert( + ls_sources, + null_ls.builtins.formatting.nixfmt.with({ + command = "${cfg.format.package}/bin/nixfmt" + }) + ) + ''; }; + + nixpkgs-fmt = null; # removed }; defaultDiagnosticsProvider = ["statix" "deadnix"]; @@ -175,6 +185,12 @@ in { config = mkIf cfg.enable (mkMerge [ { + assertions = [ + { + assertion = cfg.format.type != "nixpkgs-fmt"; + message = "nixpkgs-fmt has been archived upstream. Please use one of the following instead: ${concatStringsSep ", " (attrNames formats)}"; + } + ]; vim.pluginRC.nix = '' vim.api.nvim_create_autocmd("FileType", { pattern = "nix", From da86e554a6433fe4ebdb390494c072b12b0b624b Mon Sep 17 00:00:00 2001 From: Soliprem <73885403+Soliprem@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:51:43 +0200 Subject: [PATCH 0195/1178] Fix typo in otter setupOpts (#424) * Revert "leap: changed default binds" This reverts commit 92a7bfc4b8f788eeadf30c2ae858fd93a69dab26. * Reapply "leap: changed default binds" This reverts commit ede1d4437e2d8d1a6ff31b4dc855676c6e16df36. * otter: fixed stupid typo * otter: added changelog entry --- docs/release-notes/rl-0.7.md | 1 + modules/plugins/lsp/otter/config.nix | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 49e99df7..d5f050ab 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -279,6 +279,7 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to - 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 +- Fixed typo in Otter's setupOpts - Add Neorg support under `vim.notes.neorg` - Add LSP, diagnostics, formatter and Treesitter support for Kotlin under `vim.languages.kotlin` diff --git a/modules/plugins/lsp/otter/config.nix b/modules/plugins/lsp/otter/config.nix index e5df92f7..c8a2d3c6 100644 --- a/modules/plugins/lsp/otter/config.nix +++ b/modules/plugins/lsp/otter/config.nix @@ -32,7 +32,7 @@ in { pluginRC.otter-nvim = entryAnywhere '' -- Enable otter diagnostics viewer - require("otter").setup({${toLuaObject cfg.otter-nvim.setupOpts}}) + require("otter").setup(${toLuaObject cfg.otter-nvim.setupOpts}) ''; }; }; From 30a8a8fce08f2c9a674c2ed02e122b6132604067 Mon Sep 17 00:00:00 2001 From: diniamo Date: Sun, 27 Oct 2024 12:53:44 +0100 Subject: [PATCH 0196/1178] languages/nix: use stricter type for lsp.server --- modules/plugins/languages/nix.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index 82dded69..ffb69e92 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -145,7 +145,7 @@ in { enable = mkEnableOption "Nix LSP support" // {default = config.vim.languages.enableLSP;}; server = mkOption { description = "Nix LSP server to use"; - type = str; + type = enum (attrNames servers); default = defaultServer; }; From 5ab1af9285ddf5040e434422543c116194a41959 Mon Sep 17 00:00:00 2001 From: diniamo Date: Sun, 27 Oct 2024 12:54:39 +0100 Subject: [PATCH 0197/1178] languages/kotlin: allow specifying a command for lsp.package, fix indentation --- modules/plugins/languages/kotlin.nix | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/plugins/languages/kotlin.nix b/modules/plugins/languages/kotlin.nix index 5637b4f4..03433215 100644 --- a/modules/plugins/languages/kotlin.nix +++ b/modules/plugins/languages/kotlin.nix @@ -8,7 +8,7 @@ inherit (lib.modules) mkIf mkMerge; inherit (lib.meta) getExe; inherit (lib.nvim.languages) diagnosticsToLua; - inherit (lib.types) package; + inherit (lib.types) either package listOf str; inherit (lib.nvim.types) mkGrammarOption diagnostics; inherit (lib.lists) isList; inherit (lib.nvim.lua) expToLua; @@ -43,17 +43,17 @@ in { package = mkOption { description = "kotlin_language_server package with Kotlin runtime"; - type = package; + type = either package (listOf str); example = literalExpression '' pkgs.symlinkJoin { - name = "kotlin-language-server-wrapped"; - paths = [pkgs.kotlin-language-server]; - nativeBuildInputs = [pkgs.makeWrapper]; - postBuild = ''' - wrapProgram $out/bin/kotlin-language-server \ - --prefix PATH : ''${pkgs.kotlin}/bin - '''; - }; + name = "kotlin-language-server-wrapped"; + paths = [pkgs.kotlin-language-server]; + nativeBuildInputs = [pkgs.makeBinaryWrapper]; + postBuild = ''' + wrapProgram $out/bin/kotlin-language-server \ + --prefix PATH : ''${pkgs.kotlin}/bin + '''; + }; ''; default = pkgs.kotlin-language-server; }; From 0aa557dac69a9cd60e4fd4bb038aa09ab9781241 Mon Sep 17 00:00:00 2001 From: diniamo Date: Sun, 27 Oct 2024 12:54:53 +0100 Subject: [PATCH 0198/1178] lsp: avoid vimscript in bindings --- modules/plugins/lsp/config.nix | 42 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/modules/plugins/lsp/config.nix b/modules/plugins/lsp/config.nix index 52dc15b4..dbf6cdbd 100644 --- a/modules/plugins/lsp/config.nix +++ b/modules/plugins/lsp/config.nix @@ -18,7 +18,7 @@ mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; mkBinding = binding: action: if binding.value != null - then "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', 'lua ${action}', {noremap=true, silent=true, desc='${binding.description}'})" + then "vim.keymap.set('n', '${binding.value}', ${action}, {buffer=bufnr, noremap=true, silent=true, desc='${binding.description}'})" else ""; in { config = mkIf cfg.enable { @@ -31,26 +31,26 @@ in { vim.g.formatsave = ${boolToString cfg.formatOnSave}; local attach_keymaps = function(client, bufnr) - ${mkBinding mappings.goToDeclaration "vim.lsp.buf.declaration()"} - ${mkBinding mappings.goToDefinition "vim.lsp.buf.definition()"} - ${mkBinding mappings.goToType "vim.lsp.buf.type_definition()"} - ${mkBinding mappings.listImplementations "vim.lsp.buf.implementation()"} - ${mkBinding mappings.listReferences "vim.lsp.buf.references()"} - ${mkBinding mappings.nextDiagnostic "vim.diagnostic.goto_next()"} - ${mkBinding mappings.previousDiagnostic "vim.diagnostic.goto_prev()"} - ${mkBinding mappings.openDiagnosticFloat "vim.diagnostic.open_float()"} - ${mkBinding mappings.documentHighlight "vim.lsp.buf.document_highlight()"} - ${mkBinding mappings.listDocumentSymbols "vim.lsp.buf.document_symbol()"} - ${mkBinding mappings.addWorkspaceFolder "vim.lsp.buf.add_workspace_folder()"} - ${mkBinding mappings.removeWorkspaceFolder "vim.lsp.buf.remove_workspace_folder()"} - ${mkBinding mappings.listWorkspaceFolders "print(vim.inspect(vim.lsp.buf.list_workspace_folders()))"} - ${mkBinding mappings.listWorkspaceSymbols "vim.lsp.buf.workspace_symbol()"} - ${mkBinding mappings.hover "vim.lsp.buf.hover()"} - ${mkBinding mappings.signatureHelp "vim.lsp.buf.signature_help()"} - ${mkBinding mappings.renameSymbol "vim.lsp.buf.rename()"} - ${mkBinding mappings.codeAction "vim.lsp.buf.code_action()"} - ${mkBinding mappings.format "vim.lsp.buf.format()"} - ${mkBinding mappings.toggleFormatOnSave "vim.b.disableFormatSave = not vim.b.disableFormatSave"} + ${mkBinding mappings.goToDeclaration "vim.lsp.buf.declaration"} + ${mkBinding mappings.goToDefinition "vim.lsp.buf.definition"} + ${mkBinding mappings.goToType "vim.lsp.buf.type_definition"} + ${mkBinding mappings.listImplementations "vim.lsp.buf.implementation"} + ${mkBinding mappings.listReferences "vim.lsp.buf.references"} + ${mkBinding mappings.nextDiagnostic "vim.diagnostic.goto_next"} + ${mkBinding mappings.previousDiagnostic "vim.diagnostic.goto_prev"} + ${mkBinding mappings.openDiagnosticFloat "vim.diagnostic.open_float"} + ${mkBinding mappings.documentHighlight "vim.lsp.buf.document_highlight"} + ${mkBinding mappings.listDocumentSymbols "vim.lsp.buf.document_symbol"} + ${mkBinding mappings.addWorkspaceFolder "vim.lsp.buf.add_workspace_folder"} + ${mkBinding mappings.removeWorkspaceFolder "vim.lsp.buf.remove_workspace_folder"} + ${mkBinding mappings.listWorkspaceFolders "function() vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders())) end"} + ${mkBinding mappings.listWorkspaceSymbols "vim.lsp.buf.workspace_symbol"} + ${mkBinding mappings.hover "vim.lsp.buf.hover"} + ${mkBinding mappings.signatureHelp "vim.lsp.buf.signature_help"} + ${mkBinding mappings.renameSymbol "vim.lsp.buf.rename"} + ${mkBinding mappings.codeAction "vim.lsp.buf.code_action"} + ${mkBinding mappings.format "vim.lsp.buf.format"} + ${mkBinding mappings.toggleFormatOnSave "function() vim.b.disableFormatSave = not vim.b.disableFormatSave end"} end -- Enable formatting From 665feee445dd6fa59d267ba2bfcba7a0ee57ff62 Mon Sep 17 00:00:00 2001 From: diniamo Date: Sun, 27 Oct 2024 12:55:06 +0100 Subject: [PATCH 0199/1178] languages: csharp init with omnisharp and csharp_ls --- configuration.nix | 1 + docs/release-notes/rl-0.7.md | 14 ++- flake.lock | 34 +++++++ flake.nix | 10 +++ modules/plugins/languages/csharp.nix | 122 ++++++++++++++++++++++++++ modules/plugins/languages/default.nix | 1 + 6 files changed, 179 insertions(+), 3 deletions(-) create mode 100644 modules/plugins/languages/csharp.nix diff --git a/configuration.nix b/configuration.nix index 832bf95c..cbab23e6 100644 --- a/configuration.nix +++ b/configuration.nix @@ -75,6 +75,7 @@ isMaximal: { enable = isMaximal; crates.enable = isMaximal; }; + csharp.enable = isMaximal; }; visuals = { diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index d5f050ab..0d560f82 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -189,6 +189,9 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to - Add sorting function options for completion sources under [](#opt-vim.autocomplete.nvim-cmp.setupOpts.sorting.comparators) +- Add C# support under `vim.languages.csharp`, with support for both + omnisharp-roslyn and csharp-language-server. + [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 @@ -230,7 +233,8 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to `vim.languages.ts.extensions.ts-error-translator` to aid with Typescript development. -- Add [neo-tree.nvim] as an alternative file-tree plugin. It will be available under `vim.filetree.neo-tree`, similar to nvimtree. +- Add [neo-tree.nvim] as an alternative file-tree plugin. It will be available + under `vim.filetree.neo-tree`, similar to nvimtree. - Add `nvf-print-config` & `nvf-print-config-path` helper scripts to Neovim closure. Both of those scripts have been automatically added to your PATH upon @@ -298,5 +302,9 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to [nezia1](https://github.com/nezia1): -- Add [biome](https://github.com/biomejs/biome) support for Typescript, CSS and Svelte. Enable them via [](#opt-vim.languages.ts.format.type), [](#opt-vim.languages.css.format.type) and [](#opt-vim.languages.svelte.format.type) respectively. -- Replace [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) with [nixfmt](https://github.com/NixOS/nixfmt) (nixfmt-rfc-style). +- Add [biome](https://github.com/biomejs/biome) support for Typescript, CSS and + Svelte. Enable them via [](#opt-vim.languages.ts.format.type), + [](#opt-vim.languages.css.format.type) and + [](#opt-vim.languages.svelte.format.type) respectively. +- Replace [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) with + [nixfmt](https://github.com/NixOS/nixfmt) (nixfmt-rfc-style). diff --git a/flake.lock b/flake.lock index 34a22430..4e5ec65c 100644 --- a/flake.lock +++ b/flake.lock @@ -460,6 +460,22 @@ "type": "github" } }, + "plugin-csharpls-extended": { + "flake": false, + "locked": { + "lastModified": 1728438370, + "narHash": "sha256-sOLPV5IhOvQ0+u7CDAfG3X0ZbRCicz18QyYXQ0dxpwQ=", + "owner": "Decodetalkers", + "repo": "csharpls-extended-lsp.nvim", + "rev": "b647e1bd1f9c0410f5ef4a1517a331cbac322d9a", + "type": "github" + }, + "original": { + "owner": "Decodetalkers", + "repo": "csharpls-extended-lsp.nvim", + "type": "github" + } + }, "plugin-dashboard-nvim": { "flake": false, "locked": { @@ -1453,6 +1469,22 @@ "type": "github" } }, + "plugin-omnisharp-extended": { + "flake": false, + "locked": { + "lastModified": 1719701797, + "narHash": "sha256-P1ZCaW8w+e3H3oBhbEjDc7vuR+XuxJmb/7IbPL3KWi4=", + "owner": "Hoffs", + "repo": "omnisharp-extended-lsp.nvim", + "rev": "aad7bf06b4ca0de816b919d475a75b30f5f62b61", + "type": "github" + }, + "original": { + "owner": "Hoffs", + "repo": "omnisharp-extended-lsp.nvim", + "type": "github" + } + }, "plugin-onedark": { "flake": false, "locked": { @@ -1932,6 +1964,7 @@ "plugin-copilot-cmp": "plugin-copilot-cmp", "plugin-copilot-lua": "plugin-copilot-lua", "plugin-crates-nvim": "plugin-crates-nvim", + "plugin-csharpls-extended": "plugin-csharpls-extended", "plugin-dashboard-nvim": "plugin-dashboard-nvim", "plugin-diffview-nvim": "plugin-diffview-nvim", "plugin-dracula": "plugin-dracula", @@ -1994,6 +2027,7 @@ "plugin-nvim-ts-autotag": "plugin-nvim-ts-autotag", "plugin-nvim-web-devicons": "plugin-nvim-web-devicons", "plugin-obsidian-nvim": "plugin-obsidian-nvim", + "plugin-omnisharp-extended": "plugin-omnisharp-extended", "plugin-onedark": "plugin-onedark", "plugin-orgmode-nvim": "plugin-orgmode-nvim", "plugin-otter-nvim": "plugin-otter-nvim", diff --git a/flake.nix b/flake.nix index d12bdc57..00b56c51 100644 --- a/flake.nix +++ b/flake.nix @@ -211,6 +211,16 @@ flake = false; }; + plugin-omnisharp-extended = { + url = "github:Hoffs/omnisharp-extended-lsp.nvim"; + flake = false; + }; + + plugin-csharpls-extended = { + url = "github:Decodetalkers/csharpls-extended-lsp.nvim"; + flake = false; + }; + # Copying/Registers plugin-registers = { url = "github:tversteeg/registers.nvim"; diff --git a/modules/plugins/languages/csharp.nix b/modules/plugins/languages/csharp.nix new file mode 100644 index 00000000..5011c5cc --- /dev/null +++ b/modules/plugins/languages/csharp.nix @@ -0,0 +1,122 @@ +{ + lib, + pkgs, + config, + options, + ... +}: let + inherit (builtins) attrNames; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) either listOf package str enum; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.strings) optionalString; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.lua) expToLua; + + lspKeyConfig = config.vim.lsp.mappings; + lspKeyOptions = options.vim.lsp.mappings; + mkLspBinding = optionName: action: let + key = lspKeyConfig.${optionName}; + desc = lspKeyOptions.${optionName}.description; + in + optionalString (key != null) "vim.keymap.set('n', '${key}', ${action}, {buffer=bufnr, noremap=true, silent=true, desc='${desc}'})"; + + # Omnisharp doesn't have colors in popup docs for some reason, and I've also + # seen mentions of it being way slower, so until someone finds missing + # functionality, this will be the default. + defaultServer = "csharp_ls"; + servers = { + omnisharp = { + package = pkgs.omnisharp-roslyn; + internalFormatter = true; + lspConfig = '' + lspconfig.omnisharp.setup { + capabilities = capabilities, + on_attach = function(client, bufnr) + default_on_attach(client, bufnr) + + local oe = require("omnisharp_extended") + ${mkLspBinding "goToDefinition" "oe.lsp_definition"} + ${mkLspBinding "goToType" "oe.lsp_type_definition"} + ${mkLspBinding "listReferences" "oe.lsp_references"} + ${mkLspBinding "listImplementations" "oe.lsp_implementation"} + end, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else "{'${cfg.lsp.package}/bin/OmniSharp'}" + } + } + ''; + }; + + csharp_ls = { + package = pkgs.csharp-ls; + internalFormatter = true; + lspConfig = '' + local extended_handler = require("csharpls_extended").handler + + lspconfig.csharp_ls.setup { + capabilities = capabilities, + on_attach = default_on_attach, + handlers = { + ["textDocument/definition"] = extended_handler, + ["textDocument/typeDefinition"] = extended_handler + }, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else "{'${cfg.lsp.package}/bin/csharp-ls'}" + } + } + ''; + }; + }; + + extraServerPlugins = { + omnisharp = ["omnisharp-extended"]; + csharp_ls = ["csharpls-extended"]; + }; + + cfg = config.vim.languages.csharp; +in { + options = { + vim.languages.csharp = { + enable = mkEnableOption "C# language support"; + + treesitter = { + enable = mkEnableOption "C# treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "c-sharp"; + }; + + lsp = { + enable = mkEnableOption "C# LSP support" // {default = config.vim.languages.enableLSP;}; + server = mkOption { + description = "C# LSP server to use"; + type = enum (attrNames servers); + default = defaultServer; + }; + + package = mkOption { + description = "C# LSP server package, or the command to run as a list of strings"; + type = either package (listOf str); + default = servers.${cfg.lsp.server}.package; + }; + }; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + + (mkIf cfg.lsp.enable { + vim.startPlugins = extraServerPlugins.${cfg.lsp.server} or []; + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.csharp-lsp = servers.${cfg.lsp.server}.lspConfig; + }) + ]); +} diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 54a9e1c4..9dec325b 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -28,6 +28,7 @@ in { ./ts.nix ./typst.nix ./zig.nix + ./csharp.nix ]; options.vim.languages = { From 8ff50562d7203a2b87bc6409e806f13b115d6b48 Mon Sep 17 00:00:00 2001 From: ppenguin Date: Wed, 30 Oct 2024 12:01:16 +0100 Subject: [PATCH 0200/1178] fix markdown-preview config error --- .../plugins/utility/preview/markdown-preview/config.nix | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/plugins/utility/preview/markdown-preview/config.nix b/modules/plugins/utility/preview/markdown-preview/config.nix index 635a8a49..8349d3fc 100644 --- a/modules/plugins/utility/preview/markdown-preview/config.nix +++ b/modules/plugins/utility/preview/markdown-preview/config.nix @@ -4,9 +4,8 @@ lib, ... }: let - inherit (lib.strings) stringLength concatMapStringsSep; + inherit (lib.strings) concatMapStringsSep; inherit (lib.modules) mkIf; - cfg = config.vim.utility.preview.markdownPreview; in { config = mkIf cfg.enable { @@ -19,8 +18,8 @@ in { mkdp_filetypes = [(concatMapStringsSep ", " (x: "'" + x + "'") cfg.filetypes)]; mkdp_command_for_global = cfg.alwaysAllowPreview; mkdp_open_to_the_world = cfg.broadcastServer; - mkdp_open_ip = mkIf (stringLength cfg.customIP > 0) cfg.customIP; - mkdp_port = mkIf (stringLength cfg.customPort > 0) cfg.customPort; + mkdp_open_ip = cfg.customIP; + mkdp_port = cfg.customPort; }; }; } From c6453c4e6927a9aac13593911520a2b91a3ac472 Mon Sep 17 00:00:00 2001 From: diniamo Date: Thu, 31 Oct 2024 13:09:05 +0100 Subject: [PATCH 0201/1178] languages/julia: add Co-authored-by: raf --- configuration.nix | 7 +- docs/release-notes/rl-0.7.md | 4 + modules/plugins/languages/default.nix | 1 + modules/plugins/languages/julia.nix | 126 ++++++++++++++++++++++++++ 4 files changed, 133 insertions(+), 5 deletions(-) create mode 100644 modules/plugins/languages/julia.nix diff --git a/configuration.nix b/configuration.nix index cbab23e6..b5683ea5 100644 --- a/configuration.nix +++ b/configuration.nix @@ -65,17 +65,14 @@ isMaximal: { r.enable = isMaximal; tailwind.enable = isMaximal; typst.enable = isMaximal; - clang = { - enable = isMaximal; - lsp.server = "clangd"; - }; - + clang.enable = isMaximal; scala.enable = isMaximal; rust = { enable = isMaximal; crates.enable = isMaximal; }; csharp.enable = isMaximal; + julia.enable = isMaximal; }; visuals = { diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 0d560f82..351a0dc5 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -192,6 +192,10 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to - Add C# support under `vim.languages.csharp`, with support for both omnisharp-roslyn and csharp-language-server. +- Add Julia support under `vim.languages.julia`. Note that the entirety of Julia + is bundled with nvf, if you enable the module, since there is no way to + provide only the LSP server. + [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 diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index 9dec325b..a0a57911 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -29,6 +29,7 @@ in { ./typst.nix ./zig.nix ./csharp.nix + ./julia.nix ]; options.vim.languages = { diff --git a/modules/plugins/languages/julia.nix b/modules/plugins/languages/julia.nix new file mode 100644 index 00000000..aa537df9 --- /dev/null +++ b/modules/plugins/languages/julia.nix @@ -0,0 +1,126 @@ +{ + lib, + pkgs, + config, + ... +}: let + inherit (builtins) attrNames isList; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.types) either listOf package str enum bool nullOr; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.strings) optionalString; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.lua) expToLua; + + defaultServer = "julials"; + servers = { + julials = { + package = pkgs.julia.withPackages ["LanguageServer"]; + internalFormatter = true; + lspConfig = '' + lspconfig.julials.setup { + capabilities = capabilities, + on_attach = default_on_attach, + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else '' + { + "${optionalString (cfg.lsp.package != null) "${cfg.lsp.package}/bin/"}julia", + "--startup-file=no", + "--history-file=no", + "--eval", + [[ + using LanguageServer + + depot_path = get(ENV, "JULIA_DEPOT_PATH", "") + project_path = let + dirname(something( + ## 1. Finds an explicitly set project (JULIA_PROJECT) + Base.load_path_expand(( + p = get(ENV, "JULIA_PROJECT", nothing); + p === nothing ? nothing : isempty(p) ? nothing : p + )), + ## 2. Look for a Project.toml file in the current working directory, + ## or parent directories, with $HOME as an upper boundary + Base.current_project(), + ## 3. First entry in the load path + get(Base.load_path(), 1, nothing), + ## 4. Fallback to default global environment, + ## this is more or less unreachable + Base.load_path_expand("@v#.#"), + )) + end + @info "Running language server" VERSION pwd() project_path depot_path + server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path) + server.runlinter = true + run(server) + ]] + } + '' + } + } + ''; + }; + }; + + cfg = config.vim.languages.julia; +in { + options = { + vim.languages.julia = { + enable = mkEnableOption "Julia language support"; + + treesitter = { + enable = mkEnableOption "Julia treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "julia"; + }; + + lsp = { + enable = mkOption { + type = bool; + default = config.vim.languages.enableLSP; + description = '' + Whether to enable Julia LSP support. + + ::: {.note} + The entirety of Julia is bundled with nvf, if you enable this + option, since there is no way to provide only the LSP server. + + If you want to avoid that, you have to change + [](#opt-vim.languages.julia.lsp.package) to use the Julia binary + in {env}`PATH` (set it to `null`), and add the `LanguageServer` package to + Julia in your devshells. + ::: + ''; + }; + + server = mkOption { + type = enum (attrNames servers); + default = defaultServer; + description = "Julia LSP server to use"; + }; + + package = mkOption { + description = '' + Julia LSP server package, `null` to use the Julia binary in {env}`PATH`, or + the command to run as a list of strings. + ''; + type = nullOr (either package (listOf str)); + default = servers.${cfg.lsp.server}.package; + }; + }; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.julia-lsp = servers.${cfg.lsp.server}.lspConfig; + }) + ]); +} From 0e763161e2552bcba728b904705f6df0f2264d3b Mon Sep 17 00:00:00 2001 From: Soliprem <73885403+Soliprem@users.noreply.github.com> Date: Sun, 3 Nov 2024 23:14:14 +0100 Subject: [PATCH 0202/1178] languages/vala: init (#432) * vala: init * vala: applying reviews * vala: making formatter work * vala: cleaning up useless import * vala: wrapping uncrustify * vala: added changelog entry --- configuration.nix | 1 + docs/release-notes/rl-0.7.md | 1 + modules/plugins/languages/default.nix | 1 + modules/plugins/languages/vala.nix | 79 +++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 modules/plugins/languages/vala.nix diff --git a/configuration.nix b/configuration.nix index b5683ea5..a3ab7bf2 100644 --- a/configuration.nix +++ b/configuration.nix @@ -73,6 +73,7 @@ isMaximal: { }; csharp.enable = isMaximal; julia.enable = isMaximal; + vala.enable = isMaximal; }; visuals = { diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 351a0dc5..87df91e7 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -292,6 +292,7 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to - Add LSP, diagnostics, formatter and Treesitter support for Kotlin under `vim.languages.kotlin` - changed default keybinds for leap.nvim to avoid altering expected behavior +- Add LSP, formatter and Treesitter support for Vala under `vim.languages.vala` [Bloxx12](https://github.com/Bloxx12) diff --git a/modules/plugins/languages/default.nix b/modules/plugins/languages/default.nix index a0a57911..1ec2b68f 100644 --- a/modules/plugins/languages/default.nix +++ b/modules/plugins/languages/default.nix @@ -14,6 +14,7 @@ in { ./lua.nix ./markdown.nix ./nim.nix + ./vala.nix ./nix.nix ./ocaml.nix ./php.nix diff --git a/modules/plugins/languages/vala.nix b/modules/plugins/languages/vala.nix new file mode 100644 index 00000000..da65a372 --- /dev/null +++ b/modules/plugins/languages/vala.nix @@ -0,0 +1,79 @@ +{ + config, + pkgs, + lib, + ... +}: let + inherit (builtins) attrNames; + inherit (lib.options) mkEnableOption mkOption; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.lists) isList; + inherit (lib.types) enum either listOf package str; + inherit (lib.nvim.types) mkGrammarOption; + inherit (lib.nvim.lua) expToLua; + + cfg = config.vim.languages.vala; + + defaultServer = "vala_ls"; + servers = { + vala_ls = { + package = pkgs.symlinkJoin { + name = "vala-language-server-wrapper"; + paths = [pkgs.vala-language-server]; + buildInputs = [pkgs.makeBinaryWrapper]; + postBuild = '' + wrapProgram $out/bin/vala-language-server \ + --prefix PATH : ${pkgs.uncrustify}/bin + ''; + }; + internalFormatter = true; + lspConfig = '' + lspconfig.vala_ls.setup { + capabilities = capabilities; + on_attach = default_on_attach; + cmd = ${ + if isList cfg.lsp.package + then expToLua cfg.lsp.package + else ''{"${cfg.lsp.package}/bin/vala-language-server"}'' + }, + } + ''; + }; + }; +in { + options.vim.languages.vala = { + enable = mkEnableOption "Vala language support"; + + treesitter = { + enable = mkEnableOption "Vala treesitter" // {default = config.vim.languages.enableTreesitter;}; + package = mkGrammarOption pkgs "vala"; + }; + + lsp = { + enable = mkEnableOption "Vala LSP support" // {default = config.vim.languages.enableLSP;}; + server = mkOption { + description = "Vala LSP server to use"; + type = enum (attrNames servers); + default = defaultServer; + }; + + package = mkOption { + description = "Vala LSP server package, or the command to run as a list of strings"; + type = either package (listOf str); + default = servers.${cfg.lsp.server}.package; + }; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + (mkIf cfg.treesitter.enable { + vim.treesitter.enable = true; + vim.treesitter.grammars = [cfg.treesitter.package]; + }) + + (mkIf cfg.lsp.enable { + vim.lsp.lspconfig.enable = true; + vim.lsp.lspconfig.sources.vala_ls = servers.${cfg.lsp.server}.lspConfig; + }) + ]); +} From 21fcace3ed9d0ee5fb9077248115241996fe322e Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Mon, 4 Nov 2024 16:50:50 +0100 Subject: [PATCH 0203/1178] treewide: implement lazy loading via lz.n for selected plugins (#407) * flake: add lz.n and lzn-auto-require * lazy: init module * lzn-auto-require: add init lua code * wrapper: fix opt plugin format * lib.binds: add lz.n variant of bind functions * telescope: lazy load * nvim-tree: lazy load * dapui: lazy load * trouble: lazy load * toggleterm: lazy load * cheatsheet: lazy load * diffview: lazy load * icon-picker: lazy load * leap: lazy load * fidget: lazy load * docs: add section on lazy plugins * lazy: support lazy.enable=false * comment-nvim: lazy load * surround-nvim: lazy load * neo-tree: lazy load * fixup! lazy: init module * dap: appease the nix gods (fix statix lint) * flake.lock: fix merge mistake * doc: update release note * fixup! doc: update release note * neo-tree: fix duplicate neo-tree install * lazy: use attrsOf for lazy.plugins * treewide: update lazy.plugins syntax * docs: update lazy.plugins syntax * lazy: cleanup * Update docs/manual/hacking/additional-plugins.md Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * formatting nitpick Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * typo tee hee :3 Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * typo tee hee :4 Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * flake: update lz.n * lazy: update lz.n plugin spec * lazy: allow lines in place of str for lua code * copilot: lazy load * cmp: lazy load this moves cmp itself to lazy.plugins but other plugins that call cmp are not yet lazy so cmp is technically not yet lazy * luasnip: lazy load * flake: add rtp.nvim * cmp: actually lazy load source * fixup! cmp: actually lazy load source * format * docs: fix broken link * cmp-nvim-lsp: lazy load * lazy: allow key mode of str type * cmp: install sourcess via cmp.sourcePlugins * Update docs/manual/hacking/additional-plugins.md Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * lazy: refactor common var * nvim-dap-ui: add setupOpts * refactor: re-order plugin and lz.n configs lazy: make lzn-auto-require togglable * docs: update dag-entries * trouble: remove redundant import * lazy: remove unused module arg * toggleterm: make lazygit keybind optional * toggleterm: use toLuaObject for clarity * surround: rework keymap config * remove stale FIXME * lsp: use cmp_nvim_lsp capabilities * cmp: deduplicate attr key * theme: ensure themes load before lazy plugins * doc: update description of `theme` dag entry * lsp: avoid loading cmp on startup * doc: update configuration docs on custom plugins * cmp: skip trigger_load if lazy disabled * treesitter: remove redundant code * lsp: mark hack as HACK * comment: remove redundant plugin * Squash merge v0.7 into feature/lzn --------- Co-authored-by: raf Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> --- docs/manual/configuring/custom-plugins.md | 5 +- .../configuring/custom-plugins/configuring.md | 36 ++- .../configuring/custom-plugins/lazy-method.md | 40 +++ .../{old-method.md => legacy-method.md} | 2 +- .../{new-method.md => non-lazy-method.md} | 2 +- docs/manual/configuring/dag-entries.md | 14 +- docs/manual/hacking/additional-plugins.md | 58 +++++ docs/release-notes/rl-0.7.md | 4 + flake.lock | 52 ++++ flake.nix | 16 ++ lib/binds.nix | 24 ++ modules/default.nix | 5 +- modules/modules.nix | 1 + modules/plugins/assistant/copilot/config.nix | 116 ++++----- .../comments/comment-nvim/comment-nvim.nix | 8 + .../plugins/comments/comment-nvim/config.nix | 62 ++--- .../plugins/completion/nvim-cmp/config.nix | 163 +++++++----- .../plugins/completion/nvim-cmp/nvim-cmp.nix | 10 +- modules/plugins/debugger/nvim-dap/config.nix | 31 ++- .../plugins/debugger/nvim-dap/nvim-dap.nix | 4 + modules/plugins/filetree/neo-tree/config.nix | 16 +- modules/plugins/filetree/nvimtree/config.nix | 132 +++++----- modules/plugins/lsp/config.nix | 63 ++++- modules/plugins/lsp/trouble/config.nix | 37 ++- modules/plugins/lsp/trouble/trouble.nix | 3 + modules/plugins/snippets/luasnip/config.nix | 15 +- .../plugins/terminal/toggleterm/config.nix | 54 ++-- modules/plugins/theme/theme.nix | 2 +- modules/plugins/treesitter/config.nix | 11 +- .../utility/binds/cheatsheet/config.nix | 13 +- modules/plugins/utility/diffview/config.nix | 13 +- modules/plugins/utility/diffview/diffview.nix | 2 + .../plugins/utility/icon-picker/config.nix | 20 +- .../plugins/utility/motion/leap/config.nix | 110 ++++---- modules/plugins/utility/surround/config.nix | 47 +++- modules/plugins/utility/surround/surround.nix | 49 +++- modules/plugins/utility/telescope/config.nix | 118 ++++----- modules/plugins/visuals/fidget/config.nix | 13 +- modules/wrapper/lazy/config.nix | 108 ++++++++ modules/wrapper/lazy/default.nix | 6 + modules/wrapper/lazy/lazy.nix | 237 ++++++++++++++++++ modules/wrapper/rc/config.nix | 5 +- 42 files changed, 1226 insertions(+), 501 deletions(-) create mode 100644 docs/manual/configuring/custom-plugins/lazy-method.md rename docs/manual/configuring/custom-plugins/{old-method.md => legacy-method.md} (96%) rename docs/manual/configuring/custom-plugins/{new-method.md => non-lazy-method.md} (93%) create mode 100644 modules/wrapper/lazy/config.nix create mode 100644 modules/wrapper/lazy/default.nix create mode 100644 modules/wrapper/lazy/lazy.nix diff --git a/docs/manual/configuring/custom-plugins.md b/docs/manual/configuring/custom-plugins.md index c58c4973..76b32ea4 100644 --- a/docs/manual/configuring/custom-plugins.md +++ b/docs/manual/configuring/custom-plugins.md @@ -20,6 +20,7 @@ custom plugins that you might have added to your configuration. ```{=include=} sections custom-plugins/configuring.md -custom-plugins/new-method.md -custom-plugins/old-method.md +custom-plugins/lazy-method.md +custom-plugins/non-lazy-method.md +custom-plugins/legacy-method.md ``` diff --git a/docs/manual/configuring/custom-plugins/configuring.md b/docs/manual/configuring/custom-plugins/configuring.md index 5e837ce1..71ce9b8f 100644 --- a/docs/manual/configuring/custom-plugins/configuring.md +++ b/docs/manual/configuring/custom-plugins/configuring.md @@ -1,12 +1,32 @@ # Configuring {#sec-configuring-plugins} -Just making the plugin to your Neovim configuration available might not always -be enough. In that case, you can write custom lua config using either -`config.vim.extraPlugins` (which has the `setup` field) or -`config.vim.luaConfigRC`. The first option uses an attribute set, which maps DAG -section names to a custom type, which has the fields `package`, `after`, -`setup`. They allow you to set the package of the plugin, the sections its setup -code should be after (note that the `extraPlugins` option has its own DAG +Just making the plugin to your Neovim configuration available might not always be enough. In that +case, you can write custom lua config using either `config.vim.lazy.plugins.*.setupOpts` +`config.vim.extraPlugins.*.setup` or `config.vim.luaConfigRC`. + +The first option uses an extended version of `lz.n`'s PluginSpec. `setupModule` and `setupOpt` can +be used if the plugin uses a `require('module').setup(...)` pattern. Otherwise, the `before` and +`after` hooks should do what you need. + +```nix +{ + config.vim.lazy.plugins = { + aerial-nvim = { + # ^^^^^^^^^ this name should match the package.pname or package.name + package = aerial-nvim; + + setupModule = "aerial"; + setupOpts = {option_name = false;}; + + after = "print('aerial loaded')"; + }; + }; +} +``` + +The second option uses an attribute set, which maps DAG section names to a custom type, which has +the fields `package`, `after`, `setup`. They allow you to set the package of the plugin, the +sections its setup code should be after (note that the `extraPlugins` option has its own DAG scope), and the its setup code respectively. For example: ```nix @@ -24,7 +44,7 @@ config.vim.extraPlugins = with pkgs.vimPlugins; { } ``` -The second option also uses an attribute set, but this one is resolved as a DAG +The third option also uses an attribute set, but this one is resolved as a DAG directly. The attribute names denote the section names, and the values lua code. For example: diff --git a/docs/manual/configuring/custom-plugins/lazy-method.md b/docs/manual/configuring/custom-plugins/lazy-method.md new file mode 100644 index 00000000..77b77d5d --- /dev/null +++ b/docs/manual/configuring/custom-plugins/lazy-method.md @@ -0,0 +1,40 @@ +# Lazy Method {#sec-lazy-method} + +As of version **0.7**, we exposed an API for configuring lazy-loaded plugins via +`lz.n` and `lzn-auto-require`. + +```nix +{ + config.vim.lazy.plugins = { + aerial = { + package = pkgs.vimPlugins.aerial-nvim; + setupModule = aerial; + setupOpts = { + option_name = true; + }; + after = '' + -- custom lua code to run after plugin is loaded + print('aerial loaded') + ''; + + # Explicitly mark plugin as lazy. You don't need this if you define one of + # the trigger "events" below + lazy = true; + + # load on command + cmd = ["AerialOpen"]; + + # load on event + event = ["BufEnter"]; + + # load on keymap + keys = [ + { + key = "a"; + action = ":AerialToggle"; + } + ]; + }; + }; +} +``` diff --git a/docs/manual/configuring/custom-plugins/old-method.md b/docs/manual/configuring/custom-plugins/legacy-method.md similarity index 96% rename from docs/manual/configuring/custom-plugins/old-method.md rename to docs/manual/configuring/custom-plugins/legacy-method.md index 3b9d090e..0a6b3775 100644 --- a/docs/manual/configuring/custom-plugins/old-method.md +++ b/docs/manual/configuring/custom-plugins/legacy-method.md @@ -1,4 +1,4 @@ -# Old Method {#sec-old-method} +# Legacy Method {#sec-legacy-method} Prior to version 0.5, the method of adding new plugins was adding the plugin package to `vim.startPlugins` and add its configuration as a DAG under one of diff --git a/docs/manual/configuring/custom-plugins/new-method.md b/docs/manual/configuring/custom-plugins/non-lazy-method.md similarity index 93% rename from docs/manual/configuring/custom-plugins/new-method.md rename to docs/manual/configuring/custom-plugins/non-lazy-method.md index 200ba5e7..351af2eb 100644 --- a/docs/manual/configuring/custom-plugins/new-method.md +++ b/docs/manual/configuring/custom-plugins/non-lazy-method.md @@ -1,4 +1,4 @@ -# New Method {#sec-new-method} +# Non-lazy Method {#sec-non-lazy-method} As of version **0.5**, we have a more extensive API for configuring plugins, under `vim.extraPlugins`. Instead of using DAGs exposed by the library, you may diff --git a/docs/manual/configuring/dag-entries.md b/docs/manual/configuring/dag-entries.md index 402cde66..ff5d5c72 100644 --- a/docs/manual/configuring/dag-entries.md +++ b/docs/manual/configuring/dag-entries.md @@ -12,12 +12,14 @@ entries in nvf: 2. `globalsScript` - used to set globals defined in `vim.globals` 3. `basic` - used to set basic configuration options 4. `optionsScript` - used to set options defined in `vim.o` -5. `theme` (this is simply placed before `pluginConfigs`, meaning that - surrounding entries don't depend on it) - used to set up the theme, which has - to be done before other plugins -6. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option, +5. `theme` (this is simply placed before `pluginConfigs` and `lazyConfigs`, meaning that + surrounding entries don't depend on it) - used to set up the theme, which has to be done before + other plugins +6. `lazyConfigs` - `lz.n` and `lzn-auto-require` configs. If `vim.lazy.enable` + is false, this will contain each plugin's config instead. +7. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option, see the [Custom Plugins](/index.xhtml#ch-custom-plugins) page for adding your own plugins) DAG, used to set up internal plugins -7. `extraPluginConfigs` - the result of `vim.extraPlugins`, which is not a +8. `extraPluginConfigs` - the result of `vim.extraPlugins`, which is not a direct DAG, but is converted to, and resolved as one internally -8. `mappings` - the result of `vim.maps` +9. `mappings` - the result of `vim.maps` diff --git a/docs/manual/hacking/additional-plugins.md b/docs/manual/hacking/additional-plugins.md index 7c802154..8531aa98 100644 --- a/docs/manual/hacking/additional-plugins.md +++ b/docs/manual/hacking/additional-plugins.md @@ -124,3 +124,61 @@ vim.your-plugin.setupOpts = { ''; } ``` + +## Lazy plugins {#sec-lazy-plugins} + +If the plugin can be lazy-loaded, `vim.lazy.plugins` should be used to add it. Lazy +plugins are managed by `lz.n`. + +```nix +# in modules/.../your-plugin/config.nix +{lib, config, ...}: +let + cfg = config.vim.your-plugin; +in { + vim.lazy.plugins.your-plugin = { + # instead of vim.startPlugins, use this: + package = "your-plugin"; + + # if your plugin uses the `require('your-plugin').setup{...}` pattern + setupModule = "your-plugin"; + inherit (cfg) setupOpts; + + # events that trigger this plugin to be loaded + event = ["DirChanged"]; + cmd = ["YourPluginCommand"]; + + # keymaps + keys = [ + # we'll cover this in detail in the keymaps section + { + key = "d"; + mode = "n"; + action = ":YourPluginCommand"; + } + ]; + }; +; +} +``` + +This results in the following lua code: +```lua +require('lz.n').load({ + { + "name-of-your-plugin", + after = function() + require('your-plugin').setup({--[[ your setupOpts ]]}) + end, + + event = {"DirChanged"}, + cmd = {"YourPluginCommand"}, + keys = { + {"d", ":YourPluginCommand", mode = {"n"}}, + }, + } +}) +``` + +A full list of options can be found +[here](https://notashelf.github.io/nvf/options.html#opt-vim.lazy.plugins diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 87df91e7..bfd08b1b 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -123,6 +123,10 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to recommended to go through rustacean.nvim's README to take a closer look at its features and usage +- Add [lz.n] support and lazy-load some builtin plugins. + +[lz.n]: https://github.com/mrcjkb/lz.n + [jacekpoz](https://jacekpoz.pl): [ocaml-lsp]: https://github.com/ocaml/ocaml-lsp diff --git a/flake.lock b/flake.lock index 4e5ec65c..f387d4ad 100644 --- a/flake.lock +++ b/flake.lock @@ -892,6 +892,39 @@ "type": "github" } }, + "plugin-lz-n": { + "flake": false, + "locked": { + "lastModified": 1729525284, + "narHash": "sha256-fk+ejqcqqOQz3q4D3VB2Q+U/6wCpCDk1tiDMp2YrPNE=", + "owner": "nvim-neorocks", + "repo": "lz.n", + "rev": "ffd9991400ba7137f4fa8560ff50bccd7f8fb3ee", + "type": "github" + }, + "original": { + "owner": "nvim-neorocks", + "repo": "lz.n", + "type": "github" + } + }, + "plugin-lzn-auto-require": { + "flake": false, + "locked": { + "lastModified": 1727636949, + "narHash": "sha256-BAOzN+XOrFAJwHmsF8JtZ2EyjP9283FD/I2TbFqGSEw=", + "owner": "horriblename", + "repo": "lzn-auto-require", + "rev": "55ecd60831dac8c01d6f3dcb63a30a63a1690eb8", + "type": "github" + }, + "original": { + "owner": "horriblename", + "ref": "require-rewrite", + "repo": "lzn-auto-require", + "type": "github" + } + }, "plugin-mind-nvim": { "flake": false, "locked": { @@ -1629,6 +1662,22 @@ "type": "github" } }, + "plugin-rtp-nvim": { + "flake": false, + "locked": { + "lastModified": 1724409589, + "narHash": "sha256-lmJbiD7I7MTEEpukESs67uAmLyn+p66hrUKLbEHp0Kw=", + "owner": "nvim-neorocks", + "repo": "rtp.nvim", + "rev": "494ddfc888bb466555d90ace731856de1320fe45", + "type": "github" + }, + "original": { + "owner": "nvim-neorocks", + "repo": "rtp.nvim", + "type": "github" + } + }, "plugin-rustaceanvim": { "flake": false, "locked": { @@ -1991,6 +2040,8 @@ "plugin-lua-utils-nvim": "plugin-lua-utils-nvim", "plugin-lualine": "plugin-lualine", "plugin-luasnip": "plugin-luasnip", + "plugin-lz-n": "plugin-lz-n", + "plugin-lzn-auto-require": "plugin-lzn-auto-require", "plugin-mind-nvim": "plugin-mind-nvim", "plugin-minimap-vim": "plugin-minimap-vim", "plugin-modes-nvim": "plugin-modes-nvim", @@ -2037,6 +2088,7 @@ "plugin-project-nvim": "plugin-project-nvim", "plugin-registers": "plugin-registers", "plugin-rose-pine": "plugin-rose-pine", + "plugin-rtp-nvim": "plugin-rtp-nvim", "plugin-rustaceanvim": "plugin-rustaceanvim", "plugin-scrollbar-nvim": "plugin-scrollbar-nvim", "plugin-smartcolumn": "plugin-smartcolumn", diff --git a/flake.nix b/flake.nix index 00b56c51..d8efa3b8 100644 --- a/flake.nix +++ b/flake.nix @@ -113,6 +113,22 @@ }; ## Plugins + # Lazy loading + plugin-lz-n = { + url = "github:nvim-neorocks/lz.n"; + flake = false; + }; + + plugin-lzn-auto-require = { + url = "github:horriblename/lzn-auto-require/require-rewrite"; + flake = false; + }; + + plugin-rtp-nvim = { + url = "github:nvim-neorocks/rtp.nvim"; + flake = false; + }; + # LSP plugins plugin-nvim-lspconfig = { url = "github:neovim/nvim-lspconfig"; diff --git a/lib/binds.nix b/lib/binds.nix index 8c9e9a62..298cd30a 100644 --- a/lib/binds.nix +++ b/lib/binds.nix @@ -67,6 +67,30 @@ mkLuaBinding binding.value action binding.description; pushDownDefault = attr: mapAttrs (_: mkDefault) attr; + + mkLznBinding = mode: key: action: desc: { + inherit mode desc key action; + }; + + mkLznExprBinding = mode: key: action: desc: { + inherit mode desc key action; + lua = true; + silent = true; + expr = true; + }; + + mkSetLznBinding = binding: action: { + inherit action; + key = binding.value; + desc = binding.description; + }; + + mkSetLuaLznBinding = binding: action: { + inherit action; + key = binding.value; + lua = true; + desc = binding.description; + }; }; in binds diff --git a/modules/default.nix b/modules/default.nix index 6a950802..6306da9a 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -84,10 +84,7 @@ # built (or "normalized") plugins that are modified builtStartPlugins = buildConfigPlugins vimOptions.startPlugins; - builtOptPlugins = map (package: { - plugin = package; - optional = true; - }) (buildConfigPlugins vimOptions.optPlugins); + builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins); # additional Lua and Python3 packages, mapped to their respective functions # to conform to the format mnw expects. end user should diff --git a/modules/modules.nix b/modules/modules.nix index 1204e43f..784c413e 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -50,6 +50,7 @@ "build" "rc" "warnings" + "lazy" ]; # Extra modules, such as deprecation warnings diff --git a/modules/plugins/assistant/copilot/config.nix b/modules/plugins/assistant/copilot/config.nix index 923a0c6d..9f92d14a 100644 --- a/modules/plugins/assistant/copilot/config.nix +++ b/modules/plugins/assistant/copilot/config.nix @@ -4,11 +4,8 @@ ... }: let inherit (builtins) toJSON; - inherit (lib.nvim.lua) toLuaObject; - inherit (lib.modules) mkIf mkMerge; - inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.lists) optionals; - inherit (lib.nvim.binds) mkLuaBinding; + inherit (lib.modules) mkIf; + inherit (lib.strings) optionalString; cfg = config.vim.assistant.copilot; @@ -23,65 +20,68 @@ end end ''; + + mkLuaKeymap = mode: key: action: desc: opts: + opts + // { + inherit mode key action desc; + lua = true; + }; in { config = mkIf cfg.enable { - vim.startPlugins = - [ - "copilot-lua" - # cfg.copilotNodePackage - ] - ++ optionals cfg.cmp.enable [ - "copilot-cmp" - ]; + vim = { + lazy.plugins = { + copilot-lua = { + package = "copilot-lua"; + setupModule = "copilot"; + inherit (cfg) setupOpts; + after = mkIf cfg.cmp.enable "require('copilot_cmp').setup()"; - vim.autocomplete.nvim-cmp.sources = {copilot = "[Copilot]";}; + cmd = ["Copilot" "CopilotAuth" "CopilotDetach" "CopilotPanel" "CopilotStop"]; + keys = [ + (mkLuaKeymap ["n"] cfg.mappings.panel.accept (wrapPanelBinding ''require("copilot.panel").accept'' cfg.mappings.panel.accept) "[copilot] Accept suggestion" {}) + (mkLuaKeymap ["n"] cfg.mappings.panel.jumpNext (wrapPanelBinding "require(\"copilot.panel\").jump_next" cfg.mappings.panel.jumpNext) "[copilot] Accept suggestion" {}) + (mkLuaKeymap ["n"] cfg.mappings.panel.jumpPrev (wrapPanelBinding "require(\"copilot.panel\").jump_prev" cfg.mappings.panel.jumpPrev) "[copilot] Accept suggestion" {}) + (mkLuaKeymap ["n"] cfg.mappings.panel.refresh (wrapPanelBinding "require(\"copilot.panel\").refresh" cfg.mappings.panel.refresh) "[copilot] Accept suggestion" {}) + (mkLuaKeymap ["n"] cfg.mappings.panel.open (wrapPanelBinding '' + function() require("copilot.panel").open({ position = "${cfg.setupOpts.panel.layout.position}", ratio = ${toString cfg.setupOpts.panel.layout.ratio}, }) end + '' + cfg.mappings.panel.open) "[copilot] Accept suggestion" {}) - vim.pluginRC.copilot = entryAnywhere '' - require("copilot").setup(${toLuaObject cfg.setupOpts}) - - ${lib.optionalString cfg.cmp.enable '' - require("copilot_cmp").setup() - ''} - ''; - - # Disable plugin handled keymaps. - # Setting it here so that it doesn't show up in user docs - vim.assistant.copilot.setupOpts = { - panel.keymap = { - jump_prev = lib.mkDefault false; - jump_next = lib.mkDefault false; - accept = lib.mkDefault false; - refresh = lib.mkDefault false; - open = lib.mkDefault false; + (mkLuaKeymap ["i"] cfg.mappings.suggestion.accept "function() require('copilot.suggestion').accept() end" "[copilot] Accept suggestion" {}) + (mkLuaKeymap ["i"] cfg.mappings.suggestion.acceptLine "function() require('copilot.suggestion').accept_line() end" "[copilot] Accept suggestion (line)" {}) + (mkLuaKeymap ["i"] cfg.mappings.suggestion.acceptWord "function() require('copilot.suggestion').accept_word() end" "[copilot] Accept suggestion (word)" {}) + (mkLuaKeymap ["i"] cfg.mappings.suggestion.dismiss "function() require('copilot.suggestion').dismiss() end" "[copilot] dismiss suggestion" {}) + (mkLuaKeymap ["i"] cfg.mappings.suggestion.next "function() require('copilot.suggestion').next() end" "[copilot] next suggestion" {}) + (mkLuaKeymap ["i"] cfg.mappings.suggestion.prev "function() require('copilot.suggestion').prev() end" "[copilot] previous suggestion" {}) + ]; + }; }; - suggestion.keymap = { - accept = lib.mkDefault false; - accept_word = lib.mkDefault false; - accept_line = lib.mkDefault false; - next = lib.mkDefault false; - prev = lib.mkDefault false; - dismiss = lib.mkDefault false; + + autocomplete.nvim-cmp = { + sources = {copilot = "[Copilot]";}; + sourcePlugins = ["copilot-cmp"]; + }; + + # Disable plugin handled keymaps. + # Setting it here so that it doesn't show up in user docs + assistant.copilot.setupOpts = { + panel.keymap = { + jump_prev = lib.mkDefault false; + jump_next = lib.mkDefault false; + accept = lib.mkDefault false; + refresh = lib.mkDefault false; + open = lib.mkDefault false; + }; + suggestion.keymap = { + accept = lib.mkDefault false; + accept_word = lib.mkDefault false; + accept_line = lib.mkDefault false; + next = lib.mkDefault false; + prev = lib.mkDefault false; + dismiss = lib.mkDefault false; + }; }; }; - - vim.maps.normal = mkMerge [ - (mkLuaBinding cfg.mappings.panel.jumpPrev (wrapPanelBinding "require(\"copilot.panel\").jump_prev" cfg.mappings.panel.jumpPrev) "[copilot] Accept suggestion") - (mkLuaBinding cfg.mappings.panel.jumpNext (wrapPanelBinding "require(\"copilot.panel\").jump_next" cfg.mappings.panel.jumpNext) "[copilot] Accept suggestion") - (mkLuaBinding cfg.mappings.panel.accept (wrapPanelBinding ''require("copilot.panel").accept'' cfg.mappings.panel.accept) "[copilot] Accept suggestion") - (mkLuaBinding cfg.mappings.panel.refresh (wrapPanelBinding "require(\"copilot.panel\").refresh" cfg.mappings.panel.refresh) "[copilot] Accept suggestion") - (mkLuaBinding cfg.mappings.panel.open (wrapPanelBinding '' - function() require("copilot.panel").open({ position = "${cfg.setupOpts.panel.layout.position}", ratio = ${toString cfg.setupOpts.panel.layout.ratio}, }) end - '' - cfg.mappings.panel.open) "[copilot] Accept suggestion") - ]; - - vim.maps.insert = mkMerge [ - (mkLuaBinding cfg.mappings.suggestion.accept "require(\"copilot.suggestion\").accept" "[copilot] Accept suggestion") - (mkLuaBinding cfg.mappings.suggestion.acceptLine "require(\"copilot.suggestion\").accept_line" "[copilot] Accept suggestion (line)") - (mkLuaBinding cfg.mappings.suggestion.acceptWord "require(\"copilot.suggestion\").accept_word" "[copilot] Accept suggestion (word)") - (mkLuaBinding cfg.mappings.suggestion.next "require(\"copilot.suggestion\").next" "[copilot] next suggestion") - (mkLuaBinding cfg.mappings.suggestion.prev "require(\"copilot.suggestion\").prev" "[copilot] previous suggestion") - (mkLuaBinding cfg.mappings.suggestion.dismiss "require(\"copilot.suggestion\").dismiss" "[copilot] dismiss suggestion") - ]; }; } diff --git a/modules/plugins/comments/comment-nvim/comment-nvim.nix b/modules/plugins/comments/comment-nvim/comment-nvim.nix index 61a91715..76fd8131 100644 --- a/modules/plugins/comments/comment-nvim/comment-nvim.nix +++ b/modules/plugins/comments/comment-nvim/comment-nvim.nix @@ -1,6 +1,7 @@ {lib, ...}: let inherit (lib.options) mkEnableOption; inherit (lib.nvim.binds) mkMappingOption; + inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.comments.comment-nvim = { enable = mkEnableOption "smart and powerful comment plugin for neovim comment-nvim"; @@ -15,5 +16,12 @@ in { toggleSelectedLine = mkMappingOption "Toggle selected comment" "gc"; toggleSelectedBlock = mkMappingOption "Toggle selected block" "gb"; }; + + setupOpts = mkPluginSetupOption "Comment-nvim" { + mappings = { + basic = mkEnableOption "basic mappings"; + extra = mkEnableOption "extra mappings"; + }; + }; }; } diff --git a/modules/plugins/comments/comment-nvim/config.nix b/modules/plugins/comments/comment-nvim/config.nix index e228d92c..c2c1a7e2 100644 --- a/modules/plugins/comments/comment-nvim/config.nix +++ b/modules/plugins/comments/comment-nvim/config.nix @@ -3,46 +3,38 @@ lib, ... }: let - inherit (lib.modules) mkIf mkMerge; - inherit (lib.nvim.binds) mkExprBinding mkBinding; - inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.modules) mkIf; + inherit (lib.nvim.binds) mkLznExprBinding mkLznBinding; cfg = config.vim.comments.comment-nvim; self = import ./comment-nvim.nix {inherit lib;}; inherit (self.options.vim.comments.comment-nvim) mappings; in { config = mkIf cfg.enable { - vim.startPlugins = ["comment-nvim"]; - - vim.maps.normal = mkMerge [ - (mkBinding cfg.mappings.toggleOpLeaderLine "(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description) - (mkBinding cfg.mappings.toggleOpLeaderBlock "(comment_toggle_blockwise)" mappings.toggleOpLeaderBlock.description) - - (mkExprBinding cfg.mappings.toggleCurrentLine '' - function() - return vim.api.nvim_get_vvar('count') == 0 and '(comment_toggle_linewise_current)' - or '(comment_toggle_linewise_count)' - end - '' - mappings.toggleCurrentLine.description) - (mkExprBinding cfg.mappings.toggleCurrentBlock '' - function() - return vim.api.nvim_get_vvar('count') == 0 and '(comment_toggle_blockwise_current)' - or '(comment_toggle_blockwise_count)' - end - '' - mappings.toggleCurrentBlock.description) - ]; - - vim.maps.visual = mkMerge [ - (mkBinding cfg.mappings.toggleSelectedLine "(comment_toggle_linewise_visual)" mappings.toggleSelectedLine.description) - (mkBinding cfg.mappings.toggleSelectedBlock "(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description) - ]; - - vim.pluginRC.comment-nvim = entryAnywhere '' - require('Comment').setup({ - mappings = { basic = false, extra = false, }, - }) - ''; + vim.lazy.plugins.comment-nvim = { + package = "comment-nvim"; + setupModule = "Comment"; + inherit (cfg) setupOpts; + keys = [ + (mkLznBinding ["n"] cfg.mappings.toggleOpLeaderLine "(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description) + (mkLznBinding ["n"] cfg.mappings.toggleOpLeaderBlock "(comment_toggle_blockwise)" mappings.toggleOpLeaderBlock.description) + (mkLznExprBinding ["n"] cfg.mappings.toggleCurrentLine '' + function() + return vim.api.nvim_get_vvar('count') == 0 and '(comment_toggle_linewise_current)' + or '(comment_toggle_linewise_count)' + end + '' + mappings.toggleCurrentLine.description) + (mkLznExprBinding ["n"] cfg.mappings.toggleCurrentBlock '' + function() + return vim.api.nvim_get_vvar('count') == 0 and '(comment_toggle_blockwise_current)' + or '(comment_toggle_blockwise_count)' + end + '' + mappings.toggleCurrentBlock.description) + (mkLznBinding ["x"] cfg.mappings.toggleSelectedLine "(comment_toggle_linewise_visual)" mappings.toggleSelectedLine.description) + (mkLznBinding ["x"] cfg.mappings.toggleSelectedBlock "(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description) + ]; + }; }; } diff --git a/modules/plugins/completion/nvim-cmp/config.nix b/modules/plugins/completion/nvim-cmp/config.nix index 5d20242d..54670ace 100644 --- a/modules/plugins/completion/nvim-cmp/config.nix +++ b/modules/plugins/completion/nvim-cmp/config.nix @@ -3,91 +3,122 @@ config, ... }: let - inherit (lib.modules) mkIf; + inherit (lib.modules) mkIf mkMerge; inherit (lib.strings) optionalString; inherit (lib.generators) mkLuaInline; - inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.lua) toLuaObject; - inherit (builtins) attrNames; + inherit (lib.nvim.attrsets) mapListToAttrs; + inherit (builtins) attrNames typeOf tryEval concatStringsSep; cfg = config.vim.autocomplete.nvim-cmp; luasnipEnable = config.vim.snippets.luasnip.enable; + getPluginName = plugin: + if typeOf plugin == "string" + then plugin + else if (plugin ? pname && (tryEval plugin.pname).success) + then plugin.pname + else plugin.name; inherit (cfg) mappings; in { config = mkIf cfg.enable { vim = { - startPlugins = [ - "nvim-cmp" - "cmp-buffer" - "cmp-path" + startPlugins = ["rtp-nvim"]; + lazy.plugins = mkMerge [ + (mapListToAttrs (package: { + name = getPluginName package; + value = { + inherit package; + lazy = true; + after = '' + local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/${getPluginName package}') + require("rtp_nvim").source_after_plugin_dir(path) + ''; + }; + }) + cfg.sourcePlugins) + { + nvim-cmp = { + package = "nvim-cmp"; + after = '' + ${optionalString luasnipEnable "local luasnip = require('luasnip')"} + local cmp = require("cmp") + cmp.setup(${toLuaObject cfg.setupOpts}) + + ${optionalString config.vim.lazy.enable + (concatStringsSep "\n" (map + (package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})") + cfg.sourcePlugins))} + ''; + + event = ["InsertEnter" "CmdlineEnter"]; + }; + } ]; - autocomplete.nvim-cmp.sources = { - nvim-cmp = null; - buffer = "[Buffer]"; - path = "[Path]"; - }; - - autocomplete.nvim-cmp.setupOpts = { - sources = map (s: {name = s;}) (attrNames cfg.sources); - - # TODO: try to get nvim-cmp to follow global border style - window = mkIf config.vim.ui.borders.enable { - completion = mkLuaInline "cmp.config.window.bordered()"; - documentation = mkLuaInline "cmp.config.window.bordered()"; + autocomplete.nvim-cmp = { + sources = { + nvim-cmp = null; + buffer = "[Buffer]"; + path = "[Path]"; }; - formatting.format = cfg.format; - }; + sourcePlugins = ["cmp-buffer" "cmp-path"]; - pluginRC.nvim-cmp = mkIf cfg.enable (entryAfter ["autopairs" "luasnip"] '' - ${optionalString luasnipEnable "local luasnip = require('luasnip')"} - local cmp = require("cmp") - cmp.setup(${toLuaObject cfg.setupOpts}) - ''); + setupOpts = { + sources = map (s: {name = s;}) (attrNames cfg.sources); - # `cmp` and `luasnip` are defined above, in the `nvim-cmp` section - autocomplete.nvim-cmp.setupOpts.mapping = { - ${mappings.complete} = mkLuaInline "cmp.mapping.complete()"; - ${mappings.close} = mkLuaInline "cmp.mapping.abort()"; - ${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)"; - ${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)"; - ${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })"; + # TODO: try to get nvim-cmp to follow global border style + window = mkIf config.vim.ui.borders.enable { + completion = mkLuaInline "cmp.config.window.bordered()"; + documentation = mkLuaInline "cmp.config.window.bordered()"; + }; - ${mappings.next} = mkLuaInline '' - cmp.mapping(function(fallback) - local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil - end + formatting.format = cfg.format; - if cmp.visible() then - cmp.select_next_item() - ${optionalString luasnipEnable '' - elseif luasnip.locally_jumpable(1) then - luasnip.jump(1) - ''} - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end) - ''; + # `cmp` and `luasnip` are defined above, in the `nvim-cmp` section + mapping = { + ${mappings.complete} = mkLuaInline "cmp.mapping.complete()"; + ${mappings.close} = mkLuaInline "cmp.mapping.abort()"; + ${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)"; + ${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)"; + ${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })"; - ${mappings.previous} = mkLuaInline '' - cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - ${optionalString luasnipEnable '' - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - ''} - else - fallback() - end - end) - ''; + ${mappings.next} = mkLuaInline '' + cmp.mapping(function(fallback) + local has_words_before = function() + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + end + + if cmp.visible() then + cmp.select_next_item() + ${optionalString luasnipEnable '' + elseif luasnip.locally_jumpable(1) then + luasnip.jump(1) + ''} + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end) + ''; + + ${mappings.previous} = mkLuaInline '' + cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + ${optionalString luasnipEnable '' + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + ''} + else + fallback() + end + end) + ''; + }; + }; }; }; }; diff --git a/modules/plugins/completion/nvim-cmp/nvim-cmp.nix b/modules/plugins/completion/nvim-cmp/nvim-cmp.nix index 860a1c3f..8246e710 100644 --- a/modules/plugins/completion/nvim-cmp/nvim-cmp.nix +++ b/modules/plugins/completion/nvim-cmp/nvim-cmp.nix @@ -4,10 +4,10 @@ ... }: let inherit (lib.options) mkEnableOption mkOption literalExpression literalMD; - inherit (lib.types) str attrsOf nullOr either; + inherit (lib.types) str attrsOf nullOr either listOf; inherit (lib.generators) mkLuaInline; inherit (lib.nvim.binds) mkMappingOption; - inherit (lib.nvim.types) mkPluginSetupOption luaInline mergelessListOf; + inherit (lib.nvim.types) mkPluginSetupOption luaInline mergelessListOf pluginType; inherit (lib.nvim.lua) toLuaObject; inherit (builtins) isString; @@ -99,5 +99,11 @@ in { } ''; }; + + sourcePlugins = mkOption { + type = listOf pluginType; + default = []; + description = "List of source plugins used by nvim-cmp."; + }; }; } diff --git a/modules/plugins/debugger/nvim-dap/config.nix b/modules/plugins/debugger/nvim-dap/config.nix index 358d7c86..7e9e8f76 100644 --- a/modules/plugins/debugger/nvim-dap/config.nix +++ b/modules/plugins/debugger/nvim-dap/config.nix @@ -6,7 +6,7 @@ inherit (lib.strings) optionalString; inherit (lib.modules) mkIf mkMerge; inherit (lib.attrsets) mapAttrs; - inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding mkSetLuaLznBinding; inherit (lib.nvim.dag) entryAnywhere entryAfter; cfg = config.vim.debugger.nvim-dap; @@ -52,24 +52,31 @@ in { }) (mkIf (cfg.enable && cfg.ui.enable) { vim = { - startPlugins = ["nvim-dap-ui" "nvim-nio"]; + startPlugins = ["nvim-nio"]; - pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] ('' - local dapui = require("dapui") - dapui.setup() - '' - + optionalString cfg.ui.autoStart '' + lazy.plugins.nvim-dap-ui = { + package = "nvim-dap-ui"; + setupModule = "dapui"; + inherit (cfg.ui) setupOpts; + + keys = [ + (mkSetLuaLznBinding mappings.toggleDapUI "function() require('dapui').toggle() end") + ]; + }; + + pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] ( + optionalString cfg.ui.autoStart '' dap.listeners.after.event_initialized["dapui_config"] = function() - dapui.open() + require("dapui").open() end dap.listeners.before.event_terminated["dapui_config"] = function() - dapui.close() + require("dapui").close() end dap.listeners.before.event_exited["dapui_config"] = function() - dapui.close() + require("dapui").close() end - ''); - maps.normal = mkSetLuaBinding mappings.toggleDapUI "require('dapui').toggle"; + '' + ); }; }) ]; diff --git a/modules/plugins/debugger/nvim-dap/nvim-dap.nix b/modules/plugins/debugger/nvim-dap/nvim-dap.nix index 3fab33ae..5a699491 100644 --- a/modules/plugins/debugger/nvim-dap/nvim-dap.nix +++ b/modules/plugins/debugger/nvim-dap/nvim-dap.nix @@ -2,12 +2,16 @@ inherit (lib.options) mkEnableOption mkOption; inherit (lib.types) bool attrsOf str; inherit (lib.nvim.binds) mkMappingOption; + inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.debugger.nvim-dap = { enable = mkEnableOption "debugging via nvim-dap"; ui = { enable = mkEnableOption "UI extension for nvim-dap"; + + setupOpts = mkPluginSetupOption "nvim-dap-ui" {}; + autoStart = mkOption { type = bool; default = true; diff --git a/modules/plugins/filetree/neo-tree/config.nix b/modules/plugins/filetree/neo-tree/config.nix index be67df1e..13da0354 100644 --- a/modules/plugins/filetree/neo-tree/config.nix +++ b/modules/plugins/filetree/neo-tree/config.nix @@ -4,8 +4,6 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.filetree.neo-tree; in { @@ -16,15 +14,17 @@ in { "plenary-nvim" # commons library "image-nvim" # optional for image previews "nui-nvim" # ui library - # neotree - "neo-tree-nvim" ]; - visuals.nvimWebDevicons.enable = true; + lazy.plugins.neo-tree-nvim = { + package = "neo-tree-nvim"; + setupModule = "neo-tree"; + inherit (cfg) setupOpts; - pluginRC.neo-tree = entryAnywhere '' - require("neo-tree").setup(${toLuaObject cfg.setupOpts}) - ''; + cmd = ["Neotree"]; + }; + + visuals.nvimWebDevicons.enable = true; }; }; } diff --git a/modules/plugins/filetree/nvimtree/config.nix b/modules/plugins/filetree/nvimtree/config.nix index b97b1e45..30cc680b 100644 --- a/modules/plugins/filetree/nvimtree/config.nix +++ b/modules/plugins/filetree/nvimtree/config.nix @@ -5,10 +5,9 @@ ... }: let inherit (lib.strings) optionalString; - inherit (lib.modules) mkIf mkMerge; - inherit (lib.nvim.binds) mkBinding; + inherit (lib.modules) mkIf; + inherit (lib.nvim.binds) mkLznBinding; inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.binds) pushDownDefault; cfg = config.vim.filetree.nvimTree; @@ -16,69 +15,74 @@ inherit (self.options.vim.filetree.nvimTree) mappings; in { config = mkIf cfg.enable { - vim.startPlugins = ["nvim-tree-lua"]; + vim = { + binds.whichKey.register = pushDownDefault { + "t" = "+NvimTree"; + }; - vim.maps.normal = mkMerge [ - (mkBinding cfg.mappings.toggle ":NvimTreeToggle" mappings.toggle.description) - (mkBinding cfg.mappings.refresh ":NvimTreeRefresh" mappings.refresh.description) - (mkBinding cfg.mappings.findFile ":NvimTreeFindFile" mappings.findFile.description) - (mkBinding cfg.mappings.focus ":NvimTreeFocus" mappings.focus.description) - ]; + lazy.plugins.nvim-tree-lua = { + package = "nvim-tree-lua"; + setupModule = "nvim-tree"; + inherit (cfg) setupOpts; + cmd = ["NvimTreeClipboard" "NvimTreeClose" "NvimTreeCollapse" "NvimTreeCollapseKeepBuffers" "NvimTreeFindFile" "NvimTreeFindFileToggle" "NvimTreeFocus" "NvimTreeHiTest" "NvimTreeOpen" "NvimTreeRefresh" "NvimTreeResize" "NvimTreeToggle"]; + keys = [ + (mkLznBinding ["n"] cfg.mappings.toggle ":NvimTreeToggle" mappings.toggle.description) + (mkLznBinding ["n"] cfg.mappings.refresh ":NvimTreeRefresh" mappings.refresh.description) + (mkLznBinding ["n"] cfg.mappings.findFile ":NvimTreeFindFile" mappings.findFile.description) + (mkLznBinding ["n"] cfg.mappings.focus ":NvimTreeFocus" mappings.focus.description) + ]; + }; - vim.binds.whichKey.register = pushDownDefault { - "t" = "+NvimTree"; + pluginRC.nvimtreelua = entryAnywhere '' + ${ + optionalString cfg.setupOpts.disable_netrw '' + -- disable netrew completely + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + '' + } + + ${ + optionalString cfg.openOnSetup '' + ${optionalString config.vim.lazy.enable ''require('lz.n').trigger_load("nvim-tree-lua")''} + -- autostart behaviour + -- Open on startup has been deprecated + -- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup + + -- use a nix eval to dynamically insert the open on startup function + local function open_nvim_tree(data) + local IGNORED_FT = { + "markdown", + } + + -- buffer is a real file on the disk + local real_file = vim.fn.filereadable(data.file) == 1 + + -- buffer is a [No Name] + local no_name = data.file == "" and vim.bo[data.buf].buftype == "" + + -- &ft + local filetype = vim.bo[data.buf].ft + + -- only files please + if not real_file and not no_name then + return + end + + -- skip ignored filetypes + if vim.tbl_contains(IGNORED_FT, filetype) then + return + end + + -- open the tree but don't focus it + require("nvim-tree.api").tree.toggle({ focus = false }) + end + + -- function to automatically open the tree on VimEnter + vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) + '' + } + ''; }; - - vim.pluginRC.nvimtreelua = entryAnywhere '' - ${ - optionalString cfg.setupOpts.disable_netrw '' - -- disable netrew completely - vim.g.loaded_netrw = 1 - vim.g.loaded_netrwPlugin = 1 - '' - } - - require'nvim-tree'.setup(${toLuaObject cfg.setupOpts}) - - ${ - optionalString cfg.openOnSetup '' - -- autostart behaviour - -- Open on startup has been deprecated - -- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup - - -- use a nix eval to dynamically insert the open on startup function - local function open_nvim_tree(data) - local IGNORED_FT = { - "markdown", - } - - -- buffer is a real file on the disk - local real_file = vim.fn.filereadable(data.file) == 1 - - -- buffer is a [No Name] - local no_name = data.file == "" and vim.bo[data.buf].buftype == "" - - -- &ft - local filetype = vim.bo[data.buf].ft - - -- only files please - if not real_file and not no_name then - return - end - - -- skip ignored filetypes - if vim.tbl_contains(IGNORED_FT, filetype) then - return - end - - -- open the tree but don't focus it - require("nvim-tree.api").tree.toggle({ focus = false }) - end - - -- function to automatically open the tree on VimEnter - vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) - '' - } - ''; }; } diff --git a/modules/plugins/lsp/config.nix b/modules/plugins/lsp/config.nix index dbf6cdbd..e73a5387 100644 --- a/modules/plugins/lsp/config.nix +++ b/modules/plugins/lsp/config.nix @@ -5,7 +5,6 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.lists) optional; inherit (lib.strings) optionalString; inherit (lib.trivial) boolToString; inherit (lib.nvim.binds) addDescriptionsToMappings; @@ -23,9 +22,10 @@ in { config = mkIf cfg.enable { vim = { - startPlugins = optional usingNvimCmp "cmp-nvim-lsp"; - - autocomplete.nvim-cmp.sources = {nvim_lsp = "[LSP]";}; + autocomplete.nvim-cmp = { + sources = {nvim_lsp = "[LSP]";}; + sourcePlugins = ["cmp-nvim-lsp"]; + }; pluginRC.lsp-setup = '' vim.g.formatsave = ${boolToString cfg.formatOnSave}; @@ -116,7 +116,60 @@ in { end local capabilities = vim.lsp.protocol.make_client_capabilities() - ${optionalString usingNvimCmp "capabilities = require('cmp_nvim_lsp').default_capabilities()"} + ${optionalString usingNvimCmp '' + -- HACK: copied from cmp-nvim-lsp. If we ever lazy load lspconfig we + -- should re-evaluate whether we can just use `default_capabilities` + capabilities = { + textDocument = { + completion = { + dynamicRegistration = false, + completionItem = { + snippetSupport = true, + commitCharactersSupport = true, + deprecatedSupport = true, + preselectSupport = true, + tagSupport = { + valueSet = { + 1, -- Deprecated + } + }, + insertReplaceSupport = true, + resolveSupport = { + properties = { + "documentation", + "detail", + "additionalTextEdits", + "sortText", + "filterText", + "insertText", + "textEdit", + "insertTextFormat", + "insertTextMode", + }, + }, + insertTextModeSupport = { + valueSet = { + 1, -- asIs + 2, -- adjustIndentation + } + }, + labelDetailsSupport = true, + }, + contextSupport = true, + insertTextMode = 1, + completionList = { + itemDefaults = { + 'commitCharacters', + 'editRange', + 'insertTextFormat', + 'insertTextMode', + 'data', + } + } + }, + }, + } + ''} ''; }; }; diff --git a/modules/plugins/lsp/trouble/config.nix b/modules/plugins/lsp/trouble/config.nix index dd853e30..cae0c7ad 100644 --- a/modules/plugins/lsp/trouble/config.nix +++ b/modules/plugins/lsp/trouble/config.nix @@ -1,41 +1,40 @@ { config, lib, + options, ... }: let - inherit (lib.modules) mkIf mkMerge; - inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding pushDownDefault; + inherit (lib.modules) mkIf; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLznBinding pushDownDefault; cfg = config.vim.lsp; - self = import ./trouble.nix {inherit lib;}; - mappingDefinitions = self.options.vim.lsp.trouble.mappings; + mappingDefinitions = options.vim.lsp.trouble.mappings; mappings = addDescriptionsToMappings cfg.trouble.mappings mappingDefinitions; in { config = mkIf (cfg.enable && cfg.trouble.enable) { vim = { - startPlugins = ["trouble"]; + lazy.plugins.trouble = { + package = "trouble"; + setupModule = "trouble"; + inherit (cfg.trouble) setupOpts; - maps.normal = mkMerge [ - (mkSetBinding mappings.toggle "TroubleToggle") - (mkSetBinding mappings.workspaceDiagnostics "TroubleToggle workspace_diagnostics") - (mkSetBinding mappings.documentDiagnostics "TroubleToggle document_diagnostics") - (mkSetBinding mappings.lspReferences "TroubleToggle lsp_references") - (mkSetBinding mappings.quickfix "TroubleToggle quickfix") - (mkSetBinding mappings.locList "TroubleToggle loclist") - ]; + cmd = "Trouble"; + keys = [ + (mkSetLznBinding mappings.toggle "TroubleToggle") + (mkSetLznBinding mappings.workspaceDiagnostics "TroubleToggle workspace_diagnostics") + (mkSetLznBinding mappings.documentDiagnostics "TroubleToggle document_diagnostics") + (mkSetLznBinding mappings.lspReferences "TroubleToggle lsp_references") + (mkSetLznBinding mappings.quickfix "TroubleToggle quickfix") + (mkSetLznBinding mappings.locList "TroubleToggle loclist") + ]; + }; binds.whichKey.register = pushDownDefault { "l" = "Trouble"; "x" = "+Trouble"; "lw" = "Workspace"; }; - - pluginRC.trouble = entryAnywhere '' - -- Enable trouble diagnostics viewer - require("trouble").setup {} - ''; }; }; } diff --git a/modules/plugins/lsp/trouble/trouble.nix b/modules/plugins/lsp/trouble/trouble.nix index bd16c67e..04bd5068 100644 --- a/modules/plugins/lsp/trouble/trouble.nix +++ b/modules/plugins/lsp/trouble/trouble.nix @@ -1,11 +1,14 @@ {lib, ...}: let inherit (lib.options) mkEnableOption; inherit (lib.nvim.binds) mkMappingOption; + inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.lsp = { trouble = { enable = mkEnableOption "trouble diagnostics viewer"; + setupOpts = mkPluginSetupOption "Trouble" {}; + mappings = { toggle = mkMappingOption "Toggle trouble [trouble]" "xx"; workspaceDiagnostics = mkMappingOption "Workspace diagnostics [trouble]" "lwd"; diff --git a/modules/plugins/snippets/luasnip/config.nix b/modules/plugins/snippets/luasnip/config.nix index 541fd0fd..927b21fd 100644 --- a/modules/plugins/snippets/luasnip/config.nix +++ b/modules/plugins/snippets/luasnip/config.nix @@ -9,9 +9,18 @@ in { config = mkIf cfg.enable { vim = { - startPlugins = ["luasnip" "cmp-luasnip"] ++ cfg.providers; - autocomplete.nvim-cmp.sources = {luasnip = "[LuaSnip]";}; - pluginRC.luasnip = cfg.loaders; + lazy.plugins = { + luasnip = { + package = "luasnip"; + lazy = true; + after = cfg.loaders; + }; + }; + startPlugins = cfg.providers; + autocomplete.nvim-cmp = { + sources = {luasnip = "[LuaSnip]";}; + sourcePlugins = ["cmp-luasnip"]; + }; }; }; } diff --git a/modules/plugins/terminal/toggleterm/config.nix b/modules/plugins/terminal/toggleterm/config.nix index 07851e40..f0ebd726 100644 --- a/modules/plugins/terminal/toggleterm/config.nix +++ b/modules/plugins/terminal/toggleterm/config.nix @@ -3,39 +3,31 @@ lib, ... }: let - inherit (builtins) toJSON; - inherit (lib.lists) optionals; - inherit (lib.modules) mkIf mkMerge; + inherit (lib.strings) optionalString; + inherit (lib.lists) optional; + inherit (lib.modules) mkIf; inherit (lib.meta) getExe; - inherit (lib.nvim.binds) mkBinding; - inherit (lib.nvim.dag) entryAnywhere entryAfter; + inherit (lib.nvim.binds) mkLznBinding; inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.terminal.toggleterm; + lazygitMapDesc = "Open lazygit [toggleterm]"; in { - config = mkMerge [ - ( - mkIf cfg.enable { - vim = { - startPlugins = [ - "toggleterm-nvim" - ]; + config = mkIf cfg.enable { + vim = { + lazy.plugins.toggleterm-nvim = { + package = "toggleterm-nvim"; + cmd = ["ToggleTerm" "ToggleTermSendCurrentLine" "ToggleTermSendVisualLines" "ToggleTermSendVisualSelection" "ToggleTermSetName" "ToggleTermToggleAll"]; + keys = + [(mkLznBinding ["n"] cfg.mappings.open "execute v:count . \"ToggleTerm\"" "Toggle terminal")] + ++ optional cfg.lazygit.enable { + key = cfg.lazygit.mappings.open; + desc = lazygitMapDesc; + }; - maps.normal = mkBinding cfg.mappings.open "execute v:count . \"ToggleTerm\"" "Toggle terminal"; - - pluginRC.toggleterm = entryAnywhere '' - require("toggleterm").setup(${toLuaObject cfg.setupOpts}) - ''; - }; - } - ) - ( - mkIf (cfg.enable && cfg.lazygit.enable) - { - vim.startPlugins = optionals (cfg.lazygit.package != null) [ - cfg.lazygit.package - ]; - vim.pluginRC.toggleterm-lazygit = entryAfter ["toggleterm"] '' + setupModule = "toggleterm"; + inherit (cfg) setupOpts; + after = optionalString cfg.lazygit.enable '' local terminal = require 'toggleterm.terminal' local lazygit = terminal.Terminal:new({ cmd = '${ @@ -50,9 +42,9 @@ in { end }) - vim.keymap.set('n', ${toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = 'Open lazygit [toggleterm]'}) + vim.keymap.set('n', ${toLuaObject cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = '${lazygitMapDesc}'}) ''; - } - ) - ]; + }; + }; + }; } diff --git a/modules/plugins/theme/theme.nix b/modules/plugins/theme/theme.nix index 0422c027..b3147c00 100644 --- a/modules/plugins/theme/theme.nix +++ b/modules/plugins/theme/theme.nix @@ -66,7 +66,7 @@ in { config = mkIf cfg.enable { vim = { startPlugins = [cfg.name]; - luaConfigRC.theme = entryBefore ["pluginConfigs"] '' + luaConfigRC.theme = entryBefore ["pluginConfigs" "lazyConfigs"] '' ${cfg.extraConfig} ${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent base16-colors;}} ''; diff --git a/modules/plugins/treesitter/config.nix b/modules/plugins/treesitter/config.nix index ae093862..566a716e 100644 --- a/modules/plugins/treesitter/config.nix +++ b/modules/plugins/treesitter/config.nix @@ -5,13 +5,12 @@ ... }: let inherit (lib.modules) mkIf mkMerge; - inherit (lib.lists) optional optionals; + inherit (lib.lists) optionals; inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings; inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.dag) entryBefore entryAfter; cfg = config.vim.treesitter; - usingNvimCmp = config.vim.autocomplete.nvim-cmp.enable; self = import ./treesitter.nix {inherit pkgs lib;}; mappingDefinitions = self.options.vim.treesitter.mappings; @@ -19,9 +18,13 @@ in { config = mkIf cfg.enable { vim = { - startPlugins = ["nvim-treesitter"] ++ optional usingNvimCmp "cmp-treesitter"; + startPlugins = ["nvim-treesitter"]; + + autocomplete.nvim-cmp = { + sources = {treesitter = "[Treesitter]";}; + sourcePlugins = ["cmp-treesitter"]; + }; - autocomplete.nvim-cmp.sources = {treesitter = "[Treesitter]";}; treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars; maps = { diff --git a/modules/plugins/utility/binds/cheatsheet/config.nix b/modules/plugins/utility/binds/cheatsheet/config.nix index 2848ddc2..2fb3e25b 100644 --- a/modules/plugins/utility/binds/cheatsheet/config.nix +++ b/modules/plugins/utility/binds/cheatsheet/config.nix @@ -4,15 +4,18 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.strings) optionalString; cfg = config.vim.binds.cheatsheet; in { config = mkIf cfg.enable { - vim.startPlugins = ["cheatsheet-nvim"]; + vim.lazy.plugins.cheatsheet-nvim = { + package = "cheatsheet-nvim"; + setupModule = "cheatsheet"; + setupOpts = {}; + cmd = ["Cheatsheet" "CheatsheetEdit"]; - vim.pluginRC.cheaetsheet-nvim = entryAnywhere '' - require('cheatsheet').setup({}) - ''; + before = optionalString config.vim.lazy.enable "require('lz.n').trigger_load('telescope')"; + }; }; } diff --git a/modules/plugins/utility/diffview/config.nix b/modules/plugins/utility/diffview/config.nix index 681a3053..a6458ed5 100644 --- a/modules/plugins/utility/diffview/config.nix +++ b/modules/plugins/utility/diffview/config.nix @@ -8,9 +8,14 @@ cfg = config.vim.utility.diffview-nvim; in { config = mkIf cfg.enable { - vim.startPlugins = [ - "diffview-nvim" - "plenary-nvim" - ]; + vim = { + startPlugins = ["plenary-nvim"]; + lazy.plugins.diffview-nvim = { + package = "diffview-nvim"; + cmd = ["DiffviewClose" "DiffviewFileHistory" "DiffviewFocusFiles" "DiffviewLog" "DiffviewOpen" "DiffviewRefresh" "DiffviewToggleFiles"]; + setupModule = "diffview"; + inherit (cfg) setupOpts; + }; + }; }; } diff --git a/modules/plugins/utility/diffview/diffview.nix b/modules/plugins/utility/diffview/diffview.nix index 74ddd574..793666dc 100644 --- a/modules/plugins/utility/diffview/diffview.nix +++ b/modules/plugins/utility/diffview/diffview.nix @@ -1,7 +1,9 @@ {lib, ...}: let inherit (lib.options) mkEnableOption; + inherit (lib.nvim.types) mkPluginSetupOption; in { options.vim.utility.diffview-nvim = { enable = mkEnableOption "diffview-nvim: cycle through diffs for all modified files for any git rev"; + setupOpts = mkPluginSetupOption "Fidget" {}; }; } diff --git a/modules/plugins/utility/icon-picker/config.nix b/modules/plugins/utility/icon-picker/config.nix index 405f6917..99e43044 100644 --- a/modules/plugins/utility/icon-picker/config.nix +++ b/modules/plugins/utility/icon-picker/config.nix @@ -4,20 +4,20 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.utility.icon-picker; in { config = mkIf cfg.enable { - vim.startPlugins = [ - "icon-picker-nvim" - "dressing-nvim" - ]; + vim.startPlugins = ["dressing-nvim"]; - vim.pluginRC.icon-picker = entryAnywhere '' - require("icon-picker").setup({ - disable_legacy_commands = true - }) - ''; + vim.lazy.plugins.icon-picker-nvim = { + package = "icon-picker-nvim"; + setupModule = "icon-picker"; + setupOpts = { + disable_legacy_commands = true; + }; + + cmd = ["IconPickerInsert" "IconPickerNormal" "IconPickerYank"]; + }; }; } diff --git a/modules/plugins/utility/motion/leap/config.nix b/modules/plugins/utility/motion/leap/config.nix index 687ed24d..94a00c99 100644 --- a/modules/plugins/utility/motion/leap/config.nix +++ b/modules/plugins/utility/motion/leap/config.nix @@ -3,73 +3,59 @@ lib, ... }: let - inherit (lib.modules) mkIf mkMerge mkDefault; - inherit (lib.nvim.binds) mkBinding; - inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.modules) mkIf mkDefault; + inherit (lib.nvim.binds) mkLznBinding; cfg = config.vim.utility.motion.leap; in { config = mkIf cfg.enable { - vim.startPlugins = [ - "leap-nvim" - "vim-repeat" - ]; + vim = { + startPlugins = ["vim-repeat"]; + lazy.plugins.leap-nvim = { + package = "leap-nvim"; + keys = [ + (mkLznBinding ["n" "o" "x"] cfg.mappings.leapForwardTo "(leap-forward-to)" "Leap forward to") + (mkLznBinding ["n" "o" "x"] cfg.mappings.leapBackwardTo "(leap-backward-to)" "Leap backward to") + (mkLznBinding ["n" "o" "x"] cfg.mappings.leapForwardTill "(leap-forward-till)" "Leap forward till") + (mkLznBinding ["n" "o" "x"] cfg.mappings.leapBackwardTill "(leap-backward-till)" "Leap backward till") + (mkLznBinding ["n" "o" "x"] cfg.mappings.leapFromWindow "(leap-from-window)" "Leap from window") + ]; - vim.maps.normal = mkMerge [ - (mkBinding cfg.mappings.leapForwardTo "(leap-forward-to)" "Leap forward to") - (mkBinding cfg.mappings.leapBackwardTo "(leap-backward-to)" "Leap backward to") - (mkBinding cfg.mappings.leapFromWindow "(leap-from-window)" "Leap from window") - ]; + after = '' + require('leap').opts = { + max_phase_one_targets = nil, + highlight_unlabeled_phase_one_targets = false, + max_highlighted_traversal_targets = 10, + case_sensitive = false, + equivalence_classes = { ' \t\r\n', }, + substitute_chars = {}, + safe_labels = { + "s", "f", "n", "u", "t", "/", + "S", "F", "N", "L", "H", "M", "U", "G", "T", "?", "Z" + }, + labels = { + "s", "f", "n", + "j", "k", "l", "h", "o", "d", "w", "e", "m", "b", + "u", "y", "v", "r", "g", "t", "c", "x", "/", "z", + "S", "F", "N", + "J", "K", "L", "H", "O", "D", "W", "E", "M", "B", + "U", "Y", "V", "R", "G", "T", "C", "X", "?", "Z" + }, + special_keys = { + repeat_search = '', + next_phase_one_target = '', + next_target = {'', ';'}, + prev_target = {'', ','}, + next_group = '', + prev_group = '', + multi_accept = '', + multi_revert = '', + }, + } + ''; + }; - vim.maps.operator = mkMerge [ - (mkBinding cfg.mappings.leapForwardTo "(leap-forward-to)" "Leap forward to") - (mkBinding cfg.mappings.leapBackwardTo "(leap-backward-to)" "Leap backward to") - (mkBinding cfg.mappings.leapForwardTill "(leap-forward-till)" "Leap forward till") - (mkBinding cfg.mappings.leapBackwardTill "(leap-backward-till)" "Leap backward till") - (mkBinding cfg.mappings.leapFromWindow "(leap-from-window)" "Leap from window") - ]; - - vim.maps.visualOnly = mkMerge [ - (mkBinding cfg.mappings.leapForwardTo "(leap-forward-to)" "Leap forward to") - (mkBinding cfg.mappings.leapBackwardTo "(leap-backward-to)" "Leap backward to") - (mkBinding cfg.mappings.leapForwardTill "(leap-forward-till)" "Leap forward till") - (mkBinding cfg.mappings.leapBackwardTill "(leap-backward-till)" "Leap backward till") - (mkBinding cfg.mappings.leapFromWindow "(leap-from-window)" "Leap from window") - ]; - - vim.binds.whichKey.register."s" = mkDefault "+Leap"; - - vim.pluginRC.leap-nvim = entryAnywhere '' - require('leap').opts = { - max_phase_one_targets = nil, - highlight_unlabeled_phase_one_targets = false, - max_highlighted_traversal_targets = 10, - case_sensitive = false, - equivalence_classes = { ' \t\r\n', }, - substitute_chars = {}, - safe_labels = { - "s", "f", "n", "u", "t", "/", - "S", "F", "N", "L", "H", "M", "U", "G", "T", "?", "Z" - }, - labels = { - "s", "f", "n", - "j", "k", "l", "h", "o", "d", "w", "e", "m", "b", - "u", "y", "v", "r", "g", "t", "c", "x", "/", "z", - "S", "F", "N", - "J", "K", "L", "H", "O", "D", "W", "E", "M", "B", - "U", "Y", "V", "R", "G", "T", "C", "X", "?", "Z" - }, - special_keys = { - repeat_search = '', - next_phase_one_target = '', - next_target = {'', ';'}, - prev_target = {'', ','}, - next_group = '', - prev_group = '', - multi_accept = '', - multi_revert = '', - }, - } - ''; + binds.whichKey.register."s" = mkDefault "+Leap"; + }; }; } diff --git a/modules/plugins/utility/surround/config.nix b/modules/plugins/utility/surround/config.nix index 4c98c865..7161cf6b 100644 --- a/modules/plugins/utility/surround/config.nix +++ b/modules/plugins/utility/surround/config.nix @@ -8,24 +8,47 @@ inherit (lib.nvim.lua) toLuaObject; cfg = config.vim.utility.surround; + mkLznKey = mode: key: { + inherit key mode; + }; in { config = mkIf cfg.enable { vim = { startPlugins = ["nvim-surround"]; pluginRC.surround = entryAnywhere "require('nvim-surround').setup(${toLuaObject cfg.setupOpts})"; - utility.surround.setupOpts.keymaps = mkIf cfg.useVendoredKeybindings { - insert = "z"; - insert_line = "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"; + lazy.plugins.nvim-surround = { + package = "nvim-surround"; + setupModule = "nvim-surround"; + inherit (cfg) setupOpts; + + keys = + [ + (mkLznKey ["i"] cfg.setupOpts.keymaps.insert) + (mkLznKey ["i"] cfg.setupOpts.keymaps.insert_line) + (mkLznKey ["x"] cfg.setupOpts.keymaps.visual) + (mkLznKey ["x"] cfg.setupOpts.keymaps.visual_line) + (mkLznKey ["n"] cfg.setupOpts.keymaps.normal) + (mkLznKey ["n"] cfg.setupOpts.keymaps.normal_cur) + (mkLznKey ["n"] cfg.setupOpts.keymaps.normal_line) + (mkLznKey ["n"] cfg.setupOpts.keymaps.normal_cur_line) + (mkLznKey ["n"] cfg.setupOpts.keymaps.delete) + (mkLznKey ["n"] cfg.setupOpts.keymaps.change) + (mkLznKey ["n"] cfg.setupOpts.keymaps.change_line) + ] + ++ map (mkLznKey ["n" "i" "v"]) [ + "(nvim-surround-insert)" + "(nvim-surround-insert-line)" + "(nvim-surround-normal)" + "(nvim-surround-normal-cur)" + "(nvim-surround-normal-line)" + "(nvim-surround-normal-cur-line)" + "(nvim-surround-visual)" + "(nvim-surround-visual-line)" + "(nvim-surround-delete)" + "(nvim-surround-change)" + "(nvim-surround-change-line)" + ]; }; }; }; diff --git a/modules/plugins/utility/surround/surround.nix b/modules/plugins/utility/surround/surround.nix index 7d006381..d74966af 100644 --- a/modules/plugins/utility/surround/surround.nix +++ b/modules/plugins/utility/surround/surround.nix @@ -1,7 +1,36 @@ -{lib, ...}: let +{ + lib, + config, + ... +}: let inherit (lib.options) mkOption; - inherit (lib.types) bool; + inherit (lib.types) bool str; inherit (lib.nvim.types) mkPluginSetupOption; + + cfg = config.vim.utility.surround; + vendoredKeybinds = { + insert = "z"; + insert_line = "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"; + }; + + mkKeymapOption = name: default: + mkOption { + description = "keymap for ${name}"; + type = str; + default = + if cfg.useVendoredKeybindings + then vendoredKeybinds.${name} + else default; + }; in { options.vim.utility.surround = { enable = mkOption { @@ -13,7 +42,21 @@ in { with nvim-leap. ''; }; - setupOpts = mkPluginSetupOption "nvim-surround" {}; + setupOpts = mkPluginSetupOption "nvim-surround" { + keymaps = { + insert = mkKeymapOption "insert" "s"; + insert_line = mkKeymapOption "insert_line" "S"; + normal = mkKeymapOption "normal" "ys"; + normal_cur = mkKeymapOption "normal_cur" "yss"; + normal_line = mkKeymapOption "normal_line" "yS"; + normal_cur_line = mkKeymapOption "normal_cur_line" "ySS"; + visual = mkKeymapOption "visual" "S"; + visual_line = mkKeymapOption "visual_line" "gS"; + delete = mkKeymapOption "delete" "ds"; + change = mkKeymapOption "change" "cs"; + change_line = mkKeymapOption "change_line" "cS"; + }; + }; useVendoredKeybindings = mkOption { type = bool; diff --git a/modules/plugins/utility/telescope/config.nix b/modules/plugins/utility/telescope/config.nix index 68af9645..61436279 100644 --- a/modules/plugins/utility/telescope/config.nix +++ b/modules/plugins/utility/telescope/config.nix @@ -1,63 +1,72 @@ { + options, config, - pkgs, lib, ... }: let - inherit (lib.modules) mkIf mkMerge; - inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding; - inherit (lib.nvim.dag) entryAnywhere; - inherit (lib.nvim.binds) pushDownDefault; - inherit (lib.nvim.lua) toLuaObject; + inherit (lib.modules) mkIf; + inherit (lib.nvim.binds) addDescriptionsToMappings; + inherit (lib.strings) optionalString; + inherit (lib.lists) optionals; + inherit (lib.nvim.binds) pushDownDefault mkSetLznBinding; cfg = config.vim.telescope; - self = import ./telescope.nix {inherit pkgs lib;}; - mappingDefinitions = self.options.vim.telescope.mappings; + mappingDefinitions = options.vim.telescope.mappings; mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; in { config = mkIf cfg.enable { vim = { - startPlugins = [ - "telescope" - "plenary-nvim" - ]; + startPlugins = ["plenary-nvim"]; - maps.normal = mkMerge [ - (mkSetBinding mappings.findFiles " Telescope find_files") - (mkSetBinding mappings.liveGrep " Telescope live_grep") - (mkSetBinding mappings.buffers " Telescope buffers") - (mkSetBinding mappings.helpTags " Telescope help_tags") - (mkSetBinding mappings.open " Telescope") - (mkSetBinding mappings.resume " Telescope resume") + lazy.plugins.telescope = { + package = "telescope"; + setupModule = "telescope"; + inherit (cfg) setupOpts; + after = '' + local telescope = require("telescope") + ${optionalString config.vim.ui.noice.enable "telescope.load_extension('noice')"} + ${optionalString config.vim.notify.nvim-notify.enable "telescope.load_extension('notify')"} + ${optionalString config.vim.projects.project-nvim.enable "telescope.load_extension('projects')"} + ''; - (mkSetBinding mappings.gitCommits " Telescope git_commits") - (mkSetBinding mappings.gitBufferCommits " Telescope git_bcommits") - (mkSetBinding mappings.gitBranches " Telescope git_branches") - (mkSetBinding mappings.gitStatus " Telescope git_status") - (mkSetBinding mappings.gitStash " Telescope git_stash") + cmd = ["Telescope"]; - (mkIf config.vim.lsp.enable (mkMerge [ - (mkSetBinding mappings.lspDocumentSymbols " Telescope lsp_document_symbols") - (mkSetBinding mappings.lspWorkspaceSymbols " Telescope lsp_workspace_symbols") + keys = + [ + (mkSetLznBinding mappings.findFiles " Telescope find_files") + (mkSetLznBinding mappings.liveGrep " Telescope live_grep") + (mkSetLznBinding mappings.buffers " Telescope buffers") + (mkSetLznBinding mappings.helpTags " Telescope help_tags") + (mkSetLznBinding mappings.open " Telescope") - (mkSetBinding mappings.lspReferences " Telescope lsp_references") - (mkSetBinding mappings.lspImplementations " Telescope lsp_implementations") - (mkSetBinding mappings.lspDefinitions " Telescope lsp_definitions") - (mkSetBinding mappings.lspTypeDefinitions " Telescope lsp_type_definitions") - (mkSetBinding mappings.diagnostics " Telescope diagnostics") - ])) + (mkSetLznBinding mappings.gitCommits " Telescope git_commits") + (mkSetLznBinding mappings.gitBufferCommits " Telescope git_bcommits") + (mkSetLznBinding mappings.gitBranches " Telescope git_branches") + (mkSetLznBinding mappings.gitStatus " Telescope git_status") + (mkSetLznBinding mappings.gitStash " Telescope git_stash") + ] + ++ (optionals config.vim.lsp.enable [ + (mkSetLznBinding mappings.lspDocumentSymbols " Telescope lsp_document_symbols") + (mkSetLznBinding mappings.lspWorkspaceSymbols " Telescope lsp_workspace_symbols") - ( - mkIf config.vim.treesitter.enable - (mkSetBinding mappings.treesitter " Telescope treesitter") - ) - - ( - mkIf config.vim.projects.project-nvim.enable - (mkSetBinding mappings.findProjects " Telescope projects") - ) - ]; + (mkSetLznBinding mappings.lspReferences " Telescope lsp_references") + (mkSetLznBinding mappings.lspImplementations " Telescope lsp_implementations") + (mkSetLznBinding mappings.lspDefinitions " Telescope lsp_definitions") + (mkSetLznBinding mappings.lspTypeDefinitions " Telescope lsp_type_definitions") + (mkSetLznBinding mappings.diagnostics " Telescope diagnostics") + ]) + ++ ( + optionals config.vim.treesitter.enable [ + (mkSetLznBinding mappings.treesitter " Telescope treesitter") + ] + ) + ++ ( + optionals config.vim.projects.project-nvim.enable [ + (mkSetLznBinding mappings.findProjects "") + ] + ); + }; binds.whichKey.register = pushDownDefault { "f" = "+Telescope"; @@ -66,29 +75,6 @@ in { "fv" = "Telescope Git"; "fvc" = "Commits"; }; - - pluginRC.telescope = entryAnywhere '' - local telescope = require('telescope') - telescope.setup(${toLuaObject cfg.setupOpts}) - - ${ - if config.vim.ui.noice.enable - then "telescope.load_extension('noice')" - else "" - } - - ${ - if config.vim.notify.nvim-notify.enable - then "telescope.load_extension('notify')" - else "" - } - - ${ - if config.vim.projects.project-nvim.enable - then "telescope.load_extension('projects')" - else "" - } - ''; }; }; } diff --git a/modules/plugins/visuals/fidget/config.nix b/modules/plugins/visuals/fidget/config.nix index 3ae3b6b9..7c83cd96 100644 --- a/modules/plugins/visuals/fidget/config.nix +++ b/modules/plugins/visuals/fidget/config.nix @@ -4,16 +4,15 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.nvim.lua) toLuaObject; - inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.visuals.fidget-nvim; in { config = mkIf cfg.enable { - vim.startPlugins = ["fidget-nvim"]; - - vim.pluginRC.fidget-nvim = entryAnywhere '' - require'fidget'.setup(${toLuaObject cfg.setupOpts}) - ''; + vim.lazy.plugins.fidget-nvim = { + package = "fidget-nvim"; + setupModule = "fidget"; + event = "LspAttach"; + inherit (cfg) setupOpts; + }; }; } diff --git a/modules/wrapper/lazy/config.nix b/modules/wrapper/lazy/config.nix new file mode 100644 index 00000000..01deeb0f --- /dev/null +++ b/modules/wrapper/lazy/config.nix @@ -0,0 +1,108 @@ +{ + lib, + config, + ... +}: let + inherit (builtins) toJSON typeOf head length filter concatLists concatStringsSep; + inherit (lib.attrsets) mapAttrsToList; + inherit (lib.modules) mkIf mkMerge; + inherit (lib.generators) mkLuaInline; + inherit (lib.strings) optionalString; + inherit (lib.nvim.lua) toLuaObject; + inherit (lib.nvim.dag) entryBefore entryAfter; + cfg = config.vim.lazy; + + toLuaLznKeySpec = keySpec: + (removeAttrs keySpec ["key" "lua" "action"]) + // { + "@1" = keySpec.key; + "@2" = + if keySpec.lua + then mkLuaInline keySpec.action + else keySpec.action; + }; + + toLuaLznSpec = name: spec: + (removeAttrs spec ["package" "setupModule" "setupOpts" "keys"]) + // { + "@1" = name; + before = + if spec.before != null + then + mkLuaInline '' + function() + ${spec.before} + end + '' + else null; + + after = + if spec.setupModule == null && spec.after == null + then null + else + mkLuaInline '' + function() + ${ + optionalString (spec.setupModule != null) + "require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})" + } + ${optionalString (spec.after != null) spec.after} + end + ''; + + keys = + if typeOf spec.keys == "list" && length spec.keys > 0 && typeOf (head spec.keys) == "set" + then map toLuaLznKeySpec (filter (keySpec: keySpec.key != null) spec.keys) + # empty list or str or (listOf str) + else spec.keys; + }; + lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins; + + pluginPackages = mapAttrsToList (_: plugin: plugin.package) cfg.plugins; + + specToNotLazyConfig = _: spec: '' + do + ${optionalString (spec.before != null) spec.before} + ${optionalString (spec.setupModule != null) + "require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"} + ${optionalString (spec.after != null) spec.after} + end + ''; + + specToKeymaps = _: spec: + if typeOf spec.keys == "list" + then map (x: removeAttrs x ["ft"]) (filter (lznKey: lznKey.action != null && lznKey.ft == null) spec.keys) + else if spec.keys == null || typeOf spec.keys == "string" + then [] + else [spec.keys]; + + notLazyConfig = + concatStringsSep "\n" + (mapAttrsToList specToNotLazyConfig cfg.plugins); + + beforeAllJoined = + concatStringsSep "\n" + (filter (x: x != null) (mapAttrsToList (_: spec: spec.beforeAll) cfg.plugins)); +in { + config.vim = mkMerge [ + (mkIf cfg.enable { + startPlugins = ["lz-n" "lzn-auto-require"]; + + optPlugins = pluginPackages; + + lazy.builtLazyConfig = '' + require('lz.n').load(${toLuaObject lznSpecs}) + ${optionalString cfg.enableLznAutoRequire "require('lzn-auto-require').enable()"} + ''; + }) + + (mkIf (!cfg.enable) { + startPlugins = pluginPackages; + lazy.builtLazyConfig = '' + ${beforeAllJoined} + ${notLazyConfig} + ''; + keymaps = concatLists (mapAttrsToList specToKeymaps cfg.plugins); + }) + ]; +} diff --git a/modules/wrapper/lazy/default.nix b/modules/wrapper/lazy/default.nix new file mode 100644 index 00000000..671516b0 --- /dev/null +++ b/modules/wrapper/lazy/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./lazy.nix + ./config.nix + ]; +} diff --git a/modules/wrapper/lazy/lazy.nix b/modules/wrapper/lazy/lazy.nix new file mode 100644 index 00000000..5b2c53d1 --- /dev/null +++ b/modules/wrapper/lazy/lazy.nix @@ -0,0 +1,237 @@ +{lib, ...}: let + inherit (lib.options) mkOption mkEnableOption; + inherit (lib.types) enum listOf submodule nullOr str bool int attrsOf anything either oneOf lines; + inherit (lib.nvim.types) pluginType; + inherit (lib.nvim.config) mkBool; + + lznKeysSpec = submodule { + options = { + key = mkOption { + type = nullOr str; + description = "Key to bind to. If key is null this entry is ignored."; + }; + + action = mkOption { + type = nullOr str; + default = null; + description = "Action to trigger."; + }; + lua = mkBool false '' + If true, `action` is considered to be lua code. + Thus, it will not be wrapped in `""`. + ''; + + desc = mkOption { + description = "Description of the key map"; + type = nullOr str; + default = null; + }; + + ft = mkOption { + description = "TBD"; + type = nullOr (listOf str); + default = null; + }; + + mode = mkOption { + description = "Modes to bind in"; + type = either str (listOf str); + default = ["n" "x" "s" "o"]; + }; + + silent = mkBool true "Whether this mapping should be silent. Equivalent to adding to a map."; + nowait = mkBool false "Whether to wait for extra input on ambiguous mappings. Equivalent to adding to a map."; + script = mkBool false "Equivalent to adding