friendly-snippets
friendly-snippets copied to clipboard
Example of selectively applying snippets
I use LuaSnip, and have developed a number of LaTeX snippets. I am now considering adopting friendly-snippets for other languages, while keeping exclusively my own LaTeX snippets for .tex files.
Is there a clear set of instructions for doing that? It's unclear to me whether the instructions for disabling snippets in the home page will disable all tex snippets (including mine) or will only disable the friendly-snippet latex snippets.
Hi! You should be able do this by adding the following to your NeoVim config.
require("luasnip.loaders.from_vscode").load { exclude = { "tex", "plaintex" }, }
I believe the above snippet should accomplish your goal.
Generally the way to handle this will differ between snippet engines, so I will always say to refer back to their docs as this repo just supplies the snippets for the engine to load.
EDIT:
I re-read the message, the above snippet will exclude both. Let me brainstorm some ideas and I will get back to this thread asap (probably later this week).
Hi @danieleavitabile , I was successful in preventing the snippets from loading by using the exclude
field in the loader:
local vscode_loader = require("luasnip/loaders/from_vscode")
vscode_loader.lazy_load({
exclude = { "latex", "tex" }
})
However, due to how LuaSnip currently parses the files (here), it seems your request is not possible.
Alternatively, we CAN modify the priority of your snippets. See here for a recent explanation.
Hi again @danieleavitabile,
I was wrong! We CAN exclude the files like you asked (it just helps for me to INCLUDE my own LaTeX snippets in the snippets directory correctly :man_facepalming: ).
local vscode_loader = require("luasnip/loaders/from_vscode")
vscode_loader.lazy_load({
exclude = { "latex", "tex" }
})
vscode_loader.load({ paths = "/home/<$USER>/.config/nvim/snippets/"})
Let me know if this helps, then we can make an edit to the docs to provide an example with Luasnip!
Any updates @danieleavitabile? Did this work for you too?
I had no chance to try yet, sorry.
On 17 June 2024 at 05:41:31, OkelleyDevelopment @.@.>) wrote:
Any updates @danieleavitabilehttps://github.com/danieleavitabile? Did this work for you too?
— Reply to this email directly, view it on GitHubhttps://github.com/rafamadriz/friendly-snippets/issues/431#issuecomment-2172118510, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AE6AWZ6DMO5UPVKZB4NAWEDZHZLGPAVCNFSM6AAAAABFX36M66VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZSGEYTQNJRGA. You are receiving this because you were mentioned.Message ID: @.***>
Closing issue as I believe we've provided a working solution now. If further issues do arise, feel free to re-open this issue :+1: