Closed blueyed closed 12 years ago
I pushed an experimental branch called eval-expression, could you test it? It might work!
I'm not sure if I should evaluate %{} items or not
Note for myself: I could have a g:smartusline_deep_eval true/false shallow: evaluate %!{} only deep: evaluate %{} too
Using the parser you currently are evaluating deeply, aren't you? So it won't work for me currently, because the "%{ShortenFilename(fnamemodify(bufname("%"), ":~"), 20)}" would get evaluated and nothing would be there to get matched.
I guess that you need to evaluate deeply though, because Vim only evaluates %{}
itself when the whole setting started with "%!".
What's missing now appears to be looking for a g:smartusline_string_to_highlight
match after each eval() in the parser and then applying the markers accordingly.
Yeah, I realized that after I commited the change. I'll probably implement shallow evaluation when I have a little bit of free time.
With 0194aaf8d789494159257897bb77f8ccce4cf107 shallow evaluation (e.g. %!MyStatusLine()) is now on by default, and there is a new smartusline_deep_eval option to do deep evaluation (%{} items returned by %!MyStatusLine())
I am using an expression in my statusline config, which looks as follows:
I think smartusline should evaluate this expression and then do its search-and-replace on the result.
I have tried the following code in the
SmartusLineWin
function, but did not get it to work properly:The issue appears to be that any "%{}" parts (returned from the function) need to be evaluated, too. (from ":h 'stl'": The result can contain %{} items that will be evaluated too.)
However, in my case, I would like to highlight the result of the following expression: "%{ShortenFilename(fnamemodify(bufname("%"), ":~"), 20)}"
Therefore smartusline would have to handle highlighting not only in the end (when everything is evaluated), but look for a matching
g:smartusline_string_to_highlight
after each "eval()".I for myself will just stay with the non-plugin approach for now - feel free to close this as "won't fix" if you consider it to be too much hassle.