-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
301 lines (210 loc) · 6.56 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
execute pathogen#infect()
" VIM SETTINGS
" enable syntax highlighting
syntax on
" use 4 spaces for indentation
set shiftwidth=4
set smarttab
" indent 4 spaces using tab
set tabstop=4
filetype indent on
filetype plugin on
" change tabs to spaces
set expandtab
" always show 5 lines above/below cursor
set so=5
" 'shortcut' key :)
let mapleader = ","
let g:mapleader = ","
" disable sounds
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" highlight search results
set hlsearch
" realtime search highlight
set incsearch
" disable backup/swap files
set nobackup
set noswapfile
set nowb
" auto-indent, smart indent
set ai
set si
" wrap lines visually
set nowrap
" wrap lines in chosen places
set linebreak
" don't 'really' break lines
set textwidth=0
set wrapmargin=0
" remember cursor position in files
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" use system keyboard
set clipboard=unnamedplus
" don't copy when deleting
nnoremap d "_d
vnoremap d "_d
" show line numbers
set nu relativenumber
set listchars=trail:·
set completeopt=longest,menuone
autocmd FileType scss setlocal iskeyword+=-,$,%,@
autocmd FileType typescript setlocal iskeyword+=-,$
autocmd FileType php setlocal iskeyword+=-,$
autocmd FileType html setlocal iskeyword+=-
set cursorline
set guicursor=
set conceallevel=0
" /VIM SETTINGS
" PLUGINS SETTINGS
" hide nerdtree after selecting file
let NERDTreeQuitOnOpen=1
" always show tabline
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 1
" emmed enabled only in insert mode, with binding Ctrl-E,
let g:user_emmet_mode='i'
let g:user_emmet_leader_key='<C-E>'
" open files from CtrlP in new buffer with Enter, or in current buffer with Ctrl-T
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("e")': ['<c-t>'],
\ 'AcceptSelection("b")': ['<cr>'],
\ }
let g:ctrlp_max_files = 50000
let g:ctrlp_working_path_mode = ''
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_match_window = 'results:100'
let g:ctrlp_user_command = 'P=%s; find "$P" -type f -not -wholename "$P/.git/*" -not -wholename "$P/vendor/*"'
" disable auto-save
let g:workspace_autosave = 0
let g:workspace_session_name = '.session.vim'
let g:workspace_persist_undo_history = 0
let g:indentguides_spacechar = '┆'
let g:indentguides_tabchar = '¦'
" Code::Stats
" let g:codestats_api_key = ''
let g:airline_section_x = airline#section#create_right(['tagbar', 'filetype', '%{CodeStatsXp()}'])
" /PLUGINS SETTINGS
" FUNCTIONS
" hightlight word under cursor
function Hlw()
exe printf('match IncSearch /\V\<%s\>/', escape(expand('<cword>'), '\/'))
endfunction
" toggle gitgutter/line numbers
function! H_num_switch()
if &nu && &rnu
set number
set norelativenumber
elseif &nu
set nonumber
set norelativenumber
else
set number
set relativenumber
endif
if &nu
GitGutterSignsEnable
IndentGuidesToggle
endif
endfunction
:command -nargs=+ Ggr execute 'silent Ggrep!' <q-args> | cw | redraw!
function! WriteSudo()
:silent w !sudo tee %
:e!
endfunction
:command W call WriteSudo()
" /FUNCTIONS
" SHORTCUTS / REMAPS
" fast save with ,w
nmap <leader>w :w!<cr>
" toggle paste mode with F2
set pastetoggle=<F2>
" highlight word under cursor using ,/
nmap <leader>/ :Ggr <cword><CR>
nmap <leader>? :Ggr ''<left>
" disable gitgutter/line numbers with F3
nnoremap <F3> :call H_num_switch()<CR>
" unindent line on Shift-Tab (in normal/insert mode)
nnoremap <S-Tab> i<C-d><Esc>
inoremap <S-Tab> <C-d>
" indent line on Tab (in normal mode)
nnoremap <Tab> :><cr>
" duplicate line on Ctrl-D (in normal/insert mode)
nnoremap <C-d> :t.<cr>
inoremap <C-d> <Esc>:t.<cr>i
" duplicate selection on Ctrl-D (in visual mode)
vnoremap <C-d> y'>pgv
" indent/unindent selected lines with Tab (in visual mode)
vnoremap <Tab> ><cr>gv
vnoremap <S-Tab> <<cr>gv
" scroll view using Ctrl-Up / Ctrl-Down (in normal/insert mode)
map <C-Down> <C-E>
map <C-Up> <C-Y>
imap <C-Down> <Esc><C-E>a
imap <C-Up> <Esc><C-Y>a
" open nerdtree with Alt-1 (in normal mode)
map <M-1> :NERDTreeToggle<CR>
" change splits with Ctrl-Alt-Left / Ctrl-Alt-Right / Ctrl-Alt-Up / Ctrl-Alt-Down (in normal mode)
nnoremap <C-M-Up> <C-W><Up>
nnoremap <C-M-Down> <C-W><Down>
nnoremap <C-M-Right> <C-W><Right>
nnoremap <C-M-Left> <C-W><Left>
" switch tabs with Alt-Left / Alt-Right (in normal/insert mode; switching in insert mode switches to normal mode)
nnoremap <M-Right> :tabnext<CR>
nnoremap <M-Left> :tabprevious<CR>
inoremap <M-Right> <Esc>:tabnext<CR>
inoremap <M-Left> <Esc>:tabprevious<CR>
" switch buffers with Alt-Up / Alt-Down (in normal/insert mode; switching in insert mode switches to normal mode)
nnoremap <M-Up> :bp!<CR>
nnoremap <M-Down> :bn!<CR>
inoremap <M-Up> <Esc>:bp!<CR>
inoremap <M-Down> <Esc>:bn!<CR>
" move lines up/down (in normal/insert/visual mode)
nnoremap <S-Up> :m .-2<cr>
nnoremap <S-Down> :m .+1<cr>
inoremap <S-Up> <Esc>:m .-2<CR>==gi
inoremap <S-Down> <Esc>:m .+1<CR>==gi
vnoremap <S-Up> :m '<-2<CR>gv=gv
vnoremap <S-Down> :m '>+1<CR>gv=gv
nnoremap <C-F> :call Hlw()<cr>
" close buffer with Ctrl-K
map <C-k> :bd<CR>
" popup menu
inoremap <expr> <CR> pumvisible() ? '<C-y>' : '<CR>'
inoremap <expr> <Esc> pumvisible() ? '<C-e>' : '<Esc>'
inoremap <expr> <C-p> pumvisible() ? '<C-p>' : '<C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
inoremap <expr> <Down> pumvisible() ? '<C-n>' : '<Down>'
inoremap <expr> <Up> pumvisible() ? '<C-p>' : '<Up>'
vnoremap // y/<C-R>"<CR>N
nnoremap <C-w>o :only!<CR>
" Fugitive conflict resolution
nnoremap <leader>gd :Gvdiff<CR>
nnoremap gdh :diffget //2<CR>
nnoremap gdl :diffget //3<CR>
" highlighting lines
nnoremap <silent> <Leader>h :call matchadd('LineHighlight', '\%'.line('.').'l')<CR>
nnoremap <silent> <Leader>he :call matchadd('LineHighlightError', '\%'.line('.').'l')<CR>
nnoremap <silent> <Leader>hw :call matchadd('LineHighlightWarning', '\%'.line('.').'l')<CR>
nnoremap <silent> <Leader>hi :call matchadd('LineHighlightInfo', '\%'.line('.').'l')<CR>
nnoremap <silent> <Leader>hs :call matchadd('LineHighlightSuccess', '\%'.line('.').'l')<CR>
nnoremap <silent> <Leader>hc :call clearmatches()<CR>
" /SHORTCUTS / REMAPS
" COLOR_SCHEME
" 256 colors
set t_Co=256
" deus color scheme
set background=dark
" color scheme
colors deus
" /COLOR_SCHEME
" highlighted lines colors
hi LineHighlight ctermbg=240
hi LineHighlightError ctermbg=124
hi LineHighlightWarning ctermbg=166
hi LineHighlightInfo ctermbg=17
hi LineHighlightSuccess ctermbg=22