Skip to content

snippet not showing with show_condition=true #1327

@PapierFliegr

Description

@PapierFliegr

I defined the autosnippet sum --> \sum and the normal snippet \sum --> \sum_{}^{}. That is, if I write sum, \sum automatically expands. If I press <CR>, then limits will be added.

But when entering an inline math environment with the snippet mk --> \( $1 \) and I type in sum, then it expands to \sum but the next snippet is not listed in the completion list.
If I type sum instead, then the next snippet is shown in the completion list.

Current Behavior

mksum<CR> --> \( \sum<CR> \)

Expected Behavior

mksum<CR> --> \( \sum_{ $1 }^{ $2 } \)
mk1sum<CR> --> \( 1\sum_{ $1 }^{ $2 } \)
mkasum<CR> --> \( a\sum_{ $1 }^{ $2 } \)

What works

ms<space>sum<CR> --> \( \sum_{ $1 }^{ $2 } \)
ms,sum<CR> --> \( ,\sum_{ $1 }^{ $2 } \)

Setup

LazyVim with Luasnip and Tex extra enabled.

I use the utility file for my vimtex conditions

local M = {}

function M.math()
  return vim.fn["vimtex#syntax#in_mathzone"]() == 1
end

return M

and have the following snippets defined

local ls = require("luasnip")
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node

local tex = require("utils.conditions")
local ms = ls.extend_decorator.apply(s, { wordTrig = false }, { condition = tex.math, show_condition = tex.math })

return {
  -- Normal Snippets
  ms("\\sum", { t("\\sum_{ "), i(1), t(" }^{ "), i(2), t(" }") }),
}, {
  -- Auto Snippets
  s("mk", { t("\\( "), i(1), t(" \\)") }),
  ms("sum", t(" \\sum")),
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions