Move all local/user files (user.vim, the user bundle directory and rplugin.vim) to a new "local" folder

This commit is contained in:
Kevin MacMartin 2024-03-03 21:36:51 -05:00
parent ebc365b812
commit b9d0e25832
6 changed files with 117 additions and 97 deletions

4
.gitignore vendored
View file

@ -1,3 +1 @@
vim/bundle.user/* local
vim/user.vim
vim/rplugin.vim

View file

@ -16,26 +16,28 @@
"rplugin location: {{{ "rplugin location: {{{
lua << EOF lua << EOF
vim.env.NVIM_RPLUGIN_MANIFEST = vim.g.darkcloudpath .. "/vim/rplugin.vim" vim.env.NVIM_RPLUGIN_MANIFEST = vim.g.darkcloudpath .. "/local/rplugin.vim"
EOF EOF
"}}} "}}}
"LOAD DARKCLOUD CONFIG AND THEME FILES: {{{ "add config directory: (distro-agnostic system-wide)
"Add Config Directory: (distro-agnostic system-wide) let &runtimepath = printf('%s,%s/vim,%s/vim/after,%s/local', &runtimepath, g:darkcloudpath, g:darkcloudpath, g:darkcloudpath)
let &runtimepath = printf('%s,%s/vim,%s/vim/after',&runtimepath,g:darkcloudpath,g:darkcloudpath)
"Load Colours "load colours
if &term != "linux" if &term != "linux"
runtime colors/palette.vim runtime colors/palette.vim
"Load Colour Scheme: "load colour scheme:
colorscheme darkcloud colorscheme darkcloud
endif endif
"Load Settings: "load user config:
runtime local/user.vim
"load settings:
runtime config/settings.vim runtime config/settings.vim
"Initialize Plugins: "initialize plugins:
let g:pathogen_disabled = get(g:, "pathogen_disabled", []) let g:pathogen_disabled = get(g:, "pathogen_disabled", [])
if has('python3') if has('python3')
@ -81,15 +83,11 @@ EOF
"use pathogen to load plugins that haven't been disabled "use pathogen to load plugins that haven't been disabled
runtime bundle/vim-pathogen/autoload/pathogen.vim runtime bundle/vim-pathogen/autoload/pathogen.vim
"Load Keymappings: "load keymappings:
runtime config/keyboard.vim runtime config/keyboard.vim
"Load User Config: "load plugin configuration:
runtime user.vim
"Load Plugin Configuration:
runtime config/plugins.vim runtime config/plugins.vim
"Load After Config: "load after config:
runtime config/after.vim runtime config/after.vim
"}}}

View file

@ -34,15 +34,15 @@ A theme, config and collection of plugins for Neovim
## Configuration ## Configuration
* **Configure Variables**: The following variables can be added to `vim/user.vim` and have their values set to the values you require: * **Configure Variables**: The following variables can be added to `local/user.vim` and have their values set to the values you require:
* `g:autostartchecker`: **1** = Enable the syntax checker when a file is opened | **0** = Check syntax only after being toggled on (default: **0**) * `g:autostartchecker`: **1** = Enable the syntax checker when a file is opened | **0** = Check syntax only after being toggled on (default: **0**)
* `g:autostarttagbar`: **1** = Load a file with the tagbar visible | **0** = Require the tagbar to be toggled on (default: **0**) * `g:autostarttagbar`: **1** = Load a file with the tagbar visible | **0** = Require the tagbar to be toggled on (default: **0**)
* `g:enabletreesitter`: **1** = Use treesitter for compatible files | **0** = Keep treesitter disabled (default: **0**) * `g:enabletreesitter`: **1** = Use treesitter for compatible files | **0** = Keep treesitter disabled (default: **0**)
* `g:enablecompletion`: **1** = Enable autocompletion | **0** = Disable autocompletion (default: **0**) * `g:enablecompletion`: **1** = Enable autocompletion | **0** = Disable autocompletion (default: **0**)
* `g:enableautotags`: **1** = Automatically generate tags files | **0** = Disable tag generation (default: **0**) * `g:enableautotags`: **1** = Automatically generate tags files | **0** = Disable tag generation (default: **0**)
* `g:enablepowerline`: **1** = Render the statusline using characters that require powerline-patched fonts | **0** = Render the statusbar with characters that work with all fonts (default: **0**) * `g:enablepowerline`: **1** = Render the statusline using characters that require powerline-patched fonts | **0** = Render the statusbar with characters that work with all fonts (default: **0**)
* **Custom Settings**: Settings with priority over those set by darkcloud-nvimconfig can be added to `vim/user.vim` or any of the folders in the runtimepath. * **Custom Settings**: Settings with priority over those set by darkcloud-nvimconfig can be added to `local/user.vim` or any of the folders in the runtimepath.
* **Custom Plugins**: Pathogen compatible plugins can be cloned or extracted to `darkcloud-nvimconfig/vim/bundle.user/`, or a folder named `bundle` in any of the folders in the runtimepath. * **Custom Plugins**: Pathogen compatible plugins can be cloned or extracted to `local/bundle/`, or a folder named `bundle` in any of the folders in the runtimepath.
* **Update Script**: (requires: bash+git) Use the `update` script to update the project and submodules, as well as handle any required maintenance, generate docs from the pathogen plugins and create missing config scripts with preset values. * **Update Script**: (requires: bash+git) Use the `update` script to update the project and submodules, as well as handle any required maintenance, generate docs from the pathogen plugins and create missing config scripts with preset values.
## Mappings ## Mappings

77
update
View file

@ -8,6 +8,14 @@
# Released under the MIT license # Released under the MIT license
# #
#
# VARIABLES
#
user_vim_config=local/user.vim
local_bundle_dir=local/bundle
error_log=update-errors.log
script_name="${0//*\/}" script_name="${0//*\/}"
script_home="${0%$script_name}" script_home="${0%$script_name}"
@ -19,9 +27,6 @@ else
popd >/dev/null || exit popd >/dev/null || exit
fi fi
repo_version="$(printf "%s.r%s" "$(git show -s --format=%ci master | sed 's/\ .*//g;s/-//g')" "$(git rev-list --count HEAD)")"
error_log='update-errors.log'
if [[ -t 1 ]]; then if [[ -t 1 ]]; then
cbg_blue=$'\e[44m' cbg_blue=$'\e[44m'
cbg_red_bold=$'\e[1;41m' cbg_red_bold=$'\e[1;41m'
@ -35,6 +40,10 @@ else
cbg_blue='#' cbg_blue='#'
fi fi
#
# FUNCTIONS
#
# error: output and log error # error: output and log error
function error { function error {
printf '%s\n' "$cbg_blue $c_reset$cbg_red_bold ! ERROR: $c_reset$cfg_red_bold $2 " >&2 printf '%s\n' "$cbg_blue $c_reset$cbg_red_bold ! ERROR: $c_reset$cfg_red_bold $2 " >&2
@ -47,6 +56,7 @@ function error {
# show_version: displays version information # show_version: displays version information
function show_version { function show_version {
repo_version="$(printf "%s.r%s" "$(git show -s --format=%ci master | sed 's/\ .*//g;s/-//g')" "$(git rev-list --count HEAD)")"
printf '%s\n' "$script_name: darkcloud-nvimconfig update tool (version: $repo_version)" printf '%s\n' "$script_name: darkcloud-nvimconfig update tool (version: $repo_version)"
} }
@ -60,7 +70,10 @@ function show_help {
printf '%s\n' 'Run with no arguments to update darkcloud-nvimconfig' printf '%s\n' 'Run with no arguments to update darkcloud-nvimconfig'
} }
### SETUP #
# SETUP
#
if type -P timeout >/dev/null; then if type -P timeout >/dev/null; then
timeout_command=timeout timeout_command=timeout
elif type -P gtimeout >/dev/null; then elif type -P gtimeout >/dev/null; then
@ -98,23 +111,23 @@ cd "$script_home" || exit
# display script title # display script title
printf '\n%s\n' "$cbg_black ~~~ DarkCloud Neovim Config Update Tool ~~~ $c_reset" printf '\n%s\n' "$cbg_black ~~~ DarkCloud Neovim Config Update Tool ~~~ $c_reset"
# create vim/bundle.user if it doesn't exist # create the local bundle directory if it doesn't exist
[[ -d 'vim/bundle.user' ]] || { [[ -d "$local_bundle_dir" ]] || {
printf '\n%s' "$cbg_blue >> Creating user plugin directory:$c_reset" printf '\n%s' "$cbg_blue >> Creating user plugin directory:$c_reset"
process_status="$(install -d 'vim/bundle.user' 2>&1)" process_status="$(install -d "$local_bundle_dir" 2>&1)"
if (( ! $? )); then if (( ! $? )); then
printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset"
else else
printf '%s\n' "$cfg_red_bold FAIL! $c_reset" printf '%s\n' "$cfg_red_bold FAIL! $c_reset"
error 'install -d vim/bundle.user' "User plugin directory couldn't be created" "$process_status" error "install -d $local_bundle_dir" "User plugin directory couldn't be created" "$process_status"
fi fi
} }
# create vim/user.vim if it doesn't exist # create user.vim if it doesn't exist
[[ -e 'vim/user.vim' ]] || { [[ -e "$user_vim_config" ]] || {
printf '\n%s' "$cbg_blue >> Creating user config file:$c_reset" printf '\n%s' "$cbg_blue >> Creating user config file:$c_reset"
process_status="$(touch 'vim/user.vim' 2>&1)" process_status="$(touch "$user_vim_config" 2>&1)"
if (( ! $? )); then if (( ! $? )); then
{ {
@ -124,20 +137,23 @@ printf '\n%s\n' "$cbg_black ~~~ DarkCloud Neovim Config Update Tool ~~~ $c_reset
printf '%s\n%s\n\n' '"Enable Auto-completion: (1:autocompletion enabled | *0:autocompletion disabled)' '"let g:enablecompletion = 1' printf '%s\n%s\n\n' '"Enable Auto-completion: (1:autocompletion enabled | *0:autocompletion disabled)' '"let g:enablecompletion = 1'
printf '%s\n%s\n\n' '"Enable automatic tag generation: (1:enable tag generation | *0:disable automatic tag generation)' '"let g:enableautotags = 1' printf '%s\n%s\n\n' '"Enable automatic tag generation: (1:enable tag generation | *0:disable automatic tag generation)' '"let g:enableautotags = 1'
printf '%s\n%s\n' '"Enable Powerline: (1:use powerline characters | *0:use regular characters)' '"let g:enablepowerline = 1' printf '%s\n%s\n' '"Enable Powerline: (1:use powerline characters | *0:use regular characters)' '"let g:enablepowerline = 1'
} >> vim/user.vim } >> "$user_vim_config"
if [[ -e 'vim/user.vim' ]]; then if [[ -e "$user_vim_config" ]]; then
printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset" printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset"
else else
printf '%s\n' "$cfg_red_bold FAIL! $c_reset" printf '%s\n' "$cfg_red_bold FAIL! $c_reset"
fi fi
else else
printf '%s\n' "$cfg_red_bold FAIL! $c_reset" printf '%s\n' "$cfg_red_bold FAIL! $c_reset"
error "touch vim/user.vim" "User config couldn't be created" "$process_status" error "touch $user_vim_config" "User config couldn't be created" "$process_status"
fi fi
} }
### REPO UPDATE #
# REPO UPDATE
#
printf '\n%s' "$cbg_blue >> Updating darkcloud-nvimconfig:$c_reset" printf '\n%s' "$cbg_blue >> Updating darkcloud-nvimconfig:$c_reset"
process_status="$(git pull origin master 2>&1)" process_status="$(git pull origin master 2>&1)"
@ -149,7 +165,10 @@ else
exit 1 exit 1
fi fi
### SUBMODULE UPDATE { #
# SUBMODULE UPDATE
#
printf '\n%s\n' "$cbg_blue >> Updating plugin submodules >> $c_reset" printf '\n%s\n' "$cbg_blue >> Updating plugin submodules >> $c_reset"
printf '%s' "$cbg_blue $c_reset$cbg_yellow + Updating plugin URLs:$c_reset" printf '%s' "$cbg_blue $c_reset$cbg_yellow + Updating plugin URLs:$c_reset"
process_status="$(git submodule sync 2>&1)" process_status="$(git submodule sync 2>&1)"
@ -218,15 +237,18 @@ fi
printf '\n' printf '\n'
} }
### USER PLUGIN UPDATE #
[[ -d vim/bundle.user ]] && find vim/bundle.user -mindepth 3 -maxdepth 3 -name config | grep -q '.git/config' && { # USER PLUGIN UPDATE
#
[[ -d "$local_bundle_dir" ]] && find "$local_bundle_dir" -mindepth 3 -maxdepth 3 -name config | grep -q '.git/config' && {
printf '%s\n' "$cbg_blue >> Updating user plugins >> $c_reset" printf '%s\n' "$cbg_blue >> Updating user plugins >> $c_reset"
pushd 'vim/bundle.user' >/dev/null || exit pushd "$local_bundle_dir" >/dev/null || exit
for plugin in *; do for plugin in *; do
[[ -d "$plugin/.git" ]] && { [[ -d "$plugin/.git" ]] && {
pushd "$plugin" >/dev/null || exit pushd "$plugin" >/dev/null || exit
printf '%s' "$cbg_blue $c_reset$cbg_yellow + Updating 'vim/bundle.user/$plugin':$c_reset" printf '%s' "$cbg_blue $c_reset$cbg_yellow + Updating '$local_bundle_dir/$plugin':$c_reset"
process_status="$(git pull 2>&1)" process_status="$(git pull 2>&1)"
if (( ! $? )); then if (( ! $? )); then
@ -247,7 +269,10 @@ fi
printf '\n' printf '\n'
} }
### GENERATE PLUGIN HELP #
# GENERATE PLUGIN HELP
#
type -P vim >/dev/null && { type -P vim >/dev/null && {
printf '%s' "$cbg_blue >> Generating plugin help:$c_reset" printf '%s' "$cbg_blue >> Generating plugin help:$c_reset"
$timeout_command --preserve-status --foreground 1m nvim -c 'Helptags|qa!' $timeout_command --preserve-status --foreground 1m nvim -c 'Helptags|qa!'
@ -261,7 +286,10 @@ type -P vim >/dev/null && {
fi fi
} }
### UPDATE REMOTE PLUGINS #
# UPDATE REMOTE PLUGINS
#
printf '%s' "$cbg_blue >> Updating remote plugins for neovim:$c_reset" printf '%s' "$cbg_blue >> Updating remote plugins for neovim:$c_reset"
$timeout_command --preserve-status --foreground 1m nvim -c ':UpdateRemotePlugins|qa!' $timeout_command --preserve-status --foreground 1m nvim -c ':UpdateRemotePlugins|qa!'
@ -273,5 +301,8 @@ else
error "nvim -c ':UpdateRemotePlugins|qa!'" 'Updating remote plugins for neovim failed' error "nvim -c ':UpdateRemotePlugins|qa!'" 'Updating remote plugins for neovim failed'
fi fi
### FINISH #
# FINISH
#
printf '\n%s\n\n' "$cbg_black ~~~ Update Complete ~~~ $c_reset" printf '\n%s\n\n' "$cbg_black ~~~ Update Complete ~~~ $c_reset"

View file

@ -1,6 +0,0 @@
# Custom Plugins Folder
## Instructions
1. Clone the repositories of pathogen-compatible plugins here to have them loaded when vim runs.
2. Configure these plugins using the `user.vim` file located in the directory below this after running the `update` script.

View file

@ -13,8 +13,7 @@
scriptencoding utf-8 scriptencoding utf-8
"INITIALIZE PLUGINS: {{{ "INITIALIZE PLUGINS: {{{
"load plugins in vim/bundle/ and vim/bundle.user/ execute pathogen#infect('bundle/{}')
execute pathogen#infect('bundle/{}', 'bundle.user/{}')
"}}} "}}}
runtime! config/plugins/* runtime! config/plugins/*