L3MON4D3 / LuaSnip

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

How to load all .vscode snippets from current working directory (cwd) #1186

Closed erlangparasu closed 4 months ago

erlangparasu commented 4 months ago

project folder: .vscode/*.code-snippets

L3MON4D3 commented 4 months ago

See https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#standalone

Basically, call require("luasnip.loaders.from_vscode").load_standalone({path = vim.fn.getcwd() .. "/.vscode/snippets.code-snippets", lazy=true}).

We can't do globbing, so if you want to load all .code-snippets in .vscode, you'll have to write some code to get them, and do one call to load_standalone for each of them.

Pass lazy=true if you have some standard-name for new .code-snippets files and want to load them as soon as they're created.

erlangparasu commented 4 months ago

@L3MON4D3 Thanks. Solved with help plenary.scandir and string.find()

in my config file: https://github.com/erlangparasu/dot-config-nvim/blob/6146f6edbd99225c7d74c12b1e769ad4ebd6c6a9/lua/config/autocmds.lua#L55