Add some wiki-related changes.

Disable automatic NERDTree opening.
This commit is contained in:
Sage Vaillancourt 2022-01-30 22:42:56 -05:00
parent a70bceb09a
commit 801f824391
2 changed files with 25 additions and 12 deletions

View File

@ -4,6 +4,21 @@ function fin {
find -iname "*$@*"
}
function ws {
if [[ "$@" != "" ]]; then
local fzf_args="-q $@"
fi
# fd --type f --search-path ~/wiki -x cat | grep -v "^ *$" | \fzf $fzf_args
local filename="$(rg --with-filename --no-heading . ~/wiki | sed 's@/home/sage/wiki/@@' | fzf $fzf_args -1 --preview='bat ~/wiki/$(echo {} | sed "s/:.*//")' | sed 's/:.*//')"
if [[ "$filename" != "" ]]; then
vim ~/wiki/$filename
fi
}
function ww {
ws $(rg --no-line-number --no-filename . ~/wiki | sed 's/[^a-zA-Z0-9]\+/\n/g' | grep -v "^$" | sort -f | uniq -ci | sort -hr | fzf | cut -c 9-)
}
alias cat="bat"
export FZF_DEFAULT_COMMAND='fd --type f'
alias fzf="fzf --preview 'bat --style=numbers --color=always {}'"

22
.vimrc
View File

@ -23,16 +23,17 @@ else
endif
let mapleader=" "
nnoremap <Leader>w yiwq:PI!fd -x cat <Bar> fzf -q <CR>
" Auto open NERDTree but focus editing window
autocmd VimEnter * NERDTree
autocmd BufEnter * NERDTreeMirror
autocmd VimEnter * wincmd w
autocmd VimEnter * NERDTreeFind
autocmd VimEnter * wincmd w
" Auto close NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
autocmd VimEnter COMMIT_EDITMSG NERDTreeClose
" " Auto open NERDTree but focus editing window
" autocmd VimEnter * NERDTree
" autocmd BufEnter * NERDTreeMirror
" autocmd VimEnter * wincmd w
" autocmd VimEnter * NERDTreeFind
" autocmd VimEnter * wincmd w
" " Auto close NERDTree
" autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" autocmd VimEnter COMMIT_EDITMSG NERDTreeClose
set mouse=a
@ -47,8 +48,6 @@ set foldlevelstart=99
" Leave some room when scrolling
set scrolloff=3
nnoremap :W<CR> :w<CR>
set conceallevel=0
" Use 4 spaces
@ -60,7 +59,6 @@ autocmd FileType make setlocal noexpandtab
" *** BINDINGS ***
" Beautful escapes
inoremap fd <Esc>l
inoremap jj <Esc>l
inoremap jk <Esc>l
inoremap kj <Esc>l