sourcekit-lsp icon indicating copy to clipboard operation
sourcekit-lsp copied to clipboard

Syntax Highlighting?

Open Napoleon-Jm opened this issue 1 year ago • 10 comments

When I want to use "tokenColorCustomizations" to define a color for swift, I found the syntax is not supported very well.

E.g. The class property name and property type be recognoized the same type token? Property name: image Property type: image

the type and the name are both meta.definition.type.body.swift and meta.definition.type.class.swift

There is some other not supported too, as the function param and function call param, and so on.

Can we supported for syntax highlighting for swift?

Napoleon-Jm avatar Jan 06 '25 02:01 Napoleon-Jm

I tried to reproduce but the only case where CBUUID isn't highlighted is when the type cannot be found. Defining struct CBUUID {} highlights it as expected. Are you able to right click on CBUUID and select Go To Definition?

Screenshot 2025-01-06 at 9 26 05 AM

plemarquand avatar Jan 06 '25 14:01 plemarquand

I tried to reproduce but the only case where CBUUID isn't highlighted is when the type cannot be found. Defining struct CBUUID {} highlights it as expected. Are you able to right click on CBUUID and select Go To Definition?

Screenshot 2025-01-06 at 9 26 05 AM

Yes it can "Go To Definition", the CBUUID is system library class from CoreBluetooth. @plemarquand

Even the NSNumber is the same effect: image

Napoleon-Jm avatar Jan 07 '25 10:01 Napoleon-Jm

Could you provide some diagnostics information by:

  1. Closing all files except except one that isn't syntax highlighting correctly
  2. Close VS Code
  3. Reopen VS Code
  4. Run the > Swift: Capture VS Code Diagnostic Bundle command, choosing Full Diagnostics
  5. Zip and attach the resulting files to this GitHub issue.

plemarquand avatar Jan 07 '25 14:01 plemarquand

Could you provide some diagnostics information by:

  1. Closing all files except except one that isn't syntax highlighting correctly
  2. Close VS Code
  3. Reopen VS Code
  4. Run the > Swift: Capture VS Code Diagnostic Bundle command, choosing Full Diagnostics
  5. Zip and attach the resulting files to this GitHub issue.

@plemarquand diagnoistics.zip

Napoleon-Jm avatar Jan 08 '25 01:01 Napoleon-Jm

Nothing is jumping out at me in the diagnostics, however the relevant responses from the LSP are redacted to protect privacy. If you're comfortable having source code and file paths included in the diagnostics you can enable extended logging in sourcekit-lsp and run another diagnose.

Regardless, since the VS Code extension has its syntax highlighting provided by sourcekit-lsp I'm going to transfer this issue to that repo.

plemarquand avatar Jan 08 '25 14:01 plemarquand

Looks like we might not have build settings for a file, the logs show Producing syntactic diagnostics from the built-in swift-syntax because we have fallback build settings. If you could enable extended logging, open the file, do a jump-to-definition on CBUUID and then capture another diagnose, that should help us figure out what’s going wrong.

ahoppen avatar Jan 08 '25 14:01 ahoppen

Synced to Apple’s issue tracker as rdar://142560819

ahoppen avatar Jan 08 '25 18:01 ahoppen

Looks like we might not have build settings for a file, the logs show Producing syntactic diagnostics from the built-in swift-syntax because we have fallback build settings. If you could enable extended logging, open the file, do a jump-to-definition on CBUUID and then capture another diagnose, that should help us figure out what’s going wrong.

not only the built-in class or struct like CBUUID, but also my custom class is not work nether. image

image

Napoleon-Jm avatar Jan 09 '25 02:01 Napoleon-Jm

If you could enable extended logging, open the file, do a jump-to-definition on CBUUID and then capture another diagnose, that should help us figure out what’s going wrong.

If you could do those steps, that would really help us determine what’s going wrong.

ahoppen avatar Jan 09 '25 20:01 ahoppen

Not fully sure how the scopes work, but I noticed that it depends on the theme I have selected for what scopes show up in this debug menu.

Here is Dark+ for a variable and its type

@Napoleon-Jm Can you let me know what theme you are using?

Image Image

Here is the same variable and type for Xcode dark theme (from the marketplace)

Image Image

jerryjefit avatar Feb 05 '25 19:02 jerryjefit

Closing because this is likely a project configuration issue (based on the fact that we see Producing syntactic diagnostics from the built-in swift-syntax because we have fallback build settings in the log) and it’s not actionable to investigate what’s going wrong here without extended logging.

ahoppen avatar Oct 25 '25 12:10 ahoppen