Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telescope syntax highlighting is not working until I open a file #2084

Closed
Shunseii opened this issue Jun 4, 2023 · 25 comments
Closed

Telescope syntax highlighting is not working until I open a file #2084

Shunseii opened this issue Jun 4, 2023 · 25 comments

Comments

@Shunseii
Copy link

Shunseii commented Jun 4, 2023

Describe the bug
The syntax highlighting in the Telescope window is not respecting my configuration and uses the default, high-contrast colours when I first open it after opening a project. However, if I open a file and then open Telescope again, the syntax highlighting is back to normal. It's happening with all the languages that I've checked.

To Reproduce
Steps to reproduce the behavior:

  1. Navigate to a project directory
  2. Open the directory in neovim by running nvim
  3. Open Telescope with, say <leader>ff
  4. See the default syntax highlighting

Expected behavior
The syntax highlighting should be consistent and correct in the Telescope window.

Screenshots
When I initially open Telescope before opening any project files (shows the broken syntax highlighting)
image

After I open some file in the project then open Telescope again (shows the expected highlighting):
image

Desktop (please complete the following information):

  • Operating System: Pop!_OS 22.04
  • Terminal: Gnome Terminal
  • Neovim Version: V0.9.0

Additional context
I have the exact same setup on my laptop (issue occurs on my desktop) in terms of OS and NvChad configuration and I don't see it on my laptop. In fact, I wasn't even seeing this on my desktop until I installed the following LSPs with Mason by adding the following lines to ensure_installed and then :MasonInstallAll (since I realized I didn't have them installed nor explicitly required in my config):

  • "elixir-ls",
  • "eslint-lsp",
  • "julia-lsp",
  • "rust-analyzer",
  • "tailwindcss-language-server",
  • "typescript-language-server",

I've also copied over the entire custom/ directory from my laptop to my desktop (although they should've been identical from the start) to double-check, but I'm facing the same issue.

I suspect I just missed a step somewhere when I was setting it up again on my desktop (which I did after my laptop) rather than this being a bug, but I'm really at a loss as to how I can debug this :(

@siduck
Copy link
Member

siduck commented Jun 4, 2023

unable to reproduce!

make sure you have these tsparsers installed :

html css javascript typescript tsx

@Shunseii
Copy link
Author

Shunseii commented Jun 4, 2023

I verified just now with :TSInstallInfo that I have them all installed. The syntax highlighting works in almost all cases, it's just when I open the Telescope window before I open any file -- it's as if something doesn't load until I open a file? Really strange

@Shunseii
Copy link
Author

Shunseii commented Jun 4, 2023

So I backed up my custom dir and reinstalled NvChad with the example custom configuration and I still see the issue :/ And it's the same situation as before: only Telescope has the broken highlighting, but everything else works. And if I open another file then open Telescope, it works fine

Before opening any other file:
image

After I open a file:
image

@siduck
Copy link
Member

siduck commented Jun 4, 2023

thats really strange man, i cant reproduce it at all!

@vandenng
Copy link

vandenng commented Jun 5, 2023

I can reproduce the above error on a blank buffer(only on startup); however, this is due to the nvim-treesitter plugin not being loaded until a file is opened. This is due to lazy loading configuration for nvim-treesitter.

My suspicion is you are experiencing this aswell. To confirm, run :TSInstall before opening a telescope window to load the nvim-treesitter plugin and see if syntax highlighting populates properly.

@siduck
Copy link
Member

siduck commented Jun 5, 2023

@vandenng nvimtree should still load on module regardlessly ! because telescope loads it

@Shunseii
Copy link
Author

Shunseii commented Jun 5, 2023

@vandenng Ah interesting, yeah that does work!

@siduck
Copy link
Member

siduck commented Jun 6, 2023

I'm unable to reproduce . Are you all using neovim v0.10?

simplescreenrecorder-2023-06-06_05.30.39.mp4

@vandenng
Copy link

vandenng commented Jun 6, 2023

Interesting... Here is some info regarding my setup:
nvim v0.9.1
NVchad v2.0 at commit f8a489e
macOS v13.2.1

Screenshot 2023-06-06 at 7 45 25 AM Screenshot 2023-06-06 at 7 46 28 AM

@Shunseii
Copy link
Author

Shunseii commented Jun 6, 2023

I'm on nvim v0.9 and running the latest version of NvChad 2.0 on Pop OS 22.04 LTS, although I do have the exact same setup on another machine where I can't reproduce the issue, so there might be something else that could be affecting it

@siduck
Copy link
Member

siduck commented Jun 6, 2023

I'm on nvim v0.9 and running the latest version of NvChad 2.0 on Pop OS 22.04 LTS, although I do have the exact same setup on another machine where I can't reproduce the issue, so there might be something else that could be affecting it

try vanilla nvchad

@Shunseii
Copy link
Author

Shunseii commented Jun 7, 2023

Vanilla as in no custom configuration? I tried above after reinstalling and removing the custom configs, but still seeing it
image

@siduck
Copy link
Member

siduck commented Jun 7, 2023

Vanilla as in no custom configuration? I tried above after reinstalling and removing the custom configs, but still seeing it image

please try to open a lua file... or at least install the these tsparsers : html css javascript typescript tsx

@azuwis
Copy link
Contributor

azuwis commented Jun 7, 2023

@Shunseii Try adding this to ~/.config/nvim/lua/custom/plugins.lua:

return {
  {
    "nvim-telescope/telescope.nvim",
    dependencies = "nvim-treesitter/nvim-treesitter",
  },
}

@siduck
Copy link
Member

siduck commented Jun 7, 2023

i cant reproduce this issue at all... Please make sure you all have proper tsparsers installed. lazy.nvim autoloads a plugin on whenever their module gets called. Telescope whenever opened will also show the file preview which underhood still runs some code to call treesitter probably so nvim-treesitter too :/

vid.mp4

@azuwis
Copy link
Contributor

azuwis commented Jun 7, 2023

I have the some problem, adding "nvim-treesitter/nvim-treesitter" as dependencies of "nvim-telescope/telescope.nvim" fixes the problem.

If telescope need nvim-treesitter, maybe we should explicitly declare that? I can make a PR if you like to accept.

@siduck
Copy link
Member

siduck commented Jun 7, 2023

I have the some problem, adding "nvim-treesitter/nvim-treesitter" as dependencies of "nvim-telescope/telescope.nvim" fixes the problem.

If telescope need nvim-treesitter, maybe we should explicitly declare that? I can make a PR if you like to accept.

are you using latest version of neovim? like the v0.10 one

@azuwis
Copy link
Contributor

azuwis commented Jun 7, 2023

are you using latest version of neovim? like the v0.10 one

neovim v0.9.1

@strix
Copy link

strix commented Jun 7, 2023

It seems like this is a v0.9.x issue only. Not sure what changed in v0.10.x that prevents the issue from happening but I'm experiencing the same issue on 2 different machines (one running macOS, one running arch) both on v0.9.1

Either the fix above getting merged in or just having those affected manually add that change until we all get on a v0.10.x version.

azuwis added a commit to azuwis/NvChad that referenced this issue Jun 8, 2023
Fix Telescope syntax highlighting is not working until open a file
NvChad#2084
@Shunseii
Copy link
Author

Shunseii commented Jun 8, 2023

@Shunseii Try adding this to ~/.config/nvim/lua/custom/plugins.lua:

return {
  {
    "nvim-telescope/telescope.nvim",
    dependencies = "nvim-treesitter/nvim-treesitter",
  },
}

@azuwis Ah yeah this fixes the issue on my end too, thanks! 🙏🏼

@Shunseii
Copy link
Author

Shunseii commented Jun 8, 2023

@siduck Given that there's a nice workaround, I'm happy to close the issue -- should we keep open to discuss repro steps or fine to close?

@siduck
Copy link
Member

siduck commented Jun 8, 2023

@siduck Given that there's a nice workaround, I'm happy to close the issue -- should we keep open to discuss repro steps or fine to close?

i wont close this yet, provide steps to reproduce , make a video with clean nvchad installation. If im able to reproduce it too then i'll add your change or you can make a PR :)

@Shunseii
Copy link
Author

Shunseii commented Jun 8, 2023

Sounds good :) I'll try to get to this today or tomorrow!

@Shunseii
Copy link
Author

Shunseii commented Jun 9, 2023

repro.webm

Steps:

  • Backup custom dir and reinstall NvChad
  • Open a directory with nvim
  • Open Telescope window and notice that syntax highlighting is missing (for lua files in the video)
  • Open a file and then open Telescope window again -> notice the syntax highlighting is working now

Let me know if I can add any additional info that could help out or if I missed something !

@siduck
Copy link
Member

siduck commented Jun 10, 2023

thanks @Shunseii i can reproduce it too now. it didnt reproduce in my config because it had this plugin

image

So whenever I open telescope, i'll be in insert mode right? at that moment this plugin gets loaded and this plugin is related to treesitter so it calls some treesitter modules which then loads treesitter plugin.

Btw this telescope issue we're facing didnt exist before, recently telescope started using vim.treesitter** stuff instead of calling the treesitter plugin directly i think so i guess I'll merge your pr!

done : c2a0bb1

@siduck siduck closed this as completed Jun 10, 2023
camfrey pushed a commit to camfrey/NvFrey that referenced this issue Jun 23, 2023
Fix Telescope syntax highlighting is not working until open a file
NvChad#2084
feileo pushed a commit to feileo/NvChad that referenced this issue Aug 11, 2023
Fix Telescope syntax highlighting is not working until open a file
NvChad#2084
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants