runner/run-nvim: init

This commit is contained in:
diniamo 2024-11-21 22:03:28 +01:00
parent b6785f8218
commit e52c0c7846
8 changed files with 91 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 is bundled with nvf, if you enable the module, since there is no way to
provide only the LSP server. provide only the LSP server.
- Add `run.nvim` support for running code using cached commands.
[Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd() [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 - Make Neovim's configuration file entirely Lua based. This comes with a few

View file

@ -1710,6 +1710,22 @@
"type": "github" "type": "github"
} }
}, },
"plugin-run-nvim": {
"flake": false,
"locked": {
"lastModified": 1732227783,
"narHash": "sha256-csaSdZLmgXF9ShHbwhwVIx9l4/nVPzxG72g1xFv4JHA=",
"owner": "diniamo",
"repo": "run.nvim",
"rev": "c028adc1141b78e0773757e69851e2d255e8c799",
"type": "github"
},
"original": {
"owner": "diniamo",
"repo": "run.nvim",
"type": "github"
}
},
"plugin-rustaceanvim": { "plugin-rustaceanvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -2123,6 +2139,7 @@
"plugin-registers": "plugin-registers", "plugin-registers": "plugin-registers",
"plugin-rose-pine": "plugin-rose-pine", "plugin-rose-pine": "plugin-rose-pine",
"plugin-rtp-nvim": "plugin-rtp-nvim", "plugin-rtp-nvim": "plugin-rtp-nvim",
"plugin-run-nvim": "plugin-run-nvim",
"plugin-rustaceanvim": "plugin-rustaceanvim", "plugin-rustaceanvim": "plugin-rustaceanvim",
"plugin-smartcolumn": "plugin-smartcolumn", "plugin-smartcolumn": "plugin-smartcolumn",
"plugin-sqls-nvim": "plugin-sqls-nvim", "plugin-sqls-nvim": "plugin-sqls-nvim",

View file

@ -242,6 +242,12 @@
flake = false; flake = false;
}; };
# Runners
plugin-run-nvim = {
url = "github:diniamo/run.nvim";
flake = false;
};
# Debuggers # Debuggers
plugin-nvim-dap = { plugin-nvim-dap = {
url = "github:mfussenegger/nvim-dap"; url = "github:mfussenegger/nvim-dap";

View file

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

View file

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

View file

@ -0,0 +1,36 @@
{
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
'')
];
};
vim.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";
};
};
};
}