diff --git a/.vimrc b/.vimrc index ab53cf9..38f1116 100644 --- a/.vimrc +++ b/.vimrc @@ -99,6 +99,7 @@ call plug#begin($HOME . '/.vim/bundle') Plug $HOME . '/.vim/bundle/repos/github.com/Shougo/dein.vim' Plug 'let-def/vimbufsync' Plug 'lambdalisue/suda.vim' +Plug 'skywind3000/asyncrun.vim' " Plugins that I almost never use "Plug 'vim-scripts/DrawIt' @@ -222,6 +223,8 @@ nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) imap , (coc-snippets-expand) +imap ff (coc-fix-current) +nmap ff (coc-fix-current) " Use K to show documentation in preview window nnoremap K :call show_documentation() @@ -670,6 +673,7 @@ command! -complete=shellcmd -nargs=+ Shell call s:ExecuteInShellOutput() command! -complete=shellcmd -nargs=+ Exec call s:ExecuteInShell() command! -nargs=* Make call s:ExecuteInShellOutput('make '.) command! -nargs=* PTW call s:ExecuteInShell('ptw post --client=vim "'..'"') +command! -nargs=* CaptureNote :AsyncRun -silent capture --viewing %:p 2>&1 > /dev/null " Highlight all instances of word under cursor, when idle. " Useful when studying strange source code. @@ -806,7 +810,7 @@ inoremap jj " Leader key functions " See quickfix. -nnoremap ff :LFix +"nnoremap ff :LFix " See quickfix. nnoremap ss :SyntasticSetLoclist " Next quickfix. @@ -816,6 +820,8 @@ nnoremap fp :lprev "nnoremap aa :Denite -mode=normal -buffer-name=search-buffer grep nnoremap ac :Denite -resume -buffer-name=search-buffer grep "nnoremap aw :DeniteCursorWord -buffer-name=search-buffer grep +" +nnoremap nn :CaptureNote call denite#custom#map('insert', '', '') "call denite#custom#var('grep', 'command', ['rg']) "call denite#custom#var('grep', 'default_opts', diff --git a/bin/capture b/bin/capture new file mode 100755 index 0000000..0f28e2c --- /dev/null +++ b/bin/capture @@ -0,0 +1,48 @@ +#!/bin/bash +set -euo pipefail + +VAULT_FILE="capture.md" +VAULT_PATH="$HOME/notebook" +FILE_IN_VIEW="" +POSITIONAL=() +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + -f|--file) + VAULT_FILE="$2" + shift # past argument + shift # past value + ;; + --viewing) + FILE_IN_VIEW="$2" + shift + shift + ;; + *) # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; +esac +done + +TO_PATH="${VAULT_PATH}/${VAULT_FILE}" + +cd ${VAULT_PATH} +git pull -q + +echo "" >> ${TO_PATH} +echo "##### `date`" >> ${TO_PATH} +if [ -n "${FILE_IN_VIEW}" ]; then + echo "In file _${FILE_IN_VIEW}_" >> ${TO_PATH} +fi +for s in "${POSITIONAL[@]}" # restore positional parameters +do + echo -n "${s} " >> ${TO_PATH} +done +echo "" >> TO_PATH + +git add ${TO_PATH} +git commit -q -m "capture `date +%FT%T`" +git push -q 2>&1 > /dev/null