Ctags - mawww/kakoune GitHub Wiki

Kakoune provides the ctags.kak script, but this won't work with out of the box ctags from sourceforge.net. It relies on the readtags command that is available in universal-ctags, but not installed by default. The easiest way would be to use ctags from http://github.com/universal-ctags/ctags which will install the readtags command.

Search for tags file

Use the following hook to search for a tags file in the current directory, then parent directories, until found or the home or root directory is reached.

hook global KakBegin .* %{
    evaluate-commands %sh{
        path="$PWD"
        while [ "$path" != "$HOME" ] && [ "$path" != "/" ]; do
            if [ -e "./tags" ]; then
                printf "%s\n" "set-option -add current ctagsfiles %{$path/tags}"
                break
            else
                cd ..
                path="$PWD"
                # Replace any instances of repeated '/' with a single '/'
                path=`echo "$path" | tr -s /`                                   
            fi
        done
    }
}

This is equivalent to vim's :set tags=./tags; option.

Key mappings

This makes C-] look up the symbol under the cursor, similarly to vim:

map global normal <c-]> <a-i>w:ctags-search<ret>

Use C-o as usual to go back.

⚠️ **GitHub.com Fallback** ⚠️