Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/c0r73x/neotags.nvim

Tag highlight in neovim
https://github.com/c0r73x/neotags.nvim

async ctags highlight neovim neovim-plugin

Last synced: about 2 months ago
JSON representation

Tag highlight in neovim

Awesome Lists containing this project

README

        

Archived beacuse of lua rewrite https://github.com/c0r73x/neotags.lua

# neotags.nvim

A neovim plugin that generates and highlight ctags similar to easytags.

I wrote this because I didn't like that my vim froze when opening large
projects.

Much of the plugin's speed boost comes from it's ability to filter tags at
runtime. Only tags found in opened buffers are supplied to Neovim for
highlighting. Easytags, on the other hand, supplied all tags found recursively
for a whole project. For very large projects with possibly tens of thousands of
tags, this made Neovim's parser grind to a halt. With the new method, the tag
list is far more manageable.

Be warned that for such large projects it can take some time to process the
list of tags. Fortunately, this is done asynchronously and does not slow the
editor. Furthermore, it is only updated when either a new file is opened or the
buffer is saved. This infrequent time cost is made in place of constantly
forcing Neovim to do the same processing.

![ScreenShot](/screenshot.gif?raw=true)

## Requirements

Neotags requires Neovim with if\_python3, and psutil for Python3.
If `:echo has("python3")` returns `1` and `pip3 list | grep psutil` shows the
psutil package, then you're done; otherwise, see below.

You can enable Python3 interface and psutil with pip:

pip3 install neovim psutil

If tags processing is taking too long it may be advisable to use pypy3 in
place of python3. This is possible by adding `let g:python3_host_prog = 'pypy3'`
to your `.vimrc`. Be advised that it will be necessary to have the Neovim
python module and any modules required by any other Vim plugins installed for
pypy3 as well (including psutil).

## Configuration

There are several configuration options to tweak the processing behavior. By
default, to speed things up all standard autotools files (such as configure,
Makefile.in, etc) are ignored by ctags. This behavior can be disabled with by
setting `g:neotags_no_autoconf` to `0`. Further filenames may be ignored by
appending `--exclude=foo` to the ctags argument list (see `man ctags` for more
information).

By default, a tags file is generated in a global directory for each directory
in which source files appear. If you would like to reduce the number of tags
files, and thereby conglomerate a project into one file, you may designate any
directory as a "project" top directory using the `NeotagsAddProject` command.
See below for details.

## Optional C Extension

Because the original implementation in python can take a modestly long time for
very large projects, the section of code that does the tag filtering has been
rewritten in C. If used, this can quite dramatically decrease the waiting time,
often by up to 4+ times.

It can be enabled simply by compiling it. Run `make` in the root git directory
and the small project will be automatically configured, compiled, and installed
into `~/.vim_tags/bin`. The requirements are cmake, libpcre2, and of course
a working C compiler. All of these should be readily available on any Unix like
platform. If you want to install it elsewhere feel free to configure and build
the project yourself. It is also possible to configure with autotools by
running the included `autogen.sh` if you really prefer.

The build process can be easily automated with a package manager such as dein.
Just add

call dein#add('c0r73x/neotags.nvim', {'build': 'make'})

to your .vimrc or init.nvim file and dein will handle the rest. To disable it
after installing either delete the binary or add `let g:neotags_bin = ''` to
your setup.

As usual, on Windows things are more difficult. It is possible to compile with
MinGW, but the resulting binary is usually slower than the original python! If
you have Visual Studio installed then it is possible to generate a project with
cmake, provided that you can source a copy of `libpcre2-8.lib` or similar from
somewhere. There are no easily available pre-compiled version of this library,
so you'll either have to compile it yourself or download MinGW and use its
pre-compiled version (called `libpcre2-8.dll.a`). Put it in the same directory
as the top `CMakeFiles.txt` file and everything should work. There isn't any
shortcut around this, unfortunately.

If all of this seems like too much bother (especially for Windows users!) then
as mentioned the python version will work perfectly fine, and is probably
plenty fast enough for the majority of cases.

## Commands

| Command | Description |
| --------------------------------------------- | ------------------------------------------------------------------- |
| `NeotagsToggle` | Toggle neotags on the fly |
| `NeotagsAddProject ` | Add a directory to the global list of "project" top directories |
| `NeotagsRemoveProject ` | Add an extra directory to the current "project" |
| `NeotagsRemoveProjectDirectory