Skip to content

Instantly share code, notes, and snippets.

@muniter
Created August 28, 2021 02:46
Show Gist options
  • Save muniter/b92cf5dd5c03f89cb7284c1e285dbfd1 to your computer and use it in GitHub Desktop.
Save muniter/b92cf5dd5c03f89cb7284c1e285dbfd1 to your computer and use it in GitHub Desktop.
Luasnip
----[[
---- Beside defining your own snippets you can also load snippets from "vscode-like" packages
---- that expose snippets in json files, for example <https://github.com/rafamadriz/friendly-snippets>.
---- Mind that this will extend `ls.snippets` so you need to do it after your own snippets or you
---- will need to extend the table yourself instead of setting a new one.
--]]
local snippets_paths = function()
local plugins = { "friendly_snippets" }
local paths = {}
local path
local root_path = vim.fn.stdpath('data') .. '/site/pack/packer/start/'
for _, plug in ipairs(plugins) do
path = root_path .. plug
if vim.fn.isdirectory(path) ~= 0 then
table.insert(paths, path)
end
end
return paths
end
require("luasnip.loaders.from_vscode").lazy_load({
paths = snippets_paths(),
include = nil, -- Load all languages
exclude = {}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment