-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.project.nvim
More file actions
92 lines (79 loc) · 2.08 KB
/
.project.nvim
File metadata and controls
92 lines (79 loc) · 2.08 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
local vim = vim
local Job = require('plenary.job')
local osEnv = {}
vim.g.title = false
vim.cmd('ProjectRoot')
for line in io.popen("set"):lines() do
local envName = line:match("^[^=]+")
osEnv[envName] = os.getenv(envName)
end
--| On Buffer Write ---------------
--|--------------------------------
local function RunJob()
local cwd = vim.fn.getcwd()
local file = vim.fn.expand('%:p')
Job:new({
command = 'vectorizer',
args = {'-p', file, '--upload' },
cwd = cwd,
env = osEnv,
on_exit = function(j, return_val)
print(vim.inspect(return_val))
print(vim.inspect(j:result()))
end,
on_stderr = function(_, output) print(output) end,
}):start()
end
vim.api.nvim_create_autocmd("BufWritePost", {
callback = function()
RunJob()
end,
})
--| On Project Load ---------------
--|--------------------------------
_G.project_load = function()
vim.cmd(":ProjectAddMuanually")
local cwd = vim.fn.getcwd()
osEnv["RUST_BACKTRACE"] = 1
Job:new({
command = 'vectorizer',
args = {'-p', cwd, '--upload' },
cwd = cwd,
env = osEnv,
on_exit = function(j, return_val)
print(vim.inspect(return_val))
print(vim.inspect(j:result()))
end,
on_stderr = function(_, output) print(output) end,
}):start()
end
--| On Build Hotkey ---------------
--|--------------------------------
-- Run shell command 'just build'
-- when :ProjectBuild is called
_G.project_build = function()
local cwd = vim.fn.getcwd()
vim.cmd('ProjectRoot')
print("Building project...")
Job:new({
command = 'just',
args = {'build', 'nvim' },
cwd = cwd,
env = osEnv,
on_exit = function(j, return_val)
print(vim.inspect(return_val))
print(vim.inspect(j:result()))
end,
on_stderr = function(_, output) print(output) end,
}):start()
end
--| On Run Hotkey -----------------
--|--------------------------------
_G.project_run = function()
local cwd = vim.fn.getcwd()
local command = "env WINIT_UNIX_BACKEND=x11 alacritty --working-directory " .. cwd
vim.fn.jobstart(command, {
detach = true,
cwd = cwd
})
end