1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-26 21:22:00 +03:00

ctags.kak: Fix compatibility with OSX by using custom realpath implementation

This commit is contained in:
Maxime Coste 2018-03-30 09:30:18 +11:00
parent 8eee5500ea
commit 510be03910

View File

@ -8,9 +8,10 @@ declare-option -docstring "colon separated list of paths to tag files to parse w
define-command -params ..1 \ define-command -params ..1 \
-shell-candidates ' -shell-candidates '
realpath() { ( path=$(readlink "$1"); cd "$(dirname "$1")"; printf "%s/%s\n" "$(pwd -P)" "$(basename "$1")" ) }
printf %s\\n "$kak_opt_ctagsfiles" | tr \':\' \'\n\' | printf %s\\n "$kak_opt_ctagsfiles" | tr \':\' \'\n\' |
while read -r candidate; do while read -r candidate; do
[ -f "$candidate" ] && readlink -f "$candidate" [ -f "$candidate" ] && realpath "$candidate"
done | awk \'!x[$0]++\' | # remove duplicates done | awk \'!x[$0]++\' | # remove duplicates
while read -r tags; do while read -r tags; do
namecache="${tags%/*}/.kak.${tags##*/}.namecache" namecache="${tags%/*}/.kak.${tags##*/}.namecache"
@ -23,13 +24,14 @@ define-command -params ..1 \
If no symbol is passed then the current selection is used as symbol name} \ If no symbol is passed then the current selection is used as symbol name} \
ctags-search \ ctags-search \
%{ %sh{ %{ %sh{
realpath() { ( path=$(readlink "$1"); cd "$(dirname "$1")"; printf "%s/%s\n" "$(pwd -P)" "$(basename "$1")" ) }
export tagname=${1:-${kak_selection}} export tagname=${1:-${kak_selection}}
printf %s\\n "$kak_opt_ctagsfiles" | tr ':' '\n' | printf %s\\n "$kak_opt_ctagsfiles" | tr ':' '\n' |
while read -r candidate; do while read -r candidate; do
[ -f "$candidate" ] && readlink -f "$candidate" [ -f "$candidate" ] && realpath "$candidate"
done | awk '!x[$0]++' | # remove duplicates done | awk '!x[$0]++' | # remove duplicates
while read -r tags; do while read -r tags; do
printf '!TAGROOT\t%s\n' "$(readlink -f "${tags%/*}")/" printf '!TAGROOT\t%s\n' "$(realpath "${tags%/*}")/"
readtags -t "$tags" $tagname readtags -t "$tags" $tagname
done | awk -F '\t|\n' ' done | awk -F '\t|\n' '
/^!TAGROOT\t/ { tagroot=$2 } /^!TAGROOT\t/ { tagroot=$2 }