-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
295 lines (249 loc) · 8.22 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
"=========================="
"-- Basic Configurations --"
"=========================="
" Only Vim >= 8.0 and NeoVim are supported
if v:version < 800 && !has("nvim")
echo "WARNING: This .vimrc/init.vim does not support your vim!"
echo "Some functions may not work."
endif
autocmd!
set nocompatible " do not use vi compatible mode
set langmenu=en_US.UTF-8
set nu
set title " display filename (not Thank you for using Vim.)
set ruler " display ruler (60,7 13%)
set showcmd " show inputting key
set hlsearch " highlight the search word
set ignorecase
set smartcase
set clipboard=unnamed " sharing clipboard
if has('termguicolors')
set termguicolors
endif
colorscheme desert
set ambiwidth=double
" indents and tabs
set shiftwidth=4
set autoindent
set expandtab " convert tab to spaces
set tabstop=4 " spaces number of tab
set tw=0 " text width
set breakindent
set formatoptions=q
autocmd FileType * setlocal formatoptions-=ro
set nobackup " do not create *~ files
set noundofile " do not create *.un~ files
set backupskip=/tmp/*,/private/tmp/*
set cmdheight=1
set virtualedit=block
" quickly edit .vimrc
command! Ev edit $MYVIMRC
command! Eg edit $MYGVIMRC
command! Sv source $MYVIMRC
command! Sg source $MYGVIMRC
" complement { after Enter
inoremap {<Enter> {}<Left><CR><ESC><S-o>
augroup HighlightTrailingSpaces
autocmd!
autocmd VimEnter,WinEnter,ColorScheme * highlight TrailingSpaces term=underline guibg=green ctermbg=green
autocmd VimEnter,WinEnter * match TrailingSpaces /\s\+$/
augroup END
" quickly remove trailing whitespaces
fun! TrimTrailingWhitespaces()
let l:save = winsaveview()
%s/\s\+$//e
call winrestview(l:save)
endfun
command! TrimTrailingWhitespaces call TrimTrailingWhitespaces()
" automatically apply .vimrc changes
augroup AutoReloadVimrc
autocmd!
augroup END
if has('gui_running')
autocmd AutoReloadVimrc BufWritePost $MYVIMRC source $MYVIMRC | if has('gui_running') | source $MYGVIMRC
autocmd AutoReloadVimrc BufWritePost $MYGVIMRC if has ('gui_running') | source $MYGVIMRC
else
autocmd AutoReloadVimrc BufWritePost $MYVIMRC nested source $MYVIMRC
endif
" Disable providers except python3
let g:loaded_python_provider = 0
let g:loaded_ruby_provider = 0
let g:loaded_node_provider = 0
let g:loaded_perl_provider = 0
" Python3 configurations
if executable('brew')
let s:brew_prefix = trim(system('brew --prefix'))
let s:bin_prefix = s:brew_prefix . '/bin/'
else
echo 'Warning: `brew` not found. s:brew_prefix/s:bin_prefix is set empty.'
let s:brew_prefix = ''
let s:bin_prefix = ''
endif
let g:python3_host_prog = s:bin_prefix . 'python3'
if has("nvim")
let s:pip3 = s:bin_prefix . 'pip3'
" NOTE: It's temporarily disabled because it's slow
" call system(s:pip3 . ' install neovim pynvim')
endif
if strlen($SSH_CLIENT) != 0
echo 'Your vim is over ssh, so no plugins are loaded.'
finish
endif
" Install vim-plug
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
let s:vim_plug_url = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
silent execute '!curl -fLo ' . data_dir . '/autoload/plug.vim --create-dirs ' . s:vim_plug_url
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Run PlugInstall if there are missing plugins
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
\| PlugInstall --sync | source $MYVIMRC
\| endif
call plug#begin()
Plug 'lambdalisue/fern.vim'
let g:fern#default_hidden = 1
command! Nt Fern . -toggle -drawer
Plug 'lambdalisue/fern-git-status.vim' " It depends on fern.vim
" https://github.com/lambdalisue/vim-fern/wiki/Tips#define-nerdtree-like-mappings
function! s:init_fern() abort
" Define NERDTree like mappings
nmap <buffer> o <Plug>(fern-action-open:edit)
nmap <buffer> go <Plug>(fern-action-open:edit)<C-w>p
nmap <buffer> t <Plug>(fern-action-open:tabedit)
nmap <buffer> T <Plug>(fern-action-open:tabedit)gT
nmap <buffer> i <Plug>(fern-action-open:split)
nmap <buffer> gi <Plug>(fern-action-open:split)<C-w>p
nmap <buffer> s <Plug>(fern-action-open:vsplit)
nmap <buffer> gs <Plug>(fern-action-open:vsplit)<C-w>p
nmap <buffer> ma <Plug>(fern-action-new-path)
nmap <buffer> P gg
nmap <buffer> C <Plug>(fern-action-enter)
nmap <buffer> u <Plug>(fern-action-leave)
nmap <buffer> r <Plug>(fern-action-reload)
nmap <buffer> R gg<Plug>(fern-action-reload)<C-o>
nmap <buffer> cd <Plug>(fern-action-cd)
nmap <buffer> CD gg<Plug>(fern-action-cd)<C-o>
nmap <buffer> I <Plug>(fern-action-hidden-toggle)
nmap <buffer> q :<C-u>quit<CR>
endfunction
augroup fern-custom
autocmd! *
autocmd FileType fern call s:init_fern()
augroup END
let g:ale_completion_enabled = 1 " This setting must be set before ALE is loaded.
Plug 'dense-analysis/ale'
let g:ale_linters = {
\ 'html': ['htmlhint'],
\ 'php': ['php', 'phpcs'],
\ 'javascript': ['eslint'],
\ 'markdown': ['textlint']
\}
let g:ale_lint_on_text_changed = 'never'
let g:ale_virtualtext_cursor = 0
Plug 'thinca/vim-zenspace'
let g:zenspace#default_mode = 'on'
augroup vimrc-highlight
autocmd!
autocmd ColorScheme * highlight ZenSpace ctermbg=Red guibg=Red
augroup END
Plug 'tpope/vim-fugitive'
Plug 'itchyny/lightline.vim' " It depends on vim-fugitive
let g:lightline = {
\ 'colorscheme': 'jellybeans',
\ 'active': {
\ 'left': [
\ ['mode', 'current_branch', 'paste'],
\ [ 'modified', 'filename', 'readonly']
\ ]
\ },
\ 'component': {
\ 'readonly': '%{&readonly?"[RO]":""}'
\ },
\ 'component_function': {
\ 'current_branch': 'LLCurrentBranch',
\ 'filename': 'LLFileName',
\ 'mode': 'LLMultiMode',
\ 'fileformat': 'LLFileFormat',
\ 'filetype': 'LLFileType',
\ 'fileencoding': 'LLFileEncoding'
\ }
\ }
"-- lightline functions --"
function! LLCurrentBranch()
try
if exists('*fugitive#head') && strlen(fugitive#head())
return "ト " . fugitive#head()
endif
catch
endtry
return ''
endfunction
function! LLFileName()
return expand('%:t')
endfunction
function! LLMultiMode()
let fname = expand('%:t')
return lightline#mode()
endfunction
function! LLFileFormat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LLFileType()
return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : 'no ft') : ''
endfunction
function! LLFileEncoding()
return winwidth(0) > 70 ? (&fenc !=# '' ? &fenc : &enc) : ''
endfunction
Plug 'nathanaelkane/vim-indent-guides'
let g:indent_guides_enable_on_vim_startup=1
let g:indent_guides_start_level=2
let g:indent_guides_color_change_percent = 2
let g:indent_guides_guide_size = 1
Plug 'editorconfig/editorconfig-vim'
let g:EditorConfig_max_line_indicator = "exceeding"
Plug 'vim-scripts/taglist.vim'
let g:Tlist_Use_Right_Window = 1
let g:Tlist_WinWidth = 40
Plug 'glidenote/memolist.vim'
let g:memolist_path = expand("~/Documents/Memos")
let g:memolist_memo_suffix = "md"
Plug 'previm/previm'
let g:previm_open_cmd="open -a Safari"
augroup PrevimSettings
autocmd!
autocmd BufNewFile,BufRead *.{md,mdwn,mkd,mkdn,mark*} set filetype=markdown
augroup END
Plug 'tpope/vim-rhubarb'
Plug 'tomtom/tcomment_vim'
Plug 'airblade/vim-gitgutter'
Plug 'mattn/emmet-vim'
Plug 'junegunn/vim-easy-align'
Plug 'github/copilot.vim'
let g:copilot_filetypes = {
\ 'gitcommit': v:true,
\ 'yaml': v:true
\ }
if s:brew_prefix != ''
let g:copilot_node_command = s:brew_prefix . '/opt/node@20/bin/node'
endif
" File specific
Plug 'KazuakiM/vim-sqlfix'
Plug 'cespare/vim-toml'
Plug 'hashivim/vim-terraform'
Plug 'othree/yajs.vim'
Plug 'mattn/vim-sqlfmt'
Plug 'fatih/vim-go', { 'do': 'GoUpdateBinaries' }
Plug 'chr4/nginx.vim'
Plug 'glench/vim-jinja2-syntax'
Plug 'pearofducks/ansible-vim'
Plug 'posva/vim-vue'
Plug 'bfontaine/Brewfile.vim'
Plug 'okkiroxx/rtx.vim'
if has('nvim')
Plug 'kassio/neoterm'
endif
" This automatically executes `filetype plugin indent on` and `syntax enable`.
call plug#end()
" statusline config
set laststatus=2