-
Notifications
You must be signed in to change notification settings - Fork 8
Lets start a wiki with good defaults for popular languages #18
Comments
Sounds like a great idea! |
POG! defaults confirmed? |
I am trying to get good tasks for python, cpp (although this depends on build system), rust, lua and shells, because I work with those regularly. I can contribute those, I just need help with a few things, basically to do with getting the name of the current file and the path of the current project (cwd or lsp root). I wan't a task something like this that just uses a terminal to execute the file (works for shell files or python files)
The lsp root is for activating cmake correctly. I think |
I'm not sure exactly what you need...maybe just IIRC, the terminal should already start in the current working directory. If your cwd is not already correct, you're probably not starting vim from the project root. You should probably look into something like https://github.com/airblade/vim-rooter or https://github.com/ahmedkhalf/project.nvim. |
I maybe can relate on what @IndianBoy42 referring to. suppose I build a C file in I cannot do that right now because expansion done after split: Lines 88 to 93 in 0ccc156
while I need to add period slash Is there any way to achieve that? Thanks |
my hacky solution is to add this in my config: require("yabs.util").expand = function(str)
local split_str = vim.split(str, ' ')
local expanded_str = vim.tbl_map(vim.fn.expand, split_str)
if expanded_str[1] == "./" then
return table.concat(expanded_str, '')
else
return table.concat(expanded_str, ' ')
end
end
-- ...
yabs:setup{
-- ...
c = {
tasks = {
-- ...
run = {
command = "./ %:r",
output = "terminal",
opts = {
open_on_run = "always",
},
},
}
}
} |
@ybbond Here's a better solution (this is untested but I think it should work lol): run = {
command = function()
return "./" .. vim.fn.expand("%:r")
end,
output = "terminal",
opts = {
open_on_run = "always",
}
} This should work because if the command key is function, it uses the value that it returns as the actual command to run. Try it and LMK if that works. |
You're right though, the expand function should be improved. Either that or removed in favor of doing it the above way all the time, but I'd rather get it to work in those edge cases instead if possible. |
glad to inform that your advice does the job. thanks! maybe that's a start of example to be added to the README.md? anyway, fun fact. previously I tried: run = {
command = "lua './'..vim.fn.expand('%:r')",
type = "vim",
output = "terminal",
opts = {
open_on_run = "always",
},
}, that does not work. that's why I end up using the hacky solution. |
I think this would make this plugin a lot more use friendly
The text was updated successfully, but these errors were encountered: