forked from semanser/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
307 lines (268 loc) · 10.2 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
" PLUGIN SETUP {{{
if empty(glob('~/.vim/autoload/plug.vim'))
silent execute "!curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
autocmd VimEnter * PlugInstall | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
" Provides insert mode auto-completion for quotes, parens, brackets, etc
Plug 'Raimondi/delimitMate'
let delimitMate_expand_cr = 1
" Always highlights the enclosing html/xml tags
Plug 'Valloric/MatchTagAlways'
let g:mta_filetypes = {
\ 'html' : 1,
\ 'javascript.jsx' : 1,
\ 'jinja' : 1,
\ 'liquid' : 1,
\ 'markdown' : 1,
\ 'xhtml' : 1,
\ 'xml' : 1,
\}
" A code-completion engine
" Plug 'Valloric/YouCompleteMe', { 'do': './install.py --tern-completer' }
" let g:ycm_autoclose_preview_window_after_insertion = 1
" Shows a git diff in the gutter (sign column) and stages/undoes hunks
Plug 'airblade/vim-gitgutter'
" Auto close (X)HTML tags
Plug 'alvan/vim-closetag'
let g:closetag_close_shortcut = ''
let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.js,*jsx'
" Preview colours in source code while editing
Plug 'ap/vim-css-color'
" CSS3 syntax (and syntax defined in some foreign specifications) support for Vim's built-in syntax/css.vim
Plug 'hail2u/vim-css3-syntax'
augroup VimCSS3Syntax
autocmd!
autocmd FileType css setlocal iskeyword+=-
augroup END
" Improved incremental searching for Vim
Plug 'haya14busa/incsearch.vim'
" A command-line fuzzy finder
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
" fzf bindings for vim
Plug 'junegunn/fzf.vim'
let $FZF_DEFAULT_COMMAND = 'ag -g ""'
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
" A Vim alignment plugin
Plug 'junegunn/vim-easy-align'
" Asynchronously control git repositories in Neovim/Vim 8
Plug 'lambdalisue/gina.vim'
" The fancy start screen for Vim.
Plug 'mhinz/vim-startify'
" Vastly improved Javascript indentation and syntax support in Vim
Plug 'pangloss/vim-javascript'
" React JSX syntax highlighting and indenting for vim
Plug 'mxw/vim-jsx'
" A tree explorer plugin for vim
Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'}
let NERDTreeAutoDeleteBuffer = 1
let NERDTreeChDirMode = 2
let NERDTreeMinimalUI = 1
let NERDTreeQuitOnOpen = 1
let NERDTreeShowHidden = 1
let NERDTreeStatusline = ''
" Comment stuff out
Plug 'tpope/vim-commentary'
" The set of operator and textobject plugins to search/select/edit sandwiched textobjects.
Plug 'machakann/vim-sandwich'
" Lean & mean status/tabline for vim that's light as air
Plug 'vim-airline/vim-airline'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 0
let g:airline#extensions#tabline#show_close_button = 0
let g:airline#extensions#whitespace#enabled = 0
let g:airline_inactive_collapse=0
let g:airline_section_a = ''
let g:airline_section_b = ''
let g:airline_section_c = '%t'
let g:airline_section_x = ''
let g:airline_section_y = ''
let g:airline_section_z = '%l'
let g:airline_theme='tender'
" Asynchronous Lint Engine
Plug 'w0rp/ale'
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ 'javascript.jsx': ['eslint'],
\}
let g:ale_fix_on_save = 1
let g:ale_fixers = {}
let g:ale_fixers.javascript = ['eslint']
" Make the yanked region apparent!
Plug 'machakann/vim-highlightedyank'
" Async Vim plugin for showing your outdated Vim plugins
Plug 'semanser/vim-outdated-plugins'
" a Git wrapper so awesome, it should be illegal
Plug 'tpope/vim-fugitive'
" Vim plugin: Create your own text objects
Plug 'kana/vim-textobj-user'
" A text object for any of '', "", (), {}, [] and <>.
Plug 'rhysd/vim-textobj-anyblock'
" A 24bit colorscheme for Vim, Airline and Lightline
Plug 'jacoborus/tender.vim'
" Vim plugin for selectively illuminating other uses of current word under the cursor
Plug 'RRethy/vim-illuminate'
let g:Illuminate_ftblacklist = ['nerdtree']
call plug#end()
" }}}
" GENERAL {{{
cd /Users/semanser/Desktop/Programming " Setup working directory
syntax enable " Enable syntax highlighting
colorscheme tender
let mapleader = "\<Space>" " Setup leader key
let macvim_skip_colorscheme=1
" }}}
" VARS {{{
set autoread " autoload file changes
set autowriteall " autosave files
set background=dark " dark colorscheme
set completeopt-=preview " Do not show preview window for ins-completion.
set cursorline " Enable cursor line
set diffopt+=vertical " split diffopt in vertical mode
set encoding=utf-8 " set the character encoding to UTF-8
set expandtab " convert tabs to the spaces
set foldlevel=2 " sets the fold level
set foldmethod=indent " type of indentation
set foldnestmax=10 " sets the maximum nesting of folds
set gcr=a:blinkon0 " disable cursor blinking
set guioptions= " remove all GUI components and options.
set hidden " hide when switching buffers instead of unloading
set history=1000 " store lots of :cmdline history
set hlsearch " highlights the string matched by the search
set ignorecase " make searching case insensitive
set inccommand=nosplit " shows the effects of a command incrementally, as you type.
set incsearch " incremental search
set lazyredraw " only redraw when necessary
set nobackup " disable backups
set signcolumn=yes " always show signcolumns
set nocompatible " use Vim settings, rather then Vi
set nofoldenable " when off, all folds are open when open a new file
set noshowmode " don't show mode as we use a status line plugin
set noswapfile " disable swapfile
set nowrap " wrap lines
set scrolloff=10 " keep cursor at the minimum 10 rows from the screen borders
set shiftwidth=2 " 2 spaces
set showcmd " show (partial) command in status line
set showmatch " show match brackets
set sidescroll=1 " incrementally scroll one character
set smartcase " unless the query has capital letters
set splitbelow " open new split below
set splitright " open new split right
set tabstop=2 " 2 spaces
set termguicolors " enable True color
set ttyfast " always assume a fast terminal
set undodir=~/.vim/undo-dir " setup undo directory
set undofile " save undo chages even after computer restart
set updatetime=250 " reduce update time in Vim
set wildmenu " visual autocomplete for command menu
" }}}
" KEYMAP {{{
inoremap <C-c> <CR><Esc>O
inoremap <C-j> <Down>
inoremap <C-k> <Up>
map / <Plug>(incsearch-forward)
map <silent> <C-h> :call WinMove('h')<cr>
map <silent> <C-j> :call WinMove('j')<cr>
map <silent> <C-k> :call WinMove('k')<cr>
map <silent> <C-l> :call WinMove('l')<cr>
nmap caa cab
nmap cii cib
nmap daa dab
nmap dii dib
nnoremap <C-S-P> :call <SID>SynStack()<CR>
nnoremap <esc> :noh<return><esc>
nnoremap <leader>ev :vsplit ~/dotfiles/.vimrc<cr>
nnoremap <silent> <S-W> :bd!<CR>
nnoremap <silent> <D-S-*> :Ag <C-R><C-W><CR>
nnoremap <silent> <leader><tab> :Files<CR>
nnoremap <silent> <leader>ga :Gina add .<CR>
nnoremap <silent> <leader>gc :Gina commit<CR>
nnoremap <silent> <leader>gd :Gina diff<CR>
nnoremap <silent> <leader>gp :Gina push<CR>
nnoremap <silent> <leader>gs :Gina status -s<CR>
nnoremap <silent> <leader>j :ALENext<cr>
nnoremap <silent> <leader>k :ALEPrevious<cr>
nnoremap <silent> <leader>pu :PlugUpdate<CR>
nnoremap <silent> <leader>r :source %<CR>
nnoremap <silent> <leader>t :term<CR>
nnoremap H 0
nnoremap L $
nnoremap P P`[v`]=
nnoremap S i<cr><esc><right>
nnoremap p p`[v`]=
nnoremap ¬ :bnext<CR>
nnoremap ˙ :bprevious<CR>
noremap <F3> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" . " FG:" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"fg#")<CR>
noremap <silent> <D-1> :tabn 1<cr>
noremap <silent> <D-2> :tabn 2<cr>
noremap <silent> <D-3> :tabn 3<cr>
noremap <silent> <D-4> :tabn 4<cr>
noremap <silent> <D-5> :tabn 5<cr>
noremap <silent> <D-6> :tabn 6<cr>
noremap <silent> <D-7> :tabn 7<cr>
noremap <silent> <D-8> :tabn 8<cr>
noremap <silent> <D-9> :tabn 9<cr>
noremap <silent> <tab> :NERDTreeToggle<CR>
noremap ? <Plug>(incsearch-backward)
noremap g/ <Plug>(incsearch-stay)
tnoremap <Esc> <C-\><C-n>
vnoremap <leader>s :sort<CR>
xmap ga <Plug>(EasyAlign)
" }}}
" AUTOCOMMANDS {{{
augroup folding
autocmd FileType vim setlocal foldmethod=marker
autocmd FileType vim execute "normal! zM"
augroup END
augroup term
autocmd!
autocmd TermOpen * setlocal nonumber norelativenumber
augroup END
au BufRead,BufNewFile .eslintrc set filetype=json
" autocmd CursorHoldI,CursorMovedI * silent! call CocAction('showSignatureHelp')
" }}}
" FUNCTIONS {{{
" correct label for folding block in vimrc
set foldtext=MyFoldText()
function! MyFoldText()
let line = getline(v:foldstart)
let sub = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g')
return v:folddashes . sub
endfunction
function! WinMove(key)
let t:curwin = winnr()
exec "wincmd ".a:key
if (t:curwin == winnr())
if (match(a:key,'[jk]'))
wincmd v
else
wincmd s
endif
exec "wincmd ".a:key
endif
endfunction
function! s:show_documentation()
if &filetype == 'vim'
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" }}}
" HIGHLIGHT {{{
hi illuminatedWord guibg=#4c525e
" }}}