TakeTuesday E03: Introduction to LuaSnip
Ғылым және технология
In the third episode of #TakeTuesday, we show off the incredible LuaSnip. This is the first of three videos explaining the plugin.
Plugin: github.com/L3MON4D3/LuaSnip
Please let me know/share the video if you like the intro. It took a lot of time -- and I had tons of fun -- so it makes me happy to hear from you!
To become a sponsor: github.com/sponsors/tjdevries
My Stream: / teej_dv
My Dotfiles: github.com/tjdevries/config_m...
00:00 Introduction
02:31 Start of video
21:05 Outro
22:16 Bonus Content
Plugin to highlight just some of the buffer: github.com/folke/zen-mode.nvim
Notes about friendly snippets: github.com/L3MON4D3/LuaSnip#a...
#neovim #luasnip #lua #programming #nvim
Пікірлер: 195
"then i found LuaSnips and my life did a whole three sixty" lmaooo
@teej_dv
2 жыл бұрын
I was hoping someone would catch this haha
@thaddaeusmarkle1665
2 жыл бұрын
180 degree turns are for noobs. BeginBot goes all the way.
This is another level of intro 😄
@teej_dv
2 жыл бұрын
haha thanks! Trying to raise the bar each time.
Can't express how much I loved the intro!
@teej_dv
2 жыл бұрын
Wow! That's so generous and kind of you :) thanks so much! I will keep on trying to make people laugh and learn at the same time!
What a masterpiece hahaha Learned a lot and laughed hard, 11/10!
@teej_dv
2 жыл бұрын
Dang, 11/10. Idk how I can keep trying to top that haha! So happy you liked it :)
intro is god level
Bruh, the intro is another level! Excellent video! Keep up the great work, it’s much appreciated!
With first 2'30 mins for the intro. Gave me the motivation to watch for the rest of video without skipping any minutes. Keep doing. Good job TJ :)
The bar was set very high in this one! Looking forward to to the upcoming ones. Great vid as always! Thank you for the great content.
@teej_dv
2 жыл бұрын
Uh oh, now the pressure is on!
@elyezer
2 жыл бұрын
@@teej_dv no pressure :D
Super cool intro Teej! Loved alot and as usual awesome neovim content.
breaking change: to set snippets you need to use add_snippets ls.add_snippets('all', { ls.parser.parse_snippet("expand", "als;dfjasldkflasdfj"), }) ls.add_snippets('lua', { ls.parser.parse_snippet('lf', 'local $1 = function($2) $0 end') })
Holy cow, I love that I've found your YT channel. Looking forward for the new episode.
@teej_dv
2 жыл бұрын
Welcome :) looking forward to making it!
Holy moly truly appreciate the humour and mostly importantly the knowledge
Thanks for this video, these are so much better than reading through docs
Love the video have been waiting for this from the first episode of this series. Waiting for the next episode hope it comes too soon.
my day just got a lot better after watching this video
@teej_dv
2 жыл бұрын
The intro is awesome. Also, nice transitions.
@teej_dv
2 жыл бұрын
Awesome! We're trying hard to get better each video!
This is the best neovim / programming video I have ever seen.
Had no idea you posted this but found it from the LuaSnips documentation. Great video hahaha
Awesome Billy Mayes impersonation. I'm sold! Placing my order now
You both made my day! :D Superb job! :)
that intro is CRAZY !!! love it
Super super video. Thank you so much to learn.
@teej_dv
2 жыл бұрын
Glad you liked it
this was so cool, i when back in time to watch it again
Yooo this was exactly what I was looking for!😁 I just started porting all of my `.vim` files to `.lua` and `hrsh7th/cmp` was on that list. Liked and Subbed👍 Can't wait to see the next installment
Oh, man! I don't know if the editing or the grooming is more impressive. I guess I can just say "Amazing cuts!"
@teej_dv
2 жыл бұрын
ahahahahaha yes, i love it!
@bl_nkspac_9650
2 жыл бұрын
Underrated comment.
Worth the one month waited. Especially the intro. And sorry for the pestering you on Twitch 😂
@teej_dv
2 жыл бұрын
Haha, it motivated me to keep working on it!
holly shit this video cracks me up, well done for the content and the energy, keep it up !!
@teej_dv
2 жыл бұрын
Awesome! Makes me so happy to hear that I'm making people laugh!
Nice one, TJ!
Loved it!
It took a whopping 30 seconds for this vid to get my like.. Keep up the great content!!
So much thumbnail, so much hype.
Finally taking the dive into setting up luasnip with cmp, the options and config is a bit overwhelming for novice Lua people like myself (long time Vim user though). I'm not a programmer by trade (I'm a tech writer) so someone talking it through like this really helps. One criticism in otherwise great video: the first few characters of the line (check @7:17) are cutoff for some reason.
@teej_dv
2 жыл бұрын
Thanks! I'll keep that in mind for next time
Really helpful video, thank you!
Great content!
Saw thumbnail.... hit that like button !! If my Tuesdays were like this, I hope to contribute nvim sooner.
@teej_dv
2 жыл бұрын
haha, I hope you liked it even more after watching!
Strong @ThePrimeagen vibes. Love the energy, love the luasnip.
@teej_dv
2 жыл бұрын
He's the reason I got started with streaming
Amazing work TJ
@teej_dv
2 жыл бұрын
Thanks Jesse :) was really happy with this one!
Duuuude! Where is the video two?!! hahah Awesome work, man. keep at it. Best regards
@teej_dv
2 жыл бұрын
Filming is almost complete. Editing time now :)
I smashed that like button as hard as that guy hit that mattress
thanks man that was great ^^
wasnt expecting a github link to be this fun lol
Gotta love the intro
amazing! i mean your content is another level. i just wish you would teach me to use all of my plugins like that. thank you
@teej_dv
2 жыл бұрын
Slowly but surely I'm working on it!
that looks so powerful
This is awesome
tacos AND this? amazing, thanks TJ 😄
That font is awesome!
more OS projects need unhinged commercials with the ghost of a dead promo guy
What a thumbnail ! Can't wait
@teej_dv
2 жыл бұрын
ITS HAPPENING!!!
Okay, so you were right. I really had to watch this intro. Honestly I can’t even imagine what will you give us next. Btw, hoy do you show the CR and the tabulations? I’m intrigued. And nice video!
@teej_dv
2 жыл бұрын
Ha! I'm happy you liked it so much! You're looking for ":help listchars"
@KronosaurusRex
2 жыл бұрын
@@teej_dv huge thanks!
🤣 I needed this. At 1.75 speed, the intro is a pretty bangin' rap!
@teej_dv
2 жыл бұрын
ahaha, I hadn't tried that myself but now I'll need to go back
super cool and helpful :]
This is amazing.
Amazing! Thanks for this!
@teej_dv
2 жыл бұрын
Glad to help :)
Thank you!!!
Absolutely legendary
@teej_dv
2 жыл бұрын
Excellent cameo
Patentless technology lmao!!! Great work TJ!
@teej_dv
2 жыл бұрын
So happy someone caught that line. Was really pleased with myself with that one haha
I died laughing at the intro and then I died a second time when you bleeped out VS C***. LMAO
@teej_dv
2 жыл бұрын
we don't curse here, so no saying VS C***
Give at this guy an oscar please!!!
You lost me at $0 for the last argument. Say whaaaaat??? Great work by the way, keep on rocking!
"co-workers giggling behind my back as I slowly type boilerplate" lmao. dead
Love the intro
@teej_dv
2 жыл бұрын
Thank you, thank you :)
Thanks!
omg dude 😃 content is amazing too, thanks 🙂
@marcelfahle
2 жыл бұрын
autotune ftw
Interesting, I had basically zero clue of how to properly use snippets (I never really used them in any editor) but this got me to try out some things with LuaSnip. The fruit of my labor today is a snippet for Lua development that automatically generates the LuaDoc string for a function. Basically, it uses treesitter to get the parameters of the next function after the cursor and then uses a dynamic node to create a comment like "-- @param p {}" for every every parameter p of the function. Surprisingly this is less than 20 lines of Lua code plus another 10 lines or so for the snippet itself. Neat, and should be easy to generalize to my other main languages!
@teej_dv
2 жыл бұрын
Talking about awesome code and NOT SHARING A LINK?!?!?!?! :)
@orbital1337
2 жыл бұрын
@@teej_dv Unless I'm going crazy here, I responded to this comment earlier with a link and I think KZread automatically deleted it. Or maybe its like flagged for review or something? I don't know how KZread does things around links these days... This is what I wrote (roughly): I actually just expanded the snippet a bit more - it now also detects whether the function contains a return statement and if so, adds a "-- @return" comment, too. In fact, it checks whether there is a return statement which is not just "return" (i.e. it returns something non-nil), so we don't have false positives for functions that use early returns as control flow. It's on my github at t-troebst/config.nvim/lua/user/snippets/lua.lua (please chill KZread.. :P). I also had some fun with C++ which is my main language. I wrote some snippets that generate the special member functions (constructor, move assignment, etc.) automatically. They use treesitter to check whether the snippet is being inside of a class or not. If we're inside of a class, we get the name of the class via treesitter and generate the appropriate inline declaration / definition. Otherwise, we use the different syntax to define stuff outside of classes. In that case the use has to enter the name of the class but the templates are still correctly stripped via lua patterns / regex. The code for this stuff is also in the repo (in the snippets/cpp.lua file).
@teej_dv
2 жыл бұрын
KZread comments are actually so bad :'( this comment will probably disappear as well
@orbital1337
2 жыл бұрын
@@teej_dv Yeah like they don't even have the decency to give you an error saying "you can't post links" - they just silently remove the comment after the fact... Anyway, very nice video - it's been fun to toy around with this stuff. :P
Hey TJ, beautiful vid! I can't seem to get my snippet file to source. Is there a guide somewhere on this? Not sure where you required it or how it's imported into luasnip...
@teej_dv
2 жыл бұрын
Hmm, just make sure it's somewhere like `plugin/mysnippets.lua` or something like that.
Hey this is great content! I'm loving it :) May I ask what's the colorscheme used here? It doesn't look like the gruvbuddy I see in your dots. Keep up the great work TJ!
@teej_dv
2 жыл бұрын
Should be gruvbuddy (the picture on gruvbuddy readme is probably just out of date haha)
Loving this. Do neogit and vgit next!
@teej_dv
2 жыл бұрын
neogit is on the list to explore!
YES!
Best intro ever 🤣🤣
These intros are getting out of hand! Nice job 👍
@teej_dv
2 жыл бұрын
doin my best :)
Hahaha. This was such a good video
get this man a million subs
omg that intro
ahckk finally
LOL you are the man TJ
TJ, I just moved over to doom emacs. If you'd keep posting videos like this, I might have to consider moving back to neovim. 😂
@teej_dv
2 жыл бұрын
/me *scrambles furiously to put out new content*
Stupid question but what do you use for split navigation now then? Could only find etc. in your dots
@teej_dv
2 жыл бұрын
I'm not sure what you mean. I navigate splits w/ control + hjkl
Great intro
@teej_dv
2 жыл бұрын
Thanks sir palpatine
I love this
@teej_dv
2 жыл бұрын
Thanks! I had so much fun making it!
Can't remember that I have ever commented on a yt video. But this is hilarious.
@teej_dv
2 жыл бұрын
Wow! That's high praise! Thanks
very cool
LMFAO bruh how much effort do you put in your videos? Keep up the good work!
@teej_dv
2 жыл бұрын
Well there's a reason we're only on episode 3.... LUL
Lmaoo, perfection 👌
Suggestion for a future take Tuesday: in my journey to update my workflow to neovim with modern Lua plugins I am having a rough time getting used to the nvim-tree plugin. I used nerdtree for years and got really used to it 😞. Some of my annoyances: the file explorer window doesn’t resize to fit the file name width. Also, It isn’t easy to easily get a file explorer pane for the current file (it only allows a single nvim-tree pane per window) - I’m used to just doing something like :e % to get a file explorer in the directory of interest. I know these seem like little things but it is throwing off my workflow big time.
@robertjmccabe
2 жыл бұрын
Nevermind. I went back to the native netrw file explorer. nvim-tree was too weird for me.
What colorscheme is it?
Anyone else having trouble with luasnip recognizing snippets (timestamp 13:28 and 14:37) I found this after reading the docs: ls.add_snippets("all", { ls.parser.parse_snippet("expand", "-- this is what was expanded!"), ls.parser.parse_snippet("lf", "local $1 = function($2) $0 end"), }) Not sure if i'm implementing it wrong or if they changed the method names in a recent commit... but the ls.add_snippets() is what worked to recognize my snippets.
#amazing
Intro reminds me of Better Call Sual
Why make a whole keymap for s when you can do :so and you don't have to make a keymap and its the same number of keystrokes?
Maaan the fact that the luasnip api has changed really messed me up
Teej it's official , you are going shoot ad for my new video , with beginbot 🤣🤣
@teej_dv
2 жыл бұрын
haha, maybe I found a new career... ;)
12:30 lmaoo
Not even mad.
@teej_dv
2 жыл бұрын
BUT WAIT THERES MORE
damnit TJ
@teej_dv
2 жыл бұрын
wait a second... that's not your line
1:48 🤣🤣🤣
damn I made a bunch of luasnip snippets without the extras.. I made my own rep() function after a significant time figuring out how to do this.. I can't believe I missed the extras in the docs (assuming it's there, it is right? EDIT: yes extras is metioned, but fmt() is undocumented for as far as I can see) Also without the fmt() it is not really very readable and quite a bit of punctuation.. and of course I didn't think of creating something like that myself :) And I assume it would be a considerable effort. hopefully vid 2 and 3 will be posted soon Currently using both luasnip and ultisnips as I have to port a bunch of snippets still (which use a fair bit of python I want to get rid of and replace by lua only, it will be glorious!) Thanks for this!
@teej_dv
2 жыл бұрын
but you learned more things, so that's good :) Working on 2, but it's still a bit away.
Does LuaSnip support friendly-snippets?
@teej_dv
2 жыл бұрын
github.com/L3MON4D3/LuaSnip#add-snippets Yup!
So, your life turned around 360º, huh? You must like ballet. 😄
so when is the next video?
@teej_dv
2 жыл бұрын
haha, great queestion. I'm not sure right now. Still working on the script and what not. Can't give any good timelines at this point. Sorry about that