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

ความคิดเห็น • 79

  • @BristlyBright
    @BristlyBright 11 หลายเดือนก่อน +10

    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  10 หลายเดือนก่อน +1

      Glad it was helpful!

  • @Noname-hc4hc
    @Noname-hc4hc 2 ปีที่แล้ว +18

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

  • @jr_Linux
    @jr_Linux 2 ปีที่แล้ว +6

    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 ปีที่แล้ว +1

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

  • @tekalegn_amanuel_1
    @tekalegn_amanuel_1 2 ปีที่แล้ว +1

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

  • @JohnCodes
    @JohnCodes  2 ปีที่แล้ว +5

    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 ปีที่แล้ว +1

      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.

  • @DanielTubul
    @DanielTubul ปีที่แล้ว +1

    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!

  • @MENTOKz
    @MENTOKz 2 ปีที่แล้ว +4

    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 ปีที่แล้ว +4

      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.

  • @td0999
    @td0999 ปีที่แล้ว +1

    Lua changed my life.

  • @sdscode
    @sdscode ปีที่แล้ว

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

  • @RootsterAnon
    @RootsterAnon ปีที่แล้ว +1

    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.

  • @need4eat
    @need4eat 2 ปีที่แล้ว +4

    Thanks a lot for this! Really needed this.

  • @mazenmohsen3423
    @mazenmohsen3423 10 หลายเดือนก่อน

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

  • @calderonharoldkim8128
    @calderonharoldkim8128 2 ปีที่แล้ว

    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

  • @markmcdonnell
    @markmcdonnell 2 ปีที่แล้ว +5

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

    • @JohnCodes
      @JohnCodes  2 ปีที่แล้ว +5

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

  • @guobreakinglead7147
    @guobreakinglead7147 2 ปีที่แล้ว +1

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

  • @iduran
    @iduran ปีที่แล้ว

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

  • @rivelmods
    @rivelmods ปีที่แล้ว

    I am still getting errors with packer after renaming

  • @sujeewa8067
    @sujeewa8067 ปีที่แล้ว

    Thank you! This was really helpful! ❤

  • @kexuyo
    @kexuyo 2 ปีที่แล้ว +2

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

    • @chandebrec5856
      @chandebrec5856 ปีที่แล้ว +1

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

  • @bernardfitzgerald5697
    @bernardfitzgerald5697 7 หลายเดือนก่อน

    Nice one!

  • @vikingthedude
    @vikingthedude ปีที่แล้ว

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

  • @wyfyj
    @wyfyj ปีที่แล้ว

    Thank you for this resource

  • @jonnykopp
    @jonnykopp 2 ปีที่แล้ว

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

  • @Kiryana
    @Kiryana ปีที่แล้ว

    Very awesome! Tyvm ❤

  • @YannMetalhead
    @YannMetalhead 2 ปีที่แล้ว

    Good video, thank you!

  • @batikha7486
    @batikha7486 ปีที่แล้ว

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

  • @birdofhermes6152
    @birdofhermes6152 ปีที่แล้ว

    Thanks!

  • @aws96314
    @aws96314 ปีที่แล้ว +3

    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 ปีที่แล้ว +1

      "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

  • @pavel_trpn
    @pavel_trpn 2 ปีที่แล้ว +2

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

  • @arzelaascoli6765
    @arzelaascoli6765 ปีที่แล้ว +1

    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  ปีที่แล้ว +1

      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.

  • @rsmith31416
    @rsmith31416 2 ปีที่แล้ว +6

    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 2 ปีที่แล้ว +2

      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 2 ปีที่แล้ว

      @@craigdanielmaceacher Well said. I appreciate your comment.

  • @toranshaw4029
    @toranshaw4029 2 ปีที่แล้ว +1

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

    • @JohnCodes
      @JohnCodes  2 ปีที่แล้ว +7

      Just go straight into Neovim

    • @toranshaw4029
      @toranshaw4029 2 ปีที่แล้ว

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

    • @guobreakinglead7147
      @guobreakinglead7147 2 ปีที่แล้ว +1

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

    • @armynyus9123
      @armynyus9123 2 ปีที่แล้ว +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*

  • @eateat2934
    @eateat2934 2 ปีที่แล้ว +1

    I'm waiting for helix...

  • @scc4213
    @scc4213 2 ปีที่แล้ว

    useful

  • @lThePotatoCrew
    @lThePotatoCrew 2 ปีที่แล้ว

    pop-os, my man!

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

  • @soytxemaleon
    @soytxemaleon 2 ปีที่แล้ว

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

    • @JohnCodes
      @JohnCodes  2 ปีที่แล้ว +1

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

    • @soytxemaleon
      @soytxemaleon 2 ปีที่แล้ว

      @@JohnCodes thanks!

  • @theaungmyatmoe
    @theaungmyatmoe ปีที่แล้ว

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

  • @johnnybrasseur5156
    @johnnybrasseur5156 2 ปีที่แล้ว

    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)

  • @returned_to_monke8872
    @returned_to_monke8872 2 ปีที่แล้ว +1

    I just use emacs :V

    • @blvckbytes7329
      @blvckbytes7329 2 ปีที่แล้ว +1

      How's your pinky doing?

    • @returned_to_monke8872
      @returned_to_monke8872 2 ปีที่แล้ว +2

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

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

  • @mygamesm
    @mygamesm 2 ปีที่แล้ว +3

    lua is like the opposite of java

    • @brethorne1067
      @brethorne1067 2 ปีที่แล้ว +3

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