" navigation.vim — FZF, netrw, buffer/window management, terminal " ── netrw (built-in file browser) ─────────────────────────────────────────── let g:netrw_liststyle = 3 let g:netrw_banner = 0 let g:netrw_browse_split = 4 let g:netrw_winsize = 25 let g:netrw_altv = 1 let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+' let g:netrw_list_hide .= ',\.pyc$,node_modules,\.git,__pycache__,\.DS_Store' function! s:ToggleSidebar(...) abort let l:dir = a:0 ? a:1 : getcwd() if getbufvar(winbufnr(1), '&filetype') ==# 'netrw' && getwinvar(1, '&winfixwidth') let l:cur = winnr() 1wincmd w close if l:cur > 1 execute (l:cur - 1) . 'wincmd w' endif return endif execute 'topleft vertical 30new' execute 'Explore ' . fnameescape(l:dir) setlocal winfixwidth setlocal bufhidden=wipe wincmd p endfunction nnoremap e :call ToggleSidebar() nnoremap E :call ToggleSidebar(expand('%:p:h')) augroup ChopstickNetrw autocmd! autocmd FileType netrw setlocal bufhidden=wipe augroup END " ── FZF ───────────────────────────────────────────────────────────────────── function! s:SmartFiles() abort if isdirectory('.git') || finddir('.git', '.;') !=# '' GFiles else Files endif endfunction if exists('g:plugs["fzf.vim"]') nnoremap :call SmartFiles() nnoremap b :Buffers nnoremap rg :Rg nnoremap rG :RgWord nnoremap rt :Tags nnoremap gF :GFiles nnoremap fh :History nnoremap fc :Commands nnoremap fm :Marks nnoremap fl :BLines nnoremap fL :Lines nnoremap f/ :History/ nnoremap f: :History: endif let g:fzf_layout = { 'down': '40%' } if g:is_tty let g:fzf_preview_window = [] else let g:fzf_preview_window = ['right:50%', 'ctrl-/'] endif if g:is_tty command! -bang -nargs=* Rg \ call fzf#vim#grep( \ 'rg --column --line-number --no-heading --color=always --smart-case -- ' \ .shellescape(), 1, 0) command! -bang GFiles call fzf#vim#gitfiles('', 0) else command! -bang -nargs=* Rg \ call fzf#vim#grep( \ 'rg --column --line-number --no-heading --color=always --smart-case -- ' \ .shellescape(), 1, fzf#vim#with_preview(), 0) command! -bang GFiles call fzf#vim#gitfiles('', fzf#vim#with_preview(), 0) endif if g:is_tty command! -bang -nargs=* RgWord \ call fzf#vim#grep( \ 'rg --column --line-number --no-heading --color=always --smart-case -F -- ' \ .shellescape(expand('')), 1, 0) else command! -bang -nargs=* RgWord \ call fzf#vim#grep( \ 'rg --column --line-number --no-heading --color=always --smart-case -F -- ' \ .shellescape(expand('')), 1, fzf#vim#with_preview(), 0) endif " ── Window Maximize Toggle ────────────────────────────────────────────────── function! s:ToggleMaximize() abort if exists('t:maximize_session') execute t:maximize_session unlet t:maximize_session echo 'Window: restored' else let t:maximize_session = winrestcmd() resize | vertical resize echo 'Window: MAXIMIZED' endif endfunction nnoremap z :call ToggleMaximize() " ── Terminal ──────────────────────────────────────────────────────────────── if has('terminal') nnoremap tv :terminal nnoremap th :terminal ++rows=10 tnoremap tnoremap h tnoremap j tnoremap k tnoremap l endif