Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
90ef60a
refactor: put all api-function into their own class.
L3MON4D3 Jun 17, 2025
af1420c
Add more documentation.
L3MON4D3 Jun 17, 2025
91dddd0
doc: add code for generating docstrings from annotations.
L3MON4D3 Jun 17, 2025
c314824
gitignore build artifacts from doc.
L3MON4D3 Jun 17, 2025
b7abead
finish doc for init.lua, document ChoiceNode.C, update luals-mdgen.
L3MON4D3 Jun 18, 2025
8b327ce
remove doc.json, is build artifact.
L3MON4D3 Jun 18, 2025
79e7ab1
ci: add DOC.md-generation to push workflow.
L3MON4D3 Jun 18, 2025
aec181e
whoops!
L3MON4D3 Jun 18, 2025
f34a4ac
remove old comment.
L3MON4D3 Jun 19, 2025
8605dc1
nix: update luals-mdgen.
L3MON4D3 Jun 19, 2025
58b431d
make sure there are empty lines before any lists.
L3MON4D3 Jun 19, 2025
0d86256
update dictionary.
L3MON4D3 Jun 19, 2025
6948930
ci: use aspell directly for running spellcheck.
L3MON4D3 Jun 19, 2025
5130823
move DOC-template.md into ./data/.
L3MON4D3 Jun 19, 2025
ea7ba6d
doc: specify special-case of textNode as a choice.
L3MON4D3 Jun 20, 2025
7113cfe
ci: fix spell workflow.
L3MON4D3 Jun 20, 2025
c334ff1
update luals-mdgen.
L3MON4D3 Jun 20, 2025
678b5bf
spellcheck: set locale-dependent encoding, fix spellcheck_interactive.
L3MON4D3 Jun 20, 2025
0b37dca
Auto generate docs
L3MON4D3 Jun 20, 2025
592a634
Format with stylua
L3MON4D3 Jun 20, 2025
9659b9d
doc: add panvimdoc and vimdoc make-step, use in ci.
L3MON4D3 Jun 22, 2025
a3e75ee
re-generate doc.
L3MON4D3 Jun 22, 2025
9611fc1
doc: don't be too verbose about return-values.
L3MON4D3 Jun 22, 2025
964cff2
doc: add newlines in long doc-blocks.
L3MON4D3 Jun 22, 2025
338d9a9
Auto generate docs
L3MON4D3 Jun 22, 2025
6e9fc6d
doc: s/--/---/
L3MON4D3 Jun 22, 2025
357800b
doc: make sure class-doc is above @class.
L3MON4D3 Jun 22, 2025
e15ad06
annotations: replace table<x,y> with {[x]: y}.
L3MON4D3 Jun 22, 2025
5857a31
annotations: make type a bit more strict.
L3MON4D3 Jun 22, 2025
407ebb9
regenerate doc.
L3MON4D3 Jun 22, 2025
ac1ee19
update helptags after updating vimdoc.
L3MON4D3 Jun 22, 2025
06e6084
use panvimdoc-fork.
L3MON4D3 Jun 22, 2025
cdeed19
annotations: add return-type for get_snip_env.
L3MON4D3 Jun 22, 2025
11a250d
generate api-doc as subsubsubheadings.
L3MON4D3 Jun 22, 2025
8484341
panvimdoc: drop unnecessary flag.
L3MON4D3 Jun 22, 2025
b9e6223
doc: generate DOC.md once with panvimdoc-links, once without.
L3MON4D3 Jun 22, 2025
bec3c1b
doc: add empty line before list.
L3MON4D3 Jun 22, 2025
0c90008
doc: generate documentation before running luals-mdgen.
L3MON4D3 Jun 23, 2025
c49fdb2
doc: update luals-mdgen.
L3MON4D3 Jun 23, 2025
4bf7206
LuaSnip.Choice -> LuaSnip.ChoiceNode.ItemNode.
L3MON4D3 Jun 23, 2025
da6eee4
Few annotations tweaks
bew Jun 23, 2025
e0b81c1
Include changes for the other comments on #1353
bew Jun 23, 2025
4bfc49c
Apply suggestions
bew Jun 23, 2025
62c62e9
Add in-comment indent in doc annotations for top-doc & line continuation
bew Jun 23, 2025
ae20fa1
re-generate doc.
L3MON4D3 Jun 23, 2025
f5cdf05
add missing annotations.
L3MON4D3 Jun 23, 2025
707f89e
update luals-mdgen.
L3MON4D3 Jun 23, 2025
b0fdce2
add one last missing parameter.
L3MON4D3 Jun 23, 2025
3ccbb4f
shuffle around choiceNode doc.
L3MON4D3 Jun 24, 2025
a70f977
update luals-mdgen.
L3MON4D3 Jun 24, 2025
a47e5aa
make sure links are formatted correctly.
L3MON4D3 Jun 24, 2025
cd0f3c4
add missing newline before list.
L3MON4D3 Jun 24, 2025
5be06e2
update panvimdoc.
L3MON4D3 Jun 24, 2025
68faade
upate luals-mdgen.
L3MON4D3 Jun 24, 2025
fe21c82
update luals-mdgen.
L3MON4D3 Jun 24, 2025
fb4b3fa
update panvimdoc.
L3MON4D3 Jun 25, 2025
d8cee89
doc: briefly expand how to create a `LuaSnip.Addable`.
L3MON4D3 Jun 25, 2025
fbbd855
doc: add missing explanation for clean_invalidated-opts.
L3MON4D3 Jun 25, 2025
c9f081a
update panvimdoc.
L3MON4D3 Jun 25, 2025
75baad0
doc: render vimdoc-markdown with textwidth 80.
L3MON4D3 Jun 25, 2025
bd39313
doc: remove conflicting `LuaSnip.Snippet` definition.
L3MON4D3 Jun 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
shuffle around choiceNode doc.
  • Loading branch information
L3MON4D3 committed Jun 24, 2025
commit 3ccbb4f4c133ce2c4cf85f91c16230ff67c29c3f
18 changes: 8 additions & 10 deletions DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -747,20 +747,18 @@ ChoiceNodes allow choosing between multiple nodes.

<!-- panvimdoc-ignore-end -->

`c(pos, choices, opts?): LuaSnip.ChoiceNode`: Create a new choiceNode.
`c(pos, choices, opts?): LuaSnip.ChoiceNode`: Create a new choiceNode from a list of choices.
The first item in this list is the initial choice, and it can be changed while any node of a choice
is active. So, if all choices should be reachable, every choice has to have a place for the cursor
to stop at. If the choice is a snippetNode like `sn(nil, {...nodes...})` the given `nodes` have to
contain an `insertNode` (e.g. `i(1)`). Using an `insertNode` or `textNode` directly as a choice is
also fine, the latter is special-cased to have a jump-point at the beginning of its text.

* `pos: integer` Jump-index of the node. (See [Basics-Jump-Index](#jump-index))
* `choices: (LuaSnip.Node|LuaSnip.Node[])[]` A list of nodes that can be switched between
interactively. If a list of nodes is passed as a choice, it will be turned into a snippetNode.
Jumpable nodes that generally need a jump-index don't need one when used as a choice, they inherit
the choiceNode's jump-index. Additionally, one should make sure the cursor has a position to stop
at inside every choice, since changing the choice is generally only possible when inside the
choiceNode.
This means that for a choice like `sn(nil, {...nodes...})` the given `nodes` have to contain an
`insertNode` (e.g. `i(1)`), otherwise LuaSnip will just "jump through" the nodes making it
impossible to change the current choice after switching to it.
Using an `insertNode` or `textNode` directly as the choice is also fine, the latter is
special-cased to have a jump-point at the beginning of its text.
Jumpable nodes that generally need a jump-index don't need one when used as a choice since they
inherit the choiceNode's jump-index anyway.
* `opts?: LuaSnip.Opts.ChoiceNode?` Additional optional arguments.
Valid keys are:

Expand Down
22 changes: 11 additions & 11 deletions doc/luasnip.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*luasnip.txt* For NeoVim 0.7-0.11 Last change: 2025 June 23
*luasnip.txt* For NeoVim 0.7-0.11 Last change: 2025 June 24

==============================================================================
Table of Contents *luasnip-table-of-contents*
Expand Down Expand Up @@ -756,21 +756,21 @@ ChoiceNodes allow choosing between multiple nodes.
}))
<

`c(pos, choices, opts?): LuaSnip.ChoiceNode`: Create a new choiceNode.
`c(pos, choices, opts?): LuaSnip.ChoiceNode`: Create a new choiceNode from a
list of choices. The first item in this list is the initial choice, and it can
be changed while any node of a choice is active. So, if all choices should be
reachable, every choice has to have a place for the cursor to stop at. If the
choice is a snippetNode like `sn(nil, {...nodes...})` the given `nodes` have to
contain an `insertNode` (e.g. `i(1)`). Using an `insertNode` or `textNode`
directly as a choice is also fine, the latter is special-cased to have a
jump-point at the beginning of its text.

- `pos: integer` Jump-index of the node. (See |luasnip-basics-jump-index|)
- `choices: (LuaSnip.Node|LuaSnip.Node[])[]` A list of nodes that can be switched
between interactively. If a list of nodes is passed as a choice, it will be
turned into a snippetNode. Jumpable nodes that generally need a jump-index
don’t need one when used as a choice, they inherit the choiceNode’s
jump-index. Additionally, one should make sure the cursor has a position to
stop at inside every choice, since changing the choice is generally only
possible when inside the choiceNode. This means that for a choice like
`sn(nil, {...nodes...})` the given `nodes` have to contain an `insertNode`
(e.g. `i(1)`), otherwise LuaSnip will just "jump through" the nodes making it
impossible to change the current choice after switching to it. Using an
`insertNode` or `textNode` directly as the choice is also fine, the latter is
special-cased to have a jump-point at the beginning of its text.
don’t need one when used as a choice since they inherit the choiceNode’s
jump-index anyway.
- `opts?: LuaSnip.Opts.ChoiceNode?` Additional optional arguments. Valid keys
are:
- `restore_cursor?: boolean?` If set, the currently active node is looked up in
Expand Down
21 changes: 9 additions & 12 deletions lua/luasnip/nodes/choiceNode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,26 +73,23 @@ end
--- Specify functions to call after changing the choice, or entering or leaving
--- the node. The callback receives the `node` the callback was called on.

--- Create a new choiceNode.
--- Create a new choiceNode from a list of choices.
--- The first item in this list is the initial choice, and it can be changed
--- while any node of a choice is active. So, if all choices should be
--- reachable, every choice has to have a place for the cursor to stop at.
---
--- If the choice is a snippetNode like `sn(nil, {...nodes...})` the given
--- `nodes` have to contain an `insertNode` (e.g. `i(1)`). Using an `insertNode`
--- or `textNode` directly as a choice is also fine, the latter is special-cased
--- to have a jump-point at the beginning of its text.
---@param pos integer Jump-index of the node.
--- (See [Basics-Jump-Index](../../../DOC.md#jump-index))
---
---@param choices (LuaSnip.Node|LuaSnip.Node[])[] A list of nodes that can be
--- switched between interactively. If a list of nodes is passed as a choice,
--- it will be turned into a snippetNode.
--- Jumpable nodes that generally need a jump-index don't need one when used as
--- a choice, they inherit the choiceNode's jump-index.
--- Additionally, one should make sure the cursor has a position to stop at
--- inside every choice, since changing the choice is generally only possible
--- when inside the choiceNode.
--- This means that for a choice like `sn(nil, {...nodes...})` the given
--- `nodes` have to contain an `insertNode` (e.g. `i(1)`), otherwise LuaSnip
--- will just "jump through" the nodes making it impossible to change the
--- current choice after switching to it.
--- Using an `insertNode` or `textNode` directly as the choice is also fine,
--- the latter is special-cased to have a jump-point at the beginning of its
--- text.
--- a choice since they inherit the choiceNode's jump-index anyway.
---
---@param opts? LuaSnip.Opts.ChoiceNode Additional optional arguments.
---@return LuaSnip.ChoiceNode
Expand Down