JoosepAlviste / nvim-ts-context-commentstring

Neovim treesitter plugin for setting the commentstring based on the cursor location in a file.
MIT License
1.13k stars 34 forks source link

`set ft?` return `filetype=on` and causing losing syntax highlighting #87

Closed kohane27 closed 7 months ago

kohane27 commented 9 months ago

Minimal reproducible full config

Please see the video below. Thank you!

Description

:set ft? return filetype=on and causing losing syntax highlighting

Actual behavior

https://github.com/JoosepAlviste/nvim-ts-context-commentstring/assets/57322459/a63603f9-0d4b-4767-8446-9fb4b80e53f9

JoosepAlviste commented 9 months ago

That seems quite weird, I couldn't reproduce the issue. Did this just start happening recently? There were some breaking changes merged a day or 2 ago: https://github.com/JoosepAlviste/nvim-ts-context-commentstring/issues/82 but I don't know if they would cause such issues.

One thing to try would be to update your Neovim version, I think that one of the recent PRs that was merged required Neovim version 0.9.4 as it uses some newer Treesitter APIs.

If that doesn't help, then could you post a minimal configuration where the issue could be reproduced (based on https://github.com/JoosepAlviste/nvim-ts-context-commentstring/blob/main/utils/minimal_init.lua)? The PR template should have instructions for starting a new minimal config: https://github.com/JoosepAlviste/nvim-ts-context-commentstring/blob/main/.github/ISSUE_TEMPLATE/bug_report.yml.

kohane27 commented 9 months ago

Thank you for getting back to me. I appreciate it!

I can confirm this bug only exists after the BR a few days ago.

I'm currently on Neovim 0.9.4:

:version
NVIM v0.9.4
Build type: Release
LuaJIT 2.1.1700008891

I'll look into it and provide the minimal config.

Thank you again for creating this awesome plugin!

kohane27 commented 9 months ago

Apologies for my late reply. I still have no idea why the latest commit would not work, but I found the commit before the BR works:

{ "JoosepAlviste/nvim-ts-context-commentstring", commit = "6c30f3c8915d7b31c3decdfe6c7672432da1809d" },

I think I'll stick to it for now. I'll debug when I have time. Thank you!

JoosepAlviste commented 9 months ago

Not sure what the issue could be since I can't reproduce it 😕 on is such a weird value for filetype to have...

The only thing I can think of right now would be to use the minimal config as a base to try to reproduce it, adding small bits of your configuration at a time.

By the way, if you manually do :set filetype=lua in a Lua file, then does it provide the correct highlighting and commentstring updating?

kohane27 commented 7 months ago

@JoosepAlviste Hello! Hope you're doing well.

I finally realized the problem. For some reason in option.lua I have the following:

opt.filetype = "on"

And this was the cause of the bug. After removing this faulty line, nvim-ts-context-commentstring works flawlessly again.

My apologies and thank you again. Have a good day!