You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I guess that would be possible, though you'd have to be careful with tuple bindings like let f1, f2 = ... or other irrefutable matches. I assume you'd be fine with coloring ordinary bindings like let x = 3, too. I'm not sure how much it would add to readability, but feel free to try implementing this if you like it. Just be warned: Vim highlighting rules are notoriously brittle and finicky so test well.
I did that at home! This is how course hacky and fairly limited, hence I did not propose it for merging. Put this for example in your ~/.vim/after/syntax/ocaml.vim:
" Highlight let‐binders, ie. identifiers which are given an immediate value." Limitations:" — does not recognize let-patterns like “let (a,b) = …” or “let (C x) = …”" [ — does not recognize “let[@inline] f = …” nor “let (*lol*) f = …” ]" — does not support object values and methods" Highlighting other binders (function arguments, “fun”, “function”, “try with”," match with”…) is much more difficult and would require writing a more accurate" parser."syn match ocamlLetBinder /\(\<\(let\(\_s\+rec\)\?\|and\|for\)\>\_s\+\)\@<=\<\(\l\|_\)\(\w\|'\)*\>/" This is a coarse approximation that recognize simple PPX annotations, as in" “let[@inline] f = ...”.synmatchocamlLetBinder/\(\<\(let\(\_s\+rec\)\?\|and\|for\)\>\_s*\(\[@\(@\|\w\|\.\|\_s\)*\]\_s*\)*\)\@<=\<\(\l\|_\)\(\w\|'\)*\>/hilinkocamlLetBinderIdentifier
I quite like how vs-code highlights the function name in a color different from its arguments. Would that be possible in vim as well?
VS Code
Vim
The text was updated successfully, but these errors were encountered: