Skip to content

Commit

Permalink
feat: allow for custom telescope picker opts
Browse files Browse the repository at this point in the history
  • Loading branch information
bloznelis committed Mar 8, 2024
1 parent 7a1c28b commit 14a17f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ Track edit locations and jump back to them, like [changelist](https://neovim.io/

-- Jump to previous entry in the edit history
vim.keymap.set('n', '<C-h>', before.jump_to_last_edit, {})

-- Jump to next entry in the edit history
vim.keymap.set('n', '<C-l>', before.jump_to_next_edit, {})

-- Move edit history to quickfix (or telescope)
vim.keymap.set('n', '<leader>oe', before.show_edits, {})
end
}
```

### Configuration
#### Settings
```lua
require('before').setup({
-- How many edit locations to store in memory (default: 10)
Expand All @@ -35,3 +38,10 @@ require('before').setup({
telescope_for_preview = true
})
```
#### Telescope picker
```lua
-- Provide custom opts to telescope picker as show_edits argument:
vim.keymap.set('n', '<leader>oe', function()
before.show_edits(require('telescope.themes').get_dropdown())
end, {})
```
4 changes: 2 additions & 2 deletions lua/before.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ local function load_buf_line(bufnr, linenum)
return vim.api.nvim_buf_get_lines(bufnr, linenum - 1, linenum, false)[1]
end

function M.show_edits()
function M.show_edits(picker_opts)
local qf_entries = {}
for _, location in pairs(M.edit_locations) do
if bufvalid(location.bufnr) then
Expand All @@ -150,7 +150,7 @@ function M.show_edits()

vim.fn.setqflist(qf_entries, 'r')
if M.telescope_for_preview then
require('telescope.builtin').quickfix()
require('telescope.builtin').quickfix(picker_opts or {})
else
vim.cmd('copen')
end
Expand Down

0 comments on commit 14a17f5

Please sign in to comment.