stevearc / overseer.nvim

A task runner and job management plugin for Neovim
MIT License
1.04k stars 50 forks source link

Support YAML as alternative to VS Code tasks.json #165

Open jedrzejboczar opened 1 year ago

jedrzejboczar commented 1 year ago

I really like loading the tasks from VS Code tasks.json, it is quite simple to add per-project tasks without modifying my Neovim config. But I find myself defining multiple very similar entries in the JSON file, with only minor modifications (I have tasks for multi-stage building of some project with a few different configurations).

Would it be possible to add support for parsing YAML files? I mean, as far as I know VS Code does not support any kind of tasks.yaml, so this wouldn't be any compatibility thing. However, YAML has (imo) nicer syntax, as well as some really useful features, especially anchors/aliases/overrides/extensions. This would allow to define task "templates" in one place and just reference these in the rest of the YAML. You can find usage example at the end of this section. And user could always convert tasks.yaml to JSON if needed using tools like yq, resulting in a valid VS Code tasks.json.

As for the implementation, in toggletasks.nvim I was using lyaml. It could be an opt-in feature that works only if lyaml is installed (can be installed via luarocks). Here is an example usage.

stevearc commented 1 year ago

It's a little bit of an odd request, but I don't see any issue with it. If you want, you can add a tasks.yaml file as a secondary (or primary) task source when lyaml is present. It should be as easy as modifying these two helper functions: https://github.com/stevearc/overseer.nvim/blob/5564d0d1b7c956be5c51f4945ebbde7408a48043/lua/overseer/template/vscode/vs_util.lua#L19-L36

jedrzejboczar commented 1 year ago

After some tweaking it turned out not to be that helpful in my particular case, because I have small differences deep into the task structures and YAML anchors still were too limited. In the end I need something more like variable substitution, so I went for .nvim.lua with overseer.register_template and defining the tasks in Lua.

If someone still wants this feature, the code is on branch jb/tasks-yaml of my fork.