Skip to content

Commit

Permalink
feat: Revamped spf13-vim (#3)
Browse files Browse the repository at this point in the history
* chore: refactoring

* feat: Revamped spf13-vim

* feat: vim9 compliant
* feat: GitHub Sponsor setup
* feat: self-contained config files
* feat: revamped spf13vim with vim-plug, coc.nvim, lightline, gruvbox and other changes
  • Loading branch information
davidyew authored Dec 10, 2022
1 parent 46fb14f commit 11d2792
Show file tree
Hide file tree
Showing 21 changed files with 111 additions and 120 deletions.
4 changes: 2 additions & 2 deletions .vim/ftdetect/puml.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ vim9script
# Please add PLANTUML into environment variable, e.g: PLANTUML=C:\App,
# where exists $PLANTUML\plantuml.jar
if empty($PLANTUML)
throw 'Missing environment variable:PLANTUML'
throw 'Missing environment variable:PLANTUML for PLANTUML folder path'
endif

g:plantuml_jar_filepath = $PLANTUML .. '\\plantuml.jar'
Expand All @@ -27,6 +27,6 @@ vim9script
# SVG Output
autocmd BufWrite *.puml :silent execute '!' .. g:run_plantuml_cmd .. ' -Tsvg'
else
autocmd BufWrite *.puml :silent execute '!java -jar ' .. plantuml_jar_filepath ..' % -Tsvg &'
autocmd BufWrite *.puml :silent execute '!java -jar ' .. g:plantuml_jar_filepath ..' % -Tsvg &'
endif
# augroup END
14 changes: 0 additions & 14 deletions .vimrc.bundles.default

This file was deleted.

20 changes: 0 additions & 20 deletions .vimrc.bundles.local

This file was deleted.

9 changes: 7 additions & 2 deletions _vimrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
vim9script
set nocompatible # Must be first line

const g:config_path = '~/.spf13-vim'
execute "source " .. g:config_path .. "/bootstrap.vim"
# For 1 user installation
# const g:config_path = '~/.spf13-vim'

# For multiple user installation
const g:config_path = 'C:/src/vim/spf13-vim'

execute 'source ' .. g:config_path .. '/bootstrap.vim'
25 changes: 2 additions & 23 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

############################ SETUP PARAMETERS
app_name='spf13-vim'
[ -z "$APP_PATH" ] && APP_PATH="$HOME/.spf13-vim-2021"
[ -z "$APP_PATH" ] && APP_PATH="$HOME/.spf13-vim"
[ -z "$REPO_URI" ] && REPO_URI='https://github.com/davidyew/spf13-vim.git'
[ -z "$REPO_BRANCH" ] && REPO_BRANCH='main'
debug_mode='0'
Expand Down Expand Up @@ -122,17 +122,13 @@ create_symlinks() {
local target_path="$2"

lnif "$source_path/.vimrc" "$target_path/.vimrc"
lnif "$source_path/.vimrc.bundles" "$target_path/.vimrc.bundles"
lnif "$source_path/.vimrc.before" "$target_path/.vimrc.before"
lnif "$source_path/.vim" "$target_path/.vim"

if program_exists "nvim"; then
lnif "$source_path/.vim" "$target_path/.config/nvim"
lnif "$source_path/.vimrc" "$target_path/.config/nvim/init.vim"
fi

touch "$target_path/.vimrc.local"

ret="$?"
success "Setting up vim symlinks."
debug
Expand All @@ -143,23 +139,6 @@ setup_fork_mode() {
local target_path="$3"

if [ "$1" -eq '1' ]; then
touch "$target_path/.vimrc.fork"
touch "$target_path/.vimrc.bundles.fork"
touch "$target_path/.vimrc.before.fork"

lnif "$source_path/.vimrc.fork" "$target_path/.vimrc.fork"
lnif "$source_path/.vimrc.bundles.fork" "$target_path/.vimrc.bundles.fork"
lnif "$source_path/.vimrc.before.fork" "$target_path/.vimrc.before.fork"
lnif "$source_path/.vimrc.general.config.vim" "$target_path/.vimrc.general.config.vim"
lnif "$source_path/.vimrc.ui.config.vim" "$target_path/.vimrc.ui.config.vim"
lnif "$source_path/.vimrc.statusline.config.vim" "$target_path/.vimrc.statusline.config.vim"
lnif "$source_path/.vimrc.formatting.config.vim" "$target_path/.vimrc.formatting.config.vim"
lnif "$source_path/.vimrc.keymapping.config.vim" "$target_path/.vimrc.keymapping.config.vim"
lnif "$source_path/.vimrc.gui.config.vim" "$target_path/.vimrc.gui.config.vim"
lnif "$source_path/.vimrc.functions.vim" "$target_path/.vimrc.functions.vim"
lnif "$source_path/.vimrc.plugins.config.vim" "$target_path/.vimrc.plugins.config.vim"

lnif "$source_path/operating_systems.function.vim" "$HOME/.vim/autoload/operating_systems.function.vim"
ret="$?"
success "Created fork maintainer files."
debug
Expand Down Expand Up @@ -209,7 +188,7 @@ sync_repo "$HOME/.vim/autoload/vimplug" \
"master" \
"vimplug"

setup_vimplug "$APP_PATH/.vimrc.bundles.default"
setup_vimplug "$APP_PATH/vimrc.bundles.default.vim"

msg "\nThanks for installing $app_name."
msg "© `date +%Y` http://vim.spf13.com/"
42 changes: 22 additions & 20 deletions bootstrap.vim
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
vim9script

import expand(g:config_path .. "/file_utility.vim")
file_utility.CheckAndSource(g:config_path .. "/function.vim")
file_utility.CheckAndSource(g:config_path .. "/operating_systems.function.vim")
# import expand(g:config_path .. "/function.vim")
import expand(g:config_path .. "/operating_systems.function.vim") as OS
import expand(g:config_path .. '/file_utility.vim')

var LoadVimScript = file_utility.CheckAndSource
LoadVimScript(g:config_path .. '/function.vim')
LoadVimScript(g:config_path .. '/operating_systems.function.vim')
# import expand(g:config_path .. '/function.vim')
import expand(g:config_path .. '/operating_systems.function.vim') as OS

# Modeline and Notes {
# vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker={,} foldlevel=0 foldmethod=marker spell:
Expand Down Expand Up @@ -51,11 +53,11 @@ import expand(g:config_path .. "/operating_systems.function.vim") as OS
# On Windows, also use '.vim' instead of 'vimfiles'; this makes synchronization
# across (heterogeneous) systems easier.
if OS.Is_WINDOWS()
set runtimepath=$HOME/.vim,$HOME/.vim/after,$VIM/vimfiles/after,$VIM/vimfiles,$VIMRUNTIME,
set runtimepath=$HOME/.vim,$HOME/.vim/after,$VIM/vimfiles,$VIM/vimfiles/after,$VIMRUNTIME,

# Be nice and check for multi_byte even if the config requires
# multi_byte support most of the time
if has("multi_byte")
if has('multi_byte')
# Windows cmd.exe still uses cp850. If Windows ever moved to
# Powershell as the primary terminal, this would be utf-8
set termencoding=utf-8
Expand All @@ -73,42 +75,42 @@ import expand(g:config_path .. "/operating_systems.function.vim") as OS

# Arrow Key Fix {
# https://github.com/spf13/spf13-vim/issues/780
if &term[ : 4] == "xterm" || &term[ : 5] == 'screen' || &term[ : 3] == 'rxvt'
if &term[ : 4] == 'xterm' || &term[ : 5] == 'screen' || &term[ : 3] == 'rxvt'
inoremap <silent> <C-[>OC <RIGHT>
endif
# }

# }

# Use before config if available {
file_utility.CheckAndSource(g:config_path .. "/.vimrc.before")
LoadVimScript(g:config_path .. '/vimrc.before.vim')
# }

# Use bundles config {
file_utility.CheckAndSource(g:config_path .. "/.vimrc.bundles")
LoadVimScript(g:config_path .. '/vimrc.bundles.vim')
# }

# load config {
file_utility.CheckAndSource(g:config_path .. "/.vimrc.general.config.vim")
file_utility.CheckAndSource(g:config_path .. "/.vimrc.ui.config.vim")
file_utility.CheckAndSource(g:config_path .. "/.vimrc.statusline.config.vim")
file_utility.CheckAndSource(g:config_path .. "/.vimrc.formatting.config.vim")
file_utility.CheckAndSource(g:config_path .. "/.vimrc.keymapping.config.vim")
file_utility.CheckAndSource(g:config_path .. "/.vimrc.gui.config.vim")
file_utility.CheckAndSource(g:config_path .. "/.vimrc.plugins.config.vim")
LoadVimScript(g:config_path .. '/vimrc.general.config.vim')
LoadVimScript(g:config_path .. '/vimrc.ui.config.vim')
LoadVimScript(g:config_path .. '/vimrc.statusline.config.vim')
LoadVimScript(g:config_path .. '/vimrc.formatting.config.vim')
LoadVimScript(g:config_path .. '/vimrc.keymapping.config.vim')
LoadVimScript(g:config_path .. '/vimrc.gui.config.vim')
LoadVimScript(g:config_path .. '/vimrc.plugins.config.vim')
# }

# Use fork vimrc if available {
file_utility.CheckAndSource(g:config_path .. "/.vimrc.fork")
LoadVimScript(g:config_path .. '/vimrc.fork.vim')
# }

# Use local vimrc if available {
file_utility.CheckAndSource(g:config_path .. "/.vimrc.local")
LoadVimScript(g:config_path .. '/vimrc.local.vim')
# }

# Use local gvimrc if available and gui is running {
if has('gui_running')
file_utility.CheckAndSource(g:config_path .. "/.gvimrc.local")
LoadVimScript(g:config_path .. '/gvimrc.local.vim')
endif
# }

Expand Down
30 changes: 15 additions & 15 deletions function.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def! g:InitializeDirectories()

# To specify a different directory in which to place the vimbackup,
# vimviews, vimundo, and vimswap files/directories, add the following to
# your .vimrc.before.local file:
# your vimrc.before.local.vim file:
# g:spf13_consolidated_directory = <full path to desired directory>
# eg: g:spf13_consolidated_directory = $HOME . '/.vim/'
if exists('g:spf13_consolidated_directory')
Expand Down Expand Up @@ -103,7 +103,7 @@ command! -complete=file -nargs=+ Shell s:RunShellCommand(<q-args>)
# TODO: Can remove?
def! g:IsSpf13Fork()
var s:is_fork = 0
var s:fork_files = ["~/.vimrc.fork", "~/.vimrc.before.fork", "~/.vimrc.bundles.fork"]
var s:fork_files = [g:config_path .. '/vimrc.fork.vim', g:config_path .. '/vimrc.before.fork.vim', g:config_path .. '/vimrc.bundles.fork.vim']
for fork_file in s:fork_files
if filereadable(expand(fork_file, ":p"))
var s:is_fork = 1
Expand All @@ -121,29 +121,29 @@ enddef

# For edit of Spf13 Config files
def! g:EditSpf13Config()
<SID>ExpandFilenameAndExecute("tabedit", "~/.vimrc")
<SID>ExpandFilenameAndExecute("vsplit", "~/.vimrc.before")
<SID>ExpandFilenameAndExecute("vsplit", "~/.vimrc.bundles")
<SID>ExpandFilenameAndExecute('tabedit', g:config_path .. '/_vimrc')
<SID>ExpandFilenameAndExecute('vsplit', g:config_path .. '/vimrc.before.vim')
<SID>ExpandFilenameAndExecute('vsplit', g:config_path .. '/vimrc.bundles.vim')

execute bufwinnr(".vimrc") . "wincmd w"
<SID>ExpandFilenameAndExecute("split", "~/.vimrc.local")
execute bufwinnr('.vimrc') . 'wincmd w'
<SID>ExpandFilenameAndExecute('split', g:config_path .. '/vimrc.local.vim')
wincmd l
<SID>ExpandFilenameAndExecute("split", "~/.vimrc.before.local")
<SID>ExpandFilenameAndExecute('split', g:config_path .. '/vimrc.before.local.vim')
wincmd l
<SID>ExpandFilenameAndExecute("split", "~/.vimrc.bundles.local")
<SID>ExpandFilenameAndExecute('split', g:config_path .. '/vimrc.bundles.local.vim')

if <SID>IsSpf13Fork()
execute bufwinnr(".vimrc") . "wincmd w"
<SID>ExpandFilenameAndExecute("split", "~/.vimrc.fork")
execute bufwinnr('.vimrc') . 'wincmd w'
<SID>ExpandFilenameAndExecute('split', g:config_path .. '/vimrc.fork.vim')
wincmd l
<SID>ExpandFilenameAndExecute("split", "~/.vimrc.before.fork")
<SID>ExpandFilenameAndExecute('split', g:config_path .. '/vimrc.before.fork.vim')
wincmd l
<SID>ExpandFilenameAndExecute("split", "~/.vimrc.bundles.fork")
<SID>ExpandFilenameAndExecute('split', g:config_path .. '/vimrc.bundles.fork.vim')
endif

execute bufwinnr(".vimrc.local") . "wincmd w"
execute bufwinnr('vimrc.local.vim') . 'wincmd w'
enddef

# Disable mappings for edit and load spf13 config
# execute "noremap # . s:spf13_edit_config_mapping # :call <SID>EditSpf13Config()<CR>"
# execute "noremap # . s:spf13_apply_config_mapping . # :source ~/.vimrc<CR>"
# execute "noremap # . s:spf13_apply_config_mapping . # :source ~/_vimrc<CR>"
File renamed without changes.
7 changes: 4 additions & 3 deletions spf13-vim-windows-install.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ REM limitations under the License.
@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%

@set APP_PATH=%HOME%\.spf13-vim-2021
@set APP_PATH=%HOME%\.spf13-vim
IF NOT EXIST "%APP_PATH%" (
call git clone -b main https://github.com/davidyew/spf13-vim.git "%APP_PATH%"
) ELSE (
Expand All @@ -29,7 +29,8 @@ IF NOT EXIST "%APP_PATH%" (
call cd "%APP_PATH%"
)

copy /y "%APP_PATH%\.vimrc" "%HOME%\.vimrc"
REM copy /y "%APP_PATH%\.vimrc" "%HOME%\.vimrc"
copy /y "%APP_PATH%\_vimrc" "%HOME%\_vimrc"

REM create directory junction to .vim
REM See https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mklink
Expand All @@ -48,4 +49,4 @@ IF NOT EXIST "%HOME%/.vim/autoload/vim-plug" (
call cd %HOME%
)

call vim -u "%APP_PATH%\.vimrc.bundles" +PlugInstall! +PlugClean +qall
call vim -u "%APP_PATH%\vimrc.bundles.vim" +PlugInstall! +PlugClean +qall
File renamed without changes.
7 changes: 4 additions & 3 deletions .vimrc.before → vimrc.before.vim
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ vim9script
# autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=#404040 ctermbg=234

# Leave the default font and size in GVim
# To set your own font, do it from ~/.vimrc.local
# To set your own font, do it from ~/vimrc.local.vim
# let g:spf13_no_big_font = 1

# Disable omni complete
Expand All @@ -100,11 +100,12 @@ vim9script
# }

import expand("./file_utility.vim")
var LoadVimScript = file_utility.CheckAndSource

# Use fork before if available {
file_utility.CheckAndSource(g:config_path .. "/.vimrc.before.fork")
LoadVimScript(g:config_path .. "/vimrc.before.fork.vim")
# }

# Use local before if available {
file_utility.CheckAndSource(g:config_path .. "/.vimrc.before.local")
LoadVimScript(g:config_path .. "/vimrc.before.local.vim")
# }
14 changes: 14 additions & 0 deletions vimrc.bundles.default.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
vim9script

import expand(g:config_path .. '/file_utility.vim')
var LoadVimScript = file_utility.CheckAndSource
# Default Bundles {

# Use before config if available {
LoadVimScript(g:config_path .. '/vimrc.before.vim')
# }

# Use bundles config {
LoadVimScript(g:config_path .. '/vimrc.bundles.vim')
# }
# }
23 changes: 23 additions & 0 deletions vimrc.bundles.local.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
vim9script

Plug 'davidyew/vimwiki'
Plug 'Konfekt/FastFold'
# 2021-12-05 Skim is not ready for Windows
# Plug 'lotabout/skim', { 'dir': '~/.skim', 'do': './install' }
# Plug 'lotabout/skim.vim'
# Plug 'plasticboy/vim-markdown'
# two-pane text outliner pre-requisite: Python 3
# unstable: cannot navigate on wiki page after using voom Plug 'vim-voom/VOoM'
# jira-vim pre-requisite: Python 3
# Plug 'paulkass/jira-vim'
# Autocomplete, Language Server Protocol
Plug 'neoclide/coc.nvim', {'branch': 'release'}
# Color Scheme
Plug 'morhetz/gruvbox'
# Open API
Plug 'hsanson/vim-openapi'
# CSV
# Plug 'chrisbra/csv.vim'

# TODO: Only include this if there is ctags.exe
Plug 'tc50cal/vim-taglist'
Loading

0 comments on commit 11d2792

Please sign in to comment.