TaDaa / vimade

An eye friendly plugin that fades your inactive buffers and preserves your syntax highlighting!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TreeSitter

SingularisArt opened this issue · comments

I'm trying to disable Treesitter for inactive buffers, but I can't seem to figure out how to do it. How did you get that working?

commented

There are two cases currently:

  • vimade.enabletreesitter=0 - think this is the scenario you are interested in. Fading is performed using syntax highlighting as the baseline. Vimade overwrites TreeSitter highlights additional highlights at a higher priority using matchaddpos. Syntax is off for TreeSitter, so Vimade ends up using either NormalNC or Normal for fading.
  • vimade.enabletreesitter=1 - experimental (due to maintenance). The TreeSitter highlight tables are imported and used as the baseline instead of syntax highlighting. TreeSitter highlights are overwritten using higher priority matchaddpos.

For just fading foreground text in inactive buffers for TreeSitter, something along these lines might work (NormalNC isn't a great fit here though):

hi NormalNC guifg=#303030 ctermfg=236

function! BufEnter()
    if &ft  == ""
        let &ft=getbufvar(bufnr(), "default_type")
    endif
endfunction

function! BufLeave()
    call setbufvar(bufnr(), "default_type", &ft)
    set ft=
endfunction

au! BufEnter * call BufEnter()
au! BufLeave * call BufLeave()


When I use that code, I get the following error:
display-error

commented

Made a correction, BufEnter should be

function! BufEnter()
    if &ft  == ""
        let &ft=getbufvar(bufnr(), "default_type")
    endif
endfunction

nvim-treesitter-context.lua; line 308 its probably not liking the empty fileType. I haven't tried the plugin, but surprised its asserting on fileType -- does it error if just run set ft= or set ft=randomFileType?