Skip to content

Commit 07ca084

Browse files
committed
doc: add snippet documentation and update readme
1 parent e4d782a commit 07ca084

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ A set of preconfigured snippets for LaTeX for the snippet engine [LuaSnip](https
44

55
https://github.com/evesdropper/luasnip-latex-snippets.nvim/assets/82856360/8649e3ea-ea81-4f80-aa28-dc9c51cd4642
66

7+
## Idea
8+
I’ve created my share of smart snippets for LaTeX, and it might be nice to provide some solid defaults for people using snippets out of the box. Despite this, I would probably recommend others to make their own snippets if they can as the process is far more enjoyable and rewarding. But someone can tell me the same about creating a Neovim plugin while I’m sorely tempted to pay someone off to do the work for me because I really can’t deal with the development process, so do what makes you happy, I guess.
9+
10+
711
## Installation
812

913
Use the package manager of your choice, or don't.
@@ -22,6 +26,9 @@ use {
2226
},
2327
```
2428

29+
## Snippets
30+
See [snippets.md](./snippets.md) for the time being.
31+
2532
## Development Plans
2633

2734
Of course, add more snippets. Ideally would also like to expand this to more languages, allow for better user experience in the future; feel free to make a PR to help contribute your own ideas.
@@ -30,6 +37,7 @@ Of course, add more snippets. Ideally would also like to expand this to more lan
3037
Some similar snippet resources:
3138
- [friendly-snippets](https://github.com/rafamadriz/friendly-snippets/)
3239
- [LuaSnip-snippets.nvim](https://github.com/molleweide/LuaSnip-snippets.nvim)
40+
- [luasnip-latex-snippets.nvim](https://github.com/iurimateus/luasnip-latex-snippets.nvim) (Same repo name, different author/snippets)
3341
- [Gilles Castel's LaTeX Snippets](https://github.com/gillescastel/latex-snippets)
3442

3543
Additionally, I would like to thank Max Mehta for bringing up the idea of creating this plugin and the creator of LuaSnip, [L3MON4D3](https://github.com/L3MON4D3), for helping me debug some of the early stages of the plugin.

doc/snippets.txt

Whitespace-only changes.

snippets.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Snippets
2+
3+
Temp snippet document until I get a solution made with LuaSnip's `snippet_list`. It may be a bit terse, so feel free to make an issue or reformat it.
4+
5+
> **Warning:** Most snippets require [VimTeX](https://github.com/lervag/vimtex) for the condition/show-condition to work.
6+
7+
## `commands.lua`
8+
9+
### Labels/References
10+
- `alab`: add label, of the form `\label{${1:type}:${2:number}}$0`
11+
- `[acCer]ref`: add reference of the form `\(auto|c|C|eqn)ref{${1:type}:${2:number}}$0`
12+
* `cref/Cref` requires the `cleveref` package
13+
14+
### Single-Command Snippets
15+
All of them are of the form `\COMMAND_NAME{$1}$0`, with those with `*` also having labels of the form `\label{type:${1:number}}`
16+
17+
- `sec(*)`, `ssec(*)`, `sssec(*)`*: section, subsection, subsubsection respectively. Add `*` for the starred commands.
18+
- `sq`, `qq`: enquote* and enquote (single and double quotes). Requires `csquotes` package.
19+
- `bf`, `it`, `ttt`, `sc`, `tu`, `tov`: Text modifications (bold, italic, typewriter, small caps, underline, and overline).
20+
21+
## `environments.lua`
22+
23+
`beg` creates a generic environment snippet.
24+
25+
```tex
26+
\begin{$1}
27+
$0
28+
\end{$1}
29+
```
30+
31+
`-i` creates the itemize environment, and there's a choice of which bullet point to set (either default or custom bullets with `\item []` notation).
32+
33+
```tex
34+
\begin{itemize}
35+
\item ${1:[$2]|}
36+
\end{itemize}
37+
```
38+
39+
`-e` deals with the enumerate environment. This one is a bit more involved than the itemize environment snippet, as it allows you to choose which labels and provides two defaults, lowercase roman numerals and lowercase alphabetical characters.
40+
```tex
41+
\begin{enumerate}${1:|[label=${2:(\alph*)|(\roman*)|}]}
42+
\item ${3:[$4]|}
43+
\end{enumerate}
44+
```
45+
46+
`--`, `!-` are the accompanying commands for bullet points, which map to `\item` and `\item []` respectively. These only work at the beginning of the line in itemize/enumerate environments.
47+
48+
49+
## `math.lua`
50+
51+
### Entering Math Mode
52+
- `mk`: inline math `$$1$$0`
53+
- `dm`: display math
54+
- `ali`: align(|*|ed)
55+
- `gat`: gather(|*|ed)
56+
- `eqn`: equation(|*)
57+
58+
### Useful Math Dynamic Snippets
59+
`[bBpvV]mat(%d)x(%d)(a|r)`: creates a dxd matrix, either augmented or not. Requires [this fix](https://tex.stackexchange.com/a/2238) for augments.
60+
61+
For instance, `bmat2x2r` creates:
62+
```tex
63+
\begin{bmatrix}
64+
$1 & $2 \\
65+
$3 & $4 \\
66+
\end{bmatrix}
67+
```
68+
69+
`(%d)?cases`: creates a cases array with d rows; if no input is supplied it defaults to 2 rows.
70+
71+
For instance, `3cases` creates:
72+
```tex
73+
\begin{cases}
74+
$1 & $2 \\
75+
$3 & $4 \\
76+
$5 & $6
77+
\end{cases}
78+
```
79+
80+
## `math-commands.lua`
81+
These are somewhat self-explanatory unless someone convinces me otherwise.
82+
83+
## `delimiters.lua`
84+
85+
`lr(aAbBcmp)` creates a snippet of the form `\left[delim] $1 \right[delim] $0`; delimiters are created following this table:
86+
87+
```lua
88+
-- brackets
89+
local brackets = {
90+
a = { "\\langle", "\\rangle" },
91+
A = { "Angle", "Angle" },
92+
b = { "brack", "brack" },
93+
B = { "Brack", "Brack" },
94+
c = { "brace", "brace" },
95+
m = { "|", "|" },
96+
p = { "(", ")" },
97+
}
98+
```

0 commit comments

Comments
 (0)