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 support #235

Closed
sudoerwx opened this issue Dec 7, 2020 · 22 comments · Fixed by #253
Closed

Treesitter support #235

sudoerwx opened this issue Dec 7, 2020 · 22 comments · Fixed by #253

Comments

@sudoerwx
Copy link

sudoerwx commented Dec 7, 2020

I like this theme but It would be even better with Treesitter support.

Treesitter defines the following highlight groups (the color definitions are from Onedark).

hi! TSError ctermfg=203 guifg=#f44747
hi! TSPunctDelimiter ctermfg=249 guifg=#abb2bf
hi! TSPunctBracket ctermfg=249 guifg=#abb2bf
hi! TSPunctSpecial ctermfg=249 guifg=#abb2bf
hi! TSConstant ctermfg=75 guifg=#61afef
hi! TSConstBuiltin ctermfg=173 guifg=#d19a66
hi! TSConstMacro ctermfg=73 guifg=#56b6c2
hi! TSStringRegex ctermfg=114 guifg=#98c379
hi! TSString ctermfg=114 guifg=#98c379
hi! TSStringEscape ctermfg=73 guifg=#56b6c2
hi! TSCharacter ctermfg=114 guifg=#98c379
hi! TSNumber ctermfg=173 guifg=#d19a66
hi! TSBoolean ctermfg=173 guifg=#d19a66
hi! TSFloat ctermfg=114 guifg=#98c379
hi! TSAnnotation ctermfg=180 guifg=#e5c07b
hi! TSAttribute ctermfg=73 guifg=#56b6c2
hi! TSNamespace ctermfg=201 guifg=#ff00ff
hi! TSFuncBuiltin ctermfg=75 guifg=#61afef
hi! TSFunction ctermfg=75 guifg=#61afef
hi! TSFuncMacro ctermfg=180 guifg=#e5c07b
hi! TSParameter ctermfg=73 guifg=#56b6c2
hi! TSParameterReference ctermfg=73 guifg=#56b6c2
hi! TSMethod ctermfg=75 guifg=#61afef
hi! TSField ctermfg=168 guifg=#e06c75
hi! TSProperty ctermfg=180 guifg=#e5c07b
hi! TSConstructor ctermfg=73 guifg=#56b6c2
hi! TSConditional ctermfg=175 guifg=#c586c0
hi! TSRepeat ctermfg=175 guifg=#c586c0
hi! TSLabel ctermfg=75 guifg=#61afef
hi! TSKeyword ctermfg=175 guifg=#c586c0
hi! TSKeywordFunction ctermfg=175 guifg=#c586c0
hi! TSKeywordOperator ctermfg=175 guifg=#c586c0
hi! TSOperator ctermfg=249 guifg=#abb2bf
hi! TSException ctermfg=175 guifg=#c586c0
hi! TSType ctermfg=75 guifg=#61afef
hi! TSTypeBuiltin ctermfg=75 guifg=#61afef
hi! TSStructure ctermfg=201 guifg=#ff00ff
hi! TSInclude ctermfg=175 guifg=#c586c0
hi! TSVariable ctermfg=73 guifg=#56b6c2
hi! TSVariableBuiltin ctermfg=180 guifg=#e5c07b
hi! TSText ctermfg=226 guifg=#ffff00
hi! TSStrong ctermfg=226 guifg=#ffff00
hi! TSEmphasis ctermfg=226 guifg=#ffff00
hi! TSUnderline ctermfg=226 guifg=#ffff00
hi! TSTitle ctermfg=226 guifg=#ffff00
hi! TSLiteral ctermfg=226 guifg=#ffff00
hi! TSURI ctermfg=226 guifg=#ffff00
hi! TSTag ctermfg=168 guifg=#e06c75
hi! TSTagDelimiter ctermfg=241 guifg=#5c6370

@delphinus
Copy link

FYI: I added some settings and achieved this colorful code.

hi TSConditional guifg=#88c0d0          
hi TSConstant guifg=#d8dee9 gui=bold    
hi TSConstructor guifg=#ebcb8b gui=bold 
hi TSException guifg=#88c0d0 gui=italic 
hi TSKeyword guifg=#9a6590 gui=bold     
hi TSMethod guifg=#ebcb8b               
hi TSProperty guifg=#8fbcbb gui=italic  
hi TSRepeat guifg=#88c0d0               
hi TSTypeBuiltin guifg=#81a1c1 gui=bold 
hi TSVariableBuiltin guifg=#d08770      

スクリーンショット 0002-12-22 13 57 20

@sudoerwx
Copy link
Author

are you sure that this is according to the Nord color scheme? seems like this orange/ yellow is not from nord

@delphinus
Copy link

Yes. This is #ebcb8b - nord13.

@luisiacc
Copy link

luisiacc commented Feb 9, 2021

This theme is super cool, but with treesitter is not as good, leaves us 2 choices, stop using treesitter in order tu use this scheme, or don't use the scheme, which is not cool since treesitter is super fast even on very large files.

@mrswats
Copy link
Contributor

mrswats commented Mar 14, 2021

How could I use this in my settings to work properly? I really like nord but with treesitter feels very plain imo.

@luisiacc
Copy link

How could I use this in my settings to work properly? I really like nord but with treesitter feels very plain imo

Checkout this plugin https://github.com/ChristianChiarulli/nvcode-color-schemes.vim , it has several colorschemes with support for treesitter (nord is among them).

@mrswats
Copy link
Contributor

mrswats commented Mar 14, 2021

@luisiacc many thanks!

@sudoerwx
Copy link
Author

sudoerwx commented Mar 15, 2021

@luisiacc @mrswats i have tried this one but it doesn’t have airline support and some colors were strange, so I merged official nord and this for treesitter, and I have those 2 files (colors its folder with colorschemes and airline contains nord and badwolf airline theme, you can delete badwolf)
colors.zip
airline.zip

btw: to install them unarchive colors folder near your init.vim and airline In the autoload folder, and remove official packages from your config, because they will overwrite the custom theme

@kierun
Copy link

kierun commented Mar 15, 2021

@s-u-d-o-e-r Thank you for that. Could you open a PR upstream?

@sudoerwx
Copy link
Author

its hand made merge and I know almost nothing about themes syntax, so it would be good if someone else will review and clean those files and then make PR

@kierun
Copy link

kierun commented Mar 15, 2021

@s-u-d-o-e-r I wish I had the time!

@mrswats
Copy link
Contributor

mrswats commented Mar 15, 2021

I am happy to provide a PR if someone can give me some pointers!

@kierun
Copy link

kierun commented Mar 15, 2021

I am happy to provide a PR if someone can give me some pointers!

Sure thing. Clone the repository (it will appear under your own github), make the changes and commit then, then go to the upstream and do a PR. It might be good to open an issue first with a screen shot before and after -- I would add the after in the PR. I know there are some unit test framework for vim but I never used them… And it does not look like nvcode-color-schemes.vim uses them.

Does that help?

@mrswats
Copy link
Contributor

mrswats commented Mar 15, 2021

@kierun I know how to create a PR for an OSS project on github. I meant it in a more technical sense, would committing these two files as @s-u-d-o-e-r sent them in the appropriate locations would be enough?

@kierun
Copy link

kierun commented Mar 15, 2021

@mrswats Ah, my apologies for misunderstanding.

I would start with just replacing them and see what happens.

@mrswats
Copy link
Contributor

mrswats commented Mar 15, 2021

Opened PR :) Feel free to continue the technical discussion over there!

@arcticicestudio
Copy link
Contributor

arcticicestudio commented Mar 16, 2021

Hi to all participants in this issue 👋, and thanks @s-u-d-o-e-r for your contribution 👍

I know that the main development origin for tree-sitter was to be used as new parser for Atom back then, but when most of the users switched to the more stable and advanced Visual Studio Code (and Microsoft bought GitHub) I thought that Atom (and tree-sitter) was going to be sunset sooner or later. Nice to see that it was decoupled from Atom and developed actively.
Anyway, adding support for the nvim-treesitter plugin should not be a problem, even when it is only available for Neovim. My only concern, albeit a small one, is that sooner or later there might be a collision of highlighting group names. The TS prefix of the nvim-treesitter plugin could also be used by another plugin that is targeted for TypeScript. Would have been better if they'd choose TreeSitter instead.

@brymer-meneses
Copy link

Any updates on this issue?

@mrswats
Copy link
Contributor

mrswats commented May 10, 2021

@brymer-meneses I hadn't had much time to look into it since. I will try to check it out soon.

@kierun
Copy link

kierun commented May 17, 2021

This project is a tree-sitter implementation of Nord. It might not be compatible with Nord as-is but might be of interest.

@shaunsingh
Copy link

shaunsingh commented May 17, 2021

Hi, thanks for linking my port!

I've tried to stay to Nord and followed the directions in the readme in terms of syntax groups. All colors used in the port are part of the 16 colors present in the nord theme, except for the cursor line color which is taken from the vscode version.

The main changes I made were yellow (nord13) instead of Snow White (Nord 4) for constants, and light blue (Nord 7) instead of Snow White (Nord 4) for function names, as I feel it gives a little more pop to the theme. The biggest difference is my theme is made in lua, which means it isn't backwards compatible with Nord-vim. Ideally I wanted to submit it as a separate Nord port for Neovim, but if tree sitter is integrated into the main repository it's somewhat unnecessary.

You can find my issue/request to create a neovim theme here: nordtheme/nord#157, since work is being done on this branch, I can close it if needed.

The benefits of having neovim have its own theme are:

  1. You can work on neovim-specfic features without cluttering up the vim port
  2. The Nord.nvim theme loads much quicker since its in lua (about 2 for the nvim vs 6 ms for the vim port on average for me)
  3. Themes for other nvim utilities (lsp diagnostics, lualine, nvim-dap, etc)

On the other hand, the main drawback would be having to maintain two themes instead of just one, and the nord theme has quite a backlog of work already.

If you want a slightly more color-accurate theme, then https://github.com/kunzaatko/nord.nvim might interest you as well

arcticicestudio pushed a commit that referenced this issue Jul 10, 2021
Neovim version 0.5 [1] is a long-time awaited update that introduces
features like tree-sitter [2][3] support and native LSP [4][5].
Even though Neovim devides more and more from Vim through specific
features like first-class Lua support with custom APIs, the highlighting
for tree-sitter is achived through "normal" syntax highlighting groups.
Most of the groups are already linked by the nvim-treesitter plugin by
default [6] so only a few groups have been adjuated for now to fit the
Nord style.

[1]: https://github.com/neovim/neovim/releases/tag/v0.5.0
[2]: https://github.com/tree-sitter/tree-sitter
[3]: https://github.com/nvim-treesitter/nvim-treesitter
[4]: https://neovim.io/doc/user/lsp.html
[5]: https://github.com/neovim/nvim-lspconfig
[6]: https://github.com/nvim-treesitter/nvim-treesitter/blob/90f15d9/plugin/nvim-treesitter.vim

Co-authored-by: Ferran Jovell <[email protected]>
Co-authored-by: Arctic Ice Studio <[email protected]>
Co-authored-by: Sven Greb <[email protected]>

Closes GH-235
@arcticicestudio arcticicestudio added this to the Next milestone Jul 10, 2021
@arcticicestudio
Copy link
Contributor

Support has been implemented and merged in #253 🎉

⚠️ Note that this is the first iteration and it is very likely that there will be inconsistencies compared to the current highlighting when using "normal" Vim plugins per language. Please report any problem you find so that the support for tree-sitter can be improved continuously!

arcticicestudio pushed a commit that referenced this issue Jul 10, 2021
Neovim version 0.5 [1] is a long-time awaited update that introduces
features like tree-sitter [2][3] support and native LSP [4][5].
Even though Neovim devides more and more from Vim through specific
features like first-class Lua support with custom APIs, the highlighting
for tree-sitter is achived through "normal" syntax highlighting groups.
Most of the groups are already linked by the nvim-treesitter plugin by
default [6] so only a few groups have been adjuated for now to fit the
Nord style.

[1]: https://github.com/neovim/neovim/releases/tag/v0.5.0
[2]: https://github.com/tree-sitter/tree-sitter
[3]: https://github.com/nvim-treesitter/nvim-treesitter
[4]: https://neovim.io/doc/user/lsp.html
[5]: https://github.com/neovim/nvim-lspconfig
[6]: https://github.com/nvim-treesitter/nvim-treesitter/blob/90f15d9/plugin/nvim-treesitter.vim

Co-authored-by: Ferran Jovell <[email protected]>
Co-authored-by: Arctic Ice Studio <[email protected]>
Co-authored-by: Sven Greb <[email protected]>

Closes GH-235
crispgm pushed a commit to crispgm/nord-vim that referenced this issue Jul 14, 2021
Neovim version 0.5 [1] is a long-time awaited update that introduces
features like tree-sitter [2][3] support and native LSP [4][5].
Even though Neovim devides more and more from Vim through specific
features like first-class Lua support with custom APIs, the highlighting
for tree-sitter is achived through "normal" syntax highlighting groups.
Most of the groups are already linked by the nvim-treesitter plugin by
default [6] so only a few groups have been adjuated for now to fit the
Nord style.

[1]: https://github.com/neovim/neovim/releases/tag/v0.5.0
[2]: https://github.com/tree-sitter/tree-sitter
[3]: https://github.com/nvim-treesitter/nvim-treesitter
[4]: https://neovim.io/doc/user/lsp.html
[5]: https://github.com/neovim/nvim-lspconfig
[6]: https://github.com/nvim-treesitter/nvim-treesitter/blob/90f15d9/plugin/nvim-treesitter.vim

Co-authored-by: Ferran Jovell <[email protected]>
Co-authored-by: Arctic Ice Studio <[email protected]>
Co-authored-by: Sven Greb <[email protected]>

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

Successfully merging a pull request may close this issue.

8 participants