Add a LCP syntax highlighter for vim

Reviewers: buda, msantl, mtomic, mferencevic, ipaljak, mculinovic, vkasljevic, mpetricevic

Reviewed By: msantl

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1548
This commit is contained in:
Teon Banek 2018-08-21 14:12:53 +02:00
parent da3630f8a9
commit da9dc10373
4 changed files with 44 additions and 2 deletions

View File

@ -1981,7 +1981,7 @@ and returns true, once.")
deny-privilege revoke-privilege
show-grants show-role-for-user
show-users-for-role))
:capnp-load (lcp:capnp-load-enum "::query::capnp::AuthQuery::Action"
:capnp-load (lcp:capnp-load-enum "::query::capnp::AuthQuery::Action"
"AuthQuery::Action"
'(create-role drop-role show-roles
create-user set-password
@ -2085,7 +2085,7 @@ and returns true, once.")
std::vector<Symbol> OutputSymbols(const SymbolTable &) const override;
virtual std::vector<Symbol> ModifiedSymbols(const SymbolTable &)
const override { return {}; }
bool HasSingleInput() const override;
std::shared_ptr<LogicalOperator> input() const override;
void set_input(std::shared_ptr<LogicalOperator>) override;

14
tools/vim-lcp/README.md Normal file
View File

@ -0,0 +1,14 @@
# vim-lcp
Adds syntax highlighting of LCP files to vim. In the future the plugin may be
extended with additional features, such as formatting, new editing commands etc.
## Installation
I'm assuming that you are using some kind of plugin manager in vim. If not,
check out [Vundle](https://github.com/VundleVim/Vundle.vim).
ln -s <path-to-memgraph>/tools/vim-lcp ~/.vim/bundle/vim-lcp
After symlinking, edit your `vimrc` by adding a `Plugin 'vim-lcp'` directive
inside the `call vundle#begin() ... call vundle#end()` block.

View File

@ -0,0 +1 @@
au! BufNewFile,BufRead *.lcp setfiletype lcp

View File

@ -0,0 +1,27 @@
" Quit when a syntax file was already loaded
if exists("b:current_syntax")
finish
endif
" Base LCP syntax on Lisp syntax
runtime! syntax/lisp.vim
unlet b:current_syntax
" Include C++ syntax for inlined C++ code in LCP
syntax include @CPP syntax/cpp.vim
unlet b:current_syntax
let b:current_syntax = "lcp"
" Set the inline C++ region
syntax region lcpCPPVar matchgroup=CPPVar start="\${" excludenl end="}" contained containedin=@CPP
highlight link CPPVar SpecialComment
syntax region lcpCPP containedin=lispList,lispBQList,lispAtomList matchgroup=CPPBlock start="#>cpp" end="cpp<#" contains=@CPP
highlight link CPPBlock SpecialComment
" Additional LCP keywords
syntax keyword lcpKeyword contained containedin=lispAtomList,lispBQList,lispList lcp:define-class lcp:define-enum lcp:define-struct
syntax keyword lcpKeyword contained containedin=lispAtomList,lispBQList,lispList lcp:namespace lcp:pop-namespace
syntax keyword lcpKeyword contained containedin=lispAtomList,lispBQList,lispList lcp:capnp-namespace lcp:capnp-import lcp:capnp-type-conversion
highlight link lcpKeyword lispFunc