Skip to content

Commit

Permalink
Add dependency on jsregexp to doc+readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
L3MON4D3 committed Aug 12, 2022
1 parent af5b5e4 commit ce2340c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,8 @@ tabstop/placeholder/choice which will be visited just before the new `$0`. This
new `$0` will be inserted at the (textually) earliest valid position behind the
invalid `$0`.

## Snipmate

It is furthermore possible to parse snipmate-snippets (this includes support for
vimscript-evaluation!!)
Snipmate-snippets have to be parsed with a different function,
Expand All @@ -1101,6 +1103,25 @@ Snipmate-snippets have to be parsed with a different function,
ls.parser.parse_snipmate("year", "The year is `strftime('%Y')`")
```

`parse_snipmate` is the same as `parse_snippet`, only the snippet-body is parsed
differently.

## Transformations

To apply
[Variable/Placeholder-transformations](https://code.visualstudio.com/docs/editor/userdefinedsnippets#_variable-transforms),
luasnip needs to apply ECMAScrip-regexes.
This is implemented by relying on [`jsregexp`](https://github.com/kmarius/jsregexp).
`jsregexp` is available as a luarock, and, as such, can be installed by
`packer.nvim` (although actual usage may require a small workaround, see
[here](https://github.com/wbthomason/packer.nvim/issues/593) or
[here](https://github.com/wbthomason/packer.nvim/issues/358)).
Alternatively, the repo can be cloned, `make`d, and the resulting `jsregexp.so`
placed in some place where nvim can find it (probably `~/.config/nvim/lua/`).

If `jsregexp` cannot be found, luasnip and omits the transformation and just
inserts the input.

# VARIABLES

All `TM_something`-variables are supported with two additions:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ https://user-images.githubusercontent.com/41961280/122515860-5179fa00-d00e-11eb-

# Drawbacks
- Snippets that make use of the entire functionality of this plugin have to be defined in Lua (but 95% of snippets can be written in lsp-syntax).
- The LSP-parser does not support Regex-Transformations.

# Requirements
Neovim >= 0.5 (extmarks)
`jsregexp` for lsp-snippet-transformations.

# Setup
## Install
Expand Down

0 comments on commit ce2340c

Please sign in to comment.