You've already forked dotfiles
Adding a keymapping for a global find and replaced based off of file grep via telescope, which feeds into the quickfix list and uses cdo to apply substitute commands to each file and specific word instance chosen.
This commit is contained in:
@@ -34,7 +34,7 @@ vim.keymap.set('n', 'J', 'mzJ`z')
|
|||||||
-- Switch or close buffers in the window
|
-- Switch or close buffers in the window
|
||||||
vim.keymap.set('n', '<leader>n', ':bn<CR>', options)
|
vim.keymap.set('n', '<leader>n', ':bn<CR>', options)
|
||||||
vim.keymap.set('n', '<leader>p', ':bp<CR>', options)
|
vim.keymap.set('n', '<leader>p', ':bp<CR>', options)
|
||||||
vim.keymap.set('n', '<leader>d', ':bp|bd #<CR>', options)
|
vim.keymap.set('n', '<leader>x', ':bp|bd #<CR>', options)
|
||||||
|
|
||||||
-- Toggle spellcheck
|
-- Toggle spellcheck
|
||||||
vim.keymap.set('n', '<leader>s', ':set spell!<CR>', options)
|
vim.keymap.set('n', '<leader>s', ':set spell!<CR>', options)
|
||||||
@@ -56,6 +56,6 @@ vim.keymap.set('n', '<leader>em', function() cf.execute('benchmark') end)
|
|||||||
|
|
||||||
vim.keymap.set('n', '<leader>eo', ':Lexplore<CR>', options)
|
vim.keymap.set('n', '<leader>eo', ':Lexplore<CR>', options)
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>rn', ':%s/<C-r><C-w>//g<Left><Left>', options)
|
-- vim.keymap.set('n', '<leader>rn', ':%s/<C-r><C-w>//g<Left><Left>', options)
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>l', ':Lazy<CR>', options)
|
vim.keymap.set('n', '<leader>l', ':Lazy<CR>', options)
|
||||||
|
|||||||
@@ -3,8 +3,31 @@ return {
|
|||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
local telescope = require('telescope')
|
local telescope = require('telescope')
|
||||||
local actions = require('telescope.actions')
|
local actions = require('telescope.actions')
|
||||||
|
local action_state = require('telescope.actions.state')
|
||||||
local fb_actions = telescope.extensions.file_browser.actions
|
local fb_actions = telescope.extensions.file_browser.actions
|
||||||
|
|
||||||
|
local custom_actions = {}
|
||||||
|
|
||||||
|
function custom_actions.grep_multi_select(prompt_bufnr)
|
||||||
|
local function get_table_size(t)
|
||||||
|
local count = 0
|
||||||
|
for _ in pairs(t) do
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
return count
|
||||||
|
end
|
||||||
|
|
||||||
|
local picker = action_state.get_current_picker(prompt_bufnr)
|
||||||
|
local num_selections = get_table_size(picker:get_multi_selection())
|
||||||
|
|
||||||
|
if num_selections > 1 then
|
||||||
|
actions.send_selected_to_qflist(prompt_bufnr)
|
||||||
|
actions.open_qflist()
|
||||||
|
else
|
||||||
|
actions.file_edit(prompt_bufnr)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
opts.defaults = {
|
opts.defaults = {
|
||||||
file_ignore_patterns = {
|
file_ignore_patterns = {
|
||||||
'.png$',
|
'.png$',
|
||||||
@@ -19,8 +42,12 @@ return {
|
|||||||
layout_config = { prompt_position = 'top' },
|
layout_config = { prompt_position = 'top' },
|
||||||
layout_strategy = 'horizontal',
|
layout_strategy = 'horizontal',
|
||||||
mappings = {
|
mappings = {
|
||||||
|
n = {
|
||||||
|
['<cr>'] = custom_actions.grep_multi_select,
|
||||||
|
},
|
||||||
i = {
|
i = {
|
||||||
['<ESC>'] = actions.close
|
['<ESC>'] = actions.close,
|
||||||
|
['<cr>'] = custom_actions.grep_multi_select,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
prompt_prefix = ' ',
|
prompt_prefix = ' ',
|
||||||
@@ -38,6 +65,9 @@ return {
|
|||||||
preview_cutoff = 9999,
|
preview_cutoff = 9999,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
grep_string = {
|
||||||
|
initial_mode = 'normal',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
opts.extensions = {
|
opts.extensions = {
|
||||||
@@ -59,6 +89,7 @@ return {
|
|||||||
dependencies = {
|
dependencies = {
|
||||||
'nvim-lua/plenary.nvim',
|
'nvim-lua/plenary.nvim',
|
||||||
'nvim-telescope/telescope-file-browser.nvim',
|
'nvim-telescope/telescope-file-browser.nvim',
|
||||||
|
'kevinhwang91/nvim-bqf',
|
||||||
},
|
},
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
@@ -122,6 +153,16 @@ return {
|
|||||||
require('telescope.builtin').lsp_dynamic_workspace_symbols()
|
require('telescope.builtin').lsp_dynamic_workspace_symbols()
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
';g',
|
||||||
|
function()
|
||||||
|
require('telescope.builtin').grep_string({ search = vim.fn.input('Grep For > ')})
|
||||||
|
end
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'<leader>rn',
|
||||||
|
-- custom_actions.grep_multi_select
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'sf',
|
'sf',
|
||||||
function()
|
function()
|
||||||
|
|||||||
Reference in New Issue
Block a user