« get me outta code hell

dotfiles - Miscellaneous configuration files of my personal use
about summary refs log tree commit diff
path: root/.vimrc
diff options
context:
space:
mode:
Diffstat (limited to '.vimrc')
-rwxr-xr-x[-rw-r--r--].vimrc236
1 files changed, 146 insertions, 90 deletions
diff --git a/.vimrc b/.vimrc
index 867eebf..7039c60 100644..100755
--- a/.vimrc
+++ b/.vimrc
@@ -1,107 +1,163 @@
-" vim-sublime - A minimal Sublime Text - like vim experience bundle
-"               http://github.com/grigio/vim-sublime
-" Best view with a 256 color terminal and Powerline fonts
-" Updated by Dorian Neto (https://github.com/dorianneto)"
+" ~nebula/.vimrc (2018-2023, public domain)
 
+" table of contents:
+"   <INI> setup
+"   <VIM> vim settings
+"   <PLG> plugins
+"   <LNG> language-specific behavior
+
+" <INI> setup ------------------------------------
+
+" initialization stuff
 set nocompatible
+set encoding=utf-8
 
+" plugin management
 execute pathogen#infect()
-
-filetype off
 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 'chrisbra/NrrwRgn'
-Plugin 'colors'
+Plugin 'tpope/vim-sleuth'
+Plugin 'eslint/eslint'
 call vundle#end()
-filetype plugin indent on
 
-set background=dark
+" <VIM> 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
-let g:airline_theme='badwolf'
-syntax on
-
-" Use :help 'option' to see the documentation for the given option.
-set autoindent
-set backspace=indent,eol,start
-set showmatch
-set showmode
-set smarttab
-set shiftround
-set ttimeout
-set ttimeoutlen=50
-set nois
-set laststatus=2
-set ruler
-set showcmd
-set wildmenu
-set autoread
-set encoding=utf-8
-set tabstop=2 shiftwidth=2 expandtab
-set listchars=tab:▒░,trail:▓
-set list
-set number
-set hlsearch
-set ignorecase
-set smartcase
-
-if has('mouse')
-  set mouse=a
-endif
-
-set hidden
-set nobackup
-set nowritebackup
-set noswapfile
-set fileformats=unix,dos,mac
-set completeopt=longest
-
-"
-" Plugins config
-"
-
-" NERDTree
-nnoremap <S-n> :NERDTreeToggle<CR>
-
-" vim-airline
-let g:airline#extensions#tabline#enabled = 1
-let g:airline_powerline_fonts = 1
+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
 
-"
-" Basic shortcuts definitions
-"  most in visual mode / selection (v or ⇧ v)
-"
-
-" Find
-map <C-f> /
-" indent / deindent after selecting the text with (⇧ v), (.) to repeat.
-vnoremap <Tab> >
-vnoremap <S-Tab> <
-" Text wrap simpler, then type the open tag or ',"
-vmap <C-w> S
-" Tabs
-let g:airline#extensions#tabline#enabled = 1
-nnoremap <C-Left>  :tabprevious<CR>
-inoremap <C-Left>  <Esc>:tabprevious<CR>i
-nnoremap <C-Right>  :tabnext<CR>
-inoremap <C-Right>  <Esc>:tabnext<CR>i
-nnoremap <C-t>  :tabnew<CR>
-inoremap <C-t>  <Esc>:tabnew<CR>i
-
-set ttymouse=xterm2
-set mouse=a
-set encoding=utf-8
-nnoremap <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR>
-inoremap <C-s> <C-o>:w<CR>
+" search
+set   hlsearch
+set   ignorecase smartcase
+set noincsearch
+
+" writing behavior
+set   nobackup nowritebackup noswapfile
+set   fileformats=unix,dos,mac
+
+" keyboard shortcuts
+nnoremap <C-f> /
 nnoremap <C-s> :w<CR>
-command! -range=% Paste  <line1>,<line2>!tee /tmp/paste /dev/stdout; curl -s --data-binary @/tmp/paste https://paste.safe.moe/documents | sed -r 's$.*".*".*"(.*)".*$https://paste.safe.moe/raw/\1$g' | xclip -sel clip
+inoremap <C-s> <C-o>:w<CR>
+
+" restore previous scroll position
+autocmd BufReadPost * silent! normal! g`"zv
+
+" disable default language-specific indentation behavior
+" (this doesn't actually work as an autocmd, instead copy-paste
+" this into ~/.vim/indent/<filetype>.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
+
+" <PLG> 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
+
+" <LNG> 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
 
-" AAAAAAAAAAAAAAAAAA todo highlighting
-highlight TodoDone ctermfg=13
-highlight TodoNotDone ctermfg=15
-highlight TodoStringDone ctermfg=3
-highlight TodoStringNotDone ctermfg=2 cterm=bold
+" yaml overrides
+au FileType yaml setlocal indentexpr=
+au FileType yaml nmap <buffer> { ?---\+<CR>
+au FileType yaml nmap <buffer> } /---\+<CR>