https://github.com/ckunte/typst-snippets-vim
Custom Typst snippets for use in Vim or Neovim
https://github.com/ckunte/typst-snippets-vim
neovim snippets typst typst-snippets ultisnips vim
Last synced: about 2 months ago
JSON representation
Custom Typst snippets for use in Vim or Neovim
- Host: GitHub
- URL: https://github.com/ckunte/typst-snippets-vim
- Owner: ckunte
- License: mit
- Created: 2024-05-25T04:31:32.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2024-06-02T14:10:59.000Z (12 months ago)
- Last Synced: 2025-03-24T09:15:26.034Z (about 2 months ago)
- Topics: neovim, snippets, typst, typst-snippets, ultisnips, vim
- Language: Vim Snippet
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Custom Typst snippets for use in Vim and Neovim
Typesetting documents, letters, reports, or even books in [Typst] is not as verbose as LaTeX, but certainly error-prone, given the need for strict syntax. A handful of Vim snippets provided in this repository try to reduce this tedium to as low as practicable.
This repository contains the following custom snippets:
| Snippet | Inserts |
| ------------------------- | ------------------ |
| `apdx` + tab | appendix block |
| `bib` + tab | bibliography entry |
| `cod` + tab | code file |
| `fig` + tab | figure block |
| `file` + tab | file |
| `hd` + tab | set heading number |
| `letter` + tab | letter block |
| `lnk` + tab | add link |
| `ltmpl` + tab | letter template |
| `note` + tab | note block |
| `ntmpl` + tab | note template |
| `pb` + tab | page break |
| `ref` + tab | bibliography block |
| `tbl` + tab | table block |## What are snippets and how do they work?
The concept of a snippet is simple. Think of a block of pre-formatted text (i.e., a template) that one needs to use often. One can of-course type or copy-paste such blocks of text repeatedly the hard way, or one could instead assign such common blocks of text with an abbreviated keyword, which in turn calls the entire block of text. To ensure such blocks do not accidentally appear while typing the actual content of the note, paper, or report, a trigger is required. The trigger in this case is a tab key.
In Vim's insert mode, typing `note` and hitting tab key on the keyboard inserts the following block, and focuses on the first user input _Title_ in the template. Type the title. To jump to the next placeholder _Author_, hold ctrl and press j (`c-j` in Vim parlance). The shortcut to jumping between placeholders can be set in `~/.vimrc` file.
```typst
#import "${1:template_incl_path}": note
#show note.with(
title: [${2:title}],
author: "${3:author}",
date: [${4:date}],
)
// content hereon
```## Requirements
To be able to use snippets, the following are required:
1. Vim or Neovim with python3 support.
2. [UltiSnips][us]
3. [typst-snippets-vim][ck]## Installation
1. Set up [vim-plug][vp] plug-in manager
2. Set the required UltiSnips plug-in for [typst-snippets-vim][ck] by adding the following to `.vimrc` file:```vim
call plug#begin('~/.vim/plugged')" UltiSnips for snippets
Plug 'sirver/ultisnips'" Typst snippets for Vim using UltiSnips (downloads only tagged releases)
Plug 'ckunte/typst-snippets-vim', { 'tag': '*' }call plug#end()
let g:UltiSnipsExpandTrigger = ''
let g:UltiSnipsJumpForwardTrigger = ''
let g:UltiSnipsJumpBackwardTrigger = ''
```Reload `.vimrc` and `:PlugInstall` to install plug-ins.
[Typst]: https://typst.app
[us]: https://github.com/SirVer/ultisnips
[vp]: https://github.com/junegunn/vim-plug
[ck]: https://github.com/ckunte/typst-snippets-vim