nvim-neotest / neotest

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

[Enhancement] Is there a way to config nvim-notify #218

Open scottming opened 1 year ago

scottming commented 1 year ago

I mainly run tests in the IEx shell when I develop Elixir projects, It's super fast, but it's easy to miss the notifications, so I want to use https://github.com/rcarriga/nvim-notify to notify me after the test is finished.

How do I archive this?

FYI: https://github.com/jfpedroza/neotest-elixir/pull/23

rcarriga commented 1 year ago

You can write a custom consumer for this.

  neotest.setup({
    consumers = {
      notify = function(client)
        client.listeners.results = function(adapter_id, results, partial)
          -- Partial results can be very frequent
          if partial then
            return
          end
          require("neotest.lib").notify("Tests completed")
        end
        return {}
      end,
    },

You could check the results to change the message.

I'd be open to PRs for a built-in consumer with a more fleshed out API if you're interested or I may get around to implementing myself at some stage :sweat_smile:

scottming commented 1 year ago

I'm interested in what you said about a fleshed out API.

rcarriga commented 1 year ago

Well I'm open to ideas :smile:

Some potential niceties:

scottming commented 1 year ago

Cool, I like these ideas.

nieomylnieja commented 1 year ago

Maybe all there's needed is an example in the README. The API that's there in place along with its type hints is super clear and easy to write anything one might like, thanks @rcarriga!