Reformat unsupported files in intellij - intellij-idea

How can I reformat not supported files in Intellij ?
The files I use are .tpl for the aria templates framework : http://ariatemplates.com/usermanual/latest/writing_templates
Is there a way to configure intellij to reformat code for unsupported file types ? at least the indent.
Thanks in advance.

There are a couple things you can do:
1. Settings > Editor > Code Style > Other File Types here you can define indentation for all non supported filetypes.
2. Settings > File Types here you can add new file type with pattern. You need to click plus sign and add the name and then you can configure a couple of things like syntax highlighting for some keywords, comments recognition etc.:
3. Abouve solutions didn't format the code as you would like, but it's something IDEA might you help with. To format it you can create your own plugin which would format non supported (yet) languages. There is jetbrains SDK and here you can find documentation on how to do this.

Related

PlantUML file in IntelliJ autocomplete and color formatting not working [duplicate]

I have several django projects and several different files with name utils.py, however pycharm treats them as simple .txt files with no syntax highlighting or any other kind of parsing, how can I fix this?
Please see File | Settings (Preferences on Mac) | Editor | File Types.
Look for your file name mapped to the Text type or to the Auto-detect file type by content type.
Remove the incorrect mapping and it will fix the issue.
If you still can't find the wrong mapping in the IDE settings, locate the options/filetypes.xml file in the Configuration directory. Close the IDE and either edit this file to remove the incorrect mapping or delete this file to reset all the file types to the defaults.
You can also use Revert File Type Override / Override File Type file context menu actions.
As CrazyCoder answered, my file also landed in an unintended association. In my case it was "Auto-detect file type by content". You can just try to add your file to the desired file type (e.g. Python) and PyCharm will automatically try to move the association.
FYI, a quick action to reassociate a file's type will be available in the context menu of the Project tool window in IntelliJ IDEA 2021.2 (EAPs should be available publicly around May 2021).
In my case I had to right click the file in question (a django migration) and select Mark as Python.
I probably clicked Mark as Plain Text before by mistake.
I actually solved this by going to the Project section , and then clicking Override File Type by right clicking on the specific file. Then I selected the type of the file from the list of available file types.
That worked
For me, the file somehow forgot its type. This can be overridden by
Right click the file name --> Override File Type --> Select file type.

Configure Intellij to support another java extension file

I have some app that runs bean shell scripts (*bsh) and I absolutely love Intellij IDEA. And my bsh scripts are has syntax looks similar to java syntax. How can I add support of bsh files to make it behave like it is java source files?
I tried to add association at Settings -> Editor -> File types and all I got is general syntax highlight but it still doesn't support formatting and autocomplete so the Code -> Reformat code breaks all my formatting to left aligned text.
UPD BeanShell Box doesn't work. Maybe because of its outdating
You are probably looking for BeanShell Box plugin.

Use IntelliJ code style in Checkstyle

Essentially, I want to export the code style settings from IntelliJ (the default one is fine) and use them in Checkstyle. (It's for a maven build validation kind of thing that is already setup, but we want to use IntelliJ's code style, not Sun's or Googles)
Step one should be to export the IntelliJ code style. Easier said than done, it seems.
Now, I know there is a lot of material on this on both SO and other places, but I simply cannot find the code style xml file anywhere, not even after using "copy to project" or "save as..." in the IntelliJ settings code style dialog.
I also tried exporting code style through the IntelliJ File menu, but it will only export the code style from areas that have changed (eg. change tab space from 4 to 2 and it will only export the "OTHER_INDENT_OPTIONS" part of the code style).
I should add that I'm using IDEA 14.1.4.
Is it possible to export the complete IntelliJ code style?
Unfortunately it is not possible to do what you want for (at least) three reasons, the first two of which you have already raised:
While is possible to export a code style file from Intellij IDEA using File->Settings->Code Style->Java->{Click the Settings icon}->Select Export... from the popup menu, that exported XML file only contains the changes you have made from the default settings.
Those exported settings are in a format that is only meaningful to Intellij, so even if you could export every single Java code style setting to an XML file, you would then have to massively edit that file to make it meaningful to CheckStyle.
Finally, note that there is an open request for Intellij to do exactly what you want. See IDEA-149529:
Current export functionality for Code Styles is lacking. Only useful
for other users of IntelliJ or as a backup. Only exports the diff
between user defined settings and the built-in default. This makes it
very difficult to produce a matching style for other
formatting/beautification tools.
It would be helpful if the export had the option of exports ALL the
settings IDEA uses.
However, there is an alternative approach. Instead of providing an Intellij IDEA file to Checkstyle, provide a Checkstyle file to Intellij IDEA...
Install the Checkstyle plugin, and then open two sets of one or more duplicated files in Intellij IDEA, one set configured to use IDEA's formatting and one set configured to Checkstyle's formatting.
Repeatedly tweak the Checkstyle settings until its opened file(s) are formatted to conform to the corresponding files formatted by IDEA. When the sets of files match create a Checkstyle XML rules file. Tedious, but only a one time activity.
Finally, you can then import your customized CheckStyle XML rules file into Intellij Idea, using Import Scheme -> CheckStyle Configuration as as shown in the screen shot below (if, and only if, you have installed the CheckStyle-IDEA plugin). This functionality did not exist when the OP was created. For more details see the following bug report: IDEA-61520 Codestyle from Checkstyle and in particular the response from JetBrains dated 2/8/16.
See also:
Intellij IDEA bug Configure code style from checkstyle #126
SO post IntelliJ IDEA code format from checkstyle configuration
I was looking for an answer to this too. I suppose you want to add it to your build process like I do. Since I saw no value in enforcing something that can't be automated, I settled on (haven't implemented yet) executing the style formatter as a pre-commit hook (I use git) https://www.jetbrains.com/help/idea/command-line-formatter.html against all files in the changelist. I use the defaults too, and this would be enough.
Since I don't have any customizations, I would not know if an exported code style xml would run the default in addition to the diff in the xml. Either way, there's no point in enforcing code style rules that can't be automated.

Intellij Idea how can I specify colors for a specific file type?

I am using a color theme that I am perfectly happy with, but I am dealing with a lot of ".impex" files that are unique to the Hybris platform. The IDE essentially sees them as text files. How can I add syntax coloring to these ".impex" files so the text is not just all one color?
Maybe this plugin can help you.
Syntax highlight for impex files
Besides, you can register a file pattern to a recognised file type: Preferences -> IDE Settings -> File Types.

Webstorm: how to extend to handle PHP files or even just highlight code correctly?

I tried this IDE and I like it. Only problem is that if Im in a project that has some PHP in it, its confusing to see plain black text instead of correct PHP highlight.
I dont need brutal PHP autocomplete or so, but a syntax highlight. Is it possible to achieve in Webstorm?
Or the only option is to use PHPStorm?
Why not
File Menu > Settings > File Types > click 'PHP files' > click 'Add' in the bottom screen > enter '*.php'
(instead of html with .php)
Associate the .php file extension to HTML file cause the IDE highlight at least HTML code correctly.
File Menu > Settings > File Types > click 'HTML files' > click 'Add' in the bottom screen > enter '*.php'.
UPDATE: since TextMate bundles support was added to the IDE, you can add any language syntax highlighting to the IDE if there is TextMate bundle for it. See my reply about adding Ruby highlighting, it would be the same for PHP, just the different bundle.
Your best option is to use PhpStorm. Another option is to create your custom file type for basic syntax highlighting.
A late reply, but this worked for me:
use this textmate bundle: https://github.com/textmate/php.tmbundle
Then go to settings > File Types and associate *.php to PHP files.
Hope it helps.
I tried the textmate bundle but it seems that there is an issue. I wasn't able to get highlighting. I think it is an unsolved bug, so I wonder if someone figured out how to use it.
http://youtrack.jetbrains.com/issue/WEB-11065
http://youtrack.jetbrains.com/issue/RUBY-14273
So I think I have to use PHPStorm to get basic syntax highlighting. Thats sad :/
This questions describes how to install textmate plugin which gives you syntax highlighting:
Is it possible to get Ruby syntax highlighting in PHPStorm?
The only difference is that you want to use this bundle: https://github.com/textmate/php.tmbundle
(but maybe there are better ones)