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 Color Changes #154

Open
evantravers opened this issue Feb 4, 2021 · 14 comments
Open

TreeSitter Color Changes #154

evantravers opened this issue Feb 4, 2021 · 14 comments

Comments

@evantravers
Copy link

this is an init.lua for neovim… I've got a branch here.

-- PLUGINS
-- Using paq.nvim
vim.cmd 'packadd paq-nvim'
local paq = require('paq-nvim').paq
paq {'savq/paq-nvim', opt=true}


-- enable 24bit color
vim.o.termguicolors = true

-- THEME
-- gruvbox colors
paq 'gruvbox-community/gruvbox'
vim.g.gruvbox_italic = 1
vim.g.gruvbox_improved_strings = 1
vim.g.gruvbox_improved_warnings = 1
vim.g.gruvbox_contrast_light = 'hard'
vim.g.gruvbox_contrast_dark = 'medium'
vim.cmd [[colorscheme gruvbox]]
-- statusline
paq 'itchyny/lightline.vim'
vim.g.lightline = {
  colorscheme = 'gruvbox'
}
vim.o.showmode = false
if os.getenv('termTheme') == 'light' then
  vim.o.background = 'light'
end

paq {'nvim-treesitter/nvim-treesitter', hook = ':TSUpdate'}
require'nvim-treesitter.configs'.setup {
  highlight = {
    enable = true
  },
  indent = {
    enable = true
  }
}

I've been playing with nvim treesitter syntax stuff… and while it's more detailed than before, I kind of get the feeling that it's making new highlight groups that gruvbox doesn't know about? I'm new to working with highlights.

Before TreeSitter (using :TSToggleAll highlight to disable it):
image

After TreeSitter:
image

It's just kind of weird… no matter what language I stare at it in… there's a little more garish (maybe bold?) and a lot more red. I like the extra detail in things like regex and strings… but it kind of subverts the colors I've become accustomed to.

Anyone looked at this?

@evantravers evantravers changed the title TreeSitter TreeSitter Color Changes Feb 4, 2021
@evantravers
Copy link
Author

Doing more digging on my own problem… TreeSitter does introduce a number of new highlight groups. I think this also makes this issue related to #153… but potentially an opportunity to talk about it more.

evantravers added a commit to evantravers/dotfiles that referenced this issue Feb 4, 2021
Messing around with moonfly because my beloved gruvbox doesn't have
treesitter syntax yet.

References:
- https://github.com/bluz71/vim-moonfly-colors
- gruvbox-community/gruvbox#154
evantravers added a commit to evantravers/dotfiles that referenced this issue Feb 4, 2021
Messing around with moonfly because my beloved gruvbox doesn't have
treesitter syntax yet.

References:
- https://github.com/bluz71/vim-moonfly-colors
- gruvbox-community/gruvbox#154
@evantravers
Copy link
Author

Leaving notes for myself as I try to maybe fix an issue that I raise… looks like there's at least one person who has hacked this into their setup: https://github.com/timbedard/dotfiles/blob/9e53b4c09c55113d09ff3a939313bcfc8e8d5452/config/nvim/lua/minimal.lua#L16-L26

evantravers added a commit to evantravers/dotfiles that referenced this issue Feb 5, 2021
Messing around with moonfly because my beloved gruvbox doesn't have
treesitter syntax yet.

References:
- https://github.com/bluz71/vim-moonfly-colors
- gruvbox-community/gruvbox#154
evantravers added a commit to evantravers/dotfiles that referenced this issue Feb 5, 2021
Messing around with moonfly because my beloved gruvbox doesn't have
treesitter syntax yet.

References:
- https://github.com/bluz71/vim-moonfly-colors
- gruvbox-community/gruvbox#154
@Technical27
Copy link

here is what im using for this:

  hi! link TSAnnotation GruvboxAqua
  hi! link TSBoolean GruvboxPurple
  hi! link TSCharacter GruvboxPurple
  hi! TSComment cterm=italic
  hi! link TSComment GruvboxGrey
  hi! link TSConstructor GruvboxOrange
  hi! link TSConditional GruvboxRed
  hi! link TSConstant GruvboxFg
  hi! link TSConstBuiltin GruvboxPurple
  hi! link TSConstMacro GruvboxPurple
  hi! link TSError GruvboxRed
  hi! link TSException GruvboxRed
  hi! link TSField GruvboxFg
  hi! link TSFloat GruvboxPurple
  hi! link TSFunction GruvboxGreenBold
  hi! link TSFuncBuiltin GruvboxOrange
  hi! link TSFuncMacro GruvboxAqua
  hi! link TSInclude GruvboxAqua
  hi! link TSKeyword GruvboxRed
  hi! link TSLabel GruvboxRed
  hi! link TSMethod GruvboxGreenBold
  hi! link TSNamespace GruvboxAqua
  hi! link TSNone GruvboxPurple
  hi! link TSNumber GruvboxPurple
  hi! link TSOperator GruvboxOrange
  hi! link TSParamter GruvboxFg
  hi! link TSParameterReferance GruvboxFg
  hi! link TSProperty GruvboxBlue
  hi! link TSPunctDelimiter GruvboxFg
  hi! link TSPunctBracket GruvboxFg
  hi! link TSPunctSpecial GruvboxFg
  hi! link TSRepeat GruvboxRed
  hi! link TSString GruvboxGreen
  hi! link TSStringRegex GruvboxYellow
  hi! link TSStringEscape GruvboxOrange
  hi! link TSTag GruvboxBlue
  hi! link TSTagDelimiter GruvboxAqua
  hi! link TSText GruvboxFg
  hi! link TSLiteral GruvboxFg
  hi! link TSURI GruvboxAqua
  hi! link TSType GruvboxYellow
  hi! link TSTypeBuiltin GruvboxYellow
  hi! link TSVariable GruvboxFg
  hi! TSEmphasis cterm=italic
  hi! TSUnderline cterm=underline

Its nowhere near perfect, but it works somewhat.

evantravers added a commit to evantravers/dotfiles that referenced this issue Feb 6, 2021
Messing around with moonfly because my beloved gruvbox doesn't have
treesitter syntax yet.

References:
- https://github.com/bluz71/vim-moonfly-colors
- gruvbox-community/gruvbox#154
evantravers added a commit to evantravers/dotfiles that referenced this issue Feb 7, 2021
Messing around with moonfly because my beloved gruvbox doesn't have
treesitter syntax yet.

References:
- https://github.com/bluz71/vim-moonfly-colors
- gruvbox-community/gruvbox#154
@ellisonleao
Copy link

https://github.com/npxbr/gruvbox.nvim has Treesitter support

@rbong
Copy link

rbong commented Feb 13, 2021

I absolutely love that there's a lua port now.

MRs happily accepted for this issue, might not get a chance to add it myself, just quickly going through issues.

@rbong
Copy link

rbong commented Feb 13, 2021

@ellisonleao No message system on GitHub but I sent you an invite to become a gruvbox-community owner, you're free to accept it or not. Trying to get more people in the group so it isn't completely blocked without me and I don't see any better qualification than making a fork like this. You don't have to actually do anything in the group if you don't want to.

@ellisonleao
Copy link

hey @rbong really appreciate it! I will definitely accept it and also hope to start contributing soon!

@mactep
Copy link

mactep commented Apr 12, 2021

Hey guys, I've been trying to make those highlight links work and I faced some strange (maybe expected) behaviour. I tried to make something as follows, requiring this file in init.lua, but it didn't work:

require('nvim-treesitter.configs').setup({
  ensure_installed = {'html', 'python', 'typescript', 'lua'},
  indent = { enable = true }, 
  highlight = { enable = true }
})

vim.cmd([[
  hi! link TSConstBuiltin Constant
  hi! link TSKeywordOperator Keyword
  hi! link TSOperator GruvboxRed
  hi! link TSFunction GruvboxAqua
  hi! link TSMethod GruvboxAqua
]])

Looks like that vim.cmd(...) needs to run after neovim initiates or something. Calling luafile test.lua (a file containing vim.cmd(...)) fixes it. I'm using vim's builtin package manager, so I guess it has something to do with it, since everyone's been using packer.

Does anyone know what may be happening?

Just to help someone that may be facing this issue, I did a workaround by creating a color.vim inside nvim/plugin with those highlight links.

Sorry if I'm missing something. Thanks in advance.

@luisiacc
Copy link

Is treesitter support on the menu?

@rbong
Copy link

rbong commented May 28, 2021

Accepting all pull requests :) I don't plan to use treesitter until neovim 0.5 is released, at that point I may add it myself.

@ellisonleao
Copy link

@luisiacc if you want, https://github.com/npxbr/gruvbox.nvim/ is a lua port of this plugin and it already has treesitter support

@SeniorMars
Copy link

Sorry to ask, but is going to get updated?

@Diti
Copy link

Diti commented Feb 18, 2022

@ellisonleao seems to be actively committing to his gruvbox.nvim repository. I’m sure a pull request will show up eventually.

@rbong
Copy link

rbong commented May 3, 2022

We've been discussing this over in #183

The issue with defining specific TreeSitter highlight groups is that it runs contrary to how gruvbox has treated highlight groups up to this point. That is - we have carefully tweaked highlight groups for every single language. TreeSitter makes highlight groups consistent over every single language.

If we adopt this change, some people are going to end up with colors they don't like because they're not used to them. There's no avoiding it, so let's do it as smart as possible so it at least feels consistent and won't lead to fighting over different colors.

Also, most (not all) of the TreeSitter styles just link back to previously defined highlight groups.

We may want to develop a spec sheet (as saccarosium pointed out both Dracula and Nord have one), make sure the linked highlight groups from TreeSitter are defined well, and then just fill in any special highlight groups we need (like TSKeywordOperator because of #153).

This might be a bad solution though, because if we develop a spec sheet we either:

  1. Do not backport it to existing languages and plugins and be happy with violating our own spec sheet
  2. Do backport it and change tons of colors everyone is used to, inevitably not making some people happy and forcing them to deal with colors developed for a change they don't need

So maybe Gruvbox is just permanently a bunch of ad-hoc colors, even with general highlight groups that span across languages.

Right now though, I am leaning towards developing a spec sheet based on the colors we have now, backporting it, dealing with the inevitable influx of requests, and coming out the other end as a better colorscheme.

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

8 participants