mirror of https://github.com/ray-x/go.nvim
issue #424; neovim is deprecating non-treesitter based syntax highlighting, so it is this plugin
parent
7a52a370ab
commit
05ba8a9032
@ -0,0 +1,2 @@
|
|||||||
|
(module_path) @namespace
|
||||||
|
(version) @keyword
|
@ -0,0 +1,85 @@
|
|||||||
|
; Copyright: https://github.com/ngalaiko/tree-sitter-go-template
|
||||||
|
; Identifiers
|
||||||
|
|
||||||
|
[
|
||||||
|
(field)
|
||||||
|
(field_identifier)
|
||||||
|
] @property
|
||||||
|
|
||||||
|
(variable) @variable
|
||||||
|
|
||||||
|
; Function calls
|
||||||
|
|
||||||
|
(function_call
|
||||||
|
function: (identifier) @function)
|
||||||
|
|
||||||
|
(method_call
|
||||||
|
method: (selector_expression
|
||||||
|
field: (field_identifier) @method))
|
||||||
|
|
||||||
|
; Operators
|
||||||
|
|
||||||
|
"|" @operator
|
||||||
|
":=" @operator
|
||||||
|
|
||||||
|
; Builtin functions
|
||||||
|
|
||||||
|
((identifier) @function.builtin
|
||||||
|
(#match? @function.builtin "^(and|call|html|index|slice|js|len|not|or|print|printf|println|urlquery|eq|ne|lt|ge|gt|ge)$"))
|
||||||
|
|
||||||
|
; Delimiters
|
||||||
|
|
||||||
|
"." @punctuation.delimiter
|
||||||
|
"," @punctuation.delimiter
|
||||||
|
|
||||||
|
"{{" @punctuation.bracket
|
||||||
|
"}}" @punctuation.bracket
|
||||||
|
"{{-" @punctuation.bracket
|
||||||
|
"-}}" @punctuation.bracket
|
||||||
|
")" @punctuation.bracket
|
||||||
|
"(" @punctuation.bracket
|
||||||
|
|
||||||
|
; Keywords
|
||||||
|
|
||||||
|
[
|
||||||
|
"else"
|
||||||
|
"else if"
|
||||||
|
"if"
|
||||||
|
"with"
|
||||||
|
] @conditional
|
||||||
|
|
||||||
|
[
|
||||||
|
"range"
|
||||||
|
"end"
|
||||||
|
"template"
|
||||||
|
"define"
|
||||||
|
"block"
|
||||||
|
] @keyword
|
||||||
|
|
||||||
|
; Literals
|
||||||
|
|
||||||
|
[
|
||||||
|
(interpreted_string_literal)
|
||||||
|
(raw_string_literal)
|
||||||
|
(rune_literal)
|
||||||
|
] @string
|
||||||
|
|
||||||
|
(escape_sequence) @string.special
|
||||||
|
|
||||||
|
[
|
||||||
|
(int_literal)
|
||||||
|
(float_literal)
|
||||||
|
(imaginary_literal)
|
||||||
|
] @number
|
||||||
|
|
||||||
|
[
|
||||||
|
(true)
|
||||||
|
(false)
|
||||||
|
] @boolean
|
||||||
|
|
||||||
|
[
|
||||||
|
(nil)
|
||||||
|
] @constant.builtin
|
||||||
|
|
||||||
|
(comment) @comment
|
||||||
|
(ERROR) @error
|
@ -0,0 +1,9 @@
|
|||||||
|
(text) @yaml
|
||||||
|
|
||||||
|
((text) @injection.content
|
||||||
|
(#set! injection.language "html")
|
||||||
|
(#set! injection.combined))
|
||||||
|
|
||||||
|
((text) @injection.content
|
||||||
|
(#set! injection.language "javascript")
|
||||||
|
(#set! injection.combined))
|
@ -1,18 +0,0 @@
|
|||||||
" this file is copied from vim-go
|
|
||||||
if exists("b:current_syntax")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
if !exists("g:main_syntax")
|
|
||||||
let g:main_syntax = 'html'
|
|
||||||
endif
|
|
||||||
|
|
||||||
runtime! syntax/gotexttmpl.vim
|
|
||||||
runtime! syntax/html.vim
|
|
||||||
unlet b:current_syntax
|
|
||||||
|
|
||||||
syn cluster htmlPreproc add=gotplAction,goTplComment
|
|
||||||
|
|
||||||
let b:current_syntax = "gohtmltmpl"
|
|
||||||
|
|
||||||
" vim: sw=2 ts=2 et
|
|
@ -1,36 +0,0 @@
|
|||||||
" Copyright 2011 The Go Authors. All rights reserved.
|
|
||||||
" Use of this source code is governed by a BSD-style
|
|
||||||
" license that can be found in the LICENSE file.
|
|
||||||
"
|
|
||||||
" gotexttmpl.vim: Vim syntax file for Go templates.
|
|
||||||
|
|
||||||
" Quit when a (custom) syntax file was already loaded
|
|
||||||
" a modified version of gotexttmpl.vim
|
|
||||||
if exists("b:current_syntax")
|
|
||||||
finish
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
runtime! syntax/go.vim
|
|
||||||
unlet b:current_syntax
|
|
||||||
|
|
||||||
" Token groups
|
|
||||||
syn cluster gotplLiteral contains=goString,goRawString,goCharacter,@goInt,goFloat,goImaginary
|
|
||||||
syn keyword gotplControl contained if else end range with template
|
|
||||||
syn keyword gotplFunctions contained and html index js len not or print printf println urlquery eq ne lt le gt ge
|
|
||||||
syn match gotplVariable contained /\$[a-zA-Z0-9_]*\>/
|
|
||||||
syn match goTplIdentifier contained /\.[^[:blank:]}]\+\>/
|
|
||||||
|
|
||||||
hi def link gotplControl Keyword
|
|
||||||
hi def link gotplFunctions Function
|
|
||||||
hi def link goTplVariable Special
|
|
||||||
|
|
||||||
syn region gotplAction start="{{" end="}}" contains=@gotplLiteral,gotplControl,gotplFunctions,gotplVariable,goTplIdentifier display
|
|
||||||
syn region goTplComment start="{{\(- \)\?/\*" end="\*/\( -\)\?}}" display
|
|
||||||
|
|
||||||
hi def link gotplAction PreProc
|
|
||||||
hi def link goTplComment Comment
|
|
||||||
|
|
||||||
let b:current_syntax = "gotexttmpl"
|
|
||||||
|
|
||||||
" vim: sw=2 ts=2 et
|
|
Loading…
Reference in New Issue