-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathvimrc
380 lines (320 loc) · 9.88 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
" VUNDLE
" =============================================================
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-eunuch'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-unimpaired'
Plugin 'tpope/vim-abolish'
Plugin 'vim-ruby/vim-ruby'
" Plugin 'mattn/emmet-vim', { 'for': ['javascript.jsx', 'html', 'css'] }
Plugin 'prettier/vim-prettier', { 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'markdown', 'vue', 'yaml', 'html'] }
Plugin 'w0rp/ale'
Plugin 'rbgrouleff/bclose.vim'
Plugin 'cohama/lexima.vim'
Plugin 'easymotion/vim-easymotion'
Plugin 'SirVer/ultisnips'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'gorkunov/smartpairs.vim'
Plugin 'djoshea/vim-autoread'
Plugin 'junegunn/fzf'
Plugin 'junegunn/fzf.vim'
Plugin 'posva/vim-vue'
Plugin 'matze/vim-move'
Plugin 'pangloss/vim-javascript'
" Plugin 'othree/yajs.vim'
" Plugin 'othree/es.next.syntax.vim'
" Plugin 'othree/javascript-libraries-syntax.vim'
" Plugin 'isRuslan/vim-es6'
Plugin 'scrooloose/nerdtree'
Plugin 'mxw/vim-jsx', { 'for': ['jsx','javascript.jsx']}
Plugin 'tpope/vim-commentary' " or Plugin 'tomtom/tcomment_vim'
"Plugin 'ervandew/supertab'
Plugin 'othree/html5.vim'
" Colour Themes
Plugin 'GertjanReynaert/cobalt2-vim-theme'
Plugin 'altercation/vim-colors-solarized'
Plugin 'kaicataldo/material.vim'
Plugin 'dracula/vim'
" Test Run
Plugin 'tpope/vim-obsession'
Plugin 'lyokha/vim-xkbswitch' " Input Source Switcher
Plugin 'firegoby/html_entities_helper.vim'
Plugin 'dustinknopoff/TeaCode-Vim-Extension'
Plugin 'tpope/vim-vinegar'
Plugin 'itchyny/lightline.vim'
Plugin 'alvan/vim-closetag'
" Plugin 'ryanoasis/vim-devicons'
call vundle#end()
filetype plugin indent on
syntax on
runtime macros/matchit.vim
" =============================================================
" GENERAL SETTINGS
" =============================================================
set backspace=indent,eol,start
set history=1000
set ruler
set showcmd
set autoindent
set showmatch
set nowrap
set autoread
set autowrite
set backupdir=~/.tmp
set directory=~/.tmp
set viminfo+=!
set guioptions-=T
set laststatus=2
set scrolloff=3
set sidescrolloff=4
set hidden
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set regexpengine=1
" set relativenumber
set number
set wrap
set linebreak
set hlsearch
set incsearch
set ignorecase
set smartcase
set mouse=a
set shell=bash
set clipboard=unnamed
set winwidth=100
set winheight=5
set winminheight=5
set winheight=999
set noswapfile
set wildmenu
set nostartofline
" (Hopefully) removes the delay when hitting esc in insert mode
" set noesckeys
set ttimeout
set ttimeoutlen=1
set listchars=tab:>-,trail:~,extends:>,precedes:<,space:.
set ttyfast
" set lazyredraw
" set re=1
set path+=**
set tags=./tags;/
set encoding=UTF-8
"set foldmethod=indent
set signcolumn=yes
" =============================================================
" AUTOCOMMANDS
" =============================================================
if has("autocmd")
augroup vimrcEx
au!
autocmd BufRead *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>'))
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
autocmd BufRead * normal zR
" autocmd BufWinLeave *.* mkview
" autocmd BufWinEnter *.* silent loadview
au BufNewFile,BufReadPost *.md set filetype=markdown
au BufNewFile,BufReadPost *.vue syntax sync fromstart
autocmd FileType javascript set formatprg=prettier\ --stdin
"autocmd BufLeave,FocusLost * silent! wall
autocmd filetype crontab setlocal nobackup nowritebackup
augroup END
endif
" =============================================================
" MAPPINGS
" =============================================================
let mapleader = ","
" insert mode
"inoremap <c-e> <down>
"inoremap <c-n> <left>
"inoremap <c-y> <up>
"inoremap <c-i> <right>
" Quick open most used files
nnoremap <leader>em :!open -a 'Marked 2.app' '%:p'<cr>
nnoremap <leader>ev :e ~/.vimrc<cr>
nnoremap <leader>es :vs<cr>:UltiSnipsEdit<cr>
" UltiSnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
" create/open file in current folder
map <Leader>ee :e <C-R>=escape(expand("%:p:h"),' ') . '/'<CR>
nnoremap <silent> <space> :nohl<Bar>:echo<CR>
nnoremap <leader>w mzyyp`zj
nnoremap <leader>v :set invpaste paste?<CR>
nnoremap <leader>V V`]
nnoremap <leader>I V`]=
nnoremap <leader>a ggVG
nnoremap <leader>r :syntax sync fromstart<CR>
nmap k gk
nmap j gj
noremap <Leader>d :Bclose<CR>
noremap <Leader>D :bufdo bd<CR>
cnoremap %% <C-R>=expand("%:p:h") . "/" <CR>
" FZF
nnoremap <leader>f :GFiles<cr>
nnoremap <leader>t :Files<cr>
nnoremap <leader>. :Buffers<cr>
" Fugitive
nnoremap <leader>gg :Gstatus<CR>:only<CR>
nnoremap <leader>gw :Gwrite<CR>
" Tabs
nnoremap <leader>1 1gt<cr>
nnoremap <leader>2 2gt<cr>
nnoremap <leader>3 3gt<cr>
nnoremap <leader>4 4gt<cr>
" inc search for range commands
cnoremap $t <CR>:t''<CR>
cnoremap $T <CR>:T''<CR>
cnoremap $m <CR>:m''<CR>
cnoremap $M <CR>:M''<CR>
cnoremap $d <CR>:d<CR>``
" saves cursor after yanking in visual mode
vnoremap y myy`y
vnoremap Y myY`y
nnoremap <leader>s :w<cr>
" =============================================================
" PLUGINS CONFIGURATION
" =============================================================
" NERDTree
nnoremap <leader>q :NERDTreeToggle<cr>
let NERDTreeMinimalUI=1
let NERDTreeShowLineNumbers=1
let NERDTreeQuitOnOpen=1
let NERDTreeHijackNetrw = 0
" Lightline
let g:lightline = {
\ 'colorscheme': 'one',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#head'
\ },
\ }
" Easymotion
nmap S <Plug>(easymotion-s2)
nmap s <Plug>(easymotion-s)
" Vim Move
let g:move_key_modifier = 'C'
" Vue
" let g:vue_disable_pre_processors=1
" Markdown
let g:markdown_fenced_languages = ['css', 'erb=eruby', 'javascript', 'js=javascript', 'json=javascript', 'ruby', 'sass', 'xml', 'html']
" JSX
let g:jsx_ext_required = 0
let g:javascript_enable_domhtmlcss = 1
let g:used_javascript_libs = 'underscore,react'
" Emmet
" let g:user_emmet_settings={'javascript.jsx': {'extends':'jsx'}}
" let g:user_emmet_leader_key='<C-t>'
" Tag Autoclose
let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.vue'
" Layout switcher
let g:XkbSwitchLib = '/usr/local/lib/libInputSourceSwitcher.dylib'
let g:XkbSwitchEnabled = 1
" Prettier
nmap <Leader>p <Plug>(Prettier)
let g:prettier#exec_cmd_async = 1
let g:prettier#config#print_width = 80
let g:prettier#config#tab_width = 2
let g:prettier#config#use_tabs = 'false'
let g:prettier#config#semi = 'true'
let g:prettier#config#single_quote = 'false'
let g:prettier#config#bracket_spacing = 'true'
let g:prettier#config#jsx_bracket_same_line = 'false'
let g:prettier#config#trailing_comma = 'none'
let g:prettier#config#parser = 'babylon'
let g:prettier#config#config_precedence = 'prefer-file'
let g:prettier#config#prose_wrap = 'preserve'
let g:prettier#autoformat = 0
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue PrettierAsync
" Ale
let g:ale_set_highlights = 0
nmap <silent> <Leader>nn <Plug>(ale_previous_wrap)
nmap <silent> <Leader>np <Plug>(ale_next_wrap)
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ 'ruby': [],
\}
" =============================================================
" APPEARENCE
" =============================================================
"set term=xterm
set t_Co=256
let &t_AB="\e[48;5;%dm"
let &t_AF="\e[38;5;%dm"
" colorscheme cobalt2
colorscheme material
set background=dark
if has("gui_running")
"set guifont=Operator\ Mono:h18
set guifont=Input\ Mono:h18
set linespace=6
set guioptions-=r
colorscheme material
let g:material_theme_style = 'default' " 'palenight' | 'dark'
let g:material_terminal_italics = 1
endif
if (has("nvim"))
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
if (has("termguicolors"))
set termguicolors
endif
" =============================================================
" CUSTOM FUNCTIONS
" =============================================================
" Create folders on file save
" ===========================
function! s:MkNonExDir(file, buf)
if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/'
let dir=fnamemodify(a:file, ':h')
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
endif
endfunction
" Remove whitespaces on save saving cursor position
" =================================================
function! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
" EPUB macros
" let @a = '0vf/f>c<p>Akbkbkbkbkbp>j'
" let @b = 'gg/<p>f>a<span class="dropcap">la</span> '
" let @c = ':%s/—/PSâ[201~/g'
" let @f = '/fnreskbf F<vf/;;f>c<a href="./endnotes.xhtml#note-1" id="note-kbref-1" epub:type="noteref" style="vertical-align: suprekbkber;">1</a>F1F1F1'
" let @n = 'O<li id="note-1" epub:type="rearnote"><p>dd==0^0f(i<i>f)kbkbf)a</i>okbo<a href="./ch-2.xhtml#noteref-1" eput:kbkbb:type="se:referrer">PSâ©[201~<akb/a>kb</p>kb</li>j'
let @j = 'yGoo```jsPG'
let @h = 'yGoo```htmlPG'
let @t = 'yGoo```PG'