mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
runtime(typst): Add typst runtime files
closes: #15234 Signed-off-by: Gregory Anders <greg@gpanders.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
490c1daa24
commit
1cc4cae961
6
.github/MAINTAINERS
vendored
6
.github/MAINTAINERS
vendored
@ -18,6 +18,7 @@ runtime/autoload/modula2.vim @dkearns
|
|||||||
runtime/autoload/php.vim @david-szabo97
|
runtime/autoload/php.vim @david-szabo97
|
||||||
runtime/autoload/rubycomplete.vim @segfault @dkearns
|
runtime/autoload/rubycomplete.vim @segfault @dkearns
|
||||||
runtime/autoload/rust.vim @lilyball
|
runtime/autoload/rust.vim @lilyball
|
||||||
|
runtime/autoload/typst.vim @gpanders
|
||||||
runtime/autoload/xmlformat.vim @chrisbra
|
runtime/autoload/xmlformat.vim @chrisbra
|
||||||
runtime/autoload/dist/json.vim @habamax
|
runtime/autoload/dist/json.vim @habamax
|
||||||
runtime/colors/blue.vim @habamax @romainl @neutaaaaan
|
runtime/colors/blue.vim @habamax @romainl @neutaaaaan
|
||||||
@ -100,6 +101,7 @@ runtime/compiler/tidy.vim @dkearns
|
|||||||
runtime/compiler/ts-node.vim @dkearns
|
runtime/compiler/ts-node.vim @dkearns
|
||||||
runtime/compiler/tsc.vim @dkearns
|
runtime/compiler/tsc.vim @dkearns
|
||||||
runtime/compiler/typedoc.vim @dkearns
|
runtime/compiler/typedoc.vim @dkearns
|
||||||
|
runtime/compiler/typst.vim @gpanders
|
||||||
runtime/compiler/xmllint.vim @dkearns
|
runtime/compiler/xmllint.vim @dkearns
|
||||||
runtime/compiler/xo.vim @dkearns
|
runtime/compiler/xo.vim @dkearns
|
||||||
runtime/compiler/yamllint.vim @romainl
|
runtime/compiler/yamllint.vim @romainl
|
||||||
@ -262,7 +264,7 @@ runtime/ftplugin/toml.vim @averms
|
|||||||
runtime/ftplugin/tt2html.vim @petdance
|
runtime/ftplugin/tt2html.vim @petdance
|
||||||
runtime/ftplugin/typescript.vim @dkearns
|
runtime/ftplugin/typescript.vim @dkearns
|
||||||
runtime/ftplugin/typescriptreact.vim @dkearns
|
runtime/ftplugin/typescriptreact.vim @dkearns
|
||||||
runtime/ftplugin/typst.vim @ribru17
|
runtime/ftplugin/typst.vim @gpanders
|
||||||
runtime/ftplugin/unison.vim @chuwy
|
runtime/ftplugin/unison.vim @chuwy
|
||||||
runtime/ftplugin/v.vim @ribru17
|
runtime/ftplugin/v.vim @ribru17
|
||||||
runtime/ftplugin/vdf.vim @ObserverOfTime
|
runtime/ftplugin/vdf.vim @ObserverOfTime
|
||||||
@ -350,6 +352,7 @@ runtime/indent/tcl.vim @dkearns
|
|||||||
runtime/indent/tcsh.vim @dkearns
|
runtime/indent/tcsh.vim @dkearns
|
||||||
runtime/indent/teraterm.vim @k-takata
|
runtime/indent/teraterm.vim @k-takata
|
||||||
runtime/indent/typescript.vim @HerringtonDarkholme
|
runtime/indent/typescript.vim @HerringtonDarkholme
|
||||||
|
runtime/indent/typst.vim @gpanders
|
||||||
runtime/indent/vroom.vim @dbarnett
|
runtime/indent/vroom.vim @dbarnett
|
||||||
runtime/indent/wast.vim @rhysd
|
runtime/indent/wast.vim @rhysd
|
||||||
runtime/indent/xml.vim @chrisbra
|
runtime/indent/xml.vim @chrisbra
|
||||||
@ -553,6 +556,7 @@ runtime/syntax/tt2html.vim @petdance
|
|||||||
runtime/syntax/tt2js.vim @petdance
|
runtime/syntax/tt2js.vim @petdance
|
||||||
runtime/syntax/typescript.vim @HerringtonDarkholme @rhysd
|
runtime/syntax/typescript.vim @HerringtonDarkholme @rhysd
|
||||||
runtime/syntax/typescriptreact.vim @HerringtonDarkholme @rhysd
|
runtime/syntax/typescriptreact.vim @HerringtonDarkholme @rhysd
|
||||||
|
runtime/syntax/typst.vim @gpanders
|
||||||
runtime/syntax/shared/typescriptcommon.vim @HerringtonDarkholme @rhysd
|
runtime/syntax/shared/typescriptcommon.vim @HerringtonDarkholme @rhysd
|
||||||
runtime/syntax/unison.vim @chuwy
|
runtime/syntax/unison.vim @chuwy
|
||||||
runtime/syntax/vdf.vim @ObserverOfTime
|
runtime/syntax/vdf.vim @ObserverOfTime
|
||||||
|
50
runtime/autoload/typst.vim
Normal file
50
runtime/autoload/typst.vim
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
" Language: Typst
|
||||||
|
" Maintainer: Gregory Anders
|
||||||
|
" Last Change: 2024-07-14
|
||||||
|
" Based on: https://github.com/kaarmu/typst.vim
|
||||||
|
|
||||||
|
function! typst#indentexpr() abort
|
||||||
|
let l:lnum = v:lnum
|
||||||
|
let s:sw = shiftwidth()
|
||||||
|
|
||||||
|
let [l:plnum, l:pline] = s:get_prev_nonblank(l:lnum - 1)
|
||||||
|
if l:plnum == 0 | return 0 | endif
|
||||||
|
|
||||||
|
let l:line = getline(l:lnum)
|
||||||
|
let l:ind = indent(l:plnum)
|
||||||
|
|
||||||
|
let l:synname = synIDattr(synID(l:lnum, 1, 1), 'name')
|
||||||
|
|
||||||
|
" Use last indent for block comments
|
||||||
|
if l:synname == 'typstCommentBlock'
|
||||||
|
return l:ind
|
||||||
|
endif
|
||||||
|
|
||||||
|
if l:pline =~ '\v[{[(]\s*$'
|
||||||
|
let l:ind += s:sw
|
||||||
|
endif
|
||||||
|
|
||||||
|
if l:line =~ '\v^\s*[}\])]'
|
||||||
|
let l:ind -= s:sw
|
||||||
|
endif
|
||||||
|
|
||||||
|
return l:ind
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Gets the previous non-blank line that is not a comment.
|
||||||
|
function! s:get_prev_nonblank(lnum) abort
|
||||||
|
let l:lnum = prevnonblank(a:lnum)
|
||||||
|
let l:line = getline(l:lnum)
|
||||||
|
|
||||||
|
while l:lnum > 0 && l:line =~ '^\s*//'
|
||||||
|
let l:lnum = prevnonblank(l:lnum - 1)
|
||||||
|
let l:line = getline(l:lnum)
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
return [l:lnum, s:remove_comments(l:line)]
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Removes comments from the given line.
|
||||||
|
function! s:remove_comments(line) abort
|
||||||
|
return substitute(a:line, '\s*//.*', '', '')
|
||||||
|
endfunction
|
15
runtime/compiler/typst.vim
Normal file
15
runtime/compiler/typst.vim
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
" Vim compiler file
|
||||||
|
" Language: Typst
|
||||||
|
" Maintainer: Gregory Anders
|
||||||
|
" Last Change: 2024-07-14
|
||||||
|
" Based on: https://github.com/kaarmu/typst.vim
|
||||||
|
|
||||||
|
if exists('current_compiler')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let current_compiler = get(g:, 'typst_cmd', 'typst')
|
||||||
|
|
||||||
|
" With `--diagnostic-format` we can use the default errorformat
|
||||||
|
let s:makeprg = [current_compiler, 'compile', '--diagnostic-format', 'short', '%:S']
|
||||||
|
|
||||||
|
execute 'CompilerSet makeprg=' . join(s:makeprg, '\ ')
|
@ -1,4 +1,4 @@
|
|||||||
*filetype.txt* For Vim version 9.1. Last change: 2024 May 23
|
*filetype.txt* For Vim version 9.1. Last change: 2024 Jul 15
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -886,6 +886,10 @@ You can change the default by defining the variable g:tex_flavor to the format
|
|||||||
let g:tex_flavor = "latex"
|
let g:tex_flavor = "latex"
|
||||||
Currently no other formats are recognized.
|
Currently no other formats are recognized.
|
||||||
|
|
||||||
|
TYPST *ft-typst-plugin*
|
||||||
|
|
||||||
|
*g:typst_conceal*
|
||||||
|
When |TRUE| the Typst filetype plugin will set the 'conceallevel' option to 2.
|
||||||
|
|
||||||
VIM *ft-vim-plugin*
|
VIM *ft-vim-plugin*
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
*quickfix.txt* For Vim version 9.1. Last change: 2024 Jun 16
|
*quickfix.txt* For Vim version 9.1. Last change: 2024 Jul 15
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -1414,6 +1414,17 @@ shells and OSes and also does not allow to use other available TeX options,
|
|||||||
if any. If your TeX doesn't support "-interaction=nonstopmode", please
|
if any. If your TeX doesn't support "-interaction=nonstopmode", please
|
||||||
report it with different means to express \nonstopmode from the command line.
|
report it with different means to express \nonstopmode from the command line.
|
||||||
|
|
||||||
|
TYPST COMPILER *compiler-typst*
|
||||||
|
|
||||||
|
Vim includes a compiler plugin for Typst files. This compiler is enabled
|
||||||
|
automatically in Typst buffers by the Typst filetype plugin |ft-typst-plugin|.
|
||||||
|
Run |:make| to compile the current Typst file.
|
||||||
|
|
||||||
|
*g:typst_cmd*
|
||||||
|
By default Vim will use "typst" as the command to run the Typst compiler. This
|
||||||
|
can be changed by setting the |g:typst_cmd| variable: >
|
||||||
|
let g:typst_cmd = "/path/to/other/command"
|
||||||
|
|
||||||
=============================================================================
|
=============================================================================
|
||||||
7. The error format *error-file-format*
|
7. The error format *error-file-format*
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
*syntax.txt* For Vim version 9.1. Last change: 2024 Jul 08
|
*syntax.txt* For Vim version 9.1. Last change: 2024 Jul 15
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -3810,6 +3810,15 @@ are highlighted. To disable set it to zero in your .vimrc: >
|
|||||||
<
|
<
|
||||||
The default value is 1.
|
The default value is 1.
|
||||||
|
|
||||||
|
TYPST *ft-typst-syntax*
|
||||||
|
|
||||||
|
*g:typst_embedded_languages*
|
||||||
|
Typst files can embed syntax highlighting for other languages by setting the
|
||||||
|
|g:typst_embedded_languages| variable. This variable is a list of language
|
||||||
|
names whose syntax definitions will be included in Typst files. Example: >
|
||||||
|
|
||||||
|
let g:typst_embedded_languages = ['python', 'r']
|
||||||
|
|
||||||
VIM *vim.vim* *ft-vim-syntax*
|
VIM *vim.vim* *ft-vim-syntax*
|
||||||
*g:vimsyn_minlines* *g:vimsyn_maxlines*
|
*g:vimsyn_minlines* *g:vimsyn_maxlines*
|
||||||
There is a trade-off between more accurate syntax highlighting versus screen
|
There is a trade-off between more accurate syntax highlighting versus screen
|
||||||
|
@ -6550,6 +6550,7 @@ compiler-perl quickfix.txt /*compiler-perl*
|
|||||||
compiler-pyunit quickfix.txt /*compiler-pyunit*
|
compiler-pyunit quickfix.txt /*compiler-pyunit*
|
||||||
compiler-select quickfix.txt /*compiler-select*
|
compiler-select quickfix.txt /*compiler-select*
|
||||||
compiler-tex quickfix.txt /*compiler-tex*
|
compiler-tex quickfix.txt /*compiler-tex*
|
||||||
|
compiler-typst quickfix.txt /*compiler-typst*
|
||||||
compiler-vaxada ft_ada.txt /*compiler-vaxada*
|
compiler-vaxada ft_ada.txt /*compiler-vaxada*
|
||||||
compl-current insert.txt /*compl-current*
|
compl-current insert.txt /*compl-current*
|
||||||
compl-define insert.txt /*compl-define*
|
compl-define insert.txt /*compl-define*
|
||||||
@ -7410,6 +7411,8 @@ ft-tex-syntax syntax.txt /*ft-tex-syntax*
|
|||||||
ft-tf-syntax syntax.txt /*ft-tf-syntax*
|
ft-tf-syntax syntax.txt /*ft-tf-syntax*
|
||||||
ft-typescript-syntax syntax.txt /*ft-typescript-syntax*
|
ft-typescript-syntax syntax.txt /*ft-typescript-syntax*
|
||||||
ft-typescriptreact-syntax syntax.txt /*ft-typescriptreact-syntax*
|
ft-typescriptreact-syntax syntax.txt /*ft-typescriptreact-syntax*
|
||||||
|
ft-typst-plugin filetype.txt /*ft-typst-plugin*
|
||||||
|
ft-typst-syntax syntax.txt /*ft-typst-syntax*
|
||||||
ft-vb-syntax syntax.txt /*ft-vb-syntax*
|
ft-vb-syntax syntax.txt /*ft-vb-syntax*
|
||||||
ft-verilog-indent indent.txt /*ft-verilog-indent*
|
ft-verilog-indent indent.txt /*ft-verilog-indent*
|
||||||
ft-vhdl-indent indent.txt /*ft-vhdl-indent*
|
ft-vhdl-indent indent.txt /*ft-vhdl-indent*
|
||||||
@ -7718,6 +7721,9 @@ g:tex_subscripts syntax.txt /*g:tex_subscripts*
|
|||||||
g:tex_superscripts syntax.txt /*g:tex_superscripts*
|
g:tex_superscripts syntax.txt /*g:tex_superscripts*
|
||||||
g:tex_verbspell syntax.txt /*g:tex_verbspell*
|
g:tex_verbspell syntax.txt /*g:tex_verbspell*
|
||||||
g:typescript_host_keyword syntax.txt /*g:typescript_host_keyword*
|
g:typescript_host_keyword syntax.txt /*g:typescript_host_keyword*
|
||||||
|
g:typst_cmd quickfix.txt /*g:typst_cmd*
|
||||||
|
g:typst_conceal filetype.txt /*g:typst_conceal*
|
||||||
|
g:typst_embedded_languages syntax.txt /*g:typst_embedded_languages*
|
||||||
g:var eval.txt /*g:var*
|
g:var eval.txt /*g:var*
|
||||||
g:vim_indent indent.txt /*g:vim_indent*
|
g:vim_indent indent.txt /*g:vim_indent*
|
||||||
g:vim_indent_cont indent.txt /*g:vim_indent_cont*
|
g:vim_indent_cont indent.txt /*g:vim_indent_cont*
|
||||||
|
@ -1,14 +1,24 @@
|
|||||||
" Vim filetype plugin
|
" Vim filetype plugin file
|
||||||
" Language: typst
|
" Language: Typst
|
||||||
" Maintainer: Riley Bruins <ribru17@gmail.com>
|
" Maintainer: Gregory Anders
|
||||||
" Last Change: 2024 May 19
|
" Last Change: 2024-07-14
|
||||||
|
" Based on: https://github.com/kaarmu/typst.vim
|
||||||
|
|
||||||
if exists('b:did_ftplugin')
|
if exists('b:did_ftplugin')
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let b:did_ftplugin = 1
|
let b:did_ftplugin = 1
|
||||||
|
|
||||||
setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
|
compiler typst
|
||||||
setlocal commentstring=//\ %s
|
|
||||||
|
|
||||||
let b:undo_ftplugin = 'setl com< cms<'
|
setlocal commentstring=//\ %s
|
||||||
|
setlocal comments=s1:/*,mb:*,ex:*/,://
|
||||||
|
setlocal formatoptions+=croq
|
||||||
|
setlocal suffixesadd=.typ
|
||||||
|
|
||||||
|
let b:undo_ftplugin = 'setl cms< com< fo< sua<'
|
||||||
|
|
||||||
|
if get(g:, 'typst_conceal', 0)
|
||||||
|
setlocal conceallevel=2
|
||||||
|
let b:undo_ftplugin .= ' cole<'
|
||||||
|
endif
|
||||||
|
18
runtime/indent/typst.vim
Normal file
18
runtime/indent/typst.vim
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
" Vim indent file
|
||||||
|
" Language: Typst
|
||||||
|
" Maintainer: Gregory Anders <greg@gpanders.com>
|
||||||
|
" Last Change: 2024-07-14
|
||||||
|
" Based on: https://github.com/kaarmu/typst.vim
|
||||||
|
|
||||||
|
if exists('b:did_indent')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let b:did_indent = 1
|
||||||
|
|
||||||
|
setlocal expandtab
|
||||||
|
setlocal softtabstop=2
|
||||||
|
setlocal shiftwidth=2
|
||||||
|
setlocal autoindent
|
||||||
|
setlocal indentexpr=typst#indentexpr()
|
||||||
|
|
||||||
|
let b:undo_indent = 'setl et< sts< sw< ai< inde<'
|
472
runtime/syntax/typst.vim
Normal file
472
runtime/syntax/typst.vim
Normal file
@ -0,0 +1,472 @@
|
|||||||
|
" Vim syntax file
|
||||||
|
" Language: Typst
|
||||||
|
" Maintainer: Gregory Anders <greg@gpanders.com>
|
||||||
|
" Last Change: 2024-07-14
|
||||||
|
" Based on: https://github.com/kaarmu/typst.vim
|
||||||
|
|
||||||
|
if exists('b:current_syntax')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
syntax sync fromstart
|
||||||
|
syntax spell toplevel
|
||||||
|
|
||||||
|
" Common {{{1
|
||||||
|
syntax cluster typstCommon
|
||||||
|
\ contains=@typstComment
|
||||||
|
|
||||||
|
" Common > Comment {{{2
|
||||||
|
syntax cluster typstComment
|
||||||
|
\ contains=typstCommentBlock,typstCommentLine
|
||||||
|
syntax match typstCommentBlock
|
||||||
|
\ #/\*\%(\_.\{-}\)\*/#
|
||||||
|
\ contains=typstCommentTodo,@Spell
|
||||||
|
syntax match typstCommentLine
|
||||||
|
\ #//.*#
|
||||||
|
\ contains=typstCommentTodo,@Spell
|
||||||
|
syntax keyword typstCommentTodo
|
||||||
|
\ contained
|
||||||
|
\ TODO FIXME XXX TBD
|
||||||
|
|
||||||
|
|
||||||
|
" Code {{{1
|
||||||
|
syntax cluster typstCode
|
||||||
|
\ contains=@typstCommon
|
||||||
|
\ ,@typstCodeKeywords
|
||||||
|
\ ,@typstCodeConstants
|
||||||
|
\ ,@typstCodeIdentifiers
|
||||||
|
\ ,@typstCodeFunctions
|
||||||
|
\ ,@typstCodeParens
|
||||||
|
|
||||||
|
" Code > Keywords {{{2
|
||||||
|
syntax cluster typstCodeKeywords
|
||||||
|
\ contains=typstCodeConditional
|
||||||
|
\ ,typstCodeRepeat
|
||||||
|
\ ,typstCodeKeyword
|
||||||
|
\ ,typstCodeStatement
|
||||||
|
syntax keyword typstCodeConditional
|
||||||
|
\ contained
|
||||||
|
\ if else
|
||||||
|
syntax keyword typstCodeRepeat
|
||||||
|
\ contained
|
||||||
|
\ while for
|
||||||
|
syntax keyword typstCodeKeyword
|
||||||
|
\ contained
|
||||||
|
\ not in and or return
|
||||||
|
syntax region typstCodeStatement
|
||||||
|
\ contained
|
||||||
|
\ matchgroup=typstCodeStatementWord start=/\v(let|set|import|include)>/
|
||||||
|
\ matchgroup=Noise end=/\v%(;|$)/
|
||||||
|
\ contains=@typstCode
|
||||||
|
syntax region typstCodeStatement
|
||||||
|
\ contained
|
||||||
|
\ matchgroup=typstCodeStatementWord start=/show/
|
||||||
|
\ matchgroup=Noise end=/\v%(:|$)/ keepend
|
||||||
|
\ contains=@typstCode
|
||||||
|
\ skipwhite nextgroup=@typstCode,typstCodeShowRocket
|
||||||
|
syntax match typstCodeShowRocket
|
||||||
|
\ contained
|
||||||
|
\ /.*=>/
|
||||||
|
\ contains=@typstCode
|
||||||
|
\ skipwhite nextgroup=@typstCode
|
||||||
|
|
||||||
|
" Code > Identifiers {{{2
|
||||||
|
syntax cluster typstCodeIdentifiers
|
||||||
|
\ contains=typstCodeIdentifier
|
||||||
|
\ ,typstCodeFieldAccess
|
||||||
|
syntax match typstCodeIdentifier
|
||||||
|
\ contained
|
||||||
|
\ /\v\w\k*>(<%(let|set|show|import|include))@<![\.\[\(]@!/
|
||||||
|
syntax match typstCodeFieldAccess
|
||||||
|
\ contained
|
||||||
|
\ /\v\w\k*>(<%(let|set|show|import|include))@<!\.[\[\(]@!/
|
||||||
|
\ nextgroup=typstCodeFieldAccess,typstCodeFunction
|
||||||
|
|
||||||
|
" Code > Functions {{{2
|
||||||
|
syntax cluster typstCodeFunctions
|
||||||
|
\ contains=typstCodeFunction
|
||||||
|
syntax match typstCodeFunction
|
||||||
|
\ contained
|
||||||
|
\ /\v\w\k*>(<%(let|set|show|import|include))@<![\(\[]@=/
|
||||||
|
\ nextgroup=typstCodeFunctionArgument
|
||||||
|
syntax match typstCodeFunctionArgument
|
||||||
|
\ contained
|
||||||
|
\ /\v%(%(\(.{-}\)|\[.{-}\]|\{.{-}\}))*/ transparent
|
||||||
|
\ contains=@typstCode
|
||||||
|
|
||||||
|
" Code > Constants {{{2
|
||||||
|
syntax cluster typstCodeConstants
|
||||||
|
\ contains=typstCodeConstant
|
||||||
|
\ ,typstCodeNumberInteger
|
||||||
|
\ ,typstCodeNumberFloat
|
||||||
|
\ ,typstCodeNumberLength
|
||||||
|
\ ,typstCodeNumberAngle
|
||||||
|
\ ,typstCodeNumberRatio
|
||||||
|
\ ,typstCodeNumberFraction
|
||||||
|
\ ,typstCodeString
|
||||||
|
\ ,typstCodeLabel
|
||||||
|
syntax match typstCodeConstant
|
||||||
|
\ contained
|
||||||
|
\ /\v<%(none|auto|true|false)-@!>/
|
||||||
|
syntax match typstCodeNumberInteger
|
||||||
|
\ contained
|
||||||
|
\ /\v<\d+>/
|
||||||
|
|
||||||
|
syntax match typstCodeNumberFloat
|
||||||
|
\ contained
|
||||||
|
\ /\v<\d+\.\d*>/
|
||||||
|
syntax match typstCodeNumberLength
|
||||||
|
\ contained
|
||||||
|
\ /\v<\d+(\.\d*)?(pt|mm|cm|in|em)>/
|
||||||
|
syntax match typstCodeNumberAngle
|
||||||
|
\ contained
|
||||||
|
\ /\v<\d+(\.\d*)?(deg|rad)>/
|
||||||
|
syntax match typstCodeNumberRatio
|
||||||
|
\ contained
|
||||||
|
\ /\v<\d+(\.\d*)?\%/
|
||||||
|
syntax match typstCodeNumberFraction
|
||||||
|
\ contained
|
||||||
|
\ /\v<\d+(\.\d*)?fr>/
|
||||||
|
syntax region typstCodeString
|
||||||
|
\ contained
|
||||||
|
\ start=/"/ skip=/\v\\\\|\\"/ end=/"/
|
||||||
|
\ contains=@Spell
|
||||||
|
syntax match typstCodeLabel
|
||||||
|
\ contained
|
||||||
|
\ /\v\<\K%(\k*-*)*\>/
|
||||||
|
|
||||||
|
" Code > Parens {{{2
|
||||||
|
syntax cluster typstCodeParens
|
||||||
|
\ contains=typstCodeParen
|
||||||
|
\ ,typstCodeBrace
|
||||||
|
\ ,typstCodeBracket
|
||||||
|
\ ,typstCodeDollar
|
||||||
|
\ ,typstMarkupRawInline
|
||||||
|
\ ,typstMarkupRawBlock
|
||||||
|
syntax region typstCodeParen
|
||||||
|
\ contained
|
||||||
|
\ matchgroup=Noise start=/(/ end=/)/
|
||||||
|
\ contains=@typstCode
|
||||||
|
syntax region typstCodeBrace
|
||||||
|
\ contained
|
||||||
|
\ matchgroup=Noise start=/{/ end=/}/
|
||||||
|
\ contains=@typstCode
|
||||||
|
syntax region typstCodeBracket
|
||||||
|
\ contained
|
||||||
|
\ matchgroup=Noise start=/\[/ end=/\]/
|
||||||
|
\ contains=@typstMarkup
|
||||||
|
syntax region typstCodeDollar
|
||||||
|
\ contained
|
||||||
|
\ matchgroup=Number start=/\\\@<!\$/ end=/\\\@<!\$/
|
||||||
|
\ contains=@typstMath
|
||||||
|
|
||||||
|
|
||||||
|
" Hashtag {{{1
|
||||||
|
syntax cluster typstHashtag
|
||||||
|
\ contains=@typstHashtagKeywords
|
||||||
|
\ ,@typstHashtagConstants
|
||||||
|
\ ,@typstHashtagIdentifiers
|
||||||
|
\ ,@typstHashtagFunctions
|
||||||
|
\ ,@typstHashtagParens
|
||||||
|
|
||||||
|
" Hashtag > Keywords {{{2
|
||||||
|
syntax cluster typstHashtagKeywords
|
||||||
|
\ contains=typstHashtagConditional
|
||||||
|
\ ,typstHashtagRepeat
|
||||||
|
\ ,typstHashtagKeywords
|
||||||
|
\ ,typstHashtagStatement
|
||||||
|
|
||||||
|
" syntax match typstHashtagControlFlowError
|
||||||
|
" \ /\v#%(if|while|for)>-@!.{-}$\_.{-}%(\{|\[|\()/
|
||||||
|
syntax match typstHashtagControlFlow
|
||||||
|
\ /\v#%(if|while|for)>.{-}\ze%(\{|\[|\()/
|
||||||
|
\ contains=typstHashtagConditional,typstHashtagRepeat
|
||||||
|
\ nextgroup=@typstCode
|
||||||
|
syntax region typstHashtagConditional
|
||||||
|
\ contained
|
||||||
|
\ start=/\v#if>/ end=/\v\ze(\{|\[)/
|
||||||
|
\ contains=@typstCode
|
||||||
|
syntax region typstHashtagRepeat
|
||||||
|
\ contained
|
||||||
|
\ start=/\v#(while|for)>/ end=/\v\ze(\{|\[)/
|
||||||
|
\ contains=@typstCode
|
||||||
|
syntax match typstHashtagKeyword
|
||||||
|
\ /\v#(return)>/
|
||||||
|
\ skipwhite nextgroup=@typstCode
|
||||||
|
syntax region typstHashtagStatement
|
||||||
|
\ matchgroup=typstHashtagStatementWord start=/\v#(let|set|import|include)>/
|
||||||
|
\ matchgroup=Noise end=/\v%(;|$)/
|
||||||
|
\ contains=@typstCode
|
||||||
|
syntax region typstHashtagStatement
|
||||||
|
\ matchgroup=typstHashtagStatementWord start=/#show/
|
||||||
|
\ matchgroup=Noise end=/\v%(:|$)/ keepend
|
||||||
|
\ contains=@typstCode
|
||||||
|
\ skipwhite nextgroup=@typstCode,typstCodeShowRocket
|
||||||
|
|
||||||
|
" Hashtag > Constants {{{2
|
||||||
|
syntax cluster typstHashtagConstants
|
||||||
|
\ contains=typstHashtagConstant
|
||||||
|
syntax match typstHashtagConstant
|
||||||
|
\ /\v#(none|auto|true|false)>/
|
||||||
|
|
||||||
|
" Hashtag > Identifiers {{{2
|
||||||
|
syntax cluster typstHashtagIdentifiers
|
||||||
|
\ contains=typstHashtagIdentifier
|
||||||
|
\ ,typstHashtagFieldAccess
|
||||||
|
syntax match typstHashtagIdentifier
|
||||||
|
\ /\v#\w\k*>(<%(let|set|show|import|include))@<![\.\[\(]@!/
|
||||||
|
syntax match typstHashtagFieldAccess
|
||||||
|
\ /\v#\w\k*>(<%(let|set|show|import|include))@<!\.[\[\(]@!/
|
||||||
|
\ nextgroup=typstCodeFieldAccess,typstCodeFunction
|
||||||
|
|
||||||
|
" Hashtag > Functions {{{2
|
||||||
|
syntax cluster typstHashtagFunctions
|
||||||
|
\ contains=typstHashtagFunction
|
||||||
|
syntax match typstHashtagFunction
|
||||||
|
\ /\v#\w\k*>(<%(let|set|show|import|include))@<![\(\[]@=/
|
||||||
|
\ nextgroup=typstCodeFunctionArgument
|
||||||
|
|
||||||
|
" Hashtag > Parens {{{2
|
||||||
|
syntax cluster typstHashtagParens
|
||||||
|
\ contains=typstHashtagParen
|
||||||
|
\ ,typstHashtagBrace
|
||||||
|
\ ,typstHashtagBracket
|
||||||
|
\ ,typstHashtagDollar
|
||||||
|
syntax region typstHashtagParen
|
||||||
|
\ matchgroup=Noise start=/#(/ end=/)/
|
||||||
|
\ contains=@typstCode
|
||||||
|
syntax region typstHashtagBrace
|
||||||
|
\ matchgroup=Noise start=/#{/ end=/}/
|
||||||
|
\ contains=@typstCode
|
||||||
|
syntax region typstHashtagBracket
|
||||||
|
\ matchgroup=Noise start=/#\[/ end=/\]/
|
||||||
|
\ contains=@typstMarkup
|
||||||
|
syntax region typstHashtagDollar
|
||||||
|
\ matchgroup=Noise start=/#\$/ end=/\\\@<!\$/
|
||||||
|
\ contains=@typstMath
|
||||||
|
|
||||||
|
|
||||||
|
" Markup {{{1
|
||||||
|
syntax cluster typstMarkup
|
||||||
|
\ contains=@typstCommon
|
||||||
|
\ ,@Spell
|
||||||
|
\ ,@typstHashtag
|
||||||
|
\ ,@typstMarkupText
|
||||||
|
\ ,@typstMarkupParens
|
||||||
|
|
||||||
|
" Markup > Text {{{2
|
||||||
|
syntax cluster typstMarkupText
|
||||||
|
\ contains=typstMarkupRawInline
|
||||||
|
\ ,typstMarkupRawBlock
|
||||||
|
\ ,typstMarkupLabel
|
||||||
|
\ ,typstMarkupReference
|
||||||
|
\ ,typstMarkupUrl
|
||||||
|
\ ,typstMarkupHeading
|
||||||
|
\ ,typstMarkupBulletList
|
||||||
|
\ ,typstMarkupEnumList
|
||||||
|
\ ,typstMarkupTermList
|
||||||
|
\ ,typstMarkupBold
|
||||||
|
\ ,typstMarkupItalic
|
||||||
|
\ ,typstMarkupLinebreak
|
||||||
|
\ ,typstMarkupNonbreakingSpace
|
||||||
|
\ ,typstMarkupShy
|
||||||
|
\ ,typstMarkupDash
|
||||||
|
\ ,typstMarkupEllipsis
|
||||||
|
|
||||||
|
" Raw Text
|
||||||
|
syntax match typstMarkupRawInline
|
||||||
|
\ /`.\{-}`/
|
||||||
|
syntax region typstMarkupRawBlock
|
||||||
|
\ matchgroup=Macro start=/```\w*/
|
||||||
|
\ matchgroup=Macro end=/```/ keepend
|
||||||
|
syntax region typstMarkupCodeBlockTypst
|
||||||
|
\ matchgroup=Macro start=/```typst/
|
||||||
|
\ matchgroup=Macro end=/```/ contains=@typstCode keepend
|
||||||
|
\ concealends
|
||||||
|
|
||||||
|
for s:name in get(g:, 'typst_embedded_languages', [])
|
||||||
|
let s:include = ['syntax include'
|
||||||
|
\ ,'@typstEmbedded_'..s:name
|
||||||
|
\ ,'syntax/'..s:name..'.vim']
|
||||||
|
let s:rule = ['syn region'
|
||||||
|
\,s:name
|
||||||
|
\,'matchgroup=Macro'
|
||||||
|
\,'start=/```'..s:name..'\>/ end=/```/'
|
||||||
|
\,'contains=@typstEmbedded_'..s:name
|
||||||
|
\,'keepend'
|
||||||
|
\,'concealends']
|
||||||
|
execute 'silent! ' .. join(s:include, ' ')
|
||||||
|
unlet! b:current_syntax
|
||||||
|
execute join(s:rule, ' ')
|
||||||
|
endfor
|
||||||
|
|
||||||
|
" Label & Reference
|
||||||
|
syntax match typstMarkupLabel
|
||||||
|
\ /\v\<\K%(\k*-*)*\>/
|
||||||
|
syntax match typstMarkupReference
|
||||||
|
\ /\v\@\K%(\k*-*)*/
|
||||||
|
|
||||||
|
" URL
|
||||||
|
syntax match typstMarkupUrl
|
||||||
|
\ #\v\w+://\S*#
|
||||||
|
|
||||||
|
" Heading
|
||||||
|
syntax match typstMarkupHeading
|
||||||
|
\ /^\s*\zs=\{1,6}\s.*$/
|
||||||
|
\ contains=typstMarkupLabel,@Spell
|
||||||
|
|
||||||
|
" Lists
|
||||||
|
syntax match typstMarkupBulletList
|
||||||
|
\ /\v^\s*-\s+/
|
||||||
|
syntax match typstMarkupEnumList
|
||||||
|
\ /\v^\s*(\+|\d+\.)\s+/
|
||||||
|
syntax region typstMarkupTermList
|
||||||
|
\ oneline start=/\v^\s*\/\s/ end=/:/
|
||||||
|
\ contains=@typstMarkup
|
||||||
|
|
||||||
|
" Bold & Italic
|
||||||
|
syntax match typstMarkupBold
|
||||||
|
\ /\v(\w|\\)@1<!\*\S@=.{-}(\n.{-1,})*\S@1<=\\@1<!\*/
|
||||||
|
\ contains=typstMarkupBoldRegion
|
||||||
|
syntax match typstMarkupItalic
|
||||||
|
\ /\v(\w|\\)@1<!_\S@=.{-}(\n.{-1,})*\S@1<=\\@1<!_/
|
||||||
|
\ contains=typstMarkupItalicRegion
|
||||||
|
syntax match typstMarkupBoldItalic
|
||||||
|
\ contained
|
||||||
|
\ /\v(\w|\\)@1<![_\*]\S@=.{-}(\n.{-1,})*\S@1<=\\@1<!\2/
|
||||||
|
\ contains=typstMarkupBoldRegion,typstMarkupItalicRegion
|
||||||
|
syntax region typstMarkupBoldRegion
|
||||||
|
\ contained
|
||||||
|
\ transparent matchgroup=typstMarkupBold
|
||||||
|
\ start=/\(^\|[^0-9a-zA-Z]\)\@<=\*/ end=/\*\($\|[^0-9a-zA-Z]\)\@=/
|
||||||
|
\ concealends contains=typstMarkupBoldItalic,typstMarkupLabel,@Spell
|
||||||
|
syntax region typstMarkupItalicRegion
|
||||||
|
\ contained
|
||||||
|
\ transparent matchgroup=typstMarkupItalic
|
||||||
|
\ start=/\(^\|[^0-9a-zA-Z]\)\@<=_/ end=/_\($\|[^0-9a-zA-Z]\)\@=/
|
||||||
|
\ concealends contains=typstMarkupBoldItalic,typstMarkupLabel,@Spell
|
||||||
|
|
||||||
|
" Linebreak & Special Whitespace
|
||||||
|
syntax match typstMarkupLinebreak
|
||||||
|
\ /\\\\/
|
||||||
|
syntax match typstMarkupNonbreakingSpace
|
||||||
|
\ /\~/
|
||||||
|
syntax match typstMarkupShy
|
||||||
|
\ /-?/
|
||||||
|
|
||||||
|
" Special Symbols
|
||||||
|
syntax match typstMarkupDash
|
||||||
|
\ /-\{2,3}/
|
||||||
|
syntax match typstMarkupEllipsis
|
||||||
|
\ /\.\.\./
|
||||||
|
|
||||||
|
" Markup > Parens {{{2
|
||||||
|
syntax cluster typstMarkupParens
|
||||||
|
\ contains=typstMarkupBracket
|
||||||
|
\ ,typstMarkupDollar
|
||||||
|
syntax region typstMarkupBracket
|
||||||
|
\ matchgroup=Noise start=/\[/ end=/\]/
|
||||||
|
\ contains=@typstMarkup
|
||||||
|
syntax region typstMarkupDollar
|
||||||
|
\ matchgroup=Special start=/\\\@<!\$/ end=/\\\@<!\$/
|
||||||
|
\ contains=@typstMath
|
||||||
|
|
||||||
|
|
||||||
|
" Math {{{1
|
||||||
|
syntax cluster typstMath
|
||||||
|
\ contains=@typstCommon
|
||||||
|
\ ,@typstHashtag
|
||||||
|
\ ,typstMathIdentifier
|
||||||
|
\ ,typstMathFunction
|
||||||
|
\ ,typstMathNumber
|
||||||
|
\ ,typstMathSymbol
|
||||||
|
\ ,typstMathBold
|
||||||
|
\ ,typstMathScripts
|
||||||
|
\ ,typstMathQuote
|
||||||
|
|
||||||
|
syntax match typstMathIdentifier
|
||||||
|
\ /\a\a\+/
|
||||||
|
\ contained
|
||||||
|
syntax match typstMathFunction
|
||||||
|
\ /\a\a\+\ze(/
|
||||||
|
\ contained
|
||||||
|
syntax match typstMathNumber
|
||||||
|
\ /\<\d\+\>/
|
||||||
|
\ contained
|
||||||
|
syntax region typstMathQuote
|
||||||
|
\ matchgroup=String start=/"/ skip=/\\"/ end=/"/
|
||||||
|
\ contained
|
||||||
|
|
||||||
|
" Math > Linked groups {{{2
|
||||||
|
highlight default link typstMathIdentifier Identifier
|
||||||
|
highlight default link typstMathFunction Statement
|
||||||
|
highlight default link typstMathNumber Number
|
||||||
|
highlight default link typstMathSymbol Statement
|
||||||
|
|
||||||
|
" Highlighting {{{1
|
||||||
|
|
||||||
|
" Highlighting > Linked groups {{{2
|
||||||
|
highlight default link typstCommentBlock Comment
|
||||||
|
highlight default link typstCommentLine Comment
|
||||||
|
highlight default link typstCommentTodo Todo
|
||||||
|
highlight default link typstCodeConditional Conditional
|
||||||
|
highlight default link typstCodeRepeat Repeat
|
||||||
|
highlight default link typstCodeKeyword Keyword
|
||||||
|
highlight default link typstCodeConstant Constant
|
||||||
|
highlight default link typstCodeNumberInteger Number
|
||||||
|
highlight default link typstCodeNumberFloat Number
|
||||||
|
highlight default link typstCodeNumberLength Number
|
||||||
|
highlight default link typstCodeNumberAngle Number
|
||||||
|
highlight default link typstCodeNumberRatio Number
|
||||||
|
highlight default link typstCodeNumberFraction Number
|
||||||
|
highlight default link typstCodeString String
|
||||||
|
highlight default link typstCodeLabel Structure
|
||||||
|
highlight default link typstCodeStatementWord Statement
|
||||||
|
highlight default link typstCodeIdentifier Identifier
|
||||||
|
highlight default link typstCodeFieldAccess Identifier
|
||||||
|
highlight default link typstCodeFunction Function
|
||||||
|
highlight default link typstCodeParen Noise
|
||||||
|
highlight default link typstCodeBrace Noise
|
||||||
|
highlight default link typstCodeBracket Noise
|
||||||
|
highlight default link typstCodeDollar Noise
|
||||||
|
" highlight default link typstHashtagControlFlowError Error
|
||||||
|
highlight default link typstHashtagConditional Conditional
|
||||||
|
highlight default link typstHashtagRepeat Repeat
|
||||||
|
highlight default link typstHashtagKeyword Keyword
|
||||||
|
highlight default link typstHashtagConstant Constant
|
||||||
|
highlight default link typstHashtagStatementWord Statement
|
||||||
|
highlight default link typstHashtagIdentifier Identifier
|
||||||
|
highlight default link typstHashtagFieldAccess Identifier
|
||||||
|
highlight default link typstHashtagFunction Function
|
||||||
|
highlight default link typstHashtagParen Noise
|
||||||
|
highlight default link typstHashtagBrace Noise
|
||||||
|
highlight default link typstHashtagBracket Noise
|
||||||
|
highlight default link typstHashtagDollar Noise
|
||||||
|
highlight default link typstMarkupRawInline Macro
|
||||||
|
highlight default link typstMarkupRawBlock Macro
|
||||||
|
highlight default link typstMarkupLabel Structure
|
||||||
|
highlight default link typstMarkupReference Structure
|
||||||
|
highlight default link typstMarkupBulletList Structure
|
||||||
|
" highlight default link typstMarkupItalicError Error
|
||||||
|
" highlight default link typstMarkupBoldError Error
|
||||||
|
highlight default link typstMarkupEnumList Structure
|
||||||
|
highlight default link typstMarkupLinebreak Structure
|
||||||
|
highlight default link typstMarkupNonbreakingSpace Structure
|
||||||
|
highlight default link typstMarkupShy Structure
|
||||||
|
highlight default link typstMarkupDash Structure
|
||||||
|
highlight default link typstMarkupEllipsis Structure
|
||||||
|
highlight default link typstMarkupTermList Structure
|
||||||
|
highlight default link typstMarkupDollar Noise
|
||||||
|
|
||||||
|
" Highlighting > Custom Styling {{{2
|
||||||
|
highlight! Conceal ctermfg=NONE ctermbg=NONE guifg=NONE guibg=NONE
|
||||||
|
|
||||||
|
highlight default typstMarkupHeading term=underline,bold cterm=underline,bold gui=underline,bold
|
||||||
|
highlight default typstMarkupUrl term=underline cterm=underline gui=underline
|
||||||
|
highlight default typstMarkupBold term=bold cterm=bold gui=bold
|
||||||
|
highlight default typstMarkupItalic term=italic cterm=italic gui=italic
|
||||||
|
highlight default typstMarkupBoldItalic term=bold,italic cterm=bold,italic gui=bold,italic
|
||||||
|
|
||||||
|
let b:current_syntax = 'typst'
|
||||||
|
|
||||||
|
" }}}1
|
Loading…
x
Reference in New Issue
Block a user