Autofolding in HAML files - haml

I was searching for solutions to autofold few types of files i'm using, mainly *.rb, *.scss, *.css, *.html and few other common languages.
However i can't find a solution to auto-fold a haml files. I've found those two topics but i'm not quite sure what the vimrc lines in those examples mean.
vim folding syntax for scss
How do I enable automatic folds in Vim?
Have you any idea how can i achieve that? Any help would be appreciated:)

you can customize it to your liking by manually editing a copy of the syntax file
Copy $VIMRUNTIME/syntax/haml.vim into your $HOME/.vim/syntax/ or vimfiles/syntax/ folder to customize its behavior
Modify it according to :help syn-fold (basically add the word "fold" at the end of syntax regions you want to fold)
Put this in your .vimrc to use foldmethod=syntax when editing haml files
autocmd BufRead,BufNewFile *.haml setlocal foldmethod=syntax

Related

How to disable "disallowtab" in phpcs inside vscode?

I am using vscode editing legacy php code. The phpcs extensions is great in finding potential problems. However, the old code is using tab instead of 4 spaces for indentation. phpcs would report with:
Spaces must be used to indent lines; tabs are not allowedPHPCS(Generic.WhiteSpace.DisallowTabIndent.TabsUsed)
Because it is old code, I am not planning to fix all of the tab problem. Is there any way to turn off this rule?
I tried to find phpcs config files, cannot find any. Ideally I can set a globaly, or project-wise, to disable it. Can anybody help?

Reformat unsupported files in intellij

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.

WebStorm Smarty highlighting

Is there an way to make WebStorm highlight Smarty templates? Either through plugin or some other means?
Also note, I need this for WebStorm, not PhpStorm or some other version; I don't need autocomplete or anything else -- just highlights.
Files have .tpl extension and so far I'm treating them as HTML files and I am looking for options to increase code readability with coloring.
I have tried following based on the comments:
However, resulting .tpl file still looks like

Sublime text 2 prints wrong comment block on shortcut

For some time now, when i hit cmd-/ (mac) in .php files it prints the comments for html,
and not for php.
so it does instead of //
the format is set to PHP, and it shows 'php' on the bottom right of the editor,
also all the syntax highlighting is fine.
any idea?
thanks :)
T
Sublime is decent, I prefer notepad++ and brackets for development. For your issue, uninstall than install Sublime in default, see if it works. If it does work, and you have custom plugins for it, add one at a time and test. To see what is causing the problem. If nothing is causing the problem and you have everything set to how you had it prior. I am guessing that some form of data corruption occured or the shortcut for a comment in php is mixed up with the comment in html. The text editor shouldn't be treating a completely different language as another. I hope this helped.
What commenting is done is based on the scoping rules. I'm not a PHP programmer so I might get some of the details wrong, but you should get the general idea. If I understand correctly, PHP files consist of a mix of HTML elements and PHP code blocks. ST allows for languages to be "embedded" within another file type (in this case, embedding HTML in the PHP syntax). If the cursor is in an html region, it will use HTML commenting. If it is a PHP region, it will use PHP commenting. I know there are some issues with edge cases, but try moving the cursor into the actual PHP code block, then using the comment command. You could probably find a modified language file that will just treat everything as PHP if you want.
To check the scopes begin applied, you can use the ScopeHunter plugin. Alternatively, you can use the ctrl+alt+shift+p in windows and linux or cmd+alt+p in osx to display the scope in the status bar.
I hope that helps clarify how commenting works. How you choose to actually "solve" this is up to you though, as it's more of a personal preference thing.

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)