luasnip-latex-snippets.nvim
luasnip-latex-snippets.nvim copied to clipboard
Cannot use this plugin in markdown file.
It is wonderful work. But, I meet a problem. I can use the snips in tex file but not in md file. I pin the branch to "markdown" use packer plugin manager and I add the "markdown" to the ft configuration of this plugin. But I still can not trigger any snips which I can in tex file.
Did you pass use_treesitter = true?
Stale. Closing in favor of #2.
Did you pass
use_treesitter = true?
Can you say more about that? How and Where to add this config or pass this para?
Per the README, in the setup function
require'luasnip-latex-snippets'.setup({ use_treesitter = true })
Hi, I also encountered this issue. I have set use_treesitter = true
. But the plugin is not loaded when the filetype is markdown
. Strangely, if I set :setf markdown
, the plugin is loaded and works properly, but the syntax highlighting is lost.
I guess this is an issue caused by nvim-treesitter? It changes the filetype so that Packer no longer detects a filetype as Markdown.
Now, my workaround is to remove the constraint ft = { "tex", "markdown" },
and then both syntax highlighting and snippets work properly.
Thanks for the details.
I think it's better to handle this on the plugin, instead of deferring it to packer or some such (i.e. lazy loading shouldn't be required).
I've attempted a fix on the branch lazy-loading
I tried the new branch. This time, the plugin is loaded when a Markdown file is open. However, the snippets don't work, :lua require "luasnip.extras.snippet_list".open()
returns empty. Then, with a manual setf markdown
, the snippets work again.
Are you setting ft
on packer? If so, don't. setup {} just runs a FileType autocommand now, so there shouldn't be a (non negligible) startup cost (and thus, lazy loading is unnecessary).
Note that this commit makes it so when overriding a snippet, you'd have to do it after the ft aucmd. Perhaps we should consider a interface to filter unwanted snippets by trig/name. But that doesn't cover the Greek postfix snippets.
Are you setting
ft
on packer?
No I have removed the ft
statement. I am using the default snippets without overriding snippets or adding new ones
You probably haven't enable autosnippets. This took me a while to configure out. Many snippets defined here are in autosnippet category. It's not enabled by default in luasnip.
{
'L3MON4D3/LuaSnip',
version = "2.*",
config = function()
local ls = require 'luasnip'
ls.setup({ enable_autosnippets = true })
end
},
I meet the same problem like zcysxy, I have to setf markdown
every time. After making some attempts, I find it is because of another plugin named vimwiki. In my case, when I disable vimwiki, it works well.
Did you pass
use_treesitter = true?
Can you say more about that? How and Where to add this config or pass this para?
` return { { "hrsh7th/cmp-nvim-lsp", }, { "L3MON4D3/LuaSnip", dependencies = { "saadparwaiz1/cmp_luasnip", "rafamadriz/friendly-snippets", }, }, { "hrsh7th/nvim-cmp", config = function() local cmp = require("cmp") require("luasnip.loaders.from_vscode").lazy_load()
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" }, -- For luasnip users.
}, {
{ name = "buffer" },
}),
})
end,
}, { "iurimateus/luasnip-latex-snippets.nvim", -- vimtex isn't required if using treesitter require = { "L3MON4D3/LuaSnip", "lervag/vimtex", }, config = function() require("luasnip-latex-snippets").setup({ use_treesitter = true }) end, }, } `