overseer.nvim icon indicating copy to clipboard operation
overseer.nvim copied to clipboard

feature request: Is there any way to create custom strategy?

Open lolpie244 opened this issue 2 years ago • 3 comments

Did you check existing requests?

  • [X] I have searched the existing issues

Describe the feature

Is there any way to create custom strategy? Use case: use custom command runner, for runnig command outside neovim (like https://github.com/lolpie244/simple-kitty-runner.nvim)

Provide background

No response

What is the significance of this feature?

nice to have

Additional details

No response

lolpie244 avatar Feb 05 '24 20:02 lolpie244

Sure, you just need to implement all the required methods. The type is defined here:

https://github.com/stevearc/overseer.nvim/blob/a6dc0600f675f10b8840c61d3f9d72fdf8cf970c/lua/overseer/strategy/init.lua#L6-L14

You can look at the other strategies in that dir to see how they do things. The test strategy is nice in that it shows you exactly what the responsibilities of a strategy are with minimal code.

stevearc avatar Jun 06 '24 03:06 stevearc

@stevearc, should I somewhere add this class? Or just make fork and add it inside code?

lolpie244 avatar Jun 07 '24 21:06 lolpie244

The strategy is passed in as a name and is loaded on this line: https://github.com/stevearc/overseer.nvim/blob/fdcd46ce738ef342bce38e5433df004ebdab3a1a/lua/overseer/strategy/init.lua#L44

This means that if your strategy is "mystrategy", we'll be calling require("overseer.strategy.mystrategy"). So you can put the code in the file <runtimepath>/lua/overseer/strategy/mystrategy.lua. See :help runtimepath for more info, and :=vim.fn.stdpath("config") to see the most likely path to use as the root.

stevearc avatar Jun 08 '24 12:06 stevearc