blob: 8abf4249cc7bf07b862315790da224b76b0c9172 (
plain)
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
|
local BUILD_COMMAND = ""
---@param command string
---@return nil
function executeCommandInTerminal(command)
local channel = vim.bo.channel
-- 'clear' is used to hide the command
local exit_message = "\nPress enter to exit..."
vim.api.nvim_chan_send(channel,
"clear && " .. command .. "; echo '" .. exit_message ..
"' && read -s && exit" .. "\n")
end
function setBuildCommand()
BUILD_COMMAND = vim.fn.input("Enter compile command: ", BUILD_COMMAND)
end
function build()
if string.len(BUILD_COMMAND) == 0 then setBuildCommand() end
if string.len(BUILD_COMMAND) > 0 then
vim.cmd.term()
vim.cmd.startinsert()
executeCommandInTerminal(BUILD_COMMAND)
end
end
vim.keymap.set("n", "mc", setBuildCommand)
vim.keymap.set("n", "mt", build)
|