runner/run-nvim: init

This commit is contained in:
diniamo 2024-11-21 22:03:28 +01:00
parent b6785f8218
commit d65555b7f3
8 changed files with 93 additions and 0 deletions

View file

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

View file

@ -1710,6 +1710,22 @@
"type": "github"
}
},
"plugin-run-nvim": {
"flake": false,
"locked": {
"lastModified": 1732273891,
"narHash": "sha256-/YLSbKh0wV6VYlNWeGrEbUUBQuchNcJjm1zn6vwYmro=",
"owner": "diniamo",
"repo": "run.nvim",
"rev": "0ae1cb228341ffec317efea4247550610de6fe0e",
"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

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

View file

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

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