NvChad / base46

NvChad's base46 theme plugin with caching ( Total re-write )
Other
204 stars 199 forks source link

Syntax highlighting colorscheme incorrect for Latex files when using vimtex #239

Closed mvds314 closed 1 year ago

mvds314 commented 1 year ago

Describe the bug I want to use vimtex for syntax highlighting LaTeX, as people claim it is better that treesitter this filetype.

When I open neovim, and open a LaTeX file right away, the highlighting color do no match the NvChad theme (onedark in my case), but resembes one of the vim default themes (not sure which one).

To Reproduce Steps to reproduce the behavior:

  1. Install vimtex, set up NvChad with any theme (onedark)

  2. Disable treesitter for latex like so: { "nvim-treesitter/nvim-treesitter", opts = { ensureinstalled = { "html", "css", "bash", "python", "latex", "json", "lua", "vim", "yaml" }, }, config = function(, opts) -- https://www.reddit.com/r/neovim/comments/xqogsu/turning_off_treesitter_and_lsp_for_specific_files/ require "nvim-treesitter.configs".setup { highlight = { enable = true, -- false will disable the whole extension disable = { "tex", "latex" }, -- list of language that will be disabled use_languagetree = true, }, } end, },

  3. Open neovim

  4. open a Latex file, syntax highlighting does not look good (it resembles one of the vim default themes, not sure which one).

  5. Then switch (leader+t+h) to the selected theme of NvChad

Expected behavior Step 6 should not be required

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

siduck commented 1 year ago

add event="VeryLazy" for vimtex plugin

mvds314 commented 1 year ago

Tried it like so: { "lervag/vimtex", ft = "tex", event="VeryLazy"},

But it does not solve the problem. Syntax highlighting still looks like this (intially): image After I switch theme (manually), it looks like this: image Meaning the onedark theme, as all other files look.

siduck commented 1 year ago

@mvds314 share your settings + a test latex file

mvds314 commented 1 year ago

Sure, I put my NvChadConfig on github

For a test file, any LaTeX file would suffice. For example, put this code a file called example.tex, and open it right away opening neovim.

siduck commented 1 year ago

https://github.com/NvChad/base46/assets/59060246/09197973-7c79-4b7a-ae55-b1225aafb279

i cant reproduce this issue, also treesitter latex treesitter parser seems to provide nice highlighting, then why use vimtex?

mvds314 commented 1 year ago

Let me check on my Linux machine later today.

mvds314 commented 1 year ago

Treesitter doesn't seem be doing a good job for LaTeX. I'm not sure why, but others complain about it too. So, my first though was to turn treesitter off for for tex files and use vimtex (as I need to install that anyway), maybe there are other solutions too.

The issue persist on my Linux machine.

Steps I followed:

mvds314 commented 1 year ago

I believe I fixed it. Not sure why, but my guess is my custom config was overriding the standard treesitter config. And, I should have added the line: dofile(vim.g.base46_cache .. "syntax")

So that the entire config for treesitter now looks like this:

  {
    "nvim-treesitter/nvim-treesitter",
    opts = {
      ensure_installed = { "html", "css", "bash", "python", "latex", "json", "lua", "vim", "yaml" },
    },
    config = function(_, opts)
      -- https://www.reddit.com/r/neovim/comments/xqogsu/turning_off_treesitter_and_lsp_for_specific_files/
      dofile(vim.g.base46_cache .. "syntax")
      require("nvim-treesitter.configs").setup {
        highlight = {
          enable = true, -- false will disable the whole extension
          disable = { "tex", "latex" }, -- list of language that will be disabled
          use_languagetree = true,
        },
        indent = { enable = true },
      }
    end,
  },
siduck commented 1 year ago

yes @mvds314 the dofile code is in the default config too