dgy
/
hexagons
Archived
1
0
Fork 0
This repository has been archived on 2021-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
hexagons/.config/nvim/autoload/dead/functions.vim

47 lines
1.6 KiB
VimL

function! dead#functions#PopOutOfInsertMode() abort
if v:insertmode
call feedkeys("\<C-\>\<C-n>")
endif
endfunction
function! dead#functions#Relativize(v) abort
if &number
let &cursorline = a:v
endif
endfunction
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)