Closed daveyarwood closed 2 years ago
I've partially worked around the problem by adding this autocmd to my vimrc:
autocmd BufEnter,BufLeave /tmp/conjure.cljc ColorHighlight
It's still a little bit flaky, as you can see in this new gif:
https://daveyarwood.keybase.pub/misc/201911141526-conjure-colorizer.gif
I still have to enter the buffer in order to get color, and then after I leave, new entries in the log don't get colorized unless I enter the log buffer again. What I want is for that buffer to be colorized when it gets created and then I want it to stay colorized even if I move away into another split.
EDIT: Adding BufNewFile
and BufRead
didn't help either. I'm not sure what Conjure is doing, exactly, when it opens the log buffer. Is it a window? A split? @Olical ?
hm, is that specific to a terminal buffer?
It's not a terminal buffer, it's a file /tmp/conjure.cljc
(filetype: clojure
)
The Conjure log is a regular old buffer, a few options get set upon creation though:
vim.api.nvim_command("botright " .. size_abs .. split .. " " .. log_buf_name)
vim.api.nvim_command("setlocal winfixwidth")
vim.api.nvim_command("setlocal winfixheight")
vim.api.nvim_command("setlocal buftype=nofile")
vim.api.nvim_command("setlocal bufhidden=hide")
vim.api.nvim_command("setlocal nowrap")
vim.api.nvim_command("setlocal noswapfile")
vim.api.nvim_command("setlocal nobuflisted")
vim.api.nvim_command("setlocal nospell")
vim.api.nvim_command("setlocal foldmethod=marker")
vim.api.nvim_command("setlocal foldlevel=0")
vim.api.nvim_command("setlocal foldmarker={{{,}}}")
vim.api.nvim_command("normal! G")
I don't see why it shouldn't work. Is there an easy way to reproduce? Perhaps share a view or session file?
Am 15.11.2019 um 17:07 schrieb Oliver Caldwell notifications@github.com:
The Conjure log is a regular old buffer, a few options get set upon creation though:
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
I came up with a simpler repro:
https://daveyarwood.keybase.pub/misc/201911151455-colorizer-splits.gif
In this gif, I'm not using Conjure, I'm just editing a tiny CSS file and opening the same file in splits.
It appears that Colorizer is only colorizing the buffer that's in focus.
I'm having a similar error, but with vim-dispatch and cmake. And quickfix.
I tried a bunch of other autocmds and got a little bit further. Here's where I'm at now:
augroup auto_colorize
autocmd!
autocmd
\ BufNewFile,BufRead,BufEnter,BufLeave,WinEnter,WinLeave,WinNew
\ /tmp/conjure.cljc,*.css,*.scss
\ ColorHighlight
augroup END
Adding WinEnter, WinLeave and WinNew seems to improve the behavior such that when I open a new split, it's colorized, (it still loses color when I make a change in one split of the same file, like in my gif above), and when I move between splits, the splits that lost color get colorized again.
It still seems like the behavior we're missing is that whenever you change text, it should re-colorize all the buffers/windows. I attempted to get this behavior by adding TextChanged and TextChangedI to the autocmd, but that didn't work.
NB: With the above in place, I was able to comment out the following options because they make no difference in behavior:
" let g:colorizer_auto_color = 1
" let g:colorizer_auto_filetype='scss,css,clojure'
I just discovered that Colorizer has an option to disable its default behavior where it de-colorizes whenever you leave a buffer. This gets me most of the way to fixing this issue:
let g:colorizer_auto_color = 1
let g:colorizer_auto_filetype='scss,css,clojure'
let g:colorizer_disable_bufleave = 1
The remaining issues I'm seeing are:
Thanks for the comments everyone, very helpful.
I also noticed that,
let g:colorizer_auto_color = 1
let g:colorizer_auto_filetype='scss,css,js'
let g:colorizer_disable_bufleave = 1
made no effect, unless I sourced my .vimrc in a loaded buffer :so $MYVIMRC
. Which makes me think that it could be an initialization problem with this plugin. It's just not sourcing these at the right time.
In any case, this works for me:
augroup auto_colorize
autocmd!
autocmd
\ BufNewFile,BufRead,BufEnter,BufLeave,WinEnter,WinLeave,WinNew
\ *.js,*.css,*.scss,*.sass
\ ColorHighlight
augroup END
So I'll run with this for now and if I get some free time maybe look at the code here.
I think a better direction to get it activated in a summary is:
autocmd FileType * : ColorHighlight
with that the colors for all languages would be activated
would you please create a PR with a doc improvement for this please?
I don't think it's convenient to modify or implement the command that mentions the script, since this makes vim slow down a bit, but if you want the plugin to be initialized when opening a file no matter that vim slows down, you can add the command mentioned above in .vimrc.
autocmd FileType * : ColorHighlight
let me add this to the documentation at least
I'm using Conjure for Clojure development. It basically gives you a Clojure REPL integrated into Neovim, with a log buffer (
ft=clojure
) where output is displayed.I have a project that prints text to stdout that contains ANSI color codes. My goal is to render the text in color in the Conjure log buffer.
With this configuration:
I see this behavior:
https://daveyarwood.keybase.pub/misc/201911141433-conjure-colorizer.gif
The issues I'm noticing are:
:ColorHighlight
to manually colorize it, but then it decolorizes when I move away to another split.