How I Setup Neovim To Make It AMAZING in 2024: The Ultimate Guide

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up you guys in this video I'm going to be showing you everything you need to know to set up neim from scratch and turn it into something pretty amazing neovim and its ecosystem has grown and evolved a lot since my last complete setup guide which I made over a year ago so this is meant to be my updated complete setup guide for 2024 we're going to be using the lazy. envm plug-in manager to set up some awesome and useful features you'd expect in any modern editor like a nice file explorer a fuzzy finder to easily search for things throughout your projects LSP functionality paired with autocomplete as you type treeit sitter and some really cool features that come with that as well as nice ways to interact with Git within neovim and some other really useful plugins that I've discovered along the way this setup is primarily geared towards web development which is what I primarily do but everything I'll be talking about can be adapted to many other languages and workflows along with this video I'll have a blog post with all of the commands and code I'm going to be using so you can easily follow along with and copy and paste anything onto your own setup as well as the repository with all the source code for my config both of these will be linked in the description also if you want to stay up to date with me and everything that I'm learning and doing make sure to subscribe to my newsletter down in the description as well with that said let's get started all right so I've opened up a terminal window here there's a couple of things we're going to want to install before we get started setting up neovim the first thing you're going to need is a true color terminal so the color scheme can work properly in my case I'm using iterm 2 then we're also going to need the Homebrew package manager to install Homebrew on your machine you can use the following command I'm just going to press enter here once that's done if you're on Apple silicon you'll also need to add it to your path to do so you can run this command and then this one and then you should be done you can check if you can use home brew Now by doing Brew D- version now we can install neovim I'm going to do Brew install neovim to install it once you install neovim you can do nm-- version at the time of recording this video I'm going to be using version 0.9.5 then you're also going to need a nerd font so that icons and neovim show up properly I also recommend you do this with home brew you can do Brew tap Homebrew Cask fonts this will allow you to install nerd fonts with Homebrew and then I'm using meslo nerd font to install it you can do Brew install font meslo LG nerd font once you've installed that font you can open up these settings on your terminal I use command comma to open this up and over in profiles under text down here I have meslo LGS nerd font mono now some of our plugins will make use of rip grap for search functionality we can do Brew install rip grip to install it and then finally to set up some web development related stuff like installing the language servers we're going to need npm so I would recommend you install node you can do do Brew install node now before we begin I want to give a quick rundown of what the file structure will look like at the end of this project your configuration file will be located in your home directory underc config envm in this folder you'll have a init.lua file which is what neovim will look at whenever it starts and then we'll have this Lua folder I like to use this folder with my name you can call it whatever you like this is to avoid any naming conflicts and then I like to have this core folder where I set up my basic options and key maps and then this lazy. Lua file will set up lazy. enm which is the plugin manager we're going to be using to install and set up all of our plugins and under the plugins folder we'll have a list of all of the different plugins that we're going to be using for our setup each of these files will have configuration for that specific plugin all right so let's start setting up this file structure now we're going to do make directory dasp Tilda sl. config envm we're using the dasp so that any parent folders that don't exist are also created we're going to press enter then we're going to move into this directory by doing CD Tilda sl. config slnm and then we're going to create our main init.lua file by doing touch init.lua now we're going to do make directory DP again to create the Lua folder and inside the hosan folder and inside the core folder and then we can do make directory luah SL hosan SL plugins and then finally we're also going to create the lazy. Lua file by doing touch luah hosan la. Lua now to show you guys the file structure we just created I'm going to run the tree command as you can see we have the main in it. Lua file here and then we have the Lua directory and inside we have the Horan directory and inside the core directory the plugins directory and the lazy. L file to set up lazy. envm all right now we're going to open up the envm directory by doing envm Dot and then we're going to go into the Lua folder into hon we'll go into core and we're going to create the options. file by pressing the percent key or shift five and we're going to call this file options. Lua and then press enter now the first thing I want to do is change the appearance of the file explorer so that it's a bit easier to visualize things I'm going to use Vim docmd you can use this to run Vim script in a Lua file and we're going to do let G networ list style equal to three so that netrw which is the built-in neovim file explorer uses the tree list style I'm going to save this I'm going to open up the file explorer by doing C in explore then I'm going to go up a directory by placing my cursor over these two dots and pressing enter then I'm going to go up another level and again then I'm going to go to in it. Lua and press enter to open it up and in here I'm going to do require and then we want to load the options. Lua file that we just created to do this we can start a path ignoring the Lua folder so I can do hosan doe. options and then I'm going to save this file I'm going to quit nein by doing col q and enter and then I'm going to do envm dot again and you'll see now that the file explorer changes to tree format all right I'm going to open up this Lu directory this hosan directory go to core and open up the options. Lua file again and I'm going to start configuring some options here I'm going to do local opt is equal to bm. opt this is just to be a bit more concise then I'm going to do op. relative number is equal to True save this this will show relative numbers in our buffer to show this change I'm going to do colon source and percent and press enter as you can see here the numbers on the left hand side are relative to the position of my cursor I really like this option for moving around in new of them so if I want to move to the line where I set up the netrw list style I know it's four lines above me so I can do 4K and if I want to go back I know it's four lines below I can do 4J now I also want to know the absolute line number for the line the cursor is currently in so I can do opt do number equal to True let's save this and do colon Source percent now I'm going to set up tabbing and indentation with the following options these two lines here help set up the indentation as two spaces we want to expand tabs to be spaces and this will copy the indentation level of the current line to the next one when you create a new line if you're curious and want to dive deeper into any of these options you can check out more information by doing colon H for help and type out one of the options like Auto indent and press enter and you can read a little bit more about what it does now I also want to disable line wrapping so I'm going to do op. WP is equal to false and then I'm going to add the following to set up my search settings I want search to be case insensitive but if I use mixed casing in my search then it'll change back to case sensitive I'm going to save this this and I'm going to do colon Source percent if I do forward slash and look for ignore then it's just regular case and sensitive search but if I do ignore with uppercase it won't find anything because now it's case sensitive I also want to highlight the current cursor line by doing opt do cursor line is equal to True let's save this by the way I'm using colon W enter to save and I'm going to do colon Source percent to reflect the changes then I want to add the following to help set up the appearance of neovim we want to set term guy colors to true so that the color scheme can show up properly we set the background to dark so if a color scheme supports both light and dark it will use the dark version and we want to show the sign column on the left hand side I'm going to save this and I'm going to do colon Source percent then I'm going to add the following this helps set up back space to work as you would expect it to then I'm going to add the following this will make sure that whenever we copy any text with a neovim with any of our operators it'll use the system clipboard so that we can paste that anywhere else on our computer then I'm going to set up some options for how windows will get split I'm setting split right equal to true so that if we split a window vertically it'll go to the right and the second one where split below equals true means that if I split the window horizontally it'll go to the bottom I'm going to save this with colon W enter and do colon Source percent to reflect the changes now I'm going to open open up the Explorer by doing colon explore then I'm going to add a new file under core by doing colon e lu/ hosan SL core SL init.lua and press enter then I'm going to add require hon. core. options I'm going to save this open the file explorer again and then down in the main in A.L file instead of requiring hosan doc core. options we can now require just jan. core and save this file I'm going to open the Explorer Again by doing colon explore enter and I'm going to add a new file to set up our key maps by doing colon e lu/ hosan SLC SL key maps. Lua then I'm going to set up my leader Key by doing Vim dog. map leer equal to space I'm going to save this and then I'm going to add the following we're using this for conciseness then to set up a key map we can do key map. set and then specify the Vim mode in which this key map will apply for example I want to set up a key map for insert mode with I then you specify the key map I'm going to do JK and then what this key map will do this is going to be Escape then finally I'm going to create a table here where I set the description of this key map like so and this is going to be exit insert mode with JK and close this table and a closing parenthesis I'm going to save this then I'm going to open up the Explorer by doing colon explore I'm going to go to the init.lua file under core and in here I'm going to add require hon. core. keymaps I'm going to save this and I'm going to exit neovim by doing colon q and enter open it up again with envm DOT and enter then I'm going to open up the L directory hosan core and go back to key maps and you'll see now that if I go into insert mode now I can do JK to get out of insert mode all right now I'm going to add the following it sets up leader NH H to clear search highlights I'm going to save this and I'm going to do colon Source percent and if I start a search with forward slash I'm going to look for keymap and press enter now if I want to clear these highlights I can do liter NH so if I do space NH it'll clear out the highlights then I'm going to add the following two this is for incrementing and decrementing numbers I'm going to save this do colon Source percent and then if I do a one here now if I do space plus it'll increment the number and if I do space minus they'll decrement it then I'm going to add the following to set up some key maps for splitting up Windows I'm going to save this with colon W enter and do colon Source percent and now if I want to split vertically I can do space SV split horizontally with space sh I can close a split by doing space SX and if I resize these splits with my mouse I can make them equal size Again by doing space SE I'm going to close this split with space SX the way I like to think about creating these key maps is typically to First use my leader key and then have a specific letter for the functionality I want to create these key maps for so in this case I'm using S for split windows and then the letter after it describes what the specific key map does then I'm going to add the following to set up key maps for my tabs so again as you can see here I'm using T to remember that all of these key maps are for working with my tabs I'm going to save this and do colon Source percent and then if I do space t o o for open that'll open up a new tab I'll do that again with space to O if I want to close a tab I can do space TX if I want to go to the previous tab I can do space TP for previous and space TN where n stands for next I'm going to go back with space TP now let's say I want to open up this current file in a new tab I can do space TF so you'll see now that this file is in two different tabs I'm going to close this one with space TX and this one with space TX all right now that we've set up our basic options and key maps we can start setting up all of our plugins I'm going to open up the file explorer by doing colon explore go down here to lazy. Lua and press enter to open that file now the first thing I want to add is the following this will bootstrap lazy so that when we open up neovim it'll get installed if it isn't already installed on our machine and then we're going to require lazy and then call Dot setup and then I'm going to pass the path to the folder that will hold all of our plug-in specs or plug-in configurations this is going to be jan. plugins and I'm going to save this I'm going to open up the explore with colon explore and I'm going to go down to the main init.lua file and in here I'm going to add require hosan do lazy so that the lazy little file that we just modified gets loaded when we open up neovim I'm going to save this file and I'm going to exit neim then I'm going to do envm enter we'll get this message that says no specs found for module hos. plugins because we haven't set up any plugins yet I'm going to press enter here now we'll have a special command available to us which is colon lazy I can press enter and that will open up the lazy. nmui this will look a lot better in a second when we install our color scheme you'll see here that we have just one plug-in installed which is the lazy. enmin plugin itself to close this you can press on Q I'm going to open the explore with colon explore and press enter then I'm going to do colon e to create a new file this one will be luah hosan plugins SL init.lua I like to use this file to set up some plugins that don't require much configuration we're going to return a table and I'm going to add plenary which is a Lua plugin that many other plugins will make use of I'm also going to add the following which is the Vim TMX Navigator plugin which will make it easy for you to navigate between splits within neovim and also to t-mo panes I also want to point out that these names just point to GitHub repositories this is the name of the GitHub user that created the plugin and this is the name of the plugin itself so if you're looking add a plugin in GitHub you just need to follow this format if you want to install that plugin I'm going to save this with colon W and press enter and you'll see now that lazy. envm notices a change in our config I'm going to press enter and do colon lazy now to open up the lazy UI and you'll see here that plenary and Vim TMX Navigator are listed as not installed to install them you can use uppercase i and now they're installed I'm going to close the I with Q now we can exit neovim and go back in and these plugins will get loaded to avoid doing that right now I'm going to do colon lazy reload and pass the name of a plugin let's say I want to load the Vim t-mo Navigator plugin do Vim Das t-navigator and press enter now I'm going to create a vertical split with my keymap which is space SV and let's say I want to navigate between these two windows with Vim tmu Navigator we can use contrl and HJ K and L let's create another split by doing space SH now I can do contrl K to go up contrl J to go down crl H to go to the left and crl L to go to the right I'm going to close the split with space SX and this one with space SX all right now we're going to set up our color scheme I'm going to do colon explore and I'm going to add a new file by doing colon e Lua horian SL plugins /color scheme. Lua now we can return a table here I'm going to be using tokyoite in the setup I'm going to give it a priority of 1,000 to make sure that this plugin loads before any others then I'm going to add a field here called config this will run whenever the plug-in loads we're going to pass a function to this and close the function with end and then inside we're going to use bm. CMD to run Vim script and we're going to do color scheme Tokyo night and save this file lazy. enm sees the change I'll press enter I'm actually going to close neovim now and do colon Q press enter open it up again with envm Dot and you'll see now that the color scheme has been loaded and everything looks a lot better you might have also noticed that the lazy. MMI opened up automatically because it noticed the missing plug-in and went ahead and installed it I'm going to go back to Lua hosan plugins and open up the color scheme. Lua file and I'm going to make some changes to it I'm going to add the following down here these are just a set of colors that I'm going to use to modify the Tokyo night color scheme this is just personal preference then I'm going to require the Tokyo night plugin I'm going to call its setup function and inside pass a table to it I'm going to set the style to Knight there's a couple of different styles for the Tokyo KN color scheme you can take a look at the repository to see examples of the different styles and then I'm going to set the on colors field to a function that receives a colors argument and inside I'm going to modify the colors with this following code this makes use of the colors we defined above to modify the colors of the color scheme remember that all of this code is available in my repository as well as the blog post which are both Linked In the description I'm going to save this file exit neovim with colon q and enter and open it up again with envm Dot and this is how it looks like now now to make it a bit easier to keep working on this config I'm going to add a better file explorer I'm going to do colon e and it's going to be in luah SL hosan slpl plugins and the name of the file will be nm- tree. Lua here we'll return a table then we're going to pass the short URL for the plugin we're going to be using this is the envm tree plugin then we're going to add a dependencies field and this is going to be equal to the short URL for a different plugin called envm web dev icons this is used to show the file icons in the Explorer then again we'll add a config field that is equal to a function that will run whenever the plug-in loads then the first thing we'll do is require the plug-in like so then we'll add some recommended settings from the envm tree documentation then I'm going to add envm tree. setup and pass a table to it and I'm going to add the following options inside this will set the default width of the file explore I wanted to also show relative numbers I'm using this to change the icons for when a folder is closed and when it's open it'll use this one for when it's closed this one for when it's open then down here I'm disabling the window picker so that it works nicely with window splits and I do want to show files that are ignored by get so I'm setting ignore equals false here I'm going to save this and finally I also want to add some key maps to interact with the Explorer I'm going to add them down here at the bottom again this is just for conciseness and we follow the same pattern we use keymap do set specify the mode in this case they're all used in normal mode and I'm using leader followed by E I'm just going to save this to show you how it all works I'm going to save it you'll see that lazy. envm notices a change I'll press enter and open up the lazy UI with colon lazy and press capital I then I'm going to close the UI with q and then I'm going to load this plugin by doing colon lazy reload envm D Tree do Lua you can use tab here to finish the command I'm going to press enter and now if I do space e it'll toggle envm tree if I do it again it'll close it if I do space EF it'll open up the file explorer but at the location of the current file I'm working on I find this to be really useful if I'm working in a big project you can also close it with space EF if I open up the Explorer with space e and I do space EC it'll collapse everything and then sometimes I need to refresh the Explorer so I have another key map that's space erer for reloading envm tree I'm going to close it with space e this CMD here is the equivalent of doing colon for command line mode and then this is the envm tree command that we want to execute and the CR here is the equivalent of pressing enter you'll be seeing this a lot as we continue to Define our key maps if you want to take a look at all the different options that you can use to configure envm tree you can do colon H nm- tree and press enter and then down here you can go to envm tree Ops and you can do control and closing bracket it'll jump to that section and you'll see all of the different options that you can set up here I'm going to close this with space SX all right so the next thing I'm going to do is add the witkey plugin to make it easier for you guys to remember the key maps that you define for your config let's open the file explor by doing space e I'm going to go into the Lua directory hosan plugins and to add a new file under this folder we can press a and then type out the name for it this is going to be which- key. Lua we going to press enter I close the file explorer with space e return a table again then we're going to add the following this is the short URL for the plug-in then we're going to specify an event field so that we can lazy load this plug-in we can specify the very lazy event so that lazy. envm knows that it can load it later and it's not that important for the initial UI then we're going to add the following this init field is a function that will run during neovim startup instead of when the plug-in actually loads and here we're going to set timeout to true and timeout length to 500 MCS this is how long which key will wait to activate you'll see this in a second and then finally we want to call which key. setup but we can tell lazy. envm to do this automatically with the following we just specify the Ops field which is a table of options that gets passed to the setup function but we're leaving the table empty so that it just uses the default configuration if you want to make changes to it then you can modify this table you can take a look at the options available in the witch key repository let's save this file press enter and do colon lazy to open up the UI press capital I once it's installed we can press q and then we can do colon lazy reload and type out which and press tab to finish that out and then press enter to load this plug-in now let's say I press my leader key which is space after 500 milliseconds which key activates and it lets me know what options I have available after pressing my leader key and as you can see here we have EST and n as prefixes so if I press s which is the key maps for splitting up windows it's important that when you define those key maps you add the description field so that which key can display this so if I do V now it'll split vertically awesome all right next we're going to be setting up a pretty awesome plugin called telescope this is going to be our fuzzy finder and it makes it really easy to navigate and look for files and text throughout our projects I'm going to close this split with space SX open the file explorer with space e and under plugins I'm going to add a new file with a it's going to be called telescope. Lua and close the Explorer with space e I'm going to return a table here and then the first thing we want to add is the short plugin URL for telescope then we're going to specify a specific branch of the repository that we want to use then we're going to specify some dependencies inside We'll add first the short plugin URL for plenary we'll also add the telescope FCF native plugin to improve the Sorting performance of telescope and finally we're also going to add the dev icons plugin as a dependency here this is the same one that enm tree uses to show file icons then we're going to add a config function here that again will run whenever telescope loads inside will require the telescope module as well as the actions subm module and then we're going to call telescope. setup we're going to change some of the defaults we're setting the path display to Smart this changes how the path is displayed within telescope it makes it a bit easier to identify a specific file if the file name is pretty long and then we set up some key mappings for when we're in insert mode we can use contrl K to go up contrl J to go down and control Q to send selected items to the Quick Fix list now finally we're going to add this line here to load the FCF extension this will improve the Sorting performance and then we're going to Define some key maps for telescope these will be available in normal mode and again I'm using leader and a prefix this time it's going to be F which I think of as short for find I'll show you how these work in a second I'm going to do colon W and press enter to save the file and then colon lazy to open up the UI and you can see here that we have these missing plugins we're going to press capital I to install them now I'm going to close the UI with Q then we can load this plugin by doing colon lazy reload and we can start typing out telescope and press tab I want telescope. envm so I'm going to do tab again and then press enter I've made everything smaller so that we have more space you'll see now that if I do space FF for find files we can look for files in our project now and we have file previews on the right hand side I can use contrl K to go up in the results and contrl J to go down and I can filter the results by typing out a file name you'll see here that the paths are truncated due to the path display option which we set to Smart I'm going to look for nm- tree you'll see that it filters down to that file and if I press enter it'll open it up I can also look for text within the whole project by doing space FS which is short for fine string and I can look for Vim for example and this will give me all of the results of Vim within my project if I find one that I want to look at just press enter and it'll take me to that file let's go back to telescope by doing space FF and look for telescope and press enter if I want to look for recently open files I can do space FR for find reset I'm going to close this to close telescope you can use contrl C and if I want to look for the current word under my cursor so let's say I want to look for this word keymap here I place my cursor over it and I can do space FC and it'll look for key map throughout my project I can use tab to select a specific set of results here and then if you use control K to go over one of them and do tab again it'll deselect it I can send these to the Quick Fix list with control Q I'm going to close this with colon q and enter all right next I'm going to set up a Greer for neovim with alpha. envm I'm going to open up the file explorer under plugins add a new file with a and I'm going to call it alpha. Lua and press enter and enter let's open that up and close the file explorer with space e then return a table then the first thing you want to add is the plug-in URL then we're going to specify an event to Lazy load this plugin we're using Vim enter so that this plugin loads after neovim is done doing all of the startup stuff then we're going to add a config function the first thing we'll do is require the these two modules this is the alpha module and then this is a specific theme that we're going to be using next I'm going to set up a header for the dashboard like so and then I'm going to add the following here we're setting up some key maps that we can use when alpha. n ofm shows up then we're going to call alpha. setup passing it dashboard. Ops to configure everything and we're also going to disable folding on this specific buffer I didn't come up with this code from scratch someone else came up with something very similar to this I'll have a link in the description with a bunch of inspiration that you can take a look at to design your own greeter now I'm going to save this press enter and open up the lazy UI with colon lazy and then press capital I to install alpha. envm all right once that's done we're going to exit neovim by doing colon q and then I'm going to do enm and press enter so that we don't open up the file explorer and instead we see the green so I'm going to do enter and you'll see the grader now now you can execute any of those key maps to do that specific action for example I can just press Q to quit neovim I'm going to open it up again with NVM enter and then I'm going to do space e to toggle the file explorer open up the Lua folder hosan plugins and I'm going to add another plugin called Autos session. Lua and I'm going to open up this file and close a file explorer again we'll return a table add the plug-in URL this is so that we can restore neovim sessions easily after we close neovim and we stop working with a specific project I found this to be really useful I'll show you how it works once we set this up we'll add a config field here inside we'll load the auto session plugin then we're going to call Autos session. setup I don't want to restore sessions automatically so I set that to false and you can specify some directories here that you want to ignore next we're going to add some keymaps these will be in normal mode and I'm using leader and the prefix is going to be W which I think of as workspace save this I'll show you these key maps in a sec and let's open up the lazy UI with colon lazy and press capital I to install auto session now I'm going to load this plugin by doing colon lazy reload and type Auto and press Tab and then press enter and now we can use space WS to save the current session sessions also get saved automatically on a periodic basis but you can save a session manually with this key map when I'm using this plugin let's say for example that I split this window with space SV and then I'm going to save the session again with space WS I like to exit neovim by doing colon QA to close everything at the same time and press enter now if I open up neovim again with enm and press enter now I can do space WRR and it will restore the session it'll open up all of the splits and everything that I had opened at the last point that the session was saved again this plugin will save sessions automatically or you can save them manually with space WS I found this really useful when I'm working in my projects this works for the current working directory so if I open up another project in another directory on my computer and I was working in that other directory and a session was saved then I can restore it with this plugin as well I'm going to close a split with space SX I want to do little tweak to my greeter I'm going to open it up with space FF and look for Alpha and down here I'm going to add this line so that space WRR also shows up in the list of possible key maps when the greeter shows up let's just save this I find this message to be a little annoying I'm going to disable it I'm going to press enter and then I'm going to look for the lazy. L file with telescope again space FF and then look for lazy. Lua and press enter I'm going to add a table as a second argument to this function and then I'm going to add this following field here called change detection and I'm going to set notify to false that will disable that message that we get every time we save a new plugin file let's save this all right next I want to make my tabs look nicer we're going to be using buffer line for that let's open the file explorer go down here to plugins and add a new file with a let's call it buffer line . Lua I have a typo here to rename a file I can do R and I'm going to change this to buffer line. Lua I'm still getting the notification that's because we need to reload lazy. envm itself I'm just going to exit out of neovim with colon QA and press enter and then do neovim to open it up again and then we can do space WRR I did space e to bring back the file explorer and again I'm going to go go down here to plugins to buffer line. Lua and open that up then close a file explorer return a table and then we're going to add the plug-in URL then we're going to add the dependencies field we want to be using the dev icons with buffer line then according to the documentation we also need to add a version and make it equal to Star and then we're going to add an Ops field Again by default this gets passed to the setup function for buffer line and inside I'm setting up these options I want the mode to be tabs so that neovim retains the default tabbing functionality and I like to use the slant separator style let's save this file open up the lazy UI capital I to install buffer line Q to close lazy and then let's do colon lazy reload buffer and I'm going to just press tab here and press enter now we have some much better looking tabs if I do space t o to open a new tab that's how it'll look like I'm just going to close it with space TX now I also want to add a better status line we're going to be using luine for that let's open the file explorer and add a new file under plugins with a we're going to call this Lu line. Lua let's open that up return a table and then again the short plug-in URL for L line this also has the dev icons as a dependency then we add a config function we first load the Lu line plugin then I'm going to set up some custom colors with this table here these are just some colors that I'm going to be using to change the appearance of Lu line then we're going to add the following here to Define my Lu line theme and inside I'm going to add the following as you can see here these are just different modes so this is for normal mode and these are different L line sections this section will have a background of blue the foreground will have the color of the background and I want the text to be bold then we call L line. setup and here we pass some options and we set the theme to my L line theme which is the table that we defined above now I'm going to save this file open up the lazy UI with colon lazy press capital I to install Lu line press Q to close the UI and we can reload by doing colon lazy reload Lua and press Tab and press enter and now we have a much better status line in the bottom of the neovim window if I go into insert mode you'll see that it changes color same goes for visual mode command line mode replace and if I have another split here the inactive settings are for the split that isn't currently active so in this case it's the one on the left hand side I'm going to close the active one with space SX now I want to add a configuration so that I can see in my status line if I have plugins that need updates to do this we're going to open up the lazy. Lua file I'm going to use telescope with space FF and look for lazy. Lua open that up now we're going to add the following here to enable the Checker so that lazy. envm automatically checks for plug-in updates but I also want to set notify to false let's save this and then let's go back to the Lu line configuration with telescope space FF and look for L line and press enter and we're going to go to the top and I'm going to add this line here to load the lazy. status module and I'm going to go down to the bottom and I'm going to add the following to customize my luine sections and I'm going to modify the section X if I do colon H and LU line to open the help and then I look for sections in here you'll see that these are the Lu line sections and X is this one right here each section holds components in this case we're adding a comp component to the section this will set up the component to show the number of pending updates and we only want to show it if we have any pending updates and this is a color for it I believe this is Orange let's save this and I'm going to exit neovin by doing colon q envm and space WRR you'll see now that we actually have a pending update and it's down here in the status line if you open up lazy with colon lazy you'll see that we have one pending update for lazy. envm to update your plugins you can do uppercase U now I'm going to close the UI with Q all right now we're going to be adding another plugin to help improve the UI a little bit it's called dressing. envm I'm going to open up the file explorer go to Lua hosan plugins and add a new file here called dressing. Lua open that up this one's going to be very simple we're going to return a table then again specify the plug-in URL we're going to use the very lazy event which we've SE seen in the past so lazy. mm knows it's not that important for the initial UI and it loads later let's save this open up the lazy UI with colon lazy let's install it with capital I close the UI and then do colon lazy reload and let's do dress and tab and then press enter now I can open the file explorer and to show you an example of one of the things that this does if I press R to rename a file now the input box shows up like this and I think it looks a lot nicer we're also going to see another example of this in action after we set up the LSP I'm going to cancel this with contrl C now the next thing I want to do is add another plugin that allows me to maximize split windows we're going to add a new file by pressing a as you can see we have the better UI for this here too and we're going to call this vm- maximizer do Lua let's open this up we'll return a table specify the plug-in URL and now we're going to specify a new field we hav seen before it's going to be called keys this will tell lazy. envm to Lazy load this plugin whenever any of these key maps are executed again I'm using leader and a prefix here I'm using the same prefix that I use for split windows which is s and I'm using M for maximize let's save this open up lazy press capital I close the UI and then let's exit neovin by doing colon q and enter and I'm going to open it it up again with envm and press enter and then I'm going to do colon lazy and you'll see here that these plugins have already been loaded but Vim maximizer hasn't been loaded yet over here lazy. mm tells us that it's waiting for this keymap leader SM to actually load this plugin if I close the UI with Q let's open the Vim maximizer file with telescope with space FF let's look for vm- maximizer if I split a window here that was with space SV and then I want to maximize a split I can do space SM you'll see now that if I open the lazy y with colon lazy now Vim maximizer has been loaded after we executed that key map if I want to bring it back to the original size then we can just do space smm again I'm going to close this with space SX all right the next thing we're going to set up here is tree sitter tree sitter is great for better syntax highlighting indentation and a bunch of other cool features let's open the file explorer go to Lua hosan plugins add a new file we're going to call it tree sitter. Lua open this up all right so again we return the table then we specify the plug-in URL then we're going to add an event field so that we lazy load this plug-in on these two events buff read pre and buff new file this is for when we open an already existing file or a new file as we only need tree sitter when that happens then we're going to add a build field here the build field specifies something that will execute whenever this plugin is installed or updated when this happens we want to run TS update so that whenever this plugin is installed or updated all of the language parsers that we're going to be using with it also get updated and then we're going to add a dependencies field we're going to be using envm TS auto tag so that through the help of tree sitter we get autoc closing functionality for tags and then again we're going to add a config function here then we require the envm treesitter doc configs module then we call treesitter do setup to configure treesitter and then we're going to add the following to enable better syntax highlighting for our files this is to enable better indentation Behavior we're going to enable auto tagging which is made possible through the envm TS auto tag plugin then we're going to add an insur installed field where we're going to list all of the language parsers that we want treesitter to automatically install in the envm treesitter repository you can take a look at all of the different language parsers that you can list here I'm going to add the following list all of these are for web development related languages that I typically use and these are some other languages as well including Lua which is the language we're using to configure neov them then finally we're also going to add this incremental selection field we're going to enable it and we're going to set up some key maps for it through tree sitter we have access to a syntax tree and we can interact with it in different ways incremental selection is one of them I'll show you how it works once we finish setting this up let's save this file then I'm going to exit newm with colon Q open it up again with envm that'll install the missing plugins as well as all of the language parsers that we listed then we can close the lazy y with Q I'm going to use telescope with space FF to look for tree sitter and open that file back up now you should have better syntax highlighting and you can also use colon inspect tree to take a look at the syntax tree you can see here that if I move down through this tree it'll start highlighting the current node I'm in and to close this pane with space SX now I also want to show you the incremental selection if I'm over here in tree sitter I can do control space to select that node and then control space again to select that node and its parent control space again again again until I've selected the whole file now to show you the auto tagging I've opened up the source code for my blog which is written and spelled if I were to just add an H1 tag here you'll see that it'll autoclose that tag it should work with any other tags you use I'm just going to undo that and let's go back now that we have tree setter set up I also want to add some indent guides let open the file explor add a new file here let's call it indent Das blank line. Lua then we're going to return a table add the short plugin URL we're going to Lazy load on events as this only applies within the context of an open buffer then we're going to add this main field this is so that lazy. envm knows how to require the main module and then we're going to add the Ops field and here we're specifying a specific character that we're going to use for the indentation guide let's just save this file open up lazy do capital I close the UI now let's close neovim open it up again with envm enter and then let's do space WRR to restore our session and you'll see now the indent guides here if I'm in a more complex file let's open up the telescope. Lua file and I go down to this config function for example through treeit the plugin will also highlight the current scope of where my cursor is in all right now we're going to be setting up completion so that we get autoc completion recommendations as we type in neovim let's open the file explorer with space e go to Lua holon plugins add a new file we're going to call it en- cm. Lua and open this up all right now we're going to return a table then specify the short plugin URL then we're going to add an event field to Lazy load this plugin on insert enter this means that this plugin will only load once we go into insert mode then we're going to add a list of several different dependencies we're going to be using this is a completion source for text within the current buffer this one is for file system paths we're going to be using Luis snip for Snippets and this is the completion source for Luis snip friendly Snippets is a set of useful Snippets for a lot of different languages and finally we're using LSP kind to have VSS code like pictograms in our Auto completion now again we'll add a config function to set everything up here we'll require the CMP plugin we'll also be requiring Luis snip to set up our Snippets LSP kind for the VSS code like pictograms and this line here will help us load the Snippets from the friendly Snippets plugin so that we can have them available in our completion then we're going to call cm. setup to configure NVM CMP then we're going to add this to set up some of the behavior of the complete then we're going to add the snippet field this will set up the Snippets to use Lis snip and then we're going to add a list of key maps that we can use with the completion menu then we need to specify a list of sources here we're specifying LS snip as the First Source then text from the current buffer and then file system paths the order that you put these in is important it'll indicate how these are prioritized and then finally I'm going to add the following to set up the LSP kind vs code like pictograms let's save this open up the lazy y capital I for install that'll install envm CMP and all of its dependencies and then we can close the UI with Q now let's exit neoven Molin Q open it up with envm and press enter and then let's do space WRR now let's say I go over here and then type S I'm going to get a list of suggestions here the first one is a snippet I can use contrl J to go down down to that first one and I get a preview window of it and if I keep going with contrl J the next several here are just text within the current buffer and if I just want to abort I can do crl e contrl space to open it up again and contrl J to go down control+ K to go up I can choose one of these by pressing enter if I start typing a file path like do slash then I'll get file system paths here if a scroll bar shows up in the preview then you can use crlf to scroll through the preview and contrl B to scroll up sometimes this works and sometimes it doesn't I'm not sure why let me know in the comment section if you do I'm just going to abort with contr e all right next up I want to set up some autoc closing pairs functionality I'll open the file explorer go to plugins and add a new file called autop paays Dolla let's open this up we'll return a table then specify the short plug-in URL for for envm auto pairs then I'm going to specify an event we want to load this plugin whenever we go into insert mode then specify our dependencies we're going to be using mm CMP along with auto Pairs and then I'm going to add a config function and first require the nbm auto pairs plugin then call autop pairs. setup to configure it this is just some Tre Setter settings to configure how this plugin interacts with tree sitter then we're going to require the envm auto pairs completion functionality so that it works with auto completion we're going to require envm CMP and then we're going to make Auto Pairs and completion work together with this following line now let's save this file open up the lazy UI press capital I then we can do colon lazy reload envin Das Auto and press Tab and then press enter now you'll see that if I do a opening curly brace it'll autoc close it this also works with brackets and parentheses as well as double quote and single quote awesome now I also want to add a plugin for working with comments let's open the file explorer add a new file here called comment. Lua let's open this up let's return a table specify the short plug-in URL then we're going to use an event to Lazy load the plug-in whenever we open a new buffer or a buffer for an already existing file then we'll specify dependencies we're also going to be installing envm TS context comment string this is used for properly commenting out TSX and jsx code then we'll add a config function we're going to require the comment. enin plugin then require the module that we need to integrate envm TS context comment string with comment. envm and then we're going to call comment. setup to configure the plugin and over here with this preh hook field we set up the integration between en MTS context comment string and comment. envm now let's save this file let's quit neovim do envm enter lazy will automatically install it and let's use telescope with space FF to look for comment. Lua and now how this works is that you can use GC followed by a motion to comment out code for example let's say I want to comment out all of this code I can do GC and then use uppercase G to go to the end of this file and that that'll comment out all of it I can do that again GC and uppercase G and it'll uncomment it let's say I'm down here and I want to comment out the dependencies I can do gc2 J and gc2 J to undo that I'm over here in the spelt code for my blog again if I do GCC it'll comment out this line and it'll do it properly thanks for the additional plug-in that we're using with common. envm let's go back now I also want to add a plugin for to-do comments let's open the file explorer go to the plugins folder and add a new file with a and then I'm going to call this too- comments. Lua open this up then we'll return a table specify the short plug-in URL we'll lazy load this on events as we only need this within the context of a buffer then some dependencies this plug-in makes use of plenary and then I'm going to add a config function we're going to require the to-do comments plugin and then we're going to set up some key maps for it in normal mode we're going to have closing bracket T to go to the next nearest to-do comment and opening bracket T to go to the previous closest to-do comment now we can also integrate this plug-in with telescope I'm going to open up telescope and look for telescope. Lua then I'm going to add to-do comments as a dependency for telescope and go to the end and I'm going to add a new key map here we're going to set leer ft to look for to-do comments in our project let's save this file now let's go back to the to-do comments file by doing crl o crl o you can use crl o and crl I to jump forwards and backwards in neoven and this works if you're opening a file with telescope now I realized that I forgot to call the setup function so down here we're going to do to doore comment. setup and save this file now I'm going to close neoven with colon q and then open it up again with envm and press enter lazy will automatically install the plugin I'm going to press Q to close the UI and do space w r to restore our session now if I add a comment here and I do Todo in all caps followed by a colon this format is important it'll get highlighted and the plugin will recognize this to-do add better comments here save this you can also use other keywords here like hack and bug you can save this so you can see they're highlighted and if we do space ft they'll show up in telescope and we can navigate through them with closing bracket T and opening bracket T all right I'm going to undo all of this now before we move on to setting up the LSP I want to set up another two plugins that are really helpful when you're editing code let's open the file explorer and go to plugins add a new file the first one is for sub substitutions I'm going to do substitute. Lua this is a new plugin I've been trying out lately I used to use another one called replace with register let's return a table here and add the short plug-in URL we'll load it on an event we only need it when we're in a buffer then we add a config function where we first require the plugin then call it setup function and then add some key maps for it we're going to be able to use the letter s to substitute text in neovim this does override the built-in S command but I honestly don't use it very often let's save this file now let's close neovim with colon q and press enter and then do envm and enter it'll install it let's close the UI and then do space WRR now if I go over here to local and I do viw to select it and press y to copy that text now I can go over to key map and I can use S followed by a motion to substitute whatever that motion moves over I'm going to do IW to replace keymap if I'm over here and I do s dollar sign it'll replace everything to the end of the line if I do s uppercase G it will replace everything to the end of the file now you can also do uppercase s to replace to the end of the line and you can also use this in visual mode so let's say I use V and then l a couple of times here if I do s it'll replace that now I also want to add a plug that's really helpful for adding surrounding symbols so open the file explorer go to plugins add a new file I'm going to call this surround Lua open this up then I'm going to return a table specify the short plugin URL we're going to load it on the same events that we did earlier then we'll specify the version this is the recommendation and then we'll set config to true so that by default lazy. envm will require the plugin and call the setup function let's save this file quit neim with colon Q enter open it up again with envm enter it'll install it close the UI and space WRR now to give you a couple of examples of how this works let's say I want to surround this config string with double quotes you can use Ys to surround text with something we need to use a motion now I'm going to do IW and I want to surround it with double quote if I want to delete the surrounding double quote you can do DS double quote to undo that if you want to change it you can do CS double quote and then specify the new surrounding character in this case let's do single quote let's undo all of this this works with typical surrounding characters like Curly braces parentheses brackets double quotes single quotes and tags as well I'm over here in my spell kit project let's say I want to delete this surrounding article tags here I can do DST for tag if I want to add them back back for example I can do Ys to add surrounding and then the motion is going to be 8j and what I want to add is a tag so I'm going to do T and I'm going to write out the tag down here it's article and press enter awesome you can also change tags this way you can do CST and let's changes to a div and press enter I'm going to undo that with you all right the next thing we're going to do is set up LSP let's open the file explorer go into luaan plugins and we're actually going to add a new directory here press a let's call it LSP and follow that with a forward slash so that envm tree knows that this is a directory then let's go down here to lazy. Lua open up that file and then we're going to change this to a Lua table so I'm going to do y s to go to the comma and do curly brace now I'm going to repeat this with DOT and then I'm going to do import equals to hosan plugins I'm going to add another table here it's going to say import equals hosan do plugins. LSP and let's save this this is so that lazy. envm recognizes the LSP directory that we created under plugins let's open the file explorer and then under this folder we're going to add a new file called mason. Lua we're going to be using mason. envm to install the language servers that we need to enable LSP functionality for the languages that you work in let's add the short plugin URL here then we're going to add a dependency for it this is going to be Mason LSP config this will help us and make it easier to install and configure our language servers then we'll add a config function and the first thing we'll do is require the Mason plugin and then require the Mason LSP config plugin and then we're going to call Mason dos set up here I'm just going to modify the UI a little bit I want to use this check mark when a package is already installed this Arrow when it's pending and this x when it's uninstalled then we're going to add the following to configure Mason LSP config and then we're going to add an insur installed list where we'll include a list of language servers that we want Mason to automatically install for us you can take a look at all of the available LSP servers in the Mason LSP config repository this list will will vary depending on the languages that you actually use let's save this file now and then let's quit neovim and open it up again with envm enter lazy will install Mason and Mason LSP config and you'll see in the bottom that it'll automatically start installing the language servers that we listed if I close the lazy UI with Q I can do colon Mason and press enter and that'll open up the Mason UI you'll see here a list of the installed language servers and also all of the other available things you can install with Mason if you press two you will only see language servers we're also going to be using Mason for installing linters and formatters if you press four you'll see all of the available linters and five all of the available formatters if you want to install something manually you can go down here and then press I to install it if you want to delete something then you can hover over it I'm going to delete what we just installed with a case X let's close the Mason UI with Q now I'm going to open the file explorer go back here to LSP and I'm going to add a new file here called LSP config.lua let's open this up now we'll return a table specify the plugin URL for enm LSP config which is the plugin we're going to be using to configure our language servers then we're going to use event to Lazy load this plugin we only need LSP when we're in a buffer this is important also because we need to set up LSP config after we do Mason and Mason isn't lazy loaded next we're going to add some dependencies in here we'll add CMP envm LSP to integrate the auto completion with the language servers then we'll add envm LSP file operations this will add some nice functionality like modifying Imports when a file has been renamed and we're also going to add this neod dev. envm plugin to add improved LSP functionality for the Lua Lang anguage server when you're working with your neovim config add a config function to set everything up first we're going to require the LSP config plugin then Mason LSP config which we installed and configured earlier then the CMP envm LSP plugin for the auto completion and now we're going to set up some key maps this is just for conciseness like we've done before and we're going to create an auto command which is basically a way to set up some logic to execute automatically on a specific specific event in this case we want to use LSP attach to execute this logic whenever an LSP client attaches to a buffer then we'll add the group field and assign it to an autoc command group this is just a way to group together autoc commands in this case we're creating a new group and calling it user LSP config then we'll have a call back for the logic that we want to execute on the event and over here we're defining a table called ops which are going to be options for our key maps in this casee we're setting the buffer to the buffer that the LSP client has attached to and we want them to be silent and then we're going to add all of our key maps so all of these key maps will only be available when an LSP client attaches to a buffer and they'll only be available within that buffer over here I set my first key map this is G uppercase R and we're using telescope to look for any LSP references for what is under the cursor before I set the key map I'm setting the description field of the Ops table to add a description to the key map I think the best way to explain all of these is by showing you how they work so let's just continue down and finish setting up our language servers next we're going to add this capabilities variable that is equal to the CMP and Vim lp. default capabilities we're going to be using this to enable the auto completion over here I'm going to add this following code to change the diagnostic symbols in the sign column to these that you can see right here for errors warnings hints and info then I'm going to call Mason LSP config do setup handlers and this is a special way to automatically configure the language servers in a specific way and here we're going to add a function that gets past a server name and then we use the LSP config module and then access the field with the name of the server this would be the same as doing something like LSP config.lua or brackets and Lua but with the server name variable instead and then we're going to call setup to configure the language server in this case we just need to pass the capabilities to the language server like so so that we can enable the auto completion with envm CMP if you need to set up a different configuration for a specific language server that isn't the default then you can add them below this function for example I have a special configuration for my SP language server first you specify the name of the language server so that Mason LSP config knows to not use the default Handler for it and then you pass a function to that and inside we use the LSP config module and we want to set up the spelled language server and call the setup function inside we add the capabilities for the autoc completion and then I'm doing some thing here when the language server attaches to the buffer I have a couple of other custom configurations here I have one for graphql I modify the file types that this language server should get enabled in I have another one for EMT and another one for the Lua language server this here is so that the language server recognizes the Vim Global variable when we're working in our Neo config all right let's save this file then I'm going to close neovim open it up again it'll install envm LSP config and its dependencies let's close the UI and I'm going to do space WRR I just remembered that we also need to add the LSP as a source for the completion to do this we're going to go to nv- CMP I'm using telescope here and down at the bottom where we list our sources I'm going to add here a new source the name is enmore LSP save that and exit neovim open it up again and do space WRR all right I've opened up a typescript file in the code for my blog to give you a quick rundown of the LSP functionality now we have LSP functionality in our Auto completion if I type out something like H here you'll see a bunch of different recommendations from the LSP I'm going through these with contrl j and contrl k that in and of itself is pretty amazing very similar to what you have in VSS code but there's a lot more that you can do if I'm over something with my cursor and I want to see all of the LSP references to that I can do G and uppercase R it'll open them up in telescope if I'm over a type like markdown post here and I want to see its definition I can do GD awesome I can jump back with crol o you can also do GT to go to type definitions if I make a mistake so let's say I remove this opening parentheses now I have a bunch of different diagnostic errors I can jump through them with closing bracket D closing bracket d closing bracket D and backwards with opening bracket D and opening bracket D let's say I remove this R here from request Handler and I need to fix that I can do space CA and it will give me recommendations for how to fix it this UI is thanks to the dressing plug-in that we set up I want to change the spelling to request Handler so I'm going to press enter we can also do a smart rename so let's say I want to rename this variable I can do space RN and change it to modules with two s's and it will change all of the instances of that in this file as well as in other files if you're using it in more than one to undo that and also if you want to see documentation for what is under the cursor you can do uppercase K you can just move around to unshow that now let's say that I want to change a file in the file explorer I'm going to change the name of this types file because of the plug-in that we installed for this I can do R to rename it I'm just going to add another s here and press enter and you'll see that this import here gets updated with the new file name I'm going to rename it back to types with a single s and it's back to a single s here do note that you need to change all of the files that get affected when doing these things to do this you can do colon wa to write all finally sometimes I need to restart my language server for some reason and you can use space RS which is another key map that we have set up I'm going to add one more plugin that makes working with ls P really nice it's called trouble. envm let's open the file explorer go to plugins I'm going to add a new file here I'm going to call it trouble. Lua then I'll add a table the plug-in URL for trouble. envm then some dependencies we're going to use the dev icons and we're also going to be using to-do comments which is one of the plugins we set up earlier and then we're going to use keys so that it lazy loads whenever any of these key maps are executed here we're using leader and the prefix is going to be X let's save this open up lazy press capital I to install trouble. enven then we can close this I'm going to do lazy reload and TR and press tab press enter now if I do space XX it'll open up trouble if I do space XX again it'll close it if I do space xw it'll show me all the Diagnostics across my whole project if I go over here to this first one one I'll see this warning here in this file and this other one is a hint here if I close trouble with space XX we'll go back to the file we were in if I do space xw and go to this warning I pressed enter to actually go to this file and then I'm going to close trouble with space XX I do space XD it'll only show me diagnostics for the current buffer which is just this warning and then I can close trouble with space XX if you have to-dos so let's add a to-do here remember it has to be in the correct format let's save this file now if I do space XT it'll show me the to-dos in my project as well and I can close it with space XX let's remove this and let's go back with crl o all right the next thing we're going to set up is linting and formatting we're going to set up the formatting first let's open up the file explorer and under plugins I'm going to add a new file here called formatting. Lua we'll return a table here specify the plug-in URL we're going to be using conf form. envm for our formatting we're going to Lazy load this cuz we only need this in a buffer then we'll add a config function to set everything up then we'll require conform call conform do setup and then we're going to add this field called form Matters by ft to specify the formatters that we're going to be using for each different file type I'm going to add the following here so you can see here I'm using prettier for all of these different file types I'm using sty Lua for Lua files and isort and black for python this order is important isort will execute first and then black you can take a look at the official repo to see a list of all of the available formatters then we're going to add the following to enable the format on Save functionality and we're passing a couple different options here and then finally I'm going to add a key map so that I can use leader MP to format a specific range of text if I wanted to let's save this file and now what we need to do is to actually install these formatters we can do this with Mason we're going to install another plugin to help us do that automatically let's open up telescope with space FF to look for files and look for mason. Lua and press enter and now we're going to add the following dependency here this plugin is called Mason tool installer envm this is helpful for automatically installing other stuff that isn't language servers which we're using Mason LS P config 4 then down here we're going to require this plugin and down at the bottom we're going to do Mason tool installer do setup and we're going to add an Ensure installed list and then add the list of formatters that we want to install you can use the Mason UI to see all of the available formatters let's save this let's close neovim with colon Q open it up again with envm enter it'll install conform envm and Mason tool installer and you'll see down at the bottom that it's installing the formats as well if we close the lazy UI and do colon Mason and go to number five you'll see that these formatters have now been installed let's close Mason with Q let's do space WRR I'm going to use telescope to look for formatting. Lua you'll see now that if I mess up the formatting here and save this file file it'll automatically get formatted correctly now conform envm also respects any configuration files you're using for your project so let's say I want to have some specific formatting rules for my neim config I can open up the file explorer and add a file here called styu dotl and inside I'm going to add the following two lines to set up spaces for indentation and I want these to be two spaces let's save this I'm going to do a split pane here and I'm going to use telescope to look for formatting. Lua now let's say that I changed indent width to four then let's go to this file here and save it and you'll see that the indentation level is now changed to four through the form matter if I go back to the other Pane and change to two save this go back here remember I'm using controll H and L to move through these splits I can either save or I can also use leader MP to format the file let's say this I use formatting with prettier a lot and I also make use of the prettier RC config file to specify how I want the formatting to work in my webd projects all right now let's set up linting I'm going to move to the split on the left and close it with space SX I'm going to open the file explorer go to luah hosan plugins and I'm going to add a new file here called linting Lua we return a table specify the plug-in URL we're going to be using using envm lint we only want this to load in a buffer then we add a config function to set everything up we first require the envm lint plugin then we're going to set the linters by ft field of the envm lint module it's going to be equal to a table and again like with the formatting you specify the file types and the formatters that you want to use with those file types in this case I'm using eslor D for these webd related file types and pilent for p python files next we're going to set up the auto command to trigger the linting functionality on specific neovim events we're going to create an auto command group we're going to call it lint and then we're going to create the auto command and it's going to execute on these specific commands when we enter a buffer when we write to the buffer and when we exit insert mode as well the insert leave event will only work with some linters all right so over here we set the autoc command group and this is the Callback function for the code that will execute on these events we just want to run lint do TR lint to trigger the linting then finally we're going to add a key map so that we can use lader L to trigger linting manually let's save this file and then we need to also set up Mason to automatically install the linters we're going to use so I'm going to use telescope and look for mason. Lua and then down here in Mason tool installer we can add pilent and Es lint _ D let's save this let's exit neim with colon Q then do envm and press enter lazy. envm will install envm lint and you'll see in the bottom that Mason is installing the linters if I close lazy. envm with q and do colon Mason if I go to number four you'll see that these two linters have been installed now I'm going to close Mason with Q now I've switched over to the code for my blog in the right hand side I have an eslint RC file for the project which I use to configure linting and on the left I have some source code one of the rules I have enabled here is to prefer const variables if the value of a variable isn't changed so if I go to the left and I change this variable to let you'll see that the linting hasn't shown up yet but when we exit insert mode the event will fire and it'll trigger linting and now we get the error here if I maximize a split with space SM you'll see the linting error there this is also a diagnostic so I can do closing bracket D and trouble can also show these linting errors with space XD for the current document or buffer I'm and to close it with space XX if I change this to const and I exit insert mode the error is gone linting will also fire when we enter the buffer or when we save our changes let me save this all right the last thing I'm going to show you guys in this video is adding some plugins to work with Git within neovim let's open the file explorer and go to plugins press a to add a new file I'm going to add git signs. Lua we'll return a table then add the short plug-in URL for git signs. envm we only need this in the context of a buffer then we're going to add an Ops table and in here we're going to pass an unattach field that is equal to a function that has access to the current buffer in here we're going to set some key maps to work with this git science plugin we get this GS variable we Define this function map to make it easier to Define all of our key maps then I'm going to add these key maps these are for navigating through hunks these are for staging and unaging hunks as well as resetting any changes these are for staging the current buffer or resetting the changes in a buffer and these are for doing git blames within neovim then these are for doing diffs and finally we can also set up a text object for hunks if it sounds a little confusing you'll see how it works in just a second let's save this file I'm going to close neovim open it up it'll get installed now I've moved back to the code for my blog because it's a git repository now let's say I add some lines here you'll see now that the git signs plug-in has added the green lines on the edge to show the new lines this is essentially a hunk if I remove a line then it'll be a red Dash and if I add a forward slash here that's another color for a modification now let's let say I want to go through these gith hunks let's go to the top here I can do closing bracket H to go to the first one closing bracket H to the next closing bracket H and backwards with opening bracket H and opening bracket H let's say I just want to Stage these new lines here I can do space HS so that just got staged it's the equivalent of doing get ad you can undo that with space hu let's say I want to undo this current hunk I can do space HR to reset let's undo that with youu I can also reset the changes for the whole buffer with space H and uppercase R let's undo that with you or stage the changes for the whole buffer with space H uppercase s and we can undo that with space hu you're going to have to go through all of them now let's say I want to see who wrote this line here I can do a get blame with space HB and says it was me can move around to make that go away and if you do space H and uppercase B it'll start showing a git blame for each line as you hover through it to disable that I'll do space H and uppercase B now let's say I want to see a diff to see the differences in this file with the original I can do Space HD and it will open up in a split to see the changes when you want to close this you should go to the original which is actually the one on the left here I'm going to close this split all right I'm going to do space H and uppercase r hard to undo everything now I've also started using lazy kit within neovim it's been pretty nice I used to just run all of my kit commands manually on the terminal but this has been a good quality of life Improvement I'm going to add it to the config but this isn't a tutorial on how to use it if you want to see a more in-depth tutorial on how to use lazy git let me know in the comment section first we need to actually install lazy git I'm going to do that with Homebrew you can either close neovim and execute these commands I'm going to open a new t-mo pane if you want to learn how to use t-mo with neovim I'll have a link for it in the description I'm going to open it up in the bottom here and I'm going to do Brew install then you have to do the following here and press enter I already have it installed so that's why I get that message then I'm going to go back up into neovim and maximize this and open the file explorer go to luaan plugins add a new file here called lazy. Lua open that up then we'll return a table then the short plugin URL for lazyg get. envm then I'm going to Lazy load this plugin on specific commands then we specify plary as a dependency for lazy git and then finally we're also going to Lazy load lazy git whenever this key map is executed which is going to be leader LG for lazy git which will run the lazy git command I'm going to change this description to open lazy git let's save this I'm going to exit neovim open it up again lazy git will get installed I'll close the UI I'm back in the code for my blog let's change the name of this variable to modules with double s and let's change the name of path to path with double H just for fun let's save this and then let's do space LG and you'll see here that I have the changes in my server. ts file I can stage them with a and I can do c to write a commit for it there's a bunch of git related stuff that you can do with lazy again let me know in the comment section if you want to see a full tutorial on how to use it I'm going to unstage all of these changes with a and you can close the UI with q and I'm just going to undo my changes here and that's it you guys we're pretty much done all right you guys that's it for this video I know that was a lot of stuff I hope you found it interesting and helpful if you did don't forget to leave a like down below let me know in the comments section if you have any questions or feedback for me and don't forget to subscribe to the channel to see more content like this from me see see you guys in the next one [Music] peace
Info
Channel: Josean Martinez
Views: 42,790
Rating: undefined out of 5
Keywords: nvim, nvim setup, neovim, neovim setup, 2024, how to setup neovim, how to setup nvim, how to setup neovim from scratch
Id: 6pAG3BHurdM
Channel Id: undefined
Length: 86min 34sec (5194 seconds)
Published: Wed Apr 03 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.