From d1db6c1d37252b5a38f199e2f590c5a1617d9254 Mon Sep 17 00:00:00 2001 From: Kurenshe Nurdaulet <63652620+EpsilonKu@users.noreply.github.com> Date: Wed, 13 Mar 2024 18:00:18 +0600 Subject: [PATCH] make tab configurable (#211) * Make tab configurable * Add tab mapping to README.md --------- Co-authored-by: Nurdaulet Kurenshe --- README.md | 10 ++++++++++ lua/spectre/config.lua | 10 ++++++++++ lua/spectre/init.lua | 2 -- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 02d1980..742f178 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,16 @@ require('spectre').setup({ replace = "DiffDelete" }, mapping={ + ['tab'] = { + map = '', + cmd = "lua require('spectre').tab()", + desc = 'next query' + }, + ['shift-tab'] = { + map = '', + cmd = "lua require('spectre').tab_shift()", + desc = 'previous query' + }, ['toggle_line'] = { map = "dd", cmd = "lua require('spectre').toggle_line()", diff --git a/lua/spectre/config.lua b/lua/spectre/config.lua index 98b7266..65931da 100644 --- a/lua/spectre/config.lua +++ b/lua/spectre/config.lua @@ -35,6 +35,16 @@ local config = { replace = 'SpectreReplace', }, mapping = { + ['tab'] = { + map = '', + cmd = "lua require('spectre').tab()", + desc = 'next query' + }, + ['shift-tab'] = { + map = '', + cmd = "lua require('spectre').tab_shift()", + desc = 'previous query' + }, ['toggle_line'] = { map = 'dd', cmd = "lua require('spectre').toggle_line()", diff --git a/lua/spectre/init.lua b/lua/spectre/init.lua index 44a7cc7..0383e0f 100644 --- a/lua/spectre/init.lua +++ b/lua/spectre/init.lua @@ -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', '', "lua require('spectre').tab()", map_opt) - api.nvim_buf_set_keymap(bufnr, 'n', '', "lua require('spectre').tab_shift()", map_opt) api.nvim_buf_set_keymap(bufnr, 'n', 'yy', "lua require('spectre.actions').copy_current_line()", map_opt) api.nvim_buf_set_keymap(bufnr, 'n', '?', "lua require('spectre').show_help()", map_opt)