From 2b5ae7b63c8233bbb11a922c852b8adeacd94b86 Mon Sep 17 00:00:00 2001 From: Aashish KC Date: Thu, 25 May 2023 03:07:40 +0545 Subject: [PATCH] feat(go): add workaround to get semantic token highlighting (#815) --- lua/lazyvim/plugins/extras/lang/go.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/go.lua b/lua/lazyvim/plugins/extras/lang/go.lua index 5ce558e1..e4036185 100644 --- a/lua/lazyvim/plugins/extras/lang/go.lua +++ b/lua/lazyvim/plugins/extras/lang/go.lua @@ -22,6 +22,28 @@ return { }, }, }, + setup = { + gopls = function() + -- workaround for gopls not supporting semantictokensprovider + -- https://github.com/golang/go/issues/54531#issuecomment-1464982242 + require("lazyvim.util").on_attach(function(client, _) + if client.name == "gopls" then + 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) + -- end workaround + end, + }, }, }, {