Make Neovim BETTER than VSCode - LSP tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
modern Ides provide developers with sophisticated features like code completion refactoring ordering a coffee from Starbucks navigating to a symbol's definition and syntax highlighting these features make a developers experience writing code far more enjoyable moving quickly through code bases getting documentation and auto completion quickly and overall having a grand old time being a Bare Bones editor vim and neovim don't provide users with really cool tooling you might see out of the box and some other editors in this video I'll show you how to add that functionality to neovim by working with LSPs short for language server protocol it's pretty straightforward so give a like And subscribe and we'll get right into it so first of all what is LSP LSP stands for language server protocol and it's an open Json RPC based protocol for use between source code editors and servers that provide programming language specific features essentially the LSP is a background task running on your machine waiting to give you functionality based on what you're asking for interestingly enough LSP was originally developed by Microsoft for visual studio code it was later made in open source standard with Microsoft red hat and code Envy all having a hand personally I find it really interesting that the creation of vs code ushered in this era of amazing tooling for Vim through LSP so hey vs code and Microsoft thank you now without further Ado let's add LSP functionality to neofim in our last video we made a modular and modern configuration for neovim using Lua so if you haven't check out our last video to get an idea of that configuration now let's drill down in our configuration to core plugins.lua inside this file we want to add three new plugins Mason Mason LSP and LSP config.nvim all three of these plugins work together to give us excellent LSP functionality in neova Mason is a package manager for neovim that allows you to easily install and manage LSP servers Mason LSP config.nvim Bridges the gap between Mason and LSP config it also adds some really helpful functionality like ensuring certain LSP servers are installed and adding extra functions like LSP install and things like that nvim LSP config allows you to set up your LSP configurations so that you can communicate back and forth between neovim and your LSPs now all we have to do is save our plugins Dot Lua file Source it and run Packer sync all three of these plugins are now installed and it's ready for configuration next because all three of these plugins work together I don't want to create a new configuration file for each one we can just create one configuration file called LSP config we create this file inside of our plugin config directory and we make sure to require this in our init.lua inside our plugin config directory okay so now it's time to set up these three plugins that we just installed so we want to start off by setting up Mason and then Mason LSP config and for the config of Mason LSP config we just want to make sure we have at least one language server installed we're going to start with Lua because that's what we're working with right now so some Necco Lua is the language server we will use Mason LSP config has some docs that give us a basic way to set up each language server so we're going to paste that into our code base then if we call Mason we can see that Lua language server is installed automatically so now we have the Lua language server running Mason installed it and Mason LSP config is communicating with nvim LSP config which is communicating with our LSP subnicolua and as you can see when we quit and reopen Vim the LSP is running we have some formatting issues undefined Global Vim that's the LSP giving us feedback and now the next thing we want to do here is create a special function called on attach essentially what this is going to do is it's going to attach key bindings to each buffer through our LSP config language server setups and you can see our Lua server is telling us that we had a issue with that function so we change that that's really cool and after we Source this file we can see that we have all these key bindings doing all this awesome stuff we have shift K will give us documentation it looks amazing we have another key map that opens up telescope and finds references of functions throughout our code base and this is really awesome this is essentially the LSP working for us right now it's amazing and that's about it that's how you add LSP support to neovim through just a few plugins and a little bit of configuration we have full LSP support it looks amazing in neovim and because everything is async it runs really really fast and it doesn't slow you down as you're typing now of course Lua is not the only LSP that is supported there are a bunch so please go through the documentation and check them out every single modern language will be supported so I hope you enjoyed this video I know I did I'm enjoying this new neovim configuration and I'm loving it and again if you want to know how we got to this place with this configuration check out this video it'll tell you everything you need to know to set up our configuration just the way we have it right here in this video thanks
Info
Channel: typecraft
Views: 109,644
Rating: undefined out of 5
Keywords: neovim, vim, vim configuration, vim configuration tutorial, neovim configuration, text editor, vim plugins, configure vim, native lsp, how to configure vim, native lsp nvim, developer productivity engineering, developer productivity tools, native lsp neovim, developer productivity, vim vscode, software engineering
Id: lpQMeFph1RE
Channel Id: undefined
Length: 5min 18sec (318 seconds)
Published: Wed Dec 07 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.