0

I have a bunch of YASnippet for a single mode and sometimes it's kind of hard to find the snippet I'm looking for in the main list.

Expected behavior:

My goal is to have snippets like this one activated in all files/buffers with "model" in its name(e.g. app/models/my_model.rb)

# that's ruby-mode/model-foo:

# -*- mode: snippet -*-
# name: model - foo activation name
# condition: (string-match-p (regexp-quote "models") (buffer-file-name (window-buffer (minibuffer-selected-window))))
# --
model_foo

And this one in files/buffers with "controller" in its name(e.g. app/controllers/another_model.rb or test/controllers/another_model.rb etc)

# that's ruby-mode/controller-foo:

# -*- mode: snippet -*-
# name: controller - foo activation name
# condition: (string-match-p (regexp-quote "controllers") (buffer-file-name (window-buffer (minibuffer-selected-window))))
# --
controller_foo

Actual behavior:

Both snippets are activated(available for selection) in all files in ruby-mode. It looks like condition: is completely ignored. I've even tried to set it as "# condition: false" and snippets are still working/visible.

What might be causing this issue?

pkg-info-package-version  yasnippet
20191222.2206
BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91

1 Answers1

0

I don't have a solution to this issue yet but I have just accidentally figured what's causing it.

The issue only in the default shortcut in Spacemacs SPC i s which uses spacemacs/helm-yas which seems to completely ignore # condition: system of YASnippet. As a(temporary?) workaround you can just use yas-insert-snippet which works very similar to spacemacs/helm-yas but the conditional system is functioning properly.

Github Issue

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91