-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
283 lines (219 loc) · 7.1 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
"""""""""""""""""""""""""""""""""""""""""""
" Author: Godwin Pang - github: @godwinpang
" vimrc setup
"""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""
" => vim-plug Plugin Setup
""""""""""""""""""""""""""""""
set nocompatible " be iMproved, required
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $HOME/.vimrc
endif
call plug#begin('~/.vim/plugged')
" For Looks
Plug 'itchyny/lightline.vim'
Plug 'scrooloose/nerdtree'
Plug 'mhinz/vim-startify'
Plug 'arcticicestudio/nord-vim'
" Autocomplete
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Utils
Plug 'bronson/vim-trailing-whitespace'
Plug 'tpope/vim-commentary'
Plug 'jiangmiao/auto-pairs'
Plug 'tpope/vim-surround'
Plug 'jremmen/vim-ripgrep'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'mbbill/undotree'
Plug 'alvan/vim-closetag'
" Git
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
Plug 'junegunn/gv.vim'
" Go
Plug 'fatih/vim-go'
" Web
Plug 'pangloss/vim-javascript'
Plug 'HerringtonDarkholme/yats.vim'
Plug 'maxmellon/vim-jsx-pretty'
Plug 'jxnblk/vim-mdx-js'
" Markdown
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
Plug 'vim-python/python-syntax'
call plug#end()
set path+=**
""""""""""""""""""""""""""""""
" => General
""""""""""""""""""""""""""""""
let mapleader=" "
" Sets number of lines of history vim has to remember
set history=500
" Enable filetype plugins
filetype indent plugin on
" => UI
" Set minimum space above and below cursor
set scrolloff=5
" Set line numbers
set relativenumber
set number
" Command autocompletion settings
set wildmenu " enable command autocompletion
set wildignore=*.o,*~,*.class,*/git,*/.DS_Store
" Always show current position
set ruler " show line and char num
set cursorline " horizontal line on cursor
" Always show status line
set laststatus=2
" Set backspace to act like standard text editor
set backspace=indent,eol,start
" Set h l and arrow keys to wrap at end of line
set whichwrap+=<,>,h,l
" Search settings
set ignorecase " set search to be case insensitive
set smartcase " set search to be case sensitive when item has upper case letter
set incsearch " searches as editing search item
" Highlight matching brackets
set showmatch
" Error settings
set noerrorbells " turn off error sounds
set novisualbell " turn off error flash
set t_vb= " turn off error flash
" Don't redraw when executing macros
set lazyredraw
" Remove mode (shown in lightline anyways)
set noshowmode
set encoding=UTF-8
""""""""""""""""""""""""""""""
" => Color and Fonts
""""""""""""""""""""""""""""""
" Highlight keywords in language
syntax enable
" 80 char line length
match Error /\%101v.\+/ " Highlight chars over 80
set colorcolumn=100 " Column at 80 chars
" Colorscheme
colorscheme nord
" Background
set background=dark
set guifont=Inconsolata-g\ for\ Powerline\ 18
""""""""""""""""""""""""""""""
" => Backups
""""""""""""""""""""""""""""""
" Swap files are annoying
set noswapfile
""""""""""""""""""""""""""""""
" => Tabbing
""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Set tab to 4 spaces
set shiftwidth=4
set tabstop=4
autocmd FileType yml setlocal tabstop=2 shiftwidth=2
autocmd FileType json setlocal tabstop=2 shiftwidth=2
autocmd FileType javascript setlocal tabstop=2 shiftwidth=2
autocmd FileType javascriptreact setlocal tabstop=2 shiftwidth=2
autocmd FileType typescript setlocal tabstop=2 shiftwidth=2
autocmd FileType typescriptreact setlocal tabstop=2 shiftwidth=2
" Indentation
set autoindent " maintain indentation on newline
" Wrapping text
set textwidth=100 " Set length to wrap at
set linebreak " Set wrap to insert linebreak
""""""""""""""""""""""""""""""
" => Moving Around
""""""""""""""""""""""""""""""
" For mouse normies like me
set mouse=a
" Mapping to move around windows
map <Leader>h <C-W>h
map <Leader>j <C-W>j
map <Leader>k <C-W>k
map <Leader>l <C-W>l
" Maintain column selection when moving around
set nostartofline
" Delete trailing white space on save
fun! CleanExtraSpaces()
let save_cursor = getpos(".")
let old_query = getreg('/')
silent! %s/\s\+$//e
call setpos('.', save_cursor)
call setreg('/', old_query)
endfun
if has("autocmd")
autocmd BufWritePre *.h,*.c,*.java,*.vimrc,*.txt,*.js,*.py,*.go,*.ts,*.tsx :call CleanExtraSpaces()
endif
" Return to last edit position when opening files (You want this!)
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
""""""""""""""""""""""""""""""
" => Folds Configuration
""""""""""""""""""""""""""""""
set foldmethod=syntax
set foldlevelstart=20
nmap z za
vnoremap < <gv
vnoremap > >gv
""""""""""""""""""""""""""""""
" => Lightline Configuration
""""""""""""""""""""""""""""""
let g:lightline = {
\ 'colorscheme': 'nord',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ],
\ 'right': [ [ 'lineinfo' ],
\ [ 'percent' ],
\ ['fileformat', 'filetype' ] ]
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#head'
\ },
\ }
""""""""""""""""""""""""""""""
" => Coc Configuration
""""""""""""""""""""""""""""""
set updatetime=300
let g:coc_global_extensions = [ 'coc-tsserver', 'coc-eslint', 'coc-go',
\ 'coc-yaml', 'coc-json', 'coc-prettier']
nmap <silent> <Leader>gd <Plug>(coc-definition)
nmap <silent> <Leader>gy <Plug>(coc-type-definition)
nmap <silent> <Leader>gi <Plug>(coc-implementation)
nmap <silent> <Leader>gr <Plug>(coc-references)
nmap <Leader>rn <Plug>(coc-rename)
nmap <Leader>do <Plug>(coc-codeaction)
" Get definition in hover box
nnoremap <silent> <Leader>d :silent! call CocActionAsync('doHover')<CR>
" When pum is visible, if selected then enter selection else select first then enter
"
inoremap <silent><expr> <TAB>
\ pumvisible() ? (coc#_selected() ? "\<C-y>" : "\<C-n><C-y>") :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
" inoremap <silent><TAB> :call Call_tab()<CR>
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
inoremap <expr><CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
""""""""""""""""""""""""""""""
" => NerdTree Configuration
""""""""""""""""""""""""""""""
map <silent><Leader>n :NERDTreeToggle<CR>
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
""""""""""""""""""""""""""""""
" => Closetag Configuration
""""""""""""""""""""""""""""""
let g:closetag_filetypes= 'javascript,javascriptreact,typescript,typescriptreact,html'
let g:closetag_xhtml_filetypes= 'javascript,javascriptreact,typescript,typescriptreact,html'
let g:closetag_emptyTags_caseSensitive = 1
""""""""""""""""""""""""""""""
" => Undotree Configuration
""""""""""""""""""""""""""""""
map <silent><Leader>u :UndotreeToggle<CR>
" IDK why I can't copy
vmap <C-c> :w !pbcopy<CR><CR>