jedrzejboczar / toggletasks.nvim

Neovim task runner: JSON/YAML + toggleterm.nvim + telescope.nvim
MIT License
157 stars 3 forks source link

[Feature Request] Add "filename with no extension" variable (`fnamemodify(..., ':t:r')`) #1

Closed annenpolka closed 2 years ago

annenpolka commented 2 years ago

I use task runner to compile single files. I want to use the filename without extension as the output filename argument.

I want to define tasks like this:

        {
            "name": "clang++ compile",
            "cmd": "clang++ -g -Wall '${file}' -o '${file_noext}'",
            "cwd": "${global_cwd}",
            "tags": ["cpp"]
        }
jedrzejboczar commented 2 years ago

This makes sense, I created https://github.com/jedrzejboczar/toggletasks.nvim/commit/478997bbd3271f359ce9058e2667e2a5e13e9ba3 which should solve the issue.

I decided that, instead of adding more special variables, it'll be better to allow to use Vim's filename-modifiers directly. So now you can use ${file:t:r}. The old file_ext, file_tail and file_head are now deprecated, but will work as before to avoid breaking changes.

Filename modifiers are available for all variable expansions, so as a consequence, it's currently not possible to expand environmental variables with : in their name, but I think it's something that would never happen anyway.