Can I disable friendly-snippets only for one language? #1854
-
Contributing guidelines
Module(s)mini.snippets QuestionAfter tinkering around with mini.snippets and overriding the latex snippets from friendly-snippets I noticed I'm better off simply writing my own instead of using the ones provided by default (although I'm using them as inspiration). Is there any way to do this? I've been thinking of removing this part from my config and instead naming my snippet as simply "tex.json" but that seems a bit hacky. Is there any other way to go about doing this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hello @hownioni, Can you try: local mini_snippets, config_path = require("mini.snippets"), vim.fn.stdpath("config")
local latex_patterns = { "latex/**/*.json", "**/latex.json" }
local lang_patterns = { tex = latex_patterns, plaintex = latex_patterns }
mini_snippets.setup({
snippets = {
mini_snippets.gen_loader.from_file(config_path .. "/snippets/global.json"),
mini_snippets.gen_loader.from_runtime(latex_patterns[1], { all = false }),
mini_snippets.gen_loader.from_runtime(latex_patterns[2], { all = false }),
mini_snippets.gen_loader.from_lang({lang_patterns = lang_patterns}),
},
}) The order is important. Now, when for example the Option |
Beta Was this translation helpful? Give feedback.
-
My suggestion would be to do exactly like this. It is not hacky at all and is the suggested way to customize language-specific snippets. You'd not have to remove the part completely, but it can be something like this: -- Adjust language patterns
local latex_patterns = { 'my-tex.json' }
local lang_patterns = {
tex = latex_patterns, plaintex = latex_patterns,
-- Recognize special injected language of markdown tree-sitter parser
markdown_inline = { 'markdown.json' },
}
local gen_loader = require('mini.snippets').gen_loader
require('mini.snippets').setup({
snippets = {
gen_loader.from_lang({ lang_patterns = lang_patterns }),
},
}) This will load the file named 'my-tex.json' which should be present in ' The same approach can be done for all other languages: create specific 'my-xxx.json' file and add |
Beta Was this translation helpful? Give feedback.
My suggestion would be to do exactly like this. It is not hacky at all and is the suggested way to customize language-specific snippets.
You'd not have to remove the part completely, but it can be something like this: