-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
305 lines (235 loc) · 6.89 KB
/
.vimrc
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set the runtime path to include Vundle and initialize it
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'ascenator/L9', {'name': 'newL9'}
Plugin 'dracula/vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'ntpeters/vim-better-whitespace'
Plugin 'tpope/vim-surround'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/syntastic'
Plugin 'valloric/youcompleteme'
Plugin 'majutsushi/tagbar'
Plugin 'lilydjwg/colorizer'
Plugin 'godlygeek/tabular'
Plugin 'sheerun/vim-polyglot'
Plugin 'suan/vim-instant-markdown'
" All of your Plugins must be added before the following line
call vundle#end()
filetype plugin indent on
" vim-airline
let g:airline_powerline_fonts=1
let g:airline_theme='base16'
"" Better-whitespace
let g:better_whitespace_enabled=1
let g:strip_whitespace_on_save=1
"" Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_loc_list_height = 5
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 1
let g:syntastic_error_symbol = '✗'
let g:syntastic_style_error_symbol = '⁉️'
let g:syntastic_warning_symbol = '⚠ '
let g:syntastic_style_warning_symbol = '💩'
highlight link SyntasticErrorSign SignColumn
highlight link SyntasticWarningSign SignColumn
highlight link SyntasticStyleErrorSign SignColumn
highlight link SyntasticStyleWarningSign SignColumn
let g:syntastic_check_on_wq = 0
let g:ale_linters= {
\ 'go': ['golint', 'govet', 'errcheck'],
\ 'json': ['jsonlint'],
\ 'python': ['flake8'],
\ 'sh': ['shellcheck', 'sh'],
\ 'yaml': ['yamllint']
\ }
nmap <silent> <leader>a <Plug>(ale_next_wrap)
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
let g:syntastic_check_on_open = 0
"" NerdTree
" Open if no file is specified
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" Start if open a directory
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
" Map key to open
map <C-n> :NERDTreeToggle<CR>
" Change default arrows
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set utf-8 as standard encoding
set encoding=utf-8
" Use Unix as the standard file type
set ffs=unix,dos,mac
" Use Improved
set nocompatible
" More powerful backspacing
set backspace=2
" Set how many lines of history VIM has to remember
set history=500
" Enable filetype detection
filetype on
" Enable filetype plugins
filetype plugin on
filetype indent on
" Use the OS clipboard by default
set clipboard=unnamed
" Optimize for fast terminal connections
set ttyfast
" Disable backup
set nobackup nowritebackup noswapfile
" Don't add empty newlines at the end of files
set binary noeol
" Use vertical diff
set diffopt+=vertical
" Respect modeline in files
set modeline modelines=4
" Ignore case of searches
set ignorecase
" Always show status line
" set laststatus=2
" Enable mouse in all modes
set mouse=a
" Disable error bells
set noerrorbells novisualbell t_vb= tm=500
" Don't reset cursor to start a line when moving around
set nostartofline
" Don't show the intro message when starting Vim
set shortmess=atI
" Don't redraw while executing macros
set lazyredraw
" For regular expressions turn magic on
set magic
" Comments
autocmd Filetype cfg setlocal commentstring=#\ %s
autocmd Filetype sql setlocal commentstring=--\ %s
" eyaml recognized as yaml
autocmd BufNewFile,BufRead *.eyaml setfiletype yaml
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Indentation
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4 tabstop=4 softtabstop=4
" Configure backspaces
set backspace=indent,eol,start
set whichwrap=<,>,h,l
" Set auto indent
set ai
" Set smart indent
set si
" Wrap lines
set wrap
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" UI
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Dark background
set background=dark
" Set extra options when running in GUI mode
if has("gui_running")
set guioptions-=T
set guioptions-=e
set t_Co=256
set guitablabel=%M\ %t
end
if has('autocmd')
augroup coloroverride
autocmd!
autocmd ColorScheme * highlight LineNr ctermfg=DarkGrey guifg=DarkGrey " Override LineNr
autocmd ColorScheme * highlight CursorLineNr ctermfg=White guifg=White " Override CursorLineNr
augroup END
endif
silent! colorscheme eldar " Custom color scheme
" Enable syntax highlighting
syntax on
" Highlight current line
set cursorline
" Enable line numbers
set number nu
" Rule current line
set ruler
" Highlight searches
set hlsearch
" Highlight dynamically as pattern is typed
set incsearch
" Show the current mode
set showmode
" Show the filename in the window titlebar
set title
" Show the partial command as it is being typed
set showcmd
" Show matching backets when text indicator is over them
set showmatch
" How many tenths of second to blink when matching brackets
set mat=2
" Set the command window height to 2 to avoid many cases of having to
" "press <Enter> to continue"
set cmdheight=2
" Open new split panes to right and bottow which feels more natural
set splitbelow splitright
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Fzf
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if system('uname') =~ "Darwin"
set rtp+=/opt/homebrew/opt/fzf
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Mapping
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let mapleader = " "
let g:mapleader = " "
" Fast saving
nmap <leader>w :w!<cr>
" Fast quit
nnoremap <leader>q :qa<cr>
" Down is really the next line
nnoremap j gj
nnoremap k gk
" Resize vsplit
nmap <C-v> :vertical resize +5
nmap 25 :vertical resize 40<cr>
nmap 50 <c-w>=
nmap 75 :vertical resize 120<cr>
" Easier navigation between splits
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Open splits
nmap vs :vsplit<cr>
nmap sp :split<cr>
" Execute current file
nnoremap <leader>r :!%:p
au FileType go map <leader>r :!go run %<CR>
" tab mapping
map <D-1> 1gt
map <D-2> 2gt
map <D-3> 3gt
map <D-4> 4gt
map <D-5> 5gt
map <D-6> 6gt
map <D-7> 7gt
map <D-8> 8gt
map <D-9> 9gt
map <D-t> :tabnew<CR>
map <D-w> :tabclose<CR>
" :W sudo saves the file (useful for handling the permission-denied error)
command W w !sudo tee % > /dev/null