Closed KeqiZeng closed 2 years ago
pleace check if error exist
I'm getting the same issue and still happens after the latest fix. The only way to fix the issue is to add vim.g.fileCommands = {python = 'python3'}
to my init.lua.
pleace check if error exist
Now I get this error:
E5108: Error executing lua ...cker/start/code_runner.nvim/lua/code_runner/commands.lua:43: attempt to index field 'fileC
ommands' (a nil value)
stack traceback:
...cker/start/code_runner.nvim/lua/code_runner/commands.lua:43: in function 'get_command'
...cker/start/code_runner.nvim/lua/code_runner/commands.lua:76: in function 'get_filetype_command'
...cker/start/code_runner.nvim/lua/code_runner/commands.lua:81: in function 'run_filetype'
...cker/start/code_runner.nvim/lua/code_runner/commands.lua:138: in function 'run_code'
[string ":lua"]:1: in main chunk
I also try to addvim.g.fileCommands = {python = 'python3'}
(as @KarimLeVallois said) to my init.lua, but there is nothing different on my laptop.
I find this issue is same as #14. I try to configure in pure lua as you recommended, and it works fine for a single file. So I think this plugin maybe can not correctly recognize my json flie? What should I do if i want to configure with json? Thank you so much for your effort!!
This is my personal configuration, yes use json file
require('code_runner').setup({
term = {
size = 15,
},
filetype_path = vim.fn.expand('~/.config/nvim/code_runner.json'),
project_path = vim.fn.expand('~/.config/nvim/project_manager.json'),
}
{
"javascript": "node",
"java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
"kotlin": "cd $dir && kotlinc-native $fileName -o $fileNameWithoutExt && ./$fileNameWithoutExt.kexe",
"c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt",
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt",
"python": "python -u",
"shellscript": "bash",
"csharp": "cd $dir && mcs $fileName && mono $fileNameWithoutExt.exe",
"typescript": "deno run",
"rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
"dart": "dart"
}
This is a setup using pure lua:
require('code_runner').setup {
term = {
size = 15,
},
filetype = {
java = "cd $dir && javac $fileName && java $fileNameWithoutExt",
python = "python -u",
typescript = "deno run",
rust = "cd $dir && rustc $fileName && $dir/$fileNameWithoutExt"
},
}
The error existed before the last commit, try to update the plugin and check if the problem persists, because of all the tests that I have done, the plugin works without any problem. Remember that if it is json, you should not include trailing commas, that is, a comma after the last element. In case you use lua also try to write a correct table format because all these things the plugin cannot or should not handle. Finally, if this is resolved, I would appreciate closing the issue or, if applicable, doing a pr.
HI! At first, thanks a lot for the nice plugin.
When I used this plugin just now, I got an error:
E5108: Error executing lua ...cker/start/code_runner.nvim/lua/code_runner/commands.lua:89: Expected lua string stack traceback: [C]: in function 'cmd' ...cker/start/code_runner.nvim/lua/code_runner/commands.lua:89: in function 'run_filetype' ...cker/start/code_runner.nvim/lua/code_runner/commands.lua:138: in function 'run_code' [string ":lua"]:1: in main chunk
here is my minimal init.lua about code_runner:
use { 'CRAG666/code_runner.nvim', requires = 'nvim-lua/plenary.nvim' } in packer require('code_runner').setup { term = { position = "belowright", size = 8 }, filetype_path = "$HOME/.config/nvim/code_runner.json", project_path = "$HOME/.config/nvim/projects.json" }
and here is my coder_runner.json:
{ "python": "python -u" }
It seems also like this for other languages.
try to expand the url, above leave how you do it in vim, remember that code runner works with absolute not relative paths, in fact I will be more clear, I will add more explanation of this in the README
Thank you for letting me know that the projects weren't working, data that failed because I called them projects and not project. It was so simple to correct but here I leave the complete example configuration:
require('code_runner').setup {
term = {
size = 15,
},
filetype = {
java = "cd $dir && javac $fileName && java $fileNameWithoutExt",
python = "python -u",
typescript = "deno run",
rust = "cd $dir && rustc $fileName && $dir/$fileNameWithoutExt"
},
project = {
["~/prueba"] = {
name = "App1",
description = "Tmx frontend api",
file_name = "prueba.py"
},
}
}
Sorry for being late in replying. Now it works totally fine. I think my issue comes from here:
At first I just copy the config example to my init.lua, but it can't work so good.
Just now I change
filetype_path = "$HOME/.config/nvim/code_runner.json",
project_path = "$HOME/.config/nvim/projects.json"
to
filetype_path = vim.fn.expand('~/.config/nvim/code_runner.json'),
project_path = vim.fn.expand('~/.config/nvim/project_manager.json'),
Then it can works fine. Whatever, thank you so much again for your explanation.
HI! At first, thanks a lot for the nice plugin.
When I used this plugin just now, I got an error:
here is my minimal init.lua about code_runner:
and here is my coder_runner.json:
It seems also like this for other languages.