golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.88k stars 752 forks source link

Code highlighting color error #3530

Closed miller-star closed 1 month ago

miller-star commented 1 month ago

When I enable"ui.semanticTokens": true, the syntax highlights are confused XiaojunScreenshot2024-09-11 20 03 57

hyangah commented 1 month ago

@miller-star Can you be more specific about what is the error?

If you mean the parts that are colored with the green, that is because they are also semantically considered as namespace names. The color theme you are using assigns a different color for the namespace type tokens. You can customize and adjust the color theme, too. (https://code.visualstudio.com/docs/getstarted/themes#_editor-semantic-highlighting)

miller-star commented 1 month ago

@miller-star Can you be more specific about what is the error?

If you mean the parts that are colored with the green, that is because they are also semantically considered as namespace names. The color theme you are using assigns a different color for the namespace type tokens. You can customize and adjust the color theme, too. (https://code.visualstudio.com/docs/getstarted/themes#_editor-semantic-highlighting)

I choose the vscode light theme XiaojunScreenshot2024-09-12 09 32 20 the ui.semanticTokens=true XiaojunScreenshot2024-09-12 09 37 08 the ui.semanticTokens=false XiaojunScreenshot2024-09-12 09 37 20 It seems that semantic highlighting is not working. my settings like as follows:

 "window.commandCenter": 1,
    "editor.fontSize": 15,
    "vim.easymotion": true,
    "vim.commandLineModeKeyBindings": [

    ],
    "vim.vimrc.enable": true,
    "vim.vimrc.path": "$HOME/.vimrc",
    "vscodeGoogleTranslate.preferredLanguage": "Chinese (Simplified)",
    "commentTranslate.maxTranslationLength": 99999,
    "commentTranslate.targetLanguage": "zh-CN",
    "commentTranslate.hover.content": false,
    "commentTranslate.hover.concise": true,
    "workbench.settings.applyToAllProfiles": [

    ],
    "gopls": {
        "ui.semanticTokens": true,
        "ui.completion.completeFunctionCalls": true,
        "ui.completion.usePlaceholders": true,
        "ui.completion.completionBudget": "100ms",
    },
    // "go.docsTool": "gogetdoc", // 使用gogetdoc获取方法和类的签名帮助信息
    // "go.formatTool": "goimports", // 指定代码格式化工具,其他的如gofmt goreturns goformat
    // "go.autocompleteUnimportedPackages": true, // 未完成的包会自动补全
    "go.inferGopath": true, // 让编辑器自动推断 GOPATH(包含全局的GOPATH,并沿着当前文件向上找到src目录)
    "go.useCodeSnippetsOnFunctionSuggest": true, // 使用代码片段提示,一会会继续说Snippets
    "go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
    "go.lintTool": "golangci-lint", // 代码静态检查工具,其他的如gometalinter golint revive staticcheck
    // "go.gotoSymbol.includeGoroot": true,
    "workbench.colorTheme": "Visual Studio Light",
hyangah commented 1 month ago

That color theme doesn't seem to assign a different color for namespace tokens. You can verify with different color themes. Or, you can inspect what semantic tokens are assigned by using "Developer: Inspect Editor Tokens And Scope" command. See the syntax highlighting doc I linked in my previous command.

adonovan commented 1 month ago

Closing as not actionable.