Automatically Execute *Anything* in Nvim

  Рет қаралды 67,047

TJ DeVries

TJ DeVries

Жыл бұрын

A lot of people asked me in my previous video about Golang "How did you automatically execute the Go code in Neovim on save?" So in this video I'll show you how to do that step-by-step :)
Let me know what you think!
Video for reference: ( • Go's Worst Feature? )
Twitch: / teej_dv
Twitter: / teej_dv
Github: github.com/tjdevries
Discord: discord.gg/teej

Пікірлер: 155
@jakeshoemaker1483
@jakeshoemaker1483 Жыл бұрын
dude - you and prime opened a black hole with neovim for me and i love it bro. thanks for the content
@no_name4796
@no_name4796 2 ай бұрын
Yeah, he is the reason i was able to get into neovim lol Docs are good, but if they don't give you a more general understanding of how thing work
@leptanian
@leptanian Жыл бұрын
Great content as always. I appreciate these vids that explain bits and pieces of nvim even more after my switch to Lua. Thanks Tj!
@teej_dv
@teej_dv Жыл бұрын
Awesome :) hope you're having fun!
@majam1n
@majam1n Жыл бұрын
TJ we're lucky to have you taking us on these awesome Neovim / Lua journeys. Do more, please.
@abohm25
@abohm25 Жыл бұрын
Love this!! Great job TJ! I appreciate all the hard work you put into stuff like this. Keep them coming!
@mischavandenburg
@mischavandenburg Жыл бұрын
Thank you so much for this video! I've completely re-done my nvim configuration taking your kickstart.nvim as a starting point and I'm improving my lua to take my customisation to the next level. Please keep making these lua coding walkthroughs, they are a great way to learn!
@TheFalloo92
@TheFalloo92 Жыл бұрын
This is precisely what I was looking for, my dear. Great job!
@nilsgg
@nilsgg Жыл бұрын
Really enjoy these small practical Neovim Lua examples. Has made it possible to write my own automation functions! Thank you 😊
@n0kodoko143
@n0kodoko143 Жыл бұрын
Good the patience you have to walk is through this to this level of granularity, didn't go unnoticed. Sincerely, thank you! Sorry interested in seeing more!
@alexwexov4298
@alexwexov4298 Жыл бұрын
Amazing ! I always wondered how to write to buffers or run jobs. This kind of videos that show how to build plugins are great. Thanks.
@korney4eg
@korney4eg Жыл бұрын
As always very useful staff and practical examples! Keep going!
@vahidss
@vahidss Жыл бұрын
Thanks. I really needed it. I hadn't gotten in to autocmd so what I did was to have a nodemon (usually in a toggleterm) run what I want to do
@thaddaeusmarkle1665
@thaddaeusmarkle1665 Жыл бұрын
Awesome vid TJ! Would love to see a part 2 (yes I did leave a like 😁), and maybe something like adding the output to the quickfix list if it has a non-zero exit code would be cool too.
@tobiasweyer5063
@tobiasweyer5063 Жыл бұрын
as complete beginner to neovim, this was great to see where the journey of learning neovim, will bring me. :) Thx for the great video.
@jpbuilds6167
@jpbuilds6167 Жыл бұрын
This is so awesome and well explained. I have so many ideas. Thanks Tj
@santiagoosoriosanchez250
@santiagoosoriosanchez250 Жыл бұрын
Thanks alot I really mean it!. your way to teach is awesome giving ideas and not just how to do a specific thing
@adriansrfr
@adriansrfr Жыл бұрын
These 10 minute vids are great, keep them coming!
@vmnog
@vmnog Жыл бұрын
waiting for the continuation :) great tutorial !
@ayoubelmhamdi7920
@ayoubelmhamdi7920 Жыл бұрын
This video explains the question I asked in the comments of the previous video, thank you very much
@Cih2001
@Cih2001 Жыл бұрын
Thanks. Your videos are awesome, and I've learned a lot. Although this is something that people can figure on their own, in the tutorial, it could be helpful to explain how to create a new buffer and open it in a new window for the output using the nvim api.
@arnaudf.67
@arnaudf.67 Жыл бұрын
Wow its so much easier and extensible to do these things in lua rather than in vimscript. I remeber back in the days were it was a pain doing something like that neatly when you start having non trivial function. Thanks TJ, and I really looking forward to watch the video you mentioned at the end, on how to attach and detach with command!
@rsmith31416
@rsmith31416 Жыл бұрын
The extensibility shouldn't be any different between the lua and vimscript version. I don't know why you had issues before, but this is the vimscript version that does pretty much the same in 10 lines: let s:bufnr = 4 function Callback(channel, msg) call appendbufline(s:bufnr, '$', a:msg) endfunction augroup GoGroup autocmd! autocmd BufWritePost *.go call deletebufline(bufname(s:bufnr), 1, '$') | \ call job_start(["go", "run", "main.go"], {'callback': function('Callback')} ) augroup END The neovim implementation of jobs is pretty similar.
@jesseleite
@jesseleite Жыл бұрын
Love these types of tutorial vids man! Do more of this stuff!
@JulianInsua
@JulianInsua Жыл бұрын
Love this kind of stuff!!! Thanks!
@abujessica
@abujessica Жыл бұрын
So good at explaining stuff keep it up, truly love these videos
@teej_dv
@teej_dv Жыл бұрын
Thank you :) so happy to hear that after posting a video!
@Alpha_Dev
@Alpha_Dev Жыл бұрын
Thanks TJ, awesome idea, I will use it soon on my config. Have a great day.
@yyba2371
@yyba2371 Жыл бұрын
Awsome explanation TJ, Sure we want a another video
@willhleucka821
@willhleucka821 Жыл бұрын
Fantastic! Thank you, TJ!
@connect_to_the_dots
@connect_to_the_dots Жыл бұрын
Your lesson helped a lot, after that i wrote my first lody. Thank you very much.
@chrisjames278
@chrisjames278 Жыл бұрын
another awesome video, Thanks TJ
@dimitardimitrov3421
@dimitardimitrov3421 Жыл бұрын
WOW, great tutorial!
@user-bs4gg8sq7h
@user-bs4gg8sq7h Жыл бұрын
Thank you very much for such a great content, TJ! Have you considered creating some kind of course on Nvim, explaining and showcasing core concepts?
@avimehenwal
@avimehenwal Жыл бұрын
amazing amazing, best video on demystifying neovim ever :D Thankyou so much for sharing. Huge like from my side
@robertjmccabe
@robertjmccabe Жыл бұрын
This is awesome. Keep these coming.
@IgetsugaS2
@IgetsugaS2 Жыл бұрын
Great content as always!
@muhammadsulthanmazaya2388
@muhammadsulthanmazaya2388 Жыл бұрын
Dang u just become my fav youtuber & streamer! Nice video as always teej
@davedwad852
@davedwad852 Жыл бұрын
Masterful. You and the other lad always knocking out top notch content. You're Body he's Doyle. Nuff said.
@DanielTateNZ
@DanielTateNZ Жыл бұрын
These basics are amazing! More basics!
@wuilliam321
@wuilliam321 Жыл бұрын
Greeeeoeatttttttt! I was trying to do something like this with no success xD. This is great, i just didn't want to store the buffers anywhere, just something temporal. But thanks! Seems to be useful!
@kristupasqwert9888
@kristupasqwert9888 Жыл бұрын
We need more of these. Ive learned so mu ch from watching these! Thanks TJ
@teej_dv
@teej_dv Жыл бұрын
I've got a list of things kind of like this that I'm going to try and make it in between some of the larger videos :) glad you liked it !
@chairlovawitabat
@chairlovawitabat Жыл бұрын
Thank you TJ! This is so cool. Can you actually do a demo of creating a to-do list using only telescope and the bufwrite api? I think it’d be cool showing how you can create a list of times and then write them programmatically to a local file using lua and the nvim apis. I am playing w the idea of using nvim for latex documents. It’s 90% of the way there. The only thing missing is bibliography management-for me, being able to use a simple UI interface to add/remove refs would easily have NeoVim blow other dedicated editors out of the water .
@driden1987
@driden1987 11 ай бұрын
Hi TJ, rewatching this series in 2023, expecting a part 3 !!! Love ya
@PhanTanThangTH
@PhanTanThangTH Жыл бұрын
Thank you so much, I really really appreciate that :)
@fernandobaroni1497
@fernandobaroni1497 Жыл бұрын
Great tutorial!
@Hedshodd
@Hedshodd Жыл бұрын
Oh, I could use this to "lua-fy" my current auto commands, which are just calling vimscript inside of my .lua config. Thanks for the video!
@Ash-qp2yw
@Ash-qp2yw Жыл бұрын
This is actually really cool and I like it. I'm considering doing something similar that opens a buffer automatically and runs a specific linting tool, so I might be able to use some of this - although, I'd want to have it on it's own command, instead of on save, but that can't be too tricky to do
@lsouza1327
@lsouza1327 Жыл бұрын
it's pretty easy to do, just use vim.keymap.set(), just pass the function that you would pass to the autocmd to this function and you are done.
@wuilliam321
@wuilliam321 Жыл бұрын
Yeah! Same here!
@vellankiindeevar5530
@vellankiindeevar5530 Жыл бұрын
its just beautiful
@roa234
@roa234 Жыл бұрын
Amazing ❤️
@Tazato
@Tazato Жыл бұрын
Whenever I think my nvim is slick, youtube gives me a video of yours to make it better. Thank you for the tutorial!
@teej_dv
@teej_dv Жыл бұрын
That's very high praise! Thanks!
@_zh3ro_
@_zh3ro_ 7 ай бұрын
AMAZING!!!
@andredasilva6807
@andredasilva6807 Жыл бұрын
thats really nice. would love to see more lua scripts
@kuijaye
@kuijaye Жыл бұрын
Thanks man!
@scc4213
@scc4213 Жыл бұрын
really helpful !
@lukasz_kostka
@lukasz_kostka Жыл бұрын
I'd like to see more of things like this.
@ricardoislasruiz3186
@ricardoislasruiz3186 Жыл бұрын
Damn beautiful!
@bhaveshverma8629
@bhaveshverma8629 Жыл бұрын
Awesome again learn so much. Thanks you so much....................
@lalitmee
@lalitmee Жыл бұрын
Man, I don't need all these other plugins then. It will be simple and useful. You are a wizard, man.
@teej_dv
@teej_dv Жыл бұрын
Thanks! :) let me know if you do anything cool with it!
@lucasefe
@lucasefe Жыл бұрын
You and prime are rocking it. Thanks. Should we be watching someone else talking about neovim?
@encode_this1817
@encode_this1817 Жыл бұрын
This is great and you should feel great.
@adriansrfr
@adriansrfr 3 ай бұрын
Wow, very cool!
@armynyus9123
@armynyus9123 Жыл бұрын
Best vid on nevim.
@danilo2735
@danilo2735 Жыл бұрын
Man, that's impressive
@maheshwarimurli
@maheshwarimurli Жыл бұрын
Damn this can be super-helpful for running tests for competitive programming
@teej_dv
@teej_dv Жыл бұрын
Yeah! Just save the file and BOOM it's running :)
@mohitkumar-jv2bx
@mohitkumar-jv2bx Жыл бұрын
Lets get this video 1k likes fast!!. And thanks Tj as always for the great video.
@frydac
@frydac Жыл бұрын
heh, already 1000+ likes within 24 hours, I guess you know what to do. I would be interested to see this maybe in combo with makeprg and errorformat, which I never bothered to try out, as I'm not sure I would like it for C++ with sometimes very long error messages as I would think it gets hard to read when they are in the quickfix window, or even to get the complete error message with errorformat, and I don't know where the stdout goes which also interests me. Currently I use kitty hints to parse the terminal scrollback buffer and neovim remote to open the running nvim instance on the file:line:column of the errormsg. Anyway, great video, never used jobstart, def learned something new again :)
@nodidog
@nodidog Жыл бұрын
Top stuff 🥳
@kodder
@kodder Жыл бұрын
Good Stuff
@ricardorien
@ricardorien Жыл бұрын
Thanks!
@saltytab
@saltytab Жыл бұрын
Thank you for the again another informative video. At the risk of sounding cliched may I asked what is the colorscheme you are using.
@gamer-tantrik
@gamer-tantrik Жыл бұрын
Hey Tj love your content as always and a big fan. Why don't we make a cool informative guide to neovim and like setup 3, 4 projects where beginners could learn how to make certain plugins. I think it would really help the community and for interesting people like me who want to contribute to neovim but don't have that much time to go through complete documentation.
@gurparv1993
@gurparv1993 Жыл бұрын
If its Tj video then 2 things in the following order. : 1. Like first, 👍 2. and then watch .
@steveaguay
@steveaguay Жыл бұрын
The greatest part of watching others use vim is some simple thing said in the off hand will be revolutionary to me. I had a block where I never thought to use leader twice.
@darkarie
@darkarie Жыл бұрын
nice!
@picosdrivethru
@picosdrivethru Жыл бұрын
wowowow
@CharlieSmithv2
@CharlieSmithv2 Жыл бұрын
Nice vid! Im curious if the same could be done using tmux and a new pane versus a new nvim buffer? Or am i doing it wrong?
@MrCradleman
@MrCradleman Жыл бұрын
Great video. Finally vim could do something close to Emacs can do since 90-s :)
@teej_dv
@teej_dv Жыл бұрын
haha :) well the feature has been around for a lot longer than that, I just find doing it via Lua and Lua autocmds much more elegant. But yes, emacs can do a lot of cool things of course :)
@artemrusinov3034
@artemrusinov3034 Жыл бұрын
Cool!
@patersr
@patersr Жыл бұрын
Thanks
@patriciourrutia2297
@patriciourrutia2297 Жыл бұрын
Great video TJ! I'm gona try to use it to compile my md-latex docs with pandoc. The autosave.lua file is located in a special folder or it doesn't matter?
@teej_dv
@teej_dv Жыл бұрын
You can put it anywhere you want! You just execute it to turn it on.
@andrespotapczynski2665
@andrespotapczynski2665 Жыл бұрын
Hey TJ, where can I put questions and suggestions about topic videos? I'm new to neovim but I want to use some of the ideas that you have shown in the videos for my own use cases.
@rickhackro
@rickhackro Жыл бұрын
There's a lot of useful stuff on the nvim_{whatever} API
@lucastperez
@lucastperez Жыл бұрын
I do pretty much the same with tmux and a vim plugin called VimTmuxRunner (it sends commands to tmux panes), but the full neovim + lua solution is much cooler! 😄
@benjinguyen9965
@benjinguyen9965 Жыл бұрын
hey TJ-what colorscheme is that? It's sick!
@webmandman
@webmandman Жыл бұрын
Yo tj, you didn't mention how dynamically create a new buffer and append the stdout lines to it. But I think one can use print(data) which will automatically create a buffer horizontally at the bottom?
@Zeioth
@Zeioth 10 ай бұрын
I have an autocmd that, every time I write a buffer into the directory "personal-notes" it uses rclone to upload the content of the directory to an online storage service. Then on my phone I have a Termux script "Download notes" to download the same backlog I have on my computer on my phone, and I can read it and edit it on vim. Exactly the same way I would do on my computer.
@WilmanArambillete
@WilmanArambillete Жыл бұрын
rookie question: how do you split your screen in panes (you have 3 and have seen you handle your buffers like that in your other videos). Thanks
@miyalys
@miyalys Жыл бұрын
Does vim have an event log to help you see/debug when various events fire exactly?
@zakariachahboun
@zakariachahboun Жыл бұрын
Cool! gopher!
@WillEhrendreich
@WillEhrendreich Жыл бұрын
Awesome stuff TJ. How about taking this idea and defeating the enterprise feature for visual studio called live unit testing
@ChrisCox-wv7oo
@ChrisCox-wv7oo 8 ай бұрын
I use fswatch to monitor for any changed files in my project directory, when a file is changed, it recompiles and runs tests. The results aren't tightly integrated with nvim but it does give me real time notification as things break / fixed.
@WillEhrendreich
@WillEhrendreich 8 ай бұрын
@@ChrisCox-wv7oo I haven't done fswatch, is that similar to dotnet watch? I have done that.
@webmandman
@webmandman Жыл бұрын
dude, I thought I had subscribed to your channel a long time ago. so sorry dude. keep up the great work.
@teej_dv
@teej_dv Жыл бұрын
all is forgiven :)
@VinnyMeller
@VinnyMeller Жыл бұрын
How do you get the lsp to recognize the builtin nvim api stuff? e.g you were getting autocomplete when typing vim.api.nvim_
@KronosaurusRex
@KronosaurusRex Жыл бұрын
Hello TJ, this is great! Any chance you can explain your tj#saveandexec thing? I find interesting that it sources and kind of reloads neovim. I'm always quitting and opening again.
@teej_dv
@teej_dv Жыл бұрын
Well it sources and reloads a particular file -- it doesn't do the whole neovim. I write code that allows things to be re-executed though (and use some knowledge of lua to do so). I will add it to my list to cover reloading nvim from within the same instance though :)
@sp4yke
@sp4yke Жыл бұрын
which plugin is used for the autocompletion with signature support ?
@DragonKidPlaysMC
@DragonKidPlaysMC Жыл бұрын
More tutorials please!
@QmVuamFtaW4
@QmVuamFtaW4 Жыл бұрын
you've got some beautiful hair.
@thongng5699
@thongng5699 Жыл бұрын
What is the font name you are using?
@zen-ventzi-marinov
@zen-ventzi-marinov Жыл бұрын
Hi Tj, I guess you don't use any neovim distribution but if you did, which ones would you seriously consider?
@jazzochannel
@jazzochannel Ай бұрын
I'd like to see a follow up to this, please!
@rajaravivarmar
@rajaravivarmar Ай бұрын
How do I set such a cursor in my mac Terminal? I have enabled blinking but I don't know how to set that return symbol.
@jithin.johnson
@jithin.johnson Жыл бұрын
How about using a Makefile and running make command on BufWritePost?
@murphykuffour6034
@murphykuffour6034 Жыл бұрын
does jobstart support sudo
@cyprienh2192
@cyprienh2192 Жыл бұрын
Great video!! Is there a way to clear the buffer?
@Mankepanke
@Mankepanke Жыл бұрын
I suppose doing the same as the initial example (line 0 to -1) but passing an empty list for the data
@cyprienh2192
@cyprienh2192 Жыл бұрын
@@Mankepanke yes, does the job!
Execute **anything** in neovim (now customizable)
11:02
TJ DeVries
Рет қаралды 34 М.
PDE: A different take on editing code
20:01
TJ DeVries
Рет қаралды 75 М.
Would you like a delicious big mooncake? #shorts#Mooncake #China #Chinesefood
00:30
Super gymnastics 😍🫣
00:15
Lexa_Merin
Рет қаралды 100 МЛН
DELETE TOXICITY = 5 LEGENDARY STARR DROPS!
02:20
Brawl Stars
Рет қаралды 18 МЛН
요즘 조개네일💗💙 #유리네일 #조개네일 #shellnails
0:09
TakeTuesday E01: nvim-cmp
30:42
TJ DeVries
Рет қаралды 61 М.
tree-sitter explained
15:00
TJ DeVries
Рет қаралды 72 М.
10 Advanced Vim Features (You Probably Didn't Know)
21:47
Sebastian Daschner
Рет қаралды 66 М.
Why you're wrong about 0-based indexing
10:23
TJ DeVries
Рет қаралды 25 М.
Integrated Test Results in Neovim
14:50
TJ DeVries
Рет қаралды 34 М.
Tmux has forever changed the way I write code.
13:30
Dreams of Code
Рет қаралды 911 М.
Why Vim Experts Do THIS Instead of Using Tabs...
7:55
DevOps Toolbox
Рет қаралды 120 М.
Effective Neovim: Instant IDE
16:16
TJ DeVries
Рет қаралды 772 М.
Vim Tips I Wish I Knew Earlier
23:00
Sebastian Daschner
Рет қаралды 38 М.
Мечта Каждого Геймера
0:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 1,5 МЛН
После ввода кода - протирайте панель
0:18
Телефон в воде 🤯
0:28
FATA MORGANA
Рет қаралды 738 М.
Как работает автопилот на Lixiang L9 Max
0:34
Семен Ефимов
Рет қаралды 16 М.
Секретный смартфон Apple без камеры для работы на АЭС
0:22