Eclipse CDT variable colors in editor - eclipse

I hope this is an OK question to ask here. It's programming related so I thought it would be better here than superuser. So I'm using the CDT C++ eclipse plugin. I know how to change the colors the editor uses for certain things. But is there a way to make it so all variables are DIFFERENT colors? For example in KDevelop, it sets local variables and class variables different colors and bolds class variables. Can I replicate that in CDT?

The Eclipse text editor offers some level of color customizations for syntax.
You can check it on: Window > Preferences > C/C++ > Editor > Syntax Coloring
There are several elements that can be changed, including Code, Assembly, Comments, Preprocessor and Doxygen.
Under Code, its possible to change the color of certain variable types, like global variables, local variable declarations, local variable references, and parameter variables.
But I don't think its able to change the color of every single variable you declared in the code. Maybe you can search for an Eclipse plugin to do that.

Related

Variable name autocomplete for VSCode Language Extension (GameMaker / GML files)?

I'm editing GML files (GameMaker Studio) in VSCode. There's a wonderful plugin, GML Support which adds autocomplete for inbuilt GML functions and instances variables along with a bunch of other cool things.
However, VSCode doesn't seem to recognise local variables in GML (see screen grab below. Dot notation works fine)
I had a look at the VSCode's Programmatic Language Extension for variable name auto-completion but still don't get how I could register the variable declaration (i.e. var fooBar = 23;) with VSCode's Language Server.
Ideally, I'd like the Language Server to respect variable scope for GML files:
global variables - any var declarations for files under script folder
any local variable declarations - all var declarations in the surrounding {...}
What would be the easiest way to add variable name completion as described above?
Thanks in advance!
Edit: looked at vscode-python to see how registerCompletionItemProvider (based on VSCode Language Extension doco) could be used. Unfortunately, still not clear to me as vscode-python seem to rely on Jedi to provide symbols?
So any points appreciated!
If you want to enable simple auto-completion, you can add the following to your settings.json (Command Palette ➜ Open Settings (JSON)):
"[gml-gms81]": { "editor.quickSuggestions": true },
"[gml-gms1]": { "editor.quickSuggestions": true },
"[gml-gms2]": { "editor.quickSuggestions": true },
which works for a workaround:
For a proper solution, well, you'll need to use the registerCompletionItemProvider and index the file on demand or as you go.
The official example demonstrates the use.
For intricacies of processing GML syntax, you can peck at the code in the Ace-based external editor that I made. Processing variable definitions specifically requires you to skip over strings, comments, and loop over values (var name[=value][, name2[=value2]]) with relative degree of confidence (which can be accomplished through a balanced parser).

Can one VS Code syntax scope reference another for theme purposes?

In VS Code, I'd like to have one textmate scope (e.g. punctuation.definition.variable) reference another one (e.g. variable.other.readwrite.global) so that the first element always uses the second element's color. Is that possible?
I am not interested in creating my own theme because I want these changes to be dynamic, to stay in effect regardless of what theme is in use. Specifically, the Perl syntax definition for $foo separates the sigil (e.g. $) and the variable name (e.g. foo) into two separate elements, and I would like to treat them as one.
In settings.json you can customize the editor workspace syntax highlighting with editor.tokenColorCustomizations and that will apply to every theme unless you specify it for some themes only.
Docs: https://code.visualstudio.com/docs/getstarted/themes#_editor-syntax-highlighting
Here you can find Docs for creating you own rule for syntax highlighting: https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide

Variable substitution in Pydev code templates

Pydev offers code templates when you create a new Python module. They include variable substitution such as ${my_variable}. How are these variables supposed to be given values?
Those "variables" are not user's variables.
Their whole list is available via button "Edit Variables...". This button appears when you edit a PyDev editor template (either creating a new one of modifying an old one). Their definitions are prefixed within PyDev. You should neither expect to define your own template variables nor expect to modify the definition of the already provided ones.

How to specify indentations on multiline parameter lists in IntelliJ Scala?

This has been bothering me for a while, but I can't seem to figure out how to change this formatting. Let's take a case class as an example:
I prefer two tabs after a line-continuation; however, IntelliJ seems to force this style:
This behavior seems to be controlled by Preferences -> Editor -> Code Style -> Scala -> Other -> Alternate indentation for constructor args and parameter declarations, which specifies a minimum of 0 spaces, and that simply brings the arg list inline with the opening parentheses. This isn't a big deal by itself, but whenever I copy/paste blocks of code, it reformats everything and I have to go back and shift-tab ad nauseam. Is there a style field that I'm missing somewhere?
There's an Intellij only solution:
Under Wrapping and Braces, disable Method declaration parameters > Use normal indent for parameters.
Then, under Other, enable Alternate indentation for constructor args and parameter declarations and set to the number of spaces you want to indent from the declaration level (in your case 4).
You want "Align when multiline" checked in the code style settings
You can also look into scalari-form plugin. It gives you much more and IDE independent. You are particuliary interested in alignArguments=true and if I remember correctly defaults should make the indentation as you want.
*Note, that it formats code after some sbt task, for instance sbt test, not when you press Ctrl+Alt+L or similiar in IntelliJ

Find all assignments to variable

Eclipse has an easy way to find all references to a variable, but is there a quick way to only look for assignments?
Quick? Hm... Find all references with Ctrl+Shift+G, then filter in the Search view (results) via the View menu (dropdown triangle). You can select Reads there to filter these.
Shortcut: Cursor to the variable, menu Search > Write Access > Workspace. No keybinding assigned by default, but you can do this as usual (Preferences > General > Keys).
Ctrl+Shift+U shows all usages of a variable, with different icons for read and write references.
You can also set different colors for read and write occurrences of the selected variable (in the right part of the editor). These colors are set in Eclipse preferences, in "General -> Editors -> Text editors -> Annotations". There is "Occurences" and "Write occurences". I set the same color, slightly darker for "Write occurence", so I can easily spot write occurences, without any key stroke.
Ctrl+Alt+U finds all the references within a class (local references) for a particular variable, on my ubuntu machine.