Repository navigation
Expand file tree
/
Copy pathvimrc
More file actions
165 lines (136 loc) · 3.89 KB
/
Copy pathvimrc
File metadata and controls
165 lines (136 loc) · 3.89 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
set encoding=utf-8
set fileencodings=utf-8,cp949
set t_Co=256
set nocompatible " be iMproved, required
filetype off " required
" Manual vim-plug installation
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
call plug#begin()
" UI
Plug 'yous/vim-open-color'
Plug 'w0ng/vim-hybrid'
Plug 'vim-airline/vim-airline'
" Languages
Plug 'petRUShka/vim-sage'
Plug 'lervag/vimtex', { 'for': ['bib', 'tex'] }
" Util
Plug 'ervandew/supertab'
Plug 'scrooloose/nerdtree'
Plug 'airblade/vim-gitgutter'
" snippet
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'
Plug 'garbas/vim-snipmate'
Plug 'honza/vim-snippets'
" Nerdtree
Plug 'preservim/nerdtree'
call plug#end()
let g:snipMate = {'snippet_version': 1}
autocmd FileType python setlocal completeopt-=preview
" Nerd-tree
" let g:NERDTreeDirArrows=0
let g:NERDTreeDirArrowExpandable = '+'
let g:NERDTreeDirArrowCollapsible = '-'
" Close all open buffers on entering a window if the only
" buffer that's left is the NERDTree buffer
function! s:CloseIfOnlyNerdTreeLeft()
if exists("t:NERDTreeBufName")
if bufwinnr(t:NERDTreeBufName) != -1
if winnr("$") == 1
q
endif
endif
endif
endfunction
" ctrlp
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
syntax on
set number
set background=dark
set backspace=2
set tabstop=2
set softtabstop=2
set shiftwidth=2
set scrolloff=4
set expandtab
set smartindent
set nowrap
set undolevels=1000
set laststatus=2
set mouse=a
" Briefly jump to the matching one when a bracket is inserted
set showmatch
" set for tex
if has("autocmd")
au BufReadPost .tex set filetype=tex
au filetype tex set grepprg=grep\ -nH\ $*
au filetype tex set ai
au FileType c,cpp,java,json,markdown,perl,python
\ setlocal softtabstop=4 shiftwidth=4 tabstop=6
endif
" colorscheme hybrid
" Highlight trailing whitespace
highlight ExtraWhitespace ctermbg=darkgreen guibg=lightgreen
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
if version >= 702
autocmd BufWinLeave * call clearmatches()
endif
autocmd FileType c,cpp,java,python,sage setlocal expandtab
autocmd FileType html,php,js,css setlocal tabstop=2 softtabstop=2 shiftwidth=2
set display+=uhex
if has('extra_search')
set hlsearch
endif
" Exit Paste mode when leaving Insert mode
autocmd InsertLeave * set nopaste
" Move between splitted windows
nnoremap <tab> <C-W>w
" To remove highlights
nnoremap <C-l> :nohlsearch<CR>
" Center display after searching
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
if &term =~ "screen"
" 256 colors
let &t_Co = 256
" restore screen after quitting
let &t_ti = "\<Esc>7\<Esc>[r\<Esc>[?47h"
let &t_te = "\<Esc>[?47l\<Esc>8"
if has("terminfo")
let &t_Sf = "\<Esc>[3%p1%dm"
let &t_Sb = "\<Esc>[4%p1%dm"
else
let &t_Sf = "\<Esc>[3%dm"
let &t_Sb = "\<Esc>[4%dm"
endif
endif
augroup vimrc
" C, C++ compile
autocmd FileType c,cpp map <F5> :w<CR>:make %<CR>
autocmd FileType c,cpp imap <F5> <Esc>:w<CR>:make %<CR>
autocmd FileType c
\ if !filereadable('Makefile') && !filereadable('makefile') |
\ setlocal makeprg=gcc\ -o\ %< |
\ endif
autocmd FileType cpp
\ if !filereadable('Makefile') && !filereadable('makefile') |
\ setlocal makeprg=g++\ -o\ %< |
\ endif
" Python 2, 3
autocmd FileType python map <F5> :w<CR>:!python %<CR>
autocmd FileType python imap <F5> <Esc>:w<CR>:!python %<CR>
autocmd FileType python map <F6> :w<CR>:!python3 %<CR>
autocmd FileType python imap <F6> <Esc>:w<CR>:!python3 %<CR>
" sage
autocmd FileType sage.python map <F5> :w<CR>:!sage %<CR>
augroup END