1
1
" ------------------------------------------------------------------------------
2
- " Basic Recommended Settings (optional)
2
+ " Basic Recommended Settings
3
3
" ------------------------------------------------------------------------------
4
4
if v: version >= 800
5
5
set nocompatible
6
6
syntax on
7
7
filetype plugin indent on
8
8
endif
9
9
10
- " For older Vim versions (if needed):
10
+ " ------------------------------------------------------------------------------
11
+ " Fallback for older Vim (comment out if unnecessary)
12
+ " ------------------------------------------------------------------------------
11
13
" set nocompatible
12
14
" syntax enable
13
15
" filetype plugin on
@@ -16,11 +18,19 @@ endif
16
18
" ------------------------------------------------------------------------------
17
19
" Helper Function for Conditional Sourcing
18
20
" ------------------------------------------------------------------------------
19
- function ! SourceIfExists (file ) abort
20
- if filereadable (expand (a: file ))
21
- execute ' source ' . fnameescape (a: file )
22
- endif
23
- endfunction
21
+ if has (' vim9script' )
22
+ def SourceIfExists (file : string )
23
+ if filereadable (expand (file ))
24
+ execute ' source ' .. fnameescape (file )
25
+ endif
26
+ enddef
27
+ else
28
+ function ! SourceIfExists (file ) abort
29
+ if filereadable (expand (a: file ))
30
+ execute ' source ' . fnameescape (a: file )
31
+ endif
32
+ endfunction
33
+ endif
24
34
25
35
" ------------------------------------------------------------------------------
26
36
" Session / Directory Locations
@@ -50,8 +60,7 @@ set nowritebackup
50
60
set noswapfile
51
61
52
62
" Disable matchparen plugin (avoid glitchy behavior)
53
- let g: loaded_matchparen = 1
54
- " or use `:NoMatchParen`
63
+ let g: loaded_matchparen = 1 " or use `:NoMatchParen`
55
64
56
65
" Automatically cd to directory of opened file
57
66
set autochdir
68
77
" ------------------------------------------------------------------------------
69
78
" Netrw Tweak
70
79
" ------------------------------------------------------------------------------
71
- " Fix netrw so that its buffer is hidden when leaving
72
- autocmd FileType netrw setlocal bufhidden = delete
80
+ augroup MyNetrwFix
81
+ autocmd !
82
+ " Fix netrw so that its buffer is hidden on exit
83
+ autocmd FileType netrw setlocal bufhidden = delete
84
+ augroup END
73
85
74
86
" ------------------------------------------------------------------------------
75
87
" Truecolor Support (especially under tmux)
@@ -81,31 +93,30 @@ if exists('+termguicolors')
81
93
endif
82
94
83
95
" ------------------------------------------------------------------------------
84
- " Source Shared/Plugin Files
96
+ " Source Additional Files (Plugins, Settings, etc.)
85
97
" ------------------------------------------------------------------------------
86
- call SourceIfExists (" $HOME/.vim/plugin_loader.vim" )
98
+ call SourceIfExists (' $HOME/.vim/plugin_loader.vim' )
87
99
call plugin_loader#PlugInit ()
88
100
call settings#LoadSettings ()
89
- call SourceIfExists (" $HOME/.vim/settings/highlight.vim" )
101
+ call SourceIfExists (' $HOME/.vim/settings/highlight.vim' )
90
102
91
103
" ------------------------------------------------------------------------------
92
104
" Color Schemes - Fallback Logic
93
105
" ------------------------------------------------------------------------------
106
+ " Using an assumed function lib#ColorSchemeExists() to check if a scheme is present
94
107
95
- " Typically, you'll have a function or autoload script lib#ColorSchemeExists()
96
- " to check if a color scheme is installed. Keeping your existing logic:
97
- if has (' nvim' ) && lib#ColorSchemeExists (" tokyonight-moon" )
108
+ if has (' nvim' ) && exists (' *lib#ColorSchemeExists' ) && lib#ColorSchemeExists (' tokyonight-moon' )
98
109
colorscheme tokyonight- moon
99
- elseif lib#ColorSchemeExists ( " tokyonight" )
110
+ elseif exists ( ' * lib#ColorSchemeExists' ) && lib#ColorSchemeExists ( ' tokyonight' )
100
111
colorscheme tokyonight
101
- elseif lib#ColorSchemeExists ( " catppuccin_mocha" )
112
+ elseif exists ( ' * lib#ColorSchemeExists' ) && lib#ColorSchemeExists ( ' catppuccin_mocha' )
102
113
colorscheme catppuccin_mocha
103
- elseif lib#ColorSchemeExists ( " gruvbox" )
114
+ elseif exists ( ' * lib#ColorSchemeExists' ) && lib#ColorSchemeExists ( ' gruvbox' )
104
115
colorscheme gruvbox
105
- elseif lib#ColorSchemeExists ( " gruvbox-material" )
116
+ elseif exists ( ' * lib#ColorSchemeExists' ) && lib#ColorSchemeExists ( ' gruvbox-material' )
106
117
let g: gruvbox_material_disable_italic_comment = 1
107
118
colorscheme gruvbox- material
108
- elseif lib#ColorSchemeExists ( " everforest" )
119
+ elseif exists ( ' * lib#ColorSchemeExists' ) && lib#ColorSchemeExists ( ' everforest' )
109
120
if has (' termguicolors' )
110
121
set termguicolors
111
122
endif
@@ -114,7 +125,7 @@ elseif lib#ColorSchemeExists("everforest")
114
125
let g: everforest_transparent_background = 2
115
126
let g: everforest_disable_italic_comment = 1
116
127
colorscheme everforest
117
- elseif lib#ColorSchemeExists ( " desert-warm-256" )
128
+ elseif exists ( ' * lib#ColorSchemeExists' ) && lib#ColorSchemeExists ( ' desert-warm-256' )
118
129
colorscheme desert- warm- 256
119
130
else
120
131
colorscheme desert
@@ -123,4 +134,4 @@ endif
123
134
" ------------------------------------------------------------------------------
124
135
" Local Customizations
125
136
" ------------------------------------------------------------------------------
126
- call SourceIfExists (" $HOME/.vimrc.local" )
137
+ call SourceIfExists (' $HOME/.vimrc.local' )
0 commit comments