Neovim Complete Setup - Setting up Neovim From Scratch

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
a lot of people asked about my Vim setup how I'm using it and what configuration I did this is why in this video we will start from scratch and configure Vim editor exactly with my config line by [Music] line and I already made three different videos about viim first of all why I'm using viim and not other editor and what pros and cons it has second was about T-Max and the third was about plugins that I'm using and I will link all these three videos in the description because they are more generic and here we will focus just on the configuration of the editor from start to the end also here I must mention that Vim is not the best editor when you just started programming or when you need to finish your task really fast if you're just a beginner please download for example vs code use it and focus on learning programming language it makes sense to spend time configuring wiim only when you want to improve your coding your workflow and when you already have lots of experience and some time to spend on learning and configuring viim so what I'm using at all as I am on M I am using aity terminal this is how it looks like and as you can see it is available on all operational system and the main point of it is that it is blazingly fast it doesn't have anything inside you don't have the attempts splits whatever this is why it is fast this is what I'm using and this is how it looks like inside my laity I have t-x what is a t-x it's a terminal multiplexer which actually means it allows you to create tabs and splits and the main question of students is typically why I can't download a term and use it like all normal people it also has tabs and splits the main point is that T-Max saves your session what does it mean just imagine that here I opened my project and here I am inside rmy and I'm typing something then at some point I'm just closing my t- session like this so as you can see I am not in a session at all and everything is closed I am just typing T which will bring back t-x and as you can see I'm directly in the same state like I was before which actually means all tabs are there also split and all projects are still running and even my csor in exactly the same place place like it was previously the main point of t-x is that it saves session in memory and you can simply jump back to it you don't have this inside a term and t-x plays really nicely with electrity because it brings tabs and splits to a console which don't have it now let's talk about Vim I am not using plain Vim I am using a no and this is a fork of whim which is better developed and which has more features previous they didn't have lots of difference but nowadays Nim supports La as a programming language with which we can write plugins and this is what you can see here lower plugins are easy to create just like vimscript plugin but realistically vimscript this is aim language was there previously and it was much more difficult especially for beginners than laa laa is an extremely simple language and it is similar to JavaScript for me this is why I am using Naim inside my terminal and you already saw how it is looking for me in all my videos I have this editor I can open any file I'm sorry for Interruption but I just want to let you know that I have a membership here on the channel that you can join to support me it will give you access to the new videos earlier emojis and priority replies to your comments now let's jump back into the video and check some code inside the main point is that now I want to remove everything as you can see here I am inside folder so home do config do envm and as you can see here these are all my files which are related to neim and I just want to remove all of them as you can see I have zero configuration now I just have plain Nim installed on my machine and when I open it this is how it looks like as you can see completely empty nothing is configured and the first thing that we must do we must create a file in neat lure which will be our entry point this is right here touch init do L and now I can open it with narim if you just install narim on your machine then you can write an Vim in order to open it I have an Nas so on my machine I can write just V for Vim instead of nim this is the same now we need to open our file that we just created so we can write here NM and then our in. laa and this is how it looks like it is completely empty and what we want to do we want to require inside our folder where we will store all configuration in our case here I can write require and then typically people are writing here some username you can write here for I will write my username do cor and this single liner will require a low file from the low folder what does it mean let's save and close and now here we have just a need lure we want to create here a new folder lure because it will automatically load any cont from lower file so I can jump inside lower folder and here I want to create new folder with my username now I want to jump inside this username and create two directories first of all it will be core and secondly it will be plugins so this is how it looks like as you can see this is my home directory we have config and enim and inside enim we have a laow folder inside it is my username and here we have core folder and plugins folder so so let's jump out and as you can see this is init lure and lure now when we're opening this init lure file as you can see we're getting an error that alha core is not possible to open this is totally fine because we didn't create a file inside this directory so let's close it again and make CD inside our lure and here will be core and inside core we must create a new file so touch in need la which actually means the idea is that ins inside initial init low file we are requiring init low file inside our core and what we want to create inside core is not only in it but also the settings of nim and our key maps this is right here let's write Touch settings do low and also touch key maps. L now here I can open init low file and as you can see it is empty we're inside core and here now we can require the full path and it will be our user name then core do keymaps and then I can copy paste this line and change here key maps to settings which actually means inside our core we have just two files key maps and settings let's close this and now jump outside and let's try to start it again so I'm writing Naim and we don't have any errors at all because all our required files were successfully binded yes they're completely empty they don't do anything but this is fine now let's open our init lure again which is our main file and here after core I want to require lazy and the main point is that we will use a plug-in manager which is called lazy Nim here is a GitHub of this plugin so you can check it later if you want to most importantly we don't have this lazy file at all so we must jump inside LA and username and as you can see here we have core and plugins but I also want to create here a file which is called lazy. L and this is exactly the file that we required inside our route now here let's open this lazy lure with Nim and here I copied lazy config realistically this is exactly what you can find on installation page let's have a look first of all here what it does it creates lazy and Wim path and it clones the whole lazy and Vim from GitHub inside this path and this other part is about requiring all our plugins here we're requiring lazy and we're calling setup and inside we're writing import username do plugins and this is important because this is how all our plugins will be called and here we have some configuration for lazy if we should notify about new updates which actually means this is our main file to install all plugins most importantly we don't need to import every single plugin it will just import everything from this folder PL plugins so let's close it and as you can see near Lazy La we see this plugins folder now let's check if it was installed successfully we can just write enm and as you can see here we are getting an error no specs found for module alpha. plugins which actually means it is completely empty but it tried to load something this is why here I want to jump inside our plugins folder and create here our first plugin I want to create a new file which will be colors do laa and let's open this file with no and again we're getting here an error that it is not correct this is completely fine now inside I want to import SE configuration we have here a return and an object and actually this is a lower code and most importantly this is the name of the repository on the GitHub so we can directly open this link as you can see this is this username and this is the groovebox color scheme that I'm using which actually means this line line just installs this plugin now after this we can use priority and actually there are lots of different options inside lazy when exactly we need to load this plugin and after this we have a config function where inside we configure this plugin here we're using require Groove box which will require this plugin and Dot setup will call the setup and this is the single line that we need to set up the whole package after this here we're writing vimc MD and inside color scheme Groove box what does it mean by using Vim CMD in order to execute Vim script inside LA because not all packages are migrated to LA and sometimes we just want to natively execute some VM script code and Vim script is still supported but La has lots of benefits so this line color scheme Groove box will activate this color scheme and this line is just my configuration how it should highlight light unused variables let's close now my editor and open and Vim again as you can see now group box theme is there most probably for you you will see a lazy window so here I can type lazy and this is how window looks like as I already have lots of different packages which I cached on my machine you didn't see that window but for you if you just opened your new VI it must download this plugin with colors and then you can simply reload theme to make it working and as you can see now we have a Groove box color theme which is activated on my machine now here inside new I want to write explore to talk once again about our setup so here inside we have init lure this is our main file and we have a lower folder and this init lower can read and require things from lower folder typically inside lower folder you can create your username or you can just skip it completely and throw files inside it will work and inside here we have our lazy lure and core and plugins inside core we have just two files key maps and settings but in order to require them we're requiring just in it l and then this stuff we're requiring inside it additionally we have all plugins we will throw them here for now we have just a group box inside our colors and this lazy LW is what is requiring this plugins this is the whole structure we will just add new and new stuff but the whole structure will stay exactly the same the next thing that I want to do is go through all my settings for no in order to do that we must open with no our lure core and here will be our settings lure as you can see it is completely empty and now here I pasted all settings that I have on my machine and first of all here we're mapping our leader key to space which actually means this is our main key to make key binds and space is most commonly used now now here I have an option set highlight on search which actually means your search in the file will be highlighted Vim number shows you line numbers by default now here we have a mouse mode which means Mouse will be completely disabled we don't need it this line means that you can copy paste stuff between your system keyboard your command C for example and Vim itself this means that your line will have reps we don't need any swap files and we don't want any backup here we have undo history which means we can indefinitely undo our changes and they are stored here inside Wim undo directory now here we have case in sensitive search which means we can write lower case to find any case we want to show sign columns on the left which means this is an additional space for example for git symbols or LSP errors here we're decreasing update time of the wiim by default the values are too high this option will give you a better completion experience and this will enable better colors after this I don't really want to see these modes like insert visual because I always know in which mode I am this is why I'm disabling that and here I want to open splits always on the right and Below never on the left because it is confusing all our files inside Vim will be outter red when we're changing them outside of the Vim this is extremely important now here is stuff regarding inundation I want two spaces Smart Tab and so on here we're always using spaces and not tabs and I want to wrap lines I want line breaks and I want to show line break after this I have a language map to support Russian symbols on the keyboard also and here are some scrolling Behavior so how much lines we will scroll when we're jumping up and down so this is the whole settings that I have and I will link the whole conf that we will do in the description box below so you can simply copy paste it if you want to the next thing that we want to do is configure keymaps this is why let's open not the settings file but the keymaps file I'm sorry for Interruption but I just want to let you know that I have lots of advanced courses on different web Technologies where we create real applications and prepare for the interviews you can find the link in the description box below now let's jump back into to the video and as you can see here in total I have less than 40 lines of keymaps because viim has extensive amount of keymaps and you don't really need to override lots of stuff so let's have a look what I have but first of all you must understand how we key mapping stuff so we're writing Vim key map set and inside we're providing several arguments the first argument is in what mode this key map should work in this case here we're saying okay it should work in normal mode mode so n and visual mode this is why V for example here it is only normal mode because here it is n the second is what you want to use and then what command must be executed and after this some options for example silent true means that we won't see any information regarding calling of this key map in this case here what we are doing we are saying that in normal and visual modes this space when we're clicking on it should not do anything this is really nice because realistically we are using space as our Le key and we only type with the space inside insert mode after this here I'm using leader s so space s to save the file this is why here in normal mode leader s calls right and enter here is a little bit more tricky part we basically in normal mode use K and J in order to move lines correctly because essentially we want to just move lines straight to the top or to the bottom and not like text is written this is why here we have a check which exactly command we want to use here we have a key map to go to the beginning of the line or to the end of the line so to go to the beginning I have shift H and to go to the last symbol it is shift L then here we have shift Q in order to quit it is nice to close neim or to close a buffer for example the next to off for splits I'm using VV in order to make a vertical split of the screen and I'm using SS to make a horizontal split after we created our splits we want to jump between them this is why here is crl J crl ktrl H and crl L depending on the direction so directions are exactly the same like J K H and L that we're using for navigation here is how we can intend with Tab and shift tab in the visual mode so you are selecting in something you're clicking Tab and it will be intended and here are some nice hot keys to change where our cursor must be positioned after we copy and paste our text because by default it is positioned at the same place where we were not after the text that we pasted inside and now here I have lader H in order to clear search highlight which actually means I'm looking for something then I can just hit L the H and it is cleaned and the last one is pasting after visual selection now let's try to reopen our new Wim file first of all we need to open some file I want to open exactly the same file that we just changed it is keymap Law and now let's check some keybinds first of all space s will save the current file this is this command after this with K and J we can go normally up and down now if I want to jump to the first symbol it is shift H to the last symbol here it is shift L if I want to quit it will be shift q but I don't want to quit right now and here are our splits VV for a vertical split and we have SS for a horizontal split and now we can jump between splits with contrl G contrl ktrl H and crl L and now exactly I can use shift Q in order to close the split after this inundation in visual mode we're selecting something we're hitting tab or shift Tab and here is how we're coming at the end of young text if I'm pasting something I am at the end not at the beginning and here let's say that we're looking for keymap word as you can see it is highlighted because we configured it previously and now I want to clear my highlight I'm just hitting space H so all our hot keys are working and we're good to go the only thing that is left is going through all plugins that I have installed and show you what they are doing this is why let's try it here here touch and create a new file inside low plugins and here first of all I want a plugin comment. L and actually the name can be anything here most importantly it must be L now let's open this file so plugins comment low this is completely empty file and as you can see here we're getting an error because it is empty and we can't load it I'm pasting here everything from my config and what we're using here is a package comment. no Vim and here is an event and this event means that it will be called when we're getting a new file or we're reading a buffer now here we have a dependency of this package this is how we install dependencies and here is the config where we're calling this comment and we're requiring its dependency and then we're calling setup so I'm using exactly this package in order to comment some stuff this is why now we can close Nim open again this package will be installed for you for me it is already installed because I have it cached and now we can just comment out some lines and it is working just fine the next package that I want to show you is fuzzy finder to find any files or any text that you need to this is why here let's create a new file inside plugins and let's name it fif finder laa and let's open it with no now I will copy paste everything inside and this is quite a lot of config so first of all here we're installing this package and we have here event very lazy which means it will be initialized at the end and here inside our function we have the whole setup of fuzzy finder here I am applying color scheme then how my window can look like you can find all this information inside official GitHub repository I have some options for fif finder I have a keymap and some config for files and here I am setting some key maps for example crl p in order to find a list of files then lader B to open buffers and here lader slash so space slash in order to find any text inside my folder and last one here is GR in order to load references from LSP we didn't configure LSP yet but we will talk about it later now here I want to open with no a react project so we can check how finding files is working so here I want to write no and it is opened and now we can leverage this 3 key binds that I have for the application first of all is contrl p this is our fuzzy finder in order to find files let's say that we want to find our app component I'm typing app and as you can see we found our app file here in the list and on the top we can see the preview of the file I'm hitting enter and we're going inside if we need some other file I can type like CSS and we're finding Source weather we CSS with all content inside additionally to the that I have buffers so let's just try to open multiple files and then I can hit space b and what it does it opens buffers which means all opened files that I opened previously with vim and here I can easily switch between them and they see previews of these files for example I can select fgs 6 and jump inside it and the last thing that I'm using here from fuzzy finder is space slash and here we have a fuzzy search so we can find some text for example we're looking for weather and here we are finding all our occurrences of weather in all our files and here we can just select any of them and we're good to go and additionally to that here we can click controlr in order to bring all files that we were looking for in this quick fix window which actually means now here we can simply select any file and it will be loaded this is extremely nice when you need to update lots of files after finding some stuff the next plugin that I want to create is about showing ination this is where here let's name it indent laa and here let's open with no this file that we just created this is everything that I have here first of all this is the package here we're using this Branch we don't have any options and here we're saying that we want to require this package with such configuration so we don't want to show scope but we want to use this character for intend let's have a look I need to reload no vim and these are these lines here to show the ination inside file which is really comfortable the next package is a status line inside no in order to do that we need to create a new file let's name it line- no. L and now let's open it and here I pasted the whole configuration so again we're using here a package lower line here is a config file I have here some default colors this is just a variable colors and I have here a theme and essentially the idea is that the low line is splitted in different sections like a b c and Z on the right and what we want to do here we can call a set up and provide some configuration in my case it is extremely simple I want to hide everything and I just want to show a modified status on the left nothing else and the file name afterwards all other stuff is disabled let's have a look how it looks like I'm reloading the package and as you can see now here this is this line you can see here bluish color and the file name with AAR parent now here if I'm changing something it is red with cross to show that file is changed if we are saving this file it is blue again I don't render he any additional information like G Branch LSP status but you can do it if if you really need to the next package that I want to install is called ns. LA and I'm using it in order to bring prettier support to my browser because I want to call prettier almost on all files when I'm saving them and this is the whole configuration let's quickly go through that first of all here we want to activate it when we're opening the file and here we're getting some stuff like formatting and diagnostics from this package most importantly this is its setup and here inside sources we are saying what we want to format so here we are formatting first of all with PR everything except of markdown and MD files and here we're using not pret but pret D which is a demon which means it should not run pretty every single time it's simply used a demon here we're using formatting La so we can format La files and here I also have yes lint which is being called when we have files yes lint pgs and here is a configuration to run it on Save and here on the top we should not forget that we have a dependency which is en Vim Lua plary en Vim but we can't really check that this package is working because we didn't really install prettier or yes lint and we're doing that with one additional package which helps us to install linin formatting tools and also LSP tools this is why here what we want to do we want to call touch and create a new file which is called mason. La let's open it with no and paste a configuration inside so here we have a package Mason with dependencies of Mason LSP config and Mason tool installer we're calling them all here but most importantly we are saying that we must install this stuff what is this this is our LSPs what is LSP this is language server protocol this is this magical thing which calls your Imports which shows you errors inside your typescript and so on and here I am using TS server angular LS low for low files HTML and CSS LS so all this stuff will be automatically installed when we're opening Naim the first time and on the bottom here we're ensuring that we installed prettier style L yes link D so demon and prety D which is also demon in this case we don't really need to install all this stuff on our own let's close our and start again and now probably for you the window Mason was opened and it will install for you all these language Services you can see them here and here we can click for example four and here I have yes Lind D and five it is pretty pretty D and style laa which means Mason installs all these dependencies and now we can use them in tools like for example Ness with pretty which actually means now we can just change CH our file and then hit command s and our file is automatically prettified we can also check this on the react project I can just change this file however I want and then save and everything is prettified correctly after this you probably want to install a file tree this is why here let's create a file NM tree. L and let's open it so I will paste my configuration let's go through it first of all here we have an Lim tree package and its dependencies for LSP file operations which means all your inputs will be automatically updated when you move your file for example now here we're calling set up and here I want to change colors a little bit and also here I have a function to reorder my folders you don't really need this this is some custom stuff here we're calling NVM tree with set up here I'm providing the width of this tree and some configuration like for example which I icons I want for the folders what I want to show and so on here are icons for Diagnostics and here are my key maps so space e must toggle the tree space EF must toggle it and find a file that we're using now then space es can collapse the tree and er can refresh a tree let's check how it works now we can just call Naim and I can say space e and now here we see the file Tree on the left so this is our file La we can open laow and then here we have our core and plugins this is our whole structure that we created and now we can use this tree to create new files in order to create a new file inside plugins I can hit a and here we can name it and we want to create here a plugin three do L and now here we can just click on it to open and here is my configuration so what is TRC this is a plugin which is more of the core functionality for a lot of other plugins it splits your whole file in different chunks and it gives the possibility to all other plugins to manipulate these chunks for example it is really nice for your color scheme here we're activating it when we're reading a file we're calling TS update and here as you can see inside set up we're checking that all this stuff is installed which actually means this is syntax highlighting for JavaScript typescript dog La Ruby markdown and so on so you won't use this plugin directly but you will use it a lot under the hood for example this is how my theme looks without TRC as you can see everything is white red and a little bit green but now with it looks like this so we have here yellow color here we have an app which is greenish and now G6 is highlighted with orange now we must talk about three plugins together because we're talking about LSP and autocompletes this is why here I want inside plugins to create a new file and vm- LSP config do laa and inside I will paste my config after this I want to create new file en- cm. laa and paste inside my config and the last one is nm- outop pa. L and here is my config so all these packages are titled coupled so what is this and VM LSP config is the configuration for LSP what does it mean this is this stuff to configure your Imports highlighting errors refactoring tools like renaming of the properties and so on like for example inside typescript additionally to that we're using enm CMP which is an auto complete for our code and the last one here is enm AO pairs just for open and closed pairs inside our code so you must understand how it all works together first of all we have Mason I hope you remember Mason it ensures that all this LSP configs are installed this are our service if we don't have service nothing will work after this we have this EnV LSP config this is our client here we configure our clients on Nim how it will work with the servers so what we're doing here inside nvlsp first of all we have a dependency to the CMP which is autocomplete and now here we're configuring it this are just some settings most importantly here are key maps that we want to use when we're attached to our language server like for example on Hover we want to see some documentation then here we have a renaming across the whole application but also have a code action hotkey with GF like for example making an import and l d can show diagnostic for the line and here GD makes go to definition after this we're configuring different servers for example here I'm configuring LSPs server HTML angular LS lower LS and CSS LS and additionally to that we have our autocomplete which is n VM CMP and it can autocomplete for us a buffer a path some Snippets and obviously our code here we have some hot keys inside the autocomplete and what sources it must use so here I opened an angular application let's open our file tree and inside source app for example register I want to look on register component yes so what we are getting from LSP is for example this I can hover with shift K to see the documentation of this specific part this is coming from TS server LSP for example here we have inject and we can check what it does additionally to that here if I'm removing inject from here we're getting this validation as you can see this red signs and when I'm clicking l d it will show me cannot find name inject I can hit here GF and I'm getting code actions and here I can hit one in order to update the UT and import our inject so this is exactly what LSP does additionally to that if we're type in here for example out service from here we have our path which actually means we can easily find our file out. service and in the same way here we can for example write Constructor we're getting a nice auto complete then inside we can create a property full of type stream and again you are getting an amazing now to complete through LSP just like for example in vs code because actually it doesn't really matter that we're using no because LP is working on the server client simply renders what server does and the last package here that we didn't check is Nim Auto pairs which simply closes for us and Open brackets so here we're setting up our outter PS and we're good to go I hope that it helps you to set up new if you're looking to do that but if you just want to find the job you might want to improve your resume and I already made a video where we're improving the resume of a real junor to a better level and you can check it here
Info
Channel: Monsterlessons Academy
Views: 2,899
Rating: undefined out of 5
Keywords: Neovim Complete Setup
Id: uD-vSrtZ8uQ
Channel Id: undefined
Length: 36min 26sec (2186 seconds)
Published: Thu Mar 21 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.