
Neovim Configuration and Plugins in Fennel Lisp - bwidlar
https://oli.me.uk/neovim-configuration-and-plugins-in-fennel-lisp/
======
aasasd
For some time, I happen to use a machine with very very meh CPU performance.
Turns out, popular scripting languages are slow, except for Lua. (And maybe
also Perl, didn't check yet.) I thought that JS has fast start-up, but some
Lua scripts of mine that do file IO are finished in less time than Node's
‘hello world’.

I now wish people used Lua everywhere instead of JS, Python or Ruby. Some are
doing desktop programming in JS, for personal productivity software, like
Alfred alternatives Zazu and Cerebro. Eeeeh nah, productivity software needs
to be _fast_. Would be lots better to do that in Lua. And it's certainly a
better idea for editor plugins than using Python.

Fennel transpiles code to Lua so fast that it's feasible for scripting, even
on my machine.

I believe also that Lua might be able to do true parallelism, via libraries.
(Haven't tried yet, though.)

~~~
minxomat
I build Lua programs in prod. I use fennel or moonscript as the frontend, and
everything runs on openresty (cli tools using resty and servers using the full
stack).

Parallelism is enabled by a data flow architecture on top on nginx workers
(compare TPL Dataflow in C# or Intel TBB in C++).

Concurrency is enabled using coroutines (nginx threads). It's virtually
impossible to write blocking code and that's without any async or other bs in
sight.

It's really fcking fast. Like, some parts of the overall arch are rust, but in
the real, io bound world there's virtually no speed difference. Of course
safety is good. But you get types and other neat zero cost abstractions for
Lua using Haxe.

This Dataflow architecture also benefits from openresty built in concurrency
safe queues, maps etc with atomic commit and cross worker access. Everything
feels so damn effortless. I didn't have to do any work on making it scale.
Just tweak the number of workers knob and boom, almost linear benefit. That's
for rust and Lua, both awesome at parallelism in this case.

Anyway, even though I never write pure Lua, I still think it should have won
against python (man did we try, even riding that ML wave).

I'm in love, but me is not many.

~~~
rcarmo
What sort of queueing mechanism do you use? I’ve bee trying to get into
OpenResty but there are few documented examples of that kind of thing, and
anything that does Dataflow is interesting to me.

~~~
minxomat
Bidirectional queues are built-ins in openresty[1]. The scheduler is project-
specific and uses that.

[1] - [https://openresty-
reference.readthedocs.io/en/latest/Lua_Ngi...](https://openresty-
reference.readthedocs.io/en/latest/Lua_Nginx_API/#ngxshareddictlpush)

------
Seirdy
Fennel is a Lisp that transpiles to Lua.

One of Neovim's goals is to make Lua a first-class citizen. Eventually, it
will be possible to replace your init.vim with an init.lua. Making an init
script in Fennel sounds like a great way to bring Emacs ideas to Vim, like how
Emacs' evil-mode brought Vim ideas to Emacs.

Recently, Neovim got an official client for the Language Server Protocol
merged into master. All the example configurations[0] are written in Lua.

[0]: [https://github.com/neovim/nvim-lsp](https://github.com/neovim/nvim-lsp)

------
grewil2
Interesting to see. The Vim people at work are constantly harrasing us two
Emacs users, claiming that lisp is old and silly, and that vimscript is good.
Maybe change is acoming.

~~~
jdjdjjsjs
That sounds really strange to me. Even amongst major vim users and proponents
I have never heard anyone say vimscript is good.

Maybe I don't get out enough.

~~~
Seirdy
Vimscript is good for setting simple configurations, but bad for large/complex
software.

The Neovim team found that Lua seems to do both pretty well and has a fast
implementation (LuaJIT), so they're trying to get Lua to be Neovim's primary
extension language. Python and Javascript also seem to be popular languages
for Neovim extensions.

------
uncletaco
Well I know what I'm wasting next weekend on now.

~~~
Olical
Glad I could be of assistance :D (sorry in advance for any time lost to Lisp
fun times)

------
ethagnawl
Standard Vim has support for Lua bindings. Does anyone know of a reason this
wouldn't be applicable there as well?

~~~
Olical
Oh does it? Nice! I am a 100% Neovim user so I focus on that but if this works
in Vim 8+ with minimal changes I'm totally open to pull requests to support /
document it!

~~~
ethagnawl
If I can find some time, maybe I will take a pass at it.

------
ilovecaching
This is why I don't use neovim. VimScript is god awful (emacs lisp is also a
pretty bad lisp imo), but this is just adding additional layers of complexity
for no measurable gain in value. If I wanted to transpile to an equally bad
scripting language and talk over RPC I'd just go become a front end developer
(those web devs are out of control). I just want vim to start quickly, not
crash, and generally get out of my way. Vimscript is good enough for any sort
of scripting/plugins I want/need and I know it's going to just work.

~~~
justinmk
> This is why I don't use neovim ... this is just adding additional layers of
> complexity for no measurable gain in value

It's a plugin. It is not shipped with Neovim.

> I just want vim to start quickly, not crash, and generally get out of my way

That's a very low bar, which indicates you definitely aren't Neovim's target
audience. If you're happy with Vim, carry on.

