Closed mroavi closed 3 years ago
These should be fixed by #231 (they will actually all be highlighted as JuliaFunctionCall
).
This line shows up in my highlights:
(I also tried the typo version JuliaFuncionCall
that you wrote above, but got the same results)
and here is how the examples above appear highlighted:
So this is why I don't think it is fixed. Could it be that I'm doing something wrong?
By the way, the piece of code I showed above is not a function call but rather a function definition (one with shorter syntax than the one that uses the function
keyword, but they are equivalent)
Yes, but it will be fixed if/when #231 is merged.
As for detecting function definitions performed with assignments, I think it's basically impossible to do in any reasonable way with vim, because the =
sign that determines the interpretation comes an arbitrary number of tokens after the function name, and thus the highlighting would need to go backwards (whereas vim highlighting proceeds in the forward direction only, with some very, very limited and expensive looking-back capabilities).
Ohh I see. Thanks for the clarification!
Sorry to bother you again but the problem doesn't seem to be fixed with the new updates:
The left product
is a function name definition and should be highlighted with juliaFunctionName
. The product
in the right is a function call and it is correctly highlighted with juliaFunctionCall
These two function definitions are equivalent, and hence should have the same color highlighting:
As for detecting function definitions performed with assignments, I think it's basically impossible to do in any reasonable way with vim, because the = sign that determines the interpretation comes an arbitrary number of tokens after the function name, and thus the highlighting would need to go backwards (whereas vim highlighting proceeds in the forward direction only, with some very, very limited and expensive looking-back capabilities).
Ohh right. Sorry I missed that. Completely forgot about it. Hmm I wonder how VS Code or Atom do it.
Would it be helpful if I ask one of the maintainers?
I think that they have a running julia session and leverage Julia itself for determining the syntactic role of each token. This is not how syntax highlighting (currently) works in vim.
No, VSCode's syntax highlighting is regex based as well. We're matching short-form function definitions with this, which works ok in many cases (but can also very easily break, see e.g. https://github.com/JuliaEditorSupport/atom-language-julia/issues/240). AFAICT vim's regex engine supports both positive and negative lookaheads, so a similar implementation should be possible here as well.
Ah I see, thanks for correcting me. Anyway, the problem with that regex is the arguments part \\(.*\\)
which is what can so easily break. To do it right (in vim) one has to use a syntax region, opened by something like "identifier("
and ended by ") ="
, but the opening matches both a function call and a function def, and there is no way to discriminate based on the ending part. And I can't think of any work around to obtain that effect.
This is a function definition in assignment form:
add
is highlighted as ajuliaModuleBlock
while it should be highlighted as ajuliaFunctionName
.Another case:
IndexStyle
is highlighted asjuliaBaseTypeArray
while I think it should bejuliaFunctionName
.