Search code examples
vimluaruntimeconfigneovim

What is an external runtime in Vim?


I was reading up about setting up NeoVim and it is stated that NeoVim has an inbuilt Lua runtime, which makes it super fast.

Here is a reference to one of the posts regarding the same: https://www.reddit.com/r/neovim/comments/q7dp56/what_exactly_is_the_point_of_lua_in_neovim/

Does that mean Vim uses an external runtime? If so, what exactly is an external runtime?

If a runtime is a stage wherein the entity under concern is executed along with access to the supporting files required for its execution, I'm not sure how can there be an external/internal runtime and what would it mean for a text editor like vim/NeoVim.


Solution

  • You have two ways to extend Vim's functionalities:

    • With vimscript, the built-in scripting language which evolved over time out of the Ex commands inherited from its ancestors. This is probably what you call "internal runtime".
    • With the built-in interfaces to external scripting environments. It allows you to write the core of your plugins in Python, Ruby, Perl, Lua, MZScheme, and Tcl. This is probably what you call "external runtime" .

    Neovim added a third way by embedding a Lua engine, allowing, in principle, users to configure and extend without vimscript. This is probably what you would call a second "internal runtime".

    And Vim recently brought out a new version of vimscript, which you would also probably call a second "internal runtime".

    But what Vim calls a "runtime" is really just a bunch of directories and files that are looked up and sourced during startup. There is a notion of "system runtime" (directories and files installed globally) and "user runtime" (directories and files handled locally by the user), but "internal runtime" and "external runtime" don't make any sense.

    So, it has been possible to extend Vim with a number of languages beside vimscript for a very long time. Whenever you would need something that was not provided by vimscript, you could probably find it in Python or whatever and use it via the appropriate built-in interface. This has lots of obvious upsides but also some downsides, like the fact that Vim is rarely (never?) distributed with every interface enabled, which can be quite a roadblock for the user and quite a burden for the author.

    Concretely, embedding the Lua engine makes it possible for Neovim users to do their thing in what they consider a better language, without having to worry as much about support: Lua is built-in, therefore Lua is always available, therefore it is the new de-facto standard for extending Neovim.

    But none of that changed anything to the notion of "runtime".