chore: create cmd the lua way

This commit is contained in:
fiplox 2023-06-21 17:00:59 +02:00
parent 48b5156c7f
commit 6ec4e28ad6
1 changed files with 2 additions and 3 deletions

View File

@ -28,6 +28,7 @@ opt.grepprg = 'rg --vimgrep --no-heading --smart-case --hidden'
opt.grepformat = '%f:%l:%c:%m'
vim.api.nvim_create_user_command('Cd', 'lcd %:p:h', { nargs = 0 })
vim.api.nvim_create_user_command('Grep', 'silent grep! <args> | TroubleToggle quickfix', { nargs = '+' })
local ignore_buftype = { 'quickfix', 'nofile', 'help' }
local ignore_filetype = { 'gitcommit', 'gitrebase', 'svn', 'hgcommit' }
@ -61,7 +62,7 @@ local function run()
if win_last_line == buff_last_line then
-- Set line to last line edited
vim.cmd [[normal! g`"]]
-- Try to center
-- Try to center
elseif buff_last_line - last_line > ((win_last_line - win_first_line) / 2) - 1 then
vim.cmd [[normal! g`"zz]]
else
@ -74,5 +75,3 @@ vim.api.nvim_create_autocmd({ 'BufWinEnter', 'FileType' }, {
group = vim.api.nvim_create_augroup('nvim-lastplace', {}),
callback = run,
})
vim.cmd("command! -nargs=+ Grep execute 'silent grep! <args>' | copen")