commit 8c8a4e4a7afd175be2eb97055bb01f43ee8b992d Author: Bryan Ramos Date: Wed Apr 15 21:06:39 2026 -0400 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b6a61f0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +autoload +plugged +.netrwhist diff --git a/README.md b/README.md new file mode 100644 index 0000000..4d23289 --- /dev/null +++ b/README.md @@ -0,0 +1,74 @@ +# Vim Config + +Lightweight Vim config that mirrors the core editing feel of the Neovim setup without the IDE stack. + +## Install + +```bash +git clone git@github.com:itme-brain/vim.git ~/.vim +vim # plugins auto-install on first run +``` + +Requires `curl` and `git` for vim-plug bootstrap. On NixOS this is managed via home-manager instead. + +## How it works + +- Vim auto-loads `~/.vim/vimrc` — no symlinks needed +- [vim-plug](https://github.com/junegunn/vim-plug) auto-downloads itself via curl on first run if missing +- Missing plugins are installed with `PlugInstall --sync` on `VimEnter`, then the vimrc is re-sourced +- `silent! colorscheme` suppresses errors if the colorscheme hasn't been fetched yet (e.g. offline first run) +- Undo history persists to `~/.vim/undodir` across sessions (`undofile`) + +## Plugins + +| Plugin | What it does | +|--------|-------------| +| base16-vim | Colorscheme (onedark) | +| vim-surround | Surround text objects (`cs"'`, `ysiw]`) | +| auto-pairs | Auto-close brackets/quotes | +| fzf + fzf.vim | Fuzzy finder (files, buffers, grep) | +| vim-log-highlighting | Syntax highlighting for log files | +| vim-highlightedyank | Flash feedback on yank | +| lightline.vim | Statusline | +| vim-anzu | Search match count in statusline | + +## Keybinds + +Leader is `Space`. + +### File explorer & search +| Key | Action | +|-----|--------| +| `e` | Toggle netrw sidebar | +| `/` | Ripgrep search from git root | +| `ff` | Find files from git root (fzf) | +| `fp` | Recent files (fzf) | +| `fb` | Open buffers (fzf) | +| `?` | Command history (fzf) | + +### Buffers +| Key | Action | +|-----|--------| +| `H` / `L` | Previous / next buffer | +| `bd` | Delete buffer safely | + +### Windows +| Key | Action | +|-----|--------| +| `` | Navigate windows (skips netrw) | +| `` | Resize windows | +| `wc` | Close window | +| `ws` | Horizontal split | +| `wv` | Vertical split | +| `wm` | Maximize window | + +### Other +| Key | Action | +|-----|--------| +| `` | Clear search highlight | +| `` / `` | Scroll half-page (centered) | +| `<` / `>` (visual) | Indent and keep selection | +| `t` | Terminal (bottom split) | +| `ts` | Insert timestamp | +| `pu` | PlugUpdate | +| `pi` | PlugInstall | diff --git a/vimrc b/vimrc new file mode 100644 index 0000000..7a526d5 --- /dev/null +++ b/vimrc @@ -0,0 +1,193 @@ +let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.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' +endif + +autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) + \| PlugInstall --sync | source $MYVIMRC + \| endif + +call plug#begin('~/.vim/plugged') + Plug 'chriskempson/base16-vim' + Plug 'tpope/vim-surround' + Plug 'jiangmiao/auto-pairs' + Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } + Plug 'junegunn/fzf.vim' + Plug 'mtdl9/vim-log-highlighting' + Plug 'machakann/vim-highlightedyank' + Plug 'itchyny/lightline.vim' + Plug 'osyo-manga/vim-anzu' +call plug#end() + +let mapleader = "\" +set background=dark +if has('termguicolors') + set termguicolors +endif +silent! colorscheme base16-onedark + +highlight Normal ctermbg=NONE guibg=NONE ctermfg=White guifg=#FFFFFF +highlight NonText ctermbg=NONE guibg=NONE +highlight CursorLine ctermbg=NONE guibg=NONE +highlight CursorLineNr ctermfg=Yellow guifg=#E5C07B ctermbg=NONE guibg=NONE cterm=bold gui=bold +highlight HighlightedyankRegion ctermfg=Black guifg=#000000 ctermbg=Yellow guibg=yellow +highlight NormalNC ctermbg=NONE guibg=NONE +highlight Search ctermfg=Black guifg=#000000 ctermbg=Yellow guibg=#FFCC66 +highlight LineNr ctermbg=NONE guibg=NONE +highlight Visual ctermbg=Gray guibg=Gray ctermfg=Black guifg=Black + +let g:highlightedyank_highlight_duration = 140 +let g:lightline = { 'colorscheme': 'deus', } + +let $FZF_DEFAULT_OPTS = '--bind=tab:up,shift-tab:down' +let g:fzf_layout = { 'window': 'enew' } + +" netrw settings +let g:netrw_banner = 0 +let g:netrw_winsize = 20 +let g:netrw_liststyle = 3 +let g:netrw_browse_split = 4 +let g:netrw_altv = 1 + +autocmd FileType netrw nnoremap :wincmd l +autocmd FileType netrw nnoremap :wincmd h +autocmd FileType netrw nnoremap :wincmd j +autocmd FileType netrw nnoremap :wincmd k + +set laststatus=2 + +set number +set relativenumber +set cursorline +set scrolloff=8 + +set noincsearch +set ignorecase +set smartcase + +set clipboard=unnamedplus +set noswapfile +set nobackup +set undofile +set undodir=~/.vim/undodir + +set hidden + +set tabstop=2 +set shiftwidth=2 +set softtabstop=2 +set expandtab +set smartindent +set fillchars=eob:\ + +set statusline=%{exists('*anzu#search_status')?anzu#search_status():''} + +" --- Netrw toggle (like neo-tree) --- +function! NetrwToggle() + for i in range(1, winnr('$')) + if getbufvar(winbufnr(i), '&filetype') ==# 'netrw' + execute i . 'wincmd w' + close + return + endif + endfor + let g:netrw_return_win = winnr() + Lexplore +endfunction + +function! SafeWincmd(dir) + let target = winnr(a:dir) + if target == winnr() + return + endif + if getbufvar(winbufnr(target), '&filetype') ==# 'netrw' + return + endif + execute 'wincmd ' . a:dir +endfunction + +function! GitRoot() + let l:root = systemlist('git rev-parse --show-toplevel') + if v:shell_error == 0 && !empty(l:root) && !empty(l:root[0]) + return l:root[0] + endif + return getcwd() +endfunction + +function! SafeBdelete() + if &filetype ==# 'netrw' + echohl WarningMsg | echom 'Cannot delete buffer from netrw' | echohl None + return + endif + + let l:buflisted = getbufinfo({'buflisted': 1}) + if len(l:buflisted) <= 1 + echohl WarningMsg | echom 'Cannot delete last buffer' | echohl None + return + endif + + let l:buf = bufnr('%') + bprevious + execute 'bdelete ' . l:buf +endfunction + +" --- Plugin management --- +nnoremap pu :PlugUpdate +nnoremap pd :PlugUpgrade +nnoremap ps :PlugStatus +nnoremap pi :PlugInstall + +" --- Search (anzu) --- +nmap n (anzu-n-with-echo) +nmap N (anzu-N-with-echo) +nmap * (anzu-star-with-echo) +nmap # (anzu-sharp-with-echo) +nmap (anzu-clear-search-status) +nnoremap :nohlet @/="" + +" --- Visual indentation --- +vnoremap < >gv + +" --- Scrolling (centered) --- +nnoremap zz +nnoremap zz + +" --- Window navigation (matches nvim , skips netrw) --- +nnoremap :call SafeWincmd('h') +nnoremap :call SafeWincmd('j') +nnoremap :call SafeWincmd('k') +nnoremap :call SafeWincmd('l') + +" --- Window resize (matches nvim ) --- +nnoremap :vertical resize +10 +nnoremap :vertical resize -10 +nnoremap :resize +10 +nnoremap :resize -10 + +" --- Window management --- +nnoremap wc :close +nnoremap ws :split +nnoremap wv :vsplit +nnoremap wm _ +nnoremap ww :wincmd w +nnoremap wW :wincmd W + +" --- File explorer & search --- +nnoremap e :call NetrwToggle() +nnoremap / :execute 'lcd ' . fnameescape(GitRoot()) Rg +nnoremap ff :execute 'lcd ' . fnameescape(GitRoot()) Files +nnoremap fp :History +nnoremap fb :Buffers +nnoremap ? :History: + +" --- Buffers --- +nnoremap bd :call SafeBdelete() +nnoremap H :bprevious +nnoremap L :bnext + +" --- Terminal --- +nnoremap t :below terminal ++rows=10 + +" --- Misc --- +nnoremap ts :execute "normal! a" . strftime('[%b %d %H:%M:%S - BR]')