Closed Wangch29 closed 8 months ago
I have to say I don't understand why the author provides key mappings with "RunCode" command but do not provide cmd option. Maybe because I'm new to nvim, but this is really messing up with me. I finally got it fixed by adding a line like cmd="RunCode", and put this in your plugins folder should get it done:
return {
"CRAG666/code_runner.nvim",
cmd = "RunCode",
config = function()
require("code_runner").setup {
filetype = {
java = {
"cd $dir &&",
"javac $fileName &&",
"java $fileNameWithoutExt",
},
python = "python3 -u",
typescript = "deno run",
javascript = "node",
rust = {
"cd $dir &&",
"rustc $fileName &&",
"$dir/$fileNameWithoutExt",
},
c = function(...)
c_base = {
"cd $dir &&",
"gcc $fileName -o",
"/tmp/$fileNameWithoutExt",
}
local c_exec = {
"&& /tmp/$fileNameWithoutExt &&",
"rm /tmp/$fileNameWithoutExt",
}
vim.ui.input({ prompt = "Add more args:" }, function(input)
c_base[4] = input
vim.print(vim.tbl_extend("force", c_base, c_exec))
require("code_runner.commands").run_from_fn(vim.list_extend(c_base, c_exec))
end)
end,
},
}
end,
}
What's that?