From 9c93e9a9c083457824a7df457cd7719aa46351a7 Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Thu, 18 Jul 2024 11:48:28 +0200 Subject: [PATCH 1/3] Switch to rustaceanvim (#335) * flake: use rustaceanvim instead of rust-tools * rust: switch to rustaceanvim * docs: update release notes * flake: update nixpkgs * docs: wording --------- Co-authored-by: raf --- docs/release-notes/rl-0.7.md | 5 ++ flake.lock | 24 +++---- flake.nix | 4 +- modules/plugins/languages/rust.nix | 107 +++++++++++++---------------- 4 files changed, 67 insertions(+), 73 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index d5f3853..7c64a6a 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -34,6 +34,11 @@ Release notes for release 0.7 longer filtered and thus should be used instead. - Add dap-go for better dap configurations - Make noice.nvim customizable +- Switch from [rust-tools.nvim](https://github.com/simrat39/rust-tools.nvim) + to the more feature-packed [rustacean.nvim](https://github.com/mrcjkb/rustaceanvim. + This switch entails a whole bunch of new features and options, so you are + recommended to go through rustacean.nvim's README to take a closer look at + its features and usage. [jacekpoz](https://github.com/jacekpoz): diff --git a/flake.lock b/flake.lock index f6bb399..4601bc1 100644 --- a/flake.lock +++ b/flake.lock @@ -129,11 +129,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1720571246, - "narHash": "sha256-nkUXwunTck+hNMt2wZuYRN+jf2ySRjKTzI0fo5TDH78=", + "lastModified": 1721016451, + "narHash": "sha256-Cypl9ORr5UjtBsbjXMTJRepTe362yNVrPrntUvHiTaw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "16e401f01842c5bb2499e78c1fe227f939c0c474", + "rev": "a14c5d651cee9ed70f9cd9e83f323f1e531002db", "type": "github" }, "original": { @@ -1484,19 +1484,19 @@ "type": "github" } }, - "plugin-rust-tools": { + "plugin-rustaceanvim": { "flake": false, "locked": { - "lastModified": 1704259376, - "narHash": "sha256-kFane5ze7VDiOzF7jdmXkr50XQsNvdb+a9HQtybEVE0=", - "owner": "simrat39", - "repo": "rust-tools.nvim", - "rev": "676187908a1ce35ffcd727c654ed68d851299d3e", + "lastModified": 1720595685, + "narHash": "sha256-Mx8pB9ECjFpbfmZPuXfpwoE5pUZ363M53f27ht7MBmA=", + "owner": "mrcjkb", + "repo": "rustaceanvim", + "rev": "047f9c9d8cd2861745eb9de6c1570ee0875aa795", "type": "github" }, "original": { - "owner": "simrat39", - "repo": "rust-tools.nvim", + "owner": "mrcjkb", + "repo": "rustaceanvim", "type": "github" } }, @@ -1896,7 +1896,7 @@ "plugin-project-nvim": "plugin-project-nvim", "plugin-registers": "plugin-registers", "plugin-rose-pine": "plugin-rose-pine", - "plugin-rust-tools": "plugin-rust-tools", + "plugin-rustaceanvim": "plugin-rustaceanvim", "plugin-scrollbar-nvim": "plugin-scrollbar-nvim", "plugin-smartcolumn": "plugin-smartcolumn", "plugin-sqls-nvim": "plugin-sqls-nvim", diff --git a/flake.nix b/flake.nix index 67ed93e..7c3c38f 100644 --- a/flake.nix +++ b/flake.nix @@ -164,8 +164,8 @@ flake = false; }; - plugin-rust-tools = { - url = "github:simrat39/rust-tools.nvim"; + plugin-rustaceanvim = { + url = "github:mrcjkb/rustaceanvim"; flake = false; }; diff --git a/modules/plugins/languages/rust.nix b/modules/plugins/languages/rust.nix index 0753ab4..aaed6c5 100644 --- a/modules/plugins/languages/rust.nix +++ b/modules/plugins/languages/rust.nix @@ -125,72 +125,61 @@ in { (mkIf (cfg.lsp.enable || cfg.dap.enable) { vim = { - startPlugins = ["rust-tools"] ++ optionals cfg.dap.enable [cfg.dap.package]; + startPlugins = ["rustaceanvim"]; - lsp.lspconfig = { - enable = true; - sources.rust-lsp = '' - local rt = require('rust-tools') - rust_on_attach = function(client, bufnr) - default_on_attach(client, bufnr) - local opts = { noremap=true, silent=true, buffer = bufnr } - vim.keymap.set("n", "ris", rt.inlay_hints.set, opts) - vim.keymap.set("n", "riu", rt.inlay_hints.unset, opts) - vim.keymap.set("n", "rr", rt.runnables.runnables, opts) - vim.keymap.set("n", "rp", rt.parent_module.parent_module, opts) - vim.keymap.set("n", "rm", rt.expand_macro.expand_macro, opts) - vim.keymap.set("n", "rc", rt.open_cargo_toml.open_cargo_toml, opts) - vim.keymap.set("n", "rg", function() rt.crate_graph.view_crate_graph("x11", nil) end, opts) - ${optionalString cfg.dap.enable '' - vim.keymap.set("n", "rd", ":RustDebuggables", opts) - vim.keymap.set( - "n", "${config.vim.debugger.nvim-dap.mappings.continue}", - function() - local dap = require("dap") - if dap.status() == "" then - vim.cmd "RustDebuggables" - else - dap.continue() - end - end, - opts - ) - ''} - end - local rustopts = { - tools = { - autoSetHints = true, - hover_with_actions = false, - inlay_hints = { - only_current_line = false, - } + luaConfigRC.rustaceanvim = entryAnywhere '' + vim.g.rustaceanvim = { + ${optionalString cfg.lsp.enable '' + -- LSP + tools = { + hover_actions = { + replace_builtin_hover = false }, - server = { - capabilities = capabilities, - on_attach = rust_on_attach, - cmd = ${ + }, + server = { + cmd = ${ if isList cfg.lsp.package then expToLua cfg.lsp.package else ''{"${cfg.lsp.package}/bin/rust-analyzer"}'' }, - settings = { - ${cfg.lsp.opts} - } - }, - - ${optionalString cfg.dap.enable '' - dap = { - adapter = { - type = "executable", - command = "${cfg.dap.package}/bin/lldb-vscode", - name = "rt_lldb", - }, - }, + on_attach = function(client, bufnr) + default_on_attach(client, bufnr) + local opts = { noremap=true, silent=true, buffer = bufnr } + vim.keymap.set("n", "rr", ":RustLsp runnables", opts) + vim.keymap.set("n", "rp", ":RustLsp parentModule", opts) + vim.keymap.set("n", "rm", ":RustLsp expandMacro", opts) + vim.keymap.set("n", "rc", ":RustLsp openCargo", opts) + vim.keymap.set("n", "rg", ":RustLsp crateGraph x11", opts) + ${optionalString cfg.dap.enable '' + vim.keymap.set("n", "rd", ":RustLsp debuggables", opts) + vim.keymap.set( + "n", "${config.vim.debugger.nvim-dap.mappings.continue}", + function() + local dap = require("dap") + if dap.status() == "" then + vim.cmd "RustLsp debuggables" + else + dap.continue() + end + end, + opts + ) ''} - } - rt.setup(rustopts) - ''; - }; + end + }, + ''} + + ${optionalString cfg.dap.enable '' + dap = { + adapter = { + type = "executable", + command = "${cfg.dap.package}/bin/lldb-vscode", + name = "rustacean_lldb", + }, + }, + ''} + } + ''; }; }) ]); From cbff0e47159f6f4cb0595855ce84ba8d7dfdfe59 Mon Sep 17 00:00:00 2001 From: diniamo <55629891+diniamo@users.noreply.github.com> Date: Sat, 20 Jul 2024 10:22:13 +0200 Subject: [PATCH 2/3] flake: fix neovimConfiguration in top-level lib (#345) --- flake.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 7c3c38f..0290638 100644 --- a/flake.nix +++ b/flake.nix @@ -25,7 +25,8 @@ flake = { lib = { - inherit (lib) nvim neovimConfiguration; + inherit (lib) nvim; + inherit (lib.nvim) neovimConfiguration; }; homeManagerModules = { From f9789432f9955da30e2c210ee6e8e0a5b5434a79 Mon Sep 17 00:00:00 2001 From: diniamo <55629891+diniamo@users.noreply.github.com> Date: Sat, 20 Jul 2024 10:30:48 +0200 Subject: [PATCH 3/3] treewide: make the entire generated config lua based (#333) * modules: switch to gerg's neovim-wrapper * modules: use initViml instead of writing the file * treewide: make the entire generated config lua based * docs: remove mentions of configRC * plugins/treesitter: remove vim.cmd hack * treewide: move resolveDag to lib * modules/wrapper(rc): fix typo * treewide: migrate to pluginRC for correct DAG order The "new" DAG order is as follows: - (luaConfigPre) - globalsScript - basic - theme - pluginConfigs - extraPluginConfigs - mappings - (luaConfigPost) * plugins/theme: fix theme DAG place * plugins/theme: fix fixed theme DAG place * modules/wrapper(rc): add removed option module for configRC * docs: add dag-entries chapter, add release note entry * fix: formatting CI * languages/nix: add missing `local` * docs: fix page link * docs: add mention of breaking changes at the start of the release notes * plugins/neo-tree: convert to pluginRC * modules/wrapper(rc): add back entryAnywhere * modules/wrapper(rc): expose pluginRC * apply raf patch --------- Co-authored-by: NotAShelf --- docs/manual/configuring.md | 1 + .../configuring/custom-plugins/configuring.md | 34 +++- docs/manual/configuring/dag-entries.md | 20 +++ docs/manual/configuring/dags.md | 4 +- docs/release-notes/rl-0.7.md | 70 +++++++-- lib/dag.nix | 26 +++- lib/default.nix | 1 - lib/lua.nix | 10 -- lib/vim.nix | 26 ---- modules/default.nix | 3 +- modules/neovim/init/basic.nix | 112 ++++++-------- modules/neovim/mappings/config.nix | 42 +++-- modules/plugins/assistant/chatgpt/config.nix | 2 +- modules/plugins/assistant/copilot/config.nix | 2 +- .../autopairs/nvim-autopairs/config.nix | 2 +- .../plugins/comments/comment-nvim/config.nix | 2 +- .../plugins/completion/nvim-cmp/config.nix | 2 +- modules/plugins/dashboard/alpha/config.nix | 2 +- .../dashboard/dashboard-nvim/config.nix | 2 +- modules/plugins/dashboard/startify/config.nix | 21 ++- modules/plugins/debugger/nvim-dap/config.nix | 4 +- modules/plugins/filetree/neo-tree/config.nix | 2 +- modules/plugins/filetree/nvimtree/config.nix | 2 +- modules/plugins/git/gitsigns/config.nix | 2 +- modules/plugins/languages/clang.nix | 4 +- modules/plugins/languages/dart.nix | 2 +- modules/plugins/languages/elixir.nix | 2 +- modules/plugins/languages/go.nix | 2 +- modules/plugins/languages/html.nix | 2 +- modules/plugins/languages/lua.nix | 2 +- modules/plugins/languages/nix.nix | 13 +- modules/plugins/languages/rust.nix | 2 +- modules/plugins/languages/ts.nix | 2 +- modules/plugins/lsp/config.nix | 2 +- modules/plugins/lsp/lightbulb/config.nix | 2 +- modules/plugins/lsp/lsp-signature/config.nix | 2 +- modules/plugins/lsp/lspconfig/config.nix | 4 +- modules/plugins/lsp/lspkind/config.nix | 2 +- modules/plugins/lsp/lsplines/config.nix | 2 +- modules/plugins/lsp/lspsaga/config.nix | 2 +- modules/plugins/lsp/null-ls/config.nix | 4 +- .../lsp/nvim-code-action-menu/config.nix | 2 +- modules/plugins/lsp/nvim-docs-view/config.nix | 2 +- modules/plugins/lsp/trouble/config.nix | 2 +- modules/plugins/minimap/codewindow/config.nix | 2 +- modules/plugins/notes/mind-nvim/config.nix | 2 +- modules/plugins/notes/obsidian/config.nix | 2 +- modules/plugins/notes/orgmode/config.nix | 2 +- .../plugins/notes/todo-comments/config.nix | 2 +- .../plugins/projects/project-nvim/config.nix | 2 +- .../plugins/rich-presence/neocord/config.nix | 2 +- .../session/nvim-session-manager/config.nix | 2 +- .../spellcheck/vim-dirtytalk/config.nix | 2 +- modules/plugins/statusline/lualine/config.nix | 2 +- .../tabline/nvim-bufferline/config.nix | 2 +- .../plugins/terminal/toggleterm/config.nix | 4 +- ...ported_themes.nix => supported-themes.nix} | 0 modules/plugins/theme/theme.nix | 16 +- modules/plugins/treesitter/config.nix | 18 +-- .../plugins/treesitter/ts-context/config.nix | 2 +- modules/plugins/ui/breadcrumbs/config.nix | 2 +- modules/plugins/ui/colorizer/config.nix | 2 +- modules/plugins/ui/illuminate/config.nix | 2 +- modules/plugins/ui/modes/config.nix | 2 +- modules/plugins/ui/noice/config.nix | 2 +- .../ui/notifications/nvim-notify/config.nix | 2 +- modules/plugins/ui/smartcolumn/config.nix | 2 +- .../utility/binds/cheatsheet/config.nix | 2 +- .../utility/binds/which-key/config.nix | 2 +- modules/plugins/utility/ccc/config.nix | 2 +- .../utility/gestures/gesture-nvim/config.nix | 2 +- .../plugins/utility/icon-picker/config.nix | 2 +- .../utility/images/image-nvim/config.nix | 2 +- modules/plugins/utility/motion/hop/config.nix | 2 +- .../plugins/utility/motion/leap/config.nix | 2 +- .../plugins/utility/preview/glow/config.nix | 2 +- .../preview/markdown-preview/config.nix | 24 ++- modules/plugins/utility/surround/config.nix | 2 +- modules/plugins/utility/telescope/config.nix | 2 +- modules/plugins/utility/wakatime/config.nix | 13 +- modules/plugins/visuals/config.nix | 12 +- modules/plugins/visuals/fidget/config.nix | 2 +- modules/wrapper/rc/config.nix | 146 ++++++------------ modules/wrapper/rc/options.nix | 47 +++--- 84 files changed, 389 insertions(+), 404 deletions(-) create mode 100644 docs/manual/configuring/dag-entries.md delete mode 100644 lib/vim.nix rename modules/plugins/theme/{supported_themes.nix => supported-themes.nix} (100%) diff --git a/docs/manual/configuring.md b/docs/manual/configuring.md index 8f5e240..5a3c96f 100644 --- a/docs/manual/configuring.md +++ b/docs/manual/configuring.md @@ -5,4 +5,5 @@ configuring/custom-package.md configuring/custom-plugins.md configuring/languages.md configuring/dags.md +configuring/dag-entries.md ``` diff --git a/docs/manual/configuring/custom-plugins/configuring.md b/docs/manual/configuring/custom-plugins/configuring.md index da6274d..5e837ce 100644 --- a/docs/manual/configuring/custom-plugins/configuring.md +++ b/docs/manual/configuring/custom-plugins/configuring.md @@ -1,16 +1,38 @@ # 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 vimscript or lua config, using -either `config.vim.configRC` or `config.vim.luaConfigRC` respectively. Both of -these options are attribute sets, and you need to give the configuration you're -adding some name, like this: +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 +scope), and the its setup code respectively. For example: + +```nix +config.vim.extraPlugins = with pkgs.vimPlugins; { + aerial = { + package = aerial-nvim; + setup = "require('aerial').setup {}"; + }; + + harpoon = { + package = harpoon; + setup = "require('harpoon').setup {}"; + after = ["aerial"]; # place harpoon configuration after aerial + }; +} +``` + +The second option also uses an attribute set, but this one is resolved as a DAG +directly. The attribute names denote the section names, and the values lua code. +For example: ```nix { - # this will create an "aquarium" section in your init.vim with the contents of your custom config + # this will create an "aquarium" section in your init.lua with the contents of your custom config # which will be *appended* to the rest of your configuration, inside your init.vim - config.vim.configRC.aquarium = "colorscheme aquiarum"; + config.vim.luaConfigRC.aquarium = "vim.cmd('colorscheme aquiarum')"; } ``` diff --git a/docs/manual/configuring/dag-entries.md b/docs/manual/configuring/dag-entries.md new file mode 100644 index 0000000..5f4f4f6 --- /dev/null +++ b/docs/manual/configuring/dag-entries.md @@ -0,0 +1,20 @@ +# DAG entries in nvf {#ch-dag-entries} + +From the previous chapter, it should be clear that DAGs are useful, because you +can add code that relies on other code. However, if you don't know what the +entries are called, it's hard to do that, so here is a list of the internal +entries in nvf: + +`vim.luaConfigRC` (top-level DAG): + +1. (`luaConfigPre`) - not a part of the actual DAG, instead, it's simply + inserted before the rest of the DAG +2. `globalsScript` - used to set globals defined in `vim.globals` +3. `basic` - used to set basic configuration options +4. `theme` - used to set up the theme, which has to be done before other plugins +5. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option, + see the [Custom Plugins](/index.xhtml#ch-custom-plugins) page for adding your own + plugins) DAG, used to set up internal plugins +6. `extraPluginConfigs` - the result of `vim.extraPlugins`, which is not a + direct DAG, but is converted to, and resolved as one internally +7. `mappings` - the result of `vim.maps` diff --git a/docs/manual/configuring/dags.md b/docs/manual/configuring/dags.md index 77817cb..6bcd156 100644 --- a/docs/manual/configuring/dags.md +++ b/docs/manual/configuring/dags.md @@ -6,8 +6,8 @@ addition for certain options is the [**DAG type which is borrowed from home-manager's extended library. This type is most used for topologically sorting strings. The DAG type allows the attribute set entries to express dependency relations among themselves. This can, for -example, be used to control the order of configuration sections in your -`configRC` or `luaConfigRC`. +example, be used to control the order of configuration sections in your +`luaConfigRC`. The below section, mostly taken from the [home-manager manual](https://raw.githubusercontent.com/nix-community/home-manager/master/docs/manual/writing-modules/types.md) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 7c64a6a..c1b05bc 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -2,6 +2,28 @@ Release notes for release 0.7 +## Breaking Changes and Migration Guide {#sec-breaking-changes-and-migration-guide-0-7} + +In v0.7 we are removing `vim.configRC` in favor of making `vim.luaConfigRC` the +top-level DAG, and thereby making the entire configuration Lua based. This +change introduces a few breaking changes: + +[DAG entries in nvf manual]: /index.xhtml#ch-dag-entries + +- `vim.configRC` has been removed, which means that you have to convert all of + your custom vimscript-based configuration to Lua. As for how to do that, you + will have to consult the Neovim documentation and your search engine. +- After migrating your Vimscript-based configuration to Lua, you might not be + able to use the same entry names in `vim.luaConfigRC`, because those have also + slightly changed. See the new [DAG entries in nvf manual] for more details. + +**Why?** + +Neovim being an aggressive refactor of Vim, is designed to be mainly Lua based; +making good use of its extensive Lua API. Additionally, Vimscript is slow and +brings unnecessary performance overhead while working with different +configuration formats. + ## Changelog {#sec-release-0.7-changelog} [ItsSorae](https://github.com/ItsSorae): @@ -12,8 +34,8 @@ Release notes for release 0.7 [frothymarrow](https://github.com/frothymarrow): - Modified type for - [vim.visuals.fidget-nvim.setupOpts.progress.display.overrides](#opt-vim.visuals.fidget-nvim.setupOpts.progress.display.overrides) - from `anything` to a `submodule` for better type checking. + [](#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. @@ -21,30 +43,34 @@ Release notes for release 0.7 group for `Normal`, `NormalFloat`, `LineNr`, `SignColumn` and optionally `NvimTreeNormal` to `none`. -- Fix - [vim.ui.smartcolumn.setupOpts.custom_colorcolumn](#opt-vim.ui.smartcolumn.setupOpts.custom_colorcolumn) - using the wrong type `int` instead of the expected type `string`. +- Fix [](#opt-vim.ui.smartcolumn.setupOpts.custom_colorcolumn) using the wrong + type `int` instead of the expected type `string`. - Fix unused src and version attributes in `buildPlug`. [horriblename](https://github.com/horriblename): - Fix broken treesitter-context keybinds in visual mode -- Deprecate use of `__empty` to define empty tables in lua. Empty attrset are no +- Deprecate use of `__empty` to define empty tables in Lua. Empty attrset are no longer filtered and thus should be used instead. - Add dap-go for better dap configurations - Make noice.nvim customizable -- Switch from [rust-tools.nvim](https://github.com/simrat39/rust-tools.nvim) - to the more feature-packed [rustacean.nvim](https://github.com/mrcjkb/rustaceanvim. - This switch entails a whole bunch of new features and options, so you are - recommended to go through rustacean.nvim's README to take a closer look at - its features and usage. + +[rust-tools.nvim]: https://github.com/simrat39/rust-tools.nvim +[rustaceanvim]: https://github.com/mrcjkb/rustaceanvim + +- Switch from [rust-tools.nvim] to the more feature-packed [rustaceanvim]. This + switch entails a whole bunch of new features and options, so you are + recommended to go through rustacean.nvim's README to take a closer look at its + features and usage [jacekpoz](https://github.com/jacekpoz): -- Add [ocaml-lsp](https://github.com/ocaml/ocaml-lsp) support. +[ocaml-lsp]: https://github.com/ocaml/ocaml-lsp -- Fix Emac typo +- Add [ocaml-lsp] support + +- Fix "Emac" typo [diniamo](https://github.com/diniamo): @@ -66,6 +92,7 @@ Release notes for release 0.7 plugin's options can now be found under `indentBlankline.setupOpts`, the previous iteration of the module also included out of place/broken options, which have been removed for the time being. These are: + - `listChar` - this was already unused - `fillChar` - this had nothing to do with the plugin, please configure it yourself by adding `vim.opt.listchars:append({ space = '' })` to your @@ -74,9 +101,22 @@ Release notes for release 0.7 yourself by adding `vim.opt.listchars:append({ eol = '' })` to your lua configuration +[Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd() + +- Make Neovim's configuration file entirely Lua based. This comes with a few + breaking changes: + - `vim.configRC` has been removed. You will need to migrate your entries to + Neovim-compliant Lua code, and add them to `vim.luaConfigRC` instead. + Existing vimscript configurations may be preserved in `vim.cmd` functions. + Please see [Neovim documentation on `vim.cmd`] + - `vim.luaScriptRC` is now the top-level DAG, and the internal `vim.pluginRC` + has been introduced for setting up internal plugins. See the "DAG entries in + nvf" manual page for more information. + [NotAShelf](https://github.com/notashelf): [ts-error-translator.nvim]: https://github.com/dmmulroy/ts-error-translator.nvim +[credo]: https://github.com/rrrene/credo - Add `deno fmt` as the default Markdown formatter. This will be enabled automatically if you have autoformatting enabled, but can be disabled manually @@ -87,8 +127,8 @@ Release notes for release 0.7 - 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. + added once the [credo] linter has been added to nixpkgs. A pull request is + currently open. - Remove vim-tidal and friends. diff --git a/lib/dag.nix b/lib/dag.nix index d740f6a..d0659fe 100644 --- a/lib/dag.nix +++ b/lib/dag.nix @@ -8,10 +8,10 @@ # - the addition of the function `entryBefore` indicating a "wanted # by" relationship. {lib}: let - inherit (builtins) isAttrs attrValues attrNames elem all head tail length; + inherit (builtins) isAttrs attrValues attrNames elem all head tail length toJSON isString; inherit (lib.attrsets) filterAttrs mapAttrs; inherit (lib.lists) toposort; - inherit (lib.nvim.dag) empty isEntry entryBetween entryAfter entriesBetween; + inherit (lib.nvim.dag) empty isEntry entryBetween entryAfter entriesBetween entryAnywhere topoSort; in { empty = {}; @@ -147,8 +147,22 @@ in { ${section.data} ''; - mkVimrcSection = section: '' - " SECTION: ${section.name} - ${section.data} - ''; + resolveDag = { + name, + dag, + mapResult, + }: let + # When the value is a string, default it to dag.entryAnywhere + finalDag = mapAttrs (_: value: + if isString value + then entryAnywhere value + else value) + dag; + sortedDag = topoSort finalDag; + result = + if sortedDag ? result + then mapResult sortedDag.result + else abort ("Dependency cycle in ${name}: " + toJSON sortedDag); + in + result; } diff --git a/lib/default.nix b/lib/default.nix index 35485b7..2e4b7f8 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -11,6 +11,5 @@ languages = import ./languages.nix {inherit lib;}; lists = import ./lists.nix {inherit lib;}; lua = import ./lua.nix {inherit lib;}; - vim = import ./vim.nix; neovimConfiguration = import ./configuration.nix {inherit inputs lib;}; } diff --git a/lib/lua.nix b/lib/lua.nix index 167839e..e3f9449 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -5,16 +5,6 @@ inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters concatLines; inherit (lib.trivial) boolToString warn; in rec { - wrapLuaConfig = { - luaBefore ? "", - luaConfig, - luaAfter ? "", - }: '' - lua << EOF - ${concatLines [luaBefore luaConfig luaAfter]} - EOF - ''; - # Convert a null value to lua's nil nullString = value: if value == null diff --git a/lib/vim.nix b/lib/vim.nix deleted file mode 100644 index da5bf55..0000000 --- a/lib/vim.nix +++ /dev/null @@ -1,26 +0,0 @@ -let - inherit (builtins) isInt isBool toJSON toString; -in rec { - # yes? no. - yesNo = value: - if value - then "yes" - else "no"; - - # convert a boolean to a vim compliant boolean string - mkVimBool = val: - if val - then "1" - else "0"; - - # convert a literal value to a vim compliant value - valToVim = val: - if (isInt val) - then (toString val) - else - ( - if (isBool val) - then (mkVimBool val) - else (toJSON val) - ); -} diff --git a/modules/default.nix b/modules/default.nix index ff71677..fbcdb70 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -98,8 +98,9 @@ inputs: { neovim = vimOptions.package; plugins = concatLists [builtStartPlugins builtOptPlugins]; appName = "nvf"; - initViml = vimOptions.builtConfigRC; extraBinPath = vimOptions.extraPackages; + initLua = vimOptions.builtLuaConfigRC; + luaFiles = vimOptions.extraLuaFiles; inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3; inherit extraLuaPackages extraPython3Packages; diff --git a/modules/neovim/init/basic.nix b/modules/neovim/init/basic.nix index 3c8f0b3..07bb70d 100644 --- a/modules/neovim/init/basic.nix +++ b/modules/neovim/init/basic.nix @@ -5,16 +5,17 @@ }: let inherit (lib.options) mkOption literalExpression; inherit (lib.strings) optionalString; - inherit (lib.types) enum bool str int nullOr; + inherit (lib.types) enum bool str int; inherit (lib.nvim.dag) entryAfter; + inherit (lib.nvim.lua) toLuaObject; cfg = config.vim; in { options.vim = { leaderKey = mkOption { - type = nullOr str; - default = null; - description = "The leader key to be used internally"; + type = str; + default = " "; + description = "The leader key used for `` mappings"; }; colourTerm = mkOption { @@ -53,12 +54,6 @@ in { description = "Enable syntax highlighting"; }; - mapLeaderSpace = mkOption { - type = bool; - default = true; - description = "Map the space key to leader key"; - }; - useSystemClipboard = mkOption { type = bool; default = false; @@ -165,117 +160,110 @@ in { }; }; - config.vim.configRC.basic = entryAfter ["globalsScript"] '' - " Settings that are set for everything - set encoding=utf-8 - set hidden - set shortmess+=c - set expandtab - set mouse=${cfg.mouseSupport} - set tabstop=${toString cfg.tabWidth} - set shiftwidth=${toString cfg.tabWidth} - set softtabstop=${toString cfg.tabWidth} - set cmdheight=${toString cfg.cmdHeight} - set updatetime=${toString cfg.updateTime} - set tm=${toString cfg.mapTimeout} - set cursorlineopt=${toString cfg.cursorlineOpt} - set scrolloff=${toString cfg.scrollOffset} + config.vim.luaConfigRC.basic = entryAfter ["globalsScript"] '' + -- Settings that are set for everything + vim.o.encoding = "utf-8" + vim.o.hidden = true + vim.opt.shortmess:append("c") + vim.o.expandtab = true + vim.o.mouse = ${toLuaObject cfg.mouseSupport} + vim.o.tabstop = ${toLuaObject cfg.tabWidth} + vim.o.shiftwidth = ${toLuaObject cfg.tabWidth} + vim.o.softtabstop = ${toLuaObject cfg.tabWidth} + vim.o.cmdheight = ${toLuaObject cfg.cmdHeight} + vim.o.updatetime = ${toLuaObject cfg.updateTime} + vim.o.tm = ${toLuaObject cfg.mapTimeout} + vim.o.cursorlineopt = ${toLuaObject cfg.cursorlineOpt} + vim.o.scrolloff = ${toLuaObject cfg.scrollOffset} + vim.g.mapleader = ${toLuaObject cfg.leaderKey} + vim.g.maplocalleader = ${toLuaObject cfg.leaderKey} ${optionalString cfg.splitBelow '' - set splitbelow + vim.o.splitbelow = true ''} ${optionalString cfg.splitRight '' - set splitright + vim.o.splitright = true ''} ${optionalString cfg.showSignColumn '' - set signcolumn=yes + vim.o.signcolumn = "yes" ''} ${optionalString cfg.autoIndent '' - set autoindent + vim.o.autoindent = true ''} ${optionalString cfg.preventJunkFiles '' - set noswapfile - set nobackup - set nowritebackup + vim.o.swapfile = false + vim.o.backup = false + vim.o.writebackup = false ''} ${optionalString (cfg.bell == "none") '' - set noerrorbells - set novisualbell + vim.o.errorbells = false + vim.o.visualbell = false ''} ${optionalString (cfg.bell == "on") '' - set novisualbell + vim.o.visualbell = false ''} ${optionalString (cfg.bell == "visual") '' - set noerrorbells + vim.o.errorbells = false ''} ${optionalString (cfg.lineNumberMode == "relative") '' - set relativenumber + vim.o.relativenumber = true ''} ${optionalString (cfg.lineNumberMode == "number") '' - set number + vim.o.number = true ''} ${optionalString (cfg.lineNumberMode == "relNumber") '' - set number relativenumber + vim.o.number = true + vim.o.relativenumber = true ''} ${optionalString cfg.useSystemClipboard '' - set clipboard+=unnamedplus - ''} - - ${optionalString cfg.mapLeaderSpace '' - let mapleader=" " - let maplocalleader=" " + vim.opt.clipboard:append("unnamedplus") ''} ${optionalString cfg.syntaxHighlighting '' - syntax on + vim.cmd("syntax on") ''} ${optionalString (!cfg.wordWrap) '' - set nowrap + vim.o.wrap = false ''} ${optionalString cfg.hideSearchHighlight '' - set nohlsearch - set incsearch + vim.o.hlsearch = false + vim.o.incsearch = true ''} ${optionalString cfg.colourTerm '' - set termguicolors - set t_Co=256 + vim.o.termguicolors = true ''} ${optionalString (!cfg.enableEditorconfig) '' - let g:editorconfig = v:false - ''} - - ${optionalString (cfg.leaderKey != null) '' - let mapleader = "${toString cfg.leaderKey}" + vim.g.editorconfig = false ''} ${optionalString (cfg.searchCase == "ignore") '' - set nosmartcase - set ignorecase + vim.o.smartcase = false + vim.o.ignorecase = true ''} ${optionalString (cfg.searchCase == "smart") '' - set smartcase - set ignorecase + vim.o.smartcase = true + vim.o.ignorecase = true ''} ${optionalString (cfg.searchCase == "sensitive") '' - set nosmartcase - set noignorecase + vim.o.smartcase = false + vim.o.ignorecase = false ''} ''; } diff --git a/modules/neovim/mappings/config.nix b/modules/neovim/mappings/config.nix index 8bc58af..28ebf08 100644 --- a/modules/neovim/mappings/config.nix +++ b/modules/neovim/mappings/config.nix @@ -9,32 +9,26 @@ in { config = { vim.maps = { - normal = - mkIf cfg.disableArrows { - "" = { - action = ""; + normal = mkIf cfg.disableArrows { + "" = { + action = ""; - noremap = false; - }; - "" = { - action = ""; - - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - "" = { - action = ""; - noremap = false; - }; - } - // mkIf cfg.mapLeaderSpace { - "" = { - action = ""; - }; + noremap = false; }; + "" = { + action = ""; + + noremap = false; + }; + "" = { + action = ""; + noremap = false; + }; + "" = { + action = ""; + noremap = false; + }; + }; insert = mkIf cfg.disableArrows { "" = { diff --git a/modules/plugins/assistant/chatgpt/config.nix b/modules/plugins/assistant/chatgpt/config.nix index 79db0d9..3caa221 100644 --- a/modules/plugins/assistant/chatgpt/config.nix +++ b/modules/plugins/assistant/chatgpt/config.nix @@ -33,7 +33,7 @@ in { startPlugins = [ "chatgpt" ]; - luaConfigRC.chagpt = entryAnywhere '' + pluginRC.chagpt = entryAnywhere '' require("chatgpt").setup(${toLuaObject cfg.setupOpts}) ''; maps.normal = mkMerge [ diff --git a/modules/plugins/assistant/copilot/config.nix b/modules/plugins/assistant/copilot/config.nix index b7adc82..c9e6f83 100644 --- a/modules/plugins/assistant/copilot/config.nix +++ b/modules/plugins/assistant/copilot/config.nix @@ -34,7 +34,7 @@ in { "copilot-cmp" ]; - vim.luaConfigRC.copilot = entryAnywhere '' + vim.pluginRC.copilot = entryAnywhere '' require("copilot").setup(${toLuaObject cfg.setupOpts}) ${lib.optionalString cfg.cmp.enable '' diff --git a/modules/plugins/autopairs/nvim-autopairs/config.nix b/modules/plugins/autopairs/nvim-autopairs/config.nix index 3a20960..6ef7cbf 100644 --- a/modules/plugins/autopairs/nvim-autopairs/config.nix +++ b/modules/plugins/autopairs/nvim-autopairs/config.nix @@ -12,7 +12,7 @@ in { config = mkIf cfg.enable { vim.startPlugins = ["nvim-autopairs"]; - vim.luaConfigRC.autopairs = entryAnywhere '' + vim.pluginRC.autopairs = entryAnywhere '' require("nvim-autopairs").setup({ map_cr = ${boolToString (!config.vim.autocomplete.enable)} }) ''; }; diff --git a/modules/plugins/comments/comment-nvim/config.nix b/modules/plugins/comments/comment-nvim/config.nix index 40ccb0a..e70e918 100644 --- a/modules/plugins/comments/comment-nvim/config.nix +++ b/modules/plugins/comments/comment-nvim/config.nix @@ -41,7 +41,7 @@ in { (mkBinding cfg.mappings.toggleSelectedBlock "(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description) ]; - vim.luaConfigRC.comment-nvim = entryAnywhere '' + vim.pluginRC.comment-nvim = entryAnywhere '' require('Comment').setup({ mappings = { basic = false, extra = false, }, }) diff --git a/modules/plugins/completion/nvim-cmp/config.nix b/modules/plugins/completion/nvim-cmp/config.nix index 9e27607..a28db3e 100644 --- a/modules/plugins/completion/nvim-cmp/config.nix +++ b/modules/plugins/completion/nvim-cmp/config.nix @@ -186,7 +186,7 @@ in { # TODO: alternative snippet engines to vsnip # https://github.com/hrsh7th/nvim-cmp/blob/main/doc/cmp.txt#L82 - vim.luaConfigRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement '' + vim.pluginRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement '' local nvim_cmp_menu_map = function(entry, vim_item) -- name for each source vim_item.menu = ({ diff --git a/modules/plugins/dashboard/alpha/config.nix b/modules/plugins/dashboard/alpha/config.nix index 12072e3..bb648a5 100644 --- a/modules/plugins/dashboard/alpha/config.nix +++ b/modules/plugins/dashboard/alpha/config.nix @@ -16,7 +16,7 @@ in { # the entire credit for this dashboard configuration to https://github.com/Rishabh672003 # honestly, excellent work - vim.luaConfigRC.alpha = entryAnywhere '' + vim.pluginRC.alpha = entryAnywhere '' local alpha = require("alpha") local plenary_path = require("plenary.path") local dashboard = require("alpha.themes.dashboard") diff --git a/modules/plugins/dashboard/dashboard-nvim/config.nix b/modules/plugins/dashboard/dashboard-nvim/config.nix index 9d827a4..088842a 100644 --- a/modules/plugins/dashboard/dashboard-nvim/config.nix +++ b/modules/plugins/dashboard/dashboard-nvim/config.nix @@ -13,7 +13,7 @@ in { "dashboard-nvim" ]; - vim.luaConfigRC.dashboard-nvim = entryAnywhere '' + vim.pluginRC.dashboard-nvim = entryAnywhere '' require("dashboard").setup{} ''; }; diff --git a/modules/plugins/dashboard/startify/config.nix b/modules/plugins/dashboard/startify/config.nix index 7e9a0f4..f6cdb2c 100644 --- a/modules/plugins/dashboard/startify/config.nix +++ b/modules/plugins/dashboard/startify/config.nix @@ -5,7 +5,6 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.nvim.vim) mkVimBool; cfg = config.vim.dashboard.startify; in { @@ -23,28 +22,28 @@ in { else cfg.customFooter; "startify_bookmarks" = cfg.bookmarks; "startify_lists" = cfg.lists; - "startify_change_to_dir" = mkVimBool cfg.changeToDir; - "startify_change_to_vcs_root" = mkVimBool cfg.changeToVCRoot; + "startify_change_to_dir" = cfg.changeToDir; + "startify_change_to_vcs_root" = cfg.changeToVCRoot; "startify_change_cmd" = cfg.changeDirCmd; "startify_skiplist" = cfg.skipList; - "startify_update_oldfiles" = mkVimBool cfg.updateOldFiles; - "startify_session_autoload" = mkVimBool cfg.sessionAutoload; + "startify_update_oldfiles" = cfg.updateOldFiles; + "startify_session_autoload" = cfg.sessionAutoload; "startify_commands" = cfg.commands; "startify_files_number" = cfg.filesNumber; "startify_custom_indices" = cfg.customIndices; - "startify_disable_at_vimenter" = mkVimBool cfg.disableOnStartup; - "startify_enable_unsafe" = mkVimBool cfg.unsafe; + "startify_disable_at_vimenter" = cfg.disableOnStartup; + "startify_enable_unsafe" = cfg.unsafe; "startify_padding_left" = cfg.paddingLeft; - "startify_use_env" = mkVimBool cfg.useEnv; + "startify_use_env" = cfg.useEnv; "startify_session_before_save" = cfg.sessionBeforeSave; - "startify_session_persistence" = mkVimBool cfg.sessionPersistence; - "startify_session_delete_buffers" = mkVimBool cfg.sessionDeleteBuffers; + "startify_session_persistence" = cfg.sessionPersistence; + "startify_session_delete_buffers" = cfg.sessionDeleteBuffers; "startify_session_dir" = cfg.sessionDir; "startify_skiplist_server" = cfg.skipListServer; "startify_session_remove_lines" = cfg.sessionRemoveLines; "startify_session_savevars" = cfg.sessionSavevars; "startify_session_savecmds" = cfg.sessionSavecmds; - "startify_session_sort" = mkVimBool cfg.sessionSort; + "startify_session_sort" = cfg.sessionSort; }; }; } diff --git a/modules/plugins/debugger/nvim-dap/config.nix b/modules/plugins/debugger/nvim-dap/config.nix index b26a5bd..072ad9a 100644 --- a/modules/plugins/debugger/nvim-dap/config.nix +++ b/modules/plugins/debugger/nvim-dap/config.nix @@ -18,7 +18,7 @@ in { (mkIf cfg.enable { vim.startPlugins = ["nvim-dap"]; - vim.luaConfigRC = + vim.pluginRC = { # TODO customizable keymaps nvim-dap = entryAnywhere '' @@ -51,7 +51,7 @@ in { (mkIf (cfg.enable && cfg.ui.enable) { vim.startPlugins = ["nvim-dap-ui" "nvim-nio"]; - vim.luaConfigRC.nvim-dap-ui = entryAfter ["nvim-dap"] ('' + vim.pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] ('' local dapui = require("dapui") dapui.setup() '' diff --git a/modules/plugins/filetree/neo-tree/config.nix b/modules/plugins/filetree/neo-tree/config.nix index dd85287..df8e84b 100644 --- a/modules/plugins/filetree/neo-tree/config.nix +++ b/modules/plugins/filetree/neo-tree/config.nix @@ -20,7 +20,7 @@ in { "neo-tree-nvim" ]; - luaConfigRC.neo-tree = entryAnywhere '' + pluginRC.neo-tree = entryAnywhere '' require("neo-tree").setup(${toLuaObject cfg.setupOpts}) ''; }; diff --git a/modules/plugins/filetree/nvimtree/config.nix b/modules/plugins/filetree/nvimtree/config.nix index f016191..b97b1e4 100644 --- a/modules/plugins/filetree/nvimtree/config.nix +++ b/modules/plugins/filetree/nvimtree/config.nix @@ -29,7 +29,7 @@ in { "t" = "+NvimTree"; }; - vim.luaConfigRC.nvimtreelua = entryAnywhere '' + vim.pluginRC.nvimtreelua = entryAnywhere '' ${ optionalString cfg.setupOpts.disable_netrw '' -- disable netrew completely diff --git a/modules/plugins/git/gitsigns/config.nix b/modules/plugins/git/gitsigns/config.nix index b0aac94..039ab63 100644 --- a/modules/plugins/git/gitsigns/config.nix +++ b/modules/plugins/git/gitsigns/config.nix @@ -69,7 +69,7 @@ in { "g" = "+Gitsigns"; }; - luaConfigRC.gitsigns = entryAnywhere '' + pluginRC.gitsigns = entryAnywhere '' require('gitsigns').setup{} ''; }; diff --git a/modules/plugins/languages/clang.nix b/modules/plugins/languages/clang.nix index 98f972d..0b3ffcf 100644 --- a/modules/plugins/languages/clang.nix +++ b/modules/plugins/languages/clang.nix @@ -12,7 +12,7 @@ inherit (lib.modules) mkIf mkMerge; inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.types) mkGrammarOption; - inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.dag) entryAfter; packageToCmd = package: defaultCmd: if isList cfg.lsp.package @@ -141,7 +141,7 @@ in { config = mkIf cfg.enable (mkMerge [ (mkIf cfg.cHeader { - vim.configRC.c-header = entryAnywhere "let g:c_syntax_for_h = 1"; + vim.pluginRC.c-header = entryAfter ["basic"] "vim.g.c_syntax_for_h = 1"; }) (mkIf cfg.treesitter.enable { diff --git a/modules/plugins/languages/dart.nix b/modules/plugins/languages/dart.nix index 8f957c9..ee069a7 100644 --- a/modules/plugins/languages/dart.nix +++ b/modules/plugins/languages/dart.nix @@ -140,7 +140,7 @@ in { then ["flutter-tools-patched"] else ["flutter-tools"]; - vim.luaConfigRC.flutter-tools = entryAnywhere '' + vim.pluginRC.flutter-tools = entryAnywhere '' require('flutter-tools').setup { lsp = { color = { -- show the derived colours for dart variables diff --git a/modules/plugins/languages/elixir.nix b/modules/plugins/languages/elixir.nix index 7f969ad..1a57d78 100644 --- a/modules/plugins/languages/elixir.nix +++ b/modules/plugins/languages/elixir.nix @@ -113,7 +113,7 @@ in { (mkIf cfg.elixir-tools.enable { vim.startPlugins = ["elixir-tools"]; - vim.luaConfigRC.elixir-tools = entryAnywhere '' + vim.pluginRC.elixir-tools = entryAnywhere '' local elixir-tools = require("elixir") local elixirls = require("elixir-tools.elixirls") diff --git a/modules/plugins/languages/go.nix b/modules/plugins/languages/go.nix index 05e28ed..e0eded0 100644 --- a/modules/plugins/languages/go.nix +++ b/modules/plugins/languages/go.nix @@ -102,7 +102,7 @@ in { (mkIf cfg.dap.enable { vim = { startPlugins = ["nvim-dap-go"]; - luaConfigRC.nvim-dap-go = entryAfter ["nvim-dap"] '' + pluginRC.nvim-dap-go = entryAfter ["nvim-dap"] '' require('dap-go').setup { delve = { path = '${getExe cfg.dap.package}', diff --git a/modules/plugins/languages/html.nix b/modules/plugins/languages/html.nix index a4cf238..0bef276 100644 --- a/modules/plugins/languages/html.nix +++ b/modules/plugins/languages/html.nix @@ -36,7 +36,7 @@ in { grammars = [cfg.treesitter.package]; }; - luaConfigRC.html-autotag = mkIf cfg.treesitter.autotagHtml (entryAnywhere '' + pluginRC.html-autotag = mkIf cfg.treesitter.autotagHtml (entryAnywhere '' require('nvim-ts-autotag').setup() ''); }; diff --git a/modules/plugins/languages/lua.nix b/modules/plugins/languages/lua.nix index 7cbacb6..5ceed3e 100644 --- a/modules/plugins/languages/lua.nix +++ b/modules/plugins/languages/lua.nix @@ -61,7 +61,7 @@ in { (mkIf cfg.lsp.neodev.enable { vim.startPlugins = ["neodev-nvim"]; - vim.luaConfigRC.neodev = entryBefore ["lua-lsp"] '' + vim.pluginRC.neodev = entryBefore ["lua-lsp"] '' require("neodev").setup({}) ''; }) diff --git a/modules/plugins/languages/nix.nix b/modules/plugins/languages/nix.nix index 2e243eb..6cf1f90 100644 --- a/modules/plugins/languages/nix.nix +++ b/modules/plugins/languages/nix.nix @@ -11,7 +11,6 @@ inherit (lib.strings) optionalString; inherit (lib.types) enum either listOf package str; inherit (lib.nvim.types) mkGrammarOption diagnostics; - inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.languages) diagnosticsToLua; @@ -176,8 +175,16 @@ in { config = mkIf cfg.enable (mkMerge [ { - vim.configRC.nix = entryAnywhere '' - autocmd filetype nix setlocal tabstop=2 shiftwidth=2 softtabstop=2 + vim.pluginRC.nix = '' + vim.api.nvim_create_autocmd("FileType", { + pattern = "nix", + callback = function(opts) + local bo = vim.bo[opts.buf] + bo.tabstop = 2 + bo.shiftwidth = 2 + bo.softtabstop = 2 + end + }) ''; } diff --git a/modules/plugins/languages/rust.nix b/modules/plugins/languages/rust.nix index aaed6c5..39a8c36 100644 --- a/modules/plugins/languages/rust.nix +++ b/modules/plugins/languages/rust.nix @@ -102,7 +102,7 @@ in { startPlugins = ["crates-nvim"]; lsp.null-ls.enable = mkIf cfg.crates.codeActions true; autocomplete.sources = {"crates" = "[Crates]";}; - luaConfigRC.rust-crates = entryAnywhere '' + pluginRC.rust-crates = entryAnywhere '' require('crates').setup { null_ls = { enabled = ${boolToString cfg.crates.codeActions}, diff --git a/modules/plugins/languages/ts.nix b/modules/plugins/languages/ts.nix index 3478d4f..dd1bde6 100644 --- a/modules/plugins/languages/ts.nix +++ b/modules/plugins/languages/ts.nix @@ -192,7 +192,7 @@ in { (mkIf cfg.extensions."ts-error-translator".enable { vim.startPlugins = ["ts-error-translator"]; - vim.luaConfigRC.ts-error-translator = entryAnywhere '' + vim.pluginRC.ts-error-translator = entryAnywhere '' require("ts-error-translator").setup(${toLuaObject cfg.extensions.ts-error-translator.setupOpts}) ''; }) diff --git a/modules/plugins/lsp/config.nix b/modules/plugins/lsp/config.nix index 93e3da6..a0aa7fe 100644 --- a/modules/plugins/lsp/config.nix +++ b/modules/plugins/lsp/config.nix @@ -27,7 +27,7 @@ in { autocomplete.sources = {"nvim_lsp" = "[LSP]";}; - luaConfigRC.lsp-setup = '' + pluginRC.lsp-setup = '' vim.g.formatsave = ${boolToString cfg.formatOnSave}; local attach_keymaps = function(client, bufnr) diff --git a/modules/plugins/lsp/lightbulb/config.nix b/modules/plugins/lsp/lightbulb/config.nix index ef2239f..f44c2dd 100644 --- a/modules/plugins/lsp/lightbulb/config.nix +++ b/modules/plugins/lsp/lightbulb/config.nix @@ -12,7 +12,7 @@ in { vim = { startPlugins = ["nvim-lightbulb"]; - luaConfigRC.lightbulb = entryAnywhere '' + pluginRC.lightbulb = entryAnywhere '' vim.api.nvim_command('autocmd CursorHold,CursorHoldI * lua require\'nvim-lightbulb\'.update_lightbulb()') -- Enable trouble diagnostics viewer diff --git a/modules/plugins/lsp/lsp-signature/config.nix b/modules/plugins/lsp/lsp-signature/config.nix index c194912..c994053 100644 --- a/modules/plugins/lsp/lsp-signature/config.nix +++ b/modules/plugins/lsp/lsp-signature/config.nix @@ -20,7 +20,7 @@ in { handler_opts.border = config.vim.ui.borders.plugins.lsp-signature.style; }; - luaConfigRC.lsp-signature = entryAnywhere '' + pluginRC.lsp-signature = entryAnywhere '' -- Enable lsp signature viewer require("lsp_signature").setup(${toLuaObject cfg.lspSignature.setupOpts}) ''; diff --git a/modules/plugins/lsp/lspconfig/config.nix b/modules/plugins/lsp/lspconfig/config.nix index 1736ce9..15d42fd 100644 --- a/modules/plugins/lsp/lspconfig/config.nix +++ b/modules/plugins/lsp/lspconfig/config.nix @@ -17,7 +17,7 @@ in { startPlugins = ["nvim-lspconfig"]; - luaConfigRC.lspconfig = entryAfter ["lsp-setup"] '' + pluginRC.lspconfig = entryAfter ["lsp-setup"] '' local lspconfig = require('lspconfig') ${ @@ -29,7 +29,7 @@ in { }; } { - vim.luaConfigRC = mapAttrs (_: v: (entryAfter ["lspconfig"] v)) cfg.lspconfig.sources; + vim.pluginRC = mapAttrs (_: v: (entryAfter ["lspconfig"] v)) cfg.lspconfig.sources; } ]); } diff --git a/modules/plugins/lsp/lspkind/config.nix b/modules/plugins/lsp/lspkind/config.nix index a98aeab..93426e0 100644 --- a/modules/plugins/lsp/lspkind/config.nix +++ b/modules/plugins/lsp/lspkind/config.nix @@ -10,7 +10,7 @@ in { config = mkIf (cfg.enable && cfg.lspkind.enable) { vim.startPlugins = ["lspkind"]; - vim.luaConfigRC.lspkind = entryAnywhere '' + vim.pluginRC.lspkind = entryAnywhere '' local lspkind = require'lspkind' local lspkind_opts = { mode = '${cfg.lspkind.mode}' diff --git a/modules/plugins/lsp/lsplines/config.nix b/modules/plugins/lsp/lsplines/config.nix index 3436f64..bb07edc 100644 --- a/modules/plugins/lsp/lsplines/config.nix +++ b/modules/plugins/lsp/lsplines/config.nix @@ -10,7 +10,7 @@ in { config = mkIf (cfg.enable && cfg.lsplines.enable) { vim.startPlugins = ["lsp-lines"]; - vim.luaConfigRC.lsplines = entryAfter ["lspconfig"] '' + vim.pluginRC.lsplines = entryAfter ["lspconfig"] '' require("lsp_lines").setup() vim.diagnostic.config({ diff --git a/modules/plugins/lsp/lspsaga/config.nix b/modules/plugins/lsp/lspsaga/config.nix index ffacf12..71c9025 100644 --- a/modules/plugins/lsp/lspsaga/config.nix +++ b/modules/plugins/lsp/lspsaga/config.nix @@ -41,7 +41,7 @@ in { ]; }; - luaConfigRC.lspsaga = entryAnywhere '' + pluginRC.lspsaga = entryAnywhere '' require('lspsaga').init_lsp_saga({ ${optionalString config.vim.ui.borders.plugins.lspsaga.enable '' border_style = '${config.vim.ui.borders.plugins.lspsaga.style}', diff --git a/modules/plugins/lsp/null-ls/config.nix b/modules/plugins/lsp/null-ls/config.nix index e0d1694..8e776ed 100644 --- a/modules/plugins/lsp/null-ls/config.nix +++ b/modules/plugins/lsp/null-ls/config.nix @@ -22,7 +22,7 @@ in { # since it will hook into LSPs to receive information lsp.enable = true; - luaConfigRC = { + pluginRC = { # early setup for null-ls null_ls-setup = entryAnywhere '' local null_ls = require("null-ls") @@ -46,7 +46,7 @@ in { }; } { - vim.luaConfigRC = mapAttrs (_: v: (entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources; + vim.pluginRC = mapAttrs (_: v: (entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources; } ]); } diff --git a/modules/plugins/lsp/nvim-code-action-menu/config.nix b/modules/plugins/lsp/nvim-code-action-menu/config.nix index e55fb4a..9acc34d 100644 --- a/modules/plugins/lsp/nvim-code-action-menu/config.nix +++ b/modules/plugins/lsp/nvim-code-action-menu/config.nix @@ -23,7 +23,7 @@ in { "c" = "+CodeAction"; }; - luaConfigRC.code-action-menu = entryAnywhere '' + pluginRC.code-action-menu = entryAnywhere '' -- border configuration vim.g.code_action_menu_window_border = '${config.vim.ui.borders.plugins.code-action-menu.style}' diff --git a/modules/plugins/lsp/nvim-docs-view/config.nix b/modules/plugins/lsp/nvim-docs-view/config.nix index 45de200..5c7ad2b 100644 --- a/modules/plugins/lsp/nvim-docs-view/config.nix +++ b/modules/plugins/lsp/nvim-docs-view/config.nix @@ -19,7 +19,7 @@ in { lsp.enable = true; startPlugins = ["nvim-docs-view"]; - luaConfigRC.nvim-docs-view = entryAnywhere '' + pluginRC.nvim-docs-view = entryAnywhere '' require("docs-view").setup ${toLuaObject cfg.setupOpts} ''; diff --git a/modules/plugins/lsp/trouble/config.nix b/modules/plugins/lsp/trouble/config.nix index 72fc1ec..dd853e3 100644 --- a/modules/plugins/lsp/trouble/config.nix +++ b/modules/plugins/lsp/trouble/config.nix @@ -32,7 +32,7 @@ in { "lw" = "Workspace"; }; - luaConfigRC.trouble = entryAnywhere '' + pluginRC.trouble = entryAnywhere '' -- Enable trouble diagnostics viewer require("trouble").setup {} ''; diff --git a/modules/plugins/minimap/codewindow/config.nix b/modules/plugins/minimap/codewindow/config.nix index 11c38c9..a853514 100644 --- a/modules/plugins/minimap/codewindow/config.nix +++ b/modules/plugins/minimap/codewindow/config.nix @@ -31,7 +31,7 @@ in { "m" = "+Minimap"; }; - luaConfigRC.codewindow = entryAnywhere '' + pluginRC.codewindow = entryAnywhere '' local codewindow = require('codewindow') codewindow.setup({ exclude_filetypes = { 'NvimTree', 'orgagenda', 'Alpha'}, diff --git a/modules/plugins/notes/mind-nvim/config.nix b/modules/plugins/notes/mind-nvim/config.nix index 7f7ea9d..e0794b6 100644 --- a/modules/plugins/notes/mind-nvim/config.nix +++ b/modules/plugins/notes/mind-nvim/config.nix @@ -25,7 +25,7 @@ in { "o" = "+Notes"; }; - luaConfigRC.mind-nvim = entryAnywhere '' + pluginRC.mind-nvim = entryAnywhere '' require'mind'.setup() ''; }; diff --git a/modules/plugins/notes/obsidian/config.nix b/modules/plugins/notes/obsidian/config.nix index 5ba005e..835bc17 100644 --- a/modules/plugins/notes/obsidian/config.nix +++ b/modules/plugins/notes/obsidian/config.nix @@ -22,7 +22,7 @@ in { "o" = "+Notes"; }; - luaConfigRC.obsidian = entryAnywhere '' + pluginRC.obsidian = entryAnywhere '' require("obsidian").setup(${toLuaObject cfg.setupOpts}) ''; }; diff --git a/modules/plugins/notes/orgmode/config.nix b/modules/plugins/notes/orgmode/config.nix index d8c4906..36e0808 100644 --- a/modules/plugins/notes/orgmode/config.nix +++ b/modules/plugins/notes/orgmode/config.nix @@ -21,7 +21,7 @@ in { "o" = "+Notes"; }; - luaConfigRC.orgmode = entryAnywhere '' + pluginRC.orgmode = entryAnywhere '' -- Treesitter configuration require('nvim-treesitter.configs').setup { diff --git a/modules/plugins/notes/todo-comments/config.nix b/modules/plugins/notes/todo-comments/config.nix index cb7d628..645f677 100644 --- a/modules/plugins/notes/todo-comments/config.nix +++ b/modules/plugins/notes/todo-comments/config.nix @@ -24,7 +24,7 @@ in { (mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble" mappings.trouble.description)) ]; - luaConfigRC.todo-comments = '' + pluginRC.todo-comments = '' require('todo-comments').setup(${toLuaObject cfg.setupOpts}) ''; }; diff --git a/modules/plugins/projects/project-nvim/config.nix b/modules/plugins/projects/project-nvim/config.nix index 0f85968..b985a07 100644 --- a/modules/plugins/projects/project-nvim/config.nix +++ b/modules/plugins/projects/project-nvim/config.nix @@ -14,7 +14,7 @@ in { "project-nvim" ]; - vim.luaConfigRC.project-nvim = entryAnywhere '' + vim.pluginRC.project-nvim = entryAnywhere '' require('project_nvim').setup(${toLuaObject cfg.setupOpts}) ''; }; diff --git a/modules/plugins/rich-presence/neocord/config.nix b/modules/plugins/rich-presence/neocord/config.nix index a6dcbb5..8100b2b 100644 --- a/modules/plugins/rich-presence/neocord/config.nix +++ b/modules/plugins/rich-presence/neocord/config.nix @@ -12,7 +12,7 @@ in { config = mkIf cfg.enable { vim.startPlugins = ["neocord"]; - vim.luaConfigRC.neocord = entryAnywhere '' + vim.pluginRC.neocord = entryAnywhere '' -- Description of each option can be found in https://github.com/IogaMaster/neocord#lua require("neocord").setup(${toLuaObject cfg.setupOpts}) ''; diff --git a/modules/plugins/session/nvim-session-manager/config.nix b/modules/plugins/session/nvim-session-manager/config.nix index c86c13f..5d345c7 100644 --- a/modules/plugins/session/nvim-session-manager/config.nix +++ b/modules/plugins/session/nvim-session-manager/config.nix @@ -28,7 +28,7 @@ in { # TODO: load_current_dir_session ]; - luaConfigRC.nvim-session-manager = entryAnywhere '' + pluginRC.nvim-session-manager = entryAnywhere '' local Path = require('plenary.path') local sm = require('session_manager.config') require('session_manager').setup(${toLuaObject cfg.setupOpts}) diff --git a/modules/plugins/spellcheck/vim-dirtytalk/config.nix b/modules/plugins/spellcheck/vim-dirtytalk/config.nix index bef92e5..08426d1 100644 --- a/modules/plugins/spellcheck/vim-dirtytalk/config.nix +++ b/modules/plugins/spellcheck/vim-dirtytalk/config.nix @@ -14,7 +14,7 @@ in { # vim-dirtytalk doesn't have any setup # but we would like to append programming to spelllang # as soon as possible while the plugin is enabled - luaConfigRC.vim-dirtytalk = entryAfter ["basic"] '' + pluginRC.vim-dirtytalk = entryAfter ["basic"] '' -- append programming to spelllang vim.opt.spelllang:append("programming") ''; diff --git a/modules/plugins/statusline/lualine/config.nix b/modules/plugins/statusline/lualine/config.nix index 6c61367..d519199 100644 --- a/modules/plugins/statusline/lualine/config.nix +++ b/modules/plugins/statusline/lualine/config.nix @@ -35,7 +35,7 @@ in { vim = { startPlugins = ["lualine"]; - luaConfigRC.lualine = entryAnywhere '' + pluginRC.lualine = entryAnywhere '' local lualine = require('lualine') lualine.setup ${toLuaObject cfg.setupOpts} ''; diff --git a/modules/plugins/tabline/nvim-bufferline/config.nix b/modules/plugins/tabline/nvim-bufferline/config.nix index 59363f8..fe54efb 100644 --- a/modules/plugins/tabline/nvim-bufferline/config.nix +++ b/modules/plugins/tabline/nvim-bufferline/config.nix @@ -39,7 +39,7 @@ in { "bsi" = "BufferLineSortById"; }; - luaConfigRC.nvimBufferline = entryAnywhere '' + pluginRC.nvimBufferline = entryAnywhere '' require("bufferline").setup(${toLuaObject cfg.setupOpts}) ''; }; diff --git a/modules/plugins/terminal/toggleterm/config.nix b/modules/plugins/terminal/toggleterm/config.nix index 7f57358..07851e4 100644 --- a/modules/plugins/terminal/toggleterm/config.nix +++ b/modules/plugins/terminal/toggleterm/config.nix @@ -23,7 +23,7 @@ in { maps.normal = mkBinding cfg.mappings.open "execute v:count . \"ToggleTerm\"" "Toggle terminal"; - luaConfigRC.toggleterm = entryAnywhere '' + pluginRC.toggleterm = entryAnywhere '' require("toggleterm").setup(${toLuaObject cfg.setupOpts}) ''; }; @@ -35,7 +35,7 @@ in { vim.startPlugins = optionals (cfg.lazygit.package != null) [ cfg.lazygit.package ]; - vim.luaConfigRC.toggleterm-lazygit = entryAfter ["toggleterm"] '' + vim.pluginRC.toggleterm-lazygit = entryAfter ["toggleterm"] '' local terminal = require 'toggleterm.terminal' local lazygit = terminal.Terminal:new({ cmd = '${ diff --git a/modules/plugins/theme/supported_themes.nix b/modules/plugins/theme/supported-themes.nix similarity index 100% rename from modules/plugins/theme/supported_themes.nix rename to modules/plugins/theme/supported-themes.nix diff --git a/modules/plugins/theme/theme.nix b/modules/plugins/theme/theme.nix index a1157a0..bcc476b 100644 --- a/modules/plugins/theme/theme.nix +++ b/modules/plugins/theme/theme.nix @@ -7,10 +7,10 @@ inherit (lib.attrsets) attrNames; inherit (lib.types) bool lines enum; inherit (lib.modules) mkIf; - inherit (lib.nvim.dag) entryBefore; + inherit (lib.nvim.dag) entryAfter; cfg = config.vim.theme; - supported_themes = import ./supported_themes.nix { + supportedThemes = import ./supported-themes.nix { inherit lib config; }; in { @@ -21,12 +21,12 @@ in { }; name = mkOption { - type = enum (attrNames supported_themes); - description = "Supported themes can be found in `supported_themes.nix`"; + type = enum (attrNames supportedThemes); + description = "Supported themes can be found in `supportedThemes.nix`"; }; style = mkOption { - type = enum supported_themes.${cfg.name}.styles; + type = enum supportedThemes.${cfg.name}.styles; description = "Specific style for theme if it supports it"; }; @@ -45,11 +45,9 @@ in { config = mkIf cfg.enable { vim = { startPlugins = [cfg.name]; - configRC.theme = entryBefore ["luaScript"] '' - lua << EOF + luaConfigRC.theme = entryAfter ["basic"] '' ${cfg.extraConfig} - ${supported_themes.${cfg.name}.setup (with cfg; {inherit style transparent;})} - EOF + ${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent;}} ''; }; }; diff --git a/modules/plugins/treesitter/config.nix b/modules/plugins/treesitter/config.nix index 6bee0a2..618da88 100644 --- a/modules/plugins/treesitter/config.nix +++ b/modules/plugins/treesitter/config.nix @@ -37,18 +37,18 @@ in { }; # For some reason treesitter highlighting does not work on start if this is set before syntax on - configRC.treesitter-fold = mkIf cfg.fold (entryBefore ["basic"] '' - " This is required by treesitter-context to handle folds - set foldmethod=expr - set foldexpr=nvim_treesitter#foldexpr() + pluginRC.treesitter-fold = mkIf cfg.fold (entryBefore ["basic"] '' + -- This is required by treesitter-context to handle folds + vim.o.foldmethod = "expr" + vim.o.foldexpr = "nvim_treesitter#foldexpr()" - " This is optional, but is set rather as a sane default. - " If unset, opened files will be folded by automatically as - " the files are opened - set nofoldenable + -- This is optional, but is set rather as a sane default. + -- If unset, opened files will be folded by automatically as + -- the files are opened + vim.o.foldenable = false ''); - luaConfigRC.treesitter = entryAfter ["basic"] '' + pluginRC.treesitter = entryAfter ["basic"] '' require('nvim-treesitter.configs').setup { -- Disable imperative treesitter options that would attempt to fetch -- grammars into the read-only Nix store. To add additional grammars here diff --git a/modules/plugins/treesitter/ts-context/config.nix b/modules/plugins/treesitter/ts-context/config.nix index df5c151..416446f 100644 --- a/modules/plugins/treesitter/ts-context/config.nix +++ b/modules/plugins/treesitter/ts-context/config.nix @@ -16,7 +16,7 @@ in { # set up treesitter-context after Treesitter. The ordering # should not matter, but there is no harm in doing this - luaConfigRC.treesitter-context = entryAfter ["treesitter"] '' + pluginRC.treesitter-context = entryAfter ["treesitter"] '' require("treesitter-context").setup(${toLuaObject cfg.setupOpts}) ''; }; diff --git a/modules/plugins/ui/breadcrumbs/config.nix b/modules/plugins/ui/breadcrumbs/config.nix index 35c08ec..747a777 100644 --- a/modules/plugins/ui/breadcrumbs/config.nix +++ b/modules/plugins/ui/breadcrumbs/config.nix @@ -78,7 +78,7 @@ in { }; }; - vim.luaConfigRC.breadcrumbs = entryAfter ["lspconfig"] '' + vim.pluginRC.breadcrumbs = entryAfter ["lspconfig"] '' ${optionalString (cfg.source == "nvim-navic") '' local navic = require("nvim-navic") diff --git a/modules/plugins/ui/colorizer/config.nix b/modules/plugins/ui/colorizer/config.nix index 1ff45f6..ef5a5e6 100644 --- a/modules/plugins/ui/colorizer/config.nix +++ b/modules/plugins/ui/colorizer/config.nix @@ -14,7 +14,7 @@ in { "nvim-colorizer-lua" ]; - vim.luaConfigRC.colorizer = entryAnywhere '' + vim.pluginRC.colorizer = entryAnywhere '' require('colorizer').setup(${toLuaObject cfg.setupOpts}) ''; }; diff --git a/modules/plugins/ui/illuminate/config.nix b/modules/plugins/ui/illuminate/config.nix index 6d08c76..ffba85f 100644 --- a/modules/plugins/ui/illuminate/config.nix +++ b/modules/plugins/ui/illuminate/config.nix @@ -11,7 +11,7 @@ in { config = mkIf cfg.enable { vim.startPlugins = ["vim-illuminate"]; - vim.luaConfigRC.vim-illuminate = entryAnywhere '' + vim.pluginRC.vim-illuminate = entryAnywhere '' require('illuminate').configure({ filetypes_denylist = { 'dirvish', diff --git a/modules/plugins/ui/modes/config.nix b/modules/plugins/ui/modes/config.nix index 9f49dc4..2ea9602 100644 --- a/modules/plugins/ui/modes/config.nix +++ b/modules/plugins/ui/modes/config.nix @@ -14,7 +14,7 @@ in { "modes-nvim" ]; - vim.luaConfigRC.modes-nvim = entryAnywhere '' + vim.pluginRC.modes-nvim = entryAnywhere '' require('modes').setup(${toLuaObject cfg.setupOpts}) ''; }; diff --git a/modules/plugins/ui/noice/config.nix b/modules/plugins/ui/noice/config.nix index d3ebe01..fe82f58 100644 --- a/modules/plugins/ui/noice/config.nix +++ b/modules/plugins/ui/noice/config.nix @@ -23,7 +23,7 @@ in { treesitter.grammars = optionals tscfg.addDefaultGrammars defaultGrammars; - luaConfigRC.noice-nvim = entryAnywhere '' + pluginRC.noice-nvim = entryAnywhere '' require("noice").setup(${toLuaObject cfg.setupOpts}) ''; }; diff --git a/modules/plugins/ui/notifications/nvim-notify/config.nix b/modules/plugins/ui/notifications/nvim-notify/config.nix index 7a11b6b..0ee2301 100644 --- a/modules/plugins/ui/notifications/nvim-notify/config.nix +++ b/modules/plugins/ui/notifications/nvim-notify/config.nix @@ -13,7 +13,7 @@ in { vim = { startPlugins = ["nvim-notify"]; - luaConfigRC.nvim-notify = entryAnywhere '' + pluginRC.nvim-notify = entryAnywhere '' require('notify').setup(${toLuaObject cfg.setupOpts}) -- required to fix offset_encoding errors diff --git a/modules/plugins/ui/smartcolumn/config.nix b/modules/plugins/ui/smartcolumn/config.nix index 9edbdbb..f38edfd 100644 --- a/modules/plugins/ui/smartcolumn/config.nix +++ b/modules/plugins/ui/smartcolumn/config.nix @@ -13,7 +13,7 @@ in { vim = { startPlugins = ["smartcolumn"]; - luaConfigRC.smartcolumn = entryAnywhere '' + pluginRC.smartcolumn = entryAnywhere '' require("smartcolumn").setup(${toLuaObject cfg.setupOpts}) ''; }; diff --git a/modules/plugins/utility/binds/cheatsheet/config.nix b/modules/plugins/utility/binds/cheatsheet/config.nix index 05b7887..2848ddc 100644 --- a/modules/plugins/utility/binds/cheatsheet/config.nix +++ b/modules/plugins/utility/binds/cheatsheet/config.nix @@ -11,7 +11,7 @@ in { config = mkIf cfg.enable { vim.startPlugins = ["cheatsheet-nvim"]; - vim.luaConfigRC.cheaetsheet-nvim = entryAnywhere '' + vim.pluginRC.cheaetsheet-nvim = entryAnywhere '' require('cheatsheet').setup({}) ''; }; diff --git a/modules/plugins/utility/binds/which-key/config.nix b/modules/plugins/utility/binds/which-key/config.nix index e6aa2d9..03c85b4 100644 --- a/modules/plugins/utility/binds/which-key/config.nix +++ b/modules/plugins/utility/binds/which-key/config.nix @@ -13,7 +13,7 @@ in { config = mkIf cfg.enable { vim.startPlugins = ["which-key"]; - vim.luaConfigRC.whichkey = entryAnywhere '' + vim.pluginRC.whichkey = entryAnywhere '' local wk = require("which-key") wk.setup ({ key_labels = { diff --git a/modules/plugins/utility/ccc/config.nix b/modules/plugins/utility/ccc/config.nix index b8c4315..ab2d178 100644 --- a/modules/plugins/utility/ccc/config.nix +++ b/modules/plugins/utility/ccc/config.nix @@ -13,7 +13,7 @@ in { "ccc" ]; - vim.luaConfigRC.ccc = entryAnywhere '' + vim.pluginRC.ccc = entryAnywhere '' local ccc = require("ccc") ccc.setup { highlighter = { diff --git a/modules/plugins/utility/gestures/gesture-nvim/config.nix b/modules/plugins/utility/gestures/gesture-nvim/config.nix index 62a89ce..2996f7d 100644 --- a/modules/plugins/utility/gestures/gesture-nvim/config.nix +++ b/modules/plugins/utility/gestures/gesture-nvim/config.nix @@ -25,7 +25,7 @@ in { }) ]; - vim.luaConfigRC.gesture-nvim = entryAnywhere '' + vim.pluginRC.gesture-nvim = entryAnywhere '' vim.opt.mouse = "a" local gesture = require("gesture") diff --git a/modules/plugins/utility/icon-picker/config.nix b/modules/plugins/utility/icon-picker/config.nix index aa61d04..405f691 100644 --- a/modules/plugins/utility/icon-picker/config.nix +++ b/modules/plugins/utility/icon-picker/config.nix @@ -14,7 +14,7 @@ in { "dressing-nvim" ]; - vim.luaConfigRC.icon-picker = entryAnywhere '' + vim.pluginRC.icon-picker = entryAnywhere '' require("icon-picker").setup({ disable_legacy_commands = true }) diff --git a/modules/plugins/utility/images/image-nvim/config.nix b/modules/plugins/utility/images/image-nvim/config.nix index 52666d3..7ab4ba7 100644 --- a/modules/plugins/utility/images/image-nvim/config.nix +++ b/modules/plugins/utility/images/image-nvim/config.nix @@ -19,7 +19,7 @@ in { "magick" ]; - luaConfigRC.image-nvim = entryAnywhere '' + pluginRC.image-nvim = entryAnywhere '' require("image").setup( ${toLuaObject cfg.setupOpts} ) diff --git a/modules/plugins/utility/motion/hop/config.nix b/modules/plugins/utility/motion/hop/config.nix index 94c4a8c..505b9eb 100644 --- a/modules/plugins/utility/motion/hop/config.nix +++ b/modules/plugins/utility/motion/hop/config.nix @@ -19,7 +19,7 @@ in { vim.maps.normal = mkSetBinding mappings.hop " HopPattern"; - vim.luaConfigRC.hop-nvim = entryAnywhere '' + vim.pluginRC.hop-nvim = entryAnywhere '' require('hop').setup() ''; }; diff --git a/modules/plugins/utility/motion/leap/config.nix b/modules/plugins/utility/motion/leap/config.nix index f9a9655..9ede98f 100644 --- a/modules/plugins/utility/motion/leap/config.nix +++ b/modules/plugins/utility/motion/leap/config.nix @@ -37,7 +37,7 @@ in { (mkBinding cfg.mappings.leapFromWindow "(leap-from-window)" "Leap from window") ]; - vim.luaConfigRC.leap-nvim = entryAnywhere '' + vim.pluginRC.leap-nvim = entryAnywhere '' require('leap').opts = { max_phase_one_targets = nil, highlight_unlabeled_phase_one_targets = false, diff --git a/modules/plugins/utility/preview/glow/config.nix b/modules/plugins/utility/preview/glow/config.nix index 04e8aa0..4529a53 100644 --- a/modules/plugins/utility/preview/glow/config.nix +++ b/modules/plugins/utility/preview/glow/config.nix @@ -25,7 +25,7 @@ in { "pm" = "+Preview Markdown"; }; - vim.luaConfigRC.glow = entryAnywhere '' + vim.pluginRC.glow = entryAnywhere '' require('glow').setup({ glow_path = "${pkgs.glow}/bin/glow" }); diff --git a/modules/plugins/utility/preview/markdown-preview/config.nix b/modules/plugins/utility/preview/markdown-preview/config.nix index 750cf7e..635a8a4 100644 --- a/modules/plugins/utility/preview/markdown-preview/config.nix +++ b/modules/plugins/utility/preview/markdown-preview/config.nix @@ -4,25 +4,23 @@ lib, ... }: let - inherit (lib.strings) optionalString stringLength concatMapStringsSep; + inherit (lib.strings) stringLength concatMapStringsSep; inherit (lib.modules) mkIf; - inherit (lib.nvim.vim) mkVimBool; - inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.utility.preview.markdownPreview; in { config = mkIf cfg.enable { vim.startPlugins = [pkgs.vimPlugins.markdown-preview-nvim]; - vim.configRC.markdown-preview = entryAnywhere '' - let g:mkdp_auto_start = ${mkVimBool cfg.autoStart} - let g:mkdp_auto_close = ${mkVimBool cfg.autoClose} - let g:mkdp_refresh_slow = ${mkVimBool cfg.lazyRefresh} - let g:mkdp_filetypes = [${concatMapStringsSep ", " (x: "'" + x + "'") cfg.filetypes}] - let g:mkdp_command_for_global = ${mkVimBool cfg.alwaysAllowPreview} - let g:mkdp_open_to_the_world = ${mkVimBool cfg.broadcastServer} - ${optionalString (stringLength cfg.customIP > 0) "let g:mkdp_open_ip = '${cfg.customIP}'"} - ${optionalString (stringLength cfg.customPort > 0) "let g:mkdp_port = '${cfg.customPort}'"} - ''; + vim.globals = { + mkdp_auto_start = cfg.autoStart; + mkdp_auto_close = cfg.autoClose; + mkdp_refresh_slow = cfg.lazyRefresh; + 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; + }; }; } diff --git a/modules/plugins/utility/surround/config.nix b/modules/plugins/utility/surround/config.nix index e392d9a..824b8c9 100644 --- a/modules/plugins/utility/surround/config.nix +++ b/modules/plugins/utility/surround/config.nix @@ -18,7 +18,7 @@ in { "nvim-surround" ]; - luaConfigRC.surround = entryAnywhere '' + pluginRC.surround = entryAnywhere '' require('nvim-surround').setup() ''; diff --git a/modules/plugins/utility/telescope/config.nix b/modules/plugins/utility/telescope/config.nix index f59f816..2ec7d3d 100644 --- a/modules/plugins/utility/telescope/config.nix +++ b/modules/plugins/utility/telescope/config.nix @@ -65,7 +65,7 @@ in { "fvc" = "Commits"; }; - vim.luaConfigRC.telescope = entryAnywhere '' + vim.pluginRC.telescope = entryAnywhere '' local telescope = require('telescope') telescope.setup(${toLuaObject cfg.setupOpts}) diff --git a/modules/plugins/utility/wakatime/config.nix b/modules/plugins/utility/wakatime/config.nix index 1185db5..a1892e7 100644 --- a/modules/plugins/utility/wakatime/config.nix +++ b/modules/plugins/utility/wakatime/config.nix @@ -5,21 +5,14 @@ ... }: let inherit (lib.modules) mkIf; - inherit (lib.nvim.dag) entryAnywhere; cfg = config.vim.utility.vim-wakatime; in { config = mkIf cfg.enable { - vim.startPlugins = [ - pkgs.vimPlugins.vim-wakatime - ]; + vim.startPlugins = [pkgs.vimPlugins.vim-wakatime]; - vim.configRC.vim-wakatime = entryAnywhere '' - ${ - if cfg.cli-package == null - then "" - else ''let g:wakatime_CLIPath = "${cfg.cli-package}"'' - } + vim.pluginRC.vim-wakatime = mkIf (cfg.cli-package != null) '' + vim.g.wakatime_CLIPath = "${cfg.cli-package}" ''; }; } diff --git a/modules/plugins/visuals/config.nix b/modules/plugins/visuals/config.nix index 9327cee..1dfc661 100644 --- a/modules/plugins/visuals/config.nix +++ b/modules/plugins/visuals/config.nix @@ -14,14 +14,14 @@ in { config = mkIf cfg.enable (mkMerge [ (mkIf cfg.indentBlankline.enable { vim.startPlugins = ["indent-blankline"]; - vim.luaConfigRC.indent-blankline = entryAnywhere '' + vim.pluginRC.indent-blankline = entryAnywhere '' require("ibl").setup(${toLuaObject cfg.indentBlankline.setupOpts}) ''; }) (mkIf cfg.cursorline.enable { vim.startPlugins = ["nvim-cursorline"]; - vim.luaConfigRC.cursorline = entryAnywhere '' + vim.pluginRC.cursorline = entryAnywhere '' require('nvim-cursorline').setup { cursorline = { timeout = ${toString cfg.cursorline.lineTimeout}, @@ -37,7 +37,7 @@ in { (mkIf cfg.scrollBar.enable { vim.startPlugins = ["scrollbar-nvim"]; - vim.luaConfigRC.scrollBar = entryAnywhere '' + vim.pluginRC.scrollBar = entryAnywhere '' require('scrollbar').setup{ excluded_filetypes = { 'prompt', @@ -56,7 +56,7 @@ in { (mkIf cfg.smoothScroll.enable { vim.startPlugins = ["cinnamon-nvim"]; - vim.luaConfigRC.smoothScroll = entryAnywhere '' + vim.pluginRC.smoothScroll = entryAnywhere '' require('cinnamon').setup() ''; }) @@ -66,7 +66,7 @@ in { vim.maps.normal = mkBinding cfg.cellularAutomaton.mappings.makeItRain "CellularAutomaton make_it_rain" "Make it rain"; - vim.luaConfigRC.cellularAUtomaton = entryAnywhere '' + vim.pluginRC.cellularAUtomaton = entryAnywhere '' local config = { fps = 50, name = 'slide', @@ -94,7 +94,7 @@ in { (mkIf cfg.highlight-undo.enable { vim.startPlugins = ["highlight-undo"]; - vim.luaConfigRC.highlight-undo = entryAnywhere '' + vim.pluginRC.highlight-undo = entryAnywhere '' require('highlight-undo').setup({ duration = ${toString cfg.highlight-undo.duration}, highlight_for_count = ${boolToString cfg.highlight-undo.highlightForCount}, diff --git a/modules/plugins/visuals/fidget/config.nix b/modules/plugins/visuals/fidget/config.nix index cde2f63..3ae3b6b 100644 --- a/modules/plugins/visuals/fidget/config.nix +++ b/modules/plugins/visuals/fidget/config.nix @@ -12,7 +12,7 @@ in { config = mkIf cfg.enable { vim.startPlugins = ["fidget-nvim"]; - vim.luaConfigRC.fidget-nvim = entryAnywhere '' + vim.pluginRC.fidget-nvim = entryAnywhere '' require'fidget'.setup(${toLuaObject cfg.setupOpts}) ''; }; diff --git a/modules/wrapper/rc/config.nix b/modules/wrapper/rc/config.nix index c35b3e7..be299f3 100644 --- a/modules/wrapper/rc/config.nix +++ b/modules/wrapper/rc/config.nix @@ -3,17 +3,16 @@ lib, ... }: let - inherit (builtins) map mapAttrs toJSON filter; + inherit (builtins) map mapAttrs filter; inherit (lib.options) mkOption; inherit (lib.attrsets) filterAttrs getAttrs attrValues attrNames; - inherit (lib.strings) isString concatLines concatMapStringsSep; + inherit (lib.strings) concatLines concatMapStringsSep; inherit (lib.misc) mapAttrsFlatten; inherit (lib.trivial) showWarnings; inherit (lib.types) str nullOr; inherit (lib.generators) mkLuaInline; - inherit (lib.nvim.dag) entryAnywhere entryAfter topoSort mkLuarcSection mkVimrcSection; - inherit (lib.nvim.lua) toLuaObject wrapLuaConfig; - inherit (lib.nvim.vim) valToVim; + inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.config) mkBool; cfg = config.vim; @@ -82,11 +81,23 @@ maps); in { config = let - filterNonNull = mappings: filterAttrs (_name: value: value != null) mappings; + filterNonNull = attrs: filterAttrs (_: value: value != null) attrs; globalsScript = - mapAttrsFlatten (name: value: "let g:${name}=${valToVim value}") + mapAttrsFlatten (name: value: "vim.g.${name} = ${toLuaObject value}") (filterNonNull cfg.globals); + extraPluginConfigs = resolveDag { + name = "extra plugin configs"; + dag = mapAttrs (_: value: entryAfter value.after value.setup) cfg.extraPlugins; + mapResult = result: concatLines (map mkLuarcSection result); + }; + + pluginConfigs = resolveDag { + name = "plugin configs"; + dag = cfg.pluginRC; + mapResult = result: concatLines (map mkLuarcSection result); + }; + toLuaBindings = mode: maps: map (value: '' vim.keymap.set(${toLuaObject mode}, ${toLuaObject value.key}, ${toLuaObject value.action}, ${toLuaObject value.config}) @@ -105,96 +116,31 @@ in { omap = toLuaBindings "o" config.vim.maps.operator; icmap = toLuaBindings "ic" config.vim.maps.insertCommand; - resolveDag = { - name, - dag, - mapResult, - }: let - # When the value is a string, default it to dag.entryAnywhere - finalDag = mapAttrs (_: value: - if isString value - then entryAnywhere value - else value) - dag; - sortedDag = topoSort finalDag; - result = - if sortedDag ? result - then mapResult sortedDag.result - else abort ("Dependency cycle in ${name}: " + toJSON sortedDag); - in - result; + maps = [ + nmap + imap + vmap + xmap + smap + cmap + omap + tmap + lmap + icmap + allmap + ]; + mappings = concatLines (map concatLines maps); in { vim = { - configRC = { + luaConfigRC = { globalsScript = entryAnywhere (concatLines 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"] (concatLines callLuaFiles); - - # wrap the lua config in a lua block - # using the wrapLuaConfic function from the lib - luaScript = let - mapResult = result: (wrapLuaConfig { - luaBefore = "${cfg.luaConfigPre}"; - luaConfig = concatLines (map mkLuarcSection result); - luaAfter = "${cfg.luaConfigPost}"; - }); - - luaConfig = resolveDag { - name = "lua config script"; - dag = cfg.luaConfigRC; - inherit mapResult; - }; - in - entryAnywhere luaConfig; - - extraPluginConfigs = let - mapResult = result: (wrapLuaConfig { - luaConfig = concatLines (map mkLuarcSection result); - }); - - extraPluginsDag = mapAttrs (_: { - after, - setup, - ... - }: - entryAfter after setup) - cfg.extraPlugins; - - pluginConfig = resolveDag { - name = "extra plugins config"; - dag = extraPluginsDag; - inherit mapResult; - }; - in - entryAfter ["luaScript"] pluginConfig; - - # This is probably not the right way to set the config. I'm not sure how it should look like. - mappings = let - maps = [ - nmap - imap - vmap - xmap - smap - cmap - omap - tmap - lmap - icmap - allmap - ]; - mapConfig = wrapLuaConfig {luaConfig = concatLines (map concatLines maps);}; - in - entryAfter ["globalsScript"] mapConfig; + # basic, theme + pluginConfigs = entryAfter ["theme"] pluginConfigs; + extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs; + mappings = entryAfter ["extraPluginConfigs"] mappings; }; - builtConfigRC = let + builtLuaConfigRC = let # Catch assertions and warnings # and throw for each failed assertion. If no assertions are found, show warnings. failedAssertions = map (x: x.message) (filter (x: !x.assertion) config.assertions); @@ -203,14 +149,18 @@ in { then throw "\nFailed assertions:\n${concatMapStringsSep "\n" (x: "- ${x}") failedAssertions}" else showWarnings config.warnings; - mapResult = result: concatMapStringsSep "\n" mkVimrcSection result; - vimConfig = resolveDag { - name = "vim config script"; - dag = cfg.configRC; - inherit mapResult; + luaConfig = resolveDag { + name = "lua config script"; + dag = cfg.luaConfigRC; + mapResult = result: + concatLines [ + cfg.luaConfigPre + (concatMapStringsSep "\n" mkLuarcSection result) + cfg.luaConfigPost + ]; }; in - baseSystemAssertWarn vimConfig; + baseSystemAssertWarn luaConfig; }; }; } diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index bc14241..0594a48 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -3,13 +3,25 @@ lib, ... }: let + inherit (lib.modules) mkRemovedOptionModule; inherit (lib.options) mkOption mkEnableOption literalMD literalExpression; inherit (lib.strings) optionalString; - inherit (lib.types) str oneOf attrs lines listOf either path bool; + inherit (lib.types) str attrs lines listOf either path bool; inherit (lib.nvim.types) dagOf; inherit (lib.nvim.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 '' the experimental Lua module loader to speed up the start up process @@ -120,35 +132,20 @@ in { description = '' An attribute set containing global variable values for storing vim variables as early as possible. If - populated, this soption will set vim variables in the - built configRC as the first item. + populated, this option will set vim variables in the + built luaConfigRC as the first item. - E.g. {foo = "bar"} will set `g:foo` to "bar" where + E.g. {foo = "bar"} will set `vim.g.foo` to "bar" where the type of `bar` in the resulting vimscript will be infered from the type of the value in the `{name = value}` pair. ''; }; - configRC = mkOption { - type = oneOf [(dagOf lines) str]; + pluginRC = mkOption { + type = either (dagOf lines) str; default = {}; - description = '' - Contents of vimrc, either as a string or a DAG. - - If this option is passed as a DAG, it will be resolved - according to the DAG resolution rules (e.g. entryBefore - or entryAfter) as per the **nvf** extended library. - ''; - - example = literalMD '' - ```vim - " Set the tab size to 4 spaces - set tabstop=4 - set shiftwidth=4 - set expandtab - ``` - ''; + description = "The DAG used to configure plugins. If a string is passed, entryAnywhere is automatically applied."; }; luaConfigPre = mkOption { @@ -211,7 +208,7 @@ in { }; luaConfigRC = mkOption { - type = oneOf [(dagOf lines) str]; + type = either (dagOf lines) str; default = {}; description = '' Lua configuration, either as a string or a DAG. @@ -245,10 +242,10 @@ in { ''; }; - builtConfigRC = mkOption { + builtLuaConfigRC = mkOption { internal = true; type = lines; - description = "The built config for neovim after resolving the DAG"; + description = "The built lua config for neovim after resolving the DAG"; }; }; }