Skip to content

Commit

Permalink
fix: make conceal syntax rules optional
Browse files Browse the repository at this point in the history
  • Loading branch information
kaarmu committed Nov 12, 2023
1 parent 80ca618 commit e72561f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ something now rather than waiting for everthing later.
**Existing**
- Vim syntax highlighting.
- Compile the active document with `:make`.
- Basic concealing for italic and bold (more to come). You must `set conceallevel=2` for this to work.
- Concealing for italic, bold. You must `set conceallevel=2` for this to work.
- Concealing symbols in math mode. You must `set conceallevel=2` and the `g:typst_conceal_math` option.

**Possible features**
- Formatting using [this](https://github.com/astrale-sharp/typst-fmt/)?
Expand Down Expand Up @@ -61,13 +62,23 @@ call plug#end()

## Usage

`g:typst_cmd` - Specifies the location of the Typst executable. Defaults to `"typst"`.
### Options

`g:typst_pdf_viewer` - Specifies pdf viewer that `typst watch --open` will use.
- `g:typst_cmd`:
Specifies the location of the Typst executable. Defaults to `"typst"`.
- `g:typst_pdf_viewer`:
Specifies pdf viewer that `typst watch --open` will use.
- `g:typst_conceal_math`:
Enable concealment for math symbols in math mode (i.e. replaces symbols
with their actual unicode character). **OBS**: this can affect performance,
see issue [#64](https://github.com/kaarmu/typst.vim/issues/64).
- `g:typst_auto_close_toc`:
Specifies whether TOC will be automatically closed after using it.

`g:typst_auto_close_toc` - Specifies whether TOC will be automatically closed after using it.
### Commands

`:TypstWatch` - Watches your document and recompiles on change; also opens the document with your default pdf viewer.
- `:TypstWatch`:
Watches your document and recompiles on change; also opens the document with your default pdf viewer.

## Tips

Expand Down
5 changes: 4 additions & 1 deletion ftplugin/typst.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ if !exists('g:typst_cmd')
let g:typst_cmd = "typst"
endif


if !exists('g:typst_pdf_viewer')
let g:typst_pdf_viewer = ""
endif

if !exists('g:typst_conceal_math')
let g:typst_conceal_math = 0
endif

if !exists('g:typst_auto_close_toc')
let g:typst_auto_close_toc = 0
endif
Expand Down
5 changes: 4 additions & 1 deletion syntax/typst.vim
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,10 @@ syntax match typstMathNumber
syntax region typstMathQuote
\ matchgroup=String start=/"/ skip=/\\"/ end=/"/
\ contained
runtime! syntax/typst-symbols.vim

if g:typst_conceal_math
runtime! syntax/typst-symbols.vim
endif


" Math > Linked groups {{{2
Expand Down

0 comments on commit e72561f

Please sign in to comment.