Skip to content

Commit

Permalink
nvim: change spectre keybindings
Browse files Browse the repository at this point in the history
  • Loading branch information
massix committed Jan 7, 2024
1 parent 81e7f03 commit a51f461
Showing 1 changed file with 76 additions and 1 deletion.
77 changes: 76 additions & 1 deletion nvim/lua/plugins/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,82 @@ return {
{
"nvim-pack/nvim-spectre",
cmd = "Spectre",
opts = { open_cmd = "noswapfile vnew" },
opts = {
open_cmd = "noswapfile vnew",
mapping = {
['toggle_line'] = {
map = "dd",
cmd = "<cmd>lua require('spectre').toggle_line()<CR>",
desc = "toggle item"
},
['enter_file'] = {
map = "<cr>",
cmd = "<cmd>lua require('spectre.actions').select_entry()<CR>",
desc = "open file"
},
['send_to_qf'] = {
map = "<C-x>q",
cmd = "<cmd>lua require('spectre.actions').send_to_qf()<CR>",
desc = "send all items to quickfix"
},
['replace_cmd'] = {
map = "<C-x>c",
cmd = "<cmd>lua require('spectre.actions').replace_cmd()<CR>",
desc = "input replace command"
},
['show_option_menu'] = {
map = "<C-x>o",
cmd = "<cmd>lua require('spectre').show_options()<CR>",
desc = "show options"
},
['run_current_replace'] = {
map = "<C-x>rc",
cmd = "<cmd>lua require('spectre.actions').run_current_replace()<CR>",
desc = "replace current line"
},
['run_replace'] = {
map = "<C-x>R",
cmd = "<cmd>lua require('spectre.actions').run_replace()<CR>",
desc = "replace all"
},
['change_view_mode'] = {
map = "<C-x>v",
cmd = "<cmd>lua require('spectre').change_view()<CR>",
desc = "change result view mode"
},
['change_replace_sed'] = {
map = "trs",
cmd = "<cmd>lua require('spectre').change_engine_replace('sed')<CR>",
desc = "use sed to replace"
},
['change_replace_oxi'] = {
map = "tro",
cmd = "<cmd>lua require('spectre').change_engine_replace('oxi')<CR>",
desc = "use oxi to replace"
},
['toggle_live_update']={
map = "tu",
cmd = "<cmd>lua require('spectre').toggle_live_update()<CR>",
desc = "update when vim writes to file"
},
['toggle_ignore_case'] = {
map = "ti",
cmd = "<cmd>lua require('spectre').change_options('ignore-case')<CR>",
desc = "toggle ignore case"
},
['toggle_ignore_hidden'] = {
map = "th",
cmd = "<cmd>lua require('spectre').change_options('hidden')<CR>",
desc = "toggle search hidden"
},
['resume_last_search'] = {
map = "<C-x>l",
cmd = "<cmd>lua require('spectre').resume_last_search()<CR>",
desc = "repeat last search"
},
-- you can put your mapping here it only use normal mode
},
},
-- stylua: ignore
keys = {
{ "<leader>sr", function() require("spectre").open() end, desc = "Replace in files (Spectre)" },
Expand Down

0 comments on commit a51f461

Please sign in to comment.