Skip to content

Commit

Permalink
make tab configurable (#211)
Browse files Browse the repository at this point in the history
* Make tab configurable

* Add tab mapping to README.md

---------

Co-authored-by: Nurdaulet Kurenshe <[email protected]>
  • Loading branch information
EpsilonKu and Nurdaulet Kurenshe authored Mar 13, 2024
1 parent b1ca5ba commit d1db6c1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ require('spectre').setup({
replace = "DiffDelete"
},
mapping={
['tab'] = {
map = '<Tab>',
cmd = "<cmd>lua require('spectre').tab()<cr>",
desc = 'next query'
},
['shift-tab'] = {
map = '<S-Tab>',
cmd = "<cmd>lua require('spectre').tab_shift()<cr>",
desc = 'previous query'
},
['toggle_line'] = {
map = "dd",
cmd = "<cmd>lua require('spectre').toggle_line()<CR>",
Expand Down
10 changes: 10 additions & 0 deletions lua/spectre/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ local config = {
replace = 'SpectreReplace',
},
mapping = {
['tab'] = {
map = '<Tab>',
cmd = "<cmd>lua require('spectre').tab()<cr>",
desc = 'next query'
},
['shift-tab'] = {
map = '<S-Tab>',
cmd = "<cmd>lua require('spectre').tab_shift()<cr>",
desc = 'previous query'
},
['toggle_line'] = {
map = 'dd',
cmd = "<cmd>lua require('spectre').toggle_line()<CR>",
Expand Down
2 changes: 0 additions & 2 deletions lua/spectre/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,6 @@ function M.mapping_buffer(bufnr)
api.nvim_buf_set_keymap(bufnr, 'n', 'o', 'ji', map_opt) -- don't append line on can make the UI wrong
api.nvim_buf_set_keymap(bufnr, 'n', 'O', 'ki', map_opt)
api.nvim_buf_set_keymap(bufnr, 'n', 'u', '', map_opt) -- disable undo, It breaks the UI.
api.nvim_buf_set_keymap(bufnr, 'n', '<Tab>', "<cmd>lua require('spectre').tab()<cr>", map_opt)
api.nvim_buf_set_keymap(bufnr, 'n', '<S-Tab>', "<cmd>lua require('spectre').tab_shift()<cr>", map_opt)
api.nvim_buf_set_keymap(bufnr, 'n', 'yy', "<cmd>lua require('spectre.actions').copy_current_line()<cr>", map_opt)
api.nvim_buf_set_keymap(bufnr, 'n', '?', "<cmd>lua require('spectre').show_help()<cr>", map_opt)

Expand Down

0 comments on commit d1db6c1

Please sign in to comment.