Snippets collection for Typst.
Use your plugin manager of choice, e.g.
{ "abhinandh-s/typst-snippets" }Warning
If you're using LuaSnip make sure to use
require("luasnip.loaders.from_vscode").lazy_load(), and add
typst-snippets as a dependency for LuaSnip, otherwise snippets might not
be detected. If you don't use lazy_load() you might notice a slower
startup-time
{
"L3MON4D3/LuaSnip",
dependencies = { "abhinandh-s/typst-snippets" },
}vim.pack.add({
{ src = 'https://github.com/L3MON4D3/LuaSnip', version = 'v2.5.0' },
'https://github.com/rafamadriz/friendly-snippets',
'https://github.com/abhinandh-s/typst-snippets',
})
require("luasnip.loaders.from_vscode").load()
require('blink.cmp').setup({
snippets = { preset = 'luasnip' },
sources = {
default = { 'lsp', 'path', 'snippets', 'buffer' },
},
})use "abhinandh-s/typst-snippets"Plug "abhinandh-s/typst-snippets":CocInstall https://github.com/abhinandh-s/typst-snippets@mainThis collection of snippets should work with any snippet engine that supports loading vscode snippets. Like for example:
This snippet collection uses tab characters (\t) for indentation, not spaces.
Using tabs for indentation offers several key benefits:
- Personalization – Every developer can configure their editor to display tabs at their preferred width (2, 4, 8 spaces, etc.) without changing the actual file. What you see as 2 spaces, another developer can see as 8 spaces — the same file works for everyone.
- Portability – Tabs work consistently across different editors, operating systems, and team environments. Copy-pasting code between projects doesn't break indentation.
- Clean diffs – Since the number of tab characters doesn't change when someone adjusts their display settings, version control diffs remain clean and readable.
- File size – One tab character takes less space than 2-4 spaces, which adds up in large codebases.
Tabs for indentation, spaces for alignment.
- Use tabs at the beginning of lines to indicate nesting levels.
- Use spaces to align elements within a line (e.g., continuing a statement, aligning comments).
This separation ensures that indentation adapts to individual preferences while alignment remains visually consistent for everyone.