Vimscript is dead - How to configure Nvim with Lua!

Ғылым және технология

► Live on twitch: twitch.com/johncodes
► 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/docs.html
Nvim options docs: neovim.io/doc/user/options.html
Nvim lua API docs: neovim.io/doc/user/lua.html
Download Nvim: github.com/neovim/neovim

Пікірлер: 79

  • @BristlyBright
    @BristlyBright9 ай бұрын

    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!!!

  • @JohnCodes

    @JohnCodes

    9 ай бұрын

    Glad it was helpful!

  • @DanielTubul
    @DanielTubul Жыл бұрын

    Great explanations with even better documentation. Good job mate

  • @kubahasek
    @kubahasek Жыл бұрын

    WOW! Thank you man, just getting into neovim and this was what I was looking for to get going!

  • @tekalegn_amanuel_1
    @tekalegn_amanuel_12 жыл бұрын

    god thank you. I have been looking for a long time and finally got on your video

  • @sdscode
    @sdscode Жыл бұрын

    Really awesome/productive/efficient explanation/video, big thank you!

  • @jr_Linux
    @jr_Linux2 жыл бұрын

    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.

  • @eiakimorooka1809
    @eiakimorooka1809 Жыл бұрын

    I just started learning lua today, but lua to me felt like (perl+javascript+python)/3. Thank you for the amazing tutorial!

  • @sujeewa8067
    @sujeewa8067 Жыл бұрын

    Thank you! This was really helpful! ❤

  • @need4eat
    @need4eat2 жыл бұрын

    Thanks a lot for this! Really needed this.

  • @Kiryana
    @Kiryana Жыл бұрын

    Very awesome! Tyvm ❤

  • @Noname-hc4hc
    @Noname-hc4hc2 жыл бұрын

    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 )))

  • @wyfyj
    @wyfyj Жыл бұрын

    Thank you for this resource

  • @iduran
    @iduran Жыл бұрын

    May I ask what boom arm you are using for your mic? It looks really cool!

  • @YannMetalhead
    @YannMetalhead Жыл бұрын

    Good video, thank you!

  • @td0999
    @td0999 Жыл бұрын

    Lua changed my life.

  • @guobreakinglead7147
    @guobreakinglead71472 жыл бұрын

    Hey, what's your background music? It sounds great

  • @bernardfitzgerald5697
    @bernardfitzgerald56976 ай бұрын

    Nice one!

  • @MENTOKz
    @MENTOKz2 жыл бұрын

    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

  • @JohnCodes

    @JohnCodes

    2 жыл бұрын

    Ha true - pretty useless, but it makes it SUUUPER clear what I'm doing

  • @MENTOKz

    @MENTOKz

    2 жыл бұрын

    @@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.

  • @RootsterAnon
    @RootsterAnon Жыл бұрын

    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.

  • @birdofhermes6152
    @birdofhermes6152 Жыл бұрын

    Thanks!

  • @calderonharoldkim8128
    @calderonharoldkim8128 Жыл бұрын

    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

  • @mazenmohsen3423
    @mazenmohsen34239 ай бұрын

    Any name or reference to the music running in the bg?

  • @jonnykopp
    @jonnykopp Жыл бұрын

    Was just about to comment on the name clashing, took me way to long to figure out what I was doing lol.

  • @vikingthedude
    @vikingthedude11 ай бұрын

    We use packer to install plugins. But how do we install packer? Does it come shipped with neovim?

  • @markmcdonnell
    @markmcdonnell2 жыл бұрын

    Can you share your dotfile repo please. Thanks. This was super useful

  • @JohnCodes

    @JohnCodes

    2 жыл бұрын

    github.com/jpmcb/vim-life But disclaimer, it's pretty messy right now 😂

  • @JohnCodes
    @JohnCodes2 жыл бұрын

    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!

  • @lua5dot1

    @lua5dot1

    2 жыл бұрын

    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.

  • @timoyoungster

    @timoyoungster

    2 жыл бұрын

    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?

  • @JohnCodes

    @JohnCodes

    2 жыл бұрын

    @@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.

  • @scc4213
    @scc42132 жыл бұрын

    useful

  • @rivelmods
    @rivelmods Жыл бұрын

    I am still getting errors with packer after renaming

  • @lThePotatoCrew
    @lThePotatoCrew2 жыл бұрын

    pop-os, my man!

  • @batikha7486
    @batikha7486 Жыл бұрын

    4:47 I wouldn't say lua is that close to python, it's closer to your first explanation "javascript meets C"

  • @kexuyo
    @kexuyo2 жыл бұрын

    Can't help noticing you type :wqa every time. Maybe just try :x

  • @chandebrec5856

    @chandebrec5856

    Жыл бұрын

    You'd need `:xa` for the equivalent to `:wqa`

  • @soytxemaleon
    @soytxemaleon2 жыл бұрын

    Do you share that config on github? I looked for it but I didn't find it

  • @JohnCodes

    @JohnCodes

    2 жыл бұрын

    github.com/jpmcb/vim-life It's pretty messy tho!

  • @soytxemaleon

    @soytxemaleon

    2 жыл бұрын

    @@JohnCodes thanks!

  • @eateat2934
    @eateat29342 жыл бұрын

    I'm waiting for helix...

  • @meltygear5955

    @meltygear5955

    2 жыл бұрын

    helix deez nuts?

  • @pavel_trpn
    @pavel_trpn2 жыл бұрын

    You said vimscript dead... every lua nvim config - vim.cmd([[blablablabla]])

  • @toranshaw4029
    @toranshaw40292 жыл бұрын

    Would it be better to learn VIM first or can I go straight to learning NeoVIM?

  • @JohnCodes

    @JohnCodes

    2 жыл бұрын

    Just go straight into Neovim

  • @toranshaw4029

    @toranshaw4029

    2 жыл бұрын

    @@JohnCodes will have a look at it then, ta. 🙂

  • @guobreakinglead7147

    @guobreakinglead7147

    2 жыл бұрын

    @@toranshaw4029 vim script is very hard to write and have no value to learn it

  • @armynyus9123

    @armynyus9123

    2 жыл бұрын

    As a sysadmin: Learn pure VIM. As a developer who needs a local vscode replacement, NeoVIM is currently better.

  • @uuu12343

    @uuu12343

    2 жыл бұрын

    @@guobreakinglead7147 There is Value and is alright to learn*

  • @johnnybrasseur5156
    @johnnybrasseur51562 жыл бұрын

    Q: isn't lua embeded in legacy vim ?

  • @JohnCodes

    @JohnCodes

    2 жыл бұрын

    I don't believe so. Neovim is the main entry point for using lua for configuration

  • @rsmith31416

    @rsmith31416

    2 жыл бұрын

    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)

  • @theaungmyatmoe
    @theaungmyatmoe Жыл бұрын

    LoL cool explnation instead of reading a bunch of line of text

  • @PainfulBBQ
    @PainfulBBQ Жыл бұрын

    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 :/

  • @aws96314
    @aws96314 Жыл бұрын

    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

  • @SnackLive

    @SnackLive

    Жыл бұрын

    "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 ?

  • @zytr0x108

    @zytr0x108

    Жыл бұрын

    @@SnackLive because Lua is weird

  • @arzelaascoli6765
    @arzelaascoli6765 Жыл бұрын

    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.

  • @JohnCodes

    @JohnCodes

    Жыл бұрын

    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 🤷‍♂️

  • @arzelaascoli6765

    @arzelaascoli6765

    Жыл бұрын

    @@JohnCodes Sorry for being pendantic.

  • @returned_to_monke8872
    @returned_to_monke88722 жыл бұрын

    I just use emacs :V

  • @blvckbytes7329

    @blvckbytes7329

    2 жыл бұрын

    How's your pinky doing?

  • @returned_to_monke8872

    @returned_to_monke8872

    2 жыл бұрын

    @@blvckbytes7329 I swapped caps lock with ctrl, made everything easier, not just emacs.

  • @rsmith31416
    @rsmith314162 жыл бұрын

    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.

  • @meltygear5955

    @meltygear5955

    2 жыл бұрын

    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.

  • @craigdanielmaceacher

    @craigdanielmaceacher

    Жыл бұрын

    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.

  • @rsmith31416

    @rsmith31416

    Жыл бұрын

    @@craigdanielmaceacher Well said. I appreciate your comment.

  • @mygamesm
    @mygamesm2 жыл бұрын

    lua is like the opposite of java

  • @brethorne1067

    @brethorne1067

    2 жыл бұрын

    Right. Used nowhere.

  • @liamkearn

    @liamkearn

    2 жыл бұрын

    @@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.

  • @liamkearn

    @liamkearn

    2 жыл бұрын

    @@brethorne1067 forgot to mention the innovation in LuaJIT which will singlehandly provide more to value to programming then you ever will :)

  • @Linuxdirk
    @Linuxdirk Жыл бұрын

    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.