Vim TagQuery

Links: GitHub (ctags-query) GitHub (vim-tagquery)
Tag: Rust Vim VimWiki CLI

I use VimWiki daily for my notes and journal. I tag my notes extensively, but found that the built-in tag search in Vim and VimWiki were too basic, supporting only searches like “find all entries with the tag work”. I wanted to be able to do something like “find all entries with the tag work and python but not flask”. I also was very interested in Rust at the time, so I wanted to build something using it and get to know the language better.

I decided to first build a CLI program in Rust called ctags-query, that could parse tags from my notes, store them according to the CTAGS spec, and then query them with a simple query syntax. I built the parser in plain Rust without using any external libraries which was a pretty interesting aspect of this project.

$ ctags-query 'work & python & parsing'
path/to/fileX:10
path/to/fileY:50
path/to/fileZ:165

$ ctags-query 'work & python & parsing'
path/to/fileX:22
path/to/fileY:90

After that I integrated it into Vim as a Vimscript plugin in the vim-tagquery project and gave it a basic FZF-based search interface. Now it was possible to interactively query by tags within Vim!