Why PHP files doesn't have code folding available only for curly braces ? If I inherit direct C style rendering into custom/user filetypes.php, it works, but than, I need to add all the keywords manually, which is not a problem. It works. But than, again, `^$` (variables) are not painted ... unless I put that as well into `primary` keywords line ... but, then - again - I cannot change the color of the `$variable`, the same as other words/keywords and language constructs. In C style, no other keywords than `primary` is taken into account. Is there any workaround for this instead of using/importing C style filedef ?
PHP folding on `{}` works for me.
Not surprised C lexer does not work for PHP, its a different language.
First things first: Thanks for reply. :)
PHP folding on `{}` works for me.
Not surprised C lexer does not work for PHP, its a different language.
Yes. Works for me too, and that's default. But the thing is that `[]` and `()` are not working with default php lexer, and these should provide fold/unfold markers within gutter as well.
PHP is C-style but is using HTML definitions for styling and keywords (which is, to be sincere, nowadays - wrong), therefore, when I add
``` [settings] lexer_filetype=C tag_parser=C ```
.. or `python` instead of `C` - into ".config/geany/filedefsfiletypes.php" .. fold/unfold markers do appear for all "pairs", but no color/syntax highlighting.
When I modify `[keywords=html]` into `[keywords]` and place all php related reserved words into `primary` .. colors are there .. but not `$variables` .. and when I add `^$` as last `primary` (as **nothing else but primary works**) .. I get the color for variables nicely, but it's the same color (expected, "primary") as the rest of the PHP keywords.
On top of that .. with any other C or C-alike lexer that provides working fold points for all "pairs" ( `{}`,`()` and `[]` ) .. shell style comments **are not** reckognized, as well as line comments like this one `/// ... ` or block comments like this one `/*: ... */`.
Standard `// ..` and `/* ... */` - do work.
So, to summarize .. when I modify original PHP lexer in order to enable fold points just like for lets say .. Javascript files, the best I can get is one color for all PHP related keywords (including `$variables`) and "limited" coloring for comments.
If You have some spare time, simply open any php file with some populated array/hashmap defined inside. You won't see folding point for that array. Change to Javascript or C or D filetype, and You'll get folding points.
The thing is that PHP in Geany shares HTML lexer and it is very hard to "hack" that in order to behave like it is supposed to. Arrays as well as function parameters that span accross multiple lines. Those are very common thing in PHP and scrolling or navigating via symbols is not that much elegant sometimes, especially when particular source file is not tiny, but has 1000+ lines of code.
Here are two crops.
The default PHP document fietype. ![php_geany_php](https://github.com/geany/geany/assets/20982627/792fe865-4538-44df-a865-981ef...)
The same file/area with manual javascript document type set from the Document menu. ![php_geany_javascript](https://github.com/geany/geany/assets/20982627/f93e3d35-3e2a-441b-8b22-56515...)
To be clear, identification of lexical elements for highlighting and folding is done by pieces of C++ code specific to the source language being analysed. The C lexer is different code to the PHP lexer to the shell lexer etc. The features and facilities that one lexer has is irrelevant to another lexer, so the fact that the C lexer (also used for Javascript) folds on most bracket like constructs has no implication on what the PHP lexer folds on. There is little or no documentation on what the lexers do, but from the code PHP (and embedded JS) only folds on `{}` and optionally comments, not any other constructs.
The lexers are from the [Lexilla](https://github.com/ScintillaOrg/lexilla) project, to change or add features they should be added there and they will be imported into Geany when it is updated to the relevant version.
So, there's nothing else that can be done but to use custom filetypes.php and get the partially working results until some Geany version comes out .. with improved/updated syntax for particular file types .. that depends on another .. project.
"Ok". :/
As a volunteer project with people doing things in their own time Geany would not support more than 40 filetypes as it does without being able to leverage the excellent work of other projects like Lexilla and its associated project Scintilla, and Universal CTAGS.
Yes .. I know a lots about Geany. There's no better free IDE if You ask me. Been using it since Windows 7. Last Windows I used as my daily driver. Last windows I used in general. Since early announcments of windows 8.0 .. I switched to linux - 100%. Then, I discovered **Crunchbang** Linux .. and **Geany** was there. As default editor for everything. I was looking for decent replacement for Notepad++ in those days .. and as soon as I realized how small, fast and configurable Geany is .. i forgot everything about Np++. That is .. Geany is my best co-worker .. for approx. 10yrs. And I don't want to change it. Nuff' said. This issue I have with PHP files .. I am aware of that for a long time already .. noticed .. a long time ago, but I am also aware how things work (partially, to be honnest) and how many smart people are involved in the project .. so I never bragged and complained until yesterday. If this gets fixed, it will get fixed and I am 101% satisfied. Now, I am 99..99% satistfied and .. well, I can (continue to) live like this. ;) Symbols tree is there (much better than the one from Kate or VSCode for tha matter), can compensate lack of code folding in a need of jumping and hoping trough code to a particular spot.
You need to modify lexilla's code, to get the () and [] code folding support for PHP: geany-2.0/scintilla/lexilla/lexers/LexHTML.cxx `case eScriptPHP: if ( (state != SCE_HPHP_COMMENT) && (state != SCE_HPHP_COMMENTLINE) && (state != SCE_HJ_COMMENT) && (state != SCE_HJ_COMMENTLINE) && (state != SCE_HJ_COMMENTDOC) && (!isStringState(state)) ) { if (ch == '#') { Sci_Position j = i + 1; while ((j < lengthDoc) && IsASpaceOrTab(styler.SafeGetCharAt(j))) { j++; } if (styler.Match(j, "region") || styler.Match(j, "if")) { levelCurrent++; } else if (styler.Match(j, "end")) { levelCurrent--; } } // Modify here //else if ((ch == '{') || (ch == '}') || (foldComment && (ch == '/') && (chNext == '*'))) { //levelCurrent += (((ch == '{') || (ch == '/')) ? 1 : -1); //} else if ((ch == '{') || (ch == '}') || (ch == '[') || (ch == ']') || (ch == '(') || (ch == ')') || (foldComment && (ch == '/') && (chNext == '*'))) { levelCurrent += (((ch == '{') || (ch == '[') || (ch == '(') || (ch == '/')) ? 1 : -1); } } else if (((state == SCE_HPHP_COMMENT) || (state == SCE_HJ_COMMENT || state == SCE_HJ_COMMENTDOC)) && foldComment && (ch == '*') && (chNext == '/')) { levelCurrent--; } break;`
So I think you should get a feedback to Scintilla project.
github-comments@lists.geany.org