Skip to content

Commit c364d49

Browse files
committed
a
0 parents  commit c364d49

File tree

6 files changed

+100
-0
lines changed

6 files changed

+100
-0
lines changed

.github/workflows/doc.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
name: Generate Docs
6+
7+
jobs:
8+
docs:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: panvimdoc
15+
uses: kdheepak/panvimdoc@main
16+
with:
17+
vimdoc: boilerplate
18+
version: "Neovim <= infinity(i think)"
19+
demojify: true
20+
treesitter: true
21+
- name: Push changes
22+
uses: stefanzweifel/git-auto-commit-action@v6
23+
with:
24+
commit_message: "chore: autgenerate vimdoc"
25+
commit_user_name: "github-actions[bot]"
26+
commit_user_email: "github-actions[bot]@users.noreply.github.com"
27+
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/plugin/reload.vim

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## tiny.run
2+
a code runner because all the curent ones are bad.

lua/run.lua

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
local M = {}
2+
local vim = vim
3+
4+
local config = {
5+
enabled = true,
6+
handlers = {
7+
{ ext = "java", action = "javac [name].[ext] && java [name]" },
8+
{ ext = "py", action = "python3 [name].[ext]" },
9+
{ ext = "go", action = "go run [name].[ext]" },
10+
{ ext = "js", action = "node [name].[ext]" },
11+
{ ext = "rs", action = "cargo run [name].[ext]" },
12+
},
13+
split_cmd = "botright split | resize -10"
14+
}
15+
16+
local function random_char()
17+
local characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`~!@#$%^&*)(-=][\';\"/.,_+}{|:?><"
18+
local random_index = math.random(1, string.len(characters))
19+
local picked_character = string.sub(characters, random_index, random_index)
20+
return picked_character
21+
end
22+
23+
function M.run()
24+
if not config.enabled then return end
25+
26+
local dir, name, ext = vim.fn.expand("%:p:h"), vim.fn.expand("%:t:r"), vim.fn.expand("%:e")
27+
for _, h in ipairs(config.handlers) do
28+
if h.ext == ext then
29+
local cmd = h.action:gsub("%[name%]", name):gsub("%[ext%]", ext)
30+
31+
-- open a split to show output
32+
vim.cmd(config.split_cmd)
33+
vim.cmd("enew")
34+
local buf = vim.api.nvim_get_current_buf()
35+
vim.api.nvim_buf_set_name(buf, "crunner: " .. name .. "." .. ext .. "_" .. random_char() .. random_char())
36+
vim.api.nvim_buf_set_option(buf, "buftype", "nofile")
37+
vim.api.nvim_buf_set_option(buf, "bufhidden", "hide") -- hide on close
38+
vim.api.nvim_buf_set_option(buf, "buflisted", false) -- not in tabline
39+
vim.api.nvim_buf_set_option(buf, "swapfile", false)
40+
vim.api.nvim_buf_set_option(buf, "filetype", "crunner")
41+
42+
-- run command asynchronously
43+
vim.fn.jobstart("cd " .. dir .. " &&" .. cmd, {
44+
stdout_buffered = true,
45+
stderr_buffered = true,
46+
on_stdout = function(_, data)
47+
if data then vim.api.nvim_buf_set_lines(buf, -1, -1, false, data) end
48+
end,
49+
on_stderr = function(_, data)
50+
if data then vim.api.nvim_buf_set_lines(buf, -1, -1, false, data) end
51+
end,
52+
})
53+
54+
return
55+
end
56+
end
57+
58+
print("No handler configured for extension: " .. ext)
59+
end
60+
61+
function M.setup(opts)
62+
if opts then config = vim.tbl_deep_extend("force", config, opts) end
63+
end
64+
65+
return M

plugin/run.lua

Whitespace-only changes.

stylua.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
indent_type = "Spaces"
2+
indent_width = 2
3+
column_width = 100
4+
quote_style = "AutoPreferDouble"
5+
no_call_parentheses = false

0 commit comments

Comments
 (0)