0

Lets say I have a REPL ./repl, which reads a line from the user, evaluates it, prints it and then repeats.

I have a .vim file that does syntax highlighting for this language in my .vim/syntax directory and I want to use this file to highlight the repl input (and if possible output).

How can I do this using vim or a other programming knowing vim syntax files?

1
  • I think that would be a very convoluted way to add colors to your input/output. Perhaps, if you run some form of shell inside vim/gvim/neovim, and run your repl from there, while at the same time setting the Vim syntax of the buffer running the shell to your REPL language ?
    – VanLaser
    Commented Oct 12, 2016 at 21:16

1 Answer 1

1

As an interactive editor, Vim takes over the entire [terminal] screen. It is therefore not well suited to be used as a highlighting component (though there are ways inside Vim to access the rendered syntax highlighting, cp. the :help 2html script that renders a Vim buffer as HTML).

In my opinion, going this route isn't worth the effort. Rather, I'd suggest you have a look at alternative syntax parsers; many are just as powerful (and designed to be integrated). Though I haven't used it myself, the GNU Source-highlight might be worth looking into.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.