Lazarus Source Editor - SQL Highlighter lazarus / 9-Editor ---------------------------------------------------------------------- paweld · 2025-12-18 16:27 Hi, Sql highlighter supports several dialects. Currently, Lazarus (source editor) does not allow you to select a specific dialect - I have not found such an option. I mainly use MSSQL, so the currently set dialect does not highlight all keywords. I would like to address this issue, but I need to gather opinions on whether it is sufficient to be able to set the target dialect in the IDE options for all sql files. Or is it necessary to set it per file, but where should it be saved - in the project settings file (,lps)? ---------------------------------------------------------------------- Martin_fr · 2025-12-18 16:41 The main question here is how to represent the choice. A very, very easy way to implement (but IMHO horrible user interface) would be to just create 15 or so copies, one for each dialect (and it will get more in future...). Then its all done already. You can set a default for extensions in the options => each file can (via context menu) override the default. I don't think I would apply that patch though. There are currently about 20 HL on offer, if you drop down the selection making that 19 + 15*sql => really doesn't convince me. So then you need an entire new setting. An easy way for that might be an IDE-wide, or slightly more involved "per project" setting. "Per project" would mean you have an option in the "project options" and while that project is open, all sql files will use that setting. A per file override (via context menu) would be very nice, but be a lot of work (I recall doing that for the HL choice, though I had to deal with old code, and compatibly for old session files...), it had been rather a good amount of work. ---------------------------------------------------------------------- Martin_fr · 2025-12-18 16:49 A bit off topic, but might be of interest here. I am doing a bit of work (on the side / slow) on the SQL HL. https://gitlab.com/freepascal.org/lazarus/lazarus/-/work_items/41952 If anyone has time to contribute - Do research, provide examples how things behave for each dialect - Test, test and test - Or better, help adding testcases / an example exist - easy to extend - has cases that are badly handled at the moment. Check if there is already a thread in the issue that relates to any addition you have to make. So all different sub-issues are having their own threads. EXCEPT FOR - If it just keywords missing in a dialect => for that open a separate issue. Otherwise that work item will grow unmaintainable huge. - an entire dialect missing => separate issue. - Not SQL related ideas (i.e. rainbow brackets, etc) => separate issue - ... ---------------------------------------------------------------------- paweld · 2025-12-18 17:00 Quote from: Martin_fr on December 18, 2025, 05:41:50 pm... Thank you very much for your opinion. In that case, I'll start by adding a global option in the Lazarus IDE settings. Quote from: Martin_frThere are currently about 20 HL on offer, if you drop down the selection making that 19 + 15*sql => really doesn't convince me. With this solution, I was thinking more along the lines of a submenu for SQL highlighting, i.e., if you select Source Editor Popup Menu > File Settings > Hihglighter > SQL, a submenu with a list of dialects will expand, and the default dialect (the first place) will be selected. ---------------------------------------------------------------------- Martin_fr · 2025-12-18 17:08 Quote from: paweld on December 18, 2025, 06:00:38 pmThank you very much for your opinion. In that case, I'll start by adding a global option in the Lazarus IDE settings.Or Project settings, that should be similar effort. Though it may have a need for redirecting calls across units to avoid circular uses... But it can always be added later, as first level of overrides. QuoteWith this solution, I was thinking more along the lines of a submenu for SQL highlighting, i.e., if you select Source Editor Popup Menu > File Settings > Hihglighter > SQL, a submenu with a list of dialects will expand, and the default dialect (the first place) will be selected. Well you can look at "SyntaxHighlighterId" in the source editor => and track where that goes. IIRC that is the per file highlighter. It has the option of following the global default, or selecting an override for a file. "unitinfo" and "editorinfo" => one of them is the session info that is stored in the lps file => and that is where "per file" settings would go. ---------------------------------------------------------------------- paweld · 2025-12-18 17:10 Quote from: Martin_fr on December 18, 2025, 05:49:38 pmA bit off topic, but might be of interest here. ... Yes, I saw your report and even downloaded your changes, but unfortunately I haven't had time to check it yet. I also had to switch to the 64-bit version of the environment recently because the 32-bit version stopped rebuilding for me - the likely cause is too many components. Because the version without additional components still rebuilds fine in 32-bit, and apart from updating Lazarus sources, I didn't update any components. ---------------------------------------------------------------------- Martin_fr · 2025-12-18 17:26 Global has the advantage that it can also affect the preview editor, so you can see result when you change colors. ---------------------------------------------------------------------- paweld · 2025-12-18 17:51 Do you think that the location Editor > General > Miscellaneous for this option would be appropriate? ---------------------------------------------------------------------- Martin_fr · 2025-12-18 18:39 I think I prefer "Markup and Matches" because it is in the color section. That page probably should be split into two, but that doesn't need to be a concern for this. From an organizational point, we have more and more color/highlight/markup settings, outside the color page itself. But IMHO we should aim to have them on sub-pages of the color. ---------------------------------------------------------------------- Martin_fr · 2025-12-18 18:44 There is a need for resource string names. They can go into the IDE. But there should be some code that maps them, that would fail to compile if dialects are added in the highlighter => so everyone will know to update the IDE. If need an   $IF high(dialect)-low(dialect)_ <> 15     $FATAL There is a resource string section in SynEdit, that would be an alternative place, but I think the name (human readable) are going to be an IDE thing. ---------------------------------------------------------------------- paweld · 2025-12-18 19:04 Wouldn't it be better to define the dialect name table in the synhighlightersql.pas file, e.g. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TSQLDialectNames: array [TSQLDialect] of String = ('General SQL', 'Interbase 6', ...); ? ---------------------------------------------------------------------- Martin_fr · 2025-12-18 19:13 Must be a resource string. (Even though, names aren't likely going to be translated, still) ---------------------------------------------------------------------- paweld · 2025-12-19 09:35 OK, thank you for your feedback. I'll start with the global option - when I'm done, I'll add a report. Once it's approved, I'll try to work on the selection for individual files. ---------------------------------------------------------------------- Martin_fr · 2025-12-20 13:10 Quote from: paweld on December 18, 2025, 06:10:58 pmQuote from: Martin_fr on December 18, 2025, 05:49:38 pmA bit off topic, but might be of interest here. ... Yes, I saw your report and even downloaded your changes, but unfortunately I haven't had time to check it yet. While others testing the new features will be something that I will heavily relay on, right now the more important part is feedback on some of the questions in the thread. That can be given without having to install the changes. My problem(s) is/are: - It's a while since I done any heavy SQL / any at all. - I haven't used the SynEdit highlighter for it ever. I have no idea what is most annoyingly going wrong. And when there are multiple ways to fix it, I have no clue which one would be best suited. So improving it based on my thoughts what may be good => will likely give poor results. One part are the questions how folding should detect if a keyword really starts a foldable statement, or if maybe text just gets edited and should be ignored. (Mind that is based on the static text, i.e. "last keypress" or caret- pos are not available) Another are to ensure I have a good set of samples for "dual kind keywords". That is keywords that depend on context for what they will highlight from. Samples must include all cases for either kind. ---------------------------------------------------------------------- paweld · 2026-08-29 18:05 I've added the ability to set a default SQL dialect for all projects, as well as to set it individually for each project - I've published the fix at: https://gitlab.com/freepascal.org/lazarus/lazarus/-/work_items/42553 I also submitted a patch that allows you to disable the “outline” option for the SQL highlighter: https://gitlab.com/freepascal.org/lazarus/lazarus/-/work_items/42554