From c71e5aaab29b749890836a122da5f72562f21b03 Mon Sep 17 00:00:00 2001 From: robem Date: Wed, 18 Mar 2020 16:14:39 -0700 Subject: [PATCH] Use grep as a fallback for readtags The `grep` query is more loose than `readtags` when a tag is given. --- rc/modules/fzf-ctags.kak | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/rc/modules/fzf-ctags.kak b/rc/modules/fzf-ctags.kak index 2688a7a..0a61d69 100644 --- a/rc/modules/fzf-ctags.kak +++ b/rc/modules/fzf-ctags.kak @@ -808,17 +808,21 @@ define-command -hidden fzf-tag -params ..2 %{ evaluate-commands %sh{ printf "%s\n" "echo -markup %{{Information}'$kak_opt_fzf_tag_file_name' file found at $HOME. Check if it is right tag file}" fi - readtags_cmd="readtags" - if [ ! $(command -v ${readtags_cmd}) ]; then - printf "%s\n" "echo -markup %{{Information}'${readtags_cmd}' executable not found. Check if '${readtags_cmd} is installed}" - exit - fi - - if [ -n "$1" ]; then - cmd="cd $path; ${readtags_cmd} -t $kak_opt_fzf_tag_file_name -Q '(eq? \$kind \"$1\")' -l | cut -f1" + cmd="cd $path;" + if [ "$(command -v readtags)" ]; then + if [ -n "$1" ]; then + cmd="${cmd} readtags -t $kak_opt_fzf_tag_file_name -Q '(eq? \$kind \"$1\")' -l" + else + cmd="${cmd} readtags -t $kak_opt_fzf_tag_file_name -l" + fi else - cmd="cd $path; ${readtags_cmd} -t $kak_opt_fzf_tag_file_name -l | cut -f1" + if [ -n "$1" ]; then + cmd="${cmd} grep '^\b\"$1\"\b.*\$/' $kak_opt_fzf_tag_file_name -o" + else + cmd="${cmd} grep -v '^!_TAG_*' $kak_opt_fzf_tag_file_name" + fi fi + cmd="${cmd} | cut -f1" message="Jump to a symbol''s definition : open tag in new buffer