kaicataldo / material.vim

🎨 A port of the Material color scheme for Vim/Neovim
MIT License
610 stars 71 forks source link

All identifiers are red in ts files #74

Closed Andrii-Vovk closed 9 months ago

Andrii-Vovk commented 10 months ago

Hey! I just installed this theme, and for some reason it makes all the identifiers in .ts files red. Is there a way to change that? I'm really used to them being white in vscode's material theme

image

I'm using lunarvim; Here is my config:


local linters = require "lvim.lsp.null-ls.linters"
linters.setup {
  { command = "eslint", filetypes = { "typescript", "typescriptreact", "javascript", "javascriptreact" } }
}

local formatters = require "lvim.lsp.null-ls.formatters"
formatters.setup {
  {
    command = "prettier",
    filetypes = { "typescript", "typescriptreact", "javascriptreact", "javascriptreact" },
  },
}

require("lvim.lsp.manager").setup "tailwindcss"

local code_actions = require "lvim.lsp.null-ls.code_actions"
code_actions.setup {
  {
    exe = "eslint",
    filetypes = { "typescript", "typescriptreact", "javascript", "javascriptreact", "vue" },
  },
}

lvim.format_on_save.enabled = true

lvim.lsp.buffer_mappings.normal_mode['H'] = { vim.lsp.buf.hover, "Show documentation" }
lvim.keys.normal_mode["gD"] = "<cmd>lua vim.lsp.buf.declaration()<CR>"

lvim.colorscheme = "material"

lvim.plugins = {
  {
    "zbirenbaum/copilot.lua",
    cmd = "Copilot",
    event = "InsertEnter",
  },
  {
    "zbirenbaum/copilot-cmp",
    after = { "copilot.lua" },
    config = function()
      require("copilot_cmp").setup()
    end,
  },
  {
    "kaicataldo/material.vim",
    config = function()
      vim.g.material_theme_style = "default-community"
      vim.g.material_terminal_italics = true
    end,
  },
}

local ok, copilot = pcall(require, "copilot")
if not ok then
  return
end

copilot.setup {
  suggestion = {
    keymap = {
      accept = "<c-l>",
      next = "<c-j>",
      prev = "<c-k>",
      dismiss = "<c-h>",
    },
  },
}

local opts = { noremap = true, silent = true }
vim.api.nvim_set_keymap("n", "<c-s>", "<cmd>lua require('copilot.suggestion').toggle_auto_trigger()<CR>", opts)```

Appreciate any help!
Andrii-Vovk commented 10 months ago

Fixed this for now with an autocommand: "ColorScheme", { pattern = "*", callback = function() vim.cmd("highlight Identifier ctermfg=White guifg=White") end }

But it seems like a workaround, please let me know, if there is a proper solution

kaicataldo commented 10 months ago

Hiya! Do you know which TypeScript syntax highlighting plugin you're using? Here's what I see using my setup (using HerringtonDarkholme/yats.vim):

Screenshot 2024-01-19 at 7 05 45 PM

It's possible that the syntax highlighting plugin you're using is setting those values, so would be good to track down the root cause of the issue. Thanks!

Andrii-Vovk commented 10 months ago

Hey! Lunarvim uses nvim-treesitter by default. I tried disabling all the plugins that i added on top, and the issue persisted, so it seems that its an issue with treesitter? I'm pretty new to vim, so i'm not sure what are my next steps here, and this seems already out of scope here, as this is not a problem with your theme, but I would appreciate any help! Thanks!

cpmsmith commented 9 months ago

@Andrii-Vovk I expect you're getting those highlights from the TypeScript language server, not from tree-sitter. You can confirm that, as well as what highlight group it's using, by running the :Inspect ex command with your cursor on one of the symbols that's getting highlighted. For whatever reason, it looks like @lsp.type.variable links to Identifier, even though @variable doesn't.

image

You can disable highlights from the language server as described here, by removing semanticTokensProvider from the server_capabilities. Judging from the LunarVim docs, I think that would look like this:

local default_on_init = require("lvim.lsp").common_on_init
require("lvim.lsp.manager").setup("tsserver", {
  on_init = function (client)
    client.server_capabilities.semanticTokensProvider = nil
    default_on_init(client)
  end,
})

Or, if you want to keep the LSP-based highlighting, you can just unlink the one group as described in the Neovim docs: https://github.com/neovim/neovim/blob/32b49448b227588c2fbc93f89743104fd445e0a6/runtime/doc/lsp.txt#L470

Andrii-Vovk commented 9 months ago

Thank you, I really appreciate your help!

kaicataldo commented 8 months ago

@cpmsmith Thanks for digging into this!