Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Vim workflow for project and ctag files
#------------------------------------------------------
#-------- CTAGS
make-ctags() {
ctags -RBF -f .tags \
--file-scope=yes \
--sort=yes \
--extra=+fq \
2>/dev/null
}
make-ctags-css() {
ctags -R -f .tags_css \
--file-scope=yes \
--sort=yes \
--languages=css \
2>/dev/null
}
make-ctags-js() {
ctags -R -f .tags_js \
--file-scope=yes \
--sort=yes \
--languages=JavaScript \
2>/dev/null
}
make-ctags-html() {
ctags -R -f .tags_html \
--file-scope=yes \
--sort=yes \
--languages=HTML \
2>/dev/null
}
make-ctags-php() {
ctags -R -f .tags_php \
--file-scope=yes \
--sort=yes \
--fields=+afikKlmnsSzt \
--languages=PHP \
--extra=+fq \
2>/dev/null
}
make-ctags-sql() {
ctags -R -f .tags_sql \
--file-scope=yes \
--sort=yes \
--languages=SQL \
--extra=+fq \
2>/dev/null
}
make-ctags-shell() {
ctags -R -f .tags_sh \
--file-scope=yes \
--sort=yes \
--languages=SH \
2>/dev/null
}
make-ctags-cpp() {
ctags -R -f .tags_cpp \
--file-scope=yes \
--sort=yes \
--c++-kinds=+p \
--fields=+iaS \
--extra=+q \
2>/dev/null
}
#
# Global vim/tags/xxx tags
#
make-ctags-global() {
local dest="${HOME}/.vim/tags"
# create tags dir if it does not exist
if [ ! -d "${dest}" ]; then
mkdir -p "${dest}"
fi
ctags \
-R \
--file-scope=yes \
--sort=yes \
--c++-kinds=+p \
--fields=+iaS \
--extra=+q \
--language-force=C++ \
-f "${dest}/cpp" /usr/include/
}
#------------------------------------------------------
#-------- Vim Project
make-vim-project() {
local name dir
name="_vimrc_local.vim"
dir="$(pwd)"
read -r -d '' USAGE <<-'EOF'
Usage: make-vim-project <type>
all Create ctags for every filetype
web Create ctags for php, js, css and html
cpp Create ctags for c/c++
shell Create ctags for bash/sh
EOF
if [ $# -ne 1 ]; then
echo "$USAGE"
return
fi
# CTAGS
echo "Building ctags"
if [ "$1" == "all" ]; then
make-ctags
make-ctags-css
make-ctags-js
make-ctags-html
make-ctags-php
make-ctags-sql
make-ctags-shell
make-ctags-cpp
elif [ "$1" == "web" ]; then
make-ctags-php
make-ctags-html
make-ctags-js
make-ctags-css
make-ctags-sql
elif [ "$1" == "cpp" ]; then
make-ctags-cpp
elif [ "$1" == "shell" ]; then
make-ctags-shell
else
echo "$USAGE"
return
fi
# Vimrc
echo "Creating local vimrc"
#echo ":silent !echo \"sourcing: ${dir}/${name}\"" > "${name}"
echo ":cd ${dir}" >> "${name}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.