Vimscript is dead - How to configure Nvim with Lua!
ฝัง
- เผยแพร่เมื่อ 7 ก.ย. 2024
- ► Live on twitch: twitch.com/joh...
► Twitter: / johncodez
► Home page: johncodes.com
Vim 9.0 introduces a new scripting, programming language to replace vimscript. In this video, we'll take a look at configuring Neovim only using lua, without any vimscript.
#johncodes
🚀 SUMMARY: Vim 9.0 has a new programming language that will likely one day replace vimscript entirely. There are alot of questions remaining in core vim around the backwards compatibility of vimscript and this new scripting language going forwards. Thankfully, Neovim has embedded Lua! Huzzah! Let's take a look at how we can configure neovim with lua, and only lua!
Lua docs: www.lua.org/do...
Nvim options docs: neovim.io/doc/...
Nvim lua API docs: neovim.io/doc/...
Download Nvim: github.com/neo...
I appreciate the "slow" tempo and the basic approach to this topic. I have previously watched ThePrimagen and his nvim setup, and even though i prefer his approach in general, i really do appreciate your video more as it is more basic and more explanatory. Thank you!!!
Glad it was helpful!
The typical problem with all those "cool Lua+Nvim" guys is that they never read language tutorials. So I've started to watch this video and, a miracle! I see him opening Lua reference.. but then I notice it's 5.4. Thanks God, my world stays the same as yesterday. They still haven't learnt the difference between Lua 5.1 and 5.4 )))
dude thank you i've been looking for a way to config neovim and this was really simple compared to trying to figure it out myself. it was a little confusing and i don't know code but as someone who loves awesomeWM i appreciate lua and you really helped out.
I just started learning lua today, but lua to me felt like (perl+javascript+python)/3. Thank you for the amazing tutorial!
god thank you. I have been looking for a long time and finally got on your video
Hope yall liked this video! Let me know if there's anything you have any questions!
Edit - here's my lua configs: github.com/jpmcb/vim-life
But it's pretty messy, so be warned ha. I'll clean it up soon!
Thanks for this, your explanations really demystified setting up a lua config. Finally made the switch today. I didn't think the difference in performance from a vimL config would be so drastic.
Hi, thanks for this! It really helped me to get into nvim and lua.
Quick question though: I've basically copied your config and tinkered around a bit with it to try and understand it fully. The only problem I still have is that I like to have the tabs set to be tabs and not spaces. And I can't figure out how to set that. It seems that vim.o.expandtab has no effect whatsoever. Is there a plugin that makes tabs to spaces automatically in the config or what am I overlooking? Can you help me?
@@timoyoungster the `expandtab` option takes entries and make them the equivalent number of spaces. neovim.io/doc/user/options.html#'expandtab'
So, you'd want to leave out that configuration option. But note, this isn't a retroactive setting: it won't take existing tabs or space and attempt to convert them, you'd need some kind of linter / parser for that.
Great explanations with even better documentation.
Good job mate
WOW! Thank you man, just getting into neovim and this was what I was looking for to get going!
hmm u love to touch a file then open the file in vim when just doing the vim file.txt if u save it at all it makes that. Great video
Ha true - pretty useless, but it makes it SUUUPER clear what I'm doing
@@JohnCodes yeah i get it for showing it for the video and also i use emacs with evil-mode for my windows work computer. Because nvim or vim is not easy to put on it.
Lua changed my life.
Really awesome/productive/efficient explanation/video, big thank you!
Can you do a video on how to incorporate go debugger with nvim-dap-go? I really liked this video as I'm switching to Astro Vim and would really know how to set up a debugger. Thank you.
Thanks a lot for this! Really needed this.
Any name or reference to the music running in the bg?
Thanks man, I got the good habit of wanting to learn everytNice tutorialng before I start sotNice tutorialng (wNice tutorialch is impossible) tNice tutorials quick guide is what I
Can you share your dotfile repo please. Thanks. This was super useful
github.com/jpmcb/vim-life
But disclaimer, it's pretty messy right now 😂
Hey, what's your background music? It sounds great
May I ask what boom arm you are using for your mic? It looks really cool!
I am still getting errors with packer after renaming
Thank you! This was really helpful! ❤
Can't help noticing you type :wqa every time. Maybe just try :x
You'd need `:xa` for the equivalent to `:wqa`
Nice one!
We use packer to install plugins. But how do we install packer? Does it come shipped with neovim?
Thank you for this resource
Was just about to comment on the name clashing, took me way to long to figure out what I was doing lol.
Very awesome! Tyvm ❤
Good video, thank you!
4:47 I wouldn't say lua is that close to python, it's closer to your first explanation "javascript meets C"
Thanks!
I feel as if Neovim users want Vimscript to die just so they can feel better about their choice of using Lua. These two projects are separate for a reason and I wish Vim will remain minimal and avoids the hype around Neovim. I picked vim over Emacs just because I wanted my editor to remain minimal and not include every new stupid technology (i.e whatever vscode brings to the table). The Neovim user base is one of the most toxic ones out there and I wish they would just leave us alone
"A minimal setup" Doesn't correlate in any way to Lua or Vimscript. You can go and setup you thing in either vim or neovim to just be whatever minimal setup you like. Its just that why would you want to use Vimscript in your setup when you can use a widely documented and even more minimal language like Lua ?
@@SnackLive because Lua is weird
You said vimscript dead... every lua nvim config - vim.cmd([[blablablabla]])
Why do you call the API "endpoints?" That doesn't make any sense, you're not making RPCs or sending data through a network, you're just calling library functions.
Anything can be an "endpoint" - it's the point you end at or where you "terminate" your call. And some API library calls don't necessarily terminate but require _additional_ calls. So, like you would call an HTTP or RPC endpoint, you may need to have a string of API library calls.
But it's mostly a weird vernacular thing I say 🤷♂️
@@JohnCodes Sorry for being pendantic.
In the first part of your video, you're spreading a lot of misinformation. Vim9 script is not a new technology. It was already available in vim 8.2 and most of the initial work was done in the vim9 fork of vim, which was merged back later on. It would be far more accurate to say that when significant changes happen in a codebase, more bugs are likely to appear, just like in any other language (including Lua), and that's of course, a very weak argument for dismissing vim9 script in favor of Lua.
Additionally, the claim that your implementation of LSP for the Go language is more readable than the equivalent code in vimscript is extremely subjective. Lua is a great language, very minimal and elegant, but as part of a language binding, it is really verbose, full of indirections with a messy feel due to the use of namespaces. Again, it is not Lua's fault, since the same can be said of the language bindings for python, ruby in vim. I have yet to see a single example of a concrete implementation in which Lua in neovim is more readable than the equivalent vimscript, let alone vim9 script which is even more readable without the quirkiness of legacy vimscript.
Stuff like "readability is subjective" are always implied, but there's also some degree where it's not so subjective. I don't know how I'd react if someone started codegolfing on the codebase of my work because "short means good haha", omit commenting on design decisions because "haha I can read it and so should you haha". I think you see where this is going.
DSL like vimscript is are fit for purpose and usually are more readable for that very reason. vimscript is great for configuration, and is still importatnt because a lot if is just ex commands in a file..which is what vim is built on. I mean :global :search all the good stuff is ex commands which is what vimscript is - commands in a file. vimscript was never 'designed', it just sort of evolved piece by piece, which is how it ended up the way it is. Lua is a great language, but for simple configuration of vim, it does a decent job but isn't needed, especially since you'll be calling into "vimscript" alot anyway (vim.cmd, vim.fn, etc.). vim9 was/is a huge improvement but you're correct - there's some information here that has sadly been passed around the vim/neovim community due to ignorance.
@@craigdanielmaceacher Well said. I appreciate your comment.
Would it be better to learn VIM first or can I go straight to learning NeoVIM?
Just go straight into Neovim
@@JohnCodes will have a look at it then, ta. 🙂
@@toranshaw4029 vim script is very hard to write and have no value to learn it
As a sysadmin: Learn pure VIM. As a developer who needs a local vscode replacement, NeoVIM is currently better.
@@guobreakinglead7147
There is Value and is alright to learn*
I'm waiting for helix...
helix deez nuts?
useful
pop-os, my man!
I’m interested in learning Vim, as it is aesthetically pleasing, but this folder structure thing is such bullshit. Why have all these folders with magical names and not just specify them in require :/
Do you share that config on github? I looked for it but I didn't find it
github.com/jpmcb/vim-life
It's pretty messy tho!
@@JohnCodes thanks!
LoL cool explnation instead of reading a bunch of line of text
Q: isn't lua embeded in legacy vim ?
I don't believe so. Neovim is the main entry point for using lua for configuration
It is not embedded, but there are language bindings to write plugins written in Lua. In fact, interfaces for lua (:h lua), python (:h python), ruby (:h ruby) and tcl (:h tcl) have been available for years, and for the most part, they share the same awkward feel than the neovim implementation (vim.fn, vim.g and so on)
I just use emacs :V
How's your pinky doing?
@@blvckbytes7329 I swapped caps lock with ctrl, made everything easier, not just emacs.
I wonder why Vim developers didn't simply use Lua, too.. They break backwards compatibility and waste this once-in-a-lifetime opportunity by introducing a stupid single purpose made-up scripting language instead of an already established, widely used and documented embedded programming language.
lua is like the opposite of java
Right. Used nowhere.
@@brethorne1067 yeah you’re right apart from the Nginx frontend that big companies utilise to serve a large majority of the websites you visit.
Oh and freeBSD’s default boot loader, a lot of redis plugins that run at huge scale serving your dumbass Java syntax.
Oh yeah and that doesn’t account for buildchain usage.
Language flaming is so pissy get real.
@@brethorne1067 forgot to mention the innovation in LuaJIT which will singlehandly provide more to value to programming then you ever will :)