diff options
Diffstat (limited to '')
-rw-r--r-- | vim/vimrc | 99 |
1 files changed, 96 insertions, 3 deletions
@@ -13,7 +13,100 @@ nnoremap <leader>ev <C-w>s<C-w>j<C-w>L:e $MYVIMRC<cr> let maplocalleader = "\\" let mapleader = " " -" encryption method when using :X +" Function to allow adding a line of text to taskwarrior +function! TaskWarriorAddCurrentLine() + let current_line = getline('.') + silent execute ":!task add " . shellescape(current_line) + redraw! + echo "Task added: " . current_line + delete +endfunction + +nnoremap <leader>q :call TaskWarriorAddCurrentLine()<CR> + + +" redirect any output to a scratch buffer +" from https://gist.github.com/romainl/eae0a260ab9c135390c30cd370c20cd7 +function! Redir(cmd, rng, start, end) + for win in range(1, winnr('$')) + if getwinvar(win, 'scratch') + execute win . 'windo close' + endif + endfor + if a:cmd =~ '^!' + let cmd = a:cmd =~' %' + \ ? matchstr(substitute(a:cmd, ' %', ' ' . shellescape(escape(expand('%:p'), '\')), ''), '^!\zs.*') + \ : matchstr(a:cmd, '^!\zs.*') + if a:rng == 0 + let output = systemlist(cmd) + else + let joined_lines = join(getline(a:start, a:end), '\n') + let cleaned_lines = substitute(shellescape(joined_lines), "'\\\\''", "\\\\'", 'g') + let output = systemlist(cmd . " <<< $" . cleaned_lines) + endif + else + redir => output + execute a:cmd + redir END + let output = split(output, "\n") + endif + vnew + let w:scratch = 1 + setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile + call setline(1, output) +endfunction + +" This command definition includes -bar, so that it is possible to "chain" Vim commands. +" Side effect: double quotes can't be used in external commands +command! -nargs=1 -complete=command -bar -range Redir silent call Redir(<q-args>, <range>, <line1>, <line2>) + +" This command definition doesn't include -bar, so that it is possible to use double quotes in external commands. +" Side effect: Vim commands can't be "chained". +command! -nargs=1 -complete=command -range Redir silent call Redir(<q-args>, <range>, <line1>, <line2>) + +" big from https://gist.github.com/romainl/047aca21e338df7ccf771f96858edb86 +nnoremap ;s :g//#<Left><Left> +function! CCR() + let cmdline = getcmdline() + if cmdline =~ '\v\C^(ls|files|buffers)' + " like :ls but prompts for a buffer command + return "\<CR>:b" + elseif cmdline =~ '\v\C/(#|nu|num|numb|numbe|number)$' + " like :g//# but prompts for a command + return "\<CR>:" + elseif cmdline =~ '\v\C^(dli|il)' + " like :dlist or :ilist but prompts for a count for :djump or :ijump + return "\<CR>:" . cmdline[0] . "j " . split(cmdline, " ")[1] . "\<S-Left>\<Left>" + elseif cmdline =~ '\v\C^(cli|lli)' + " like :clist or :llist but prompts for an error/location number + return "\<CR>:sil " . repeat(cmdline[0], 2) . "\<Space>" + elseif cmdline =~ '\C^old' + " like :oldfiles but prompts for an old file to edit + set nomore + return "\<CR>:sil se more|e #<" + elseif cmdline =~ '\C^changes' + " like :changes but prompts for a change to jump to + set nomore + return "\<CR>:sil se more|norm! g;\<S-Left>" + elseif cmdline =~ '\C^ju' + " like :jumps but prompts for a position to jump to + set nomore + return "\<CR>:sil se more|norm! \<C-o>\<S-Left>" + elseif cmdline =~ '\C^marks' + " like :marks but prompts for a mark to jump to + return "\<CR>:norm! `" + elseif cmdline =~ '\C^undol' + " like :undolist but prompts for a change to undo + return "\<CR>:u " + else + return "\<CR>" + endif +endfunction +cnoremap <expr> <CR> CCR() + + + +" encryptio) method when using :X set cm=blowfish2 " Underline the current line, based on its length. @@ -122,7 +215,7 @@ let g:UltiSnipsEditSplit="vertical" nmap <silent> tn :TestNearest<CR> nmap <silent> tf :TestFile<CR> nmap <silent> ts :TestSuite<CR> -nmap <silent> <leader>tl :TestLast<CR> +nmap <silent> tl :TestLast<CR> nmap <silent> <leader>tv :TestVisit<CR> let test#strategy = "basic" let test#python#pytest#options = '-q -s' @@ -407,7 +500,7 @@ nnoremap <leader>Y :let @+=printf("[%s](%s)", expand('%:t'), "file://" . expand( imap <C-x><C-l> <plug>(fzf-complete-line) " remap :W to :w - :W was previous Windows in fzf -cnoreabbrev W w +command! W w " ghetto note system " Go to index of notes |