forked from CatalinManolescu/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
226 lines (197 loc) · 5.84 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
set nocompatible " not vi compatible
"------------------
" Syntax and indent
"------------------
syntax on " turn on syntax highlighting
set showmatch " show matching braces when text indicator is over them
" highlight current line, but only in active window
augroup CursorLineOnlyInActiveWindow
autocmd!
autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
augroup END
" vim can autodetect this based on $TERM (e.g. 'xterm-256color')
" but it can be set to force 256 colors
" set t_Co=256
if has('gui_running')
colorscheme solarized
let g:lightline = {'colorscheme': 'solarized'}
elseif &t_Co < 256
colorscheme default
set nocursorline " looks bad in this mode
else
set background=dark
let g:solarized_termcolors=256 " instead of 16 color with mapping in terminal
colorscheme solarized
" customized colors
highlight SignColumn ctermbg=234
highlight StatusLine cterm=bold ctermfg=245 ctermbg=235
highlight StatusLineNC cterm=bold ctermfg=245 ctermbg=235
let g:lightline = {'colorscheme': 'dark'}
highlight SpellBad cterm=underline
" patches
highlight CursorLineNr cterm=NONE
endif
filetype plugin indent on " enable file type detection
set autoindent
"---------------------
" Basic editing config
"---------------------
set shortmess+=I " disable startup message
set nu " number lines
set rnu " relative line numbering
set incsearch " incremental search (as string is being typed)
set hls " highlight search
set listchars=tab:>>,nbsp:~ " set list to see tabs and non-breakable spaces
set lbr " line break
set scrolloff=5 " show lines above and below cursor (when possible)
set noshowmode " hide mode
set laststatus=2
set backspace=indent,eol,start " allow backspacing over everything
set timeout timeoutlen=1000 ttimeoutlen=100 " fix slow O inserts
set lazyredraw " skip redrawing screen in some cases
set autochdir " automatically set current directory to directory of last opened file
set hidden " allow auto-hiding of edited buffers
set history=8192 " more history
set nojoinspaces " suppress inserting two spaces between sentences
" use 4 spaces instead of tabs during formatting
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
" smart case-sensitive search
set ignorecase
set smartcase
" tab completion for files/bufferss
set wildmode=longest,list
set wildmenu
set mouse+=a " enable mouse mode (scrolling, selection, etc)
if &term =~ '^screen'
" tmux knows the extended mouse mode
set ttymouse=xterm2
endif
set nofoldenable " disable folding by default
"--------------------
" Misc configurations
"--------------------
" unbind keys
map <C-a> <Nop>
map <C-x> <Nop>
nmap Q <Nop>
" disable audible bell
set noerrorbells visualbell t_vb=
" open new split panes to right and bottom, which feels more natural
set splitbelow
set splitright
" quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" movement relative to display lines
nnoremap <silent> <Leader>d :call ToggleMovementByDisplayLines()<CR>
function SetMovementByDisplayLines()
noremap <buffer> <silent> <expr> k v:count ? 'k' : 'gk'
noremap <buffer> <silent> <expr> j v:count ? 'j' : 'gj'
noremap <buffer> <silent> 0 g0
noremap <buffer> <silent> $ g$
endfunction
function ToggleMovementByDisplayLines()
if !exists('b:movement_by_display_lines')
let b:movement_by_display_lines = 0
endif
if b:movement_by_display_lines
let b:movement_by_display_lines = 0
silent! nunmap <buffer> k
silent! nunmap <buffer> j
silent! nunmap <buffer> 0
silent! nunmap <buffer> $
else
let b:movement_by_display_lines = 1
call SetMovementByDisplayLines()
endif
endfunction
" toggle relative numbering
nnoremap <C-n> :set rnu!<CR>
" save read-only files
command -nargs=0 Sudow w !sudo tee % >/dev/null
"---------------------
" Plugin configuration
"---------------------
" nerdtree
nnoremap <Leader>n :NERDTreeToggle<CR>
nnoremap <Leader>f :NERDTreeFind<CR>
" buffergator
let g:buffergator_suppress_keymaps = 1
nnoremap <Leader>b :BuffergatorToggle<CR>
" gundo
nnoremap <Leader>u :GundoToggle<CR>
if has('python3')
let g:gundo_prefer_python3 = 1
endif
" ctrlp
nnoremap ; :CtrlPBuffer<CR>
let g:ctrlp_switch_buffer = 0
let g:ctrlp_show_hidden = 1
" ag / ack.vim
command -nargs=+ Gag Gcd | Ack! <args>
nnoremap K :Gag "\b<C-R><C-W>\b"<CR>:cw<CR>
if executable('ag')
let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden -g ""'
let g:ackprg = 'ag --vimgrep'
endif
" syntastic
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_mode_map = {
\ 'mode': 'passive',
\ 'active_filetypes': [],
\ 'passive_filetypes': []
\}
nnoremap <Leader>s :SyntasticCheck<CR>
nnoremap <Leader>r :SyntasticReset<CR>
nnoremap <Leader>i :SyntasticInfo<CR>
nnoremap <Leader>m :SyntasticToggleMode<CR>
" easymotion
map <Space> <Plug>(easymotion-prefix)
" incsearch
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
" incsearch-easymotion
map z/ <Plug>(incsearch-easymotion-/)
map z? <Plug>(incsearch-easymotion-?)
map zg/ <Plug>(incsearch-easymotion-stay)
" argwrap
nnoremap <Leader>w :ArgWrap<CR>
noremap <Leader>x :OverCommandLine<CR>
" markdown
let g:markdown_fenced_languages = [
\ 'bash=sh',
\ 'c',
\ 'coffee',
\ 'erb=eruby',
\ 'javascript',
\ 'json',
\ 'perl',
\ 'python',
\ 'ruby',
\ 'yaml',
\ 'go',
\ 'racket',
\ 'haskell',
\ 'rust',
\]
let g:markdown_syntax_conceal = 0
let g:markdown_folding = 1
" fugitive
set tags^=.git/tags;~
"---------------------
" Local customizations
"---------------------
" local customizations in ~/.vimrc_local
let $LOCALFILE=expand("~/.vimrc_local")
if filereadable($LOCALFILE)
source $LOCALFILE
endif