-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugins.vim
More file actions
198 lines (160 loc) · 6.37 KB
/
plugins.vim
File metadata and controls
198 lines (160 loc) · 6.37 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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" ██╗ ██╗██╗███╗ ███╗██████╗ ██████╗
" ██║ ██║██║████╗ ████║██╔══██╗██╔════╝
" ██║ ██║██║██╔████╔██║██████╔╝██║
" ╚██╗ ██╔╝██║██║╚██╔╝██║██╔══██╗██║
" ╚████╔╝ ██║██║ ╚═╝ ██║██║ ██║╚██████╗
" ╚═══╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 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
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" }}}
" AUTO-INSTALL MISSING PLUGINS ----------------------------------- {{{
" Function to check if all plugins are installed
function! CheckPluginsInstalled()
let l:missing_plugins = []
" Check each plugin directory
let l:plugins = [
\ 'gruvbox',
\ 'nerdtree',
\ 'vim-airline',
\ 'vim-polyglot',
\ 'vim-commentary',
\ 'vim-surround',
\ 'ale',
\ 'tagbar',
\ 'indentline'
\ ]
for plugin in l:plugins
if empty(glob('~/.vim/plugged/' . plugin))
call add(l:missing_plugins, plugin)
endif
endfor
return l:missing_plugins
endfunction
" Auto-install missing plugins on startup
function! AutoInstallPlugins()
let l:missing = CheckPluginsInstalled()
if !empty(l:missing)
echo "Installing missing plugins: " . join(l:missing, ', ')
PlugInstall --sync
endif
endfunction
" Check and install missing plugins after Vim starts
autocmd VimEnter * call timer_start(500, {-> AutoInstallPlugins()})
" }}}
" 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
colorscheme gruvbox " Set the colorscheme to gruvbox
set termguicolors " Enable true color support in terminal
let g:gruvbox_italic=1 " Enable italics in gruvbox theme
colorscheme gruvbox " Ensure gruvbox is applied (redundant, but safe)
set background=dark " Use dark background variant
hi Normal guibg=NONE ctermbg=NONE " Make background transparent
" 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$']
" 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
autocmd BufWinEnter * silent NERDTreeMirror
" ALE (Asynchronous Lint Engine) Configuration
" Provides real-time syntax checking and code fixing
let g:ale_disable_lsp = 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
nmap <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')
" Function to check if plugins need updating
function! ShouldUpdatePlugins()
if !filereadable(g:plug_last_update_file)
return 1
endif
let last_update = str2nr(readfile(g:plug_last_update_file)[0])
let current_time = localtime()
return (current_time - last_update) > g:plug_update_interval
endfunction
" Function to update plugins and record timestamp
function! AutoUpdatePlugins()
if ShouldUpdatePlugins()
echo "Updating plugins..."
PlugUpdate
call writefile([string(localtime())], g:plug_last_update_file)
endif
endfunction
" Auto-update plugins on Vim startup (runs silently in background)
autocmd VimEnter * call timer_start(1000, {-> AutoUpdatePlugins()})
" Manual update command (use :UpdatePluginsNow to force update)
command! UpdatePluginsNow call AutoUpdatePlugins()
" }}}