Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command in filetype not taken into account anymore ? #126

Open
vimchun opened this issue Dec 20, 2024 · 11 comments
Open

Command in filetype not taken into account anymore ? #126

vimchun opened this issue Dec 20, 2024 · 11 comments
Labels
invalid This doesn't seem right

Comments

@vimchun
Copy link

vimchun commented Dec 20, 2024

Few hours ago, I could run :RunFile toggleterm with no problem (I could run a python script with a custom command).

The latest commit might have a regression : the filetype I set is not taken into account anymore filetype = { python = "clear && python3 -u" }. It seems the command run is the default one : filetype = { python = "python -u '$dir/$fileName'" }.

Note : I had to remove hot_reload = true because I had an error when saving

Error detected while processing BufWritePost Autocommands for "*":
Error executing lua callback: .../nvim/lazy/code_runner.nvim/lua/code_runner/filetype.lua:19: attempt to index field 'utils' (a nil value)
stack traceback:
        .../nvim/lazy/code_runner.nvim/lua/code_runner/filetype.lua:19: in function 'getCommand'
        .../nvim/lazy/code_runner.nvim/lua/code_runner/commands.lua:43: in function <.../nvim/lazy/code_runner.nvim/lua/code_runner/commands.lua:39>

@vimchun vimchun changed the title The command in filetype not taken into account anymore ? Command in filetype not taken into account anymore ? Dec 20, 2024
@CRAG666
Copy link
Owner

CRAG666 commented Dec 20, 2024

Pleace, send screenshot

@CRAG666
Copy link
Owner

CRAG666 commented Dec 20, 2024

@vimchun update the plugin, pleace

@vimchun
Copy link
Author

vimchun commented Dec 20, 2024

@CRAG666 I just updated it, I still have the same behavior :
(as you can see, I set python3 as for the command, but I get python -u)

image

@CRAG666
Copy link
Owner

CRAG666 commented Dec 20, 2024

@vimchun pleace check your config. My config work:
imagen

@CRAG666
Copy link
Owner

CRAG666 commented Dec 20, 2024

@CRAG666 my config:
local preview_cmd = "/bin/zathura"
local folder = ""

return {
"CRAG666/code_runner.nvim",
-- name = "code_runner",
dev = true,
keys = {
{
"e",
function()
require("code_runner").run_code()
end,
desc = "[e]xcute code",
},
},
opts = {
mode = "better_term",
better_term = {
number = 1,
},
filetype = {
v = "v run",
tex = function(...)
require("code_runner.hooks.tectonic").build(preview_cmd, { "--keep-logs" })
end,
quarto = {
"cd $dir &&",
"quarto preview $fileName",
"--no-browser",
"--port 4444",
},
markdown = function(...)
local hook = require "code_runner.hooks.preview_pdf"
require("code_runner.hooks.ui").select {
Marp = function()
require("code_runner").run_from_fn "marp --theme-set $MARPT -w -p . &$end"
end,
Latex = function()
hook.run {
command = "pandoc",
args = { "$fileName", "-o", "$tmpFile", "-t pdf" },
preview_cmd = preview_cmd,
}
end,
Beamer = function()
hook.run {
command = "pandoc",
args = { "$fileName", "-o", "$tmpFile", "-t beamer" },
preview_cmd = preview_cmd,
}
end,
Eisvogel = function()
hook.run {
command = "bash",
args = { "./build.sh" },
preview_cmd = preview_cmd,
overwrite_output = ".",
}
end,
}
end,
javascript = "node",
java = "cd $dir && javac $fileName && java $fileNameWithoutExt",
kotlin = "cd $dir && kotlinc-native $fileName -o $fileNameWithoutExt && ./$fileNameWithoutExt.kexe",
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
require("code_runner.commands").run_from_fn(vim.list_extend(c_base, c_exec))
end)
end,
-- c = {
-- "cd $dir &&",
-- "gcc $fileName -o",
-- "/tmp/$fileNameWithoutExt &&",
-- "/tmp/$fileNameWithoutExt &&",
-- "rm /tmp/$fileNameWithoutExt",
-- },
cpp = {
"cd $dir &&",
"g++ $fileName",
"-o /tmp/$fileNameWithoutExt &&",
"/tmp/$fileNameWithoutExt",
},
-- python = "python -u '$dir/$fileName'",
python = "python3",
sh = "bash",
typescript = "deno run",
typescriptreact = "yarn dev$end",
rust = "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
dart = "dart",
cs = function(...)
local root_dir = require("null-ls.utils").root_pattern "*.csproj"(vim.loop.cwd())
return "cd " .. root_dir .. " && dotnet run$end"
end,
},
project_path = vim.fn.expand "~/.config/nvim/project_manager.json",
},
}

@CRAG666
Copy link
Owner

CRAG666 commented Dec 20, 2024

@vimchun Please delete the plugin and reinstall

@CRAG666
Copy link
Owner

CRAG666 commented Dec 20, 2024

pleace check: :lua vim.print(require("code_runner").get_filetype_command())

@vimchun
Copy link
Author

vimchun commented Dec 20, 2024

@CRAG666 I have the same behavior after deleting/reinstalling the plugin, and your command returns python -u /home/mhh/.config/nvim/test_formatting/test_python.py

image

Sorry if the problem is from my environment, I did a lot of modifications in the past few hours... I will check and will come back to you.

@CRAG666 CRAG666 added the invalid This doesn't seem right label Dec 20, 2024
@vimchun
Copy link
Author

vimchun commented Dec 20, 2024

Not sure why you added the invalid label.

I deleted all my plugins except code_runner and toggleterm, uninstall/reinstall both again.

image

I set this :

require("code_runner").setup({
    filetype = { python = "python3" }
})

On my python file, :lua vim.print(require("code_runner").get_filetype_command()) still returns python -u /home/mhh/.config/nvim/test_formatting/test_python.py

image

So I tried with the commit = 'c367431' (the one I was supposed to have when it worked well), and it works (with the message in Spanish #125) :

image

image

@vimchun
Copy link
Author

vimchun commented Dec 20, 2024

(and still works well after loading all my plugins again, ... not sure about the invalid label...)

@CRAG666
Copy link
Owner

CRAG666 commented Dec 20, 2024

More reports for change tag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants