thenbe / neotest-playwright

A playwright adapter for neotest.
MIT License
43 stars 5 forks source link

feat: add experimental telescope picker for project selection (`:NeotestPlaywrightProject`) #31

Closed thenbe closed 5 months ago

thenbe commented 5 months ago

closes #20 closes #29

Feedback welcome. To test this PR:

{
    'nvim-neotest/neotest',
    dependencies = {
+       {
            'thenbe/neotest-playwright',
+           branch = 'telescope',
+           dependencies = 'nvim-telescope/telescope.nvim',
+       },
    },
    config = function()
        require('neotest').setup({
            adapters = {
                require('neotest-playwright').adapter({
                    options = {
                        -- persist_project_selection...,
+                       experimental = {
+                           -- If true, a telescope picker will be used for `:NeotestPlaywrightProject`.
+                           -- Otherwise, `vim.ui.select` is used.
+                           -- In normal mode, `<Tab>` toggles the project under the cursor.
+                           -- `<CR>` (enter key) applies the selection.
+                           telescope = {
+                               enabled = true,
+                               opts = {},
+                           },
+                       },
                    },
                }),
            },
        })
    end,
}
catgoose commented 5 months ago

Thanks, this seems to be working for me.

Could we pass in telescope options? For example if I wanted to use the layout:

local opts = {
  layout_strategy = "vertical",
  layout_config = {
    width = 0.5,
    height = 0.50,
    vertical = {
      prompt_position = "bottom",
    },
  },
}
require("neotest-playwright").adapter({
  options = {
    experimental = {
      use_telescope = true,
      opts = opts
    },
  },
}),
thenbe commented 5 months ago

Good to hear it's working for you.

I've changed the options signature to allow custom telescope options. If no options are set, it now falls back to the user's default telescope opts (as set in their original telescope config).

        experimental = {
-           use_telescope = true
+           telescope = {
+               enabled = true,
+               opts = {},
+           },
        }
catgoose commented 5 months ago

image

Beautiful! This works great.