 In the early days of this YouTube channel, one of the most common topics that was discussed was VIM. But then about two and a half to three years ago, I moved away from VIM over to Emacs and I've done a lot of video coverage of Emacs, but people have asked me to revisit VIM and especially NeoVIM, which NeoVIM sees a lot of development. There's a lot of action with NeoVIM. NeoVIM is an improvement really on VIM because they're moving away from using VIM script to an actual programming language that is Lua. So that is going to see a lot more people actually contribute to NeoVIM because now you can use the Lua programming language to contribute to NeoVIM and especially to plugins because now you can actually write NeoVIM plugins using Lua. Again, a real programming language instead of that horrible VIM script that nobody really liked. And because NeoVIM continues to improve with each new release, people have asked me to revisit NeoVIM and especially people have asked for a video on how to convert their existing NeoVIM config that uses VIM script. How can you convert that over to a config that actually uses the Lua programming language? And I thought, that's interesting because I don't know how to do that. So I actually spent the last couple of days actually converting my NeoVIM config, my init.vm over to a Lua config file, init.lua. And honestly, it was very easy to do this. I'm going to walk you through it. So let me switch over to my desktop and this is my old init.vm. So this is my old NeoVIM config that was just written using just standard VIM script. There's not much to see here. It's not a very lengthy document, right? Because I'm not one of these people. I never wanted a super long NeoVIM config file because to me it seems pointless. It's a terminal text editor, right? It's kind of designed to be minimal, light, fast. And if you're one of these people that your NeoVIM init file is starting to be a thousand lines long, two thousand lines long, five thousand lines long, that's crazy. Like, what are you doing at that point? And I'm being serious. At that point, you really should have long ago already started investigating Emacs because that's what Emacs is for, right? Basically you write your own text editor, right? You build it from the ground up using Emacs list, but it's kind of the difference between Emacs and VIM and NeoVIM. So really, if you're one of those people that your config file is like a novel, you know, maybe explore Emacs, but for me, you know, my NeoVIM config, even though it's simple, I did want to convert it to Lua just to see how it would look. So typically when I'm looking to configure things that, you know, I've never configured before, whether it be text editors, window managers, whatever it happens to be, I'll just do a quick search on Google and I'll find somebody that's already done some of the work for me. And that's what I did in this case. If I switch over to my web browser here, I found this person's .files over on GitHub. I'm sure I could have found a million .files that had an example of an init.lua file. But you know, I opened this guys and you know, and one of the problems I had finding some good config files to take a look at it, many of them are these very lengthy documents. Again, I don't understand the people that have these crazy long VIM or NeoVIM config files, but this person had his broken down into, you see, require settings, require auto command, require plugins, require keybinds. So he's got these broken down into their own separate config files. So he's requiring them, right? Importing them basically into the init.lua. So actually we need to go investigate all of these files to actually see what he's doing with his config. So let me back up and go into this directory. And there are those files, auto command.lua, keybinds.lua, plugins.lua, settings.lua. And I'm just going to go into the settings.lua here. And it's pretty easy to see what's going on in this lua config file. You see at the top, he's got these two lines here. Local G equals VIM.G, local O equals VIM.O. So he's just setting a short variable here for these because he's going to type these over and over again because all of these variables down here would be VIM.O dot term GUI colors equals true. Or VIM.O dot scroll off equals eight, yada, yada, yada. See he would have to type that a million times. So just to save him from having to type VIM.O, he's just setting that to simply O. And the same thing for G is actually VIM.G. And you can see he has most of your standard Neo VIM settings already here. As far as do you want relative line numbers turned on, the number width, do you want to expand tab, what's your tab stop, your shift width, your soft tab stop, you know, just standard VIM config settings. They're all here in this settings.lua file. And it's not very lengthy. So what I did is I just copied everything here. Now I'm going to change a lot of the values that he had set because I prefer different values for some of this stuff. So let me switch back over to my config file here. And again, that was the old config. Now let me open the new config and I do colon E for edit here and open up my new init.lua. And you can see I pasted a lot of what he had in his settings over here. So let me go back to the old init and let me scroll past this part here that begins with the plugins. We'll get to the plugins in just a second. But starting here is a lot of the settings here with set. That's mostly what's going on over here with these VIM.0 settings here. And since my config is not a very lengthy config, you know, my old init.lua, you know, and most of it was just the settings. So once I really had all of that set, you know, I didn't really rebind a lot of the key bindings. I had a few, but most of the standard key bindings I'm fine with. But just for sake of completeness, I did want to experiment with changing some key bindings. Again, just to know how to do it in case I need to do it in the future. So let me go back over to this guy's .files here. And we already took a look at his settings.lua and I just copied the whole thing. Even settings I'm not going to use. I just commented those out just to have them there for reference for later. And then I went into key bindings.lua just to see how you map key bindings. And honestly, this is not hard at all. They created this local function and you see map MKV. So how this works is you're going to give a mode. So that's the value M. So N, of course, is normal mode. I would be insert mode. And then the key. So when you tap the key in in this case and then V is the value, what does it actually do? Well, it actually does NZZ in this case. Not exactly sure what he's trying to do. It looks like he's trying to keep the cursor in the center of the document for an obvious key binding. That's obvious. You can see what it's doing. Map, quitting NeoVim. So map in normal mode. Anytime he does control Q, what does that actually do? It gets you into command mode colon Q return to quit out of NeoVim. So that's a pretty obvious example of exactly how to map a key binding using NeoVim and using Lua in this case. So I wanted to add some of this to my config just to have it there for reference. So what I ended up doing is I took these two key bindings here, just as an example, and I added it to my config. And as you can see, I added his local function here, local function map, mode, key value. And then I added this here, mimic shell movements. And by shell movements, these are really Emacs key bindings, right? These are standard, can do Emacs key bindings. The shell, the bash shell, the fish shell, ZSH, they all use Emacs bindings by default. And he wanted to add them, I guess, into his Vim config, which I found rather interesting that a Vim user wanted some Emacs-like bindings in their config. So I thought I would add it to mine as well, since I'm an actual Emacs user. And you can see we're mapping I for insert mode, control E, and what it does, control E is going to take us to the end of the line. You can see it's going to run escape to get into normal mode, capital A, which is append, right? We're going to the end of the file, getting into insert mode. Well now, we're just doing control E to do that. And control A does the reverse. It goes to the beginning of the line and keeps us in insert mode. So now we know how to do most of the settings, as far as setting things like tab stops and things like that. Now we know how to do the key bindings. And the only real major thing to get into is plugins. Now as a longtime Vim user, I've used several plugin managers for Vim. I've used a pathogen and bundle and plug and probably several others. But in this guy's Neo Vim config here, he's got plugins.lua. And then he's got Vim.api.inVimCreateAutoCommand yada yada yada. He's doing something here that involves this program called packer and he's running a command called packercompile. And I'm not actually familiar with this plugin manager for Neo Vim that's called packer. It is all new to me. But looking at it, I was intrigued because you can see in this block here return require packer startup and inside this block you have use and then the name of a plugin use and then the name of another plugin use and then the name of another plugin. It's got some options as well. This reminded me a lot of use package with Emacs. So it seems to be a almost like an Emacs inspired Vim plugin manager, which I thought was really neat. And honestly looking at it, it looks pretty simple to use. He's got a lot going on again. He's one of these Neo Vim users that has a ton of plugins and he's really trying to do a lot. You know, for me, I only needed about a dozen plugins. So let me show you what I did. So I have return require packer startup function and then similar to what you saw in the example config, I have use and then the name of a plugin. So this is going to be a plugin that will install and will use. And the first one, of course, needs to be packer itself, right? We have to install the packer plugin manager. And from there, you just keep using these use statements, for example, use in Vim dash Lua line slash Lua line dot in Vim. That is for a plugin called Lua line, which is the status line you see down here. That is another plugin I've never used up until a couple of days ago, but I thought it was interesting because I've always used an airline and a light line and some other status lines with Vim and Neo Vim. But I wanted one that was specifically written in Lua. So I found Lua line and honestly, it looks great. So I'll keep using it. And really all I did, let me move back to this window here and go to the top because I've got the plugins at the top of my old and then all I did is I went and I basically just copied all of this stuff over as if I changed the word plug to use. And that was pretty much it, right? Some of the plugins I decided not to copy over to my new file. And of course, then in my new file, I'm using some plugins that I wasn't using in the old file. But for the most part, the plugins was dead simple to get working. And for those of you new to packer, the commands for packer is get into command mode. So colon, start typing pack, and if I do tab complete, you will see some of the commands available. The obvious one you'll want to do at first would be pack packer install. And then it should open up a split and it'll tell you exactly what it's installing. In this case, we've already got everything installed. There's also a packer update where it would update all of your plugins. But again, since this is pretty fresh, there shouldn't have meant anything that really needed updating. And really what you've seen is pretty much everything I've got in my config. Again, I'm not one of these people that has a lengthy config, but let me go from the top. So you've got me defining some variables here. I did G for vim.go for vim.o, capital A for vim.api, because somewhere here I did have one setting that is a vim.api command, but I may have more down the road. So I just went ahead and set that to a single letter variable. But then I set again a lot of the standard vim settings for text width and tab stop shift width. And there was a ignore case, which of course is set to true. Smart case is set to true. Then you see g.mapLeader equals space. So we're setting the space bar as the leader key in vim, which for me is easy because space is the key for DOOMemax, right? Space, most of the DOOMemax key bindings begin with space as part of the key core. So we're just going to keep space as our leader key here. And then here is that vim.api command, which we just assigned the variable capital A to. It looks like what I was doing here, this is highlight the region on a yank on a copy. And I got this again from the config file over on GitHub. Of course, I'm going to link to that guy's GitLab so you guys can see his example. And of course, I'm going to link to my config that I created from his config as well. So you can take a look at mine as well. But that's it. I mean, here's the key bindings. I only added two key bindings as an example. And then of course, the plugin section is the end of the file here. Now, one thing I did add to the plugin section, I found this really cool color scheme here. In vim-base16, it's a NeoVim specific base 16 color scheme plugin. And it has dozens of color schemes built into it. So before I was adding various plugins in my old vim config, my old NeoVim config for various popular color schemes, like I'd have a Dracula plugin or a OneDark plugin, et cetera. Well, this has you covered, this invim-base16. So if I actually do colon, and I just start typing color scheme space, and then let me do tab and look at all of these base 16 color schemes, right? Let me do one dark is actually the one I'm currently using here is one light. Oh my goodness. That is horrible. Let me do color scheme base 16 and then solarized here. Of course it is. There's solar flare, but that's not what I wanted. I wanted solarized dark. So you guys know I'm all about color schemes, especially in DTOS, I try to have everything configured to where we can quickly switch between 10 or 12 popular color schemes. So that really helps me out. If I ever want to package this NeoVim config as part of DTOS. Now let me switch back to color scheme base 16, one dark. Yeah, that's much easier on the eyes. So there you have it. That's my new init.lua file, my NeoVim config written in Lua. Really easy. Obviously, you just go find other people's configs for inspiration, but even if you just wrote it from scratch, you know, go read some documentation. This is not rocket science, right? Like literally, I think anybody could do this. So I'm really glad I looked into this because I do think that NeoVim is definitely headed in a right direction. I think NeoVim, I think the maintainers of NeoVim really appreciate some of what Emax does. And I think they see some of the advantages maybe that Emax has over standard Vim and they're trying to bridge that gap a little bit where Bram, the maintainer of standard Vim, mainline Vim, he's really set in his ways and really doesn't want to move off of the way that Vim has always done things. For example, Vim script. They're actually recently they released a new version of Vim with a new version of Vim script. And like, why nobody likes Vim script anyway? Why aren't you constantly trying to improve Vim script when nobody wants it? Right. And people have actually tried to convince Bram to actually move to Lua like NeoVim is doing. It would just make sense because everybody understands that NeoVim made the right decision moving to Lua. And I really wish the mainline Vim would do the same thing. But yeah, again, everybody has their own projects. Everybody wants to go their own way. And you and I may not agree with certain decisions. But again, this is it's like my projects. I do things sometimes that I want to do. I get pull requests, merge requests. People are like, you're doing this wrong. You should do it this way. It's like, no, no, no. This is the way I want to do it because it's the way I want to do it. It's my project. You know, it's my project, my rules. This is my vision, my direction. And I get that. But I think as far as for the masses and for widespread popularity and gaining more users, NeoVim definitely headed in the right direction. Now, before I go, I need to thank a few special people. I need to thank the producers of this episode. Dustin Gabe, James Matt, Maxim, Michael, Mitchell, Paul West. Why you bald, homie, Alan, our dragon, Chuck, Commander, Henry, Diokai, Dylan, Greg, Marsdrom, Erion, Alexander, Paul, Pete's Archon for tour, Polytech reality. Pete's for Les Red Prophet, Steven, Tools Devler and Willie. These guys, they're my house tiered patrons over on Patreon. Without these guys, this quick look at it and knit.lua file. It would not have been possible. The show is also brought to you by each and every one of these fine ladies and gentlemen. All these names you're seeing on the screen right now. These are all my supporters over on Patreon because I don't have any corporate sponsors. Corporate sponsors wouldn't sponsor somebody like me, right? Because all I do is I go to GitHub and I just copy other people's dot files, right? That's half of what I do. I depend on you guys. If you like my work and want to see more videos about Linux, free and open source software, subscribe to DistroTube over on Patreon. Peace. Now I need to convert my knit.lua to an knit.org.