From 8e25ac2c4f606f3a82e079e0c4efa662b6c4e442 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 25 Jul 2022 09:56:12 -0400 Subject: Add tags support for more languages Rust seems to not be supported in my ctags version :( Also rename some Ide scripts because these are commands, not really scripts. --- Biz/Bild.nix | 1 + Biz/Ide/ftags | 24 ++++++++++++++++++++++++ Biz/Ide/ftags.sh | 19 ------------------- Biz/Ide/hoog | 17 +++++++++++++++++ Biz/Ide/hoog.sh | 17 ----------------- Biz/Ide/init_tags.sh | 12 ------------ Biz/Ide/mktags | 27 +++++++++++++++++++++++++++ 7 files changed, 69 insertions(+), 48 deletions(-) create mode 100755 Biz/Ide/ftags delete mode 100755 Biz/Ide/ftags.sh create mode 100755 Biz/Ide/hoog delete mode 100755 Biz/Ide/hoog.sh delete mode 100755 Biz/Ide/init_tags.sh create mode 100755 Biz/Ide/mktags (limited to 'Biz') diff --git a/Biz/Bild.nix b/Biz/Bild.nix index 15d9134..547ccb9 100644 --- a/Biz/Bild.nix +++ b/Biz/Bild.nix @@ -117,6 +117,7 @@ rec { # this should just be dev tools buildInputs = with nixpkgs.pkgs; [ bild + ctags figlet git haskell.packages.${constants.ghcCompiler}.fast-tags diff --git a/Biz/Ide/ftags b/Biz/Ide/ftags new file mode 100755 index 0000000..6899faa --- /dev/null +++ b/Biz/Ide/ftags @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# +# search tags with fzf +# + set -euo pipefail + if [[ "$EDITOR" =~ ^emacs ]]; then + echo "error: emacs tags not supported" + exit 1 + else + tags=$BIZ_ROOT/tags + fi + tag_search=$( + awk 'BEGIN { FS="\t" } !/^!/ {print toupper($4)"\t"$1"\t"$2"\t"$3}' "$tags" \ + | cut -c1-80 \ + | fzf-tmux \ + --nth=1,2 \ + --preview-window=down \ + --preview "rg --ignore-case --pretty --context 2 --word-regexp {+2}" + ) + ${EDITOR:-vim} \ + "$(cut -f3 <<< "$tag_search")" \ + -c "set nocst" \ + -c "silent tag $(cut -f2 <<< "$tag_search")" +## diff --git a/Biz/Ide/ftags.sh b/Biz/Ide/ftags.sh deleted file mode 100755 index fba7fb0..0000000 --- a/Biz/Ide/ftags.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -# -# search tags with fzf -# - set -euo pipefail - tags=$BIZ_ROOT/tags - tag_search=$( - awk 'BEGIN { FS="\t" } !/^!/ {print toupper($4)"\t"$1"\t"$2"\t"$3}' "$tags" \ - | cut -c1-80 \ - | fzf-tmux \ - --nth=1,2 \ - --preview-window=down \ - --preview "rg --ignore-case --pretty --context 2 --word-regexp {+2}" - ) - ${EDITOR:-vim} \ - "$(cut -f3 <<< "$tag_search")" \ - -c "set nocst" \ - -c "silent tag $(cut -f2 <<< "$tag_search")" -## diff --git a/Biz/Ide/hoog b/Biz/Ide/hoog new file mode 100755 index 0000000..976f0d4 --- /dev/null +++ b/Biz/Ide/hoog @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# +# search hoogle with fzf +# + set -euo pipefail + HOOG="hoogle search --count=200" + export FZF_DEFAULT_COMMAND="$HOOG $*" + result=$(fzf-tmux \ + --preview-window=down \ + --preview "hoogle search --link --info {+2}" \ + --bind "change:reload:$HOOG {q} || true" \ + --ansi \ + | cut -d' ' -f 1,2 \ + | sed -e 's/ /./g' + ) + hoogle search --info "$result" +## diff --git a/Biz/Ide/hoog.sh b/Biz/Ide/hoog.sh deleted file mode 100755 index 976f0d4..0000000 --- a/Biz/Ide/hoog.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -# -# search hoogle with fzf -# - set -euo pipefail - HOOG="hoogle search --count=200" - export FZF_DEFAULT_COMMAND="$HOOG $*" - result=$(fzf-tmux \ - --preview-window=down \ - --preview "hoogle search --link --info {+2}" \ - --bind "change:reload:$HOOG {q} || true" \ - --ansi \ - | cut -d' ' -f 1,2 \ - | sed -e 's/ /./g' - ) - hoogle search --info "$result" -## diff --git a/Biz/Ide/init_tags.sh b/Biz/Ide/init_tags.sh deleted file mode 100755 index 0efc0ed..0000000 --- a/Biz/Ide/init_tags.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -# -# fast-tags wrapper to generate tags automatically if there are none. -# - fns=$@ - if [[ ! -r tags ]]; then - echo Generating tags from scratch... - exec fast-tags $flags -R . - else - exec fast-tags $fns - fi -## diff --git a/Biz/Ide/mktags b/Biz/Ide/mktags new file mode 100755 index 0000000..b5b55c7 --- /dev/null +++ b/Biz/Ide/mktags @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# +# script to generate tags automatically if there are none. +# + set -euxo pipefail + files=$@ + tags=$BIZ_ROOT/tags + flags=() + if [[ "$EDITOR" =~ ^emacs ]]; then + flags+=("-e") + fi + if [[ ! -r $tags ]]; then + echo Generating tags from scratch... + fast-tags "${flags[@]}" -R $BIZ_ROOT + ctags "${flags[@]}" \ + --append=yes \ + --recurse=yes \ + --exclude="$BIZ_ROOT/_/*" \ + $BIZ_ROOT + else + fast-tags "${flags[@]}" $files + ctags "${flags[@]}" \ + --append=yes \ + --exclude="_/*" \ + $files + fi +## -- cgit v1.2.3