Repository navigation
Expand file tree
/
Copy pathnvimrc
More file actions
279 lines (225 loc) · 10 KB
/
Copy pathnvimrc
File metadata and controls
279 lines (225 loc) · 10 KB
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
"
" ~/.nvimrc
"
" PLUGINS
" --------------------------------------
call plug#begin()
Plug 'bling/vim-airline'
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_left_sep = ''
let g:airline_right_sep = ''
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.whitespace = 'Ξ'
Plug 'janko-m/vim-test'
let test#strategy = 'neovim'
Plug 'kien/ctrlp.vim'
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_match_window = 'max:16,results:64'
let g:ctrlp_open_multiple_files = '1r'
let g:ctrlp_open_new_file = 'r'
nnoremap <silent> <Leader>b :CtrlPBuffer<CR>
Plug 'majutsushi/tagbar'
let g:tagbar_autoclose = 1
nnoremap <silent> <Leader>t :TagbarToggle<CR>
Plug 'mileszs/ack.vim'
let g:ackprg = 'ag --nogroup --nocolor --column'
nnoremap <Leader>a :Ack<Space>
Plug 'Glench/Vim-Jinja2-Syntax'
Plug 'Lokaltog/vim-easymotion'
Plug 'dag/vim-fish'
Plug 'elixir-lang/vim-elixir'
Plug 'floobits/floobits-neovim'
Plug 'godlygeek/tabular'
Plug 'maxbrunsfeld/vim-yankstack'
Plug 'mtth/scratch.vim'
Plug 'nathangrigg/vim-beancount'
Plug 'rodjek/vim-puppet'
Plug 'tomtom/tcomment_vim'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-speeddating'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-vividchalk'
Plug '~/.nvim/vendor/nginx'
Plug '~/.nvim/vendor/nix'
call plug#end()
runtime! macros/matchit.vim
call yankstack#setup()
" COLORS AND FONTS
" --------------------------------------
colorscheme vividchalk
" Remove the underline from the cursorline
highlight CursorLine cterm=bold ctermbg=234
" Adjust colors for the line numbers and fold indicators
highlight CursorLineNr ctermfg=Yellow ctermbg=234
highlight LineNr ctermfg=DarkGray ctermbg=232
highlight FoldColumn ctermfg=DarkGray ctermbg=234
" Highlight trailing whitespace characters and tabs not used for indentation
highlight WhitespaceErrors ctermbg=red guibg=red
match WhitespaceErrors /\s\+$/
autocmd BufWinEnter * match WhitespaceErrors /\s\+$\|[^\t]\@<=\t\+/
autocmd InsertEnter * match WhitespaceErrors /\s\+\%#\@<!$\|[^\t]\@<=\t\+/
autocmd InsertLeave * match WhitespaceErrors /\s\+$\|[^\t]\@<=\t\+/
autocmd BufWinLeave * call clearmatches()
" SETTINGS
" --------------------------------------
set ignorecase " Ignore case when searching
set infercase " Base insert mode completion based on the typed text
set smartcase " Override ignorecase if search has upper case characters
set autoindent " Do dumb auto-indentation when no filetype is set
set autoread " Automatically reload when a file is changed outside of Vim
set backspace=indent,eol,start " Allow backspacing over everything
set cmdheight=2 " Use two screen lines for the command-line to avoid hit-enter prompts
set complete-=i " Disable scanning of included files for keyword completion
set cursorline " Highlight the screen line of the cursor
set directory=/var/tmp// " Centrally store all swap files using full path names
set display+=lastline " Show as much as possible of the last line in a window versus '@' lines
set expandtab " Convert tabs to spaces
set fileformats+=mac " Always check for mac end-of-line formats
set foldcolumn=3 " Display column indicating open/closed folds
set foldlevel=99 " Default to no folds closed
set foldmethod=indent " Lines with equal indent form a fold
set formatoptions+=1 " Prefer breaking before, not after, a one-letter word
set formatoptions+=n " When formatting text with gq, recognize lists
set hidden " Allow the changing of buffers without saving
set history=1000 " Remember 1000 lines of command line history
set hlsearch " Highlight the last used search pattern
set incsearch " Enable incremental searching
set laststatus=2 " Always show the statusline
set lazyredraw " Do not redraw screen while executing macros
set linebreak " Wrap long lines at word boundaries
set list " Display unprintable characters
set matchtime=4 " Blink matched brackets for 4/10ths of a second
set mouse=a " Enable mouse use for all modes
set nobackup " Do not automatically backup files
set nojoinspaces " Do not insert 2 spaces after sentences when joining
set nomodeline " Do not read settings from modelines
set nostartofline " Do not move cursor to SOL during jump commands
set nowrap " Do not automatically wrap long lines
set nrformats-=octal " Consider numbers starting with a zero to still be decimal
set number " Precede each line with its line number
set numberwidth=1 " Use the minimal number of columns for line numbers
set relativenumber " Show line numbers relative to the cursor's line
set ruler " Show the cursor position at all times
set scrolloff=2 " Keep two lines above and below cursor when scrolling
set sessionoptions-=options " Adjust behavior of mksession
set showcmd " Display incomplete commands
set showmatch " Highlight matching brackets
set sidescrolloff=3 " Keep three columns left and right of cursor when scrolling
set smarttab " Insert blanks according to shiftwidth when in front of a line
set ttimeout " Enable terminal timeout for key code sequences
set ttimeoutlen=100 " Time out on key codes after a tenth of a second
set viminfo^=! " Save and restore all-capital global variables
set virtualedit=block " Cursor can be positioned anywhere when in blockwise Visual mode
set whichwrap+=h,l " Allow cursor keys to line wrap
set wildmenu " Use enhanced command line completion
set wildmode=longest:list,full " Set the wildchar completion mode
set winminheight=0 " Minimal height of a non-current window
" Delete comment character when joining commented lines
if v:version > 703 || v:version == 703 && has("patch541")
set formatoptions+=j
endif
" Use custom characters for window separators and whitespace
set fillchars=vert:\ ,fold:-
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
if &termencoding ==# 'utf-8' || &encoding ==# 'utf-8'
let &fillchars = "vert:\u259a,fold:\u00b7"
let &listchars = "tab:\u21e5 ,trail:\u2423,extends:\u21c9,precedes:\u21c7,nbsp:\u00b7"
endif
autocmd InsertEnter * setlocal nolist
autocmd InsertLeave * setlocal list
" Set up default tab spacing
set shiftwidth=4
set softtabstop=4
set tabstop=4
" Search upward for tags files
setglobal tags-=./tags tags^=./tags;
" HELPER FUNCTIONS
" --------------------------------------
" Execute a command while preserving the cursor location and search history
function! Preserve(command)
" save the last search and cursor position
let _s=@/
let l = line(".")
let c = col(".")
" execute the given command
execute a:command
" restore the search history and cursor position
let @/=_s
call cursor(l, c)
endfunction
" Jump to the last known cursor position when opening files
" See :help restore-cursor
function! RestoreCursor()
" don't restore the cursor position for VCS commit logs
if line("'\"") > 0
\ && line("'\"") <= line("$")
\ && bufname('%') !~ '\.git\/COMMIT_EDITMSG\|svn-commit\.tmp'
exe "normal! g`\""
endif
endfunction
autocmd BufReadPost * call RestoreCursor()
" MAPPINGS & CUSTOM COMMANDS
" --------------------------------------
" Always use very magic regexes for search patterns
nnoremap / /\v
vnoremap / /\v
" Save a keystroke when entering command-line mode
noremap ; :
" Don't move linewise when long lines are wrapped
noremap j gj
noremap k gk
" Q formats paragraphs, instead of entering Ex mode
noremap Q gqip
" Assist with common typo when trying to quit
nnoremap q: q:iq<Esc>
" Assist with common mistake of not opening file with sudo
cnoremap w!! w !sudo tee % >/dev/null
" Move between windows using Ctrl + home row motion keys
nnoremap <C-J> <C-W>j
nnoremap <C-K> <C-W>k
nnoremap <C-H> <C-W>h
nnoremap <C-L> <C-W>l
" Run the entire file through the indent filter
noremap <silent> <Leader>= :call Preserve("normal gg=G")<CR>
" Ensure that you can undo CTRL-U after inserting a line break
inoremap <C-U> <C-G>u<C-U>
" Change the CWD to where the current file is located
noremap <silent> <Leader>cd :cd %:p:h<CR>
" Remove last search pattern highlighting
nnoremap <silent> <Leader>h :nohlsearch<CR>
" Highlight lines longer than textwidth
" or column 79 if the textwidth option is not set
noremap <silent> <Leader>l m`:execute '/\%>' . (&tw ? &tw : 79) . 'v.\+'<CR>``
" Toggle paste mode
nnoremap <Leader>p :set invpaste paste?<CR>
" Copy visual area to the OS X clipboard
vnoremap <C-C> :w !pbcopy<CR><CR>gv
" Remove trailing whitespace
noremap <silent> <Leader>rtw :call Preserve("%s/\\s\\+$//e")<CR>
" Replace word with the contents of the unnamed register (paste buffer)
noremap <silent> <Leader>rw "_diwhp<CR>
" Toggle spellchecking for the local buffer
noremap <silent> <Leader>sc :setlocal spell! spelllang=en_us<CR>
" Save typing when doing a global search/replace
noremap <Leader>sr :%s//g<Left><Left>
" Select the text that was just pasted
noremap <Leader>v V`]
" Yank from the cursor to the end of the line
nmap Y y$
" FILETYPE SPECIFIC SETTINGS
" --------------------------------------
" Use tabs for these file types
autocmd FileType fish setlocal noexpandtab
autocmd FileType gitconfig setlocal noexpandtab
autocmd FileType make setlocal noexpandtab
autocmd FileType sh setlocal noexpandtab
autocmd FileType tex setlocal noexpandtab
autocmd FileType vim setlocal noexpandtab
" Use a tab spacing of two spaces for these file types
autocmd FileType beancount setlocal shiftwidth=2 softtabstop=2 tabstop=2
autocmd FileType elixir setlocal shiftwidth=2 softtabstop=2 tabstop=2
autocmd FileType yaml setlocal shiftwidth=2 softtabstop=2 tabstop=2