nvim-neotest / neotest

An extensible framework for interacting with tests within NeoVim.
MIT License
2.44k stars 123 forks source link

[Feature request] support `ftplugin` #354

Open mrcjkb opened 10 months ago

mrcjkb commented 10 months ago

Hey :wave:

I was wondering if it would be feasible to support ftplugin workflows. Specifically, I'd like to be able to add adapters to neotest using files in, e.g.

etc.

At a first glance, it looks like, this could easily be achieved by changing https://github.com/nvim-neotest/neotest/blob/73043d666780e35185a77589e01bec96a52db910/lua/neotest/config/init.lua#L370

to

user_config = vim.tbl_deep_extend("force", user_config or default_config, config)

Taking this a step further, adapters could potentially self-register themselves in an ftplugin script, if the file that triggered the script to be sourced is a test file.

The caveat to the above approach is that vim.tbl_deep_extend doesn't merge lists, so the user_config.adapters list would be overwritten. This could be mitigated either by inserting into the existing table, or by providing a separate register_adapter API.

@rcarriga what are your thoughts?

rcarriga commented 9 months ago

Running setup again introduces complexities elsewhere but I think having a register_adapter method makes sense :smile: