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

73 lines
2.2 KiB
Lua
Raw Permalink Normal View History

2024-05-21 14:20:50 +07:00
--typescript = "deno run",
-- cpp="gcc $fileName -lstdc++ -o $fileNameWithoutExt && $fileNameWithoutExt"
2024-06-22 13:20:21 +07:00
local pyrun = "python -u"
if vim.fn.has("win32") == 0 then
pyrun = "python3 -u"
end
2024-05-20 08:42:59 +07:00
local rfile = {
2024-06-14 08:40:35 +07:00
java = "cd $dir && javac $fileName && java $fileNameWithoutExt",
2024-06-22 13:20:21 +07:00
python = pyrun,
2024-06-14 08:40:35 +07:00
typescript = "ts-node $dir/$fileName",
rust = "cd $dir && rustc $fileName && $dir/$fileNameWithoutExt",
cpp = "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt",
scss = "sass $dir/$fileName $dir/$fileNameWithoutExt.css",
javascript = 'node "$dir/$fileName"',
2024-05-20 08:42:59 +07:00
}
2024-06-14 08:21:36 +07:00
local runscript = pcode.coderunner or {}
2024-05-21 14:20:50 +07:00
rfile = vim.tbl_deep_extend("force", runscript, rfile)
2024-05-20 08:42:59 +07:00
return {
2024-06-14 08:40:35 +07:00
"CRAG666/code_runner.nvim",
lazy = true,
cmd = { "RunCode", "RunFile", "RunProject", "RunClose" },
opts = {
-- put here the commands by filetype
filetype = rfile,
-- 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",
2024-05-20 08:42:59 +07:00
2024-06-14 08:40:35 +07:00
-- Num from `0 - 1` for measurements
height = 0.8,
width = 0.8,
x = 0.5,
y = 0.5,
2024-05-20 08:42:59 +07:00
2024-06-14 08:40:35 +07:00
-- Highlight group for floating window/border (see ':h winhl')
border_hl = "FloatBorder",
float_hl = "Normal",
2024-05-20 08:42:59 +07:00
2024-06-14 08:40:35 +07:00
-- Transparency (see ':h winblend')
blend = 0,
},
},
config = function(_, opts)
require("code_runner").setup(opts)
end,
2024-07-13 13:07:24 +07:00
keys = {
{ "<leader>r", "", desc = "  Run", mode = "n" },
{
"<leader>rs",
'<cmd>autocmd bufwritepost [^_]*.sass,[^_]*.scss silent exec "!sass %:p %:r.css"<CR>',
desc = "Auto Compile Sass",
mode = "n",
},
{ "<leader>rr", "<cmd>RunCode<CR>", desc = "Run Code", mode = "n" },
{ "<leader>rf", "<cmd>RunFile<CR>", desc = "Run File", mode = "n" },
{ "<leader>rp", "<cmd>RunProject<CR>", desc = "Run Project", mode = "n" },
{ "<leader>rg", "<cmd>terminal<cr>gradle run<cr>", desc = "Run Gradle", mode = "n" },
{ "<leader>rm", "<cmd>terminal mvn package<cr>", desc = "MVN Build", mode = "n" },
},
2024-05-20 08:42:59 +07:00
}