L3MON4D3 / LuaSnip

Snippet Engine for Neovim written in Lua.
Apache License 2.0
3.31k stars 234 forks source link

Load snippets by project type #1141

Open RaulAxolotech opened 5 months ago

RaulAxolotech commented 5 months ago

Hello, first of all, great plugin.

Right now I'm attaching the angular snippets to typescript and html:

luasnip.filetype_extend("typescript", { "angular" }) luasnip.filetype_extend("html", { "angular" }) Now the problem that I'm facing is that when I open a Nestjs project (Typescript) then the snippets for angular are available, is it possible to define snippets by project type?

bew commented 5 months ago

How would you expect the project type to be decided? Aka how to know the file is an Angular-related file in your case?

RaulAxolotech commented 5 months ago

Angular has a configruation file in the root directory, angular.json, checking that file exists we can assume the filetype.

bew commented 4 months ago

One thing you could do is assign a dual filetype like html.angular for files that have that specific file up the file system hierarchy, this will load both htmk snippets & angular snippets afaik.

RaulAxolotech commented 4 months ago

I'll check how to do it and I'll post here how that works, thank you!