From f34d5836a69c7d7f8e4680be24cd337b63540871 Mon Sep 17 00:00:00 2001 From: Mystical-C <64483945+MysticalDevil@users.noreply.github.com> Date: Sat, 11 Nov 2023 20:59:31 +0800 Subject: [PATCH] fix: Enable some framework snippets in luasnip --- lua/devil/complete/engine/luasnip_cfg.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lua/devil/complete/engine/luasnip_cfg.lua b/lua/devil/complete/engine/luasnip_cfg.lua index a3b1ca3..6e19e2b 100644 --- a/lua/devil/complete/engine/luasnip_cfg.lua +++ b/lua/devil/complete/engine/luasnip_cfg.lua @@ -14,7 +14,9 @@ require("luasnip.loaders.from_vscode").load({ }) -- https://github.com/rafamadriz/friendly-snippets/ -require("luasnip.loaders.from_vscode").lazy_load() +vim.tbl_map(function(type) + require("luasnip.loaders.from_" .. type).lazy_load() +end, { "vscode", "snipmate", "lua" }) luasnip.config.set_config({ history = true, @@ -29,6 +31,24 @@ luasnip.config.set_config({ }, }) +local filetype_extend = require("luasnip").filetype_extend +filetype_extend("typescript", { "tsdoc", "vue" }) +filetype_extend("javascript", { "jsdoc", "vue" }) +filetype_extend("lua", { "luadoc" }) +filetype_extend("python", { "pydoc" }) +filetype_extend("rust", { "rustdoc" }) +filetype_extend("cs", { "csharpdoc" }) +filetype_extend("java", { "javadoc" }) +filetype_extend("c", { "cdoc" }) +filetype_extend("cpp", { "cppdoc" }) +filetype_extend("php", { "phpdoc" }) +filetype_extend("kotlin", { "kdoc" }) +filetype_extend("ruby", { "rdoc" }) +filetype_extend("sh", { "shelldoc" }) +filetype_extend("dart", { "flutter" }) + +-- Keybindings + vim.keymap.set({ "i", "s" }, "", function() if luasnip.expand_or_jumpable() then luasnip.expand_or_jumpable()