4 releases
new 0.1.3 | Jul 3, 2025 |
---|---|
0.1.2 | Mar 30, 2025 |
0.1.1 | Mar 28, 2025 |
0.1.0 | Mar 27, 2025 |
#474 in FFI
77 downloads per month
165KB
3.5K
SLoC
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 recursively in the current directory and its children.
If the --append
option is used, it will look for a tag file in the current
directory or any of its parent directories, and update the tag file if it exists
with tags generated from the list of files passed via command line.
Supported Languages
Full support with extension fields
- Go
- Rust
Basic navigation support without extension fields
- C
- C++
- Elixir
- Java
- JavaScript
- Lua
- Ocaml
- PHP
- Python
- Ruby
- C#
- Bash/Sh
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'
Usage
$ 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:
-f <TAG_FILE>
Name to be used for the tagfile, should not contain path separator [default: tags]
--append <APPEND_RAW>
Append tags to existing tag file instead of reginerating the file from scratch.
Need to pass in list of file names for which new tags are to be generated.
Will panic if the tag file doesn't already exist in current or one of the parent
directories. [default: no]
--workers <WORKERS>
Number of threads to use for parsing files [default: 4]
--exclude <EXCLUDE>
Files/directories matching the pattern will not be used while generating tags
--options <OPTIONS>
Value passed in this arg is currently being ignored.
Kept for compatibility with `vim-gutentags` plugin. [default: ]
--sort <SORT_RAW>
Whether to sort the files or not.
Values of 'yes', 'on', 'true', '1' set it to true
Values of 'no', '0', 'off', 'false' set it to false [default: yes]
--extras <EXTRAS>
Enable extra tag information (e.g., +q for qualified tags, +f for file scope) [default: ]
--format <FORMAT>
Value passed in this arg is currently being ignored.
Kept for compatibility with `tagbar` plugin. [default: ]
--excmd <EXCMD>
Value passed in this arg is currently being ignored.
Kept for compatibility with `tagbar` plugin. [default: ]
--fields <FIELDS>
Include selected extension fields (e.g., +l for line numbers, +S for signatures) [default: ]
--language-force <LANGUAGE_FORCE>
Value passed in this arg is currently being ignored.
Kept for compatibility with `tagbar` plugin. [default: ]
--rust-kinds <RUST_KINDS>
Comma-separated list of Rust tag kinds to generate.
Available kinds: n(module), s(struct), g(enum), u(union), i(trait),
f(function), c(impl), m(field), e(enum_variant), C(constant), v(variable),
t(type_alias), M(macro) [default: ]
--go-kinds <GO_KINDS>
Go language specific kinds to generate tags for [default: ]
-h, --help
Print help
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
Dependencies
~254MB
~8M SLoC