PART 3 LEARNING VIM TOGETHER #LEARNTOLEARN SERIES create a #rust #toolchain

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone good morning today i wanted to take a step back and look at why are we doing this so i guess i didn't do a proper job at justifying why to learn something new in general you know this is part of the learn to learn series and the first thing you have to know is that when you want to learn a new technology that's going to take a significant amount of time and it's time that you won't get back so basically you want to make you want to be smart about your time investments okay you don't want to end up in a situation where you are learning random things left and right because that won't take you to your destination the best way to decide like what to learn is to look at where you want to be and then work your way backwards from there okay so in my case why am i investing on them well the reason is that i tried some other technologies like intellij vs code and so on and i found bugs in the tool that prevented me from doing what i wanted to do just yesterday i was using intellij um and you know i was trying to execute some commands while editing text so there's a way to like show the code and and the terminal and the thing crashed right that's just not acceptable right just you know not only your paying license but the thing doesn't even work and no disrespect to the intellij team uh those guys i think invented kotlin so please but do not take these as a negative thing by any means but um my point is that if i'm going to pay a license and the thing is not even going to work that well i might as well learn the open source tools that will help me to be free it's about freedom guys so as you know i'm i'm a rust developer and rust is open source i cannot be using a a proprietary tool chain with it you want to end up using everything open source you want to be free i know it sounds pretty idealistic from someone using a mac but okay you try your best i'm using obs i try to keep things as open source as possible so with that mindset in with that mindset we're going to go ahead and work our way backwards so the objective today and i'm going to spend exactly one hour looking at it at 7 15 eastern i'm going to end this stream either way what we're going to do is i want to have a productive tool chain to do rust development now what's a tool chain well i need to be able to edit code a compile code search replace what else do you need to do git integration right all these things are your tool chain and if you are just starting in in software development i highly encourage you to start choosing your tools where will you see vim being used because you know some people might look at veeam and say well this is very backwards it's a black screen like looks boring well turns out that the reason why i first started to look at veyman at emacs is because that's what startups use in the way area actually all over the us and arguably all over the world but i was impressed by how how loyal users are in the bay area to bim lately there's a vs vs code mode that uses veeam syntax so i see a lot of people using vs code too but this is this is the standard guys so let's go ahead and get started with that in mind uh by the way thank you so much for connecting uh i know it's pretty it's pretty weird uh but uh i hope you're getting a lot of value out of this as as much as i am um okay so development environment with vim and rust what are our goals here well first of all we want to be able to uh i want to say edit text so edit edit code and then you want to be able to compile it then what else git integration when i say edit code by the way this is a markup files that's why the syntax is not exactly what you might expect edit code i want to be able to [Music] have syntax highlighting uh maybe i want to be able to click to like select a particular keyword and like a particular struct and then hopefully it will take me to the file where that track is declared so how you call that syntax highlighting and then code completion of course then you want to do so navigate navigate between files and fair enough let's uh as you know i liked adding these notes at the beginning so that we are not just like running around without uh direction right okay so let's see how far we can get so i guess the first thing you will have to do in your os is to install cargo a my my business partner griffin created a great tutorial on how to install cargo okay so please look it up in our youtube channel if you look at playlist there's a rust playlist and it's the first video in there so assuming that you have cargo cargo is like the compiler right legs so let's see what's next okay so okay i have cargo right let me just check great um fantastic what else um i want to see let's create a cargo project first cargo you need right so that creates like the template of a cargo program them cargo oh fantastic it's smart enough to recognize uh that you are using because i'm using it how did yeah because i'm using git it took the author i guess and then it took the name of the directory of the name of the package that's pretty smart actually can i say cargo run here maybe hello world good old hello world that's fantastic this will this is a great starting point if we go to source sorry about the small font size guys um we go to search and then we go to main then we see the program there now obviously we don't have syntax highlight so how can we fix that well if we just google uh rust beam integration right not a big deal what comes up all right so there's an article that is fairly recent this plugin is fairly popular so we already found tools that we can use to integrate vim with rust all right so set up vim as your rust id the veeam text editor is a great development environment for programming rust applications fantastic the ros programming language is designed to implement systems programming with safe concurrency and high memory performance in a way that feels similar to c plus developers it's also one of the most loved programming languages okay but i so this person says that believes that the veeam editor is a great fit for a rust ide oh great we just found ourselves a tutorial that's fantastic so my recommendation is and this is just going to be a very hit at miss but it looks fairly recent you know you want to at least give it a chance um open source.com looks like might be an expensive domain so supported by hi by red hat that's encouraging cool all right so this looks like a decent enough a source so we can go ahead and follow the tutorial i'll go ahead and add this article to the readme oh i was going to use sima yeah he also used emacs sometimes all right so as always i try to cite my sources there you go all right to set up ra rust for development download rostop a handy rust installer utility and run the following in your terminal i don't think i have rust up i do indeed i do please look up a griffin's video on how to set up a rust in general all right um when i say look up is within the security unit channel that is okay [Music] to set up ros for development download to tutor what is this now we have veeam already right i think this is to install rostop so we already have it so we we can skip through this i think okay syntax highlighting veeam allows you to configure your runtime by defining it in the vim rc file to enable syntax highlighting open your vim rc so let's do it the them rc and add the following in the vmrc file and save it all right and then save it all right the first the first line runs turns on the detection plug in an indent configuration all at once the second line enables syntax highlighting these features will help you to manage your developer workflow in rust all right let me just make sure that my face doesn't cover the webpage okay create a rust application in them i already have a rost application so i can just go to src and then vim mainser okay we got syntax highlighting that's pretty neat fantastic okay so we already met one of our goals that's great did you notice how vim automatically indented and organized the code that's that is because of the first line you entered into the vmrc file great job to build this application using ros package manager great job now we are going to go ahead and build the application using ros package manager cargo so i said something wrong cargo is not a compiler it's a package manager i think rust uses rust compiler is llvm right llvm he said i don't know let's see yeah trust the compiler llvm rust uses llvm as the back end so the compiler is called rust c and rust uses llvm as the back end it's the compiler infrastructure okay fantastic makes sense got it uh okay all right so we got syntax highlighting pretty amazing we don't need this we already have a package we don't need to go through this i don't have the three command brew install tree brew is like our package manager for macos this is great guys i bet you this video is going to blow up because this is actually really useful one thing i didn't tell you is that after i do the live stream i have to spend then like another hour or so like setting up all the keywords and all the things so yeah it's quite a time investment but i'm loving it i feel i'm getting a little bit better don't you think let me know in the comments um so far i feel lucky because i got i got mostly love probably because of the topic right like programmers and technical people tend to be not that nasty well i take that back there are some nasty developers too all right this is fantastic tree is a nice utility guys this is great open the main s rs source code in them the code is the same as in the hello world example you created manually above this is just a standard cargo commands so i'm not sure what's the value in this to be quite honest with you um okay congratulations you set up beam editor using ros ide on your local machine that's it okay maybe i'm missing something yeah okay so this this gave us something really important which is code completion so i respect this article this is great now can we do better right can we do better because right now here's what we got prints the thing but if i do something stupid like let me remove this quotation by the way yeah okay so i removed that save it obviously i have introduced a bug the compiler tells me that there's a bug but ideally i would like them to tell me hey dude you are about to screw up so let's see let's see what we can do with that i think i think we can now start looking at the plugin right let me close some tabs here so if you do if you google rust vm integration this is what will come up now if of course you okay the one at the top might be the most popular so it's definitely worth exploring now it seems like this is provided by the rust team because the top project is rustling itself yeah so i think that's this might be like the official tool chain that these guys maintain for pem so that's a good indicator that is going to work maybe some of the rust guys at firefox use this um absolutely possible i think we did that step right rc yeah all right so does it look the same sync text well we did syntax enable that might or might not be the same that syntax on i'm just going to copy the thing exactly like they did um okay this is a little bit of a degradation background i'm going to digress from the topic here but how do i uh select line i forgot so i'm in insertion mode let me just save um sorry select i'm going to look at my notes i don't i know that we tackle this the last time it's just repetition right you just need to do it several times until this sticks it's all good i know i have it in my notes here okay copy position the cursor anywhere in the line you want to yank um then okay that worked end of line is it zero what's dollar for oh there you go yeah yeah dollar takes you to the to the end of the line and then you can do double d is to delete the line okay let me just show my keys key caster yeah there you go all right so just to take a step back what i wanted to do is i wanted to copy the second line to the top right so then you do y y to copy and then to yank it you type p but the problem is that um i want to put to paste it above this line so i don't know how to to do that oh capital p capital p paste above call and then to delete the line you do double d okay i think it's give yourself some time it doesn't matter that you move a little bit slower but give yourself some time to learn this thing and i have a feeling that this will pay off all right anyways where were we installation okay most plugin managers don't do this automatically so these statements are usually added by you searching the vmrc right after the plugin manager load section well i don't have a plugin manager load say section um b8 packages bundle pathogen um are these different like plugin managers okay or let's see what happens neo bundle so i it's clear to me that you need to do these two steps and then depending on the plug-in manager that you use then you have to use one of these right so the problem is we don't have any plugin manager so probably it's a good thing to choose one now um is this we made packages what is this we made packages oh no where are we being packaged is a directory that contains one or more plugins the advantage over normal plugins a package can be downloaded as an archive and unpacked it unpacked in its own directory thus the files are not mixed with the files of other plugins that makes it easy to update and remove fine pathogen let's see manage your runtime path manage your runtime path with ease in practical terms pathogen vm makes it super easy to install plugins and runtime files in their own private directories for new users i recommend using using vim's built-in package management instead all right i'll take the advice for now so this is getting on my way all right so um help packages all right this piece of documentation is the same we got from veeam documentation so all right fair enough let's follow the recommendation because probably if we if we just jump to using pathogen we want to know what the hell are we doing so let's you know let's let's give ourselves some time to learn the tooling and most plugin managers don't do this automatically so these statements are usually added by users in their bin okay so it's clear to me that this is this is the this is the repo we have to clone um and it will clone it to the right folder dot beam packet pack plugin start all right let's make sure that we have that folder in our current directory so if we do that's a bad start we don't have that folder i wonder if this git clone will create the folder recursively maybe you did all right so if we go to them them yeah okay it created the whole thing now what all right so rustvim automatically registers cargo as a syntax checker with since syntact syntastic if nothing else is specified see help rust syntastic for more details search browsing with tag bar the installation of talkbar along with universal c tags is recommended for a good tag bar experience for other kinds of setups rustvim tries to configure tag bar to some degree okay playpen integration this requires a web api vamp to be installed ross play command will send the current selection or nothing or if nothing is selected the current the current buffer to rust play pane if you set blah blah blah we'll copy the url to the clipboard running a test under cursor in a cargo project the rust test command will run the test that it's that is under the cursor this is useful when your project is big and running all the off of and running all of the tests takes a long time all right so ideally we have downloaded this plugin to the right folder and what i mean let's hope that when we open uh a rust file the plugin will activate sometimes plugins do that i'm not sure uh in this case i'm not sure if it did because we have a typo and i expected that to be highlighted um if nothing else let's see help rust it's in tastic oh typo help rust syntas uh same error it's fantastic i don't think the plugin is activated that's not big of a deal so seems like we downloaded the uh the plugin right then um let's see how to activate these plugins let's read some documentations together all right using bim packages a veeam package is a directory that contains one or more plugins the advantages of normal plugins a package can be downloaded and as an archive and unpacked in its own directory thus the files are not mixed with files of other plugins that makes it easy to update and remove a package can be a git mercurial et cetera repository that makes it really easy to update a package can contain multiple plugins that depend on each other a package can contain plugins that are automatically added loaded on startup and and ones that are are only loaded with pack at i assume that probably we'll need to add we'll need to use pack app to activate the rust plugin let's see okay let's assume that let's assume your vm files are in the slash pin directory and you want to add a package from a zip file the directory name full is arbitrary you can pick anything you like you will now have these files under slash bim and let's just contrast that with what we actually have okay let's give it a second here already use the font a bit and so it says that if we go to slash them oh yeah sweet all right so we have pack plugin oh the structure looks a bit different plaque pack plug-in start i'm not sure if it will like that you see what i'm saying there's one more layer of nesting in our system let's see you will now have these files under slash bim okay all right so we are missing one folder we have pack and then plugins and then start i'm going to assume that's correct when vim starts up after processing your vmrc it scans all directories in pack path for plugins under the pack slash no pack slash star slash pack slash start slash start directory first all those directories are added to the runtime path then all their plugins are loaded if the fuvar plugin kicks in and sets the file type to some beam will find this syntax slash some beam file because its directory is in the run time path okay so now you guys remember that we had to create the directory so there's a chance that the there's a chance that uh the local vm i have installed has a different path actually but we'll see we'll figure it out we are 30 something minutes in we'll cut that one hour but i'm i'm pretty fairly confident we'll get there let's see all right so if we go to um i'm just going to the rust project i had them less on three there you go all right um let's start beam beam and then src all right cool when beams pop up a palm can we look at the path that will be my question pack i want to see the pack if i say pack load all back load is it working is it doing something you just have to assume that right this also works all alright if the fugar plugins kicks in and sets the file type to some blah blah blah is this doing anything at all i don't know um how can i look all the how can i look at all the loaded packs let's see a pack all right there's some of it all right all right i think it loaded something but now i i want to do format ah this is cool so it's not doing on screen uh it's not doing the syntax completion on screen like it's not actually like scratching things on the ui but when i try to compile it says um line 2 column 14 on terminated double quote string that's great so from this screen you need to press escape i think no quit all right how do i dismiss this um all right i'm a bit stuck here let's see so what happened is it shows it's showing like a very rudimentary window on top of our of our editor i'm trying to dismiss it so let's see how the to these miss buffer them all right i quit that didn't feel quite right but maybe that's the way to do it rust format again then we get an error then we say okay quit then we go fix the code right it does some syntax completion it does some highlighting so that's great now let's let's see if it really does syntax completion um okay how do i [Music] that doesn't work let's see okay before we do that so we [Music] let's say let's say that we really do like some weird alright so we are here and we move this over like a couple of spaces so this is misaligned then we say rust format this is this is good guys now what else what else can we do okay so we said that does formatting do we get code completion right do we get code completion let's see by the way let me just take a minute here to chill save my coffee how you guys like this stuff this is actually pretty damn awesome isn't it i think i think that having a bigger goal really helps to frame your your work you always need to keep in mind that time is limited so you want to invest your time in things that are going to benefit you the most okay okay sit my coffee look at the screen this is good all right let's keep going let's plow through this so let's see all right so we want to see if we have code completion error checking with syntactic rust vm automatically re rust vim automatically registers cargo as a syntax checker within fintastic i apologize if nothing else is specified my question is do we have to manually install syntastic right i think the answer is going to be yes but let's let me break the code once again just so that um it's all good um all right sorry yeah so we want to see if rust rust is synthastic did i do i have a typo rust syntastic for more details i don't think so all right let's say let's look at scentastic syntax checking hacks hacks for vim installation syntastic itself has rather relaxed requirements it doesn't have any external dependencies and needs and needs and it needs a version of beam compiled with a few common features not all possible combinations of features that include the ones above make equal sense on all operating systems but being version 11 now seven sorry or later with the normal big or huge feature set should be fine fair enough synthastic she'll work with any modern plugin managers for them okay will it work with the classic one well let's give it a shot um if you get an error when you do this then probably you didn't install pathogen right go back to step one and make sure you did the following okay installing syntastic with pathogen i want to install since syntastic with a beam package manager is that even possible let's see all right so [Music] let's see pathogen until on syntactic repo the only exam the only example they provide for installing syntastic is using pathogen will how should i install it without pathogen or any package manager and then the answer is pathogen is only needed for vm seven or earlier in beam eight all pathogens functionality is already built in and you shall never use it at all okay to install a plug-in in vem eight you only have to put it under the following path where bundle where here bundle can be any name of your choice then restart beam an issue help tax all to rebuild help tax all right this looks fair enough to me so we'll do a similar thing where we cloned so we did git clone right so it seems to me like we'll be doing this but we'll use a different uh hold on wait a second all right theme packs plugins start okay i see so what we can do is call this um but i'm not sure if this is going to work but we might as well break stuff it's always fun to break stuff but all right let's see um it's fantastic seeing tastic okay and then wow someone is hungry i think all right do you guys think this is going to work i think it it might let's see beam scene test take and then slash shintastic slash plugin slash fantastic bam all right all right aha beams in tastic then fantastic again then all right let me clone it outside and then i'll i'll put it in how about that so let me clone it like um i'll clone it in my home directory so let's clone the whole thing probably i don't need the whole repo but that's okay now you know what i really want to keep it let's see i'm pretty sure i need all this all these should go on their plugin right it's like this whole folder needs to get in there um back plugins start start rust status it status oh it's not under version control i thought the rust plug-in was under version control but it's not actually interesting so i think what we can do is um just put put all those files in here and see what happens right so we'll clone the whole folder here we want it here do i have a typo all right let's clone it outside and we'll move things over i didn't really want to do that but let's do it gate clone there you go fantastic plugin aha so let's move all these stuff so move let's move plugin to them a pax so let's call it like um it's fantastic right so then if we go to vampax plugin all right fair enough that looks promising let's see let's go to a rust file 2020 uh them two two two theme lesson three start c okay and then there was a command that said rebuild all all tags so help tax all [Music] um let's see fantastic pathogen is only needed for vm vm okay oh it said i had to put the plugin inside start i screw up there and let me just move it that this should be easy where are we move syntactic to start right fair enough um i did something before to all right this looks like it picked up something how do we know that syntastic is installed installation help quit beam and start it back up to reload it then type all right help all right so there's something there this plugin this plugin automatically re integrates with syntastic checker there are two checkers provided rostc and cargo blah blah blah if you like to change it pop up let's see i'm hopeful that something is installed here uh frequently asked questions uh i installed syntastic but isn't reporting any errors the most likely reason is that none of the syntax checker checkers that it requires are installed for example by default python requires either flic 8 or pylin pylinth to be installed all right let's let's see what what is installed so help synthastic checkers insert let's see all right help i did something do you guys remember what i did to to reload all the to reload the rust um plugin i did something something about loading all plugins yeah vm load all plugins okay so we did this now you can place vm plugins in inside there cool any plugins installed into opt are available to bim but not loaded into memory until you add them to a session so let me see if i say pack back load all right so that doesn't quite do it but let's see rust rust format okay since veeam 8 package managers have become less useful but some users still prefer them because of their ability to how to update several plugins how can i see which plugins are loaded right or do i need to like package pack add scene tag tactic is that the name of the thing tastic all right got stuck there a little bit i don't know what it's doing is it doing anything at all i don't know let me introduce some errors and then save i don't see it all right that's okay so as promised we'll cut it here and tomorrow we'll continue we'll see we'll get this going i have no doubts about that so thank you so much for watching and i hope you guys are not
Info
Channel: Security Union
Views: 430
Rating: undefined out of 5
Keywords: vim and rust, how to code rust with vim, rust vim, rust with mac, vim on macos
Id: Z3_7qDhSx2U
Channel Id: undefined
Length: 61min 40sec (3700 seconds)
Published: Wed Nov 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.