Neovim IDE setup from scratch

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey if you've been following neo vm you may have seen people talk about something called a language server so knee of them 0.5 has a lot of new features some of the coolest ones are they set up tree sitter which is a syntax highlighting engine that can be embedded inside any of them and controlled through neovim's lua scripting engine and lsp what lsp does is allows you to do id like stuff like autocomplete go to definition hover over anything and see what the documentation for the function or variable you're hovering over looks like and do stuff like battery name variables this is now natively supported inside neovim you need to install a couple plugins to make it work and to make configuring it easier but it works really well and you get a full-on development experience inside any of them so i'm going to be going over how to get that all set up and configured because it can be a little tricky and there's not a lot of documentation on it because these things are only available in the latest release of any of them we have to install neovim nightly the 0.5.0 it's actually very stable the 0.5.0 is scheduled to be released any day now in order to get that set up you're going to need to fire up your browser and head on over to the neovim repo github.com and the releases page there if you scroll down a bit there's installation instructions for mac os and for linux so go ahead and follow those you'll download the file through the little assets drop down here any of them and once you have any of them 0.5.0 configured and running then you can start to have some fun to give you a sneak peek of what that looks like here's my new vim config on a javascript file with the typescript language server installed so we have full completion everything so i'm going to fire up new of them you'll notice currently at the bottom it says no active lsp because i don't have a file open yet so i'm going to open my recent news files and go to this file so as you saw after a second it popped up with this diagnostic message over here saying it couldn't find a model module mdxjsls react so that message is coming directly from the language server itself and you can also see that the language server is working because you've got this lsp typescript in the bottom and your file type is properly picked up as typescript tsx or react typescript so some of the things this gets you if i go up here and hit k on these you'll get a little pop-up that explains what's going on and it tells you any information the language server might have about your current thing so app props for example is coming from nextjs which has next type signatures all configured up here so you can see exactly what kind of properties you get inside this app props thing that you're importing from next better yet if you're over inside a function and i want to do something like say my page props you get this nice list of how to complete things which breaks down what kind of things you're looking at so i can pick page props from the list and then use it there even cooler you can do stuff like rename variables inline so you'll notice this page props is being used in two places currently if you hit the rename binding you can set this to whatever you like let's say some new name you'll notice that it went ahead and renamed them in both places depending how your language service configured in most cases this will actually rename it across multiple files as well so this is really cool and handy and takes a lot of the tdm out of working with this all right so let's get started and figure out how to get all this running on your configuration i've just hopped over to a new user which has a simplified version of my config that i've put online if you know how to work with vmscript and all that stuff and don't want to deal with this you can actually just head straight over to the repository and cherry pick the pieces of it that you like so the repository for that is github.com nickvdp slash nvm dash lsp dash config so this has an init.vim here that installs plugins that you'll need as well as all the configuration to make these plugins work the way they should all right switching back to neovim let's open up our neovim initiative file neofm stuff is stored under utilityslash.config nvm so this is the same file that you'll see on the repository i was just mentioning but i'm going to go through here and explain what all is going on so you need a plugin manager installed i'm using a popular one called bim plug i won't go into how those work here any plugin manager will work the trick is just to have the right set of plugins installed these three are what power is the lsp servers so nvm lsp config lsp install and lsp saga you're also going to want nvim copy which makes the auto completion work nicely as well as animatry sitter and nvmetry sitter text objects later on we're also going to wire up telescope which lets you search over files grab over the entire folder that you're in open up any buffers you're in change color schemes all sorts of stuff it's a really handy plug-in plenary and pop-up are not actually used directly there are prerequisites of this telescope plug-in there and finally it sets you up with galaxy line which gives you a properly configured status bar once you have those installed in vim plug you have to activate them by typing plug and stall like this i've already done that previously so i won't be doing it here and that's pretty much that the next tricky bit is configuring them the first thing we'll set up is telescope which is just a major quality of life improvement so you'll see here the mappings i've set up for them you can change these to whatever works best for you one of the handier ones is find buffer so hitting a semicolon will show any buffers that you have open in the current bin and allows you to fuzzy find around it so notice how it's highlighting even though i'm not typing them in order it's highlighting them as it finds them inside there so you can with a massive list of files this introduction what you're looking for really easily you can also do a super powered search where you can do a fuzzy find inside your current file so comma slash is what i've activated that to here so let's say i want to go the line where the unimpaired plugin was being used i would just type plug on impaired and it passed me over directly to that line so let's use slash again to get back to telescope bindings so this is the comment line that i found there and here we are we're right back at the telescope binding things there's other selectors for other cool stuff like doing a live crap over all the files in your current directory or being able to open any file that's in the current git repository or even searching over your own bookmarks so telescope is really handy you can take a look at these bindings here and customize them to whatever works best for you the next bit the stuff that makes some of the things i was doing with the lsp a minute ago useful is the bindings for them so you can copy these bindings out of this file here one of the more handy ones is gd that's what jumps the definition of a variable you're looking at i like to map that to control bracket as well because that's uh that's easy to remember for me since that's how vim does it you can also do stuff like gr i like to remember that as get references which will show you any places inside your current code base that are referencing the current file and of course you can get help via k as i mentioned before for anything that you're looking at and you can even call your lsps auto format if the lsp supports it and of course rename variables and call code actions which some lsp servers provide to do specialized actions over your code that makes sense for that particular coding language and the last thing that's worth looking at the tree sitter stuff i mentioned earlier these are requiring a little bit of lua so because these plugins are newer and uvm plugins they tend to use the lua scripting language to configure and control them i've moved most of the settings out here so you don't have to deal with them too much however if you want to customize the stuff that shows up in your status bar or maybe change some settings related to how the autocomplete works these are all inside the lua folder in the vim folder so i'm gonna fire that up here so config nvm slash lua slash status bar dot lua so here you go each of these gls followed by a number show you one of the symbols and these are the components that make up the status bar you're looking at below the text objects i was discussing about tree sitter earlier are inside the treescenter.lua file there at the bottom of the file there so these lines here are the mappings that i've configured you can change these or customize them as you see fit one thing to keep in mind when using these lsps is that you need to install an lsp for every language you're working on a minute ago i was using javascript and the way i got that working is i did lsp install typescript so this command supports autocomplete by the way so for example if you want if you weren't sure about what you wanted when you type pi and hit tab it'll find python bash pretty much most popular languages are covered here go even php is available so you can go ahead and lsp install whatever languages you need and then if you're paying attention in the tree sitter file tree sitter also has its own parsers for all the languages you're using and you can edit and customize these here to choose which languages are installed you can also there's a command for this as well it's called ts install and if there's some language that you wanted to use that's not on this list for example maybe you're a haskell programmer you can ts install it's just like that and it'll go ahead and install it in the background so you only have to do these once i'm in tree sitter's case you can store these here and any computer you use it on will persist these and automatically install them when you start them and in the case of the lsp servers that functionality is not available yet so you have to you'll have to do lsp install and get it fired up that way so since i'm looking at a lua file let's install the lua language server just to show you how this works okay so the lua language server was just installed and you'll notice immediately it started showing up with feedback from these so apparently this line has an extra space on the end deleting that makes that warning go away etc and k and all the other stuff we were talking about a minute ago is also available as well so that about covers it take a look at the repository to get more details and with these together you should have a pretty complete ide like experience from inside neovim the trade-off of course is you have to spend a little more time learning things like a little bit of lua a little bit of vimscript and how to customize these all right until next time
Info
Channel: Technikly
Views: 13,911
Rating: 4.902174 out of 5
Keywords:
Id: 7KVgMAd16NQ
Channel Id: undefined
Length: 10min 58sec (658 seconds)
Published: Wed Jun 02 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.