1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
" ~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()
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 'tpope/vim-sleuth'
Plugin 'eslint/eslint'
call vundle#end()
" <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
syntax off
set background=dark
set colorcolumn=+1
set cursorline
set laststatus=2
set list listchars=trail:▓
set number
set scrolloff=3 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 <C-f> /
nnoremap <C-s> :w<CR>
inoremap <C-s> <C-o>:w<CR>
" 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/<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
" text (txt) overrides
au FileType text setlocal wrap
" yaml overrides
au FileType yaml setlocal indentexpr=
au FileType yaml nmap <buffer> { ?---\+<CR>
au FileType yaml nmap <buffer> } /---\+<CR>
" 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!
|