feat(snip): warning if jsregexp is not installed

This commit is contained in:
arne314
2025-01-08 20:44:16 +01:00
parent 0b84b6c53d
commit 434dc5c6c4
2 changed files with 8 additions and 1 deletions

View File

@@ -79,7 +79,7 @@ require('typstar').setup({
### Snippets ### Snippets
1. Install [LuaSnip](https://github.com/L3MON4D3/LuaSnip/), set `enable_autosnippets = true` and set a visual mode selection key (e.g. `store_selection_keys = '<Tab>'`) in the configuration 1. Install [LuaSnip](https://github.com/L3MON4D3/LuaSnip/), set `enable_autosnippets = true` and set a visual mode selection key (e.g. `store_selection_keys = '<Tab>'`) in the configuration
2. Install [jsregexp](https://github.com/kmarius/jsregexp) as described [here](https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#transformations) (running `:lua require('jsregexp')` in nvim should not result in an error) 2. Install [jsregexp](https://github.com/kmarius/jsregexp) as described [here](https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#transformations) (You will see a warning on startup if jsregexp isn't installed properly)
3. Install [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) and run `:TSInstall typst` 3. Install [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) and run `:TSInstall typst`
4. Optional: Setup [ctheorems](https://typst.app/universe/package/ctheorems/) with names like [here](./lua/typstar/snippets/markup.lua) 4. Optional: Setup [ctheorems](https://typst.app/universe/package/ctheorems/) with names like [here](./lua/typstar/snippets/markup.lua)

View File

@@ -105,6 +105,13 @@ function M.setup()
) )
end end
luasnip.add_snippets('typst', autosnippets) luasnip.add_snippets('typst', autosnippets)
local jsregexp_ok, _ = pcall(require, "luasnip-jsregexp")
if not jsregexp_ok then
jsregexp_ok, _ = pcall(require, "jsregexp")
end
if not jsregexp_ok then
vim.notify("WARNING: Most snippets won't work as jsregexp is not installed", vim.log.levels.WARN)
end
end end
end end