From fa07364214f85d5dcabd8cef38c9bb9a0e2516b0 Mon Sep 17 00:00:00 2001 From: Nick Rolfe Date: Mon, 4 Feb 2019 10:48:32 +0000 Subject: [PATCH 1/3] Vim syntax highlighting and file-type detection --- misc/vim/README.md | 3 +++ misc/vim/ftdetect/ql.vim | 4 ++++ misc/vim/syntax/ql.vim | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 misc/vim/README.md create mode 100644 misc/vim/ftdetect/ql.vim create mode 100644 misc/vim/syntax/ql.vim diff --git a/misc/vim/README.md b/misc/vim/README.md new file mode 100644 index 000000000000..bd6a3f33cf94 --- /dev/null +++ b/misc/vim/README.md @@ -0,0 +1,3 @@ +# QL syntax highlighting and file-type detection for Vim + +To install, copy the `syntax` and `ftdetect` directories to `~/.vim`. diff --git a/misc/vim/ftdetect/ql.vim b/misc/vim/ftdetect/ql.vim new file mode 100644 index 000000000000..e4216dfbf555 --- /dev/null +++ b/misc/vim/ftdetect/ql.vim @@ -0,0 +1,4 @@ + +au BufRead,BufNewFile *.ql setfiletype ql +au BufRead,BufNewFile *.qll setfiletype ql + diff --git a/misc/vim/syntax/ql.vim b/misc/vim/syntax/ql.vim new file mode 100644 index 000000000000..25681d043761 --- /dev/null +++ b/misc/vim/syntax/ql.vim @@ -0,0 +1,35 @@ +syn keyword qlKeyword from where select predicate in as order by asc desc module +syn keyword qlAnnotation abstract cached external final library noopt private +syn keyword qlLogic not and or implies exists forall forex any none +syn keyword qlConditional if then else +syn keyword qlType int float string boolean date +syn keyword qlImport import nextgroup=qlQualified skipwhite +syn keyword qlTypeMod class extends instanceof nextgroup=qlType skipwhite +syn keyword qlPredicate rank + +syn match qlQualified "\v([a-zA-Z_]+\.)*[a-zA-Z_]+" +syn match qlComment "//.*$" contains=@Spell +syn match qlComparison "[!=<>]" +syn match qlVar "\v[a-zA-Z0-9_#]+" +syn match qlType "\v[@A-Z][a-zA-Z0-9_]+" +syn match qlPredicate "\v[a-zA-Z0-9_#@]+\ze\(" + +syn region qlComment start="/\*" end="\*/" contains=@Spell +syn region qlString start=/\v"/ skip=/\v\\./ end=/\v"/ + +hi def link qlComment Comment +hi def link qlString String +hi def link qlImport Include +hi def link qlComparison Operator +hi def link qlAnnotation PreProc +hi def link qlTypeMod Keyword +hi def link qlLogic Keyword +hi def link qlPredicate Function +hi def link qlConditional Conditional +hi def link qlType Type +if !exists("g:qlVarNoHighlight") + hi def link qlVar Identifier +endif +hi def link qlKeyword Keyword +hi def link qlQualified Normal + From 01fac3164140584fa8576e3c40b6625b60381052 Mon Sep 17 00:00:00 2001 From: Nick Rolfe Date: Fri, 8 Feb 2019 13:43:15 +0000 Subject: [PATCH 2/3] Vim syntax: highlight numbers and new keywords --- misc/vim/syntax/ql.vim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/misc/vim/syntax/ql.vim b/misc/vim/syntax/ql.vim index 25681d043761..f551f62fe649 100644 --- a/misc/vim/syntax/ql.vim +++ b/misc/vim/syntax/ql.vim @@ -1,11 +1,12 @@ -syn keyword qlKeyword from where select predicate in as order by asc desc module +syn keyword qlKeyword from where select predicate in as order by asc desc module result this super syn keyword qlAnnotation abstract cached external final library noopt private syn keyword qlLogic not and or implies exists forall forex any none syn keyword qlConditional if then else syn keyword qlType int float string boolean date syn keyword qlImport import nextgroup=qlQualified skipwhite syn keyword qlTypeMod class extends instanceof nextgroup=qlType skipwhite -syn keyword qlPredicate rank +syn keyword qlAggregate avg concat count max min rank strictconcat strictcount strictsum sum +syn keyword qlConstant false true syn match qlQualified "\v([a-zA-Z_]+\.)*[a-zA-Z_]+" syn match qlComment "//.*$" contains=@Spell @@ -13,6 +14,8 @@ syn match qlComparison "[!=<>]" syn match qlVar "\v[a-zA-Z0-9_#]+" syn match qlType "\v[@A-Z][a-zA-Z0-9_]+" syn match qlPredicate "\v[a-zA-Z0-9_#@]+\ze\(" +syn match qlInt "\d\+" +syn match qlFloat "\d\+\.\d\+" syn region qlComment start="/\*" end="\*/" contains=@Spell syn region qlString start=/\v"/ skip=/\v\\./ end=/\v"/ @@ -24,9 +27,13 @@ hi def link qlComparison Operator hi def link qlAnnotation PreProc hi def link qlTypeMod Keyword hi def link qlLogic Keyword +hi def link qlAggregate Keyword hi def link qlPredicate Function hi def link qlConditional Conditional hi def link qlType Type +hi def link qlConstant Constant +hi def link qlInt Number +hi def link qlFloat Float if !exists("g:qlVarNoHighlight") hi def link qlVar Identifier endif From 7db2f643cc0c1678c250f2397b7786f8d723f10e Mon Sep 17 00:00:00 2001 From: Nick Rolfe Date: Mon, 11 Feb 2019 11:42:53 +0000 Subject: [PATCH 3/3] Vim syntax: add missing annotations and annotation arguments --- misc/vim/syntax/ql.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/vim/syntax/ql.vim b/misc/vim/syntax/ql.vim index f551f62fe649..56e6f09d2f23 100644 --- a/misc/vim/syntax/ql.vim +++ b/misc/vim/syntax/ql.vim @@ -1,5 +1,5 @@ syn keyword qlKeyword from where select predicate in as order by asc desc module result this super -syn keyword qlAnnotation abstract cached external final library noopt private +syn keyword qlAnnotation abstract cached external final library noopt private deprecated override query pragma language bindingset noinline nomagic monotonicAggregates syn keyword qlLogic not and or implies exists forall forex any none syn keyword qlConditional if then else syn keyword qlType int float string boolean date