From 9f65af402fb282f6edce43dd02fb29c574d301e7 Mon Sep 17 00:00:00 2001 From: Jannik ZANDER Date: Thu, 12 May 2016 22:45:44 +0200 Subject: [PATCH] Effortless Ctags with Git --- .git_template/hooks/ctags | 8 +++ .git_template/hooks/post-checkout | 2 + .git_template/hooks/post-commit | 2 + .git_template/hooks/post-merge | 2 + .git_template/hooks/post-rewrite | 4 ++ .gitconfig | 100 ++++++++++++++++-------------- .vimrc | 76 +++++++---------------- 7 files changed, 91 insertions(+), 103 deletions(-) create mode 100755 .git_template/hooks/ctags create mode 100755 .git_template/hooks/post-checkout create mode 100755 .git_template/hooks/post-commit create mode 100755 .git_template/hooks/post-merge create mode 100755 .git_template/hooks/post-rewrite diff --git a/.git_template/hooks/ctags b/.git_template/hooks/ctags new file mode 100755 index 0000000..1ac991e --- /dev/null +++ b/.git_template/hooks/ctags @@ -0,0 +1,8 @@ +#!/bin/sh +set -e +PATH="/usr/local/bin:$PATH" +dir="`git rev-parse --git-dir`" +trap 'rm -f "$dir/$$.tags"' EXIT +git ls-files | \ + ctags --tag-relative -L - -f"$dir/$$.tags" --languages=-javascript,sql +mv "$dir/$$.tags" "$dir/tags" diff --git a/.git_template/hooks/post-checkout b/.git_template/hooks/post-checkout new file mode 100755 index 0000000..84f17ed --- /dev/null +++ b/.git_template/hooks/post-checkout @@ -0,0 +1,2 @@ +#!/bin/sh +.git/hooks/ctags >/dev/null 2>&1 & diff --git a/.git_template/hooks/post-commit b/.git_template/hooks/post-commit new file mode 100755 index 0000000..84f17ed --- /dev/null +++ b/.git_template/hooks/post-commit @@ -0,0 +1,2 @@ +#!/bin/sh +.git/hooks/ctags >/dev/null 2>&1 & diff --git a/.git_template/hooks/post-merge b/.git_template/hooks/post-merge new file mode 100755 index 0000000..84f17ed --- /dev/null +++ b/.git_template/hooks/post-merge @@ -0,0 +1,2 @@ +#!/bin/sh +.git/hooks/ctags >/dev/null 2>&1 & diff --git a/.git_template/hooks/post-rewrite b/.git_template/hooks/post-rewrite new file mode 100755 index 0000000..fe8972d --- /dev/null +++ b/.git_template/hooks/post-rewrite @@ -0,0 +1,4 @@ +#!/bin/sh +case "$1" in + rebase) exec .git/hooks/post-merge ;; +esac diff --git a/.gitconfig b/.gitconfig index e11463a..0901b62 100644 --- a/.gitconfig +++ b/.gitconfig @@ -1,3 +1,53 @@ +[init] + templatedir = ~/.git_template +[core] + # Use custom `.gitignore` + excludesfile = ~/.gitignore_global + # Treat spaces before tabs and all kinds of trailing whitespace as an error + # [default] trailing-space: looks for spaces at the end of a line + # [default] space-before-tab: looks for spaces before tabs at the beginning of a line + whitespace = space-before-tab,-indent-with-non-tab,trailing-space + # utocrlf = input + editor = git-editor.sh +[color] + # Use colors in Git commands that are capable of colored output when + # outputting to the terminal. (This is the default setting in Git = 1.8.4.) + ui = auto +[color "branch"] + current = yellow reverse + local = yellow + remote = green +[color "diff"] + meta = yellow bold + frag = magenta bold # line info + old = red # deletions + new = green # additions +[color "status"] + added = yellow + changed = green + untracked = cyan +[help] + # Automatically correct and execute mistyped commands + autocorrect = 1 +[diff] + tool = git-difftool + # Detect copies as well as renames + renames = copies + prompt = false +[difftool "git-difftool"] + cmd = git-difftool.sh $LOCAL $REMOTE +[merge] + tool = git-mergetool + # Include summaries of merged commits in newly created merge commit messages + log = true + prompt = false +[mergetool "git-mergetool"] + cmd = git-mergetool.sh $LOCAL $REMOTE $BASE $MERGED +[push] + default = simple +[apply] + # Detect whitespace errors when applying a patch + whitespace = fix [alias] # View abbreviated SHA, description, and history graphs lg = !"git lg1" @@ -50,54 +100,8 @@ co = checkout cobr = checkout -b root = rev-parse --show-toplevel -[apply] - # Detect whitespace errors when applying a patch - whitespace = fix -[core] - # Use custom `.gitignore` - excludesfile = ~/.gitignore_global - # Treat spaces before tabs and all kinds of trailing whitespace as an error - # [default] trailing-space: looks for spaces at the end of a line - # [default] space-before-tab: looks for spaces before tabs at the beginning of a line - whitespace = space-before-tab,-indent-with-non-tab,trailing-space - # utocrlf = input - editor = git-editor.sh -[color] - # Use colors in Git commands that are capable of colored output when - # outputting to the terminal. (This is the default setting in Git = 1.8.4.) - ui = auto -[color "branch"] - current = yellow reverse - local = yellow - remote = green -[color "diff"] - meta = yellow bold - frag = magenta bold # line info - old = red # deletions - new = green # additions -[color "status"] - added = yellow - changed = green - untracked = cyan -[help] - # Automatically correct and execute mistyped commands - autocorrect = 1 -[diff] - tool = git-difftool - # Detect copies as well as renames - renames = copies - prompt = false -[difftool "git-difftool"] - cmd = git-difftool.sh $LOCAL $REMOTE -[merge] - tool = git-mergetool - # Include summaries of merged commits in newly created merge commit messages - log = true - prompt = false -[mergetool "git-mergetool"] - cmd = git-mergetool.sh $LOCAL $REMOTE $BASE $MERGED -[push] - default = simple + ctags = !.git/hooks/ctags [include] # Local/private config goes in the include path = ~/.gitconfig_local + diff --git a/.vimrc b/.vimrc index 9448ac6..3a01c35 100644 --- a/.vimrc +++ b/.vimrc @@ -1,9 +1,7 @@ set nocompatible -"------------------------------------------------------------------------------ -" For plug -"------------------------------------------------------------------------------ -" +"-----------plugin manager---------------- + if empty(glob('$HOME/.vim/autoload/plug.vim')) silent !curl -fLo $HOME/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim @@ -12,63 +10,28 @@ endif call plug#begin('$HOME/.vim/plugged') -Plug 'thanthese/Tortoise-Typing' +Plug 'tpope/vim-sensible' +Plug 'tpope/vim-ragtag' +Plug 'tpope/vim-repeat' +Plug 'tpope/vim-surround' +Plug 'tpope/vim-fugitive' Plug 'altercation/vim-colors-solarized' -Plug 'plasticboy/vim-markdown' -Plug 'vim-airline/vim-airline' -Plug 'vim-airline/vim-airline-themes' +"Plug 'vim-airline/vim-airline' +"Plug 'vim-airline/vim-airline-themes' Plug 'mileszs/ack.vim' Plug 'brandonbloom/csearch.vim' Plug 'chazy/cscope_maps' -Plug 'vim-scripts/taglist.vim' +"Plug 'vim-scripts/taglist.vim' "Plug 'airblade/vim-gitgutter' Plug 'junegunn/fzf.vim' Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } -Plug 'tpope/vim-surround' -Plug 'tpope/vim-ragtag' +Plug 'thanthese/Tortoise-Typing' call plug#end() -"------------------------------------------------------------------------------ -" Regular setting -"------------------------------------------------------------------------------ -" -set backspace=2 -set autoindent -set nobackup -set noswapfile -set nowb -set encoding=utf-8 -set expandtab -set hidden -set hlsearch -set incsearch -set ignorecase -set smartcase -set laststatus=2 -set number -set ruler -set mouse=a -set shiftwidth=2 -set softtabstop=2 -set expandtab -set showcmd -set showmatch -set visualbell t_vb= -set modeline -set modelines=1 -set so=7 -set wildmenu -set nostartofline -set confirm -set cmdheight=2 -set notimeout -set ttimeout -set ttimeoutlen=4000 -set tags+=tags; +"--------------------------------------------- " For color -syntax enable set background=dark let g:solarized_menu=0 try @@ -77,6 +40,7 @@ catch colorscheme default endtry +" For fonts if has("gui_running") if has("gui_gtk2") set guifont=Inconsolata\ 12 @@ -88,20 +52,22 @@ if has("gui_running") endif " For markdown -let g:vim_markdown_folding_disabled = 1 +autocmd BufNewFile,BufReadPost *.md set filetype=markdown +let g:markdown_fenced_languages = ['html', 'python', 'bash=sh'] +let g:markdown_syntax_conceal = 0 " For taglist -let Tlist_Compact_Format = 1 -let Tlist_GainFocus_On_ToggleOpen = 1 -let Tlist_Close_On_Select = 1 -nnoremap :TlistToggle +"let Tlist_Compact_Format = 1 +"let Tlist_GainFocus_On_ToggleOpen = 1 +"let Tlist_Close_On_Select = 1 +"nnoremap :TlistToggle " %s is replaced with fzf command "let g:fzf_launcher = 'xterm -e bash -ic %s' let g:fzf_launcher = "In_a_new_term_function %s" "For airline -let g:airline#extensions#tabline#enabled = 1 +"let g:airline#extensions#tabline#enabled = 1 " Easy escape inoremap jj -- 2.43.0