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

Treesitter alongside vimtex #2469

Closed
aryabhatta-dey opened this issue Aug 24, 2022 · 16 comments
Closed

Treesitter alongside vimtex #2469

aryabhatta-dey opened this issue Aug 24, 2022 · 16 comments

Comments

@aryabhatta-dey
Copy link
Contributor

Not really an issue rather a suggestion.

Currently, Vimtex's documentation suggests not to install markdown or latex Treesitter parsers if one wants to use Vimtex for recognizing mathzones. But this means one cannot use plugins like https://github.com/AckslD/nvim-FeMaco.lua.

So to get around the problem one can do

require("nvim-treesitter.configs").setup({
	ensure_installed = { "markdown" },
	highlight = {
		enable = true,
		disable = { "latex" },
		additional_vim_regex_highlighting = { "latex", "markdown" },
	},
	--other treesitter settings
})

I have tested this config out with small markdown files and as of the moment I can use both nvim-FeMaco and Vimtex's mathzones in the same file.

@lervag
Copy link
Owner

lervag commented Aug 24, 2022

Thanks! It would be nice if you could explain what additional_vim_regex_highlighting does?

@clason
Copy link
Contributor

clason commented Aug 24, 2022

It does not disable the legacy syntax engine when attaching a treesitter parser (via syntax off), i.e., it runs both treesitter and regex highlighting in parallel (completely negating any performance benefit, and possibly leading to weird results since both types of highlighting are applied, one over the other).

It's a band-aid that's not really recommended as a practical solution.

@aryabhatta-dey
Copy link
Contributor Author

To quote directly from the readme of https://github.com/nvim-treesitter/nvim-treesitter "Setting this to true will run :h syntax and tree-sitter at the same time. Set this to true if you depend on 'syntax' being enabled (like for indentation). Using this option may slow down your editor, and you may see some duplicate highlights. Instead of true it can also be a list of languages".

I haven't yet experienced any negative effects but yes it's true it duplicates effort and is a band aid solution. But I prefer that loss in efficiency over loosing either nvim-FeMaco or Vimtex.

@lervag
Copy link
Owner

lervag commented Aug 24, 2022

Cool, thanks for the explanations!

@aryabhatta-dey if you think we should make an update to the docs; would you care to propose a first version of this update?

@aryabhatta-dey
Copy link
Contributor Author

Sure. Should I submit it as a pr with only documentation changes?

@lervag
Copy link
Owner

lervag commented Aug 25, 2022

Yes, that would be great :)

@aryabhatta-dey
Copy link
Contributor Author

Hey! Just made a pr #2484. Sorry for not getting back to you so long. Please take a look and let me know what you think.

@lervag
Copy link
Owner

lervag commented Sep 9, 2022

Thanks! I'll check it out now. I believe this issue can be closed now? (Feel free to reopen if I missed something.)

@lervag lervag closed this as completed Sep 9, 2022
lervag added a commit that referenced this issue Sep 9, 2022
refer: #2484, #2469

* commit 'HEAD@{1}':
  doc: minor adjustments
  Made changes to doc/vimtex.txt vimtex-faq-treesitter section according to the discussion in #2469
@SeniorMars
Copy link

Is there anyway to remove the message that vimtex puts out about treesitter syntax?

@lervag
Copy link
Owner

lervag commented Feb 27, 2023

Yes: use let g:vimtex_syntax_enabled = 0 or vim.g.vimtex_syntax_enabled = 0.

@SeniorMars
Copy link

This might be a weird thing to ask, but since I use treesitter with:

        additional_vim_regex_highlighting = { "latex" },

I hoped there was a way to get rid of the message and not the support. vim.g.vimtex_syntax_enabled = 0 disables conceal on my system even with additional_vim_reg_highlighting, but I would like to get rid of the warning, not the support. Is this possible?

lervag added a commit that referenced this issue Mar 6, 2023
@lervag
Copy link
Owner

lervag commented Mar 6, 2023

Ah, that's right. I agree that in this case there is no need for the warning. I've tried to update the check so that it only outputs the warning if VimTeX syntax is not active. Can you please update and check if it works?

@lervag
Copy link
Owner

lervag commented Mar 6, 2023

It would be nice if you also checked if the warning is still there if you remove additional_vim_regex_highlighting. :)

@SeniorMars
Copy link

The warning is all gone! Thank you so much! I want to say I love this plugin so much. Is there any way we can sponsor you?

@lervag
Copy link
Owner

lervag commented Mar 7, 2023

Glad to hear it, and thanks for the kind words! I don't mind donations, of course - there's a paypal badge on the README. <3

@lervag
Copy link
Owner

lervag commented Mar 7, 2023

But I will also be glad if you instead choose to "pass it on" by donating to some cause you believe in, be it charity or other FOSS projects. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants