but they don’t do anything. Only way it works is if I visit the particular snippet file, press -c -c (load-snippet-buffer) where it tells me to enter a table. Then calling yas-expand works.
What did you expect to happen?
Using the configuration options above, I shouldn’t have to visit the snippet file every time.
You don’t need to add anything to your (elisp) config. The :editor snippets module initializes yasnippet (by both loading your snippet files and activating yas-minor-mode for you).
but they don’t do anything
I suspect that you ran M-x yas-recompile-all at some point in the past, thus all your existing snippets (at the time) were hardcoded into .yas-compiled-snippets.el files in each directory in ~/.doom.d/snippets/*/. Until you rerun this command (or delete those files), yasnippet won’t see your new snippets.
So either rerun M-x yas-recompile-all or use M-x doom-snippets-remove-compiled-snippets to delete all those .yas-compiled-snippets.el files (the better option while you’re actively working on your private snippets library).
~I tried those, including deleting .yas-compiled-snippets.el manually, but it didn’t do anything. Invoking yas-reload-all doesn’t seem to do anything either.
This is from the documentation of yas-load-snippet-buffer-and-close:
If the
snippet is new, ask the user whether (and where) to save it. If
the snippet already has a file, just save it.
As I’ve said, I get prompted to save it. So yasnippet thinks the snippet file is ‘new’. But I don’t know why. The value of +snippets-dir is ~/.doom.d/snippets, while all my snippets are under ~/.doom.d/snippets/MAJOR-MODE, could this be an issue? I don’t think so but I can’t think of anything else right now.~
Holy moly it turns out setting +snippets-dir to ~/.doom.d/snippets/MAJOR-MODE did the trick! You might want to change the :snippets documentation page.
That doesn’t make sense. +snippets-dir should be set to ~/.doom.d/snippets, not a sub-directory thereof. The only way this would work is if you are putting your snippets in ~/.doom.d/snippets/MAJOR-MODE/MAJOR-MODE/...…
Or are you literally putting your snippets in a directory named “MAJOR-MODE” in ~/.doom.d/snippets? (I.e. not replacing MAJOR-MODE with the name of a major mode, like emacs-lisp-mode)
Oh, it turns out that is what I’m doing, e.g. ~/.doom.d/snippets/MAJOR-MODE/org-mode. My apologies. In my defense, the documentation is a bit unclear, although I didn’t find anyone else with this problem so it’s probably just me
That being said, wouldn’t it be better to have something like this in the documentation:
Type a snippet trigger and press TAB to expand it. This module comes with
Doom’s official snippet library, and can be extended by adding your own
snippets to a $DOOMDIR/snippets/<name of major mode> directory, e.g.
$DOOMDIR/snippets/org-mode.
That being said, wouldn’t it be better to have something like this in the documentation:
In retrospect, it would certainly be clearer. I adopted the convention from elisp documentation, where variable arguments are capitalized (e.g. (function ARG1 ARG2)). I’ll adopt a clearer one for our new docs (that I’m cooking up in our rewrite-docs branch). Sorry for the confusion!