42 lines
1.5 KiB
VimL
42 lines
1.5 KiB
VimL
function! dead#functions#JumpToNextHeading(direction, count)
|
|
let col = col('.')
|
|
silent execute a:direction ==? 'up' ? '?^#' : '/^#'
|
|
if a:count > 1
|
|
silent execute 'normal! ' . repeat('n', a:direction ==? 'up' && col != 1 ? a:count : a:count - 1)
|
|
endif
|
|
silent execute 'normal! ' . col . '|'
|
|
unlet col
|
|
endfunction
|
|
|
|
function! dead#functions#NewMail()
|
|
let l:path = system('mktemp --tmpdir XXXXXXXXXX.eml')
|
|
execute 'sp' l:path
|
|
" See the help for `skeleton`.
|
|
0r ~/.config/nvim/templates/correo.skeleton | w | $
|
|
endfunction
|
|
command! Mail call dead#functions#NewMail()
|
|
|
|
" Ripgrep advanced
|
|
function! dead#functions#RipgrepFzf(query, fullscreen)
|
|
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true'
|
|
let initial_command = printf(command_fmt, shellescape(a:query))
|
|
let reload_command = printf(command_fmt, '{q}')
|
|
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
|
|
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
|
|
endfunction
|
|
|
|
command! -nargs=* -bang RG call dead#functions#RipgrepFzf(<q-args>, <bang>0)
|
|
|
|
" Git grep
|
|
command! -bang -nargs=* GGrep
|
|
\ call fzf#vim#grep(
|
|
\ 'git grep --line-number '.shellescape(<q-args>), 0,
|
|
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
|
|
|
|
function! dead#functions#FormatFile()
|
|
let b:PlugView=winsaveview()
|
|
exe 'silent normal! gg=G'
|
|
call winrestview(b:PlugView)
|
|
echo 'file indented'
|
|
endfunction
|