-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
355 lines (282 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
" All system-wide defaults are set in $VIMRUNTIME/archlinux.vim (usually just
" /usr/share/vim/vimfiles/archlinux.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vimrc), since archlinux.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing archlinux.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages.
runtime! archlinux.vim
" If you prefer the old-style vim functionalty, add 'runtime! vimrc_example.vim'
" Or better yet, read /usr/share/vim/vim80/vimrc_example.vim or the vim manual
" and configure vim to your own liking!
" do not load defaults if ~/.vimrc is missing
"let skip_defaults_vim=1
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" --> GENERAL
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=500
" Pathogen
execute pathogen#infect()
" Enable filetype plugins
filetype plugin indent on
" Set map leader
let mapleader=","
" Fast saving
nmap <leader>w :w!<cr>
" Copy/paste to/from clipboard (clipboard feature needed)
vmap <C-c> "+yi
vmap <C-x> "+c
vmap <C-l> c<ESC>"+p
imap <C-l> <C-r><C-o>+
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" --> VIM user interface
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 7 lines to the curson - when moving vertically using j/k
set so=7
" Always show current position
set ruler
set number
set relativenumber
" Trun on the Wild menu
set wildmenu
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Make search act liek search in modern browsers
set incsearch
" Don't redraw while executing macros (perf config)
set lazyredraw
" For regular expressions trun magic on
set magic
" Show matching brackets when text indicator is over them
set showmatch
" How many thenths of secound to blink when matching brackets
set mat=2
" No annoyinh sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" --> COLORS AND FONTS
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax on
set cursorline
" Enable 256 colors palette
"let g:solarized_termcolors=256
" If it is between 6AM and 5PM then light else dark solarized scheme
let hour = strftime("%H")
if 6 <= hour && hour < 18
set background=light
else
set background=dark
endif
set background=dark
" Solarized color scheme
colorscheme solarized
" Set utf8 as standard encoding
set encoding=utf8
" Toggle between dark and light backgrounds
map <F9> :let &background = ( &background == "dark"? "light" : "dark" )<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" --> TEXT, ,AB AND INDENT RELATED
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces insted of tabs
set expandtab
" Be smart when using tabs ;)
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Line break on 500 characters
set lbr
set tw=500
set ai " auto indent
set si " smart indent
set wrap " wrap lines
set colorcolumn=80
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" --> Spell checker
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Run Spell checker with <F6>
map <F6> :setlocal spell! spelllang=en<CR>
" Change spell checker to serbian latin
map <F7> :setlocal spell! spelllang=sr@latin<CR>
" Change spell checker to serbian
map <F8> :setlocal spell! spelllang=sr<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" --> VISUAL MODE RELATED
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Visual mode pressing * or # searches for the current selection
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" --> MOVING AROUND, TABS, WINDOWS AND BUFFERS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Disable highlight when <leader><CR> is pressed
map <silent> <leader><CR> :noh<CR>
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Close the current buffer
map <leader>bd :Bclose<CR>:tabclose<CR>gT
" Close all the buffers
map <leader>ba :bufdo bd<CR>
map <leader>l :bnext<CR>
map <leader>h :bpreviouse<CR>
" Mapping for managing tab
map <leader>tn :tabnew<CR>
map <leader>to :tabonly<CR>
map <leader>tc :tabclose<CR>
map <leader>tm :tabremove
map <leader>t<leader> :tabnext
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" --> Status line
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Always show the status line
set laststatus=2
set statusline=\ %{HasPaste()}%<%-15.25(%f%)%m%r%h\ %w\ \
set statusline+=\ \ \ [%{&ff}/%Y]
set statusline+=\ \ \ %<%20.30(%{hostname()}:%{CurDir()}%)\
set statusline+=%=%-10.(%l,%c%V%)\ %p%%/%L
function! CurDir()
let curdir = substitute(getcwd(), $HOME, "~", "")
return curdir
endfunction
function! HasPaste()
if &paste
return '[PASTE]'
else
return ''
endif
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" --> EDITING MAPPINGS """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remam VIM 0 to first non-blank character
map 0 ^
"nmap <M-j> mz:m+<cr>`z
"nmap <M-k> mz:m-2<cr>`z
"vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
"vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
"if has("mac") || has("macunix")
" nmap <D-j> <M-j>
"nmap <D-k> <M-k>
"vmap <D-j> <M-j>
"vmap <D-k> <M-k>
"endif
" Delete trailing white space on save, useful for some filetypes ;)
fun! CleanExtraSpaces()
let save_cursor = getpos(".")
let old_query = getreg('/')
silent! %s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfun
if has("autocmd")
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" --> TURN PERSISTENT UNDO ON
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
try
set undodir=~/.vim_runtime/temp_dirs/undodir
set undofile
catch
endtry
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" --> PARENTHESIS/BRACKET
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
vnoremap ( <esc>`>a)<esc>`<i(<esc>
vnoremap [ <esc>`>a]<esc>`<i[<esc>
vnoremap { <esc>`>a}<esc>`<i{<esc>
vnoremap ' <esc>`>a'<esc>`<i'<esc>
vnoremap " <esc>`>a"<esc>`<i"<esc>
inoremap ( ()<esc>i
inoremap [ []<esc>i
inoremap { {}<esc>i
inoremap ' ''<esc>i
inoremap " ""<esc>i
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" --> OMNI COMPLETION
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable omni completion
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType java set omnifunc=javacomplete#Complete
" use syntax complete if nothing else available
if has("autocmd") && exists("+omnifunc")
autocmd Filetype *
\ if &omnifunc == "" |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
endif
set cot-=preview "disable doc preview in omnicomplete
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" -->PYTHON
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let python_highlight_all = 1
au FileType python syn keyword pythonDocorater True None False self
au BufNewFile,BufRead *.jinja set syntax=htmljinja
au BufNewFile,BufRead *.mako set tf=mako
au FileType python map <buffer> F :set foldmethod=indent<CR>
au FileType python set cindent
au FileType python set cinkeys-=0#
au FileType python set indentkeys-=0#
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" --> MARKDOWN
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Interpret .md files, etc. as .markdown
let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'}
" Code snippets
au FileType markdown,rmd inoremap <leader>n ---<CR>title:<CR>author:<CR>output:<CR>---<Esc>3kA
au FileType markdown,rmd inoremap <leader>b ****<Esc>hi
au FileType markdown,rmd inoremap <leader>s ~~~~<Esc>hi
au FileType markdown,rmd inoremap <leader>e **<Esc>i
au FileType markdown,rmd inoremap <leader>i ![]()<Esc>F[a
au FileType markdown,rmd inoremap <leader>a []()<Esc>F[a
au FileType markdown,rmd inoremap <leader>l ---------<CR>
au FileType rmd inoremap <leader>t $$<Esc>i
au FileType rmd inoremap <leader>1 ````<Esc>hi
au FileType rmd inoremap <leader>r ```{r}<CR>```<Esc>ko
au FileType rmd inoremap <leader>p ```{python}<CR>```<Esc>ko
au FileType rmd inoremap <leader>c ```<CR>```<Esc>ko
" Auto compile
au FileType rmd map <F5> :!echo<Space>"require(rmarkdown);<Space>render('<c-r>%')"<Space>\|<Space>R<Space>--vanilla<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" --> SYNTASTIC
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nmap <silent> <leader>a <Plug>(ale_next_wrap)
" Disable highlighting
let g:ale_set_highlight=0
" Only run linting when saving the file
let g:ale_lint_on_text_changed='never'
let g:ale_lint_on_enter=0
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" -->LATEX
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:livepreview_previewer='zathura'
" Run Latex Live Preview
nmap <F12> :LLPStartPreview<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" --> NERD TREE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let NERDTreeShowHidden=0
let NERDTreeIgnore=['\.pyc$', '__pycashe__']
let g:NERDTreeWinSize=25
map <leader>nn :NERDTreeToggle<CR>
map <leader>nb :NERDTreeFromBookmaprk<Space>
map <leader>nf :NERDTreeFind<CR>