Closed akthe-at closed 5 months ago
I figured out how to do it on the client side, I will close this and leave the autocommand here for any future people searching for this:
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
client.server_capabilities.semanticTokensProvider = nil
end,
})
just to be clear, there was no issue with the semantic highlighting, you just wanted to disable it because it has no effect with the theme you use?
There is an issue but I don't think it is on your end. I'm doing more research to try and pin it down
I'm seeing an issue on catppuccin, it's changing functions to blue, rather than the normal peach colour. Taken me hours to tie down what was causing it.
Do you have semantic_tokens = true ?
{ "catppuccin/nvim", lazy = true, name = "catppuccin", opts = { integrations = { aerial = true, alpha = true, cmp = true, dashboard = true, flash = true, gitsigns = true, headlines = true, illuminate = true, indent_blankline = { enabled = true }, leap = true, lsp_trouble = true, mason = true, markdown = true, mini = true, native_lsp = { enabled = true, underlines = { errors = { "undercurl" }, hints = { "undercurl" }, warnings = { "undercurl" }, information = { "undercurl" }, }, }, navic = { enabled = true, custom_bg = "lualine" }, neotest = true, neotree = true, noice = true, notify = true, semantic_tokens = true, telescope = true, treesitter = true, treesitter_context = true, which_key = true, }, }, }
I do, but also tried disabling that option in my troubleshooting and it was still changing the colour, it's fine now after doing.
setup = {
basedpyright = function()
LazyVim.lsp.on_attach(function(client, _)
if client.name == "basedpyright" then
-- Disable semantic tokens as breaking colorscheme function colours
client.server_capabilities.semanticTokensProvider = nil
end
end)
end,
Before with semantic tokens enabled in basedpyright. Notice the blue input() and print() functions: -
How it usually looks with pyright and also pylance in VSCode: -
instead of adding all that to setup, i found this an easier one liner to add to my options, vim.highlight.priorities.semantic_tokens = 95
OK cool, what does the 95 relate to?
The priority level, I believe treesitter is 100, so it allows treesitter to take precedence.
makes me wonder if a lot of the vim/neovim themes need to be updated to work with basedpyright's semantic token highlights. Consider this, before basedpyright's release I believe the average way that python/neovim users were interacting with semantic_tokens was via semshi which did not work for a lot of people and was seldom used I believe.
Folke/Tokyonight was just adding a fix for this today.
Funny enough, I was playing around with the semshi extra in LazyVim today and that’s when I noticed something was up. I thought the plug-in broke something and then I spent ages trying to find out what had changed. I even thought catppuccin had changed something, so was scouring through code to see if that was the case. It’s only when I opened the buffer and saw colours change when basedpyright popped in my Lualine that I figured out they must be related.
Please give it an upvote so we can prioritise the tickets 😊
Is there or could we get a way to disable semantic highlighting if we desire? I have other themes that support semantic tokens and there is no issue but there are others without...I was hoping perhaps I could have the ability to turn off semantic highlighting when I am using those themes?
Basedpyright Enabled:
Basedpyright disabled, only tree sitter highlights and the theme without semantic token support.