refactor(nvim): make asm files write to .target
directory on compile
This commit is contained in:
parent
e5c4aece97
commit
336bea3973
@ -1,20 +1,30 @@
|
|||||||
vim.opt_local.commentstring = "# %s"
|
vim.opt_local.commentstring = "# %s"
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>fr", function()
|
vim.keymap.set("n", "<leader>fr", function()
|
||||||
local curr_file = vim.fn.expand("%:p")
|
local curr_file = vim.api.nvim_buf_get_name(0)
|
||||||
vim.fn.expand("%:p")
|
local curr_dir = vim.fn.fnamemodify(curr_file, ":h")
|
||||||
local curr_dir = vim.fn.expand("%:p:h")
|
local fname = vim.fn.fnamemodify(curr_file, ":t:r")
|
||||||
vim.fn.expand("%:p")
|
|
||||||
require("toggleterm").exec(
|
local target_dir = curr_dir .. "/.target"
|
||||||
string.format(
|
local object_path = target_dir .. "/obj.o"
|
||||||
"as %s -o %s/obj.o && ld %s/obj.o -o %s/out && %s/out",
|
local executable_path = target_dir .. "/" .. fname
|
||||||
curr_file,
|
|
||||||
curr_dir,
|
vim.fn.mkdir(target_dir, "p")
|
||||||
curr_dir,
|
|
||||||
curr_dir,
|
local cmd = {
|
||||||
curr_dir
|
"as",
|
||||||
)
|
curr_file,
|
||||||
)
|
"-o",
|
||||||
|
object_path,
|
||||||
|
"&& \n",
|
||||||
|
"ld",
|
||||||
|
object_path,
|
||||||
|
"-o",
|
||||||
|
executable_path,
|
||||||
|
"&& \n",
|
||||||
|
executable_path
|
||||||
|
}
|
||||||
|
require("toggleterm").exec(table.concat(cmd, " "))
|
||||||
end, {
|
end, {
|
||||||
buffer = true,
|
buffer = true,
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user