Neovim plugin that can quickly navigate to previously indexed locations.
Early development, but useable.
It uses the python3 remote plugin api and sqlite.
You can use :Zem to open a prompt with preview window that shows the currently matching
elements, or you can use :ZemEdit QUERY to directly go to the location.
-
put the
zemfolder inside arplugin/python3folder that nvim searches. (for example using vim-plugPlug 'wonkodv/zem') -
in nvim:
:UpdateRemotePluginsand restart -
(optionaly) define mappings in
init.vimnnoremap <S-Y> :Zem<CR> nnoremap <C-y> :Zem<C-R><C-W><CR> nnoremap <C-]> :ZemEdit =Impl <C-R><C-W><CR>
Before using the :Zem command, the Index must be filled. By executing
:ZemUpdateIndex, all configured sources are indexed and the elements stored in
an sqlite3 database.
Each element consists of these fields:
- match: Text that is matched against to find it (e.g. function name)
- type: what this element represents, (e.g. File, Define, ...)
- file: which file the element is in
- location: how to find the element in the file (Line number or
/{pattern}/)
Each letter of a word must match in order, but words can match out of order:
query | matches | doesn't match
------------|-------------|-----------------
fob | FooBar | Foo
ba foo | FooBar | Foo
foofoo | FooBarFoo | Foo
foo foo | Foo | Bar
Tokens that start with = match against types. If none are given, all types are matched,
otherwise only those types that start with the given ones are matched
query | matches
-----------|-------------
=I | ['Implementation', 'Import']
=Impl | ['Implementation']
=Impl =De | ['Implementation', 'Define']
Matching multiple types might be useful to define mappings that open zem and
narrow down the number of matched types (e.g. nmap <S-T> :Zem =Define =Type <CR>)
The two implemented sources are:
files: index filestags: scan a file generated byctagsand index each tag.
the following configuration variables can be set in init.vim and/or, in a
.nvimrc file inside each project. (.nvimrc files are sourced in the CWD if
the option exrc is set.)
g:zem_db('.zem.sqlite') Name of the index database.g:zem_height(20) Number of rows in the preview windowg:zem_prompt('ZEM> ') Promptg:zem_markup(...)python str.format()-string to displaymatch,typ,file,locationg:zem_sources(['files', 'tags']) names of scanners to use. must be implemented inzem/scanner.pyor vim functions that return elements as(match, typ, file, location)-tuples.g:zem_source_FUNCNAMEParameter that is passed to the scanner. Can be omitted to use defaults.g:zem_source_filesdictionary with these fields:root(".") where to search for filespattern(["**/*.*"]) search pattern (pythonpathlib.Path.glob()syntax)exclude(["*~",".git.","*.pyc",...]) files to exclude (unusual syntax)type("File") type of the matches
g:zem_source_tagsdictionary with these fields:files(['.tags', 'tags']) files to scantype_map({'d':'Define','f':'Implementation', ...}) Map the tag-kind to Element-type. The default maps most tag kinds onto one of:Define,Prototyp,Typedef,Implementation