bmalehorn / vscode-fish

Fish syntax highlighting and formatting
MIT License
62 stars 6 forks source link

Highlight the first field #12

Closed Bit0r closed 3 years ago

Bit0r commented 3 years ago

I think the first field of all lines can be highlighted, because even if it is not a fish command, it can be an external command. For example, sudo, bat, dig, etc. Specifically, the first word of each line and the first word after && | || can be highlighted. But if the end of the previous line is \, then there is no need to highlight. image

Bit0r commented 3 years ago

87216892-65d16380-c376-11ea-8aa2-622f6f7431b0

bmalehorn commented 3 years ago

Good idea. I think adding support for these should be easy:

However I'm not too sure about excluding:

whatis \
  apt

As I'm not sure the regex-based parsing used in tmlanguage files supports multi-line regex and lookbehinds. Still, I should give it a try. I like the idea of dropping highlighting for cat, test, etc. as they are often highlighted incorrectly.

Another option that could be a bigger project is to use fish_indent to parse the file, then use that for syntax highlighting. This would be more accurate since I wouldn't have to reimplement the parser; I would just use the real parser and forward the results to VSCode. I've created https://github.com/bmalehorn/vscode-fish/issues/13 to track that.

bmalehorn commented 3 years ago

@Bit0r I've now updated the syntax highlighting to only highlight functions like you described.

It doesn't have the backslash exclusion yet, but I'm pretty happy with the result!

Bit0r commented 3 years ago

very good!