Trouble with LuaSnip detecting local snippets path
I'm using packer, and here is my luasnip config:
use({
"L3MON4D3/LuaSnip",
tag = "v2.*",
config = function()
local home = os.getenv('HOME');
local snippets = home .. '/Development/NullVoxPopuli/snippets'
require("luasnip.loaders.from_vscode").lazy_load {
paths = { snippets },
}
end
})
but! my completion provider never shows any of these. I have found that if I hard-code the path in my completion provider (blink.cmp), the snippets show up
how I do that here
require('blink.cmp').setup({
sources = {
providers = {
snippets = {
opts = {
-- supposed to be handled by luasnip
search_paths = { localEmberSnippets },
},
}
}
},
snippets = {
-- Shorthand doesn't work yet
-- preset = 'luasnip' ,
expand = function(snippet)
require("luasnip").lsp_expand(snippet)
end,
active = function(filter)
if filter and filter.direction then
return require("luasnip").jumpable(filter.direction)
end
return require("luasnip").in_snippet()
end,
jump = function(direction)
require("luasnip").jump(direction)
end,
},
})
Is there a debugging log or something I could use to figure out why LuaSnip can't find the snippets itself?
I wonder if the problem is the package.json I have that is in the snippets folder?
maybe language arrays aren't properly detected?
Here is my package.json
{
"name": "ember-snippets",
"publisher": "ember-tooling",
"displayName": "Ember Polaris Snippets - gjs, gts, tests, services, etc",
"description": "Snippets for Ember projects for quickly generating boilerplate",
"icon": "images/tbd.png",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/ember-tooling/snippets.git"
},
"bugs": {
"url": "https://github.com/ember-tooling/snippets/issues"
},
"homepage": "https://github.com/ember-tooling/snippets#readme",
"version": "0.0.0",
"categories": [
"Snippets"
],
"engines": {
"vscode": ">= 1.0.0"
},
"keywords": [
"Ember",
"TypeScript",
"JavaScript",
"Snippets",
"Polaris",
"Tests",
"Testing",
"Services",
"Boilerplate",
"HTML"
],
"contributes": {
"snippets": [
{
"language": [
"Glimmer JS",
"javascript.glimmer",
"Glimmer TS",
"typescript.glimmer"
],
"path": "./snippets/all.json"
},
{
"language": [
"Glimmer JS",
"javascript.glimmer"
],
"path": "./snippets/javascript.glimmer.json"
},
{
"language": [
"Glimmer TS",
"typescript.glimmer"
],
"path": "./snippets/typescript.glimmer.json"
},
{
"language": "javascript",
"path": "./snippets/javascript.json"
},
{
"language": "typescript",
"path": "./snippets/typescript.json"
}
]
},
"scripts": {
"lint:fix": "prettier . --write",
"publish": "npm version patch; vsce publish",
"build": "npm run build_readme; npm run dups; npm run count; npm run countTS; npm run countHTML; npm run countJS; npm run countJson",
"build_readme": "cat src/README_top.md > README.md; npm run generate_readme_table; cat src/README_bottom.md >> README.md;",
"generate_readme_table": "cat src/snippets.json | grep 'prefix\\|description' | sed -e \"s/description//\" | sed -e \"s/prefix//\" | sed -e 's/ \"\": \"//' | sed -e 's/\",//' | sed -e 'N;s/\\n/ | /' | sed -e 's/$/ |/g' | sed -e 's/^/| /' | sort >> README.md",
"dup_snippet": "cat src/snippets.json | grep '\": {' | sort | uniq -d",
"dup_name": "cat src/snippets.json | grep 'prefix' | sort | uniq -d",
"dups": "npm run dup_snippet; npm run dup_name",
"count": "cat src/snippets.json | grep 'prefix' | wc -l",
"countTS": "cat snippets/typescript.json | grep 'prefix' | wc",
"countHTML": "cat snippets/html.json | grep 'prefix' | wc",
"countJS": "cat snippets/javascript.json | grep 'prefix' | wc",
"countJson": "cat snippets/json.json | grep 'prefix' | wc",
"patch": "npm version patch"
},
"devDependencies": {
"prettier": "^3.5.3"
}
}
Hi :)
You can increase the loglevel before the call to lazy_load (require("luasnip").log.set_loglevel("info")), open a new instance, let it load the snippets, and then check the log via require("luasnip").log.open(). There should be some information about which paths are actually searched.
You can also check whether luasnip really has/hasn't loaded these snippets via :LuaSnipListAvailable