treetags

Crates.iotreetags
lib.rstreetags
version0.5.2
created_at2025-03-27 12:41:41.096627+00
updated_at2025-12-04 13:29:00.281099+00
descriptionGenerate vi compatible tags for multiple languages
homepage
repositoryhttps://github.com/jha-naman/treetags
max_upload_size
id1607895
size308,324
Jha Naman (jha-naman)

documentation

README

TreeTags

Generate vi compatible tags for multiple languages.

Uses the tags queries defined in the various official language parsers to detect tags.

The goal is to have code navigation available in vim/nvim for multiple languages with minimum effort and have reasonable performance. Extension Fields support is missing by design for most languages to make it easier to support multiple languages and keep the program trivially easy to maintain.

Refer to this issue to see how tags compare to LSP.

By default, it will generate a new tag file in the current directory and look for tags in files list passed during command line invokation. By default it recursively traverses directories present in the list. Pass the -R no or --recurse no options do not want directories to be recursively looked into for tags. If the --append option is used it will update the existing tag file with tags generated from the list of files passed via command line.

Supported Languages

Full support with extension fields

  • Go
  • Rust
  • C
  • C++

Basic navigation support without extension fields

  • Bash/Sh
  • C#
  • Elixir
  • Haskell
  • Java
  • JavaScript
  • Julia
  • Lua
  • Ocaml
  • PHP
  • Python
  • Ruby
  • Scala

Installation

Install Rust and C developmet toolchains to build treetags

cargo build --release
cp target/release/treetags /somewhere/in/the/PATH/

Recommended Usage

While it is fine to manually invoke treetags to generate tags file for a project, the recommended way is to use the gutentags plugin to manage the tags file. There is a nice write-up on setting up gutentags here, which can be useful for setting things up.

You will have to configure gutentags to use treetags as the tags generator at a minimum in your vim/nvim configuration file.

let g:gutentags_ctags_executable = 'treetags'

Or, if you are using lua for configuration

vim.g.gutentags_ctags_executable = 'treetags'

Generate shell autocomplete scripts

Users can generate completions like:

# refer to your shell documentation for determining the correct path for autcomplete files
treetags completions bash > ~/.local/share/bash-completion/completions/treetags
treetags completions zsh > ~/.local/share/zsh/site-functions/_treetags
treetags completions fish > ~/.config/fish/completions/treetags.fish

Running Integration Tests

Integration tests are built from test cases on demand

cargo build  # Generates test files
cargo test   # Runs all tests including generated ones

Usage

Use the --help option to see supported command line arguments.

$ target/release/treetags --help
Generate vi compatible tags for multiple languages

Usage: treetags [OPTIONS] [FILE_NAMES]...

Arguments:
  [FILE_NAMES]...  List of file names to be processed when `--append` option is passed

Options:
  ... # Options omitted for brevity
Commit count: 45

cargo fmt