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/*
vim/user.vim
vim/rplugin.vim
local

118
init.vim
View file

@ -16,80 +16,78 @@
"rplugin location: {{{
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
"}}}
"LOAD DARKCLOUD CONFIG AND THEME FILES: {{{
"Add Config Directory: (distro-agnostic system-wide)
let &runtimepath = printf('%s,%s/vim,%s/vim/after',&runtimepath,g:darkcloudpath,g:darkcloudpath)
"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)
"Load Colours
if &term != "linux"
runtime colors/palette.vim
"load colours
if &term != "linux"
runtime colors/palette.vim
"Load Colour Scheme:
colorscheme darkcloud
"load colour scheme:
colorscheme darkcloud
endif
"load user config:
runtime local/user.vim
"load settings:
runtime config/settings.vim
"initialize plugins:
let g:pathogen_disabled = get(g:, "pathogen_disabled", [])
if has('python3')
"check for python-neovim
redir => python_neovim_check
silent python3 exec("import pkgutil\nneovim = pkgutil.find_loader('neovim')\nfound = neovim is not None\nprint(found)")
redir END
if substitute(python_neovim_check, '^\n*\([^\n]*\)\n*$', '\1', '') == 'True'
let g:python_neovim = 1
else
let g:python_neovim = 0
endif
"Load Settings:
runtime config/settings.vim
"check for python-msgpack
redir => python_msgpack_check
silent python3 exec("import pkgutil\nmsgpack = pkgutil.find_loader('msgpack')\nfound = msgpack is not None\nprint(found)")
redir END
"Initialize Plugins:
let g:pathogen_disabled = get(g:, "pathogen_disabled", [])
if has('python3')
"check for python-neovim
redir => python_neovim_check
silent python3 exec("import pkgutil\nneovim = pkgutil.find_loader('neovim')\nfound = neovim is not None\nprint(found)")
redir END
if substitute(python_neovim_check, '^\n*\([^\n]*\)\n*$', '\1', '') == 'True'
let g:python_neovim = 1
else
let g:python_neovim = 0
endif
"check for python-msgpack
redir => python_msgpack_check
silent python3 exec("import pkgutil\nmsgpack = pkgutil.find_loader('msgpack')\nfound = msgpack is not None\nprint(found)")
redir END
if substitute(python_msgpack_check, '^\n*\([^\n]*\)\n*$', '\1', '') == 'True'
let g:python_msgpack = 1
else
let g:python_msgpack = 0
endif
if substitute(python_msgpack_check, '^\n*\([^\n]*\)\n*$', '\1', '') == 'True'
let g:python_msgpack = 1
else
"if python isn't available disable plugins that depend on it and set library variables to false
call add(g:pathogen_disabled, 'MatchTagAlways')
let g:python_neovim = 0
let g:python_msgpack = 0
endif
else
"if python isn't available disable plugins that depend on it and set library variables to false
call add(g:pathogen_disabled, 'MatchTagAlways')
let g:python_neovim = 0
let g:python_msgpack = 0
endif
"don't load vim-gutentags if ctags can't be found
if !executable('ctags')
call add(g:pathogen_disabled, 'vim-gutentags')
endif
"don't load vim-gutentags if ctags can't be found
if !executable('ctags')
call add(g:pathogen_disabled, 'vim-gutentags')
endif
if !g:python_neovim || !g:python_msgpack
"don't load deoplete if either of its python dependencies are missing
call add(g:pathogen_disabled, 'deoplete.nvim')
call add(g:pathogen_disabled, 'neco-syntax')
endif
if !g:python_neovim || !g:python_msgpack
"don't load deoplete if either of its python dependencies are missing
call add(g:pathogen_disabled, 'deoplete.nvim')
call add(g:pathogen_disabled, 'neco-syntax')
endif
"use pathogen to load plugins that haven't been disabled
runtime bundle/vim-pathogen/autoload/pathogen.vim
"use pathogen to load plugins that haven't been disabled
runtime bundle/vim-pathogen/autoload/pathogen.vim
"Load Keymappings:
runtime config/keyboard.vim
"load keymappings:
runtime config/keyboard.vim
"Load User Config:
runtime user.vim
"load plugin configuration:
runtime config/plugins.vim
"Load Plugin Configuration:
runtime config/plugins.vim
"Load After Config:
runtime config/after.vim
"}}}
"load after config:
runtime config/after.vim

View file

@ -34,15 +34,15 @@ A theme, config and collection of plugins for Neovim
## 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: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:enablecompletion`: **1** = Enable autocompletion | **0** = Disable autocompletion (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**)
* **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 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 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 `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.
## Mappings

77
update
View file

@ -8,6 +8,14 @@
# 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_home="${0%$script_name}"
@ -19,9 +27,6 @@ else
popd >/dev/null || exit
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
cbg_blue=$'\e[44m'
cbg_red_bold=$'\e[1;41m'
@ -35,6 +40,10 @@ else
cbg_blue='#'
fi
#
# FUNCTIONS
#
# error: output and log error
function error {
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
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)"
}
@ -60,7 +70,10 @@ function show_help {
printf '%s\n' 'Run with no arguments to update darkcloud-nvimconfig'
}
### SETUP
#
# SETUP
#
if type -P timeout >/dev/null; then
timeout_command=timeout
elif type -P gtimeout >/dev/null; then
@ -98,23 +111,23 @@ cd "$script_home" || exit
# display script title
printf '\n%s\n' "$cbg_black ~~~ DarkCloud Neovim Config Update Tool ~~~ $c_reset"
# create vim/bundle.user if it doesn't exist
[[ -d 'vim/bundle.user' ]] || {
# create the local bundle directory if it doesn't exist
[[ -d "$local_bundle_dir" ]] || {
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
printf '%s\n' "$cfg_green_bold SUCCESS! $c_reset"
else
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
}
# create vim/user.vim if it doesn't exist
[[ -e 'vim/user.vim' ]] || {
# create user.vim if it doesn't exist
[[ -e "$user_vim_config" ]] || {
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
{
@ -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 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'
} >> 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"
else
printf '%s\n' "$cfg_red_bold FAIL! $c_reset"
fi
else
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
}
### REPO UPDATE
#
# REPO UPDATE
#
printf '\n%s' "$cbg_blue >> Updating darkcloud-nvimconfig:$c_reset"
process_status="$(git pull origin master 2>&1)"
@ -149,7 +165,10 @@ else
exit 1
fi
### SUBMODULE UPDATE {
#
# SUBMODULE UPDATE
#
printf '\n%s\n' "$cbg_blue >> Updating plugin submodules >> $c_reset"
printf '%s' "$cbg_blue $c_reset$cbg_yellow + Updating plugin URLs:$c_reset"
process_status="$(git submodule sync 2>&1)"
@ -218,15 +237,18 @@ fi
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"
pushd 'vim/bundle.user' >/dev/null || exit
pushd "$local_bundle_dir" >/dev/null || exit
for plugin in *; do
[[ -d "$plugin/.git" ]] && {
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)"
if (( ! $? )); then
@ -247,7 +269,10 @@ fi
printf '\n'
}
### GENERATE PLUGIN HELP
#
# GENERATE PLUGIN HELP
#
type -P vim >/dev/null && {
printf '%s' "$cbg_blue >> Generating plugin help:$c_reset"
$timeout_command --preserve-status --foreground 1m nvim -c 'Helptags|qa!'
@ -261,7 +286,10 @@ type -P vim >/dev/null && {
fi
}
### UPDATE REMOTE PLUGINS
#
# UPDATE REMOTE PLUGINS
#
printf '%s' "$cbg_blue >> Updating remote plugins for neovim:$c_reset"
$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'
fi
### FINISH
#
# FINISH
#
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
"INITIALIZE PLUGINS: {{{
"load plugins in vim/bundle/ and vim/bundle.user/
execute pathogen#infect('bundle/{}', 'bundle.user/{}')
execute pathogen#infect('bundle/{}')
"}}}
runtime! config/plugins/*