Skip to content

Commit

Permalink
General improvements and additions (#1)
Browse files Browse the repository at this point in the history
* Don't hightlight end in the middle of a word

* Highlight operators

* highlight periods

* Highlight function parentheses

- Also combined operators and used correct highlight colors

* Highlight braces

* Prepend #@ to newlines if previous line had it

* Highlight yttStatement in pink

- Also fixes end highlighting

* fix based on vint
  • Loading branch information
martyspiewak authored Feb 18, 2020
1 parent 4c68266 commit 14b3283
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions autoload/ytt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
let s:save_cpo = &cpo
set cpo&vim

function! YttEnter()
if getline('.') =~# '^#@.*$'
return "\<Esc>o#@ "
else
return "\<CR>"
endif
endfunction

function! ytt#enable()
if exists(':ALEDisable') != 0
:ALEDisable
Expand All @@ -20,19 +28,28 @@ function! ytt#enable()

syn match yttConditional "if/end" contains=starlarkConditional contained
syn match yttRepeat "for/end" contains=starlarkRepeat contained
syn match yttEnd "end" contained
syn match yttEnd "\<end\>" contained
syn match yttSpecial "#@" contained
syn match yttOperator "[+|=|!|:|\.]" contained
syn match yttFunction "[A-Za-z_]*(" contained
syn match yttFunction "[)|,]" contained
syn match yttBlock "[{|}]" contained

hi def link yttConditional Conditional
hi def link yttRepeat Repeat
hi def link yttEnd Statement
hi def link yttSpecial Special
hi def link yttOperator Operator
hi def link yttFunction Function
hi def link yttBlock Operator

syn region yttStatement start="#@" end="$"
\ contains=starlarkStatement,starlarkConditional,starlarkRepeat,starlarkOperator,starlarkType,starlarkBuitin,starlarkInclude,starlarkBlock,starlarkParen,starlarkString,,yttSpecial,yttConditional,yttRepeat,yttEnd
hi def link yttStatement Comment
\ contains=starlarkStatement,starlarkConditional,starlarkRepeat,starlarkOperator,starlarkType,starlarkBuitin,starlarkInclude,starlarkBlock,starlarkParen,starlarkString,,yttSpecial,yttConditional,yttRepeat,yttEnd,yttOperator,yttFunction,yttBlock
highlight yttStatement guifg=Pink

syn sync minlines=500

imap <expr> <CR> YttEnter()
endfunction

function! ytt#disable()
Expand Down

0 comments on commit 14b3283

Please sign in to comment.