Files
dotfiles/nvim/lua/custom_commands.lua
FaultyBranches 114d764b18 cleanup: Removing extraneous items that are meant for development work
and experimental settings rather than the official stable setup
2026-08-12 10:36:57 -05:00

22 lines
1.1 KiB
Lua

vim.api.nvim_create_user_command('FindAndReplace', function(opts)
-- Update each quickfix location using substitute, update the files to save changes, close the opened buffers and close the quickfix window
vim.api.nvim_command(string.format('cfdo s/%s/%s/gc', opts.fargs[1], opts.fargs[2]) .. '| update | cclose')
end, { nargs = '*' })
-- Installs tree-sitter plugins for languages from the luarocks repo
-- Takes a space separated list of arguments of language names, tacks them onto the tree-sitter- package names and runs the install
vim.api.nvim_create_user_command('TreeSitterInstall', function(opts)
for index, value in ipairs(opts.fargs) do
if index > 0 then
local result = vim.system({ 'luarocks', '--local', '--lua-version', '5.1', 'install', 'tree-sitter-' .. value }, { text = true }):wait()
if result.code == 0 then
print('Completed install of tree-sitter-' .. value)
else
print('Failed to install tree-sitter-' .. value)
print(result.stdout)
end
end
end
end, { nargs = '*' })