diff --git a/autoload/typst/options.vim b/autoload/typst/options.vim index 1bff77c..b6d4e46 100644 --- a/autoload/typst/options.vim +++ b/autoload/typst/options.vim @@ -11,6 +11,7 @@ function! typst#options#init() abort " {{{1 call s:declare_option('typst_conceal', 0) call s:declare_option('typst_conceal_math', g:typst_conceal) call s:declare_option('typst_conceal_emoji', g:typst_conceal) + call s:declare_option('typst_syntax_use_lsp', 0) call s:declare_option('typst_auto_close_toc', 0) call s:declare_option('typst_auto_open_quickfix', 1) call s:declare_option('typst_embedded_languages', []) diff --git a/ftplugin/typst.vim b/ftplugin/typst.vim index 19f89cb..616510d 100644 --- a/ftplugin/typst.vim +++ b/ftplugin/typst.vim @@ -32,6 +32,31 @@ if g:typst_conceal setlocal conceallevel=2 endif +if g:typst_syntax_use_lsp && g:typst_conceal + lua << EOF + vim.api.nvim_create_autocmd('LspTokenUpdate', { + callback = function(args) + local token = args.data.token + if token.type == 'punct' then + local conceal = '' + local should_conceal = false + if token.modifiers.strong or token.modifiers.emph then + should_conceal = true + end + if should_conceal then + vim.api.nvim_buf_set_extmark( + args.buf, args.data.client_id, token.line, token.start_col, { + end_col = token.end_col, + conceal = '', + priority = vim.highlight.priorities.semantic_tokens + 1, + }) + end + end + end + }) +EOF +endif + setlocal commentstring=//\ %s setlocal comments=s1:/*,mb:*,ex:*/,:// diff --git a/syntax/typst.vim b/syntax/typst.vim index e13d3e2..2df568c 100644 --- a/syntax/typst.vim +++ b/syntax/typst.vim @@ -1,7 +1,8 @@ -" Vim syntax file +" Vim syntax file using LSP " Language: Typst " Maintainer: Kaj Munhoz Arfvidsson -" Upstream: https://github.com/kaarmu/typst.vim +" Upstream: +" if exists("b:current_syntax") | finish | endif @@ -313,38 +314,44 @@ syntax region typstMarkupTermMarker \ contains=@typstMarkup " Bold & Italic -syntax match typstMarkupBold - \ /\v(\w|\\)@1