Merge pull request #474 from diniamo/run-nvim

runner/run-nvim: init
This commit is contained in:
raf 2024-11-30 12:31:24 +03:00 committed by GitHub
commit 29b7c415a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 119 additions and 15 deletions

View file

@ -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

View file

@ -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",

View file

@ -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";

View file

@ -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).
'')
];
}

View file

@ -31,6 +31,7 @@
"notes"
"projects"
"rich-presence"
"runner"
"session"
"snippets"
# "spellcheck" # FIXME: see neovim/init/spellcheck.nix

View file

@ -14,12 +14,6 @@
cfg = config.vim;
in {
options.vim = {
leaderKey = mkOption {
type = str;
default = " ";
description = "The leader key used for `<leader>` 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

View file

@ -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", "<leader>rr", ":RustLsp runnables<CR>", opts)
vim.keymap.set("n", "<leader>rp", ":RustLsp parentModule<CR>", opts)
vim.keymap.set("n", "<leader>rm", ":RustLsp expandMacro<CR>", opts)
vim.keymap.set("n", "<leader>rc", ":RustLsp openCargo", opts)
vim.keymap.set("n", "<leader>rg", ":RustLsp crateGraph x11", opts)
vim.keymap.set("n", "<localleader>rr", ":RustLsp runnables<CR>", opts)
vim.keymap.set("n", "<localleader>rp", ":RustLsp parentModule<CR>", opts)
vim.keymap.set("n", "<localleader>rm", ":RustLsp expandMacro<CR>", opts)
vim.keymap.set("n", "<localleader>rc", ":RustLsp openCargo", opts)
vim.keymap.set("n", "<localleader>rg", ":RustLsp crateGraph x11", opts)
${optionalString cfg.dap.enable ''
vim.keymap.set("n", "<leader>rd", ":RustLsp debuggables<cr>", opts)
vim.keymap.set("n", "<localleader>rd", ":RustLsp debuggables<cr>", opts)
vim.keymap.set(
"n", "${config.vim.debugger.nvim-dap.mappings.continue}",
function()

View file

@ -0,0 +1,5 @@
{
imports = [
./run-nvim
];
}

View file

@ -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 "<cmd>Run<CR>")
(mkSetLznBinding "n" mappings.runOverride "<cmd>Run!<CR>")
(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."<leader>r" = mkDefault "+Run";
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./run-nvim.nix
./config.nix
];
}

View file

@ -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" "<leader>ri";
runOverride = mkMappingOption "Run and override" "<leader>ro";
runCommand = mkMappingOption "Run prompt" "<leader>rc";
};
};
};
}

View file

@ -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