Skip to content

Commit 53f0ae1

Browse files
committed
GHOSTFERAK
1 parent 6d013da commit 53f0ae1

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

nvim/lua/bfredl/ghostzig.lua

+19-11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ _G.h = h
77

88
local ns = a.create_namespace'ghostzig'
99
h.ghostpath = vim.fn.stdpath'run'..'/ghostzig_'..vim.fn.getpid()
10+
h.ghostcmd = nil
11+
h.ghostargs = {}
12+
13+
h.ghosted_bufs = {} -- bufs which might have stale diags
14+
15+
a.create_autocmd({'TextChanged', 'TextChangedI'}, {
16+
pattern = "*.zig";
17+
callback = function() h.ghostbuild() end;
18+
})
1019

1120
function h.ghostwrite()
1221
bufname = vim.fn.fnamemodify(vim.fn.bufname(), ':.')
@@ -21,7 +30,8 @@ function h.ghostwrite()
2130
ghostpipe:close()
2231
end
2332

24-
function h.ghostbuild(entrypoint, test)
33+
function h.ghostbuild()
34+
if h.ghostcmd == nil then return end -- disabled
2535
if h.state == "running" or h.state == "throttled" then
2636
-- require'luadev'.print("THROTTLE")
2737
h.state = "throttled"
@@ -30,13 +40,11 @@ function h.ghostbuild(entrypoint, test)
3040
h.state = "running"
3141
h.ghostwrite()
3242

33-
local subcmd = test and 'test' or 'build-exe'
34-
args = { subcmd, '-lc', '-fno-emit-bin', h.ghostpath..'/'..entrypoint}
3543
local start_time = vim.fn.reltime()
3644
-- require'luadev'.print("START")
3745
local job = Job:new {
38-
command = 'zig';
39-
args = args;
46+
command = h.ghostcmd;
47+
args = h.ghostargs;
4048
on_exit = vim.schedule_wrap(function(j, ret)
4149
local time = vim.fn.reltime(start_time)
4250
local lines = j:stderr_result()
@@ -65,7 +73,7 @@ function h.ghostbuild(entrypoint, test)
6573

6674
if h.state == "throttled" then
6775
h.state = nil
68-
h.ghostbuild(entrypoint)
76+
h.ghostbuild(command, args)
6977
else
7078
h.state = "done"
7179
end
@@ -86,13 +94,13 @@ end
8694

8795
function h.ghostzig(entrypoint, test)
8896
cwd = vim.fn.getcwd()
89-
h.ghosted_bufs = {}
9097
-- TODO: only .zig files?
9198
vim.fn.system({'mkdir', '-p', h.ghostpath})
9299
vim.fn.system({'cp', '-r', cwd .. '/src', h.ghostpath .. '/src'})
93-
a.create_autocmd({'TextChanged', 'TextChangedI'}, {
94-
pattern = "*.zig";
95-
callback = function() h.ghostbuild(entrypoint, test) end;
96-
})
100+
101+
local command = 'zig'
102+
local subcmd = test and 'test' or 'build-exe'
103+
args = { subcmd, '-lc', '-fno-emit-bin', h.ghostpath..'/'..entrypoint}
104+
97105
end
98106
return h

zshrc

+9
Original file line numberDiff line numberDiff line change
@@ -524,3 +524,12 @@ fi
524524

525525
# bun completions
526526
[ -s "/home/bfredl/.bun/_bun" ] && source "/home/bfredl/.bun/_bun"
527+
528+
529+
# BEGIN opam configuration
530+
# This is useful if you're using opam as it adds:
531+
# - the correct directories to the PATH
532+
# - auto-completion for the opam binary
533+
# This section can be safely removed at any time if needed.
534+
[[ ! -r '/home/bfredl/.opam/opam-init/init.zsh' ]] || source '/home/bfredl/.opam/opam-init/init.zsh' > /dev/null 2> /dev/null
535+
# END opam configuration

0 commit comments

Comments
 (0)