-
-
Notifications
You must be signed in to change notification settings - Fork 856
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
feat: languages table to specify treesitter highlighing #1612
Conversation
I just realized that there is a bug. I fix it first. |
Done. |
Congrats on your first (of hopefully many!) open-source PRs! 🎉 🚀 When I look at defaults = {
preview = {
treesitter = false,
languages = { "perl", "javascript" },
},
}, I think the opposite of
To me,
Is anyone else confused by this? I'm wondering if it could be made more clear? |
Thanks!
Yes maybe you are right. I think having a defaults = {
preview = {
treesitter = {
enable = { "..." },
-- or
disable = { "..." },
},
},
}, and keep the option of defaults = {
preview = {
treesitter = true
},
}, |
Great, and also neccecry commit! I think using tables makes it definetely more clear. To further tweak it you could adapt it from treesitters config highlight section. require'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all"
ensure_installed = { "c", "lua", "rust" },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- List of parsers to ignore installing (for "all")
ignore_install = { "javascript" },
highlight = {
-- `false` will disable the whole extension
enable = true,
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
-- the name of the parser)
-- list of language that will be disabled
disable = { "c", "rust" },
-- 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
additional_vim_regex_highlighting = false,
},
} which would translate into something like: defaults = {
preview = {
treesitter = {
enable = true,
disable = { "perl", "javascript" },
},
},
}, edit: I didn't read your last comment properly, which basically does this and also is a nice implementation using a table OR bool - but is a bit harder logic to implement when having the possibility to define enabled and disabled tables. Do you have the time to update your PR? |
Currently in the merge phase. I am going to look at it prior to the dev branch merge tomorrow, see #1938 for more information Thanks for the PR :) |
I will try to update this PR's today. |
I took the liberty to finish this since there weren't any updates since dec 19. And we have a feature freeze today. So i am going to merge this now into the current dev branch and after that into the current master. I also added documentation. So if you want to now how it works, please refer to that or the last commit. Basically the gist is now. that preview.treesitter can be a table with a Thanks for the PR :) |
this follows nvim-treesitter more closely but enable can also be a table of enabled languages The config now looks like this: ```lua defaults = { preview = { treesitter = { enable = false, -- or enable = { "c" }, -- disable can be set if enable isn't set disable = { "perl", "javascript" }, }, }, }, ```
First of all just say that's my first "contribution" to any open source project. I hope with time the contributions are bigger :). This change makes more sense for me that the logic that it's being use now, but maybe not for everyone. Any feedback welcome.
If the languages exists in the config, only the file-types that match with
the ones on the table will be affected by the treesitter boolean.
The config now will look like this:
That will make that only
perl
andjavascript
will use regex for the highlight and any other file-type will use treesitter if possible.