pojokcodeid.nvim-lazy/lua/user/coderunner.lua

57 lines
1.5 KiB
Lua
Raw Normal View History

2023-01-15 00:17:41 +07:00
local status_ok, code_runner = pcall(require, "code_runner")
if not status_ok then
2023-01-21 11:43:43 +07:00
return
2023-01-15 00:17:41 +07:00
end
2023-03-05 19:29:48 +07:00
2023-03-05 20:11:50 +07:00
local rfile = {
2023-03-06 13:27:50 +07:00
java = "cd $dir && javac $fileName && java $fileNameWithoutExt",
python = "python3 -u",
2023-06-15 07:25:49 +07:00
--typescript = "deno run",
typescript = "ts-node $dir/$fileName", -- npm install -g ts-node
2023-03-06 13:27:50 +07:00
rust = "cd $dir && rustc $fileName && $dir/$fileNameWithoutExt",
-- cpp="gcc $fileName -lstdc++ -o $fileNameWithoutExt && $fileNameWithoutExt"
2024-05-12 15:18:53 +07:00
cpp = "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt",
2023-03-06 13:27:50 +07:00
scss = "sass $dir/$fileName $dir/$fileNameWithoutExt.css",
2023-12-21 07:59:34 +07:00
javascript = 'node "$dir/$fileName"',
2023-03-05 19:29:48 +07:00
}
local data_exists, runscript = pcall(require, "core.config")
if data_exists then
2023-03-05 20:11:50 +07:00
if runscript.coderunner ~= nil then
2023-03-06 13:27:50 +07:00
rfile = vim.tbl_deep_extend("force", runscript.coderunner, rfile)
2023-03-05 19:29:48 +07:00
end
end
2023-01-15 00:17:41 +07:00
code_runner.setup({
2023-01-21 11:43:43 +07:00
-- put here the commands by filetype
2023-03-05 20:11:50 +07:00
filetype = rfile,
2023-01-21 11:43:43 +07:00
-- mode = "term",
mode = "float",
focus = true,
startinsert = true,
term = {
--position = "vert",
position = "bot",
size = 50,
},
float = {
-- Key that close the code_runner floating window
close_key = "<ESC>",
-- Window border (see ':h nvim_open_win')
border = "rounded",
-- Num from `0 - 1` for measurements
height = 0.8,
width = 0.8,
x = 0.5,
y = 0.5,
-- Highlight group for floating window/border (see ':h winhl')
border_hl = "FloatBorder",
float_hl = "Normal",
-- Transparency (see ':h winblend')
blend = 0,
},
2023-01-15 00:17:41 +07:00
})