From 36c10758b19dd074d573fbe80db2f63fb6e42bb7 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 4 Apr 2025 16:55:39 -0500 Subject: [PATCH] Add vimrc for use if vim is needed in one-off cases --- copy_configs | 4 +- src_files/.config/vim/.vimrc | 126 +++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 src_files/.config/vim/.vimrc diff --git a/copy_configs b/copy_configs index 0f1a26a..5336e8e 100755 --- a/copy_configs +++ b/copy_configs @@ -28,8 +28,8 @@ log "---------------- dotfiles ----------------" copy_dir src_files/.config $XDG_CONFIG_HOME copy_dir src_files/.local $DIR_LOCAL -# duplicate, but copy anyway, ensures set if zsh isn't yet looking to $XDG_CONFIG_HOME/zsh -copy_file src_files/.config/zsh/.zshenv $HOME +copy_file src_files/.config/zsh/.zshenv $HOME # duplicate, copy anyway, ensures $ZDOTDIR +# copy_file src_files/.config/vim/.vimrc $HOME # copy to $HOME if need to use vim # on macos, handle sim-linking to gimp config since gimp defaults to app-support if [[ "$BOX_SETUP_OS" = "macos" ]]; then diff --git a/src_files/.config/vim/.vimrc b/src_files/.config/vim/.vimrc new file mode 100644 index 0000000..c8522c5 --- /dev/null +++ b/src_files/.config/vim/.vimrc @@ -0,0 +1,126 @@ +" base settings +set nocompatible +let mapleader="," + +" plugin manager and plugin list +filetype off +set rtp+=$XDG_CONFIG_HOME/vim/plugins/Vundle.vim +call vundle#begin('$XDG_CONFIG_HOME/vim/plugins') +Plugin 'VundleVim/Vundle.vim' + +" language-specific +Plugin 'leafgarland/typescript-vim' + +" themes +Plugin 'rose-pine/vim' +Plugin 'ghifarit53/tokyonight-vim' +call vundle#end() +filetype plugin on " or plugin indent on ? + +" plugin config + let g:netrw_banner=0 " hide banner + let g:netrw_browse_split=0 " opens in same window + let g:netrw_liststyle=3 " listing style: tree + let g:netrw_list_hide= '.*\.swp$' + " let g:netrw_list_hide.=netrw_gitignore#Hide() + " TODO add toggle to exaand/collapse whole tree + + let g:typescript_indent_disable = 1 + +" functions +func! ToggleTabMode() + set expandtab! + if &expandtab + echo "using space characters in place of tabs" + else + echo "using tab characters" + endif +endfunc + +" TODO add function (or something) similar to gf, but clear the buffer in +" which it is run (idea is to use this with results of grep in blank pane) + +" copy & paste: registers, clipboard +set clipboard+=unnamed " TODO or maybe unamedplus? + +" colors, themes, appearance +"set background=light +let g:tokyonight_style = 'night' " available: night, storm +colorscheme tokyonight +" colorscheme rosepine_moon + +" measurements, numbers, visual/audible cues +set cursorline +set colorcolumn=89,90 +set noerrorbells novisualbell +set hlsearch +set laststatus=2 +set number relativenumber +set ruler +set showcmd +set noshowmode +set title + +" syntax highlighting +syntax enable " TODO 'enable' or 'on'? + +" settings for buffers +set hidden + +" settings for panes/splits, tabs +set splitright splitbelow +map h +map j +map k +map l + +" finding and opening files +set wildmenu +set path+=** + +" text input and editing +set tabstop=4 +set expandtab +autocmd BufEnter * set formatoptions-=ro +" TODO get recursion working for the tags command below +command! MakeTags !ctags -f tags -R . + +" shortcuts or aliases + " shortcuts for find in pane/tab + nnoremap f. :find* + nmap fr :vnewf. + nmap fb :newf. + nmap ft :tabnewf. + + " shortcuts for grep in pane/tab + nnoremap g, :r!grep--exclude-dir=node_modules-rIi. + nmap g. :enewg, + nmap gr :vnewg, + nmap gb :newg, + nmap gt :tabnewg, + + " shortcuts for tree (netrw) in pane/tab + nnoremap t. :edit. + nnoremap tr :vsplit. + nnoremap tb :split. + nnoremap tt :tabnew. + + " toggle tab/space mode + nnoremap tab :call ToggleTabMode() + + " toggles related to line numbers and cursor + nnoremap nu :set number! + nnoremap rnu :set relativenumber! + nnoremap cc :set cuc! + + " searching: replace-all in file + nnoremap ra :%s//g + " TODO maybe add global (working dir, recursive) replace-all feature? + + " format file content + nnoremap fmtjson :%!jq.- + +" automatic actions + autocmd BufWritePre * %s/\s\+$//e " delete trailing whitespace + " autocmd BufWritePre * %s/\n\+\%$//e " delete end-of-file newlines +