forked from mkitt/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
192 lines (176 loc) · 5.89 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
set nocompatible
runtime! macros/matchit.vim
filetype plugin indent on
syntax enable
" Plugins
" --------------------------------------
call plug#begin('~/.vim/plugged')
" Editor
Plug 'mg979/vim-visual-multi'
Plug 'mkitt/pigment'
Plug 'nelstrom/vim-visual-star-search'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'scrooloose/nerdtree'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-rhubarb'
Plug 'tpope/vim-speeddating'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'vim-scripts/YankRing.vim'
" Filetypes
Plug 'jparise/vim-graphql'
Plug 'leafgarland/typescript-vim'
Plug 'maxmellon/vim-jsx-pretty'
Plug 'othree/html5.vim'
Plug 'pangloss/vim-javascript'
call plug#end()
" Preferences
" --------------------------------------
set autoindent
set autoread
set backspace=2
if has("balloon_eval") && has("unix") | set ballooneval | endif
set clipboard=unnamed
set complete-=i
set completeopt=longest,menu,menuone,preview,noselect,noinsert
set display+=lastline
set expandtab
set formatoptions+=j
if executable('rg') | set grepprg=rg\ | endif
set hidden
set history=1000
set hlsearch
set ignorecase
set incsearch
set laststatus=2
set list
set listchars=tab:▸\ ,eol:¬,trail:·
set mouse=a
set nobackup
set nojoinspaces
set noshowcmd
set nostartofline
set noswapfile
set nowrap
set nowritebackup
set nrformats-=octal
set number
set ruler
set scrolloff=3
set sessionoptions-=options
set shiftround
set shiftwidth=2
set shortmess-=S
set shortmess+=c
set showmatch
set sidescrolloff=3
set signcolumn=number
set smartcase
set smartindent
set smarttab
set softtabstop=2
set splitright splitbelow
if &t_Co == 8 && $TERM !~# '^linux' | set t_Co=16 | endif
set tabstop=2
set title
set ttimeout
set ttimeoutlen=50
set ttyfast
set undolevels=1000
set updatetime=50
set wildignore+=*.DS_Store
set wildmenu
set wildmode=longest:full,full
let g:NERDTreeAutoDeleteBuffer=1
let g:NERDTreeMapUpdir='-'
let g:NERDTreeMinimalUI=1
let g:NERDTreeRespectWildIgnore=1
let g:NERDTreeShowHidden=1
let g:NERDTreeWinSize=40
let g:javascript_plugin_flow=1
let g:markdown_fenced_languages=['css', 'html', 'javascript', 'json', 'graphql', 'sh', 'typescript=javascript', 'yaml']
let g:VM_maps = {}
let g:VM_maps['Find Under']='<C-\>'
let g:VM_maps['Find Subword Under']='<C-\>'
let g:netrw_liststyle=3
let g:yankring_history_dir=$HOME.'/.vim/tmp/yankring/'
let g:yankring_window_height=10
" Key Mappings
" --------------------------------------
" Move between splits
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
" NERDTree in a buffer (like netrw)
nnoremap <silent>- :silent edit %:p:h<CR>
nnoremap <silent>_ :silent edit .<CR>
" Tab through popup menu items and allow return to select
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
inoremap <silent><expr> <TAB> coc#pum#visible() ? coc#pum#next(1) : CheckBackspace() ? "\<Tab>" : coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
inoremap <silent><expr> <C-@> coc#refresh()
" The `g`oto and list commands
nnoremap <silent><nowait><C-@> :CocList<CR>
nnoremap <silent><nowait><C-c> :CocList commands<CR>
nnoremap <silent><nowait>ga :CocList --normal diagnostics<CR>
nnoremap <silent><nowait>gb :CocList buffers<CR>
nnoremap <silent><nowait>gd :call CocActionAsync('jumpTypeDefinition')<CR>
nnoremap <silent><nowait>gf :call CocActionAsync('jumpDefinition')<CR>
nnoremap <silent><nowait>gF :call CocActionAsync('jumpDefinition', 'vsplit')<CR>
nnoremap <silent><nowait>gh :call CocActionAsync('doHover')<CR>
nnoremap <silent><nowait>gl :CocList files<CR>
nnoremap <silent><nowait>gL :CocListResume<CR>
nnoremap <silent><nowait>gr :call CocActionAsync('jumpReferences')<CR>
nnoremap <silent><nowait>gs :CocList grep<CR>
xnoremap <silent><nowait>gs y :CocList grep <C-R>=escape(@",'$ ')<CR><CR>
nnoremap <silent><nowait>gu :call CocActionAsync('showSignatureHelp')<CR>
nnoremap <silent><nowait>gV `[v`]
nnoremap <silent><nowait>gy :NERDTreeToggle<CR>
nnoremap gz :CocSearch<space>
xnoremap gz y :CocSearch <C-R>=escape(@",'$ ')<CR><CR>
nmap <silent><nowait>g/ <Plug>(coc-refactor)
nmap <silent><nowait>g. <Plug>(coc-codeaction)
vmap <silent><nowait>g. <Plug>(coc-codeaction-selected)
" Custom unimpaireds
nmap <silent>[g <Plug>(coc-diagnostic-prev)
nmap <silent>]g <Plug>(coc-diagnostic-next)
" Clear the search highlight
noremap <silent><leader>\ :nohlsearch<CR>
" Remove whitespace
noremap <silent><leader>CW :%s/\s\+$//<CR>
" Auto Commands
" --------------------------------------
func! Eatchar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunc
if has("autocmd")
augroup FTOptions
autocmd!
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd BufRead,BufNewFile *.ts set syntax=javascript
autocmd BufRead,BufNewFile *.tsx set filetype=typescript.tsx
autocmd BufRead,BufNewFile *.tsx set syntax=javascript.jsx
autocmd BufRead,BufNewFile .env.* set filetype=sh
autocmd BufRead,BufNewFile COMMIT_EDITMSG setlocal spell
autocmd FileType markdown,text,txt setlocal textwidth=80 linebreak nolist wrap spell
autocmd FileType qf setlocal wrap
autocmd QuickFixCmdPost *grep* botright copen
autocmd QuitPre * if empty(&buftype) | lclose | endif
" Abbreviations
autocmd FileType javascript,javascript.jsx,typescript,typescript.tsx iabbrev <buffer> bgc backgroundColor: '',<Left><Left><C-R>=Eatchar('\s')<CR>
autocmd FileType javascript,javascript.jsx,typescript,typescript.tsx iabbrev <buffer> sdb outline: '1px dotted blue',<C-R>=Eatchar('\s')<CR>
autocmd FileType javascript,javascript.jsx,typescript,typescript.tsx iabbrev <buffer> cdl console.log()<Left><C-R>=Eatchar('\s')<CR>
augroup END
endif
" Theme
" --------------------------------------
colorscheme pigment