Switched to lazy vim as packer stopped working.

Will need to clear the .local/shared/nvim/site directory to stop using
the packer packages.
I guess I made a build and run? that's neat.
This commit is contained in:
2024-01-29 16:53:18 +08:00
parent 4a09b836c1
commit 48eb0d8d60
5 changed files with 90 additions and 23 deletions
+46
View File
@@ -28,6 +28,25 @@ local function get_build_cmd()
return ""
end
local function get_buildnrun_cmd()
for path, type in vim.fs.dir(vim.fn.getcwd(), nil)
do
if (path == "build.zig") then
return "zig build run"
end
-- TODO(twig): build and run on other langauges
--if (path == "build.bat" or path == "build.sh") then
-- if (vim.loop.os_uname().sysname == "Windows_NT") then
-- -- TODO(twig): if I move to llvm this should work, right now cl doesn't work because nvim spawns a command prompt that doesn't have vcvars in it (nor does it have my stuff)
-- return "build.bat"
-- else
-- -- TODO(twig): this is untested!
-- return "./build.sh"
-- end
--end
end
return ""
end
function save_all_and_build()
if job_id then
print("Job processing")
@@ -53,3 +72,30 @@ function save_all_and_build()
job_id = vim.fn.termopen(build_cmd, {on_exit = job_exit})
vim.api.nvim_buf_set_name(job_buffer, '[build]')
end
function save_all_and_buildnrun()
if job_id then
print("Job processing")
return
end
local opts = {}
vim.api.nvim_exec('wa', opts)
if not has_buffer() then
job_buffer = vim.api.nvim_create_buf(true, true)
end
local job_window = vim.fn.bufwinnr(job_buffer)
if job_window ~= -1 then
vim.cmd(job_window .. ' wincmd w')
else
vim.cmd('buffer ' .. job_buffer)
end
vim.api.nvim_buf_set_option(job_buffer, 'filetype', 'build')
vim.api.nvim_buf_set_option(job_buffer, 'modified', false)
-- THis looks at files in the cwd and decides if there is something to build (build.zig for zig, build.bat/.sh for c++)
local build_cmd = get_build_cmd()
job_id = vim.fn.termopen(build_cmd, {on_exit = job_exit})
vim.api.nvim_buf_set_name(job_buffer, '[build]')
end