-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvimrc
More file actions
273 lines (210 loc) · 9.51 KB
/
vimrc
File metadata and controls
273 lines (210 loc) · 9.51 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
" vim: set ts=4 sw=4 expandtab:
" Copyright (C) 2013-2024 Matthew Langbehn
"
" This program is free software: you can redistribute it and/or modify
" it under the terms of the GNU General Public License as published by
" the Free Software Foundation, either version 3 of the License, or
" (at your option) any later version.
"
" This program is distributed in the hope that it will be useful,
" but WITHOUT ANY WARRANTY; without even the implied warranty of
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" GNU General Public License for more details.
"
" You should have received a copy of the GNU General Public License
" along with this program. If not, see <http://www.gnu.org/licenses/>.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" "
" "
" A simple vim Configuration File "
" "
" "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set vi incompatible mode
" (must be set before any other options)
set nocompatible
" Enable Pathogen
" Easy vim plugin management
execute pathogen#infect()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" "
" Completion System "
" "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable Omni Completion
" Requires filetype plugin to be turned on
set omnifunc=syntaxcomplete#Complete
" Set completion system to use the longest common text, and always show a menu
set completeopt=longest,menuone
" Set menu color to grey
:highlight Pmenu ctermbg=grey gui=bold
" Set keys for completion menu
" [ENTER] = Select
" Arrow Keys = Scroll through options
" PageUp and PageDown = Jump through options
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
inoremap <expr> <PageDown> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>"
inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>"
" Setup smart tab completion
" This enables accessing the completion menu by pressing [TAB]
function! Smart_TabComplete()
let line = getline('.')
let substr = strpart(line, -1, col('.')+1)
let substr = matchstr(substr, "[^ \t]*$")
if (strlen(substr)==0)
return "\<tab>"
endif
let has_period = match(substr, '\.') != -1
let has_slash = match(substr, '\/') != -1
if (!has_period && !has_slash)
return "\<C-X>\<C-P>"
elseif ( has_slash )
return "\<C-X>\<C-F>"
else
return "\<C-X>\<C-O>"
endif
endfunction
" Bind [TAB] to call Smart_TabComplete()
inoremap <tab> <c-r>=Smart_TabComplete()<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" "
" Previous Session Information "
" "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Tell vim to remember certain things when we exit
" '10 : marks will be remembered for up to 10 previously edited files
" "100 : will save up to 100 lines for each register
" :20 : up to 20 lines of command-line history will be remembered
" % : saves and restores the buffer list
" n... : where to save the viminfo files
set viminfo='10,\"100,:20,%,n~/.viminfo
function! ResCur()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" "
" Search Settings "
" "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Highlight results
set hlsearch
" Ignore case
set ignorecase
" Incremental search -- search as you type
set incsearch
" Try to be smart about case
set smartcase
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" "
" Syntax Checking "
" "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_ansible_checkers = ['ansible-lint']
let g:syntastic_markdown_checkers = ['textlint']
let g:syntastic_markdown_textlint_args = "--rule no-todo,no-empty-section,common-misspellings,alex,rousseau"
let g:syntastic_python_checkers = ['flake8','pylint']
let g:syntastic_yaml_checkers = ['yamllint']
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" "
" Text Formatting "
" "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" When in front of a line, insert space according to shift width,
" rather than tab stop
set smarttab
" Set <F3> to toggle paste mode
" This is to be used when pasting from another application, and
" prevents autoindent from breaking existing formating.
" The second line allows this to work while in insert mode.
" The third like shows the change while in insert mode.
nnoremap <F3> :set invpaste paste?<CR>
set pastetoggle=<F3>
set showmode
" Lines should be soft-wrapped at 80 columns
set wrap
set linebreak
set nolist
" If par is installed, use it to format text
" use 'gq' to reformat, or 'gw' to use vim's built-in formatter
if executable("par")
set formatprg=par\ -w72
endif
" Enable file type plug-ins
filetype plugin on
filetype indent on
" Specific filetype settings
autocmd Filetype bash setlocal ts=4 sw=4 expandtab
autocmd Filetype sh setlocal ts=4 sw=4 expandtab
autocmd Filetype yaml setlocal ts=2 sw=2 expandtab
" Use UTF-8 encoding
set encoding=utf8
" Set Unix as the standard file type
set ffs=unix,dos,mac
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" "
" User Interface "
" "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
let g:ansible_attribute_highlight = "ab"
let g:ansible_name_highlight = 'd'
let g:ansible_extra_keywords_highlight = 1
" Configure colors for a dark background
set background=dark
" Automatically read changes made to the file from the outside
set autoread
" Show line numbers
set number
" Show the cursor position
set ruler
" Enable spell checking by default
" <F2> will toggle spell checking
set spell
nmap <F2> :set invspell<CR>
" Always keep 3 lines above and below the cursor
set scrolloff=3
" Backspace and cursor movements should wrap between lines
set whichwrap=b,s,h,l,<,>,[,]
" Show matching brackets
set showmatch
" Show match for 2 tenths of a second
set matchtime=2
" Use vim-airline for status bar
set laststatus=2
let g:airline#extensions#tabline#enabled = 1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" "
" Whitespace Control "
" "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Create the pattern "ExtraWhitespace" and set its highlight color to red
highlight ExtraWhitespace ctermbg=red guibg=red
" Search for whitespace at the end of lines
match ExtraWhitespace /\s\+$/
" When opening a new buffer, search for whitespace at the end of lines
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
" Search for whitespace at the end of lines when entering insert mode
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
" Search for whitespace at the end of lines when leaving insert mode
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
" Added to avoid performance issues due to repeated matching
autocmd BufWinLeave * call clearmatches()
" <F4> removes all trailing whitespace
nnoremap <silent> <F4> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>