Compare commits

..

13 commits

Author SHA1 Message Date
e3b54f994a search fallback 2026-05-07 11:25:36 -04:00
770106343d rg 2026-05-07 11:23:20 -04:00
7eef7a526d final 2026-05-07 11:13:48 -04:00
d870991836 hide ft 2026-05-07 11:11:04 -04:00
bdee5567a7 cap 2026-05-07 11:08:36 -04:00
4722ec2da4 nav 2026-05-07 11:07:41 -04:00
cb2c54f2a1 fix 2026-05-07 11:06:32 -04:00
5ce1ceea15 grep compat 2026-05-07 11:04:04 -04:00
024b6ee244 lied 2026-05-07 11:02:27 -04:00
26fd7bbb50 final 2026-05-07 10:59:00 -04:00
9c3cbbfbbf more 2026-05-07 10:56:03 -04:00
978f17aa64 more compat 2026-05-07 10:54:28 -04:00
8721c364b1 older compat 2026-05-07 10:50:06 -04:00
3 changed files with 259 additions and 125 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
autoload autoload
plugged plugged
.netrwhist .netrwhist
bin

View file

@ -1,6 +1,5 @@
" anticuus.vim " anticuus.vim
" Pitch-black minimalist theme — port of nvim anticuus + custom syntax extensions. " Pitch-black minimalist theme with 256-color terminal fallbacks.
" Requires `set termguicolors`.
hi clear hi clear
if exists('syntax_on') if exists('syntax_on')
@ -10,133 +9,156 @@ endif
let g:colors_name = 'anticuus' let g:colors_name = 'anticuus'
set background=dark set background=dark
function! s:hi(group, guifg, guibg, ctermfg, ctermbg, gui, cterm)
let l:cmd = 'highlight ' . a:group
if a:guifg !=# ''
let l:cmd .= ' guifg=' . a:guifg
endif
if a:guibg !=# ''
let l:cmd .= ' guibg=' . a:guibg
endif
if a:ctermfg !=# ''
let l:cmd .= ' ctermfg=' . a:ctermfg
endif
if a:ctermbg !=# ''
let l:cmd .= ' ctermbg=' . a:ctermbg
endif
if a:gui !=# ''
let l:cmd .= ' gui=' . a:gui
endif
if a:cterm !=# ''
let l:cmd .= ' cterm=' . a:cterm
endif
execute l:cmd
endfunction
" === Base === " === Base ===
highlight Normal guifg=#dadada guibg=#000000 call s:hi('Normal', '#dadada', '#000000', '253', '16', '', '')
highlight NormalNC guifg=#dadada guibg=#000000 call s:hi('NormalNC', '#dadada', '#000000', '253', '16', '', '')
highlight NonText guifg=#3a3a3a guibg=NONE call s:hi('NonText', '#3a3a3a', 'NONE', '237', 'NONE', '', '')
highlight EndOfBuffer guifg=#000000 guibg=NONE call s:hi('EndOfBuffer', '#000000', 'NONE', '16', 'NONE', '', '')
highlight Whitespace guifg=#3a3a3a call s:hi('Whitespace', '#3a3a3a', '', '237', '', '', '')
highlight SpecialKey guifg=#3a3a3a call s:hi('SpecialKey', '#3a3a3a', '', '237', '', '', '')
" === Syntax: comments dim italic, strings green === " === Syntax: comments dim italic, strings green ===
highlight Comment guifg=#5a5a5a gui=italic cterm=italic call s:hi('Comment', '#5a5a5a', '', '240', '', 'italic', 'italic')
highlight SpecialComment guifg=#5a5a5a gui=italic cterm=italic call s:hi('SpecialComment', '#5a5a5a', '', '240', '', 'italic', 'italic')
highlight String guifg=#00b300 call s:hi('String', '#00b300', '', '34', '', '', '')
highlight Character guifg=#5a5a5a gui=italic cterm=italic call s:hi('Character', '#5a5a5a', '', '240', '', 'italic', 'italic')
" === Literals: purple === " === Literals: purple ===
highlight Number guifg=#c490d0 call s:hi('Number', '#c490d0', '', '176', '', '', '')
highlight Float guifg=#c490d0 call s:hi('Float', '#c490d0', '', '176', '', '', '')
highlight Boolean guifg=#c490d0 call s:hi('Boolean', '#c490d0', '', '176', '', '', '')
highlight Constant guifg=#c490d0 call s:hi('Constant', '#c490d0', '', '176', '', '', '')
" === Identifiers / functions: white baseline, functions teal === " === Identifiers / functions: white baseline, functions teal ===
highlight Identifier guifg=#dadada call s:hi('Identifier', '#dadada', '', '253', '', '', '')
highlight Function guifg=#88ddcc call s:hi('Function', '#88ddcc', '', '116', '', '', '')
" === Statements: yellow keywords, red exception/return === " === Statements: yellow keywords, red exception/return ===
highlight Statement guifg=#ffcc00 call s:hi('Statement', '#ffcc00', '', '220', '', '', '')
highlight Conditional guifg=#ffcc00 call s:hi('Conditional', '#ffcc00', '', '220', '', '', '')
highlight Repeat guifg=#dadada call s:hi('Repeat', '#dadada', '', '253', '', '', '')
highlight Keyword guifg=#ffcc00 call s:hi('Keyword', '#ffcc00', '', '220', '', '', '')
highlight Operator guifg=#dadada call s:hi('Operator', '#dadada', '', '253', '', '', '')
highlight Label guifg=#ffcc00 call s:hi('Label', '#ffcc00', '', '220', '', '', '')
highlight Exception guifg=#ff6b6b call s:hi('Exception', '#ff6b6b', '', '203', '', '', '')
" === PreProc family: green === " === PreProc family: green ===
highlight PreProc guifg=#00b300 call s:hi('PreProc', '#00b300', '', '34', '', '', '')
highlight Include guifg=#00b300 call s:hi('Include', '#00b300', '', '34', '', '', '')
highlight Define guifg=#00b300 call s:hi('Define', '#00b300', '', '34', '', '', '')
highlight Macro guifg=#00b300 call s:hi('Macro', '#00b300', '', '34', '', '', '')
highlight PreCondit guifg=#00b300 call s:hi('PreCondit', '#00b300', '', '34', '', '', '')
" === Types: amber === " === Types: amber ===
highlight Type guifg=#e8a060 call s:hi('Type', '#e8a060', '', '215', '', '', '')
highlight StorageClass guifg=#e8a060 call s:hi('StorageClass', '#e8a060', '', '215', '', '', '')
highlight Structure guifg=#e8a060 call s:hi('Structure', '#e8a060', '', '215', '', '', '')
highlight Typedef guifg=#e8a060 call s:hi('Typedef', '#e8a060', '', '215', '', '', '')
" === Special: green for special chars, red for tags === " === Special: green for special chars, red for tags ===
highlight Special guifg=#00b300 call s:hi('Special', '#00b300', '', '34', '', '', '')
highlight SpecialChar guifg=#00b300 call s:hi('SpecialChar', '#00b300', '', '34', '', '', '')
highlight Tag guifg=#ff6b6b call s:hi('Tag', '#ff6b6b', '', '203', '', '', '')
highlight Delimiter guifg=#dadada call s:hi('Delimiter', '#dadada', '', '253', '', '', '')
" === Errors / Todo === " === Errors / Todo ===
highlight Error guifg=#ff6b6b call s:hi('Error', '#ff6b6b', '', '203', '', '', '')
highlight Todo guifg=#ffcc00 gui=bold cterm=bold call s:hi('Todo', '#ffcc00', '', '220', '', 'bold', 'bold')
" === Line numbers / cursor / columns === " === Line numbers / cursor / columns ===
highlight LineNr guifg=#dadada guibg=NONE call s:hi('LineNr', '#dadada', 'NONE', '253', 'NONE', '', '')
highlight CursorLineNr guifg=#dadada guibg=#282828 gui=bold cterm=bold call s:hi('CursorLineNr', '#dadada', '#282828', '253', '235', 'bold', 'bold')
highlight CursorLine guibg=#121212 call s:hi('CursorLine', '', '#121212', '', '233', 'NONE', 'NONE')
highlight CursorColumn guibg=#121212 call s:hi('CursorColumn', '', '#121212', '', '233', '', '')
highlight ColorColumn guibg=#1a1a1a call s:hi('ColorColumn', '', '#1a1a1a', '', '234', '', '')
highlight SignColumn guifg=#00b300 guibg=#000000 call s:hi('SignColumn', '#00b300', '#000000', '34', '16', '', '')
" === Splits / status / winbar === " === Splits / status / winbar ===
highlight VertSplit guifg=#3a3a3a guibg=NONE call s:hi('VertSplit', '#3a3a3a', 'NONE', '237', 'NONE', '', '')
highlight WinSeparator guifg=#3a3a3a guibg=NONE call s:hi('WinSeparator', '#3a3a3a', 'NONE', '237', 'NONE', '', '')
highlight StatusLine guifg=#dadada guibg=#000000 call s:hi('StatusLine', '#dadada', '#000000', '253', '16', '', '')
highlight StatusLineNC guifg=#dadada guibg=#000000 call s:hi('StatusLineNC', '#dadada', '#000000', '253', '16', '', '')
highlight WinBar guifg=#dadada gui=bold cterm=bold call s:hi('WinBar', '#dadada', '', '253', '', 'bold', 'bold')
highlight WinBarNC guifg=#888888 call s:hi('WinBarNC', '#888888', '', '245', '', '', '')
" === Visual / search === " === Visual / search ===
highlight Visual guibg=#3a3a3a call s:hi('Visual', '', '#3a3a3a', '', '237', '', '')
highlight VisualNOS guibg=#3a3a3a call s:hi('VisualNOS', '', '#3a3a3a', '', '237', '', '')
highlight Search guifg=#000000 guibg=#ffcc00 call s:hi('Search', '#000000', '#ffcc00', '16', '220', '', '')
highlight IncSearch guifg=#000000 guibg=#88ddcc call s:hi('IncSearch', '#000000', '#88ddcc', '16', '116', '', '')
highlight CurSearch guifg=#000000 guibg=#c490d0 call s:hi('CurSearch', '#000000', '#c490d0', '16', '176', '', '')
" === Brackets === " === Brackets ===
highlight MatchParen guifg=#c490d0 gui=bold,underline cterm=bold,underline call s:hi('MatchParen', '#c490d0', '', '176', '', 'bold,underline', 'bold,underline')
" === Popup menu (completion / fzf overlay) === " === Popup menu (completion / fzf overlay) ===
highlight Pmenu guifg=#dadada guibg=#181818 call s:hi('Pmenu', '#dadada', '#181818', '253', '234', '', '')
highlight PmenuSel guifg=#000000 guibg=#ffcc00 call s:hi('PmenuSel', '#000000', '#ffcc00', '16', '220', '', '')
highlight PmenuSbar guibg=#181818 call s:hi('PmenuSbar', '', '#181818', '', '234', '', '')
highlight PmenuThumb guibg=#3a3a3a call s:hi('PmenuThumb', '', '#3a3a3a', '', '237', '', '')
" === Folds / titles / directories === " === Folds / titles / directories ===
highlight Folded guifg=#888888 gui=italic cterm=italic call s:hi('Folded', '#888888', '', '245', '', 'italic', 'italic')
highlight FoldColumn guifg=#888888 guibg=NONE call s:hi('FoldColumn', '#888888', 'NONE', '245', 'NONE', '', '')
highlight Title guifg=#88ddcc gui=bold cterm=bold call s:hi('Title', '#88ddcc', '', '116', '', 'bold', 'bold')
highlight Directory guifg=#88ddcc call s:hi('Directory', '#88ddcc', '', '116', '', '', '')
" === Diff === " === Diff ===
highlight DiffAdd guifg=#a5d6a7 guibg=#0a2010 call s:hi('DiffAdd', '#a5d6a7', '#0a2010', '151', '22', '','')
highlight DiffChange guifg=#e8a060 guibg=#201a0a call s:hi('DiffChange', '#e8a060', '#201a0a', '215', '58', '','')
highlight DiffDelete guifg=#ff6b6b guibg=#200a0a call s:hi('DiffDelete', '#ff6b6b', '#200a0a', '203', '52', '','')
highlight DiffText guifg=#ffcc00 guibg=#3a2000 gui=bold cterm=bold call s:hi('DiffText', '#ffcc00', '#3a2000', '220', '94', 'bold', 'bold')
" === Spell === " === Spell ===
highlight SpellBad guisp=#ff6b6b gui=undercurl cterm=underline highlight SpellBad guisp=#ff6b6b gui=undercurl cterm=underline
highlight SpellCap guisp=#ffcc00 gui=undercurl cterm=underline highlight SpellCap guisp=#ffcc00 gui=undercurl cterm=underline
highlight SpellRare guisp=#c490d0 gui=undercurl cterm=underline highlight SpellRare guisp=#c490d0 gui=undercurl cterm=underline
highlight SpellLocal guisp=#88ddcc gui=undercurl cterm=undercurl highlight SpellLocal guisp=#88ddcc gui=undercurl cterm=underline
" === Markdown (vim's built-in syntax) === " === Markdown (vim's built-in syntax) ===
highlight markdownH1 guifg=#00b300 gui=bold cterm=bold call s:hi('markdownH1', '#00b300', '', '34', '', 'bold', 'bold')
highlight markdownH2 guifg=#00b300 gui=bold cterm=bold call s:hi('markdownH2', '#00b300', '', '34', '', 'bold', 'bold')
highlight markdownH3 guifg=#00b300 gui=bold cterm=bold call s:hi('markdownH3', '#00b300', '', '34', '', 'bold', 'bold')
highlight markdownH4 guifg=#00b300 gui=bold cterm=bold call s:hi('markdownH4', '#00b300', '', '34', '', 'bold', 'bold')
highlight markdownH5 guifg=#00b300 gui=bold cterm=bold call s:hi('markdownH5', '#00b300', '', '34', '', 'bold', 'bold')
highlight markdownH6 guifg=#00b300 gui=bold cterm=bold call s:hi('markdownH6', '#00b300', '', '34', '', 'bold', 'bold')
highlight markdownHeadingDelimiter guifg=#00b300 gui=bold cterm=bold call s:hi('markdownHeadingDelimiter', '#00b300', '', '34', '', 'bold', 'bold')
highlight markdownLinkText guifg=#88ddcc gui=underline cterm=underline call s:hi('markdownLinkText', '#88ddcc', '', '116', '', 'underline', 'underline')
highlight markdownUrl guifg=#5a5a5a gui=italic cterm=italic call s:hi('markdownUrl', '#5a5a5a', '', '240', '', 'italic', 'italic')
highlight markdownCode guifg=#e8a060 call s:hi('markdownCode', '#e8a060', '', '215', '', '', '')
highlight markdownCodeBlock guifg=#e8a060 call s:hi('markdownCodeBlock', '#e8a060', '', '215', '', '', '')
" === Diagnostic groups (for plugins like ALE/CoC) === " === Diagnostic groups (for plugins like ALE/CoC) ===
highlight DiagnosticError guifg=#ff6b6b call s:hi('DiagnosticError', '#ff6b6b', '', '203', '', '', '')
highlight DiagnosticWarn guifg=#ffcc00 call s:hi('DiagnosticWarn', '#ffcc00', '', '220', '', '', '')
highlight DiagnosticInfo guifg=#00b300 call s:hi('DiagnosticInfo', '#00b300', '', '34', '', '', '')
highlight DiagnosticHint guifg=#dadada call s:hi('DiagnosticHint', '#dadada', '', '253', '', '', '')
highlight link ALEErrorSign DiagnosticError highlight link ALEErrorSign DiagnosticError
highlight link ALEWarningSign DiagnosticWarn highlight link ALEWarningSign DiagnosticWarn
highlight link ALEInfoSign DiagnosticInfo highlight link ALEInfoSign DiagnosticInfo
" === vim-highlightedyank === " === vim-highlightedyank ===
highlight HighlightedyankRegion guifg=#000000 guibg=#ffcc00 call s:hi('HighlightedyankRegion', '#000000', '#ffcc00', '16', '220', '', '')

179
vimrc
View file

@ -1,24 +1,42 @@
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' let data_dir = '~/.vim'
if executable(expand('~/.vim/bin/rg'))
let $PATH = expand('~/.vim/bin') . ':' . $PATH
endif
if empty(glob(data_dir . '/autoload/plug.vim')) if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
endif endif
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) augroup vimrc_plug_install
autocmd!
autocmd VimEnter * if exists('g:plugs') && len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
\| PlugInstall --sync | source $MYVIMRC \| PlugInstall --sync | source $MYVIMRC
\| endif \| endif
augroup END
call plug#begin('~/.vim/plugged') call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-surround' Plug 'tpope/vim-surround'
Plug 'jiangmiao/auto-pairs' Plug 'jiangmiao/auto-pairs'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf', { 'do': './install --all' }
if v:version < 800
Plug 'junegunn/fzf.vim', { 'commit': '5ab282c2f4a597fa655f39f36e7ee8e97bf51650' }
else
Plug 'junegunn/fzf.vim' Plug 'junegunn/fzf.vim'
endif
Plug 'mtdl9/vim-log-highlighting' Plug 'mtdl9/vim-log-highlighting'
Plug 'machakann/vim-highlightedyank'
Plug 'osyo-manga/vim-anzu' Plug 'osyo-manga/vim-anzu'
if v:version < 800 && has('timers')
Plug 'machakann/vim-highlightedyank', { 'commit': '03fe057c5836a3f3897a943dc96bdfe3f087890e' }
elseif v:version >= 800
Plug 'machakann/vim-highlightedyank'
endif
call plug#end() call plug#end()
let mapleader = "\<Space>" let mapleader = "\<Space>"
set background=dark set background=dark
if !has('gui_running') && &t_Co < 256
set t_Co=256
endif
if has('termguicolors') if has('termguicolors')
set termguicolors set termguicolors
endif endif
@ -26,8 +44,8 @@ silent! colorscheme anticuus
highlight Normal ctermbg=NONE guibg=NONE ctermfg=White guifg=#FFFFFF highlight Normal ctermbg=NONE guibg=NONE ctermfg=White guifg=#FFFFFF
highlight NonText ctermbg=NONE guibg=NONE highlight NonText ctermbg=NONE guibg=NONE
highlight CursorLine ctermbg=NONE guibg=NONE highlight CursorLine term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE
highlight CursorLineNr ctermfg=Yellow guifg=#E5C07B ctermbg=NONE guibg=NONE cterm=bold gui=bold highlight CursorLineNr term=bold ctermfg=Yellow guifg=#E5C07B ctermbg=NONE guibg=NONE cterm=bold gui=bold
highlight HighlightedyankRegion ctermfg=Black guifg=#000000 ctermbg=Yellow guibg=yellow highlight HighlightedyankRegion ctermfg=Black guifg=#000000 ctermbg=Yellow guibg=yellow
highlight NormalNC ctermbg=NONE guibg=NONE highlight NormalNC ctermbg=NONE guibg=NONE
highlight Search ctermfg=Black guifg=#000000 ctermbg=Yellow guibg=#FFCC66 highlight Search ctermfg=Black guifg=#000000 ctermbg=Yellow guibg=#FFCC66
@ -35,6 +53,11 @@ highlight LineNr ctermbg=NONE guibg=NONE
highlight Visual ctermbg=Gray guibg=Gray ctermfg=Black guifg=Black highlight Visual ctermbg=Gray guibg=Gray ctermfg=Black guifg=Black
let g:highlightedyank_highlight_duration = 140 let g:highlightedyank_highlight_duration = 140
if v:version < 800 && has('timers')
nmap y <Plug>(highlightedyank)
xmap y <Plug>(highlightedyank)
omap y <Plug>(highlightedyank)
endif
let $FZF_DEFAULT_OPTS = '--bind=tab:up,shift-tab:down' let $FZF_DEFAULT_OPTS = '--bind=tab:up,shift-tab:down'
let g:fzf_layout = { 'window': 'enew' } let g:fzf_layout = { 'window': 'enew' }
@ -46,10 +69,21 @@ let g:netrw_liststyle = 3
let g:netrw_browse_split = 4 let g:netrw_browse_split = 4
let g:netrw_altv = 1 let g:netrw_altv = 1
autocmd FileType netrw nnoremap <buffer> <C-l> :wincmd l<CR> augroup vimrc_netrw
autocmd FileType netrw nnoremap <buffer> <C-h> :wincmd h<CR> autocmd!
autocmd FileType netrw nnoremap <buffer> <C-j> :wincmd j<CR> autocmd FileType,BufEnter,BufWinEnter * call HideNetrwBuffer()
autocmd FileType netrw nnoremap <buffer> <C-k> :wincmd k<CR> autocmd FileType netrw nnoremap <buffer> <C-l> :wincmd l<CR>
autocmd FileType netrw nnoremap <buffer> <C-h> :wincmd h<CR>
autocmd FileType netrw nnoremap <buffer> <C-j> :wincmd j<CR>
autocmd FileType netrw nnoremap <buffer> <C-k> :wincmd k<CR>
augroup END
augroup vimrc_quickfix
autocmd!
autocmd FileType qf nnoremap <buffer> <Tab> j
autocmd FileType qf nnoremap <buffer> <S-Tab> k
autocmd FileType qf nnoremap <buffer> <CR> <CR>:cclose<CR>
augroup END
set laststatus=2 set laststatus=2
@ -65,8 +99,12 @@ set smartcase
set clipboard=unnamedplus set clipboard=unnamedplus
set noswapfile set noswapfile
set nobackup set nobackup
set undofile if exists('&undofile')
set undodir=~/.vim/undodir set undofile
if exists('&undodir')
set undodir=~/.vim/undodir
endif
endif
set hidden set hidden
@ -75,7 +113,9 @@ set shiftwidth=2
set softtabstop=2 set softtabstop=2
set expandtab set expandtab
set smartindent set smartindent
set fillchars=eob:\ if v:version >= 800
set fillchars=eob:\
endif
set statusline=%{exists('*anzu#search_status')?anzu#search_status():''} set statusline=%{exists('*anzu#search_status')?anzu#search_status():''}
@ -89,35 +129,63 @@ function! NetrwToggle()
endif endif
endfor endfor
let g:netrw_return_win = winnr() let g:netrw_return_win = winnr()
if exists(':Lexplore') == 2
Lexplore Lexplore
else
execute 'topleft vertical ' . g:netrw_winsize . 'new'
Explore
endif
endfunction endfunction
function! SafeWincmd(dir) function! SafeWincmd(dir)
let target = winnr(a:dir) let l:current = winnr()
if target == winnr()
return
endif
if getbufvar(winbufnr(target), '&filetype') ==# 'netrw'
return
endif
execute 'wincmd ' . a:dir execute 'wincmd ' . a:dir
if winnr() == l:current
return
endif
if &filetype ==# 'netrw'
execute l:current . 'wincmd w'
endif
endfunction endfunction
function! GitRoot() function! GitRoot()
let l:root = systemlist('git rev-parse --show-toplevel') let l:root = substitute(system('git rev-parse --show-toplevel'), '\n\+$', '', '')
if v:shell_error == 0 && !empty(l:root) && !empty(l:root[0]) if v:shell_error == 0 && !empty(l:root)
return l:root[0] return l:root
endif endif
return getcwd() return getcwd()
endfunction endfunction
function! FzfRg()
if exists(':Rg') != 2 && exists(':grep') != 2
echohl WarningMsg | echom 'No project search command is available' | echohl None
return
endif
execute 'lcd ' . fnameescape(GitRoot())
if executable('rg') && exists(':Rg') == 2
Rg
else
let l:query = input('Search: ')
if empty(l:query)
return
endif
let l:results = system('grep -RIn -e ' . shellescape(l:query) . ' . 2>/dev/null')
if empty(l:results)
echohl WarningMsg | echom 'No matches found' | echohl None
return
endif
cgetexpr split(l:results, "\n")
copen
endif
endfunction
function! SafeBdelete() function! SafeBdelete()
if &filetype ==# 'netrw' if &filetype ==# 'netrw'
echohl WarningMsg | echom 'Cannot delete buffer from netrw' | echohl None echohl WarningMsg | echom 'Cannot delete buffer from netrw' | echohl None
return return
endif endif
let l:buflisted = getbufinfo({'buflisted': 1}) let l:buflisted = filter(range(1, bufnr('$')), 'buflisted(v:val)')
if len(l:buflisted) <= 1 if len(l:buflisted) <= 1
echohl WarningMsg | echom 'Cannot delete last buffer' | echohl None echohl WarningMsg | echom 'Cannot delete last buffer' | echohl None
return return
@ -128,6 +196,46 @@ function! SafeBdelete()
execute 'bdelete ' . l:buf execute 'bdelete ' . l:buf
endfunction endfunction
function! IsNetrwBuffer(buf)
let l:name = bufname(a:buf)
return getbufvar(a:buf, '&filetype') =~# '^netrw'
\ || fnamemodify(l:name, ':t') ==# 'NetrwTreeListing'
\ || (!empty(l:name) && isdirectory(l:name))
endfunction
function! HideNetrwBuffer()
if IsNetrwBuffer(bufnr('%'))
setlocal nobuflisted
endif
endfunction
function! ListedFileBuffers()
return filter(range(1, bufnr('$')), 'buflisted(v:val) && !IsNetrwBuffer(v:val)')
endfunction
function! SafeBnext(dir)
let l:buffers = ListedFileBuffers()
if empty(l:buffers)
return
endif
let l:current = bufnr('%')
let l:index = index(l:buffers, l:current)
if l:index < 0
let l:index = 0
elseif a:dir > 0
let l:index = (l:index + 1) % len(l:buffers)
else
let l:index = (l:index - 1 + len(l:buffers)) % len(l:buffers)
endif
execute 'buffer ' . l:buffers[l:index]
endfunction
if exists(':Buffers') == 2
command! -bar -bang -nargs=? -complete=buffer Buffers call fzf#vim#buffers(<q-args>, ListedFileBuffers(), fzf#vim#with_preview({ 'placeholder': '{1}' }), <bang>0)
endif
" --- Plugin management --- " --- Plugin management ---
nnoremap <leader>pu :PlugUpdate<CR> nnoremap <leader>pu :PlugUpdate<CR>
nnoremap <leader>pd :PlugUpgrade<CR> nnoremap <leader>pd :PlugUpgrade<CR>
@ -150,13 +258,14 @@ vnoremap > >gv
nnoremap <C-U> <C-U>zz nnoremap <C-U> <C-U>zz
nnoremap <C-D> <C-D>zz nnoremap <C-D> <C-D>zz
" --- Window navigation (matches nvim <C-h/j/k/l>, skips netrw) --- " --- Window navigation (skips netrw) ---
nnoremap <C-h> :call SafeWincmd('h')<CR> nnoremap <silent> <C-h> :call SafeWincmd('h')<CR>
nnoremap <C-j> :call SafeWincmd('j')<CR> nnoremap <silent> <BS> :call SafeWincmd('h')<CR>
nnoremap <C-k> :call SafeWincmd('k')<CR> nnoremap <silent> <C-j> :call SafeWincmd('j')<CR>
nnoremap <C-l> :call SafeWincmd('l')<CR> nnoremap <silent> <C-k> :call SafeWincmd('k')<CR>
nnoremap <silent> <C-l> :call SafeWincmd('l')<CR>
" --- Window resize (matches nvim <C-Arrow>) --- " --- Window resize ---
nnoremap <C-Right> :vertical resize +10<CR> nnoremap <C-Right> :vertical resize +10<CR>
nnoremap <C-Left> :vertical resize -10<CR> nnoremap <C-Left> :vertical resize -10<CR>
nnoremap <C-Up> :resize +10<CR> nnoremap <C-Up> :resize +10<CR>
@ -172,7 +281,7 @@ nnoremap <leader>wW :wincmd W<CR>
" --- File explorer & search --- " --- File explorer & search ---
nnoremap <leader>e :call NetrwToggle()<CR> nnoremap <leader>e :call NetrwToggle()<CR>
nnoremap <leader>/ :execute 'lcd ' . fnameescape(GitRoot()) <Bar> Rg<Space> nnoremap <leader>/ :call FzfRg()<CR>
nnoremap <leader>ff :execute 'lcd ' . fnameescape(GitRoot()) <Bar> Files<CR> nnoremap <leader>ff :execute 'lcd ' . fnameescape(GitRoot()) <Bar> Files<CR>
nnoremap <leader>fp :History<CR> nnoremap <leader>fp :History<CR>
nnoremap <leader>fb :Buffers<CR> nnoremap <leader>fb :Buffers<CR>
@ -180,11 +289,13 @@ nnoremap <leader>? :History:<CR>
" --- Buffers --- " --- Buffers ---
nnoremap <leader>bd :call SafeBdelete()<CR> nnoremap <leader>bd :call SafeBdelete()<CR>
nnoremap H :bprevious<CR> nnoremap H :call SafeBnext(-1)<CR>
nnoremap L :bnext<CR> nnoremap L :call SafeBnext(1)<CR>
" --- Terminal --- " --- Terminal ---
nnoremap <leader>t :below terminal ++rows=10<CR> if exists(':terminal') == 2
nnoremap <leader>t :below terminal ++rows=10<CR>
endif
" --- Misc --- " --- Misc ---
nnoremap <Leader>ts :execute "normal! a" . strftime('[%b %d %H:%M:%S - BR]')<CR> nnoremap <Leader>ts :execute "normal! a" . strftime('[%b %d %H:%M:%S - BR]')<CR>