Developer Productivity, v2

Customizing Neovim

ThePrimeagen
terminal
Developer Productivity, v2

Check out a free preview of the full Developer Productivity, v2 course

The "Customizing Neovim" Lesson is part of the full, Developer Productivity, v2 course featured in this preview video. Here's what you'd learn in this lesson:

ThePrimeagen introduces Neovim and explains the differences between Neovim and other code editors like VS Code. He also mentions the usefulness of learning Vim motions and suggests incorporating a keyboard-centric approach to improve productivity.

Preview
Close

Transcript from the "Customizing Neovim" Lesson

[00:00:00]
>> ThePrimeagen: All right, so I'm gonna play around a little bit with Neovim, show you guys a few things about Neovim. Let's show of hands, how many people here are VS Coders, slash Zedders, all that the other side, yeah, yeah. Anyone, Neovimers, any Neovimers in here? Let's go, mana for my own heart.

[00:00:17]
We got one people, [APPLAUSE] all right. That's all I wanna say, just because it's not that I'm trying to convince you to use it. It's that I want to show you guys what it can do, and then at some point in the future it might solve your problems in a way that's different.

[00:00:33]
Cuz one of the biggest problems, and everybody has this problem, every last person has this problem. Right now, I've been using Zed to solve some problems. Did I? I deleted Zed. When I was doing all this, I wiped out my local.bin. Zed was in local.bin, I'm gonna have to reinstall Zed.

[00:00:49]
But you get the idea that everyone has a notion of how something should be used. And when you use something different, you try to make it into that. You see this all the time, especially when someone learning a new language. If you've only ever done JavaScript and you attempt to learn Go, you're gonna try to write Go like you write JavaScript.

[00:01:06]
And then you're gonna go, this language sucks, and I'm gonna go, yeah, it kind of does suck. Not because it sucks, but because how you use it kinda sucks. It's not really meant to be used this way. That's a bad way to approach it, you shouldn't approach it that way.

[00:01:18]
And so it's just like you always have to kind of adopt a new mentality when you use something new. And so Neovim has its own way you should use it and it's very, very different than how you use VS Code. And so if you go into Vim, you try to make it into an IDE, you probably won't like it.

[00:01:31]
It just probably will be really awful. It just won't be a good experience and I don't blame you, because I wouldn't like it either. All right, creating your own Neovim experience. I'm gonna give you a little brief look. This isn't really a follow along section. If you already have Neovim set up, you theoretically could.

[00:01:47]
If you kinda have just a basic idea, you could, but I'm just gonna kinda show you a couple cool things. So, first off, like we've kind of talked about dot files, Neovim also has its RC file that gets started. I'm gonna go into here, and we had this under config neovim.

[00:02:03]
I'm gonna replace this as nvim right here, and it has a knit loop, so I have Hello fan. So if I were to execute dev-env and then open up vim, you'll notice that it prints this. And that's because that script I just wrote executed and only had one line, print, right, and that's it.

[00:02:19]
And so theoretically I could do a lot more. Now, the nice part is that anything that's on the path will be executed or will be included in vim. And so, one of the paths is config/nvim, so my XDG path. So anything in here I can now incorporate into my Vim experience.

[00:02:36]
So I can go in here and create a folder called Lua, and inside of there I can create it as prime, inside of here, I can have an init.lua, and I can have print( hello from prime, right? Oopses, how do I even do that? That was weird. All right, there we go, must have pressed something.

[00:02:57]
There we go, so we have that, and now I have this beautiful little file right here. So I can now require in that prime file. I can go, require("prime"), and this will have that. That's not require, require. There we go. So anything that's in there, can I figure it out?

[00:03:13]
There you go, it can figure that out. It can figure out that script. That means you can build kind of a complex set of .files to really incorporate and run your neovim experience, and this is really just the basic. You have an init file, anything that's a source can have a Lua directory.

[00:03:29]
Anything inside that Lua directory can have subdirectories. Those subdirectories are requireable by name. And so me personally, I put all my .files under config neovim, Lua, the prime engine. So that way I don't run into anyone else's library, cuz if you just name it math, maybe there's gonna be something called math, right?

[00:03:45]
You don't wanna name it dumb things, because or else you're just gonna collide and it stinks. So I just have it as my name, put it in there, and then it just works. So that means if I go in here and I quit this, and I do that, and I bring this back up, and I vim, you're gonna notice this says hello from prime, and then hello fem, right?

[00:04:00]
So I went and did both of them. It required in my file, and then it did the printing out and so everything's kinda running. So that's like the basic idea of this. It gets really extensive. If you actually want to get into some level of neoviming and you wanna go do all that, check out kickstart.neovim.

[00:04:16]
I probably should add the word Neovim in there, cuz there's entirely too many things called a kickstart in the universe. But if you went here, you could go through and this just gives you the minimal file that you need, it just gives you a net.lua. And the net.lua, when it opens up, it has some nice little comments, some cool little ASCII.

[00:04:36]
Look how cool that ASCII art is. And inside of here, it just has everything you'd need to get Vim started as one file with a bunch of auto completing LSPs, telescope. Everything you possibly need, shows you how to use package manager all in one file. And it's mostly comments, just to kind of explain the whole thing and so it's pretty fantastic.

[00:04:54]
And so just like a thing, check it out. It's a good way to get started. I just wanna show you it's very easy to get started, easy to create your own directories. That's all you need to know, learn Kickstart. Everything else is pretty fantastic. All right, so now, we're gonna get into, I don't wanna call them bragging moments, but we're gonna do some pretty cool stuff with all of this.

[00:05:14]
So let's see. I had one more note about Vim. If you see someone that's using something like Vim and they're using it really profesionally, and you wanted to start with that, the best way to do that is to start by learning Vim motions. Use your current editor, VS Code.

[00:05:26]
Maybe you just wanna use the motions and never use Vim ever. That's totally good, but I would argue that Vim motions are an objectively better experience than your mouse every time. You learn how to use them, you will be significantly faster. The juice will eventually be worth the squeeze if you want to get good at it, but at some point your mouse is just not gonna be as good.

[00:05:49]
>> Speaker 2: Is it similar to people who are really good with spreadsheet shortcuts?
>> ThePrimeagen: Yeah, when you meet anyone that knows a program really well, you go, wow, that's really cool, right? It's just because they've just taken the time to learn it. The thing is I program for 30 to 50 hours a week.

[00:06:03]
So, I should just learn these things, because I'm constantly manipulating text. My only thing I do is take text, make it into one shape, into another shape, into another shape, into another shape. And it's just this constant act of doing that. And so you can do that in any editor, it does not have to be Vim.

[00:06:19]
Just learn a text like a keyboard centric approach to your life, and it will pay off bigly as time goes on, just not all that convenient.
>> Speaker 3: What's the Vim motion to expand all the windows?
>> ThePrimeagen: Expand all the windows?
>> Speaker 3: [LAUGH]
>> ThePrimeagen: That one does not exist, because Vim does not have that as an option, okay?

[00:06:38]
And you could, though, you could make it. I bet you you could do that, because you could write a little Lua script that contacts your window manager. And your window manager could make all the things pop out, and then you could use your mouse, and it'd be fantastic.

[00:06:51]
Also, I said this earlier, which is, when you're first using something like Vim, you probably have this experience that makes you feel very confused. And that's because you don't have a file tree. There's no file tree. So if you had a file tree, all of a sudden, it starts to look more of what you're used to.

[00:07:09]
And so whenever you look at something that looks new, it feels very confusing.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now