Note that there are some explanatory texts on larger screens.

plurals
  1. POHighlight arguments in function body in vim
    primarykey
    data
    text
    <p>A little something that could be borrowed from IDEs. So the idea would be to highlight function arguments (and maybe scoped variable names) inside function bodies. This is the default behaviour for some C:</p> <p><img src="https://i.stack.imgur.com/9a4a4.png" alt="plain vim highlighting"></p> <p>Well, if I were to place the cursor inside <code>func</code> I would like to see the arguments <code>foo</code> and <code>bar</code> highlighted to follow the algorithm logic better. Notice that the similarly named <code>foo</code> in <code>func2</code> wouldn't get highlit. This luxury could be omitted though...</p> <p><img src="https://i.stack.imgur.com/k23Hk.png" alt="func hilighted"></p> <p>Using locally scoped variables, I would also like have locally initialized variables highlit:</p> <p><img src="https://i.stack.imgur.com/JmHlw.png" alt="highlight &lt;code&gt;i&lt;/code&gt; inside for"></p> <p>Finally to redemonstrate the luxury:</p> <p><img src="https://i.stack.imgur.com/JSjEU.png" alt="luxury again"></p> <p>Not so trivial to write this. I used the C to give a general idea. Really I could use this for Scheme/Clojure programming better:</p> <p><img src="https://i.stack.imgur.com/Q4RN1.png" alt="for clojure too"> <img src="https://i.stack.imgur.com/J6amb.png" alt="inside let construct"></p> <p>This should recognize <code>let</code>, <code>loop</code>, <code>for</code>, <code>doseq</code> bindings for instance.</p> <p>My vimscript-fu isn't that strong; I suspect we would need to</p> <ul> <li>Parse (non-regexply?) the arguments from the function definition under the cursor. This would be language specific of course. My priority would be Clojure.</li> <li>define a syntax region to cover the given function/scope only</li> <li>give the required syntax matches</li> </ul> <p>As a function this could be mapped to a key (if very resource intensive) or <code>CursorMoved</code> if not so slow.</p> <p>Okay, now. Has anyone written/found something like this? Do the vimscript gurus have an idea on how to actually start writing such a script?</p> <p>Sorry about slight offtopicness and bad formatting. Feel free to edit/format. Or vote to close.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload