-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.vimrc
327 lines (275 loc) · 9.17 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
filetype off
syntax off
call plug#begin('~/.vim/plugged')
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'airblade/vim-gitgutter'
Plug 'cormacrelf/vim-colors-github'
Plug 'alvan/vim-closetag', { 'for': ['javascript', 'svelte', 'typescript', 'typescriptreact', 'vue'] }
Plug 'cohama/lexima.vim'
Plug 'editorconfig/editorconfig-vim'
Plug 'ervandew/supertab'
Plug 'preservim/nerdtree'
Plug 'fatih/vim-go', {'do': ':GoUpdateBinaries', 'for': 'go'}
Plug 'itchyny/lightline.vim'
Plug 'junegunn/goyo.vim'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'scrooloose/nerdcommenter'
Plug 'thoughtbot/vim-rspec', { 'for': 'ruby' }
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-surround'
Plug 'vim-airline/vim-airline-themes'
Plug 'dense-analysis/ale'
Plug 'gorodinskiy/vim-coloresque', { 'for': ['css', 'scss'] }
Plug 'christoomey/vim-tmux-navigator'
Plug 'ludovicchabant/vim-gutentags', { 'for': ['javascript', 'typescript', 'typescriptreact'] }
Plug 'kristijanhusak/vim-js-file-import', {'do': 'npm install', 'for':['javascript', 'typescript', 'typescriptreact']}
Plug 'sheerun/vim-polyglot'
Plug 'altercation/vim-colors-solarized'
Plug 'vimwiki/vimwiki'
Plug 'dyng/ctrlsf.vim'
Plug 'universal-ctags/ctags'
Plug 'preservim/tagbar'
call plug#end()
filetype plugin indent on
" Map leader \ to ,
let mapleader = ","
" set swapfile
set dir=~/tmp
set encoding=utf-8
set clipboard=unnamed
set ruler
"set foldcolumn=3
set mouse=a
set laststatus=2
"set colorcolumn=80
set cursorline
"set cursorcolumn
"set relativenumber
"set number
set number relativenumber
syntax sync minlines=256
set nocompatible
set inccommand=nosplit
set foldlevelstart=99
set foldlevel=99
set splitright
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Github colorscheme settings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"Set themes
" use a slightly darker background, like GitHub inline code blocks
"let g:github_colors_soft = 1
"" more blocky diff markers in signcolumn (e.g. GitGutter)
"let g:github_colors_block_diffmark = 0
"" in your .vimrc or init.vim
"colorscheme github
"" if you use airline / lightline
"let g:airline_theme = "github"
""let g:lightline = { 'colorscheme': 'github' }
"set background=dark
"colorscheme monokai
"let g:airline_theme='monokai'
"let g:lightline = {
"\ 'colorscheme': 'monokai',
"\ }
set background=light
colorscheme papercolor
let g:airline_theme='papercolor'
let g:lightline = {
\ 'colorscheme': 'papercolor',
\ }
"highlight Normal ctermbg=black
"highlight nonText ctermbg=black
"let g:solarized_termcolors=256
"set background=dark
"colorscheme solarized
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ALE Linter settings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:ale_linter_aliases = {'svelte': ['css', 'javascript']}
let g:ale_linters = {
\ 'rust': ['cargo'],
"\ 'go': ['staticcheck'],
\ 'css': ['prettier'],
\ 'html': ['prettier'],
\ 'javascript': ['prettier'],
\ 'typescript': ['prettier'],
\ 'vue': ['prettier'],
\ 'typescriptreact': ['eslint', 'prettier'],
\ 'ruby': ['brakeman', 'standardrb', 'ruby', 'rails_best_practices', 'rubocop'],
\ 'svelte': ['stylelint', 'eslint', 'prettier-standard']
"\ 'python': ['pylint']
\}
let g:ale_fixers = {
\'ruby': ['sorbet', 'standardrb', 'rubocop'],
\'rust': ['rustfmt'],
\'vue': ['prettier'],
\'html': ['prettier'],
\'css': ['prettier'],
\'javascript': ['prettier'],
\'typescript': ['prettier'],
\'typescriptreact': ['eslint', 'prettier'],
\'svelte': ['stylelint', 'eslint', 'prettier', 'prettier-standard'],
"\ 'python': ['black'],
\'*': ['remove_trailing_lines', 'trim_whitespace']
\}
let g:ale_lint_on_text_changed = 'never'
let g:ale_lint_on_enter = 0
let g:ale_lint_on_save = 1
let g:ale_fix_on_save = 1
let g:ale_set_loclist = 0
let g:ale_completion_enabled = 1
let g:ale_set_quickfix = 0
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#fnamecollapse = 0
let g:ale_rust_rls_toolchain = 'stable'
" Customize fzf colors to match your color scheme
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'] }
" [Buffers] Jump to the existing window if possible
let g:fzf_buffers_jump = 1
" [[B]Commits] Customize the options used by 'git log':
let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'
" [Tags] Command to generate tags file
let g:fzf_tags_command = 'ctags -R'
" [Commands] --expect expression for directly executing the command
let g:fzf_commands_expect = 'alt-enter,ctrl-x'
"command! -bang -nargs=* Ag
"\ call fzf#vim#ag(<q-args>,
"\ <bang>0 ? fzf#vim#with_preview('up:60%')
"\ : fzf#vim#with_preview('right:50%:hidden', '?'),
"\ <bang>0)
" ctrl + f to search
"nnoremap <C-f> :Ag!<Enter>
nnoremap <C-f> :Rg<space>
" Find files with fzf
nmap <leader>p :Files<CR>
nmap <leader>m :CtrlSF -R ""<Left>
nmap <leader>n :CtrlSFFocus<CR>
" Find within file lines
nmap <leader>f :BLines<CR>
" Substitute the word under the cursor.
nmap <leader>s :%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>
" Substitute highlighted selection.
vnoremap <leader>s "+y :%s/\v(<C-r>")/<C-r>"/gI<Left><Left><Left>
" ctrl + s to save
noremap <silent> <C-S> :write<CR>
vnoremap <silent> <C-S> <C-C>:write<CR>
inoremap <silent> <C-S> <C-C>:write<CR>
" noremap jj <Esc>:w<CR>
"# ~/.zshrc
"# enable control-s and control-q
"stty start undef
"stty stop undef
"setopt noflowcontrol
"Insert mode key mappings
inoremap <C-l> <Right>
inoremap <C-j> <Down>
inoremap <C-b> <C-o>o
inoremap <C-k> <Up><C-o>A
inoremap <C-d> <Right>,<C-o>o
inoremap <C-e> <Right>:<Space>,<Left>
"Improve search
set ignorecase
set smartcase
set incsearch
set hlsearch
nnoremap * /\<<C-R>=expand('<cword>')<CR>\><CR>
nnoremap # ?\<<C-R>=expand('<cword>')<CR>\><CR>
"Easy cd to directory with `,cd`
nnoremap <leader>cd :cd %:p:h<CR>:pwd<CR>
"Center cursor vertically
set scrolloff=999
if !exists('*VCenterCursor')
augroup VCenterCursor
au!
au OptionSet *,*.*
\ if and( expand("<amatch>")=='scrolloff' ,
\ exists('#VCenterCursor#WinEnter,WinNew,VimResized') )|
\ au! VCenterCursor WinEnter,WinNew,VimResized|
\ endif
augroup END
function VCenterCursor()
if !exists('#VCenterCursor#WinEnter,WinNew,VimResized')
let s:default_scrolloff=&scrolloff
let &scrolloff=winheight(win_getid())/2
au VCenterCursor WinEnter,WinNew,VimResized *,*.*
\ let &scrolloff=winheight(win_getid())/2
else
au! VCenterCursor WinEnter,WinNew,VimResized
let &scrolloff=s:default_scrolloff
endif
endfunction
endif
nnoremap <leader>zz :call VCenterCursor()<CR>
fun! JumpToDef()
if exists("*GotoDefinition_" . &filetype)
call GotoDefinition_{&filetype}()
else
exe "norm! \<C-]>"
endif
endf
" Jump to tag
nn <M-g> :call JumpToDef()<cr>
ino <M-g> <esc>:call JumpToDef()<cr>i
" Map jk to ESC in insert mode
inoremap jk <esc>
" Disable ESC key in insert mode.
inoremap <esc> <nop>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set Vim-specific sequences for RGB colors
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
" set swap config, Sets the directory to ~/.vim/tmp
set directory^=$HOME/.vim/tmp//
" vv to generate new vertical split
nnore map <silent> vv <C-w>v
" Prompt for a command to run
map <Leader>vp :VimuxPromptCommand<CR>
" Run last command executed by VimuxRunCommand
map <Leader>vl :VimuxRunLastCommand<CR>
autocmd vimenter * NERDTree
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
map <C-n> :NERDTreeToggle<CR>
map <C-m> :NERDTreeFind<CR>
" Plugin alvan/vim-closetag
let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.php,*.ts,*.jsx,*.tsx,*.js,*.vue,*.erb,*.svelte"
let g:closetag_xhtml_filetypes = 'xhtml,js,jsx,tsx,typescriptreact'
" Universal-ctags is required
let g:js_file_import_no_mappings = 0
let g:js_file_import_omit_semicolon = 0
let g:js_file_import_use_fzf = 1
let g:js_file_import_sort_after_insert = 1
set wildignore+=*node_modules/**
set wildignore+=*dist/**
set wildignore+=*build/**
au BufRead /tmp/psql.edit.* set syntax=sql
"Configure vimwiki to use Markdown
let g:vimwiki_list = [{'path': '~/vimwiki/',
\ 'syntax': 'markdown', 'ext': '.md'}]
"Ripgrep command
let g:rg_command = 'rg --vimgrep -S'
"Navigate to the next error with ALE
nmap <leader>e :ALENext<cr>
"Toggle universal ctag display.
nmap <leader>t :TagbarToggle<CR>