Skip to content

Commit

Permalink
feat(highlight): link to treesitter highlight groups instead of vim o…
Browse files Browse the repository at this point in the history
…nes (#56)

See `:h treesitter-highlight-groups`

This enables the use of nimsuggest's semantic highlights with treesitter highlights on supported versions of neovim.

All `@<group>` tree sitter highlights are linked to classic vim highlights, so nothing is really lost here, if a theme doesn't use `@<group>` highlights, but this increases compatibility with modern themes which use `@<group>` highlights.
  • Loading branch information
aMOPel authored Oct 22, 2023
1 parent 87afde2 commit 076239e
Showing 1 changed file with 105 additions and 51 deletions.
156 changes: 105 additions & 51 deletions syntax/nim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -208,54 +208,108 @@ syntax sync match nimSync grouphere NONE "^\%(discard\|let\|var\|const\|type\)"
syntax sync match nimSyncString grouphere nimString "^\%(discard\|asm\)\s\+\"\{3}"
syntax sync match nimSyncString grouphere nimRawString "r\"\{3}"

highlight default link nimKeywordOperator Operator
highlight default link nimStatement Statement
highlight default link nimConditional Conditional
highlight default link nimKeyword Keyword
highlight default link nimException Exception
highlight default link nimRepeat Repeat
highlight default link nimConstant Constant
highlight default link nimPreCondit PreCondit
highlight default link nimInclude Include
highlight default link nimStructure Structure
highlight default link nimPreProcStmt Macro
highlight default link nimComment Comment
highlight default link nimTodo Todo
highlight default link nimLongDocComment Comment
highlight default link nimLongComment Comment
highlight default link nimString String
highlight default link nimEscapeStr SpecialChar
highlight default link nimEscapeChar SpecialChar
highlight default link nimEscapeQuote SpecialChar
highlight default link nimRawString String
highlight default link nimQuote String
highlight default link nimTripleQuote nimQuote
highlight default link nimCharacter Character
highlight default link nimNumber Number
highlight default link nimFloat Float
highlight default link nimCustomNumber Number
highlight default link nimPragma PreProc
" semantic highlighter, straight from the compiler
" TSymKind in compiler/ast.nim, sk prefix replaced with nimSug
highlight default link nimSugUnknown Error
highlight default link nimSugParam Identifier
highlight default link nimSugModule Identifier
highlight default link nimSugType Type
highlight default link nimSugGenericParam Type
highlight default link nimSugVar Identifier
highlight default link nimSugGlobalVar Identifier
highlight default link nimSugLet Identifier
highlight default link nimSugGlobalLet Identifier
highlight default link nimSugConst Constant
highlight default link nimSugResult Special
highlight default link nimSugProc Function
highlight default link nimSugFunc Function
highlight default link nimSugMethod Function
highlight default link nimSugIterator Function
highlight default link nimSugConverter Macro
highlight default link nimSugMacro Macro
highlight default link nimSugTemplate Macro
highlight default link nimSugField Identifier
highlight default link nimSugEnumField Constant
highlight default link nimSugForVar Identifier
highlight default link nimSugLabel Identifier
if has("nvim-0.9.0")
highlight default link nimKeywordOperator @keyword.operator
highlight default link nimStatement @keyword
highlight default link nimConditional @conditional
highlight default link nimKeyword @keyword
highlight default link nimException @exception
highlight default link nimRepeat @repeat
highlight default link nimConstant @constant
highlight default link nimPreCondit @conditional
highlight default link nimInclude @include
highlight default link nimStructure @keyword
highlight default link nimPreProcStmt @function.builtin
highlight default link nimComment @comment
highlight default link nimTodo @text.todo
highlight default link nimLongDocComment @comment.documentation
highlight default link nimLongComment @comment.documentation
highlight default link nimString @string
highlight default link nimEscapeStr @string.escape
highlight default link nimEscapeChar @string.escape
highlight default link nimEscapeQuote @string.escape
highlight default link nimRawString @string
highlight default link nimQuote @string
highlight default link nimTripleQuote nimQuote
highlight default link nimCharacter @character
highlight default link nimNumber @number
highlight default link nimFloat @float
highlight default link nimCustomNumber @number
highlight default link nimPragma @preproc

" semantic highlighter, straight from the compiler
" TSymKind in compiler/ast.nim, sk prefix replaced with nimSug
highlight default link nimSugUnknown @error
highlight default link nimSugParam @parameter
highlight default link nimSugModule @namespace
highlight default link nimSugType @type
highlight default link nimSugGenericParam @parameter
highlight default link nimSugVar @variable
highlight default link nimSugGlobalVar @variable
highlight default link nimSugLet @variable
highlight default link nimSugGlobalLet @variable
highlight default link nimSugConst @constant
highlight default link nimSugResult @variable.builtin
highlight default link nimSugProc @function.call
highlight default link nimSugFunc @function.call
highlight default link nimSugMethod @function.call
highlight default link nimSugIterator @function.call
highlight default link nimSugConverter @function.macro
highlight default link nimSugMacro @function.macro
highlight default link nimSugTemplate @function.macro
highlight default link nimSugField @field
highlight default link nimSugEnumField @constant
highlight default link nimSugForVar @parameter
highlight default link nimSugLabel @label
else
highlight default link nimKeywordOperator Operator
highlight default link nimStatement Statement
highlight default link nimConditional Conditional
highlight default link nimKeyword Keyword
highlight default link nimException Exception
highlight default link nimRepeat Repeat
highlight default link nimConstant Constant
highlight default link nimPreCondit PreCondit
highlight default link nimInclude Include
highlight default link nimStructure Structure
highlight default link nimPreProcStmt Macro
highlight default link nimComment Comment
highlight default link nimTodo Todo
highlight default link nimLongDocComment Comment
highlight default link nimLongComment Comment
highlight default link nimString String
highlight default link nimEscapeStr SpecialChar
highlight default link nimEscapeChar SpecialChar
highlight default link nimEscapeQuote SpecialChar
highlight default link nimRawString String
highlight default link nimQuote String
highlight default link nimTripleQuote nimQuote
highlight default link nimCharacter Character
highlight default link nimNumber Number
highlight default link nimFloat Float
highlight default link nimCustomNumber Number
highlight default link nimPragma PreProc

highlight default link nimSugUnknown Error
highlight default link nimSugParam Identifier
highlight default link nimSugModule Identifier
highlight default link nimSugType Type
highlight default link nimSugGenericParam Type
highlight default link nimSugVar Identifier
highlight default link nimSugGlobalVar Identifier
highlight default link nimSugLet Identifier
highlight default link nimSugGlobalLet Identifier
highlight default link nimSugConst Constant
highlight default link nimSugResult Special
highlight default link nimSugProc Function
highlight default link nimSugFunc Function
highlight default link nimSugMethod Function
highlight default link nimSugIterator Function
highlight default link nimSugConverter Macro
highlight default link nimSugMacro Macro
highlight default link nimSugTemplate Macro
highlight default link nimSugField Identifier
highlight default link nimSugEnumField Constant
highlight default link nimSugForVar Identifier
highlight default link nimSugLabel Identifier
endif

0 comments on commit 076239e

Please sign in to comment.