@@ -108,13 +108,13 @@ require("lazy").setup({
108108 end
109109 },
110110
111- {
112- ' windwp/nvim-autopairs' ,
113- event = " InsertEnter" ,
114- config = true
115- -- use opts = {} for passing setup options
116- -- this is equivalent to setup({}) function
117- },
111+ -- {
112+ -- 'windwp/nvim-autopairs',
113+ -- event = "InsertEnter",
114+ -- config = true
115+ -- -- use opts = {} for passing setup options
116+ -- -- this is equivalent to setup({}) function
117+ -- },
118118
119119 -- FZF-lua for fuzzy finding
120120 { " junegunn/fzf" , build = " ./install --bin" },
@@ -129,7 +129,7 @@ require("lazy").setup({
129129 grep = {
130130 actions = {
131131 -- swapping the bindings for ctrl-r so ctrl-g matches files
132- [" ctrl-r" ] = { actions .grep_lgrep },
132+ [" ctrl-r" ] = { actions .grep_lgrep },
133133 [" ctrl-g" ] = { actions .toggle_ignore },
134134 }
135135 },
@@ -224,3 +224,43 @@ vim.keymap.set("n", "<c-B>", require("fzf-lua").buffers, { desc = "Fzf Buffers"
224224
225225vim .g .copilot_no_tab_map = true
226226vim .api .nvim_set_keymap (" i" , " <C-J>" , ' copilot#Accept("<CR>")' , { silent = true , expr = true })
227+
228+ vim .api .nvim_create_user_command (' ReplaceWord' , function (opts )
229+ -- Ensure we have exactly two arguments
230+ if # opts .fargs ~= 2 then
231+ vim .notify (' ReplaceWord requires exactly two arguments: oldword newword' , vim .log .levels .ERROR )
232+ return
233+ end
234+
235+ local old = opts .fargs [1 ]
236+ local new = opts .fargs [2 ]
237+
238+ -- Escape special characters for the substitution
239+ old = vim .fn .escape (old , ' /\\ ' )
240+ new = vim .fn .escape (new , ' /\\ ' )
241+
242+ -- Get list of Git-tracked files
243+ local files = vim .fn .systemlist (' git ls-files 2>/dev/null' )
244+ if vim .v .shell_error ~= 0 then
245+ vim .notify (' Error: Not in a Git repository or git ls-files failed' , vim .log .levels .ERROR )
246+ return
247+ end
248+
249+ if # files == 0 then
250+ vim .notify (' No files found in Git repository' , vim .log .levels .WARN )
251+ return
252+ end
253+
254+ -- Iterate over files
255+ for _ , file in ipairs (files ) do
256+ -- Ensure file exists and is readable
257+ if vim .fn .filereadable (file ) == 1 then
258+ pcall (function ()
259+ vim .cmd (' edit +0 ' .. vim .fn .fnameescape (file ))
260+ vim .cmd (' silent! %s/' .. old .. ' /' .. new .. ' /g' )
261+ vim .cmd (' update' )
262+ end )
263+ end
264+ end
265+ vim .notify (' Replacement complete in Git-tracked files' , vim .log .levels .INFO )
266+ end , { nargs = ' +' })
0 commit comments