I occasionally like to tinker with syntax files (especially conceals; I use λ
for anonymous functions (lambda:
, fn
) in several languages).
However, one complaint with conceal is that I can only use a single character. When concealing, e.g., fn
, having one character breaks some vertical alignment. One solution is to use λ.
instead, keeping the two characters and aligning with the lambda-calculus origins.
In at least two syntax files I use, fn
is part of a syn-keyword
definition. In order to use the λ.
above, I need to do something like this:
syn match group /fn\@=/ conceal cchar=λ
syn match group /fn\@<=/ conceal cchar=.
However, syn-match
s have lower priority, so these don't apply. The original
syn keyword group fn conceal cchar=λ
works just fine, because it is a keyword defined later.
TL;DR
I would like to either
- remove
fn
from a syntax keyword group, or - override a keyword from a match
One possible solution is
syn clear group
" re-add everything else
" syn keyword group ...
But this fails when group
has more than just keywords and is very complex. It's also not scalable at all.
I'm open to some kind of meta-programming/parsing the output of syn list
, but it needs to be quasi-readable/understandable.
Here's a clojure example:
; should be concealed?
fn [x]
; definitely should be
(fn [x] x)
; definitely should be
( fn [x])
; shouldn't be, though my current keyword solution would
(let [fn 1] fn)
; same
(let [ fn 1] fn)
; definitely shouldn't be
(let [afn 1] afn)
And here's one from sml
(* should conceal *)
val id = fn x => x
(* also should conceal *)
val _ = (fn x => x) id
(*
technically this isn't valid SML, but it should conceal
and it demonstrates a beginning-of-line issue
*)
fn x => x
fn
for lambdas? (Just trying to find the best reproducer for your issue...)(let [fn 1] ...)
versions, the identifierfn
is being temporarily re-bound to1
. I won't mind if they get concealed, since I consider that an extreme abuse and would never make it past one of my code-reviews. The last example(let [afn 1] ...)
is different, since the identifier isafn
and that's "fine" stylistically, but shouldn't be concealed