Skip to content

Commit

Permalink
Put syntax file back based on comments of #424
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-x committed Mar 3, 2024
1 parent 543b4b9 commit 43850d0
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
18 changes: 18 additions & 0 deletions syntax/gohtmltmpl.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
" 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
36 changes: 36 additions & 0 deletions syntax/gotexttmpl.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
" 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

0 comments on commit 43850d0

Please sign in to comment.