Compare commits
3 Commits
78e2309f2f
...
3444377f73
Author | SHA1 | Date | |
---|---|---|---|
3444377f73 | |||
1e1b74f072 | |||
541fe69d57 |
@ -1,50 +1,3 @@
|
|||||||
local actions = require('telescope.actions')
|
|
||||||
local action_state = require('telescope.actions.state')
|
|
||||||
|
|
||||||
-- Custom function for search and replace using Telescope
|
|
||||||
-- test
|
|
||||||
function _G.search_and_replace()
|
|
||||||
local current_file = vim.fn.expand('%:p')
|
|
||||||
local query = vim.fn.input('Enter search pattern: ')
|
|
||||||
|
|
||||||
-- Create the Telescope prompt with custom mappings
|
|
||||||
require('telescope.builtin').find_files({
|
|
||||||
prompt_title = 'Search and Replace',
|
|
||||||
cwd = vim.loop.cwd(),
|
|
||||||
hidden = true,
|
|
||||||
attach_mappings = function(prompt_bufnr, map)
|
|
||||||
actions.select_default:replace(function()
|
|
||||||
local selection = action_state.get_selected_entry()
|
|
||||||
|
|
||||||
-- Get the replace pattern from user
|
|
||||||
local replace_query = vim.fn.input('Replace with: ', '')
|
|
||||||
|
|
||||||
if not replace_query == '' then
|
|
||||||
local args = { query, replace_query }
|
|
||||||
|
|
||||||
-- Open a terminal buffer to run the search and replace command
|
|
||||||
require('telescope.builtin').terminal_job({
|
|
||||||
cmd = {
|
|
||||||
'sh', '-c',
|
|
||||||
string.format(
|
|
||||||
"grep -rl '%s' . | xargs sed -i 's/%s/%s/g'",
|
|
||||||
table.concat(args, "'"),
|
|
||||||
query,
|
|
||||||
replace_query
|
|
||||||
)
|
|
||||||
},
|
|
||||||
cwd = vim.fn.expand('%:p:h'),
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
return true
|
|
||||||
end)
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
-- fuzzy finder
|
-- fuzzy finder
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
@ -77,11 +30,35 @@ return {
|
|||||||
opts.desc = "telescope buffers"
|
opts.desc = "telescope buffers"
|
||||||
vim.keymap.set("n", "<leader>fb", builtin.buffers, opts)
|
vim.keymap.set("n", "<leader>fb", builtin.buffers, opts)
|
||||||
|
|
||||||
opts.desc = "telescope nvim functions"
|
opts.desc = "Show nvim functions"
|
||||||
vim.keymap.set("n", "<leader>fh", builtin.help_tags, opts)
|
vim.keymap.set("n", "<leader>fh", builtin.help_tags, opts)
|
||||||
|
|
||||||
|
-- Recent Commands
|
||||||
|
opts.desc = "Show recent commands"
|
||||||
|
vim.keymap.set('n', '<leader>frc', ':Telescope command_history<CR>', opts)
|
||||||
|
|
||||||
-- Search and replace
|
-- Recent Searches
|
||||||
|
opts.desc = "Show recent searches"
|
||||||
|
vim.keymap.set('n', '<leader>frs', ':Telescope search_history<CR>', opts)
|
||||||
|
|
||||||
|
-- Old Files
|
||||||
|
opts.desc = "Show recent files"
|
||||||
|
vim.keymap.set('n', '<leader>frf', ':Telescope oldfiles<CR>', opts)
|
||||||
|
|
||||||
|
-- Quickfix Items
|
||||||
|
opts.desc = "Show quickfix items"
|
||||||
|
vim.keymap.set('n', '<leader>fq', ':Telescope quickfix<CR>', opts)
|
||||||
|
|
||||||
|
-- Spell Suggestions
|
||||||
|
opts.desc = "Show spell suggestions"
|
||||||
|
vim.keymap.set('n', '<leader>fs', ':Telescope spell_suggest<CR>', opts)
|
||||||
|
|
||||||
|
-- Diagnostics
|
||||||
|
opts.desc = "Show diagnostics"
|
||||||
|
vim.keymap.set('n', '<leader>fd', ':Telescope diagnostics<CR>', opts)
|
||||||
|
|
||||||
|
-- Implementations
|
||||||
|
opts.desc = "Show implementations"
|
||||||
|
vim.keymap.set('n', '<leader>fi', ':Telescope lsp_implementations<CR>', opts)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ return {
|
|||||||
darkgreen = Shade.new("#005602", 0.10, -0.15),
|
darkgreen = Shade.new("#005602", 0.10, -0.15),
|
||||||
darkyellow = Shade.new("#dfd100", 0.10, -0.15),
|
darkyellow = Shade.new("#dfd100", 0.10, -0.15),
|
||||||
yellow = Shade.new("#e3c46d", 0.15, -0.15),
|
yellow = Shade.new("#e3c46d", 0.15, -0.15),
|
||||||
darkblue = Shade.new("#1010aa", 0.15, -0.15),
|
darkblue = Shade.new("#1010cc", 0.15, -0.15),
|
||||||
blue = Shade.new("#7070dd", 0.15, -0.15),
|
blue = Shade.new("#7070dd", 0.15, -0.15),
|
||||||
magenta = Shade.new("#C02490", 0.30, -0.15),
|
magenta = Shade.new("#C02490", 0.30, -0.15),
|
||||||
pink = Shade.new("#ff82c2", 0.15, -0.15),
|
pink = Shade.new("#ff82c2", 0.15, -0.15),
|
||||||
|
@ -3,3 +3,4 @@ config
|
|||||||
Supremum
|
Supremum
|
||||||
Infimum
|
Infimum
|
||||||
iff
|
iff
|
||||||
|
BFS
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user