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.keymap.set("n", "<leader>fr", function()
|
||||
local curr_file = vim.fn.expand("%:p")
|
||||
vim.fn.expand("%:p")
|
||||
local curr_dir = vim.fn.expand("%:p:h")
|
||||
vim.fn.expand("%:p")
|
||||
require("toggleterm").exec(
|
||||
string.format(
|
||||
"as %s -o %s/obj.o && ld %s/obj.o -o %s/out && %s/out",
|
||||
curr_file,
|
||||
curr_dir,
|
||||
curr_dir,
|
||||
curr_dir,
|
||||
curr_dir
|
||||
)
|
||||
)
|
||||
local curr_file = vim.api.nvim_buf_get_name(0)
|
||||
local curr_dir = vim.fn.fnamemodify(curr_file, ":h")
|
||||
local fname = vim.fn.fnamemodify(curr_file, ":t:r")
|
||||
|
||||
local target_dir = curr_dir .. "/.target"
|
||||
local object_path = target_dir .. "/obj.o"
|
||||
local executable_path = target_dir .. "/" .. fname
|
||||
|
||||
vim.fn.mkdir(target_dir, "p")
|
||||
|
||||
local cmd = {
|
||||
"as",
|
||||
curr_file,
|
||||
"-o",
|
||||
object_path,
|
||||
"&& \n",
|
||||
"ld",
|
||||
object_path,
|
||||
"-o",
|
||||
executable_path,
|
||||
"&& \n",
|
||||
executable_path
|
||||
}
|
||||
require("toggleterm").exec(table.concat(cmd, " "))
|
||||
end, {
|
||||
buffer = true,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user