From da9dc10373325e0d907d818273bea044f503079f Mon Sep 17 00:00:00 2001 From: Teon Banek Date: Tue, 21 Aug 2018 14:12:53 +0200 Subject: [PATCH] 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 --- src/query/plan/operator.lcp | 4 ++-- tools/vim-lcp/README.md | 14 ++++++++++++++ tools/vim-lcp/ftdetect/lcp.vim | 1 + tools/vim-lcp/syntax/lcp.vim | 27 +++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 tools/vim-lcp/README.md create mode 100644 tools/vim-lcp/ftdetect/lcp.vim create mode 100644 tools/vim-lcp/syntax/lcp.vim diff --git a/src/query/plan/operator.lcp b/src/query/plan/operator.lcp index 4f3e39cc9..2766e64ff 100644 --- a/src/query/plan/operator.lcp +++ b/src/query/plan/operator.lcp @@ -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 OutputSymbols(const SymbolTable &) const override; virtual std::vector ModifiedSymbols(const SymbolTable &) const override { return {}; } - + bool HasSingleInput() const override; std::shared_ptr input() const override; void set_input(std::shared_ptr) override; diff --git a/tools/vim-lcp/README.md b/tools/vim-lcp/README.md new file mode 100644 index 000000000..755eaf1f4 --- /dev/null +++ b/tools/vim-lcp/README.md @@ -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 /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. diff --git a/tools/vim-lcp/ftdetect/lcp.vim b/tools/vim-lcp/ftdetect/lcp.vim new file mode 100644 index 000000000..c49b926ec --- /dev/null +++ b/tools/vim-lcp/ftdetect/lcp.vim @@ -0,0 +1 @@ +au! BufNewFile,BufRead *.lcp setfiletype lcp diff --git a/tools/vim-lcp/syntax/lcp.vim b/tools/vim-lcp/syntax/lcp.vim new file mode 100644 index 000000000..52bb50cc9 --- /dev/null +++ b/tools/vim-lcp/syntax/lcp.vim @@ -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