Turn VIM into a full featured IDE with only one command

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Vim the only Editor to also double up as an escape room is a highly configurable text editor that focuses on efficiency and performance out of the box however Vim is pretty underwhelming despite having one of the best set of key bindings for any software it's lacking many modern features found in other editors well let's Rectify that with one command we'll turn the standard Vim setup into this a full-featured IDE but before we can use our magic command we need to get our environment set up the first thing to actually do is install neovim ah yeah I forgot to mention we're going to use a more modern Vim to achieve our IDE status don't worry they're pretty similar neofim is actually a fork of him and provides features we're going to need I use Arch by the way so I'm going to install using Pac-Man for other operating systems check out neovim's website for instructions once installed you're probably going to want to Alias the Vim command to load near them instead which will save you from your own muscle memory you may also want to add this Alias to your shell startup script as well so that it persists across sessions you're also going to want to have a nerd font installed and set up as your terminal font I'm using jetbrain's mono nerd font personally But whichever one you fancy will work and finally you just need to ensure that you have git installed now you may be thinking that they're only being one command as a bit of a stretch but just bear with me here is the one command I was referencing to get set up before I share it you'll probably want to make some configuration changes later on so make sure to finish this video to figure out how to actually customize your new Vim configuration what we're going to install is called nvchad which is a set of neovim lure configuration files that will give us a lot of IDE goodness for free to install it you just have to run one of the following commands depending on your operating system these commands will clone the Envy chat repo into your neovim configuration directory so first make sure to backup any existing configuration you already have you may also want to delete your local neovim cache as well to prevent any issues after that you can then run our single command and clone a copy of nvchat once the Clone is completed let's go ahead and open up Neo then you'll be prompted to install the example configuration go ahead and type in n as in no this will ensure you're working from the same starting point as I am after that you should see a window in which all of the default packages are being installed once that's done we can explore some of the functionality of our new IDE the first thing you're going to want to do is probably change the theme nvchat supports a custom theme switcher internally so you're able to choose the theme you want you can bring this up by typing space T and H in that order with the theme switcher up you can navigate up and down using control n or Ctrl P which stands for next or previous or you just type in the name of the theme that you're looking for personally I use Capuchin because it's the best color scheme ever so I'm just going to go ahead and set that up now that we have our theme set up we're going to want to apply it to our programming languages neovim ships with trees that are installed which allows us to easily set up syntax highlighting for many languages to install Syntax for a new language we just need to call the TS install command from the VIN command line using the colon key we can also check which syntaxes we have installed using the TS install info command tree seter is great but it doesn't have syntax highlighting for every language fortunately there's a way we can achieve this using other Vim plugins but I'll talk about that later on in the video when we look at customization modern editors typically provide a file tree for visually navigating a project nvchat is no different and provides one through a package called nvim tree to open it you just need to press Ctrl and N we then have a working tree we can use to navigate our project with to open a file is as easy as selecting the file and pressing enter sometimes in a larger project it's good to Mark a file by actually pressing the m key this will allow you to easily find it when you're scrolling through later on as well as browsing and opening files we can also perform write actions on our file system we can create a new file by pressing the a key and typing in the new file name we can also copy files using the C and then P key and can rename files using the r key whilst having a file tree is great for visual navigation it's not the most efficient way to jump around a code base if we know the file we want to open we can just jump straight to it to do so you can open up the find files menu using space f and f this will open up a new window which we can then use to search for files in our project by the way the space key is the leader key in nvchab and is used to initialize a lot of commands as well as searching across all of the files in our project we can also perform a search across only the files we've already opened to do this we use the space f and B command to open up a window that is constrained to show only our open buffers at this stage you may be concerned that there are a lot of new key bindings to remember in order to make the full use of our new IDE fortunately Envy chat ships with a cheat sheet feature which we can use to quickly reference key commands the command to pull up the cheat sheet is space C and H which brings up a new window we can then navigate through to close the cheat sheet is the same command again additionally nvchat also provides a feature to help suggest key combinations if we press the leader key aka the space key and wait for a second a window appears which will suggest other commands to follow with and what those commands will do both of these features can help to get the most out of our new IDE nvchat has some simple key bindings for navigating our windows to move around you just need to press Ctrl and then what are the navigation Keys either h j k or l to see this in action you can open up new panes in Vim using the VSP or SP commands which stand for vertical split or split and then use the subsequent keys to move about additionally NV chat comes with the ability to toggle absolute and relative line numbers for use with it we can toggle line numbers using space followed by n or relative line numbers by using space r and Nan one thing that can be difficult to navigate in Vim is open buffers fortunately we know we can navigate using the find buffer window we saw before but end of each add also provides a tab bar similar to other Ides this bar will show any buffers that we have open as well as any van tabs to cycle through our buffers from left to right we can use the tab key or use the shift Tab Key to cycle in Reverse if we have too many buffers open we can close our active buffer by using the space and X key combination modern editors typically allow access to a terminal session to enable the user to run command line tools nvchat is no different and provides key bindings to access the neovim shell opening up a command line shell can be achieved by pressing the space key followed by H for a horizontal window or space followed by V for a vertical window this gives access to a full featured shell in order to perform command line operations nvchat provides a lot out of the box but there are some custom configurations you'll likely want to do in order to get set up fortunately envychat provides a mechanism to customize pretty easily one thing to note is that all of the configuration is in Lua personally I find this easier than vinscript but it wouldn't hurt to run through a quick lure tutorial to get acquainted to add customizations we need to add our custom configuration to one of the two files in our custom directory either the chatrc.lure file or the init.lure file each one has its specific use case the chat rc.luophile is used for overriding the default config lure table of MV Chad whilst the init.lure file is used for overriding neovim options and commands basically whenever you want to make changes to plugins or Envy chat options then use the chat rc.lure file if you want to make changes to the typical neovim or film configurations use the init.lure file instead now that we know where to place customization code let's go ahead and make our first change I mentioned earlier that tree seter doesn't support every language a good example of this is Crystal fortunately there is a Vim plugin on GitHub that we can use first we'll need to open up our chatrc.lure file you'll notice that our theme has also been set here as well the documentation recommends to group all plugins into their own configuration file called plugins.lure let's go ahead and reference that new file in the plugins key of our table next we can create our new file in our custom folder after creating the file let's open it up and return an empty lure table inside now we can add our plugin as a value in The Lure table we'll also need to specify the file type that we want the plugin to load for as well this is because nvchat uses the lazy plugin manager internally which will lazy load plugins to improve startup performance to specify the file type we just set the Ft key to Crystal additionally we can also disable lazy loading for a plugin by setting the lazy key to false but this should be avoided if possible to then install the plugin we would normally just call Lazy sync in the Vim command line but as this is our first plugin we'll need to close vim and reopen it again now we should see the lazy package manager window and the Crystal plugin install if we then open up a crystal file we can see that syntax highlighting is working neat in addition to installing plugins we may also wish to configure them to enable certain features we can add any plug-in configuration to our plugins.lure file here we're going to enable the auto formatting of Crystal code in our plugin we can do this by adding in a config function which will set our film configuration when the plugin is loaded for autocomplete we just need to set the value of our Crystal Auto format to 1. when we save this file we should see lazy automatically reconfigure once the reconfigure is complete we can open up our Crystal file again and see the auto formatting take place when we save as I mentioned before we can also set standard Vim configuration in our init.lure file I prefer to keep my lines less than 80 characters long so I'm going to add this into my configuration and here you can see it works perfectly the final piece that we want to configure is LSP which stands for language server protocol LSP is basically a protocol that enables editors to receive co-completion and other tooling using language servers neovim comes with this out of the box and envy chap provides some configuration we can use to manage LSP plugins let's go ahead and add in an LSP Conflict for all rust analyzer first we'll need to add in an override for our LSP config package configuration to do that let's open up our customs plugins lure and add in a new entry for neovim nvim LSP config then we'll add a config function block which will require the default LSP config and a custom LSB config file that we're about to create next let's create our custom LSP config at custom configs LSP config.lure now we need to import the on attach and capabilities methods from the main LSP config to use in our setup functions we also want to import the LSP config package now we'll add in an entry to the LSP config for rust analyzer we'll also pass in the on attach and capability variables finally we'll set the file type that we're interested in and where the language server should consider as the project root for our rust projects if you want to add in other LSP server configurations you can reference the neovim LSP config server configurations guide on GitHub or type in Colon help LSP config-all on the Vim command line with our neovim configuration setup next we want to make sure we have rust analyzer installed on our system you can do this using rest up which is typically my preferred method or you can use the Mason plugin provided by nvchat to manage LSP binaries for you to use Mason is as simple as adding an entry to our custom config to override the default config and then to add our LSP server to the ensure installed block then we can use the Mason install all command to download and install the language server and with that we have a working LSB server for co-completion with rust nvchat has been my go-to neovim configuration for just over a year now and it's been a real pleasure to use as my daily driver I hope this video inspired you to give it a try as your own neovim configuration as always thank you for watching and I'll see you on the next one
Info
Channel: Dreams of Code
Views: 230,789
Rating: undefined out of 5
Keywords: text editor, vim, neovim, nvim, chadnv, emacs, nano, coding, editors, ricing, customization vim, how to set vim, tutorial, vimscript, lua
Id: Mtgo-nP_r8Y
Channel Id: undefined
Length: 11min 54sec (714 seconds)
Published: Sun Apr 02 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.