-
Notifications
You must be signed in to change notification settings - Fork 0
/
.nvim-commands.lua
46 lines (41 loc) · 1.69 KB
/
.nvim-commands.lua
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
36
37
38
39
40
41
42
43
44
45
46
-- source with luafile to run tree sitter test commands in the integrated terminal
-- DEPENDS ON https://github.com/akinsho/toggleterm.nvim
function vim.getVisualSelection()
vim.cmd('noau normal! "vy"')
local text = vim.fn.getreg("v")
vim.fn.setreg("v", {})
text = string.gsub(text, "\n", "")
if #text > 0 then
return text
else
return ""
end
end
TSTEST = ""
vim.api.nvim_set_keymap("n", "<F1>", "<cmd>TermExec cmd='v . && ./vgtk'<CR>", { noremap = true, silent = true })
-- -- run a test with the visually selected string
-- vim.keymap.set("v", "<F2>", function()
-- TSTEST = vim.getVisualSelection()
-- vim.cmd("TermExec cmd='tree-sitter generate && tree-sitter test -d -D -f \"" .. TSTEST .. "\"'<CR>")
-- end, { noremap = true, silent = true })
--
-- -- rerun last visually selected test
-- vim.keymap.set("n", "<F2>", function()
-- vim.cmd("TermExec cmd='tree-sitter generate && tree-sitter test -d -D -f \"" .. TSTEST .. "\"'<CR>")
-- end, { noremap = true, silent = true })
--
-- -- update a test
-- vim.keymap.set("v", "<F3>", function()
-- TSTEST = vim.getVisualSelection()
-- vim.cmd("TermExec cmd='tree-sitter test -d -D -f \"" .. TSTEST .. "\" -u'<CR>")
-- end, { noremap = true, silent = true })
--
-- vim.keymap.set("n", "<F4>", function()
-- TSTEST = vim.getVisualSelection()
-- vim.cmd("TermExec cmd='python script/roadmapgen.py sync --jakt-path ~/src/jakt/jakt'<CR>")
-- end, { noremap = true, silent = true })
--
-- vim.keymap.set("n", "<F5>", function()
-- TSTEST = vim.getVisualSelection()
-- vim.cmd("TermExec cmd='python script/roadmapgen.py check --jakt-path ~/src/jakt/jakt'<CR>")
-- end, { noremap = true, silent = true })