Highlight empty lines in neovim
Highlight empty lines are maybe a greatly desired option. In neovim, you can highlight empty lines by using nvim_buf_set_virtual_text, can't you?
Is this something that's going to get implemented? It seems like something that should exist
I was thinking the same and wanted to experiment stuff but it seems not possible currently: https://github.com/neovim/neovim/blob/master/runtime/doc/api.txt#L2016
By default (and currently the only option) the text will be
placed after the buffer text.
^^^^^^^^^^^^
i didn't even see this issue, but i was trying to do the same thing as well. I came up with this
let g:pretty_indent_namespace = nvim_create_namespace('pretty_indent')
function! PrettyIndent()
let l:view=winsaveview()
call cursor(1, 1)
call nvim_buf_clear_namespace(0, g:pretty_indent_namespace, 1, -1)
while 1
let l:match = search('^$', 'W')
if l:match ==# 0
break
endif
let l:indent = cindent(l:match)
if l:indent > 0
call nvim_buf_set_virtual_text(
\ 0,
\ g:pretty_indent_namespace,
\ l:match - 1,
\ [[repeat(repeat(' ', &shiftwidth - 1) . '│', l:indent / &shiftwidth), 'IndentGuide']],
\ {}
\)
endif
endwhile
call winrestview(l:view)
endfunction
augroup PrettyIndent
autocmd!
autocmd TextChanged * call PrettyIndent()
autocmd BufEnter * call PrettyIndent()
autocmd InsertLeave * call PrettyIndent()
augroup END
There are probably edgecases
It doesn't work for wrapped lines, thats a limitation of virtual text
It only works if cindent is working properly.

I've been playing with this a bit more
I can get solid results with the indentexpr, but its too slow to run synchronously.
I have a working prototype to run it async in an embedded neovim instance, but its a bit hacky. It just opens the file again and sends results back.
Maybe its possible to use nvim_buf_attach, but i'm not sure how.
Also its a bit ridiculous to run a new neovim instance just to fill in blank line indentation, but :man_shrugging:
Are you interested to integrate this here? If not i'll make it a standalone plugin
I made it a new standalone plugin for now
https://github.com/lukas-reineke/indent-blankline.nvim
I just enter space and save the file and it works for empty lines too :p

I made it a new standalone plugin for now
https://github.com/lukas-reineke/indent-blankline.nvim
Is this going to be implemented in indentline? For now I'll use yours