blob: f5fc3dfbf0571fd8a24e45fccb86a2d5566be1fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
--[[ 50-runner.lua — run the current buffer's file with a per-filetype command.
Registers a run command for each supported file type and exposes running the current buffer through
the dotfiles.runner engine.
User commands:
Run: run the current buffer's file
Keymaps:
`<leader>r` run the current buffer's file
]]
local runner = require("dotfiles.runner")
----------------------------------------------------------------------------------------------------
-- Runners -----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
-- The `sh` runner shells out to <man://bash%281%29>; `%` expands to the current file path.
runner.register("lua", { "nvim", "-l", "%" })
runner.register("python", { "python", "%" })
runner.register("sh", { "bash", "%" })
----------------------------------------------------------------------------------------------------
-- Commands & keymaps ------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
-- Run the current buffer's file.
local function run_current()
runner.run()
end
-- stylua: ignore start
vim.api.nvim_create_user_command("Run", run_current, { desc = "Run the current buffer" })
vim.keymap.set("n", "<leader>r", run_current, { desc = "Run the current buffer" })
|