How to make semantic token highlighting work with gopls in neovim?

This page summarizes the projects mentioned and recommended in the original post on /r/golang

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • go

    The Go programming language

  • My config based on that: lua { "neovim/nvim-lspconfig", opts = { setup = { gopls = function(_, opts) local ih = require("inlay-hints") require("lazyvim.util").on_attach(function(client, bufnr) if client.name == "gopls" then ih.on_attach(client, bufnr) -- workaround to hl semanticTokens -- https://github.com/golang/go/issues/54531#issuecomment-1464982242 if not client.server_capabilities.semanticTokensProvider then local semantic = client.config.capabilities.textDocument.semanticTokens client.server_capabilities.semanticTokensProvider = { full = true, legend = { tokenTypes = semantic.tokenTypes, tokenModifiers = semantic.tokenModifiers, }, range = true, } end end end) opts.settings = { gopls = { semanticTokens = true, analyses = { unusedparams = true, }, staticcheck = true, hints = { assignVariableTypes = true, compositeLiteralFields = true, compositeLiteralTypes = true, constantValues = true, functionTypeParameters = true, parameterNames = true, rangeVariableTypes = true, }, }, } end, }, }, }

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts