vimwiki
vimwiki copied to clipboard
Conceal syntax elements in tables
I notice that links in tables use the syntax highlighting group VimwikiLinkT
while outside of a table it's 'VimwikiLink. My links in the table show the
[[and
]], and if I use the
|` to add a description, it shows everything. If the link has an anchor as well as description, it can get quite long, and in a multi-column table, the table gets very wide very quickly.
I can't imagine this is by design, so I thought it must be something in my .vimrc or conflict with another plugin. However, reducing my .vimrc to just the three required lines (set compatible
, filetype plugin on
and syntax on
) and a bundle/ directory containing only vimwiki, results in the same behavior. In a table row like:
| | [[Of Wolves and Men]] | [[The Hero's Homecoming#Farmer John|Farmer John]] | Wren | werewolf | Some notes. |
The whole "Farmer John" link shows up, brackets, anchor, and all.
You're right, this is not done on purpose. This could be a simple bug but it also could be hard or even impossible to fix, because the hiding to links is based on a vim-feature called conceal which is not powerful and advanced enough for some things we'd like to do.
Um, yes, this is done on purpose. In fact, nothing inside tables is concealed, simply because to draw a nice table, we need to compute the width of their cells. The last time I checked, computing the width of a potentially concealed string was very complicated, slow and error-prone, so the easy solution was chosen. I'll leave this issue open nevertheless, as a reminder to check on this again.
Hello. I was going to create a feature request for this very issue until I discovered this had already been requested. Would it be possible to compute the width of the cell based on the character length of the description and/or the length of the column header (which ever is greater)?
@sibyfi, yes you can, anyway vimwiki is always getting the larger cell size for each column.
The hard thing is that you must be precise enough to align the |
when the text is concealed and so add some [](all those characters)
to it position for the column at the right of it in the unconcealed space but remembering their size in the concealed space to determine the largest cell.
Feel free to open a PR, it will be really appreciated. It may take you 6h. See autoload/vimwiki/table.vim
and syntax/vimwiki.vim
.