From 801f824391c7b7fa705c853240f9aedafbd848c0 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 30 Jan 2022 22:42:56 -0500 Subject: [PATCH] Add some wiki-related changes. Disable automatic NERDTree opening. --- .shell_aliases | 15 +++++++++++++++ .vimrc | 22 ++++++++++------------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/.shell_aliases b/.shell_aliases index 075d103..a1d2d66 100644 --- a/.shell_aliases +++ b/.shell_aliases @@ -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 {}'" diff --git a/.vimrc b/.vimrc index cea9182..fdef6dd 100644 --- a/.vimrc +++ b/.vimrc @@ -23,16 +23,17 @@ else endif let mapleader=" " +nnoremap w yiwq:PI!fd -x cat fzf -q -" 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 :w - set conceallevel=0 " Use 4 spaces @@ -60,7 +59,6 @@ autocmd FileType make setlocal noexpandtab " *** BINDINGS *** " Beautful escapes -inoremap fd l inoremap jj l inoremap jk l inoremap kj l