" ~nebula/.vimrc (2018-2023, public domain) " table of contents: " setup " vim settings " plugins " language-specific behavior " setup ------------------------------------ " initialization stuff set nocompatible set encoding=utf-8 " plugin management execute pathogen#infect() set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'VundleVim/Vundle.vim' Plugin 'vim-airline/vim-airline' Plugin 'vim-airline/vim-airline-themes' Plugin 'airblade/vim-gitgutter' Plugin 'tpope/vim-sleuth' Plugin 'eslint/eslint' call vundle#end() " vim settings ----------------------------- " indentation & wrapping set tabstop=4 shiftwidth=4 expandtab set autoindent set nosmartindent " also overridden per language set smarttab shiftround set nowrap set linebreak set breakindent set showbreak=\ ↳\ " " editor behavior filetype indent off set autoread set hidden set backspace=indent,eol,start set mouse=a ttymouse=xterm2 set ttimeout ttimeoutlen=50 " editor appearance colorscheme molokai syntax off set background=dark set colorcolumn=+1 set cursorline set laststatus=2 set list listchars=trail:▓ set number set scrolloff=5 sidescrolloff=8 set showcmd set noshowmode " airline shows mode already set wildmenu " search set hlsearch set ignorecase smartcase set noincsearch " writing behavior set nobackup nowritebackup noswapfile set fileformats=unix,dos,mac " keyboard shortcuts nnoremap / nnoremap :w inoremap :w " restore previous scroll position fun! RestoreScrollPosition() " always start editing certain files at the top if &ft =~ 'gitcommit' return endif g`"zv " this is the actual restore-scroll part endfun autocmd BufReadPost * silent! normal! :call RestoreScrollPosition() " spooky vim backups stolen from official example config if has("vms") set nobackup " do not keep a backup file, use versions instead else set backup " keep a backup file (restore to previous version) if has('persistent_undo') set undofile " keep an undo file (undo changes after closing) endif endif " disable default language-specific indentation behavior " (this doesn't actually work as an autocmd, instead copy-paste " this into ~/.vim/indent/.vim files) " let b:did_indent = 1 " only allow a few syntax highlighting colors hi NonText ctermbg=NONE ctermfg=NONE cterm=NONE hi Visual ctermbg=fg ctermfg=bg cterm=NONE hi Boolean ctermbg=NONE ctermfg=NONE cterm=NONE hi Character ctermbg=NONE ctermfg=NONE cterm=NONE hi Comment ctermbg=NONE ctermfg=45 cterm=NONE hi Conditional ctermbg=NONE ctermfg=NONE cterm=NONE hi Constant ctermbg=NONE ctermfg=NONE cterm=NONE hi Delimiter ctermbg=NONE ctermfg=NONE cterm=NONE hi Error ctermbg=NONE ctermfg=NONE cterm=reverse hi Exception ctermbg=NONE ctermfg=NONE cterm=NONE hi Float ctermbg=NONE ctermfg=NONE cterm=NONE hi Function ctermbg=NONE ctermfg=NONE cterm=NONE hi Identifier ctermbg=NONE ctermfg=NONE cterm=NONE hi Ignore ctermbg=NONE ctermfg=NONE cterm=NONE hi Keyword ctermbg=NONE ctermfg=NONE cterm=NONE hi Label ctermbg=NONE ctermfg=NONE cterm=NONE hi Number ctermbg=NONE ctermfg=NONE cterm=NONE hi Operator ctermbg=NONE ctermfg=NONE cterm=NONE hi PreProc ctermbg=NONE ctermfg=NONE cterm=NONE hi Repeat ctermbg=NONE ctermfg=NONE cterm=NONE hi Special ctermbg=NONE ctermfg=NONE cterm=NONE hi SpecialChar ctermbg=NONE ctermfg=NONE cterm=NONE hi Statement ctermbg=NONE ctermfg=NONE cterm=NONE hi StorageClass ctermbg=NONE ctermfg=NONE cterm=NONE hi String ctermbg=NONE ctermfg=NONE cterm=NONE hi Title ctermbg=NONE ctermfg=NONE cterm=NONE hi Todo ctermbg=NONE ctermfg=DarkGray cterm=underline hi Type ctermbg=NONE ctermfg=NONE cterm=NONE hi Underlined ctermbg=NONE ctermfg=DarkGray cterm=underline hi Search ctermbg=DarkGray ctermfg=white cterm=NONE hi link gitcommitOverflow Error hi htmlItalic ctermbg=NONE ctermfg=NONE cterm=underline " plugin settings -------------------------- " airline " let g:airline_theme='minimalist' let g:airline_theme='zenburn' " distinguished (grey yellow) " peaksea (grey) " molokai (molokai) " minimalist (nice) " luna (wof) " zenburn (grey good contrast) let g:airline_powerline_fonts = 1 let g:airline#extensions#tabline#enabled = 1 " ale " Only lint if .eslintrc is present autocmd BufEnter,BufNew *.js let g:ale_linters = FindGlob('.eslintrc.*', expand('%:p:h')) ? {'javascript': ['eslint']} : {'javascript': ['']} function! g:FindGlob(pattern, path) let fullpattern = a:path . "/" . a:pattern if strlen(glob(fullpattern)) return 1 else let parts = split(a:path, "/") if len(parts) let newpath = "/" . join(parts[0:-2], "/") return FindGlob(a:pattern, newpath) else return 0 endif endif endfunction " language specific behavior --------------- " indent options for particular languages autocmd FileType javascript set smartindent autocmd FileType c,cpp,h,hpp set smartindent " word wrap javascript comments autocmd BufEnter,BufNew *.js autocmd CursorMoved,CursorMovedI * :if match(getline('.'), '^\s*//') == 0 | :setlocal textwidth=80 | :else | :setlocal textwidth=0 | :endif " yaml overrides au FileType yaml setlocal indentexpr= au FileType yaml nmap { ?---\+ au FileType yaml nmap } /---\+ " start git commits in insert mode (wrong and evil) " au BufNewFile,BufRead COMMIT_EDITMSG,MERGE_MSG,TAG_EDITMSG :startinsert! " au BufNewFile,BufRead NOTES_EDITMSG,EDIT_DESCRIPTION :startinsert!