Closed piechologist closed 2 years ago
Hi @piechologist, glad to see you're enjoying the extension!
I've gone ahead and added this syntax highlighting in https://github.com/bmalehorn/vscode-fish/commit/e8750f10d91879b12382e1c49ff6ba3db771368d:
before | after |
---|---|
![]() |
![]() |
Technically, I don't have a special rule for highlighting and
, or
, and not
. Instead, I just highlight whatever comes after the ;
. This should cover your use case but work for all functions in general. After all, and
, or
, and not
are not special syntax in fish, they're just built-in functions. Hope you enjoy!
Thank you for the quick update! Words after semicolons look perfect now.
Regarding and
, or
, and not
, fish itself classifies these as operators on the command-line (as in the universal variable fish_color_operator
). For instance, that's a screenshot from my terminal (true
and echo
are colored as commands):
Currently, true
and echo
look like plain text in VSCode:
I propose to handle and
, or
, and not
as keywords in your extension. true
and echo
would be automatically colored as commands. It would look like this (which is closer to the command-line, depending on individual color settings of course):
I fiddled with the file ~/.vscode/extensions/bmalehorn.vscode-fish-*/syntaxes/fish.tmLanguage.json
and just changed while
to while|and|or|not
inside the regexes (twice on line 57 and once on line 65). So, no need to change the logic of the syntax coloring and no fear of breaking things. What do you think?
Hi @piechologist, I'm going through and clearing out old issues.
You're right that these should be highlighted similarly to fish itself. I implemented a fix in 2fe4ccc, highlighting them as keywords.
It's not totally correct, since and
, or
, and not
are actually built-in functions and not of keywords. You could define the functions yourself like this:
function and
test $status -eq 0 && $argv
end
function or
test $status -eq 0 || $argv
end
function not
$argv
if test $status -eq 0
return 1
else
return 0
end
end
...while keywords like function
, if
, end
are parsed differently and couldn't be defined by the user.
However I'm happy to make these highlighted closer to whatever shows up in your terminal.
EDIT: Added
not
.Could you add highlighting for the keywords
and
,or
, andnot
? Also, they should change the syntax of the following words the wayif
orwhile
do.In version 1.0.20, you added function syntax highlighting for
(
,|
,&&
. I think, adding;
to this list should not do any harm.PS: Thanks a lot for this extension! I use it almost every day… 👍