From 2aeec7cb695380f570921463c1e5d5ca243d14e1 Mon Sep 17 00:00:00 2001 From: diniamo Date: Thu, 21 Nov 2024 22:03:28 +0100 Subject: [PATCH 1/4] runner/run-nvim: init --- docs/release-notes/rl-0.7.md | 2 ++ flake.lock | 17 +++++++++ flake.nix | 6 ++++ modules/modules.nix | 1 + modules/plugins/runner/default.nix | 5 +++ modules/plugins/runner/run-nvim/config.nix | 38 ++++++++++++++++++++ modules/plugins/runner/run-nvim/default.nix | 6 ++++ modules/plugins/runner/run-nvim/run-nvim.nix | 18 ++++++++++ 8 files changed, 93 insertions(+) create mode 100644 modules/plugins/runner/default.nix create mode 100644 modules/plugins/runner/run-nvim/config.nix create mode 100644 modules/plugins/runner/run-nvim/default.nix create mode 100644 modules/plugins/runner/run-nvim/run-nvim.nix diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 876f1ab2..3f24ae8f 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -201,6 +201,8 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to is bundled with nvf, if you enable the module, since there is no way to provide only the LSP server. +- Add [`run.nvim`](https://github.com/diniamo/run.nvim) support for running code using cached commands. + [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/flake.lock b/flake.lock index d9e6b477..7b4c63b0 100644 --- a/flake.lock +++ b/flake.lock @@ -1710,6 +1710,22 @@ "type": "github" } }, + "plugin-run-nvim": { + "flake": false, + "locked": { + "lastModified": 1732918526, + "narHash": "sha256-kiszNmZZDXG8tAPMQKuGJDCkqCMzsWT7BkCvkVsH2lA=", + "owner": "diniamo", + "repo": "run.nvim", + "rev": "d867466e01b8fa4e54a589b9ef446cf43fb966de", + "type": "github" + }, + "original": { + "owner": "diniamo", + "repo": "run.nvim", + "type": "github" + } + }, "plugin-rustaceanvim": { "flake": false, "locked": { @@ -2123,6 +2139,7 @@ "plugin-registers": "plugin-registers", "plugin-rose-pine": "plugin-rose-pine", "plugin-rtp-nvim": "plugin-rtp-nvim", + "plugin-run-nvim": "plugin-run-nvim", "plugin-rustaceanvim": "plugin-rustaceanvim", "plugin-smartcolumn": "plugin-smartcolumn", "plugin-sqls-nvim": "plugin-sqls-nvim", diff --git a/flake.nix b/flake.nix index 4e417e7f..319b8f56 100644 --- a/flake.nix +++ b/flake.nix @@ -242,6 +242,12 @@ flake = false; }; + # Runners + plugin-run-nvim = { + url = "github:diniamo/run.nvim"; + flake = false; + }; + # Debuggers plugin-nvim-dap = { url = "github:mfussenegger/nvim-dap"; diff --git a/modules/modules.nix b/modules/modules.nix index 784c413e..bc441e96 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -31,6 +31,7 @@ "notes" "projects" "rich-presence" + "runner" "session" "snippets" # "spellcheck" # FIXME: see neovim/init/spellcheck.nix diff --git a/modules/plugins/runner/default.nix b/modules/plugins/runner/default.nix new file mode 100644 index 00000000..d37fb5f4 --- /dev/null +++ b/modules/plugins/runner/default.nix @@ -0,0 +1,5 @@ +{ + imports = [ + ./run-nvim + ]; +} diff --git a/modules/plugins/runner/run-nvim/config.nix b/modules/plugins/runner/run-nvim/config.nix new file mode 100644 index 00000000..70cd5c9f --- /dev/null +++ b/modules/plugins/runner/run-nvim/config.nix @@ -0,0 +1,38 @@ +{ + lib, + config, + options, + ... +}: let + inherit (lib.modules) mkIf mkDefault; + inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLznBinding mkSetLuaLznBinding; + + cfg = config.vim.runner.run-nvim; + mappingDefinitions = options.vim.runner.run-nvim.mappings; + mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; +in { + config = mkIf cfg.enable { + vim = { + lazy.plugins.run-nvim = { + package = "run-nvim"; + setupModule = "run"; + inherit (cfg) setupOpts; + + cmd = "Run"; + + keys = [ + (mkSetLznBinding "n" mappings.run "Run") + (mkSetLznBinding "n" mappings.runOverride "Run!") + (mkSetLuaLznBinding "n" mappings.runCommand '' + function() + local input = vim.fn.input("Run command: ") + if input ~= "" then require("run").run(input, false) end + end + '') + ]; + }; + + binds.whichKey.register."r" = mkDefault "+Run"; + }; + }; +} diff --git a/modules/plugins/runner/run-nvim/default.nix b/modules/plugins/runner/run-nvim/default.nix new file mode 100644 index 00000000..5062c6e7 --- /dev/null +++ b/modules/plugins/runner/run-nvim/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./run-nvim.nix + ./config.nix + ]; +} diff --git a/modules/plugins/runner/run-nvim/run-nvim.nix b/modules/plugins/runner/run-nvim/run-nvim.nix new file mode 100644 index 00000000..dd24e6c3 --- /dev/null +++ b/modules/plugins/runner/run-nvim/run-nvim.nix @@ -0,0 +1,18 @@ +{lib, ...}: let + inherit (lib.options) mkEnableOption; + inherit (lib.nvim.types) mkPluginSetupOption; + inherit (lib.nvim.binds) mkMappingOption; +in { + options = { + vim.runner.run-nvim = { + enable = mkEnableOption "run.nvim"; + setupOpts = mkPluginSetupOption "run.nvim" {}; + + mappings = { + run = mkMappingOption "Run cached" "ri"; + runOverride = mkMappingOption "Run and override" "ro"; + runCommand = mkMappingOption "Run prompt" "rc"; + }; + }; + }; +} From 48a74623d82e5ba3c42420a9faf13853778a8a63 Mon Sep 17 00:00:00 2001 From: diniamo Date: Sun, 24 Nov 2024 20:03:12 +0100 Subject: [PATCH 2/4] languages/rust: use local leader for binds --- modules/plugins/languages/rust.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/plugins/languages/rust.nix b/modules/plugins/languages/rust.nix index 9a388896..61cfd617 100644 --- a/modules/plugins/languages/rust.nix +++ b/modules/plugins/languages/rust.nix @@ -145,13 +145,13 @@ in { 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) + 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", "rd", ":RustLsp debuggables", opts) vim.keymap.set( "n", "${config.vim.debugger.nvim-dap.mappings.continue}", function() From 71de14149dae25904362cc527d5f43ca1756319f Mon Sep 17 00:00:00 2001 From: diniamo Date: Sat, 30 Nov 2024 10:18:53 +0100 Subject: [PATCH 3/4] init/basic: deprecate `vim.leaderKey` in favour of `vim.globals.mapleader` and `vim.globals.maplocalleader` tmp Co-authored-by: raf --- modules/extra/deprecations.nix | 5 +++++ modules/neovim/init/basic.nix | 8 -------- modules/wrapper/rc/options.nix | 5 ++++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/extra/deprecations.nix b/modules/extra/deprecations.nix index a4ac56a3..45dba827 100644 --- a/modules/extra/deprecations.nix +++ b/modules/extra/deprecations.nix @@ -59,5 +59,10 @@ in { With Trouble having so many different modes, and breaking changes upstream, it no longer makes sense, nor works, to toggle only Trouble. '') + # 2024-11-30 + (mkRemovedOptionModule ["vim" "leaderKey"] '' + This has been deprecated in favor of using the more generic `vim.globals` + (you can use `vim.globals.mapleader` to change this instead). + '') ]; } diff --git a/modules/neovim/init/basic.nix b/modules/neovim/init/basic.nix index 2114dcb8..c7d98e02 100644 --- a/modules/neovim/init/basic.nix +++ b/modules/neovim/init/basic.nix @@ -14,12 +14,6 @@ cfg = config.vim; in { options.vim = { - leaderKey = mkOption { - type = str; - default = " "; - description = "The leader key used for `` mappings"; - }; - colourTerm = mkOption { type = bool; default = true; @@ -197,8 +191,6 @@ in { 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.undoFile.enable '' vim.o.undofile = true diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index 1159b9fe..c76c000b 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -101,7 +101,10 @@ in { globals = mkOption { type = attrs; - default = {}; + default = { + mapleader = " "; + maplocalleader = ","; + }; example = {"some_variable" = 42;}; description = '' An attribute set containing global variable values From 8bc230bf0071879c0df37a075c2c907a5b15685d Mon Sep 17 00:00:00 2001 From: diniamo Date: Sat, 30 Nov 2024 10:19:31 +0100 Subject: [PATCH 4/4] docs(0.7): add breaking changes entry --- docs/release-notes/rl-0.7.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 3f24ae8f..00ebcea5 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -81,6 +81,16 @@ favor of nixfmt (more information can be found To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to `nixfmt`. +### leader changes {#sec-leader-changes} + +This has been deprecated in favor of using the more generic `vim.globals` (you +can use `vim.globals.mapleader` to change this instead). + +Rust specific keymaps now use `maplocalleader` instead of `localleader` by +default. This is to avoid conflicts with other modules. You can change +`maplocalleader` with `vim.globals.maplocalleader`, but it's recommended to set +it to something other than `mapleader` to avoid conflicts. + ## Changelog {#sec-release-0.7-changelog} [ItsSorae](https://github.com/ItsSorae): @@ -201,7 +211,8 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to is bundled with nvf, if you enable the module, since there is no way to provide only the LSP server. -- Add [`run.nvim`](https://github.com/diniamo/run.nvim) support for running code using cached commands. +- Add [`run.nvim`](https://github.com/diniamo/run.nvim) support for running code + using cached commands. [Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd()