gruvbox-community / gruvbox

Retro groove color scheme for Vim - community maintained edition
MIT License
801 stars 62 forks source link

TreeSitter Color Changes #154

Open evantravers opened 3 years ago

evantravers commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

Technical27 commented 3 years ago

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.

ellisonleao commented 3 years ago

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

rbong commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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

mactep commented 3 years ago

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 commented 3 years ago

Is treesitter support on the menu?

rbong commented 3 years ago

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 commented 3 years ago

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

SeniorMars commented 3 years ago

Sorry to ask, but is going to get updated?

Diti commented 2 years ago

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

rbong commented 2 years ago

We've been discussing this over in https://github.com/gruvbox-community/gruvbox/pull/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.