Zero to IDE with LazyVim

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we'll be looking at the lazy Vim setup for neovim powered by lazy.nbim which is a modern plugin manager lazy Venom is a great way to get started with an ID like environment and it also has great ways to extend and modify how it's configured lazyvim also has its own documentation site which is a nice addition to its GitHub repo so let's begin we'll go to the installation section of the site and first we'll back up our current neovim setup in case we want to revert back later and then we'll clone the lazy Vim starter repo to our local machine and then we'll remove the dot get folder so you can add it to your own repo later okay so now you should be able to start neovim and watch the magic happen the lazy.mvim experience is very nice and interactive especially in this case where you're setting up an environment for the first time and by the end you have your new lazy Vim version of neovim all set up it's a good idea at this point to run the check Health command to verify everything is okay so I'm a bit zoomed in for this recording but if I zoom out a little you'll see something more like what you would see a dashboard for quick actions you might want when you first open neobim okay let's quit and switch to the folder where our new lazyven configuration lives and relaunch neobim a good thing to know about laservim is that it comes pre-installed with the witch key this plugin allows you to hit the leader key Space by default and it'll show a list of key maps for you to explore this is Handy especially when the key maps might be new to you or you infrequently use some of them so in our case let's type e which will open new tree at our root directory and let's navigate to the Lua config folder and open up the lazy.lua file then we'll toggle Neo tree off with leader e again since we typed the key map quickly the witch key overlap doesn't appear which is a nice touch you'll notice that several plugins and language servers aren't installed until they're needed which is great for initial performance let's open up Mason which is a way to manage language servers linters formatters and more with leader cm so the installed language servers does not include typescript which is something that I regularly use I could install it using Mason but there are other settings I would need to manually set up thankfully however lazyvim has a few modules already coded that include the typescript settings already wired up for us so let's uncomment lines 14 through 16 to include typescript and Json support along with the mini animate plugin which I'll show you what that does later and we'll save our changes and quit neovim now let's switch back to our previous typescript project with CD Dash and then start neovim on launch you'll see that lazy.nvim is installing some plugins that were required by the lines we uncommented earlier all right now let's start to navigate our typescript project we'll type space our leader key to engage which key then F to find and then F again to find files this launches the telescope plugin that will search for files known by git normally you'd see a preview of these files so let me zoom out just a tad and as I search you can see a preview of the selected file on the right let's open the page.tsx file lazyvim comes pre-configured with the leap.nvim plugin to allow you to easily jump to any location which is what I'm using here to jump directly to the first Styles reference you might have noticed the cursor animating to the location well that was the mini.animate plugin that we enabled earlier since we installed the typescript language server we can now leverage LSP features such as rename here we'll rename styles to CSS and the LSP will intelligently rename the variables as needed if you press a capital K it'll show hover documentation showing type information let's search for a string across our project we'll hit leader and then s for search and G for grep from our root directory and we'll search for John as before I'm a bit zoomed in here so let's zoom out for a more realistic View here on the right you can see a preview of the search results for the match and let's go to that file here we can see some inline linting information coming from the typescript LSB here we could use the trouble plugin by pressing leader XX to view Diagnostics then you could jump directly to the issue and we'll close that panel and then we can launch some code actions via the typescript LSP by pressing leader CA in this case we'll just prefix the Raq variable with an underscore to ignore the warning if you'd like to change your color scheme then you could press leader U capital c and we'll switch to Alpha Lord then we'll change it back to Tokyo night once you have more than one buffer open you could toggle between them by pressing leader FB and Telescope will open with existing buffers and we'll pick page TSX you could also use the right bracket B to go to the next buffer and the left bracket B to go to the previous buffer and you could always use the mouse to click the tabs at the top of the window there are other ways too but those are the ones I primarily use okay now let's switch to splits you could create a vertical split by pressing leader pipe and create a horizontal split by pressing leader Dash and then you can navigate to the left split with Ctrl H to the right split with Ctrl l down a split with Ctrl J and up a split with Ctrl k and you can adjust the size of the split with Ctrl up Ctrl down control right and control left okay let's close those splits and move along to help you can bring up a huge list of help pages to search by pressing leader sh let's search for to do and see its help page this help page is about H2 plugin that lazyvim has installed let's exit this help page and take a look above our home function let's add a to-do comment saying do this or that already you can see visually that the to-do comment looks special let's switch to the next buffer before pressing leader St to search for to do's and you'll see the to do from the other file if we press enter it'll switch us back over to that buffer to the correct line another piece of functionality that you would probably expect from an IDE is auto completion well lazyvan wires that all up for you as well if we start typing func you'll see a list of auto completions and one of them is a snippet so we'll Ctrl n down to that option and hit enter then we could fill in the stops along the way we'll call this say hello then tab and change params to message then tab and make the type a string and then tab into the body of the function now we can type the code of our function we'll just console.log and print out hello and the message passed to the function with autocompletes showing up along the way then when we use our new function say hello we also get autocomplete help and type information to help us again and here we'll say world sometimes you know there's a key map that you want and which key may just not be cutting it in that case you could press leader SK to search key maps here we'll type lazy and you can see that there's a key map for leader L to launch lazy in this case I could just hit enter since I have it selected which will bring up the lazy.com UI here you might want to sync up your plugins with a capital S which installs cleans and updates all of your plugins in this case we have a few updates lazyvim itself and the indent blank line plugin you could also press capital P to look at the profile of our plugins it looks like our total startup time is about 50 milliseconds you can filter down the list with Ctrl F and only show plugins that are slower than some threshold we'll enter 10 milliseconds and here are those plugins okay let's exit and move along there are several settings that you could toggle on and off for example pressing leader UL toggles the UI line numbers off and on there are several other UI toggles that you can explore yourself let's go over to the CSS module and do some Global search replace here we're going to Leverage The Specter plugin by pressing leader Sr to search and replace here we'll replace description with the term summary which has 17 matches and will limit the path to files that end with TSX or css which reduces our matches down to 11. we could view additional help in specker by typing the question mark and let's move this over a little to give some room and we'll type leader RC to replace the current item however I don't want to change the meta tag so I'll press DD on this line to delete the current item which means I can replace the rest of the items with liter capital r now let's see where we're at and use lasagit by pressing leader GG this view is a bit cramped since I'm zoomed in so far for this video so I'll zoom out slightly and I'll Zoom back from lazygift you could review your work stage files commit your work and so much more I'm a big fan of lazygift so it's a nice feature to be able to launch it directly from neobim another handy key map is be able to quickly spin up a temporary terminal by pressing leader ft from your root directory here I'll just run npm run which will show a list of available npm scripts that I can run and I'll just exit when I'm done alright let's quit our typescript project for now and transition to extending lazy Vim from our initial setup but before we do how about subscribing to this Channel and liking the video the stats show that most who watch my videos are not subscribers but you can change that oh and it'd be nice if you could comment about something you'd like me to cover in future videos okay enough with that let's switch back to the neovim config directory with CD Dash and we'll start adding editing and disabling stuff from the base lazy Vim config and let's launch neovim and get into it we'll open up neotrie and navigate to the Lua config folder and open the options.lua file this is where you could add your own custom options for neobim you can always reference to the documentation on what options lazyfem already provides in our case let's set the win bar for neobim which is content that is displayed at the top of every window where equals represents a separation point for alignment m is a modifier flag of the buffer and F is the path to the file in the buffer so let's save our file and Source it and now you can see the wind bar in the upper right of the buffer this might not be super helpful right now but if you have multiple splits it could come in more handy speaking of splits let's make a vertical split and open the keymaps.luophile here we'll add a new key map for normal mode and we'll use the leader.sx keymap that will resume the last telescope picker that happened to be open previously and we'll make this not recursive and silent okay we'll save this which will be Auto formatted now let's sorts this file and test it if we press leader to kick in which key we can see s to Surge but then for the X there's an empty spot so we registered the key map it works just fine but I didn't provide a description so let's go back and do that we'll go to the last argument and add a new desc description entry to the lewid table and we'll call it resume okay so we'll save again which formats the file then we'll Source the file again and if we type leader s we'll now see our new x with a resume next to it and sure enough it still brings up the last telescope picker there's also an auto commands.lua file where you can register any specific Auto commands that you want but we'll move on to another topic instead let's open up the example.lua file from the plugins folder this file has a lot of Handy examples that you could pull from none of them are executed because it returns an empty luit table at the beginning of the file so now I'd like to show you how to modify the default color scheme of lazy Vim let's come down to line 11 and we'll grab until line 21. we'll yank those lines to use in just a little bit over in Neo tree you could press the question mark to get a helpful list of commands on the plugins folder we'll press a to add a new file called groovebox.lua in this file we'll return a Lua table and paste the lines that we just yanked the Lua table on line 2 registers the groovebox theme and the other Lua table updates the definition of lazyvin and adjust the color scheme option to groovebox instead of the default Tokyo Knight once we save this file lazy fam is already aware that it's special if we open up lazy you'll see that it's aware and that we want groovebox but it hasn't been installed yet and we can press capital I to install the new theme now let's quit and restart any of them to see the difference and sure enough this is the groovebox theme okay let's try something else we'll add a new piece of functionality to telescope we'll add a file browser picker so let's add a file Dash browser.lua file to the plugins folder and here we'll paste in a snippet that defines the plugin which is an extension for telescope then we can actually Define plug-in specific key maps in the same file under the keys entry here we're saying leader S capital B will invoke telescope using the file browser extension and using the path of the current buffer and we'll provide a description so that which key works well too then we'll register the extension after the plugin loads so let's save the file then we'll open lazy and we can see that the plugin isn't installed yet and you can also see that it recognizes our custom keymap leader S capital B we'll go ahead and install it with capital i and quit any of them and restart and here I'll press leader then s then capital B and voila there's our telescope file browser where we can navigate down into folders and back up okay next let's change this dashboard lazyvim with something a little more custom for this we'll create a new file in the plugins folder called alpha.lua and here I'll paste in a bit of code so in line two we're referencing the existing plugin that lazyvim is already using the Ops function allows us to take the existing options that were defined elsewhere and to tweak them for our purposes so I'm taking the section header value from the options and setting it to a banner that says neovam with my Twitter handle underneath so we'll save this file quit neovam and relaunch and hey a customized dashboard okay so we showed how to get started how to add your own settings and how to modify existing settings before we conclude let's show how to disable some features that you may not want from the base lazy Vim configuration for this we'll add yet another file to the plugins folder called disable.luo in this file let's return a lewd table with an entry that disables the Specter plugin maybe you don't like this plugin and you'd rather use telescope Quick Fix lists and CDO updates instead so let's save this file quit neovam and relaunch now when we launch which key and go into s for search you will no longer see the r key registered for the Specter plugin because it was disabled I know I showed a lot during this video and it was a bit of a whirlwind but I hope that you learned something interesting Believe It or Not There is a whole lot more lazy Vim provides that I didn't even show I highly recommend that you check out the documentation there's some great stuff in there and until next time keep learning and please leave a comment about what you think about laserfim I'd love to hear about it
Info
Channel: Elijah Manor
Views: 289,391
Rating: undefined out of 5
Keywords:
Id: N93cTbtLCIM
Channel Id: undefined
Length: 16min 59sec (1019 seconds)
Published: Wed Feb 01 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.