3

After much Googling I have been unable to make Vim's code conceal feature work with Javascript and Typescript (without requiring a plugin).

I have been trying to use lines like the following in my .vimrc to conceal my code but without any luck:

syntax keyword Normal function conceal cchar=λ
syntax keyword Keyword return conceal cchar=>

Aim:

// Actual
function sum(a) {
  return function inner(b) {
    return a + b
  }
}
// Displayed
λ sum a
  > inner b
    > a + b

Goals:

  • Replace function with the lambda symbol
  • Replace return with the > symbol
  • Replace [name]([args]) with name args
  • Conceal the {
  • Conceal the }
Alex Mckay
  • 3,463
  • 16
  • 27

1 Answers1

1

Your snippet appears to work as intended if you enable the "conceal" feature:

cole

See :help 'conceallevel'.

But you may have a kind of race condition with other syntax scripts if you don't execute those :syntax commands at the right time. When in a TypeScript buffer, could you do :scriptnames and add the output of the command to your question?

romainl
  • 186,200
  • 21
  • 280
  • 313