diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 28e7c79c..8dcfc5b0 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,6 +211,9 @@ 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 5e201d89..1721d8a6 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 1123432e..e52f9416 100644 --- a/flake.nix +++ b/flake.nix @@ -238,6 +238,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/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/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/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/plugins/languages/rust.nix b/modules/plugins/languages/rust.nix index f0262997..ec1887cb 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() 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"; + }; + }; + }; +} diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index dd3a36e6..508a8bf8 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