34

WebStorm didn't support Vue.js natively (at least for now - Apr, 2016).

I've find few advice how to improve WebStorm experience. Now I want to list them in one place (I'll answer my own question below).

Feel free to improve the answer

S Panfilov
  • 16,641
  • 17
  • 74
  • 96

4 Answers4

79

WebStorm now supports vue.js (starting from 2017.1 [blog])

So no additional steps required


DEPRECATED

This is the checklist of ways to improve WebStorm(PhpStorm, Idea, etc.) experience:

  1. Use Vue.js plugin.

UPDATE: Both plugins have own problems atm

You can install it via Settings(Preferences) => Plugins => Browse repositories => (search for) "vue"

choose one or both: "Vue.js" or "vue-for-idea". It's up to you.

  1. Set "Javascript Language Version" to ES6.

Open Settings(Preferences) => Language & Frameworks => JavaScript. Set Javascript Language Version to ECMAcript6

https://github.com/postalservice14/vuejs-plugin

  1. Improve HTML-tag's attributes highlighting

Open Settings(Preferences) => Editor => Inspection => HTML => select Unknown HTML tag attributes => click Custom HTML tag attributes. Add your attributes.

For example, my list:

v-on,v-on:click,v-on:change,v-on:focus,v-on:blur,v-on:keyup,:click,@click,v-model,v-text,v-bind,:disabled,@submit,v-class,:class,v-if,:value,v-for,scoped,@click.prevent,number,:readonly,@input,@click,v-show,v-else,readonly,v-link,:title,:for,tab-index,:name,:id,:checked,transition,@submit.prevent,autocapitalize,autocorrect,slot,v-html,:style

P.S. For the full list of custom tags check @Alex's answer below

P.P.S. Actually it's should work in more common way:

Open Settings(Preferences) => Languages & Frameworks => Javascript => Libraries => click Add (after this you should set path to the vue.js. You can dowmload it with npm or whatever)

(More info in this answer: https://stackoverflow.com/a/28903910/930170)

But I didn't get success with that.

  1. Enable Node.js Coding Assistance:

Open Settings(Preferences) => Languages & Frameworks => Node.js and NPM

If "Node.js core library is not enabled", click button Enabled


DEPRECATED (may be required if you don't use vue plugins for IDE):

  1. Make *.vue files to be recognized as a html flies.

Open Settings(Preferences) => Editor =>File Types find HTML in Recognized File Types, then add *.vue as a new Registered Patterns.

  1. Improve ES6 highlight.

In each vue file with tag:

    <script type="text/babel">
        // your code here...
    </script>

(This is would help to recognise constructions like setTimeout(() => {console.log(1) }, 100))

  1. Improve styles highlight. (sass, scss, etc)

In each vue file with tag:

    <style lang="sass" rel="stylesheet/sass">
        // your style here...
    </style>

For scss it's gonna be <style lang="scss" type="text/scss">

For stylus please try <style lang="stylus" type="text/stylus">


UPD: The steps below are not so trusted, they may helps, or may not, some of them I didn't check personally, or I didn't catch is any effect exist or not.

  1. Import TextMate Bundle functionality.

https://www.jetbrains.com/help/phpstorm/2016.1/textmate-bundles.html?origin=old_help

  1. Import TypeScript tables for vue.

Open Settings(Preferences) => Language & Frameworks => JavaScript => Libraries. Click Download, Switch to TypeScript community stubs. And download all tabs with vue word.

Example: https://youtu.be/4mKiGkokyx8?t=84 (from 1:24)


UPD2: For more info check the issue at github: https://github.com/vuejs/vue-syntax-highlight/issues/3


UPD3: FAQ:

  1. Can I improve pug(jade) highlight?

    • No. Because Webstorm doesn't support template language injection... Issue has been up since 2013 with no official word.
S Panfilov
  • 16,641
  • 17
  • 74
  • 96
  • The trick ` – Namek Aug 22 '16 at 21:28
  • 1
    oh, figured it out. `` is what worked for me. – Namek Aug 22 '16 at 21:38
  • 1
    For improve HTML-tag's attributes highlighting be aware about XML inspection which can cause problems with html inspection. – Jaroslav Klimčík Nov 16 '16 at 09:07
  • Thanks for this exhaustive analysis, which was a great help. However neither of the plug-ins are any good in WebStorm for the reasons you stated. Nor did the list of extra HTML tag attributes make any difference, for some reason. What **does** work is assigning .vue files to HTML, and then using vue shorthand - i.e. @ instead of v-on, and just ':' instead of v-bind. However I would much prefer v-on to @, because it says what it's doing. – mwarren Nov 22 '16 at 12:54
  • 2
    Anyone here have a clue on how to modify the default tab indentation spacing for the template area? Using the vue.js plugin, everything is good but i'm not able to change the tab spacing from 4 to 2. Same thing is also true for styles. Only the script area reads in the tab spacing settings. – uptownhr Jan 16 '17 at 04:32
  • Is there any way to use the official plugin in IntelliJ IDEA? I can clone the plugin from the official git repository alright but I couldn't find a way to build and install it... Also it doesn't seem to be available yet in the list of official plugins if I try to directly install from `Settings`. I would rather just stick to IntelliJ IDEA for all my developments instead of having to explicitly launch WebStorm for this purpose. – xji Mar 13 '17 at 11:11
  • @JIXiang have no ideas about plugin. But you can do all the way work around and make it work without plugin (see deprecated section above) – S Panfilov Mar 13 '17 at 12:44
  • I am still not able to use vue in webstorm, even though I am using Wbstorm 2017. Any ideas? – Yasser Hussain Mar 20 '17 at 16:57
  • @YasserHussain That's weird. Are you sure, that you're using a correct version, cause it's in Early Access Preview right now. Otherwise you can try to follow up this answer – S Panfilov Mar 21 '17 at 03:58
  • @SergeyPanfilov *.vue was under JSX file type for some reason. Fixed it. No worries. – Yasser Hussain Mar 21 '17 at 05:36
17

I updated the list of unknown HTML tags so you just have to copy-paste this in the PhpStorm setting :

nobr, noembed, comment, noscript, embed, script, :checked, :class, :click, :disabled, :for, :id, :name, :readonly, :style, :title, :value, @click, @click.prevent, @click.stop, @click.capture, @click.self, @drag, @drag.prevent, @drag.stop, @drag.capture, @drag.self, @dragend, @dragend.prevent, @dragend.stop, @dragend.capture, @dragend.self, @dragenter, @dragenter.prevent, @dragenter.stop, @dragenter.capture, @dragenter.self, @dragleave, @dragleave.prevent, @dragleave.stop, @dragleave.capture, @dragleave.self, @dragover, @dragover.prevent, @dragover.stop, @dragover.capture, @dragover.self, @dragstart, @dragstart.prevent, @dragstart.stop, @dragstart.capture, @dragstart.self, @drop, @drop.prevent, @drop.stop, @drop.capture, @drop.self, @input, @input.prevent, @input.stop, @input.capture, @input.self, @submit, @submit.prevent, @submit.stop, @submit.capture, @submit.self, scoped, slot, tab-index, v-bind, v-class, v-else, v-for, v-html, v-if, v-link, v-model, v-on, v-on:input, v-on:input.prevent, v-on:input.stop, v-on:input.capture, v-on:input.self, v-on:submit, v-on:submit.prevent, v-on:submit.stop, v-on:submit.capture, v-on:submit.self, v-on:blur, v-on:blur.prevent, v-on:blur.stop, v-on:blur.capture, v-on:blur.self, v-on:change, v-on:change.prevent, v-on:change.stop, v-on:change.capture, v-on:change.self, v-on:click, v-on:click.prevent, v-on:click.stop, v-on:click.capture, v-on:click.self, v-on:focus, v-on:focus.prevent, v-on:focus.stop, v-on:focus.capture, v-on:focus.self, v-on:keypress, v-on:keypress.prevent, v-on:keypress.stop, v-on:keypress.capture, v-on:keypress.self, v-on:keyup, v-on:keyup.prevent, v-on:keyup.stop, v-on:keyup.capture, v-on:keyup.self, v-on:keyup.enter, v-on:keyup.enter.prevent, v-on:keyup.enter.stop, v-on:keyup.enter.capture, v-on:keyup.enter.self, v-on:keyup.tab, v-on:keyup.tab.prevent, v-on:keyup.tab.stop, v-on:keyup.tab.capture, v-on:keyup.tab.self, v-on:keyup.delete, v-on:keyup.delete.prevent, v-on:keyup.delete.stop, v-on:keyup.delete.capture, v-on:keyup.delete.self, v-on:keyup.esc, v-on:keyup.esc.prevent, v-on:keyup.esc.stop, v-on:keyup.esc.capture, v-on:keyup.esc.self, v-on:keyup.space, v-on:keyup.space.prevent, v-on:keyup.space.stop, v-on:keyup.space.capture, v-on:keyup.space.self, v-on:keyup.up, v-on:keyup.up.prevent, v-on:keyup.up.stop, v-on:keyup.up.capture, v-on:keyup.up.self, v-on:keyup.down, v-on:keyup.down.prevent, v-on:keyup.down.stop, v-on:keyup.down.capture, v-on:keyup.down.self, v-on:keyup.left, v-on:keyup.left.prevent, v-on:keyup.left.stop, v-on:keyup.left.capture, v-on:keyup.left.self, v-on:keyup.right, v-on:keyup.right.prevent, v-on:keyup.right.stop, v-on:keyup.right.capture, v-on:keyup.right.self, v-show, v-text, v-on:drag, v-on:drag.prevent, v-on:drag.stop, v-on:drag.capture, v-on:drag.self, v-on:dragend, v-on:dragend.prevent, v-on:dragend.stop, v-on:dragend.capture, v-on:dragend.self, v-on:dragenter, v-on:dragenter.prevent, v-on:dragenter.stop, v-on:dragenter.capture, v-on:dragenter.self, v-on:dragleave, v-on:dragleave.prevent, v-on:dragleave.stop, v-on:dragleave.capture, v-on:dragleave.self, v-on:dragover, v-on:dragover.prevent, v-on:dragover.stop, v-on:dragover.capture, v-on:dragover.self, v-on:dragstart, v-on:dragstart.prevent, v-on:dragstart.stop, v-on:dragstart.capture, v-on:dragstart.self, v-on:drop, v-on:drop.prevent, v-on:drop.stop, v-on:drop.capture, v-on:drop.self, @focus, @focus.prevent, @focus.stop, @focus.capture, @focus.self, @change, @change.prevent, @change.stop, @change.capture, @change.self, @blur, @blur.prevent, @blur.stop, @blur.capture, @blur.self, @keypress, @keypress.prevent, @keypress.stop, @keypress.capture, @keypress.self, @keyup, @keyup.prevent, @keyup.stop, @keyup.capture, @keyup.self, v-on:reset, v-on:reset.prevent, v-on:reset.stop, v-on:reset.capture, v-on:reset.self, @reset, @reset.prevent, @reset.stop, @reset.capture, @reset.self, v-on:keydown, v-on:keydown.prevent, v-on:keydown.stop, v-on:keydown.capture, v-on:keydown.self, @keydown, @keydown.prevent, @keydown.stop, @keydown.capture, @keydown.self, v-on:mousenter, v-on:mousenter.prevent, v-on:mousenter.stop, v-on:mousenter.capture, v-on:mousenter.self, v-on:mouseover, v-on:mouseover.prevent, v-on:mouseover.stop, v-on:mouseover.capture, v-on:mouseover.self, v-on:mousemove, v-on:mousemove.prevent, v-on:mousemove.stop, v-on:mousemove.capture, v-on:mousemove.self, v-on:mousedown, v-on:mousedown.prevent, v-on:mousedown.stop, v-on:mousedown.capture, v-on:mousedown.self, v-on:mouseup, v-on:mouseup.prevent, v-on:mouseup.stop, v-on:mouseup.capture, v-on:mouseup.self, @mousenter, @mousenter.prevent, @mousenter.stop, @mousenter.capture, @mousenter.self, @mouseover, @mouseover.prevent, @mouseover.stop, @mouseover.capture, @mouseover.self, @mousemove, @mousemove.prevent, @mousemove.stop, @mousemove.capture, @mousemove.self, @mousedown, @mousedown.prevent, @mousedown.stop, @mousedown.capture, @mousedown.self, @mouseup, @mouseup.prevent, @mouseup.stop, @mouseup.capture, @mouseup.self, v-on:dblclick, v-on:dblclick.prevent, v-on:dblclick.stop, v-on:dblclick.capture, v-on:dblclick.self, v-on:contextmenu, v-on:contextmenu.prevent, v-on:contextmenu.stop, v-on:contextmenu.capture, v-on:contextmenu.self, v-on:wheel, v-on:wheel.prevent, v-on:wheel.stop, v-on:wheel.capture, v-on:wheel.self, v-on:mouseleave, v-on:mouseleave.prevent, v-on:mouseleave.stop, v-on:mouseleave.capture, v-on:mouseleave.self, v-on:mouseout, v-on:mouseout.prevent, v-on:mouseout.stop, v-on:mouseout.capture, v-on:mouseout.self, v-on:select, v-on:select.prevent, v-on:select.stop, v-on:select.capture, v-on:select.self, @dblclick, @dblclick.prevent, @dblclick.stop, @dblclick.capture, @dblclick.self, @contextmenu, @contextmenu.prevent, @contextmenu.stop, @contextmenu.capture, @contextmenu.self, @wheel, @wheel.prevent, @wheel.stop, @wheel.capture, @wheel.self, @mouseleave, @mouseleave.prevent, @mouseleave.stop, @mouseleave.capture, @mouseleave.self, @mouseout, @mouseout.prevent, @mouseout.stop, @mouseout.capture, @mouseout.self, @select, @select.prevent, @select.stop, @select.capture, @select.self, v-bind:key

I would have commented your previous answer, but the character limit prevented me to do so.

Note : there are many more events available, and I only hand picked the most common ones, in my own opinion.

Alex
  • 1,241
  • 13
  • 22
3

I circumvent template-injection with separate template-files which is not very nice ...

<template lang="pug" src="./MyComponent.pug">
Psi
  • 474
  • 4
  • 14
3

WebStorm started supporting VueJS officially See their blog

But now It's only working in Early Access Preview Build

Ahmed Sabry
  • 434
  • 1
  • 8
  • 17