-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugins.vim
More file actions
226 lines (191 loc) · 7.92 KB
/
Copy pathplugins.vim
File metadata and controls
226 lines (191 loc) · 7.92 KB
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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" ██╗ ██╗██╗███╗ ███╗██████╗ ██████╗
" ██║ ██║██║████╗ ████║██╔══██╗██╔════╝
" ██║ ██║██║██╔████╔██║██████╔╝██║
" ╚██╗ ██╔╝██║██║╚██╔╝██║██╔══██╗██║
" ╚████╔╝ ██║██║ ╚═╝ ██║██║ ██║╚██████╗
" ╚═══╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" AUTO-INSTALL VIM-PLUG ------------------------------------------ {{{
" Check if vim-plug is installed, if not install it automatically
if empty(glob('~/.vim/autoload/plug.vim'))
echo "Installing vim-plug..."
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
augroup plug_bootstrap
autocmd!
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
augroup END
endif
" }}}
" AUTO-INSTALL MISSING PLUGINS ----------------------------------- {{{
" Function to check if all plugins are installed.
" Derived from g:plugs, which vim-plug builds from the Plug calls below, so the
" list cannot drift out of sync with the plugins actually declared.
function! CheckPluginsInstalled() abort
if !exists('g:plugs')
return []
endif
return sort(filter(keys(g:plugs), '!isdirectory(g:plugs[v:val].dir)'))
endfunction
" Auto-install missing plugins on startup. Returns 1 if an install was started.
function! AutoInstallPlugins() abort
let l:missing = CheckPluginsInstalled()
if empty(l:missing)
return 0
endif
echo 'Installing missing plugins: ' . join(l:missing, ', ')
PlugInstall --sync
return 1
endfunction
" Install, then update -- from a single timer. Two independent timers used to
" fire 500ms apart, so PlugInstall and PlugUpdate could run concurrently over
" the same directories on a first launch.
function! s:PluginMaintenance() abort
if AutoInstallPlugins()
return
endif
if get(g:, 'plug_auto_update', 1)
call AutoUpdatePlugins()
endif
endfunction
augroup plug_maintenance
autocmd!
autocmd VimEnter * call timer_start(500, {-> s:PluginMaintenance()})
augroup END
" }}}
" PLUGINS ------------------------------------------------------- {{{
" Create plugged directory if it doesn't exist
if !isdirectory(expand('~/.vim/plugged'))
call mkdir(expand('~/.vim/plugged'), 'p')
endif
call plug#begin('~/.vim/plugged')
Plug 'morhetz/gruvbox'
Plug 'scrooloose/nerdtree'
Plug 'vim-airline/vim-airline'
Plug 'sheerun/vim-polyglot'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'dense-analysis/ale'
Plug 'preservim/tagbar'
Plug 'yggdroot/indentline'
call plug#end()
" }}}
" PLUGIN CONFIG ------------------------------------------------------- {{{
" Gruvbox Colorscheme Configuration
" Order matters: scheme options and 'background' are read while the colorscheme
" loads, so they must be set first. This previously needed two :colorscheme
" calls because g:gruvbox_italic was set between them.
let g:gruvbox_italic=1 " Enable italics in gruvbox theme
set background=dark " Use dark background variant
if has('termguicolors') " Enable true color support in terminal
set termguicolors
endif
" 'silent!': on a first run the plugin is not downloaded yet and a bare call
" would raise E185 before the auto-installer has had a chance to run.
silent! colorscheme gruvbox
" Make the background transparent, and keep it transparent -- any later
" :colorscheme call reloads the scheme and restores Normal's background.
augroup transparent_background
autocmd!
autocmd ColorScheme * highlight Normal guibg=NONE ctermbg=NONE
augroup END
highlight Normal guibg=NONE ctermbg=NONE
" Set terminal ANSI colors to match gruvbox palette
let g:terminal_ansi_colors = [
\ '#282828', '#cc241d', '#98971a', '#d79921',
\ '#458588', '#b16286', '#689d6a', '#a89984',
\ '#928374', '#fb4934', '#b8bb26', '#fabd2f',
\ '#83a598', '#d3869b', '#8ec07c', '#ebdbb2',
\]
" Airline Configuration
" Enhanced status line with powerline fonts support
let g:airline_powerline_fonts=1
" NERDTree Configuration
" File explorer tree with enhanced functionality
nnoremap <C-t> :NERDTreeToggle<CR>
let NERDTreeShowHidden=1
let NERDTreeRespectWildIgnore=1
set wildignore+=*.DS_Store,*.min.*
let NERDTreeIgnore=['\.git$', '\.jpg$', '\.mp4$', '\.ogg$', '\.iso$', '\.pdf$', '\.pyc$', '\.odt$', '\.png$', '\.gif$', '\.db$']
augroup nerdtree_setup
autocmd!
" Auto-start NERDTree when Vim opens without file arguments
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif
" Mirror NERDTree on each new tab for consistent file exploration. The
" getcmdwintype() guard is NERDTree's documented recipe -- without it this
" also fires for the command-line window, where it errors.
autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif
augroup END
" ALE (Asynchronous Lint Engine) Configuration
" Provides real-time syntax checking and code fixing
let g:ale_disable_lsp = 1
" Without this the fixers below are configured but never run.
let g:ale_fix_on_save = 1
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['eslint'],
\ 'javascriptreact': ['eslint'],
\}
" IndentLine Configuration
" Visual indentation guides for better code readability
let g:indentLine_color_gui = '#423d38'
let g:indentLine_setConceal = 0
let g:indentLine_char = '|'
" Tagbar Configuration
" Code structure overview with tag navigation
nnoremap <F8> :TagbarToggle<CR>
" Extended JSX/React support for Tagbar
let g:tagbar_type_javascriptreact = {
\ 'ctagstype': 'javascript',
\ 'kinds': [
\ 'A:array',
\ 'P:property',
\ 'T:tags',
\ 'O:objects',
\ 'g:generator functions',
\ 'f:functions',
\ 'c:classes',
\ 'm:methods',
\ 'V:variables',
\ 'I:imports',
\ 'E:exports',
\ 's:styled components'
\ ]}
" }}}
" AUTO-UPDATE PLUGINS ----------------------------------- {{{
" Check for plugin updates every 7 days (adjust g:plug_update_interval as needed)
let g:plug_update_interval = 7 * 24 * 60 * 60 " 7 days in seconds
let g:plug_last_update_file = expand('~/.vim/plug_last_update')
" Set g:plug_auto_update to 0 in your vimrc to disable the startup update check
" and rely on :UpdatePluginsNow instead.
" Function to check if plugins need updating
function! ShouldUpdatePlugins() abort
if !filereadable(g:plug_last_update_file)
return 1
endif
" get() rather than [0]: an empty file (an interrupted write) would raise
" E684 on every startup.
let l:last_update = str2nr(get(readfile(g:plug_last_update_file), 0, '0'))
return (localtime() - l:last_update) > g:plug_update_interval
endfunction
" Function to update plugins and record timestamp
function! AutoUpdatePlugins() abort
if !ShouldUpdatePlugins()
return
endif
" Recorded before starting, not after. PlugUpdate is asynchronous, so there
" is nothing here to wait on -- this timestamps the attempt, which at least
" stops a failing update from retrying on every single startup.
call writefile([string(localtime())], g:plug_last_update_file)
echo 'Updating plugins...'
PlugUpdate
endfunction
" (The startup check is scheduled by s:PluginMaintenance above, so that an
" install and an update can never run at the same time.)
" Manual update command (use :UpdatePluginsNow to force update)
command! UpdatePluginsNow call AutoUpdatePlugins()
" }}}