forked from sebdah/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
245 lines (224 loc) · 7.96 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
call plug#begin('~/.vim/plugged')
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
" Multiple Plug commands can be written in a single line using | separators
"Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" On-demand loading
Plug 'preservim/nerdtree'
" Vim client for TabNine https://tabnine.com/
" Plug 'codota/tabnine-vim', { 'branch': 'python3' }
" Plug 'tabnine/YouCompleteMe'
" Plug 'kaicataldo/material.vim'
Plug 'tpope/vim-fugitive'
Plug 'ryanoasis/vim-devicons'
Plug 'sheerun/vim-polyglot'
Plug 'luochen1990/rainbow'
Plug '/opt/homebrew/opt/fzf'
Plug 'junegunn/fzf.vim'
Plug 'jremmen/vim-ripgrep' " Use RipGrep in Vim and display results in a quickfix list
Plug 'rust-lang/rust.vim'
Plug 'majutsushi/tagbar'
Plug 'preservim/nerdcommenter'
Plug 'buoto/gotests-vim'
Plug 'google/vim-colorscheme-primary'
Plug 'tomasiser/vim-code-dark'
Plug 'ayu-theme/ayu-vim'
Plug 'terryma/vim-multiple-cursors'
" Plug 'cstrahan/vim-capnp'
Plug 'wakatime/vim-wakatime'
Plug 'Yggdroot/indentLine'
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
Plug 'arcticicestudio/nord-vim'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'NLKNguyen/papercolor-theme'
" Plug 'humanoid-colors/vim-humanoid-colorscheme'
Plug 'rizzatti/dash.vim'
" Initialize plugin system
call plug#end()
" Set the leader button
let mapleader = ','
" Remap Esc to jk
inoremap jk <Esc>
" Allow vim to set a custom font or color for a word
" syntax enable
" syntax on
"if (has("termguicolors"))
" set termguicolors
"endif
" let NERDTreeQuitOnOpen=1
" Autosave buffers before leaving them
autocmd BufLeave * silent! :wa
" Remove trailing white spaces on save
autocmd BufWritePre * :%s/\s\+$//e
" Center the screen quickly
nnoremap <space> zz
"let g:material_theme_style = 'darker'
"let g:material_terminal_italics = 1
let g:rainbow_active = 1
"colorscheme material
"syntax enable
syntax on
"set t_Co=256
"set background=dark
"colorscheme primary
"colorscheme codedark
"let ayucolor="dark"
"colorscheme ayu
if (has("gui_running"))
" set termguicolors
" let ayucolor="dark"
" colorscheme ayu
" Toggle background with <leader>bg
" set modifiable
" map <leader>bg :let ayucolor = (ayucolor == "dark"? "light" : "dark")\|colorscheme ayu<cr>
else
colorscheme codedark
" colorscheme humanoid
" colorscheme dracula
endif
set autoindent " take indent for new line from previous line
set smartindent " enable smart indentation
set autoread " reload file if the file changes on the disk
set autowrite " write when switching buffers
set autowriteall " write on :quit
if system('uname -s') == "Darwin\n"
set clipboard=unnamed "OSX
else
set clipboard=unnamedplus "Linux
endif
"set clipboard=unnamedplus
"set colorcolumn=81 " highlight the 80th column as an indicator
set completeopt-=preview " remove the horrendous preview window
set completeopt+=menuone
set completeopt+=noinsert
set completeopt-=longest
"set cursorline " highlight the current line for the cursor
"hi clear CursorLine
"hi CursorLine gui=underline cterm=underline
set cursorline
hi cursorline cterm=none term=none
autocmd WinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
highlight CursorLine guibg=#303000 ctermbg=234
set encoding=utf-8
set expandtab " expands tabs to spaces
set list " show trailing whitespace
set listchars=tab:\|\ ,trail:▫
set nospell " disable spelling
set noswapfile " disable swapfile usage
set nowrap
set noerrorbells " No bells!
set novisualbell " I said, no bells!
set number " show number ruler
set relativenumber " show relative numbers in the ruler
set ruler
set formatoptions=tcqronj " set vims text formatting options
set softtabstop=2
set tabstop=2
"set textwidth=80
set title " let vim set the terminal title
set updatetime=300 " redraw the status bar often
set wildmenu " command-line completion operates in an enhanced mode
set wildmode=longest,list,full " :h 'wildmode'
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
set mouse=n
"----------------------------------------------
" Plugin: scrooloose/nerdtree
"----------------------------------------------
nnoremap <leader>d :NERDTreeToggle<cr>
nnoremap <F2> :NERDTreeToggle<cr>
"----------------------------------------------
" Language: Golang
"----------------------------------------------
au FileType go set noexpandtab
au FileType go set shiftwidth=4
au FileType go set softtabstop=4
au FileType go set tabstop=4
"----------------------------------------------
" Language: Rust
"----------------------------------------------
au FileType rust set expandtab
"au FileType rust set noexpandtab
au FileType rust set shiftwidth=4
au FileType rust set softtabstop=4
au FileType rust set tabstop=4
let g:rustfmt_autosave = 1
"----------------------------------------------
" Language: Python
"----------------------------------------------
au FileType python set expandtab
au FileType python set shiftwidth=4
au FileType python set softtabstop=4
au FileType python set tabstop=4
"----------------------------------------------
" Language: sql
"----------------------------------------------
au FileType sql set expandtab
au FileType sql set shiftwidth=2
au FileType sql set softtabstop=2
au FileType sql set tabstop=2
"----------------------------------------------
" Plugin: 'junegunn/fzf.vim'
"----------------------------------------------
nnoremap <c-p> :FZF<cr>
" tagbar
nmap <F3> :TagbarToggle<CR>
nnoremap <leader>t :TagbarToggle<cr>
" Language: Go
" Tagbar configuration for Golang
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_function_parameters = 1
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 2
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" vim-easy-align
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" disable vim-go autocomplete
let g:go_code_completion_enabled = 0
" disable diagnostics support
let g:lsp_diagnostics_enabled = 1
" disable document code action signs
let g:lsp_document_code_action_signs_enabled = 0
" Enables a floating window of diagnostic error for the current line to status
let g:lsp_diagnostics_float_cursor = 1
" vim-lsp config
function! s:on_lsp_buffer_enabled() abort
" setlocal omnifunc=lsp#complete
setlocal signcolumn=yes
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
nmap <buffer> gd <plug>(lsp-definition)
nmap <buffer> gs <plug>(lsp-document-symbol-search)
nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
nmap <buffer> gr <plug>(lsp-references)
nmap <buffer> gi <plug>(lsp-implementation)
nmap <buffer> gt <plug>(lsp-type-definition)
nmap <buffer> <leader>rn <plug>(lsp-rename)
nmap <buffer> [g <plug>(lsp-previous-diagnostic)
nmap <buffer> ]g <plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover)
inoremap <buffer> <expr><c-f> lsp#scroll(+4)
inoremap <buffer> <expr><c-d> lsp#scroll(-4)
let g:lsp_format_sync_timeout = 1000
autocmd! BufWritePre *.rs,*.go,*.py,*.clj call execute('LspDocumentFormatSync')
" refer to doc to add more commands
endfunction
augroup lsp_install
au!
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END