GithubHelp home page GithubHelp logo

c0r73x / neotags.nvim Goto Github PK

View Code? Open in Web Editor NEW
121.0 7.0 9.0 734 KB

Tag highlight in neovim

License: MIT License

Python 31.84% Makefile 1.06% CMake 3.14% C 47.97% Vim Script 15.98%
neovim ctags highlight async neovim-plugin

neotags.nvim's Introduction

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

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 <DIRECTORY> Add a directory to the global list of "project" top directories
NeotagsRemoveProject <DIRECTORY Remove a directry from the global list of "project" top directories
NeotagsAddProjectDirectory <DIRECTORY> Add an extra directory to the current "project"
NeotagsRemoveProjectDirectory <DIRECTORY Remove a directry from the current "project"
NeotagsBinToggle Toggle usage of the compiled C binary

Options

Option Description Default
g:neotags_enabled Option to enable/disable neotags 0
g:neotags_directory Global directory in which to store all generated tags files ~/.vim_tags
g:neotags_settings_file Global file in which to store all saved "project" directories g:neotags_directory/neotags.json
g:neotags_ignored_tags List of tag names globally excluded from ever being highlighted (eg. try NULL in C) ""
g:neotags_no_autoconf Automatically exclude all standard GNU autotools files (except Makefile) to speed up processing by having fewer tags 1
g:neotags_events_update List of vim events when to run tag generation and update highlight BufWritePost
g:neotags_events_highlight List of vim events when to update highlight BufEnter, BufReadPre
g:neotags_events_rehighlight List of vim events when to clear cache and update highlight Syntax, FileType
g:neotags_run_ctags Option to enable/disable ctags generation from neotags 1
g:neotags_highlight Option to enable/disable neotags highlighting 1
g:neotags_recursive Option to enable/disable recursive tag generation 1
g:neotags_find_tool Command (such as ag -g) run in place of ctags -R to find files ""
g:neotags_ctags_bin Location of ctags ctags
g:neotags_ctags_args ctags arguments --fields=+l --c-kinds=+p --c++-kinds+p --sort=no --extras=+q
g:neotags_ctags_timeout ctags timeout in seconds 3
g:neotags_silent_timeout Hide message when ctags timeouts 0
g:neotags_verbose Verbose output (for debug, must be set before neotags is starated) 0
g:neotags_ignore List of filetypes to ignore 'text','nofile','mail','qf'
g:neotags_global_notin List of global syntax groups which should not include highlighting. '.&ast;String.&ast;', '.&ast;Comment.&ast;', 'cIncluded', 'cCppOut2', 'cCppInElse2', 'cCppOutIf2', 'pythonDocTest', 'pythonDocTest2'
g:neotags_ft_conv Dictionary of languages to convert between ctags and vim { 'C++': 'cpp', 'C#': 'cs' }
g:neotags_ft_ext Dictionary of languages to convert between vim and file extensions { 'python': ['py'], 'perl': ['pl', 'pm'], 'cpp': ['cpp', 'cxx', 'c', 'h', 'hpp'], 'c': ['c', 'h'], 'ruby': ['rb'], 'javascript': ['js', 'jsx', 'vue'], 'vue': ['js', 'vue'], 'typescript': ['ts', 'tsx'] }
g:neotags_tagfiles_by_type Uses g:neotags_regex_tool and g:neotags_find_tool to only find files by extension(s) 0
g:neotags_regex_tool Regex tool to use with g:neotags_tagfiles_by_type ag
g:neotags#c#order Group Name creation for the C language cgstuedfpm
g:neotags#cpp#order Group Name creation for the Cpp language cgstuedfpm
g:neotags#python#order Group Name creation for the Python language mfc
g:neotags#ruby#order Group Name creation for the Ruby language mfc
g:neotags#sh#order Group Name creation for the Shell language fa
g:neotags#java#order Group Name creation for the Java language cimegf
g:neotags#javascript#order Group Name creation for the Javascript language cCfmpo
g:neotags#vim#order Group Name creation for the Vimscript language acfv
g:neotags#perl#order Group Name creation for the Perl language s
g:neotags#php#order Group Name creation for the Php language cfdi

Highlight Group Names

By default group name creation is set for all the different group names of all the supported languages.

C/Cpp

Default Highlight all groups:

let g:neotags#cpp#order = 'cgstuedfpm'
let g:neotags#c#order = 'cgstuedfpm'
Option Group Name
c cppTypeTag
g cppTypeTag
s cppTypeTag
t cppTypeTag
u cppTypeTag
e cppEnumTag
d cppPreProcTag
f cppFunctionTag
p cppFunctionTag
m cppMemberTag

C highlighting is identical to Cpp just remove pp from the group name. Example, cTypeTag. With the g:neotags#cpp#order function you can restrict the highlighting to selected groups. See Speed Improvements below.

Vimscript

let g:neotags#vim#order = 'acfv'
Option Group Name
a vimAutoGroupTag
c vimCommandTag
f vimFuncNameTag (Uses vimScriptFuncNameTag for local script functions)
v vimVariableTag

Python

let g:neotags#python#order = 'mfc'
Language Group Name
m pythonMethodTag
f pythonFunctionTag
c pythonClassTag

Ruby

let g:neotags#ruby#order = 'mfc'
Option Group Name
m rubyModuleNameTag
f rubyClassNameTag
c rubyMethodNameTag

Shell / Zsh

let g:neotags#sh#order = 'fa'
Option Group Name
f shFunctionTag
a shAliasTag

Java

let g:neotags#java#order = 'cimegf'
Option Group Name
c javaClassTag
i javaInterfaceTag
m javaMethodTag
e javaEnumTag
g javaEnumTypeTag
f javaFieldTag

Javascript

let g:neotags#javascript#order = 'cCfmpo'
Option Group Name
c javascriptClassTag
C javascriptConstantTag
f javascriptFunctionTag
m javascriptMethodTag
p javascriptPropsTag
o javascriptObjectTag

Perl

let g:neotags#perl#order = 's'
Option Group Name
s perlFunctionTag

Php

let g:neotags#php#order = 'cfdi'
Option Group Name
c phpClassesTag
f phpFunctionsTag
d phpConstantTag
i phpInterfaceTag
a phpInterfaceTag

Tips

To use the_silver_searcher or similar applications when generating tags you can do something like this.

let g:neotags_recursive = 1

" Use this option for the_silver_searcher
let g:neotags_find_tool = 'ag -g ""'
" Or this one for ripgrep. Not both.
let g:neotags_find_tool = 'ag --files'

Speed Improvements

Also on big projects syntax highlighting may become slow. To address this you can try:

set regexpengine=1

This provides significant speed improvements. In addition you set the highlight options for your language not highlight everything but maybe only the tags your interested in the most. Example:

let g:neotags#cpp#order = 'ced'

The above will only highlight cppTypeTag, cppPreProcTag, cppEnumTag.

ptags

Neotags have support for ptags by adding let g:neotags_ctags_bin = 'ptags' to your vimrc.

Do note that if you have your own custom settings for g:neotags_ctags_args you need to prepend these with -c. Also since ptags do not support -L- the g:neotags_find_tool will be ignored. (-L was added in the latest version).

This is my setup using ptags for git repositories and ctags for other folders.

function s:neotagsCtagsCheck()
    if system('git rev-parse --is-inside-work-tree') =~# 'true'
        let g:neotags_ctags_bin = 'ptags'
        echom 'Neotags using ptags'
        let g:neotags_ctags_args = [
                    \   '-c --fields=+l',
                    \   '-c --c-kinds=+p',
                    \   '-c --c++-kinds=+p',
                    \   '-c --sort=yes',
                    \   "-c --exclude='.mypy_cache'",
                    \   '-c --regex-go=''/^\s*(var)?\s*(\w*)\s*:?=\s*func/\2/f/''',
                    \   "-c --exclude='*Makefile'",
                    \   "-c --exclude='*Makefile.in'",
                    \   "-c --exclude='*aclocal.m4'",
                    \   "-c --exclude='*config.guess'",
                    \   "-c --exclude='*config.h.in'",
                    \   "-c --exclude='*config.log'",
                    \   "-c --exclude='*config.status'",
                    \   "-c --exclude='*configure'",
                    \   "-c --exclude='*depcomp'",
                    \   "-c --exclude='*install-sh'",
                    \   "-c --exclude='*missing'",
                    \ ]
    else
        let g:neotags_ctags_bin = 'ctags'
        echom 'Neotags using ctags'
        let g:neotags_ctags_args = [
                    \   '--fields=+l',
                    \   '--c-kinds=+p',
                    \   '--c++-kinds=+p',
                    \   '--sort=yes',
                    \   "--exclude='.mypy_cache'",
                    \   '--regex-go=''/^\s*(var)?\s*(\w*)\s*:?=\s*func/\2/f/''',
                    \   "--exclude='*Makefile'",
                    \   "--exclude='*Makefile.in'",
                    \   "--exclude='*aclocal.m4'",
                    \   "--exclude='*config.guess'",
                    \   "--exclude='*config.h.in'",
                    \   "--exclude='*config.log'",
                    \   "--exclude='*config.status'",
                    \   "--exclude='*configure'",
                    \   "--exclude='*depcomp'",
                    \   "--exclude='*install-sh'",
                    \   "--exclude='*missing'",
                    \ ]
    endif
endfunction

augroup Neotags
    autocmd VimEnter * call s:neotagsCtagsCheck()
augroup END

Language conversion

The neotags_ft_conv variable is used to convert for example C++ to cpp but it can be used to convert custom filetypes to ctag filetypes.

For example this is what i use for flow

let g:neotags_ft_conv = {
            \ 'C++': 'cpp',
            \ 'C#': 'cs',
            \ 'JavaScript': 'flow',
            \ }

Note that you do need to copy the javascript neotags file neotags.vim/plugin/neotags/javascript.vim to after/plugin/neotags/flow.vim and do a replace for '#javascript' to '#flow'

Custom Rules

You can create custom rules for existing languages or new languages.

let g:neotags#[ctags language]#order = 'string with ctags kinds'
let g:neotags#[ctags language]#[ctags kind] = { 'group': 'highlight' }

For more advanced rules, check the files in neotags.vim/plugin/neotags/*.vim.

You can get the list of kinds by running ctags --list-kinds=[language].

order determents priority of the highlight by first to last (tags with the same name will use the one with higher priority). Note that only kinds in the order string will be loaded.

For example, this is what I use in typescript/tsx

In ~/.ctags

--langdef=typescript
--langmap=typescript:.ts
--langmap=typescript:+.tsx
--regex-typescript=/^[ \t]*(export([ \t]+abstract)?([ \t]+default)?)?[ \t]*class[ \t]+([a-zA-Z0-9_]+)/\4/c,classes/
--regex-typescript=/^[ \t]*(declare)?[ \t]*namespace[ \t]+([a-zA-Z0-9_]+)/\2/n,modules/
--regex-typescript=/^[ \t]*(export)?[ \t]*module[ \t]+([a-zA-Z0-9_]+)/\2/M,modules/
--regex-typescript=/^[ \t]*(export)?[ \t]*function[ \t]+([a-zA-Z0-9_]+)/\2/f,functions/
--regex-typescript=/^[ \t]*export[ \t]+(var|let|const)[ \t]+([a-zA-Z0-9_]+)/\2/v,variables/
--regex-typescript=/^[ \t]*(var|let|const)[ \t]+([a-zA-Z0-9_]+)[ \t]*=[ \t]*function[ \t]*\(\)/\2/V,varlambdas/
--regex-typescript=/^[ \t]*(export)?[ \t]*(public|protected|private)[ \t]+(static)?[ \t]*([a-zA-Z0-9_]+)/\4/m,members/
--regex-typescript=/^[ \t]*(export)?[ \t]*interface[ \t]+([a-zA-Z0-9_]+)/\2/i,interfaces/
--regex-typescript=/^[ \t]*(export)?[ \t]*type[ \t]+([a-zA-Z0-9_]+)/\2/t,types/
--regex-typescript=/^[ \t]*(export)?[ \t]*enum[ \t]+([a-zA-Z0-9_]+)/\2/e,enums/
--regex-typescript=/^[ \t]*import[ \t]+([a-zA-Z0-9_]+)/\1/I,imports/
--regex-typescript=/^[ \t]*@([A-Za-z0-9._$]+)[ \t]*/\1/d,decorator/

In vimrc

let g:neotags#typescript#order = 'cnfmoited'

let g:neotags#typescript#c = { 'group': 'javascriptClassTag' }
let g:neotags#typescript#C = { 'group': 'javascriptConstantTag' }
let g:neotags#typescript#f = { 'group': 'javascriptFunctionTag' }
let g:neotags#typescript#o = { 'group': 'javascriptObjectTag' }

let g:neotags#typescript#n = g:neotags#typescript#C
let g:neotags#typescript#f = g:neotags#typescript#f
let g:neotags#typescript#m = g:neotags#typescript#f
let g:neotags#typescript#o = g:neotags#typescript#o
let g:neotags#typescript#i = g:neotags#typescript#C
let g:neotags#typescript#t = g:neotags#typescript#C
let g:neotags#typescript#e = g:neotags#typescript#C

let g:neotags#typescript#d = g:neotags#typescript#c

neotags.nvim's People

Contributors

c0r73x avatar haasn avatar lbartoletti avatar roflcopter4 avatar sauercrowd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

neotags.nvim's Issues

Install fails with dein

First problem is with a colon
call dein#add('c0r73x/neotags.nvim', {'build:' 'make'})
E720: Missing colon in Dictionary: 'make'})
Then get
Error detected while processing VimEnter Auto commands for "*": E117: Unknown function: NeotagsInit

Edited - problem still exists

Neotags fails to start when installed with vim-plug

I have the python3 neovim and psutils packages installed, and I have installed Neotags using vim-plug. On vim startup, I get the message
Error detected while processing VimEnter Auto commands for "*": E117: Unknown function: NeotagsInit
Would you happen to know what might be tripping vim up?

Traceback at startup

When starting neovim I get the following traceback:

error caught while executing async callback:                                                                                                                   
AttributeError("'Neotags' object has no attribute 'ft'")                                                                                                       
Traceback (most recent call last):                                                                                                                             
  File "/home/asadaoui/.config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 140, in init                                                
    self.update(False)                                                                                                                                         
  File "/home/asadaoui/.config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 181, in update                                              
    self.__groups[ft] = self._parseTags(ft)                                                                                                                    
  File "/home/asadaoui/.config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 382, in _parseTags                                          
    return self._get_tags(files, ft)                                                                                                                           
  File "/home/asadaoui/.config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 578, in _get_tags                                           
    self._parse(ft, match_list, groups, languages, ignored_tags, equivalent, order)                                                                            
  File "/home/asadaoui/.config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 604, in _parse                                              
    key = "%s#%s" % (self.ft, match['kind'].decode('ascii'))                                                                                                   
AttributeError: 'Neotags' object has no attribute 'ft'                                                                                                         
                                                                                                                                                               
the call was requested at                                                                                                                                      
  File "/usr/lib/python3.7/site-packages/neovim/api/nvim.py", line 210, in filter_notification_cb                                                              
    notification_cb(name, args)                                                                                                                                
  File "/usr/lib/python3.7/site-packages/neovim/plugin/host.py", line 107, in _on_notification                                                                 
    handler(*args)                                                                                                                                             
  File "/usr/lib/python3.7/site-packages/neovim/plugin/host.py", line 69, in _wrap_function                                                                    
    return fn(*args)                                                                                                                                           
  File "/home/asadaoui/.config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/__init__.py", line 20, in init                                                
    self.__vim.async_call(self.__neotags.init) 

From a quick look at the code at that line:

    def _parse(self, ft, match_list, groups, languages, ignored_tags, equivalent, order):
        dia.debug_start()
        key_lang = languages[0]

        if key_lang in ('c', 'cpp', 'java', 'go', 'rust', 'cs'):
            buf = strip_c(self.__slurp, dia)
        else:
            buf = bytes(self.__slurp, 'ascii', errors='replace')

        toks = sorted(tokenize(buf, dia))

        for match in match_list:
            if (bindex(toks, match['name']) != (-1)
                    or b'$' in match['name']
                    or b'.' in match['name']):
                key = "%s#%s" % (self.ft, match['kind'].decode('ascii'))
                groups[key].add(match['name'])

        dia.debug_end("Finished _parse, found %d items."
                      % sum(map(len, groups.values())))

It looks like the self.ft should just be ft.

Very poor performance when neotags is enabled and the tags file is large

I have a project with a large tags file (wc -l tags -> 8949), and enabling neotags absolutely cripples vim's performance. Even simple tasks such as j/k are slow, and saving (:w) takes a good 5-10 seconds. This makes editing any file almost impossible.

Also, even with a smaller tags file (e.g. just 1-2k tags), it's still noticeably choppier when scrolling around or saving files.

Is there a way to speed up neotags? Other highlighting plugins (e.g. TagHighlight) do not have this issue.

Invalid buffer id

NvimError(b'Invalid buffer id')
Traceback (most recent call last):
  File "/Users/henryoliver/.config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 140, in init
    self.update(False)
  File "/Users/henryoliver/.config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 181, in update
    self.__groups[ft] = self._parseTags(ft)
  File "/Users/henryoliver/.config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 372, in _parseTags
    self.__slurp = '\n'.join(self.__cur['buf'])
  File "/Users/henryoliver/Library/Python/3.7/lib/python/site-packages/pynvim/api/buffer.py", line 75, in __iter__
    lines = self[:]
  File "/Users/henryoliver/Library/Python/3.7/lib/python/site-packages/pynvim/api/buffer.py", line 48, in __getitem__
    return self.request('nvim_buf_get_lines', start, end, False)
  File "/Users/henryoliver/Library/Python/3.7/lib/python/site-packages/pynvim/api/common.py", line 51, in request
    return self._session.request(name, self, *args, **kwargs)
  File "/Users/henryoliver/Library/Python/3.7/lib/python/site-packages/pynvim/api/nvim.py", line 182, in request
    res = self._session.request(name, *args, **kwargs)
  File "/Users/henryoliver/Library/Python/3.7/lib/python/site-packages/pynvim/msgpack_rpc/session.py", line 102, in request
    raise self.error_wrapper(err)
pynvim.api.nvim.NvimError: b'Invalid buffer id'

the call was requested at
  File "/Users/henryoliver/Library/Python/3.7/lib/python/site-packages/pynvim/api/nvim.py", line 222, in filter_notification_cb
    notification_cb(name, args)
  File "/Users/henryoliver/Library/Python/3.7/lib/python/site-packages/pynvim/plugin/host.py", line 120, in _on_notification
    handler(*args)
  File "/Users/henryoliver/Library/Python/3.7/lib/python/site-packages/pynvim/plugin/host.py", line 82, in _wrap_function
    return fn(*args)
  File "/Users/henryoliver/.config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/__init__.py", line 20, in init
    self.__vim.async_call(self.__neotags.init)```

No module name 'neovim.api.nvim'

When starting neovim I get this traceback:

no notification handler registered for "/home/asadaoui/.config/nvim/plugged/neotags.nvim/rplugin/python3/neotags:function:NeotagsInit"                         
Encountered ModuleNotFoundError loading plugin at /home/asadaoui/.config/nvim/plugged/neotags.nvim/rplugin/python3/neotags: No module named 'neovim.api.nvim'  
Traceback (most recent call last):                                                                                                                             
  File "/usr/lib/python3.7/site-packages/pynvim/plugin/host.py", line 135, in _load                                                                            
    module = imp.load_module(name, file, pathname, descr)                                                                                                      
  File "/usr/lib/python3.7/imp.py", line 244, in load_module                                                                                                   
    return load_package(name, filename)                                                                                                                        
  File "/usr/lib/python3.7/imp.py", line 216, in load_package                                                                                                  
    return _load(spec)                                                                                                                                         
  File "<frozen importlib._bootstrap>", line 696, in _load                                                                                                     
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked                                                                                            
ModuleNotFoundError: No module named 'neovim.api.nvim'

I'm using Neovim v0.3.1

It looks like the python module was renamed from neovim to pynvim. (see this commit)

No highlighting and error in ctags-default flags

  • The default for neotags_ctags_args should contain −−extra=[+|−]flags not --extras=[+|-]flags
  • I am not able to see any difference, when invoking NeotagsToogle.
    My Config:

let g:neotags_enabled = 1
let g:neotags_ctags_args = [ \ '--fields=+l', \ '--c-kinds=+p', \ '--c++-kinds=+p', \ '--sort=no', \ '--extra=+q', \ ]
let g:neotags_highlight = 1

C syntax highlighting not working as before

After some time I updated all my plugins in neovim and I found that some of the highlights are not working like cType and others

screen shot 2018-08-23 at 17 04 20

I'm using rakr/vim-one as my colour scheme I don't see any strange change there.
Anyone can point to me what to look for? I'm getting a bit crazy here

Fails to find module 'ctags'

Looks like trying to call UpdateRemotePlugins throws an error.

Encountered ImportError loading plugin at /Users/mhartington/.config/nvim/.dein/rplugin/python3/neotags: No module named 'ctags'
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/neovim/plugin/host.py", line 132, in _load
    module = imp.load_module(name, file, pathname, descr)
  File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/imp.py", line 244, in load_module
    return load_package(name, filename)
  File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/imp.py", line 216, in load_package
    return _load(spec)
  File "<frozen importlib._bootstrap>", line 693, in _load
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
ImportError: No module named 'ctags'

Seems there is no ctags module to import. Any ideas?

Clarity for ag use in readme.md

The way the following is written is unclear to me:

To use the_silver_searcher or similar applications when generating tags you can do something like this.

let g:neotags_appendpath = 0
let g:neotags_recursive = 0

" Use this option for the_silver_searcher
let g:neotags_ctags_bin = 'ag -g "" '. getcwd() .' | ctags'
" Or this one for ripgrep. Not both.
let g:neotags_ctags_bin = 'rg --files '. getcwd() .' | ctags'
let g:neotags_ctags_args = [
\ '-L -',
\ '--fields=+l',
\ '--c-kinds=+p',
\ '--c++-kinds=+p',
\ '--sort=no',
\ '--extras=+q'
\ ]

Is the ctags_args setting applicable to both the ag and the ripgrep setup?

`async=True` SyntaxError

Upon executing :UpdateRemotePlugins, this error appeared:

  File "/Users/amadan/.local/share/nvim/plugged/neotags.nvim/rplugin/python3/neotag
s/neotags.py", line 128
    self.vim.command('autocmd %s * call NeotagsUpdate()' % evupd, async=True)
                                                                      ^
SyntaxError: invalid syntax

I expect this is due to async being a keyword in Python since 3.7.0:

import keyword
keyword.iskeyword('async')
# => True
import sys
sys.version
# => '3.7.0 (default, Jun 29 2018, 20:13:13) \n[Clang 9.1.0 (clang-902.0.39.2)]'

No highlight of C tags

Work only default highlight for C language.
User-defined types and macroses aren't highlighted.

My config:
let g:neotags_enabled = 1
let g:neotags_highlight = 1
let g:neotags#c#order = 'cgstuedfpm'
let g:neotags#cpp#order = 'cgstuedfpm'

Other plugins:
NerdTree
ctrlp
tagbar

Only update tags matching the buffer saved

It seems like neotags.nvim does not work unless neotags itself is in charge of actually generating the tags file. But I don't like the way neoplete generates tags.

The plugin I'm using currently for that, vim-autotag, only updates tags related to the buffer I just saved. So I can manually run ctags to add additional source files, which will not get clobbered by the script. If I try doing the same with neotags, they get removed:

$ ctags -R --extras=+f --fields=\* /usr/include/vulkan .
$ grep -c 'vulkan.h' tags
3736
# save buffer with neotags running
$ grep -c 'vulkan.h' tags
0

It would be great if you could either modify this script to behave more like vim-autotag (thus preserving the existing tags), or alternatively make it possible to combine neotags with vim-autotag somehow (so I can use neoplete for tag highlighting and vim-autotag for tag updating).

Link the highlighted tag names to sensible values by default

cTypeTag etc. are all completely undefined by default, which sort of defeats the purpose of a highlighting engine. (And no, I don't plan on adding this boilerplate for every language in existence to my own .vimrc)

IMO the default should be linked to sane values like cTypeTag -> Type, cFunctionTag -> Function etc..

Tags sometimes don't get highlighted until I force them to?

I'm not really sure how to debug this, or provide consistent or clear reproduction advice.

Sometimes I noticed that neotags simply doesn't highlight anything. Forcing it off and on again (:NeotagsToggle() twice) fixes it. As does switching to a different buffer and back (sometimes).

I use a lot of split buffers (:vsp etc.), maybe that has something to do with it?

I don't notice anything odd in :messages. I haven't had time to investigate this properly yet.

Error started in latest commits

error caught while executing async callback:
ValueError('cannot mmap an empty file',)
Traceback (most recent call last):
  File "/Users/carlitux/.cache/dein/.cache/init.vim/.dein/rplugin/python3/neotags/neotags.py", line 106, in highlight
    groups, kinds = self._getTags(files)
  File "/Users/carlitux/.cache/dein/.cache/init.vim/.dein/rplugin/python3/neotags/neotags.py", line 329, in _getTags
    mf = mmap.mmap(f.fileno(), 0,  access=mmap.ACCESS_READ)
ValueError: cannot mmap an empty file

the call was requested at
  File "/usr/local/lib/python3.6/site-packages/neovim/api/nvim.py", line 171, in filter_notification_cb
    notification_cb(name, args)
  File "/usr/local/lib/python3.6/site-packages/neovim/plugin/host.py", line 108, in _on_notification
    handler(*args)
  File "/usr/local/lib/python3.6/site-packages/neovim/plugin/host.py", line 70, in _wrap_function
    return fn(*args)
  File "/Users/carlitux/.cache/dein/.cache/init.vim/.dein/rplugin/python3/neotags/__init__.py", line 25, in highlight
    self.__vim.async_call(self.__neotags.highlight)

Disable/enable tags highlighting on the fly

Hello,

Would it be possible to enable/disable tags highlighting without restarting nvim? Tag highlighting is awesome but it makes vim deadly slow, I'd love to just enable it when i need.

Or maybe it can be done already?

No such file or directory when starting neovim

Hi guys,

I installed neotags.vim, compiled the binary and added this config in init.vim:

let g:neotags_enabled = 1
let g:neotags_highlight = 1
let g:neotags_run_ctags = 1
let g:neotags_verbose = 1
let g:neotags_recursive = 1
let g:neotags_no_autoconf = 1

For some reason, when starting neovim, I get this error:

error caught while executing async callback:
FileNotFoundError(2, 'No such file or directory')
Traceback (most recent call last):
File "/Users/elhodred/code/dotfiles/config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 137, in init
self.update(False)
File "/Users/elhodred/code/dotfiles/config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 156, in update
self._update(ft, force)
File "/Users/elhodred/code/dotfiles/config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 278, in _update
self.__groups[ft] = self._parseTags(ft)
File "/Users/elhodred/code/dotfiles/config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 396, in _parseTags
return self._get_tags(files, ft)
File "/Users/elhodred/code/dotfiles/config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 558, in _get_tags
with self._open(File, 'rb', comp_type) as fp:
File "/Users/elhodred/code/dotfiles/config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 943, in _open
return eval(string)
File "", line 1, in
File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/gzip.py", line 53, in open
binary_file = GzipFile(filename, gz_mode, compresslevel)
File "/usr/local/Cellar/python/3.6.4_3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/gzip.py", line 163, in init
fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/Users/elhodred/.vim_tags/__Users__elhodred__Nextcloud__Projects__Athonet__kamailio.tags.gz'

the call was requested at
File "/usr/local/lib/python3.6/site-packages/neovim/api/nvim.py", line 210, in filter_notification_cb
notification_cb(name, args)
File "/usr/local/lib/python3.6/site-packages/neovim/plugin/host.py", line 107, in _on_notification
handler(*args)
File "/usr/local/lib/python3.6/site-packages/neovim/plugin/host.py", line 69, in _wrap_function
return fn(*args)
File "/Users/elhodred/code/dotfiles/config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/init.py", line 20, in init
self.__vim.async_call(self.__neotags.init)

I don't know where to look. Please, someone can give me some directions?

Error on startup

When I install I get the following on startup:

Error detected while processing VimEnter Auto commands for "*":
E117: Unknown function: NeotagsInit
Press ENTER or type command to continue

And this when I try and run :NeotagsToggle

E117: Unknown function: NeotagsToggle

Python deps loaded and puthon3 available in neovim.

$ pip3 list | grep neovim
neovim (0.2.0)
$ pip3 list | grep psutil
psutil (5.4.3)
:version
NVIM v0.2.0
Build type: RelWithDebInfo
Compilation: /usr/bin/x86_64-linux-gnu-gcc -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=2
 -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -DDISABLE_LOG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnost
ics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/build/neovim-LpFVCC/neovim-0.2.0/build/config -I/build/neovim-LpFVCC/neovim-0.2.0/src -I/usr/include -I/usr/include -I/usr/inc
lude -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/build/neovim-LpFVCC/neovim-0.2.0/build/src/nvim/auto -I/build/neovim-LpFVCC/neovim-0.2.0/build/include
Compiled by [email protected]

Optional features included (+) or not (-): +acl   +iconv    +jemalloc +tui
For differences from Vim, see :help vim-differences

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Allow adding extra directories to "projects"

If my project heavily relies on identifiers exported by third parties libraries, I would like to be able to add their include directories to my tag list.

On the command line, I can do this with e.g. ctags . /usr/include/foo/. It seems like neotags has no concept of doing this (except perhaps by overriding the ctags arguments itself via a local vimrc or something).

It would be hugely useful if you could allow adding third party directories like this.

Note that I discussed this before in #12, but the recommended solution in that thread (to disable neotags tag generation in favor of other scripts like autotags) no longer works because neotags no longer consults the tags file, instead storing its tags in ~/.vim_tags. So proper support for this in neotags is needed.

Error on neotags_enabled : Key not found without configuration

Hi, just install this plugin, and restarted, I get this error :

error caught while executing async callback:                                                                                                                                                                       
NvimError(b'Key not found',)                                                                                                                                                                                       
Traceback (most recent call last):                                                                                                                                                                                 
  File "/home/lesell_b/.config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 37, in init                                                                                                     
    if(self.__vim.vars['neotags_enabled']):                                                                                                                                                                        
  File "/usr/lib/python3.5/site-packages/neovim/api/common.py", line 78, in __getitem__                                                                                                                            
    return self._get(key)                                                                                                                                                                                          
  File "/usr/lib/python3.5/site-packages/neovim/api/nvim.py", line 131, in request                                                                                                                                 
    res = self._session.request(name, *args, **kwargs)                                                                                                                                                             
  File "/usr/lib/python3.5/site-packages/neovim/msgpack_rpc/session.py", line 98, in request                                                                                                                       
    raise self.error_wrapper(err)                                                                                                                                                                                  
neovim.api.nvim.NvimError: b'Key not found'                                                                                                                                                                        
                                                                                                                                                                                                                   
the call was requested at                                                                                                                                                                                          
  File "/usr/lib/python3.5/site-packages/neovim/api/nvim.py", line 159, in filter_request_cb                                                                                                                       
    result = request_cb(name, args)                                                                                                                                                                                
  File "/usr/lib/python3.5/site-packages/neovim/plugin/host.py", line 92, in _on_request                                                                                                                           
    rv = handler(*args)                                                                                                                                                                                            
  File "/usr/lib/python3.5/site-packages/neovim/plugin/host.py", line 70, in _wrap_function                                                                                                                        
    return fn(*args)                                                                                                                                                                                               
  File "/home/lesell_b/.config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/__init__.py", line 20, in init                                                                                                    
    self.__vim.async_call(self.__neotags.init)

The error goes off if I set let g:neotags_enabled = 1 in init.vim, but as there shoud be default values, I think this is not the wanted behavior

always error msg: regexp missing final separator

ctags: Warning: /\s*(var)?\s*(\w*)\s*:?=\s*func/\2/f/: regexp missing final separator
neovim 0.4.3, windows 10, ctags for windows
Editing Golang files and md files. Guess not supported by neotags, however.

Syntax highlighting flickers while neotags is running

After opening a buffer, all of the highlighted type names etc. end up flickering back and forth between the chosen highlight color and the normal highlighting while neotags is recomputing the highlighting rules.

It flickers back and forth a good 5-10 times or so, and is quite distracting.

tagfiles() return an empty array

Neotags generate tags automatically and set tag file into tags variable. but when i echo tagfiles() it's return an empty array (using set tags? it's return tags=./tags;,tags,/tmp/nvim9khncX/75). Using command like :tag tagname neovim says No tags file.

Is i must generate ctags manually or using other plugin for generate ctags ?.
thanks before.

No HighLight

Today I'm trying to bring some better highlight on my neovim config. Because I really think that could help if this code was more readable:

#define FOO int

FOO test;

Class Foo2 {};

Foo2 test2;

I want to see FOO and Foo2 with some colors, and that's why I wanted to use [neotags][1] (so neotags should be able to resolve this right?)

So why even with let g:neotags_enabled = 1 and the tags file which is generated correctly (I can see define and class), I still don't have colors even when I remove every other plugins?

Error when python venv in same directory

I get this when loading a python file, ever since I ran: 'python -m venv .venv

error caught while executing async callback:
NvimError(b'Vim(syntax):E339: Pattern too long',)
Traceback (most recent call last):
File "/home/ben/.bbenv/config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 52, in init
self.highlight()
File "/home/ben/.bbenv/config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 158, in highlight
[self.__vim.command(cmd) for cmd in cmds]
File "/home/ben/.bbenv/config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/neotags.py", line 158, in
[self.__vim.command(cmd) for cmd in cmds]
File "/home/ben/.local/lib/python3.5/site-packages/neovim/api/nvim.py", line 218, in command
return self.request('nvim_command', string, **kwargs)
File "/home/ben/.local/lib/python3.5/site-packages/neovim/api/nvim.py", line 131, in request
res = self._session.request(name, *args, **kwargs)
File "/home/ben/.local/lib/python3.5/site-packages/neovim/msgpack_rpc/session.py", line 98, in request
raise self.error_wrapper(err)
neovim.api.nvim.NvimError: b'Vim(syntax):E339: Pattern too long'

the call was requested at
File "/home/ben/.local/lib/python3.5/site-packages/neovim/api/nvim.py", line 171, in filter_notification_cb
notification_cb(name, args)
File "/home/ben/.local/lib/python3.5/site-packages/neovim/plugin/host.py", line 108, in _on_notification
handler(*args)
File "/home/ben/.local/lib/python3.5/site-packages/neovim/plugin/host.py", line 70, in _wrap_function
return fn(*args)
File "/home/ben/.bbenv/config/nvim/plugged/neotags.nvim/rplugin/python3/neotags/init.py", line 21, in init
self.__vim.async_call(self.__neotags.init)

I noticed that the .tags file has a lot of the information found in the .venv folder. Is there a way to exclude it?

Sluggish with big projects

Hi,
Thanks for awesome plugin. My issue is that neovim in windows because extremely sluggish when neotags is enabled for big projects. On the other side I dont even see any highlight difference. I assume is because is busy _parseLine() and not done yet. The neotags file that it creates is ~8.8kb. However, if I use the default options:

let g:neotags_ctags_args = [
            \ '-L -',
            \ '--fields=+l',
            \ '--c-kinds=+p',
            \ '--c++-kinds=+p',
            \ '--sort=no',
            \ '--extra=+q'
            \ ]

Then neotags ctags file is created but always with size 0.
This below is my configuration:

Plug 'c0r73x/neotags.nvim' " Depends on pip3 install --user psutil
	let g:neotags_enabled = 1
	let g:neotags_file = g:cache_path . 'neotags'

	let g:neotags_appendpath = 0
	let g:neotags_recursive = 0
	let g:neotags_ctags_bin = 'rg --files -t cpp "'. getcwd() .'" | ctags'
	let g:neotags_ctags_args = [
				\ '-L -',
				\ '--fields=+iaSl',
				\ '--c-kinds=+p',
				\ '--c++-kinds=+p',
				\ '--sort=no',
				\ '--extra=+q'
				\ ]

Thanks for the support

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.