summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vimrc8
-rw-r--r--Biz/Bild/ShellHook.sh6
-rwxr-xr-xBiz/Ide/ftags.sh23
-rwxr-xr-xBiz/Ide/init_tags.sh13
-rwxr-xr-xBiz/Ide/post-checkout28
-rwxr-xr-xBiz/Ide/post-merge2
6 files changed, 66 insertions, 14 deletions
diff --git a/.vimrc b/.vimrc
new file mode 100644
index 0000000..a1848dd
--- /dev/null
+++ b/.vimrc
@@ -0,0 +1,8 @@
+augroup tags
+au BufWritePost *.hs silent !$BIZ_ROOT/Biz/Ide/init_tags.sh %
+au BufWritePost *.hsc silent !$BIZ_ROOT/Biz/Ide/init_tags.sh %
+au BufWritePost *.lhs silent !$BIZ_ROOT/Biz/Ide/init_tags.sh %
+augroup END
+
+set equalprg=ormolu
+
diff --git a/Biz/Bild/ShellHook.sh b/Biz/Bild/ShellHook.sh
index 7724c28..9e629f3 100644
--- a/Biz/Bild/ShellHook.sh
+++ b/Biz/Bild/ShellHook.sh
@@ -18,6 +18,12 @@ alias runghc="runghc --ghc-arg=-i$BIZ_ROOT"
alias tree="tree -I _"
+# link git hooks
+rm -f $BIZ_ROOT/.git/hooks/{post-checkout,post-merge,pre-commit}
+ln -s $BIZ_ROOT/Biz/Ide/post-checkout $BIZ_ROOT/.git/hooks/post-checkout
+ln -s $BIZ_ROOT/Biz/Ide/post-merge $BIZ_ROOT/.git/hooks/post-merge
+ln -s $BIZ_ROOT/Biz/Lint.py $BIZ_ROOT/.git/hooks/pre-commit
+
function bild() {
runghc Biz.Bild $@
}
diff --git a/Biz/Ide/ftags.sh b/Biz/Ide/ftags.sh
index daa4ca0..2687e9a 100755
--- a/Biz/Ide/ftags.sh
+++ b/Biz/Ide/ftags.sh
@@ -2,17 +2,12 @@
# ftags - search ctags
set -euo pipefail
tags=$BIZ_ROOT/tags
-if [[ ! -e $tags ]]
-then
- fast-tags -R $BIZ_ROOT
-else
- line=$(
- awk 'BEGIN { FS="\t" } !/^!/ {print toupper($4)"\t"$1"\t"$2"\t"$3}' $tags \
- | cut -c1-80 \
- | fzf --nth=1,2
- )
- ${EDITOR:-vim} \
- $(cut -f3 <<< "$line") \
- -c "set nocst" \
- -c "silent tag $(cut -f2 <<< "$line")"
-fi
+tag_search=$(
+ awk 'BEGIN { FS="\t" } !/^!/ {print toupper($4)"\t"$1"\t"$2"\t"$3}' $tags \
+ | cut -c1-80 \
+ | fzf --nth=1,2
+)
+${EDITOR:-vim} \
+ $(cut -f3 <<< "$tag_search") \
+ -c "set nocst" \
+ -c "silent tag $(cut -f2 <<< "$tag_search")"
diff --git a/Biz/Ide/init_tags.sh b/Biz/Ide/init_tags.sh
new file mode 100755
index 0000000..10e9c85
--- /dev/null
+++ b/Biz/Ide/init_tags.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+# fast-tags wrapper to generate tags automatically if there are none.
+
+flags=(
+ --fully-qualified
+)
+fns=$@
+if [[ ! -r tags ]]; then
+ echo Generating tags from scratch...
+ exec fast-tags $flags -R .
+else
+ exec fast-tags $flags $fns
+fi
diff --git a/Biz/Ide/post-checkout b/Biz/Ide/post-checkout
new file mode 100755
index 0000000..5474b5a
--- /dev/null
+++ b/Biz/Ide/post-checkout
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+set -eu
+
+# Path to wherever you put this.
+init_tags=$BIZ_ROOT/Biz/Ide/init_tags.sh
+
+old=$1
+new=$2
+# is_branch=$2 # 1 if branch, 2 if file
+
+# filter out only the changed files
+changed=($(git diff --name-only $old $new))
+
+if [[ ! -r tags ]]
+then
+ $init_tags
+elif [[ ${#changed} -gt 0 ]]
+then
+ grep -v -F --regexp=${^changed} $BIZ_ROOT/tags > $BIZ_ROOT/tags.tmp
+ mv tags.tmp tags
+
+ # Retag all hs files except the ones that were deleted.
+ modified=($(git diff --name-only --diff-filter=d $old $new))
+ # Filter *.hs, since grep returns non-zero for no matches.
+ modified=(${(M)modified:#*.hs})
+ echo "modified: $modified"
+ $init_tags $modified
+fi
diff --git a/Biz/Ide/post-merge b/Biz/Ide/post-merge
new file mode 100755
index 0000000..624e797
--- /dev/null
+++ b/Biz/Ide/post-merge
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+exec $BIZ_ROOT/Biz/Ide/post-checkout 'HEAD@{1}' HEAD