-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
executable file
·400 lines (314 loc) · 10.8 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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
" Excute pathiogen
execute pathogen#infect()
call pathogen#helptags()
"set term=nxterm
" Set tab stop - how many columns a tab counts for. Linux kernel code expects each tab to be eight columns wide. Visual Studio expects each tab to be four columns wide. This is the only command here that will affect how existing text displays
" Set soft tab stop - how many columns vim uses when you hit Tab in insert mode. If softtabstop is less than tabstop and expandtab is not set, vim will use a combination of tabs and spaces to make up the desired spacing. If softtabstop equals tabstop and expandtab is not set, vim will always use tabs. When expandtab is set, vim will always use the appropriate number of spaces
" Set tab indentation - how many columns text is indented with the reindent operations (<< and >>) and automatic C-style indentation
" Set no expand tab - when expandtab is set, hitting Tab in insert mode will produce the appropriate number of spaces
:set tabstop=4 softtabstop=4 shiftwidth=4 expandtab
" add yaml stuffs
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" Indent following lines to the indentation of previous line.
set autoindent
" set indentation
set cindent
" Display when in Insert, Append or Replace mode on the bottom side
set showmode
" Show line numbers on right side of each line
set number
" Display line and column numbers in bottom right side
set ruler
" filetype
filetype plugin indent on
set nocompatible
set backspace=2
set foldmethod=marker
" set color sheme
colorscheme default
" Use 256 colours (Use this setting only if your terminal supports 256
" colours)
set t_Co=256
" Hide the mouse when typing text
set mousehide
" Ebanle mouse
set mouse=a
" Make shift-insert work like in Xterm
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>
" Switch on syntax highlighting if it wasn't on yet.
if !exists("syntax_on")
syntax on
endif
" Switch on search pattern highlighting.
set hlsearch
" Set font
"set gfn=Courier\ 10\ Pitch\ 12
"set gfn=Courier\ 10\ Pitch\ 10
""""""""""""""""" Tlist
" Open the taglist window when Vim starts.
"autocmd VimEnter * Tlist " instead of let Tlist_Auto_Open=1
" Place the taglist window on the right side.
let Tlist_Use_Right_Window=1
" Show tags for the current buffer only.
let Tlist_Show_One_File=1
" Open tagbar if already opened in new tab
" autocmd BufEnter * nested :call tagbar#autoopen(0)
"Tags plugin
map <F3> :TagbarToggle<CR>
"Nerd tree plugin
map <F2> :NERDTreeTabsToggle<cr>
" set split to right and below instead of left and above
set splitright
set splitbelow
" toggle hidden chrachters: Deprecated
" nmap <leader>l :set list!<CR>
" Launch white space removal
nmap _$ :call <SID>StripTrailingWhitespaces()<CR>
" remove white spaces accross the file
function! <SID>StripTrailingWhitespaces()
" save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history,
let @/=_s
call cursor(l, c)
endfunction"
" open files easly
map <leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
map <leader>sp :sp <C-R>=expand("%:p:h") . "/" <CR>
map <leader>vsp :vsp <C-R>=expand("%:p:h") . "/" <CR>
map <leader>et :tabe <C-R>=expand("%:p:h") . "/" <CR>
" run Wrap to change the wrapping to words
command! -nargs=* Wrap set wrap linebreak nolist
Wrap
" map numbers on of toggle
map <leader>nu :set nu!<CR>
" Move easyly between visual lines
map <C-j> gj
map <C-k> gk
" some iretating commands
command! Q q
command! W w
command! Wq wq
command! WQ wq
command! WA wa
command! Wa wa
command! Qa qa
command! QA qa
" Highlight white spaces
highlight RedundantSpaces ctermbg=green guibg=lightgreen
match RedundantSpaces /\s\+$/
" Refresh the page
map <F5> :edit <cr>
"All kinds of addings to make word complete easier
set completeopt=longest,menuone
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <expr> <C-n> pumvisible() ? '<C-n>' : '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
inoremap <expr> <M-,> pumvisible() ? '<C-n>' : '<C-x><C-o><C-n><C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
" set vertical column to 80 characters
set colorcolumn=80
" always show statusline
set laststatus=2
" Open you vimrc from everywhere
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
" Source your vimrc
nnoremap <leader>sv :source $MYVIMRC<cr>
" Do not sort by name
let g:tagbar_sort = 0
" Set width to 30
let g:tagbar_width = 30
" Continue where you left off on each file
if has("autocmd")
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
endif
set relativenumber
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END
" if has("autocmd")
" filetype on
" augroup my_autocmds
" autocmd!
" " Toggle insert/visual line numbers
" " autocmd InsertEnter * :set number | :set norelativenumber
" " autocmd InsertLeave * :set number | :set relativenumber
" augroup END
" endif
" Run NERDTreeTabs by default
" let g:nerdtree_tabs_open_on_console_startup=1
" Set NERDTree to 30
let NERDTreeWinSize = 20
" Airline additions
" let g:airline_extensions = ['csv','whitespace']
" let g:airline#extensions#csv#column_display = 'Name'
" Do not show branch
let g:airline_section_b = ''
" Do not show encoding
let g:airline_section_y = ''
"let g:csv_no_conceal = 1
" set clipboard=unnamedplus
autocmd FileType python map <buffer> <leader>8 :call Pep8()<CR>
autocmd BufNewFile,BufRead *.cl set syntax=cpp
autocmd BufNewFile,BufReadPost *.ino,*.pde set filetype=cpp
" :SW sudo saves the file
" (useful for handling the permission-denied error)
command! SW w !sudo tee % > /dev/null
" This is totally awesome - remap jj to escape in insert mode. You'll never type jj anyway, so it's great!
inoremap jj <esc>
nnoremap JJJJ <nop>
" Ignore compiled files
set wildignore=*.o,*~,*.pyc,.*.swp
if has("win16") || has("win32")
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
else
set wildignore+=.git\*,.hg\*,.svn\*
endif
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Make sure that extra margin on left is removed
set foldcolumn=0
" Enable Ctrl-A/Ctrl-X to work on octal and hex numbers, as well as characters
set nrformats=octal,hex ",alpha
" Use for snippets
"
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<c-b>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
" Add space after comment
" let g:NERDSpaceDelims = 1
" vim-instant-markdown
let g:instant_markdown_autostart = 0
" au BufNewFile,BufRead *.vy set filetype=python
" set term=screen-256color
" set term=ansi
" Table mode
function! s:isAtStartOfLine(mapping)
let text_before_cursor = getline('.')[0 : col('.')-1]
let mapping_pattern = '\V' . escape(a:mapping, '\')
let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\')
return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$')
endfunction
inoreabbrev <expr> <bar><bar>
\ <SID>isAtStartOfLine('\|\|') ?
\ '<c-o>:TableModeEnable<cr><bar><space><bar><left><left>' : '<bar><bar>'
inoreabbrev <expr> __
\ <SID>isAtStartOfLine('__') ?
\ '<c-o>:silent! TableModeDisable<cr>' : '__'
" Help menu
inoremap <F1> <Esc>
noremap <F1> :call MapF1()<CR>
" Open help menu of F1
function! MapF1()
if &buftype == "help"
exec 'quit'
else
exec 'help'
endif
endfunction
" Ale configs
let g:ale_set_balloons = 1
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
let g:ale_list_window_size = 5
" Jump to next ale error/warning
nmap <silent> <leader>k <Plug>(ale_previous_wrap_error)
nmap <silent> <leader>j <Plug>(ale_next_wrap_error)
nmap <silent> <leader>J <Plug>(ale_next_wrap_warning)
nmap <silent> <leader>K <Plug>(ale_previous_wrap_warning)
let g:ale_markdown_remark_lint_options = "-u preset-lint-recommended"
" Toggle ALE quick list
noremap <Leader>l :call QFixToggle()<CR>
function! QFixToggle()
if exists("g:qfix_win")
cclose
unlet g:qfix_win
else
copen 10
let g:qfix_win = bufnr("$")
endif
endfunction
" ALE fixers
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ 'typescript': ['tsserver', 'eslint'],
\ 'json': ['jq', 'jsonlint'],
\ 'vue': ['eslint']
\}
let g:ale_fixers = {
\ 'javascript': ['eslint', 'prettier'],
\ 'typescript': ['prettier', 'eslint'],
\ 'vue': ['eslint'],
\ 'scss': ['prettier'],
\ 'html': ['prettier'],
\ 'json': ['prettier'],
\ 'solidity': ['prettier']
\}
let g:ale_fix_on_save = 1
let g:EditorConfig_exec_path = '/usr/bin/editorconfig'
" Neocomplete
source $HOME/.vim/neocomp.vim
" Golang
autocmd BufRead,BufNewFile *.go source $HOME/.vim/govim.vim
" Rust
autocmd BufRead,BufNewFile *.rs source $HOME/.vim/rustvim.vim
" TypeScript
autocmd FileType typescript source $HOME/.vim/ts.vim
" JavaScript
autocmd FileType javascript source $HOME/.vim/js.vim
" Python
autocmd FileType python source $HOME/.vim/pyvim.vim
" Latex
source $HOME/.vim/texvim.vim
" Convert files
source $HOME/.vim/convert.vim
" Grammarous
" source /User/amanusk/.vim/grammer.vim
" InstantRst
" source /User/amanusk/.vim/instantrt.vim
" Add rls to path
set runtimepath+=/Users/amanusk/.vim-plugins/LanguageClient-neovim
let g:ackprg = 'ag --nogroup --nocolor --column -w'
" hard time on
let g:hardtime_default_on = 0
" Disable quick fix window and use ale
let g:tsuquyomi_disable_quickfix = 1
" Required for operations modifying multiple buffers like rename.
set hidden
" Which version of rls to run
let g:LanguageClient_serverCommands = {
\ 'javascript': ['javascript-typescript-stdio'],
\ 'rust': ['~/.cargo/bin/rustup', 'run', 'nightly-2019-07-10-x86_64-apple-darwin', 'rls'],
\ }
" Use completing with rls
set completefunc=LanguageClient#complete
function LC_maps()
if has_key(g:LanguageClient_serverCommands, &filetype)
nnoremap <silent> gc :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> gr :call LanguageClient#textDocument_rename()<CR>
endif
endfunction
autocmd FileType * call LC_maps()
" Solidity tabs
autocmd BufNewFile,BufRead *.sol setlocal shiftwidth=4 softtabstop=4 expandtab
autocmd BufNewFile,BufRead *.sol setlocal autoindent
autocmd BufNewFile,BufRead *.sol setlocal cindent
autocmd BufNewFile,BufRead *.sol setlocal smartindent
" Disalbe ale for lates
" let g:ale_pattern_options = {
" \ '.*\.tex$': {'ale_enabled': 0},
" \}