I can not format my code by Webstorm which looks like terrible.How to fix it ?
You can try making nunjucks mimic a language that WebStorm does support, by setting the tags option.
Or just use an IDE that supports Jinja2 templates. If you're stuck with JetBrains, PyCharm could suit you.
I've tried these,but It's not much helpful!
Duplicate of #431?
That's pretty easy.
Example of my configuration:
module.exports = function (app, nunjucks, dir) {
app.set('views', dir.views);
app.set('view engine', 'nunj');
app.set('view cache', app.get('env') === 'production');
nunjucks.configure('views', {
autoescape: true,
express: app
});
app.use(function (req, res, next) {
res.locals.user = req.session.user || false;
next();
});
};
Works like a charm :-) I switched from Swig that is no longer maintained to this one in no time.
I use Webstorm 10.0.
I can't find Twig. All my files started with T are there.

I can't find any Twig plugins.

Oh. My bad. I use phpstorm and there is twig support by default and plugin in repository. I understand that phpstorm plugin won't work with webstorm? Then I can't help you. You can try to install plugin from disk.
@dariuszp I download Twig from PhpStorm Plugins. Then I install it to WebStorm.I works! Wonderful !

Thank you!
I'm glad that I could help. Good luck.
Hi there, I get the following message trying to do it:
"Plugin Twig Support is incompatible with current installation"
ideas?
Old webstorm? Can you provide any details?
Webstorm 8.0.4
@cmdelatorre Please file a bug on the appropriate repo (perhaps the twig plugin?), thanks!
(feel free to keep discussing it here if desired, but I'd like to close the bug)
Sure, no worries.
Just to help anyone else out who ends up here looking for an answer, I was able to download the intellij twig plugin and install it manually into the latest webstorm. It seems to work.
Also, you don't need to install it _manually_.
You can install Twig in WebStorm from File > Settings > Plugins > Install JetBrains plugin,
and then you look for "Twig Support" in the list.
i found just install twig is not use,you should do this
preference-> Editor-> File Types find Twig (you should install before),then add *.nunjucks at the under block , then apply
Then you will find your nunjucks code changed

I come from 2018 with a Mac...
In WebStorm 2018.3 for Mac, you can install Twig from WebStorm > Preferences > Plugins and then look for "Twig Support" in the marketplace. With Twig installed, you can tell it to highlight your nunjucks file through the way showed in @MehmetNuri's screenshot.
Thanks all. Meow~
This appears to crash Webstorm 2020.3 EAP due to some missing PHP string dependency.
Most helpful comment
That's pretty easy.
Example of my configuration:
Works like a charm :-) I switched from Swig that is no longer maintained to this one in no time.