mrcjkb / haskell-tools.nvim

🦥 Supercharge your Haskell experience in neovim!
GNU General Public License v2.0
484 stars 20 forks source link

Commands for opening test/spec files and vice versa #206

Closed mrcjkb closed 1 year ago

mrcjkb commented 1 year ago

Feature description

Not sure yet if this belongs in this plugin:

I often have a module that is accompanied by one or two test modules of the same name (e.g. MyModule -> MyModuleSpec and/or MyModuleTest).

It would be nice to be able to cycle between these files with a command/keymap.

This idea is similar to other.nvim, but that plugin doesn't seem to let you link more than two files.

It might also be useful to leverage LSP workspace symbols for this.

mrcjkb commented 1 year ago

Add bang ! to create file if it doesn't exist

mrcjkb commented 1 year ago

other.nvim is sufficient for this.

See for example the following config:

  mappings = {
    {
      pattern = '(.+)/src/(.*)/(.*).hs$',
      target = {
        {
          target = '%1/test/%2/%3Spec.hs',
          context = 'spec',
        },
        {
          target = '%1/test/%2/*%3Test.hs',
          context = 'test',
        },
      },
    },
    -- jump back from specs
    {
      pattern = '(.+)/test/(.*)/(.*)Spec.hs$',
      target = '%1/src/%2/%3.hs',
    },
    -- jump back from tests
    {
      pattern = '(.+)/test/(.*)/(.*)Test.hs$',
      target = '%1/src/%2/%3.hs',
    },
  },