mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-14 07:09:11 +08:00
feat(lang#teal): add lang#teal
layer
This commit is contained in:
parent
bfb5444c34
commit
9713a45048
89
autoload/SpaceVim/layers/lang/teal.vim
Normal file
89
autoload/SpaceVim/layers/lang/teal.vim
Normal file
@ -0,0 +1,89 @@
|
||||
"=============================================================================
|
||||
" teal.vim --- teal language support for SpaceVim
|
||||
" Copyright (c) 2016-2019 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg@outlook.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
""
|
||||
" @section lang#teal, layers-lang-teal
|
||||
" @parentsection layers
|
||||
" This layer is for teal development, disabled by default, to enable this
|
||||
" layer, add following snippet to your SpaceVim configuration file.
|
||||
" >
|
||||
" [[layers]]
|
||||
" name = 'lang#teal'
|
||||
" <
|
||||
"
|
||||
" @subsection layer options
|
||||
"
|
||||
" 1. `teal_interpreter`: Set the teal interpreter, by default, it is `tl`
|
||||
" >
|
||||
" [[layers]]
|
||||
" name = 'lang#teal'
|
||||
" teal_interpreter = 'path/to/tl'
|
||||
" <
|
||||
"
|
||||
" @subsection Key bindings
|
||||
" >
|
||||
" Mode Key Function
|
||||
" ---------------------------------------------
|
||||
" normal SPC l r run current file
|
||||
" <
|
||||
"
|
||||
" This layer also provides REPL support for teal, the key bindings are:
|
||||
" >
|
||||
" Key Function
|
||||
" ---------------------------------------------
|
||||
" SPC l s i Start a inferior REPL process
|
||||
" SPC l s b send whole buffer
|
||||
" SPC l s l send current line
|
||||
" SPC l s s send selection text
|
||||
" <
|
||||
"
|
||||
|
||||
if exists('s:teal_interpreter')
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:teal_interpreter = 'tl'
|
||||
|
||||
function! SpaceVim#layers#lang#teal#plugins() abort
|
||||
let plugins = []
|
||||
call add(plugins, [g:_spacevim_root_dir . 'bundle/vim-teal', {'merged' : 0}])
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#teal#config() abort
|
||||
call SpaceVim#plugins#repl#reg('teal', s:teal_interpreter)
|
||||
call SpaceVim#plugins#runner#reg_runner('teal', s:teal_interpreter . ' run %s')
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('teal', function('s:language_specified_mappings'))
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#teal#set_variable(var) abort
|
||||
let s:teal_interpreter = get(a:var, 'teal_interpreter', s:teal_interpreter)
|
||||
endfunction
|
||||
|
||||
function! s:language_specified_mappings() abort
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','r'], 'call SpaceVim#plugins#runner#open()', 'execute current file', 1)
|
||||
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'],
|
||||
\ 'call SpaceVim#plugins#repl#start("teal")',
|
||||
\ 'start REPL process', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'l'],
|
||||
\ 'call SpaceVim#plugins#repl#send("line")',
|
||||
\ 'send line and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'b'],
|
||||
\ 'call SpaceVim#plugins#repl#send("buffer")',
|
||||
\ 'send buffer and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'],
|
||||
\ 'call SpaceVim#plugins#repl#send("selection")',
|
||||
\ 'send selection and keep code buffer focused', 1)
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#teal#health() abort
|
||||
call SpaceVim#layers#lang#teal#plugins()
|
||||
call SpaceVim#layers#lang#teal#config()
|
||||
return 1
|
||||
endfunction
|
76
bundle/vim-teal/CODE_OF_CONDUCT.md
Normal file
76
bundle/vim-teal/CODE_OF_CONDUCT.md
Normal file
@ -0,0 +1,76 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at hisham@gobolinux.org. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
19
bundle/vim-teal/LICENSE
Normal file
19
bundle/vim-teal/LICENSE
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (C) 2020 Patrick Desaulniers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
32
bundle/vim-teal/README.md
Normal file
32
bundle/vim-teal/README.md
Normal file
@ -0,0 +1,32 @@
|
||||
# vim-teal
|
||||
This plugin provides [Teal](https://github.com/teal-language/tl) language support for Vim.
|
||||
|
||||

|
||||
|
||||
## Features
|
||||
|
||||
- Syntax highlighting
|
||||
- Automatic indentation
|
||||
- Linting (requires [ALE](https://github.com/dense-analysis/ale))
|
||||
- Automatic insertion of `end` tokens (requires [vim-endwise](https://github.com/tpope/vim-endwise))
|
||||
- `:compiler` support
|
||||
|
||||
## Install
|
||||
Using [vim-plug](https://github.com/junegunn/vim-plug):
|
||||
```vim
|
||||
" Teal language support
|
||||
Plug 'teal-language/vim-teal'
|
||||
|
||||
" Optional dependencies; will be loaded on-demand when editing Teal files
|
||||
Plug 'dense-analysis/ale', { 'for': 'teal' }
|
||||
Plug 'tpope/vim-endwise', { 'for': 'teal' }
|
||||
```
|
||||
|
||||
You should also make sure that the Teal compiler [is available in your PATH:](https://github.com/teal-language/tl#installing)
|
||||
```
|
||||
luarocks install tl
|
||||
```
|
||||
|
||||
## Contributors
|
||||
|
||||
Contributions are greatly appreciated! Feel free to fork [this repository](https://github.com/teal-language/vim-teal) and open a pull request on GitHub.
|
39
bundle/vim-teal/ale_linters/teal/tlcheck.vim
Normal file
39
bundle/vim-teal/ale_linters/teal/tlcheck.vim
Normal file
@ -0,0 +1,39 @@
|
||||
" Description: Teal linter based on `tl check`
|
||||
|
||||
" Based on https://github.com/dense-analysis/ale/blob/master/ale_linters/lua/luacheck.vim
|
||||
|
||||
call ale#Set('teal_tlcheck_executable', 'tl')
|
||||
call ale#Set('teal_tlcheck_options', '')
|
||||
|
||||
function! ale_linters#teal#tlcheck#GetCommand(buffer) abort
|
||||
return '%e' . ale#Pad(ale#Var(a:buffer, 'teal_tlcheck_options'))
|
||||
\ . ' check %s'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#teal#tlcheck#Handle(buffer, lines) abort
|
||||
" Matches patterns line the following:
|
||||
"
|
||||
" artal.tl:159:17: shadowing definition of loop variable 'i' on line 106
|
||||
" artal.tl:182:7: unused loop variable 'i'
|
||||
let l:pattern = '^\(.\{-}\):\(\d\+\):\(\d\+\): \(.\+\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'filename': l:match[1],
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'text': l:match[4],
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('teal', {
|
||||
\ 'name': 'tlcheck',
|
||||
\ 'executable': {b -> ale#Var(b, 'teal_tlcheck_executable')},
|
||||
\ 'command': function('ale_linters#teal#tlcheck#GetCommand'),
|
||||
\ 'callback': 'ale_linters#teal#tlcheck#Handle',
|
||||
\ 'output_stream': 'both'
|
||||
\})
|
20
bundle/vim-teal/compiler/tl.vim
Normal file
20
bundle/vim-teal/compiler/tl.vim
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
if exists("current_compiler")
|
||||
finish
|
||||
endif
|
||||
let current_compiler = "tl"
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if exists("g:teal_check_only")
|
||||
CompilerSet makeprg=tl\ -q\ check\ %
|
||||
elseif exists("g:teal_check_before_gen")
|
||||
CompilerSet makeprg=tl\ -q\ check\ %\ &&\ tl\ -q\ gen\ %
|
||||
else
|
||||
CompilerSet makeprg=tl\ -q\ gen\ %
|
||||
endif
|
||||
CompilerSet errorformat=%f:%l:%c:\ %m
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
8
bundle/vim-teal/ftdetect/teal.vim
Normal file
8
bundle/vim-teal/ftdetect/teal.vim
Normal file
@ -0,0 +1,8 @@
|
||||
fun! s:DetectTL()
|
||||
if getline(1) =~# '^#!.*/bin/env\s\+tl\>'
|
||||
setfiletype teal
|
||||
endif
|
||||
endfun
|
||||
|
||||
autocmd BufRead,BufNewFile *.tl setlocal filetype=teal
|
||||
autocmd BufNewFile,BufRead * call s:DetectTL()
|
15
bundle/vim-teal/ftplugin/teal.vim
Normal file
15
bundle/vim-teal/ftplugin/teal.vim
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
let s:cpo_save = &cpo
|
||||
|
||||
setlocal comments=s:--[[,mb:-,ex:]],:--,f:#,:--
|
||||
setlocal commentstring=--%s
|
||||
setlocal suffixesadd=.tl
|
||||
|
||||
let b:undo_ftplugin = "setl com< cms< mp< sua<"
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
131
bundle/vim-teal/indent/teal.vim
Normal file
131
bundle/vim-teal/indent/teal.vim
Normal file
@ -0,0 +1,131 @@
|
||||
" Vim indent file
|
||||
" Language: Teal
|
||||
|
||||
" Adapted from https://github.com/tbastos/vim-lua and the default lua file
|
||||
|
||||
" {{{ setup
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
setlocal autoindent
|
||||
setlocal nosmartindent
|
||||
|
||||
setlocal indentexpr=GetTealIndent(v:lnum)
|
||||
setlocal indentkeys+=0=end,0=until
|
||||
|
||||
if exists("*GetTealIndent")
|
||||
finish
|
||||
endif
|
||||
" }}}
|
||||
" {{{ Patterns
|
||||
|
||||
" [\t ] seems to be faster than \s
|
||||
let s:begin_block_open_patt = '\C^[\t ]*\%(if\|for\|while\|repeat\|else\|elseif\|do\|then\)\>'
|
||||
let s:end_block_open_patt = '\C\%((\|{\|then\|do\)[\t ]*$'
|
||||
let s:block_close_patt = '\C^[\t ]*\%(\%(end\|else\|elseif\|until\)\>\|}\|)\)'
|
||||
|
||||
let s:middle_patt = '\C\<\%(function\|record\|enum\)\>'
|
||||
let s:ignore_patt = 'String$\|Comment$\|Type$'
|
||||
|
||||
let s:starts_with_bin_op = '\C^[\t ]*\([<>=~^&|*/%+-.:]\|\%(or\|and\|is\|as\)\>\)'
|
||||
|
||||
" }}}
|
||||
" {{{ Helpers
|
||||
function s:IsIgnorable(line_num, column)
|
||||
return synIDattr(synID(a:line_num, a:column, 1), 'name') =~# s:ignore_patt
|
||||
\ && !(getline(a:line_num) =~# '^[\t ]*\%(--\)\?\[=*\[')
|
||||
endfunction
|
||||
|
||||
function s:PrevLineOfCode(line_num)
|
||||
let line_num = prevnonblank(a:line_num)
|
||||
while s:IsIgnorable(line_num, 1)
|
||||
let line_num = prevnonblank(line_num - 1)
|
||||
endwhile
|
||||
return line_num
|
||||
endfunction
|
||||
|
||||
" strip comments
|
||||
function s:GetLineContent(line_num)
|
||||
" remove trailing -- ...
|
||||
let content = getline(a:line_num)
|
||||
return substitute(content, '--.*$', '', '')
|
||||
endfunction
|
||||
|
||||
function s:MatchPatt(line_num, line_content, patt, prev_match)
|
||||
if a:prev_match != -1
|
||||
return a:prev_match
|
||||
endif
|
||||
let match_index = match(a:line_content, a:patt)
|
||||
if match_index != -1 &&
|
||||
\ synIDattr(synID(a:line_num, match_index+1, 1), "name") =~# s:ignore_patt
|
||||
let match_index = -1
|
||||
endif
|
||||
return match_index
|
||||
endfunction
|
||||
" }}}
|
||||
" {{{ The Indent function
|
||||
function GetTealIndent(lnum)
|
||||
if s:IsIgnorable(a:lnum, 1)
|
||||
return indent(a:lnum - 1)
|
||||
endif
|
||||
let prev_line_num = s:PrevLineOfCode(a:lnum - 1)
|
||||
if prev_line_num == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let prev_line = s:GetLineContent(prev_line_num)
|
||||
|
||||
let i = 0
|
||||
let match_index = s:MatchPatt(prev_line_num, prev_line, s:begin_block_open_patt, -1)
|
||||
let match_index = s:MatchPatt(prev_line_num, prev_line, s:end_block_open_patt, match_index)
|
||||
let match_index = s:MatchPatt(prev_line_num, prev_line, s:middle_patt, match_index)
|
||||
|
||||
" If the previous line opens a block (and doesnt close it), >>
|
||||
if match_index != -1 && prev_line !~# '\C\<\%(end\|until\)\>'
|
||||
let i += 1
|
||||
endif
|
||||
|
||||
" If the current line closes a block, <<
|
||||
let curr_line = s:GetLineContent(a:lnum)
|
||||
let match_index = s:MatchPatt(a:lnum, curr_line, s:block_close_patt, -1)
|
||||
if match_index != -1
|
||||
let i -= 1
|
||||
endif
|
||||
|
||||
" if line starts with bin op and previous line doesnt, >>
|
||||
let current_starts_with_bin_op = 0
|
||||
let prev_starts_with_bin_op = 0
|
||||
let match_index = s:MatchPatt(a:lnum, curr_line, s:starts_with_bin_op, -1)
|
||||
if match_index != -1
|
||||
let current_starts_with_bin_op = 1
|
||||
endif
|
||||
|
||||
let match_index = s:MatchPatt(prev_line_num, prev_line, s:starts_with_bin_op, -1)
|
||||
if match_index != -1
|
||||
let prev_starts_with_bin_op = 1
|
||||
endif
|
||||
|
||||
if current_starts_with_bin_op && !prev_starts_with_bin_op
|
||||
let i += 1
|
||||
elseif !current_starts_with_bin_op && prev_starts_with_bin_op
|
||||
let i -= 1
|
||||
endif
|
||||
|
||||
if i > 1
|
||||
|
||||
let i = 1
|
||||
" elseif i < -1
|
||||
" let i = -1
|
||||
|
||||
endif
|
||||
return indent(prev_line_num) + (shiftwidth() * i)
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
BIN
bundle/vim-teal/media/fizzbuzz.gif
Normal file
BIN
bundle/vim-teal/media/fizzbuzz.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 111 KiB |
27
bundle/vim-teal/plugin/teal.vim
Normal file
27
bundle/vim-teal/plugin/teal.vim
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
function s:LoadPlugins()
|
||||
if exists("g:loaded_matchit")
|
||||
let b:match_ignorecase = 0
|
||||
let b:match_words=
|
||||
\ '\<\%(do\|enum\|record\|function\|if\)\>:' .
|
||||
\ '\<\%(return\|else\|elseif\)\>:' .
|
||||
\ '\<end\>,' .
|
||||
\ '\<repeat\>:\<until\>'
|
||||
endif
|
||||
if exists("g:loaded_endwise")
|
||||
let b:endwise_addition = 'end'
|
||||
let b:endwise_words = 'function,do,then,enum,record'
|
||||
let b:endwise_pattern = '\zs\<\%(then\|do\)\|\(\%(function\|record\|enum\).*\)\ze\s*$'
|
||||
let b:endwise_syngroups = 'tealFunction,tealDoEnd,tealIfStatement,tealRecord,tealEnum'
|
||||
endif
|
||||
|
||||
if exists("g:colors_name") && g:colors_name == "dracula"
|
||||
hi! link tealTable DraculaFg
|
||||
hi! link tealFunctionArgName DraculaOrangeItalic
|
||||
hi! link tealSelf DraculaPurpleItalic
|
||||
hi! link tealBuiltin DraculaCyan
|
||||
hi! link tealGeneric DraculaOrangeItalic
|
||||
endif
|
||||
endfunction
|
||||
|
||||
autocmd FileType teal call s:LoadPlugins()
|
554
bundle/vim-teal/syntax/teal.vim
Normal file
554
bundle/vim-teal/syntax/teal.vim
Normal file
@ -0,0 +1,554 @@
|
||||
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
if !has("lambda")
|
||||
echoerr "vim-teal: Teal syntax requires lambda support, please update your vim installation"
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
syn case match
|
||||
syn sync fromstart
|
||||
|
||||
syn cluster tealBase contains=
|
||||
\ tealComment,tealLongComment,
|
||||
\ tealConstant,tealNumber,tealString,tealLongString
|
||||
syn cluster tealExpression contains=
|
||||
\ @tealBase,tealParen,tealBuiltin,tealBracket,tealBrace,
|
||||
\ tealOperator,tealFunctionBlock,tealFunctionCall,tealError,
|
||||
\ tealTableConstructor,tealRecordBlock,tealEnumBlock,tealSelf,
|
||||
\ tealVarargs
|
||||
syn cluster tealStatement contains=
|
||||
\ @tealExpression,tealIfThen,tealThenEnd,tealBlock,tealLoop,
|
||||
\ tealRepeatBlock,tealWhileDo,tealForDo,
|
||||
\ tealGoto,tealLabel,tealBreak,tealReturn,
|
||||
\ tealLocal,tealGlobal
|
||||
|
||||
" {{{ ), ], end, etc error
|
||||
syn match tealError "\()\|}\|\]\)"
|
||||
syn match tealError "\<\%(end\|else\|elseif\|until\|in\)\>"
|
||||
syn match tealInvalid /\S\+/ contained
|
||||
" }}}
|
||||
" {{{ Table Constructor
|
||||
syn region tealTableConstructor
|
||||
\ matchgroup=tealTable
|
||||
\ start=/{/ end=/}/
|
||||
\ contains=@tealExpression,tealTableEntryTypeAnnotation
|
||||
syn match tealTableEntryTypeAnnotation /:.\{-}\ze=/ contained
|
||||
\ contains=@tealSingleType
|
||||
" }}}
|
||||
" {{{ Types
|
||||
|
||||
" Programmatically generate type definitions for single types and type lists
|
||||
syn match tealUnion /|/ contained nextgroup=@tealType skipwhite skipempty skipnl
|
||||
syn match tealSingleUnion /|/ contained nextgroup=@tealSingleType skipwhite skipempty skipnl
|
||||
|
||||
syn match tealTypeComma /,/ contained nextgroup=@tealType skipwhite skipempty skipnl
|
||||
syn match tealSingleTypeAnnotation /:/ contained nextgroup=@tealSingleType skipwhite skipempty skipnl
|
||||
syn match tealTypeAnnotation /:/ contained nextgroup=@tealType skipwhite skipempty skipnl
|
||||
syn match tealGeneric /\K\k*/ contained
|
||||
|
||||
" {{{ Patterns
|
||||
let s:typePatterns = {
|
||||
\ 'tealFunctionType': {
|
||||
\ 'synType': 'match',
|
||||
\ 'patt': '\<function\>',
|
||||
\ 'nextgroup': ['tealFunctionGenericType', 'tealFunctionArgsType'],
|
||||
\ },
|
||||
\ 'tealBasicType': {
|
||||
\ 'synType': 'match',
|
||||
\ 'patt': '\K\k*\(\.\K\k*\)*',
|
||||
\ 'nextgroup': ['tealGenericType'],
|
||||
\ },
|
||||
\ 'tealFunctionGenericType': {
|
||||
\ 'synType': 'region',
|
||||
\ 'start': '<',
|
||||
\ 'end': '>',
|
||||
\ 'matchgroup': 'tealParens',
|
||||
\ 'nextgroup': ['tealFunctionArgsType'],
|
||||
\ 'contains': ['tealGeneric'],
|
||||
\ },
|
||||
\ 'tealGenericType': {
|
||||
\ 'synType': 'region',
|
||||
\ 'start': '<',
|
||||
\ 'end': '>',
|
||||
\ 'matchgroup': 'tealParens',
|
||||
\ 'contains': ['tealGeneric'],
|
||||
\ },
|
||||
\ 'tealFunctionArgsType': {
|
||||
\ 'synType': 'region',
|
||||
\ 'start': '(',
|
||||
\ 'end': ')',
|
||||
\ 'matchgroup': 'tealParens',
|
||||
\ 'contains': ['@tealType'],
|
||||
\ 'nextgroup': ['tealTypeAnnotation'],
|
||||
\ 'dontsub': 1,
|
||||
\ },
|
||||
\ 'tealTableType': {
|
||||
\ 'synType': 'region',
|
||||
\ 'start': '{',
|
||||
\ 'end': '}',
|
||||
\ 'matchgroup': 'tealTable',
|
||||
\ 'contains': ['@tealType'],
|
||||
\ },
|
||||
\ }
|
||||
" }}}
|
||||
|
||||
" Add nextgroup=tealUnion,tealTypeComma and
|
||||
" make a second syntax item with nextgroup=tealSingleUnion
|
||||
" the effect of this is that we have @tealType, which is a type list
|
||||
" and @tealSingleType for function arguments
|
||||
" {{{ ToSingleName
|
||||
function s:ToSingleName(str)
|
||||
return substitute(a:str, 'Type', 'SingleType', '')
|
||||
endfunction
|
||||
" }}}
|
||||
" {{{ MakeSyntaxItem
|
||||
function s:MakeSyntaxItem(typeName, props)
|
||||
if exists("a:props.contains")
|
||||
let a:props.contains += ['tealLongComment']
|
||||
endif
|
||||
for single in [v:true, v:false]
|
||||
let tname = a:typeName
|
||||
if single
|
||||
let tname = s:ToSingleName(tname)
|
||||
endif
|
||||
let cmd = 'syntax '
|
||||
let cmd .= a:props.synType
|
||||
let cmd .= ' '
|
||||
let cmd .= tname
|
||||
let cmd .= ' '
|
||||
if a:props.synType == 'region'
|
||||
if exists("a:props.matchgroup")
|
||||
let cmd .= 'matchgroup=' . a:props.matchgroup
|
||||
endif
|
||||
let cmd .= ' start=+' . a:props.start . '+ end=+' . a:props.end
|
||||
else
|
||||
let cmd .= '+' . a:props.patt
|
||||
endif
|
||||
let cmd .= '+ '
|
||||
let cmd .= 'contained '
|
||||
if exists("a:props.contains")
|
||||
let cmd .= 'contains=' . join(a:props.contains, ",") . ' '
|
||||
endif
|
||||
let cmd .= 'nextgroup='
|
||||
if exists("a:props.nextgroup")
|
||||
let nextgroup = copy(a:props.nextgroup)
|
||||
else
|
||||
let nextgroup = []
|
||||
endif
|
||||
call map(nextgroup, {-> (single && v:val =~# "Type" && !exists("a:props.dontsub")) ? s:ToSingleName(v:val) : v:val})
|
||||
if single
|
||||
let nextgroup += ['tealSingleUnion']
|
||||
else
|
||||
let nextgroup += ['tealUnion', 'tealTypeComma']
|
||||
endif
|
||||
let cmd .= join(nextgroup, ',')
|
||||
let cmd .= ' skipwhite skipempty skipnl'
|
||||
exec cmd
|
||||
exec "syn cluster teal" . (single ? "Single" : "") . "Type add=" . tname
|
||||
endfor
|
||||
exec "highlight link " . s:ToSingleName(tname) . " " . tname
|
||||
endfunction
|
||||
" }}}
|
||||
call map(s:typePatterns, {tname, props -> s:MakeSyntaxItem(tname, props)})
|
||||
|
||||
syn cluster tealNewType contains=tealRecordBlock,tealEnumBlock
|
||||
" }}}
|
||||
" {{{ Function call
|
||||
syn match tealFunctionCall /\K\k*\ze\s*\n*\s*\(["'({]\|\[=*\[\)/
|
||||
" }}}
|
||||
" {{{ Operators
|
||||
" Symbols
|
||||
syn match tealOperator "[#<>=~^&|*/%+-]\|\.\."
|
||||
" Words
|
||||
syn keyword tealOperator and or not
|
||||
syn keyword tealOperator is as
|
||||
\ nextgroup=@tealSingleType
|
||||
\ skipempty skipnl skipwhite
|
||||
syn match tealVarargs /\.\.\./
|
||||
" }}}
|
||||
" {{{ Comments
|
||||
syn match tealComment "\%^#!.*$"
|
||||
syn match tealComment /--.*$/ contains=tealTodo,@Spell
|
||||
syn keyword tealTodo contained TODO todo FIXME fixme TBD tbd XXX
|
||||
syn region tealLongComment start=/--\[\z(=*\)\[/ end=/\]\z1\]/
|
||||
" }}}
|
||||
" {{{ local ... <const>, global ... <const>, local type ..., break, return, self
|
||||
syn keyword tealTypeDeclaration type contained
|
||||
\ nextgroup=tealTypeDeclarationName
|
||||
\ skipwhite skipempty skipnl
|
||||
syn match tealTypeDeclarationName /\K\k*/ contained
|
||||
\ nextgroup=tealTypeDeclarationEq,tealInvalid
|
||||
\ skipwhite skipempty skipnl
|
||||
syn match tealTypeDeclarationEq /=/ contained
|
||||
\ nextgroup=@tealSingleType,tealRecordBlock,tealEnumBlock
|
||||
\ skipwhite skipempty skipnl
|
||||
syn region tealAttributeBrackets contained transparent
|
||||
\ matchgroup=tealParens
|
||||
\ start=/</ end=/>/
|
||||
\ contains=tealAttribute
|
||||
\ nextgroup=tealVarComma,tealTypeAnnotation
|
||||
\ skipwhite skipempty skipnl
|
||||
syn match tealAttribute contained /\K\k*/
|
||||
syn match tealVarName contained /\K\k*/
|
||||
\ nextgroup=tealAttributeBrackets,tealVarComma,tealTypeAnnotation
|
||||
\ skipwhite skipempty skipnl
|
||||
syn match tealVarComma /,/ contained
|
||||
\ nextgroup=tealVarName
|
||||
\ skipwhite skipempty skipnl
|
||||
syn keyword tealLocal local
|
||||
\ nextgroup=tealFunctionBlock,tealRecordBlock,tealEnumBlock,tealVarName,tealTypeDeclaration
|
||||
\ skipwhite skipempty skipnl
|
||||
syn keyword tealGlobal global
|
||||
\ nextgroup=tealFunctionBlock,tealRecordBlock,tealEnumBlock,tealVarName,tealTypeDeclaration
|
||||
\ skipwhite skipempty skipnl
|
||||
syn keyword tealBreak break
|
||||
syn keyword tealReturn return
|
||||
syn keyword tealSelf self
|
||||
" }}}
|
||||
" {{{ Parens
|
||||
syn region tealParen transparent
|
||||
\ matchgroup=tealParens
|
||||
\ start=/(/ end=/)/
|
||||
\ contains=@tealExpression
|
||||
syn region tealBracket transparent
|
||||
\ matchgroup=tealBrackets
|
||||
\ start=/\[/ end=/\]/
|
||||
\ contains=@tealExpression
|
||||
" }}}
|
||||
" {{{ function ... end
|
||||
syn region tealFunctionBlock transparent
|
||||
\ matchgroup=tealFunction
|
||||
\ start=/\<function\>/ end=/\<end\>/
|
||||
\ contains=@tealStatement,tealFunctionStart
|
||||
syn match tealFunctionStart /\(\<function\>\)\@8<=\s*/ contained
|
||||
\ nextgroup=tealFunctionName,tealFunctionGeneric,tealFunctionArgs
|
||||
\ skipwhite skipempty skipnl
|
||||
syn match tealFunctionName /\K\k*\(\.\K\k*\)*\(:\K\k*\)\?/ contained
|
||||
\ nextgroup=tealFunctionGeneric,tealFunctionArgs,tealInvalid
|
||||
\ skipwhite skipempty skipnl
|
||||
syn region tealFunctionGeneric contained transparent
|
||||
\ start=/</ end=/>/
|
||||
\ contains=tealGeneric
|
||||
\ nextgroup=tealFunctionArgs
|
||||
\ skipwhite skipempty skipnl
|
||||
syn region tealFunctionArgs contained transparent
|
||||
\ matchgroup=tealParens
|
||||
\ start=/(/ end=/)/
|
||||
\ contains=tealFunctionArgName,tealFunctionArgComma,tealSingleTypeAnnotation
|
||||
\ nextgroup=tealTypeAnnotation
|
||||
\ skipwhite skipempty skipnl
|
||||
syn match tealFunctionArgName contained /\K\k*/
|
||||
\ nextgroup=tealSingleTypeAnnotation,tealFunctionArgComma,tealInvalid
|
||||
\ skipwhite skipempty skipnl
|
||||
syn match tealFunctionArgComma contained /,/
|
||||
\ nextgroup=tealFunctionArgName
|
||||
\ skipwhite skipempty skipnl
|
||||
" }}}
|
||||
" {{{ record ... end
|
||||
syn match tealRecordType /\K\k*/ contained
|
||||
\ nextgroup=tealRecordAssign,tealInvalid
|
||||
\ skipwhite skipnl skipempty
|
||||
syn match tealRecordEntry /\K\k*/ contained
|
||||
\ nextgroup=tealSingleTypeAnnotation,tealInvalid
|
||||
\ skipwhite skipnl skipempty
|
||||
syn match tealRecordEntry /\[.*\]/ contained
|
||||
\ nextgroup=tealSingleTypeAnnotation,tealInvalid
|
||||
\ contains=tealString,tealLongString
|
||||
\ skipwhite skipnl skipempty
|
||||
\ transparent
|
||||
syn cluster tealRecordItem contains=tealRecordEntry
|
||||
syn region tealRecordBlock contained
|
||||
\ matchgroup=tealRecord transparent
|
||||
\ start=/\<record\>/ end=/\<end\>/
|
||||
\ contains=tealRecordKeywordName,tealRecordStart,@tealRecordItem,tealTableType,tealComment,tealLongComment
|
||||
syn cluster tealRecordItem add=tealRecordBlock,tealEnumBlock
|
||||
syn match tealRecordStart /\(\<record\>\)\@6<=\s*/ contained
|
||||
\ nextgroup=tealRecordName,tealRecordGeneric
|
||||
\ skipwhite skipnl skipempty
|
||||
syn match tealRecordName /\K\k*/ contained
|
||||
\ nextgroup=tealRecordGeneric
|
||||
\ skipwhite skipnl skipempty
|
||||
syn region tealRecordGeneric contained transparent
|
||||
\ matchgroup=tealParens
|
||||
\ start=/</ end=/>/
|
||||
\ contains=tealGeneric
|
||||
syn keyword tealRecordUserdata userdata contained
|
||||
\ nextgroup=@tealRecordItem
|
||||
\ skipwhite skipnl skipempty
|
||||
syn match tealRecordTypeDeclaration /type\s*\K\k*\s*=/ contained
|
||||
\ contains=tealRecordTypeKeyword,tealOperator
|
||||
\ nextgroup=@tealSingleType,@tealNewType,tealInvalid
|
||||
\ skipwhite skipnl skipempty
|
||||
syn keyword tealRecordMetamethodKeyword metamethod contained
|
||||
syn match tealRecordMetamethod /metamethod\s\+\K\k*/ contained
|
||||
\ contains=tealRecordMetamethodKeyword
|
||||
\ nextgroup=tealSingleTypeAnnotation
|
||||
\ skipwhite skipnl skipempty
|
||||
|
||||
syn keyword tealRecordTypeKeyword type contained
|
||||
syn cluster tealRecordItem
|
||||
\ add=tealRecordTypeDeclaration,tealRecordUserdata,tealRecordMetamethod
|
||||
" }}}
|
||||
" {{{ enum ... end
|
||||
syn match tealEnumStart /\(\<enum\>\)\@4<=\s*/ contained
|
||||
\ nextgroup=tealEnumName
|
||||
\ skipwhite skipnl skipempty
|
||||
syn match tealEnumName /\K\k*/ contained
|
||||
syn region tealEnumBlock
|
||||
\ matchgroup=tealEnum transparent
|
||||
\ start="\<enum\>" end="\<end\>"
|
||||
\ contains=tealEnumStart,tealString,tealLongString,tealComment,tealLongComment,tealInvalid
|
||||
" }}}
|
||||
" {{{ record entries with names 'enum' and 'record'
|
||||
syn match tealRecordKeywordName /\(enum\|record\)\s*\ze:/ contained
|
||||
\ contains=tealRecordItem
|
||||
\ nextgroup=tealSingleTypeAnnotation,tealInvalid
|
||||
\ skipwhite skipnl skipempty
|
||||
" }}}
|
||||
" {{{ if ... then, elseif ... then, then ... end, else
|
||||
syn keyword tealError then
|
||||
syn region tealIfThen
|
||||
\ transparent matchgroup=tealIfStatement
|
||||
\ start=/\<if\>/ end=/\<then\>/me=e-4
|
||||
\ contains=@tealExpression
|
||||
\ nextgroup=tealThenEnd
|
||||
\ skipwhite skipnl skipempty
|
||||
syn region tealElseifThen contained
|
||||
\ transparent matchgroup=tealIfStatement
|
||||
\ start=/\<elseif\>/ end=/\<then\>/
|
||||
\ contains=@tealExpression
|
||||
syn region tealThenEnd
|
||||
\ transparent matchgroup=tealIfStatement
|
||||
\ start=/\<then\>/ end=/\<end\>/
|
||||
\ contains=tealElseifThen,tealElse,@tealStatement
|
||||
syn keyword tealElse else contained containedin=tealThenEnd
|
||||
" }}}
|
||||
" {{{ for ... do ... end, in
|
||||
syn region tealForDo
|
||||
\ matchgroup=tealFor transparent
|
||||
\ contains=tealIn,@tealExpression
|
||||
\ start=/\<for\>/ end=/\<do\>/me=e-2
|
||||
syn keyword tealIn in contained
|
||||
" }}}
|
||||
" {{{ while ... do ... end
|
||||
syn region tealWhileDo
|
||||
\ matchgroup=tealWhile transparent
|
||||
\ contains=@tealExpression
|
||||
\ start=/\<while\>/ end=/\<do\>/me=e-2
|
||||
" }}}
|
||||
" {{{ do ... end
|
||||
syn region tealBlock
|
||||
\ matchgroup=tealDoEnd transparent
|
||||
\ contains=@tealStatement
|
||||
\ start=/\<do\>/ end=/\<end\>/
|
||||
" }}}
|
||||
" {{{ repeat ... until
|
||||
syn region tealRepeatBlock
|
||||
\ matchgroup=tealRepeatUntil transparent
|
||||
\ contains=@tealStatement
|
||||
\ start=/\<repeat\>/ end=/\<until\>/
|
||||
" }}}
|
||||
" {{{ Goto
|
||||
syn keyword tealGoto goto
|
||||
syn match tealLabel /::\K\k*::/
|
||||
" }}}
|
||||
" {{{ true, false, nil, etc...
|
||||
syn keyword tealConstant nil true false
|
||||
" }}}
|
||||
" {{{ Strings
|
||||
syn match tealSpecial contained #\\[\\abfnrtvz'"]\|\\x[[:xdigit:]]\{2}\|\\[[:digit:]]\{,3}#
|
||||
syn region tealLongString matchgroup=tealString start="\[\z(=*\)\[" end="\]\z1\]" contains=@Spell
|
||||
syn region tealString start=+'+ end=+'\|$+ skip=+\\\\\|\\'+ contains=tealSpecial,@Spell
|
||||
syn region tealString start=+"+ end=+"\|$+ skip=+\\\\\|\\"+ contains=tealSpecial,@Spell
|
||||
" }}}
|
||||
" {{{ Numbers
|
||||
" integer number
|
||||
syn match tealNumber "\<\d\+\>"
|
||||
" floating point number, with dot, optional exponent
|
||||
syn match tealNumber "\<\d\+\.\d*\%([eE][-+]\=\d\+\)\=\>"
|
||||
" floating point number, starting with a dot, optional exponent
|
||||
syn match tealNumber "\.\d\+\%([eE][-+]\=\d\+\)\=\>"
|
||||
" floating point number, without dot, with exponent
|
||||
syn match tealNumber "\<\d\+[eE][-+]\=\d\+\>"
|
||||
" hex numbers
|
||||
syn match tealNumber "\<0[xX][[:xdigit:].]\+\%([pP][-+]\=\d\+\)\=\>"
|
||||
" }}}
|
||||
" {{{ Built ins
|
||||
|
||||
syn keyword tealBuiltIn assert error collectgarbage
|
||||
\ print tonumber tostring type
|
||||
\ getmetatable setmetatable
|
||||
\ ipairs pairs next
|
||||
\ pcall xpcall
|
||||
\ _G _ENV _VERSION require
|
||||
\ rawequal rawget rawset rawlen
|
||||
\ loadfile load dofile select
|
||||
syn match tealBuiltIn /\<package\.cpath\>/
|
||||
syn match tealBuiltIn /\<package\.loaded\>/
|
||||
syn match tealBuiltIn /\<package\.loadlib\>/
|
||||
syn match tealBuiltIn /\<package\.path\>/
|
||||
syn match tealBuiltIn /\<coroutine\.running\>/
|
||||
syn match tealBuiltIn /\<coroutine\.create\>/
|
||||
syn match tealBuiltIn /\<coroutine\.resume\>/
|
||||
syn match tealBuiltIn /\<coroutine\.status\>/
|
||||
syn match tealBuiltIn /\<coroutine\.wrap\>/
|
||||
syn match tealBuiltIn /\<coroutine\.yield\>/
|
||||
syn match tealBuiltIn /\<string\.byte\>/
|
||||
syn match tealBuiltIn /\<string\.char\>/
|
||||
syn match tealBuiltIn /\<string\.dump\>/
|
||||
syn match tealBuiltIn /\<string\.find\>/
|
||||
syn match tealBuiltIn /\<string\.format\>/
|
||||
syn match tealBuiltIn /\<string\.gsub\>/
|
||||
syn match tealBuiltIn /\<string\.len\>/
|
||||
syn match tealBuiltIn /\<string\.lower\>/
|
||||
syn match tealBuiltIn /\<string\.rep\>/
|
||||
syn match tealBuiltIn /\<string\.sub\>/
|
||||
syn match tealBuiltIn /\<string\.upper\>/
|
||||
syn match tealBuiltIn /\<string\.gmatch\>/
|
||||
syn match tealBuiltIn /\<string\.match\>/
|
||||
syn match tealBuiltIn /\<string\.reverse\>/
|
||||
syn match tealBuiltIn /\<table\.pack\>/
|
||||
syn match tealBuiltIn /\<table\.unpack\>/
|
||||
syn match tealBuiltIn /\<table\.concat\>/
|
||||
syn match tealBuiltIn /\<table\.sort\>/
|
||||
syn match tealBuiltIn /\<table\.insert\>/
|
||||
syn match tealBuiltIn /\<table\.remove\>/
|
||||
syn match tealBuiltIn /\<math\.abs\>/
|
||||
syn match tealBuiltIn /\<math\.acos\>/
|
||||
syn match tealBuiltIn /\<math\.asin\>/
|
||||
syn match tealBuiltIn /\<math\.atan\>/
|
||||
syn match tealBuiltIn /\<math\.atan2\>/
|
||||
syn match tealBuiltIn /\<math\.ceil\>/
|
||||
syn match tealBuiltIn /\<math\.sin\>/
|
||||
syn match tealBuiltIn /\<math\.cos\>/
|
||||
syn match tealBuiltIn /\<math\.tan\>/
|
||||
syn match tealBuiltIn /\<math\.deg\>/
|
||||
syn match tealBuiltIn /\<math\.exp\>/
|
||||
syn match tealBuiltIn /\<math\.floor\>/
|
||||
syn match tealBuiltIn /\<math\.log\>/
|
||||
syn match tealBuiltIn /\<math\.max\>/
|
||||
syn match tealBuiltIn /\<math\.min\>/
|
||||
syn match tealBuiltIn /\<math\.huge\>/
|
||||
syn match tealBuiltIn /\<math\.fmod\>/
|
||||
syn match tealBuiltIn /\<math\.modf\>/
|
||||
syn match tealBuiltIn /\<math\.ult\>/
|
||||
syn match tealBuiltIn /\<math\.tointeger\>/
|
||||
syn match tealBuiltIn /\<math\.maxinteger\>/
|
||||
syn match tealBuiltIn /\<math\.mininteger\>/
|
||||
syn match tealBuiltIn /\<math\.pow\>/
|
||||
syn match tealBuiltIn /\<math\.rad\>/
|
||||
syn match tealBuiltIn /\<math\.sqrt\>/
|
||||
syn match tealBuiltIn /\<math\.random\>/
|
||||
syn match tealBuiltIn /\<math\.randomseed\>/
|
||||
syn match tealBuiltIn /\<math\.pi\>/
|
||||
syn match tealBuiltIn /\<io\.close\>/
|
||||
syn match tealBuiltIn /\<io\.flush\>/
|
||||
syn match tealBuiltIn /\<io\.input\>/
|
||||
syn match tealBuiltIn /\<io\.lines\>/
|
||||
syn match tealBuiltIn /\<io\.open\>/
|
||||
syn match tealBuiltIn /\<io\.output\>/
|
||||
syn match tealBuiltIn /\<io\.popen\>/
|
||||
syn match tealBuiltIn /\<io\.read\>/
|
||||
syn match tealBuiltIn /\<io\.stderr\>/
|
||||
syn match tealBuiltIn /\<io\.stdin\>/
|
||||
syn match tealBuiltIn /\<io\.stdout\>/
|
||||
syn match tealBuiltIn /\<io\.tmpfile\>/
|
||||
syn match tealBuiltIn /\<io\.type\>/
|
||||
syn match tealBuiltIn /\<io\.write\>/
|
||||
syn match tealBuiltIn /\<os\.clock\>/
|
||||
syn match tealBuiltIn /\<os\.date\>/
|
||||
syn match tealBuiltIn /\<os\.difftime\>/
|
||||
syn match tealBuiltIn /\<os\.execute\>/
|
||||
syn match tealBuiltIn /\<os\.exit\>/
|
||||
syn match tealBuiltIn /\<os\.getenv\>/
|
||||
syn match tealBuiltIn /\<os\.remove\>/
|
||||
syn match tealBuiltIn /\<os\.rename\>/
|
||||
syn match tealBuiltIn /\<os\.setlocale\>/
|
||||
syn match tealBuiltIn /\<os\.time\>/
|
||||
syn match tealBuiltIn /\<os\.tmpname\>/
|
||||
syn match tealBuiltIn /\<debug\.debug\>/
|
||||
syn match tealBuiltIn /\<debug\.gethook\>/
|
||||
syn match tealBuiltIn /\<debug\.getinfo\>/
|
||||
syn match tealBuiltIn /\<debug\.getlocal\>/
|
||||
syn match tealBuiltIn /\<debug\.getupvalue\>/
|
||||
syn match tealBuiltIn /\<debug\.setlocal\>/
|
||||
syn match tealBuiltIn /\<debug\.setupvalue\>/
|
||||
syn match tealBuiltIn /\<debug\.sethook\>/
|
||||
syn match tealBuiltIn /\<debug\.traceback\>/
|
||||
syn match tealBuiltIn /\<debug\.getmetatable\>/
|
||||
syn match tealBuiltIn /\<debug\.setmetatable\>/
|
||||
syn match tealBuiltIn /\<debug\.getregistry\>/
|
||||
syn match tealBuiltIn /\<debug\.getuservalue\>/
|
||||
syn match tealBuiltIn /\<debug\.setuservalue\>/
|
||||
syn match tealBuiltIn /\<debug\.upvalueid\>/
|
||||
syn match tealBuiltIn /\<debug\.upvaluejoin\>/
|
||||
syn match tealBuiltIn /\<utf8\.char\>/
|
||||
syn match tealBuiltIn /\<utf8\.charpattern\>/
|
||||
syn match tealBuiltIn /\<utf8\.codepoint\>/
|
||||
syn match tealBuiltIn /\<utf8\.codes\>/
|
||||
syn match tealBuiltIn /\<utf8\.len\>/
|
||||
syn match tealBuiltIn /\<utf8\.offset\>/
|
||||
|
||||
" }}}
|
||||
" {{{ Highlight
|
||||
hi def link tealTypeDeclaration StorageClass
|
||||
hi def link tealKeyword Keyword
|
||||
hi def link tealFunction Keyword
|
||||
hi def link tealFunctionName Function
|
||||
hi def link tealFunctionArgName Identifier
|
||||
hi def link tealLocal Keyword
|
||||
hi def link tealGlobal Keyword
|
||||
hi def link tealBreak Keyword
|
||||
hi def link tealReturn Keyword
|
||||
hi def link tealIn Keyword
|
||||
hi def link tealSelf Special
|
||||
hi def link tealTable Structure
|
||||
hi def link tealBasicType Type
|
||||
hi def link tealFunctionType Type
|
||||
hi def link tealAttribute StorageClass
|
||||
hi def link tealParens Normal
|
||||
hi def link tealRecord Keyword
|
||||
hi def link tealEnum Keyword
|
||||
hi def link tealIfStatement Conditional
|
||||
hi def link tealElse Conditional
|
||||
hi def link tealFor Repeat
|
||||
hi def link tealWhile Repeat
|
||||
hi def link tealDoEnd Keyword
|
||||
hi def link tealRepeatUntil Repeat
|
||||
hi def link tealFunctionCall Function
|
||||
hi def link tealGoto Keyword
|
||||
hi def link tealLabel Label
|
||||
hi def link tealString String
|
||||
hi def link tealLongString String
|
||||
hi def link tealSpecial Special
|
||||
hi def link tealComment Comment
|
||||
hi def link tealLongComment Comment
|
||||
hi def link tealConstant Constant
|
||||
hi def link tealNumber Number
|
||||
hi def link tealOperator Operator
|
||||
hi def link tealBuiltin Identifier
|
||||
hi def link tealError Error
|
||||
hi def link tealInvalid Error
|
||||
hi def link tealGeneric Type
|
||||
hi def link tealTodo Todo
|
||||
hi def link tealRecordName tealBasicType
|
||||
hi def link tealRecordType tealBasicType
|
||||
hi def link tealRecordTypeKeyword tealKeyword
|
||||
hi def link tealRecordAssign tealOperator
|
||||
hi def link tealEnumName tealBasicType
|
||||
hi def link tealTypeDeclarationEq tealOperator
|
||||
hi def link tealTypeDeclarationName tealBasicType
|
||||
hi def link tealRecordUserdata Keyword
|
||||
hi def link tealRecordMetamethodKeyword Keyword
|
||||
" }}}
|
||||
|
||||
let b:current_syntax = "teal"
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
16
bundle/vim-teal/test/test.tl
Normal file
16
bundle/vim-teal/test/test.tl
Normal file
@ -0,0 +1,16 @@
|
||||
local x = 123
|
||||
|
||||
local Point = record
|
||||
x: number
|
||||
y: number
|
||||
end
|
||||
|
||||
local function myfunc(a: any, b: number, c: Point): number
|
||||
print(a)
|
||||
|
||||
if x then
|
||||
prnit("Hello, I am an error")
|
||||
end
|
||||
|
||||
return 42
|
||||
end
|
@ -199,33 +199,34 @@ CONTENTS *SpaceVim-contents*
|
||||
104. lang#swig..............................|SpaceVim-layers-lang-swift|
|
||||
105. lang#swig...............................|SpaceVim-layers-lang-swig|
|
||||
106. lang#tcl.................................|SpaceVim-layers-lang-tcl|
|
||||
107. lang#toml...............................|SpaceVim-layers-lang-toml|
|
||||
108. lang#typescript...................|SpaceVim-layers-lang-typescript|
|
||||
109. lang#v.....................................|SpaceVim-layers-lang-v|
|
||||
110. lang#vala...............................|SpaceVim-layers-lang-vala|
|
||||
111. lang#vbnet.............................|SpaceVim-layers-lang-vbnet|
|
||||
112. lang#verilog.........................|SpaceVim-layers-lang-verilog|
|
||||
113. lang#vim.................................|SpaceVim-layers-lang-vim|
|
||||
114. lang#vue.................................|SpaceVim-layers-lang-vue|
|
||||
115. lang#wdl.................................|SpaceVim-layers-lang-wdl|
|
||||
116. lang#wolfram.........................|SpaceVim-layers-lang-wolfram|
|
||||
117. lang#xml.................................|SpaceVim-layers-lang-xml|
|
||||
118. lang#xquery...........................|SpaceVim-layers-lang-xquery|
|
||||
119. lang#zig.................................|SpaceVim-layers-lang-zig|
|
||||
120. language server protocol......................|SpaceVim-layers-lsp|
|
||||
121. leaderf...................................|SpaceVim-layers-leaderf|
|
||||
122. mail.........................................|SpaceVim-layers-mail|
|
||||
123. operator.................................|SpaceVim-layers-operator|
|
||||
124. shell.......................................|SpaceVim-layers-shell|
|
||||
125. ssh...........................................|SpaceVim-layers-ssh|
|
||||
126. test.........................................|SpaceVim-layers-test|
|
||||
127. tmux.........................................|SpaceVim-layers-tmux|
|
||||
128. tools#dash.............................|SpaceVim-layers-tools-dash|
|
||||
129. tools#mpv...............................|SpaceVim-layers-tools-mpv|
|
||||
130. tools#zeal.............................|SpaceVim-layers-tools-zeal|
|
||||
131. treesitter.............................|SpaceVim-layers-treesitter|
|
||||
132. ui.............................................|SpaceVim-layers-ui|
|
||||
133. unite.......................................|SpaceVim-layers-unite|
|
||||
107. lang#teal...............................|SpaceVim-layers-lang-teal|
|
||||
108. lang#toml...............................|SpaceVim-layers-lang-toml|
|
||||
109. lang#typescript...................|SpaceVim-layers-lang-typescript|
|
||||
110. lang#v.....................................|SpaceVim-layers-lang-v|
|
||||
111. lang#vala...............................|SpaceVim-layers-lang-vala|
|
||||
112. lang#vbnet.............................|SpaceVim-layers-lang-vbnet|
|
||||
113. lang#verilog.........................|SpaceVim-layers-lang-verilog|
|
||||
114. lang#vim.................................|SpaceVim-layers-lang-vim|
|
||||
115. lang#vue.................................|SpaceVim-layers-lang-vue|
|
||||
116. lang#wdl.................................|SpaceVim-layers-lang-wdl|
|
||||
117. lang#wolfram.........................|SpaceVim-layers-lang-wolfram|
|
||||
118. lang#xml.................................|SpaceVim-layers-lang-xml|
|
||||
119. lang#xquery...........................|SpaceVim-layers-lang-xquery|
|
||||
120. lang#zig.................................|SpaceVim-layers-lang-zig|
|
||||
121. language server protocol......................|SpaceVim-layers-lsp|
|
||||
122. leaderf...................................|SpaceVim-layers-leaderf|
|
||||
123. mail.........................................|SpaceVim-layers-mail|
|
||||
124. operator.................................|SpaceVim-layers-operator|
|
||||
125. shell.......................................|SpaceVim-layers-shell|
|
||||
126. ssh...........................................|SpaceVim-layers-ssh|
|
||||
127. test.........................................|SpaceVim-layers-test|
|
||||
128. tmux.........................................|SpaceVim-layers-tmux|
|
||||
129. tools#dash.............................|SpaceVim-layers-tools-dash|
|
||||
130. tools#mpv...............................|SpaceVim-layers-tools-mpv|
|
||||
131. tools#zeal.............................|SpaceVim-layers-tools-zeal|
|
||||
132. treesitter.............................|SpaceVim-layers-treesitter|
|
||||
133. ui.............................................|SpaceVim-layers-ui|
|
||||
134. unite.......................................|SpaceVim-layers-unite|
|
||||
7. Usage....................................................|SpaceVim-usage|
|
||||
1. alternate file........................|SpaceVim-usage-alternate-file|
|
||||
2. buffers-and-files..................|SpaceVim-usage-buffers-and-files|
|
||||
@ -4849,6 +4850,45 @@ This layer also provides REPL support for tcl, the key bindings are:
|
||||
<
|
||||
|
||||
|
||||
==============================================================================
|
||||
LANG#TEAL *SpaceVim-layers-lang-teal*
|
||||
|
||||
This layer is for teal development, disabled by default, to enable this layer,
|
||||
add following snippet to your SpaceVim configuration file.
|
||||
>
|
||||
[[layers]]
|
||||
name = 'lang#teal'
|
||||
<
|
||||
|
||||
LAYER OPTIONS
|
||||
|
||||
1. `teal_interpreter`: Set the teal interpreter, by default, it is `tl`
|
||||
|
||||
>
|
||||
[[layers]]
|
||||
name = 'lang#teal'
|
||||
teal_interpreter = 'path/to/tl'
|
||||
<
|
||||
|
||||
KEY BINDINGS
|
||||
|
||||
>
|
||||
Mode Key Function
|
||||
---------------------------------------------
|
||||
normal SPC l r run current file
|
||||
<
|
||||
|
||||
This layer also provides REPL support for teal, the key bindings are:
|
||||
>
|
||||
Key Function
|
||||
---------------------------------------------
|
||||
SPC l s i Start a inferior REPL process
|
||||
SPC l s b send whole buffer
|
||||
SPC l s l send current line
|
||||
SPC l s s send selection text
|
||||
<
|
||||
|
||||
|
||||
==============================================================================
|
||||
LANG#TOML *SpaceVim-layers-lang-toml*
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user