Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Allow additional options to be passed to sources #457

Closed
1 task done
Tired-Fox opened this issue May 31, 2024 · 0 comments · Fixed by #445
Closed
1 task done

feature: Allow additional options to be passed to sources #457

Tired-Fox opened this issue May 31, 2024 · 0 comments · Fixed by #445
Labels
enhancement New feature or request

Comments

@Tired-Fox
Copy link

Did you check the docs?

  • I have read all the trouble.nvim docs

Is your feature request related to a problem? Please describe.

There is no problem, just a quality of life

Describe the solution you'd like

Currently, using require("trouble.sources.telescope").open only takes the passed buffer number from telescope. After adding the items to the trouble buffer, it opens the window with require("trouble").open("telescope").

It would be a nice quality of life to allow the user to pass additional options to the require("trouble.sources.telescope").open function. This would allow the user to change the auto focus, preview, and other options.

local open_with_trouble = require("trouble.sources.telescope").open
require("telescope").setup({
  defaults = {
    mappings = {
      n = { ["<c-t>"] =  open_with_trouble }
    }
  }
})

-- to something like

local open_with_trouble = function (bufnr)
  require("trouble.sources.telescope").open(bufnr, {
    focus = true,
    -- etc...
  })
end
require("telescope").setup({
  defaults = {
    mappings = {
      n = { ["<c-t>"] = open_with_trouble }
    }
  }
})

Maybe a table merge so that the end of trouble.sources.trouble.add can look something like this

function M.add(prompt_bufnr, opts)
  --- ... add items from buffer

  opts = vim.tbl_extend("force", {}, opts, { mode = "telescope" })
  vim.schedule(function()
    require("telescope.actions").close(prompt_bufnr),
    require("trouble").open(opts)
  end)
end

Describe alternatives you've considered

Alternatively the opening of the window could be pulled out and into the trouble.sources.telescope.open function itself

Additional context

No response

@Tired-Fox Tired-Fox added the enhancement New feature or request label May 31, 2024
@folke folke closed this as completed in 4eaaf9c May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant