39

I just installed the new Android Studio and I'm looking for a way to be able to get support for CSS and JS (autocomplete, highlighting for incorrect usages) as i would in PHPStorm and also WebStorm, both intelliJ products.

I have googled and even added it to 'File Types', but stil they just display as plain text files.

0

2 Answers 2

39

You can get syntax highlighting pretty easy.

In File > Settings > Files Types, create a Javascript file type and add *.js to the registered patterns. You will need to add all the keywords.

Alternatively you can edit the XML file directly. In Ubuntu it is stored at /home/"User Name"/.AndroidStudioPreview/config/filetypes, and mine looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<filetype binary="false" default_extension="" description="Javascript" name="Javascript">
  <highlighting>
    <options>
      <option name="LINE_COMMENT" value="//" />
      <option name="COMMENT_START" value="/*" />
      <option name="COMMENT_END" value="*/" />
      <option name="HEX_PREFIX" value="" />
      <option name="NUM_POSTFIXES" value="" />
      <option name="HAS_BRACES" value="true" />
      <option name="HAS_BRACKETS" value="true" />
      <option name="HAS_PARENS" value="true" />
      <option name="HAS_STRING_ESCAPES" value="true" />
    </options>
    <keywords keywords="break;case;catch;continue;debugger;default;delete;do;else;finally;for;function;if;in;instanceof;new;return;switch;this;throw;try;typeof;var;void;while;with" ignore_case="false" />
  </highlighting>
  <extensionMap>
    <mapping ext="js" />
  </extensionMap>
</filetype>

As for autocompletion you may want to look into File Watcher, but I haven't figured it out yet. But I think if you have PHPStorm and WebStorm you already have the plugins you need for IntelliJ. And you can add custom plugins. Maybe try adding the free IDEA plugins to WebStorm ...

EDIT: In the latest Android Studio (1.0) on Windows, the location of these XMLs is the following:

.AndroidStudio\config\options\filetypes.xml :

<?xml version="1.0" encoding="UTF-8"?>
<application>
  <component name="FileTypeManager" version="11">
    <ignoreFiles list="CVS;SCCS;RCS;rcs;.DS_Store;.svn;.pyc;.pyo;*.pyc;*.pyo;.git;*.hprof;_svn;.hg;*.lib;*~;__pycache__;.bundle;*.rbc;" />
    <extensionMap>
      <mapping ext="js" type="Javascript" />
    </extensionMap>
  </component>
</application>

.AndroidStudio\config\filetypes\Javascript.xml

<?xml version="1.0" encoding="UTF-8"?>
<filetype binary="false" default_extension="" description="Javascript Files" name="Javascript Files">
  <highlighting>
    <options>
      <option name="LINE_COMMENT" value="//" />
      <option name="COMMENT_START" value="/*" />
      <option name="COMMENT_END" value="*/" />
      <option name="HEX_PREFIX" value="" />
      <option name="NUM_POSTFIXES" value="" />
      <option name="HAS_BRACES" value="true" />
      <option name="HAS_BRACKETS" value="true" />
      <option name="HAS_PARENS" value="true" />
      <option name="HAS_STRING_ESCAPES" value="true" />
    </options>
    <keywords keywords="break;case;catch;continue;debugger;default;delete;do;else;finally;for;function;if;in;instanceof;new;return;switch;this;throw;try;typeof;var;void;while;with" ignore_case="false" />
  </highlighting>
  <extensionMap>
    <mapping ext="js" />
  </extensionMap>
</filetype>
Sign up to request clarification or add additional context in comments.

9 Comments

Uhhh I have been using Android Studio and editing my js files in WebStorm. Every now n then (like right now.) Webstorm changes the IDE config(?) file n when I go back to AS, it says, "reload project" I click OK and then I get errors like, There is no output path for the APK; and Sources output directory is null for module.
Thanks for the File Types thing. That is a huge improvement ... keeping track of those {} pairs etc.
@pdschuller I really have no idea, I don't have Webstorm so I wouldn't be able to reproduce your problem. I suggest asking the jetbrains support. And it looks like from this post Intellij and WebStorm can not work as one. Sounds like a load a BS, another reason to stay away from JetBrains and their money grubbing BS
this is pretty annoying, having paid for phpstorm as well, I'd love them, but doubt they will, to let me build via phpstorm, or at least export the settings from the studio into phostorm.
on your keywords you need a ';' between default and delete :) good work sharing this, very helpful!
|
5

JS/CSS are not part of Android Studio. You'd have to install IntelliJ Ultimate edition if you need those.

In general, you won't get a feature like that which is only available in a paid version in a free tool like Android Studio or IntelliJ Community Edition.

3 Comments

good point. I already pay for phpstorm, just seems a shame I can't use them all in the same place :(
Well, NetBeans does it pretty well and is free, so why not in Android Studio?
oh wow, netbeans is still going, thats cool

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.