Magically format embedded languages in Neovim

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ธ.ค. 2024

ความคิดเห็น • 159

  • @joeycozza2600
    @joeycozza2600 2 ปีที่แล้ว +105

    Programming is Cool. Also, just in case you didn't catch it, "Rust".

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว +20

      good point, wouldn't want people to miss Rust, btw

    • @ricardokullock2535
      @ricardokullock2535 2 ปีที่แล้ว +4

      Can't like your comment because the current count is 42. Don't want to mess that up.

    • @redumptious2544
      @redumptious2544 ปีที่แล้ว +3

      @@ricardokullock2535hahaha nice.
      The more niche 69

  • @ronniemagatti3342
    @ronniemagatti3342 2 ปีที่แล้ว +42

    Loving these more advanced videos! Good stuff!

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว +6

      Thanks :) they have been pretty fun to make as well!

  • @mosheavni404
    @mosheavni404 2 ปีที่แล้ว +12

    Thanks TJ, keep it up!
    I don't imagine myself writing treesitter queries anytime soon, but who knows, I didn't think I'd move from the way my vimrc was, and now my whole config is in lua.
    נאו-ווים זה מגניב!

  • @notgate2624
    @notgate2624 2 ปีที่แล้ว +22

    Loving these. Treesitter is a game changer

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว +3

      It really enables all sorts of crazy integrations!

  • @scottiedoesno
    @scottiedoesno 2 ปีที่แล้ว +2

    This kind of stuff makes in depth configuration and plugin writing so much more approachable! Thanks a ton and keep it up!

  • @chrisjames278
    @chrisjames278 2 ปีที่แล้ว +5

    This is awesome. Thanks TJ. Was great to watch this live as well. Would love this to be expanded on in upcoming videos

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว +1

      What would you like to see expanded upon? I'm not sure what other aspects would make a good youtube video.

    • @chrisjames278
      @chrisjames278 2 ปีที่แล้ว

      @@teej_dv It was mostly just what could be done with the TS queries in a file, but like you said in the video, after playing around with some queries this morning, it is pretty self explanatory.
      One question I have is would you be able to change the colour scheme of the SQL syntax highlighting or would it always just default to whatever you have set as your current colour scheme?

    • @Martinni39
      @Martinni39 2 ปีที่แล้ว

      @@teej_dv It would be interesting if we could leverage TS to do some bulk refactoring.

  • @davidstadelmann3278
    @davidstadelmann3278 2 ปีที่แล้ว +2

    Awesome in every sense. Your videos are always very well structured and it is always a pleasure to watch and listen. It takes so much different aspects to achieve this. I really appreciate your commitment.

  • @syswow6457
    @syswow6457 2 ปีที่แล้ว +5

    As usual - damn great video. It would be great if things like this will expand to some kind of "LUA?? NEOVIM?? YES - treesitter usage guide & examples with RUST BTW" series. Can't wait for it.

  • @n0kodoko143
    @n0kodoko143 2 ปีที่แล้ว +1

    Thanks! TJ!
    Question: for work I'm on a MacBook (traditionally Linux but you know), having trouble with mac's version of cmake which forces me to use brew (meaning no nightly version on the Mac).
    Any suggestions (also, I'm on an m1, arm arch).
    Thanks in advance!
    Also, at least on my journey, seeing potential for heredocs! (Neovim is cool)

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว +1

      can't you do `brew install neovim --HEAD` ?

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว +1

      Also, thanks for the super thanks :)

    • @n0kodoko143
      @n0kodoko143 2 ปีที่แล้ว

      Hot sauce - so brew is a bit of a 'git clone' (programmer humor) 🤣. TY it's compliling as I type.

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว

      awesome!

  • @alexwexov4298
    @alexwexov4298 2 ปีที่แล้ว

    Wow amazing, I was searching these kind of videos my whole life ! Thanks TJ !!!!!

  • @arnaudf.67
    @arnaudf.67 2 ปีที่แล้ว

    This is mind bogueling, thank you so much TJ to make those videos

  • @albertlee9592
    @albertlee9592 2 ปีที่แล้ว

    Omg this was unthinkable in vim a couple of years ago.. amazing! Thank you for showing the possibility and the how of this dark magic

  • @ricardokullock2535
    @ricardokullock2535 2 ปีที่แล้ว +2

    Neovim é foda! Parabéns pelo trabalho! :D

  • @Martinni39
    @Martinni39 2 ปีที่แล้ว +2

    I'd be curious to see if TS could still detect the SQL string if it was stored in a constant variable instead of directly in the query func. Damn I guess have to go try that for myself..

  • @nodidog
    @nodidog ปีที่แล้ว

    Love this so much. I'm going to go and adapt this concept to the SQL queries in a Go project, see you on the other side

  • @Gokuroro
    @Gokuroro 2 ปีที่แล้ว +4

    Looking at the Treesitter Scheme code I was thinking that it could be interesting to have something like that using the jq JSON parser inside neovim.

  • @rubensiotaperez9334
    @rubensiotaperez9334 ปีที่แล้ว

    I very much enjoy your videos, always something to learn - thank you. I am intrigued to find out what color scheme you use, I really like it!

  • @maximilianmuecke8552
    @maximilianmuecke8552 2 ปีที่แล้ว +1

    Brilliant, just what I was looking for! Loving your colorscheme, what are you using?

  • @davidsicilia5316
    @davidsicilia5316 2 ปีที่แล้ว

    Thanks for this video, much better than reading docs!

  • @jefmyers502
    @jefmyers502 2 ปีที่แล้ว

    You're videos are super helpful! Thank you! Like button smashed!

  • @arisweedler4703
    @arisweedler4703 2 ปีที่แล้ว

    In SF. Big fan, TSPlayground blew my mind. I gotta switch to nvim from vim, now. I have spent hours and hours reading through vim help pages (and 2 books - practical vim & learnvimscriptthehardway (ok this is a website)). I have written a few small cute little plugins in old vimscript. Including a clone of the “execute from one buffer and put it into another”.
    The plugin I’m most proud of is one that defines a grammar to [tab]edit or source your config files (ftplugin, syntax, vimrc, current, etc.)
    I enjoyed it all, but it was also a lot of work. I am slowly coming to accept that the native treesitter bindings are just… it’s unbeatable. As I learn more about neovim, it becomes the first time in my life where I’m starting to see stuff that I can’t think of how to do in vim and I think that I know enough to confidently say “this cannot be done trivially”.
    I could write an external program that does this… filters the whole file & formats the SQL - it would probably even use treesitter. The results would be the same - but it wouldn’t be part of my text editor. But to have first class support for stuff like this, the interactive building of the query - instead of having to copy paste example code into the treesitter web app (idk if they even have a query builder but they certainly do - that’s too useful not to) - so fast. So clean. So powerful.
    Now begins the arduous and slow journey of … I just gotta learn the available commands. See y’all in 100 in-documentation hours! :) I will enjoy the journey

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว

      The nice thing about switching to neovim is that so much of what you had working before will continue to work! :) so it hopefully would not be a paintful switch. Let me know how it goes :)

  • @craigrodrigues3435
    @craigrodrigues3435 2 ปีที่แล้ว

    Whoa this is cool neovim + treesitter == A++!

  • @axeldahlberg7043
    @axeldahlberg7043 2 ปีที่แล้ว +2

    I really like this way of going a bit quicker and refer to documentations for details :) Then I can learn what is possible and if I need more details I can look it up later on.
    Btw, I think this implementation assumes the strings are on separate lines from the other rust nodes? Supporting formatting eg `sqlx::query(r#"..."#, id)` on a single line might be more tricky I guess.

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว +2

      Yes, it does assume that right now because I will always write them on multiple lines :) the beauty of writing tools for yourself!

  • @Unaimend
    @Unaimend ปีที่แล้ว

    We need more tree sitter stuff, that was soo cool.

  • @CarmenGeelhaar
    @CarmenGeelhaar 11 หลายเดือนก่อน

    👍 love tutorials like this one. I will try it out in a go project

  • @wouldbabyhitlerkillyou4217
    @wouldbabyhitlerkillyou4217 2 ปีที่แล้ว +1

    Do a vid on decoration provider and/or how to implement a totally custom TS highlighter please. Also when to use register_cbs vs buffer events vs decoration provider? Also difference between regular extmarks and ephemeral?

  • @TNeulaender
    @TNeulaender 2 ปีที่แล้ว

    Wow. That really was a lot easier than I thought O.o.

  • @mahdiaghaei8154
    @mahdiaghaei8154 2 ปีที่แล้ว

    Awesome content, I'm learning a lot from you. Here is what you asked for in persian language:
    نئوویم عالیه 😃

  • @jesseleite
    @jesseleite 2 ปีที่แล้ว

    Rad stuff! Would love to see more treesitter fun vids!

  • @tomontheinternet
    @tomontheinternet 2 ปีที่แล้ว +3

    Very cool!
    Did anyone catch what programming language he was using??

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว +5

      Have you heard of rust? BTW? RUST BTW?!

    • @bew
      @bew 2 ปีที่แล้ว +1

      It's Lua :)

    • @astroid-ws4py
      @astroid-ws4py 2 ปีที่แล้ว +1

      Rust + Python + Lua + Scheme, All are cool !!

  • @sebastianmangelsen8056
    @sebastianmangelsen8056 ปีที่แล้ว

    TJ, how do you highlight the carriage return in all lines? Many thanks in advance!

  • @MarwanMustafaFikrat
    @MarwanMustafaFikrat ปีที่แล้ว

    Hey Teej, I've been looking all over the place to find how to (what now I know is) using `injections` to change the highlighting of a node (or range?). Where is this `/queries/{lang}/injections.scm` stuff documented?

  • @MarcelRobitaille
    @MarcelRobitaille 2 หลายเดือนก่อน

    How did you do that thing at 12:15???

  • @MinNyeAccount
    @MinNyeAccount ปีที่แล้ว

    you create some cool stuff brohan

  • @devonduty
    @devonduty 2 ปีที่แล้ว +1

    Neovim ist fantastisch!

  • @daephx
    @daephx 4 หลายเดือนก่อน

    Completely glanced over the plenary job that runs the python script.

  • @armynyus9123
    @armynyus9123 ปีที่แล้ว

    I fear a bit we'll loose you to helix, with all your love for rust....

  • @philippemassicotte5401
    @philippemassicotte5401 ปีที่แล้ว

    Thank you very much. This was very helpful!

  • @Danielo515
    @Danielo515 2 ปีที่แล้ว +3

    Awesome video as always. Do you know what will be even more awesome? A dedicated tree sitter queries video. Information on the topic is sparse and hard to find

  • @thiagoritcher
    @thiagoritcher ปีที่แล้ว

    So nice. Thanks for that!

  • @weeb3277
    @weeb3277 9 หลายเดือนก่อน +1

    can you write a syntax highlighter/formatter for graphql embed in a JS string?

    • @germandavid2520
      @germandavid2520 8 หลายเดือนก่อน

      Prettier support that by default, just add the word graphql or gql before the backticks like this graphql`your graphql code here`

  • @PRonYouTube
    @PRonYouTube ปีที่แล้ว

    Excited to watch through this tomorrow. Would also love to know if there's a way to enable syntax highlighting for embedded languages too

    • @dariuscorvus
      @dariuscorvus ปีที่แล้ว

      probably you need a naming scheme or detect the language through the content of the constant

  • @cadetriestocode
    @cadetriestocode 2 ปีที่แล้ว

    Amazing content, tutorials like this pried me from the hands of Elisp 😂

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว

      thanks :) I'm glad you enjoyed it!

  • @fabiomc
    @fabiomc 2 ปีที่แล้ว

    Wow… lots of little tips here, thank you so much!

  • @MarcelRobitaille
    @MarcelRobitaille 2 หลายเดือนก่อน

    But how do you format the scheme string literal query you use to format your sql string literal query

  • @cherryramatis2508
    @cherryramatis2508 ปีที่แล้ว

    Neovim é muito incrivel! Cheers from brazil

  • @masoudesmaeilian5083
    @masoudesmaeilian5083 ปีที่แล้ว

    Hi TJ, where I can have the source code for this injected sql formatter you have wrote, pleas?

  • @darkarie
    @darkarie 2 ปีที่แล้ว

    Amazing video TJ!

  • @rafaelcolladojr
    @rafaelcolladojr 9 หลายเดือนก่อน

    How would you limit this to whichever SQL query literal your cursor is in?

  • @matthiasqueitsch3720
    @matthiasqueitsch3720 2 ปีที่แล้ว

    Can you explain how I match in order to inject? I have a SQL with jina blocks inside (dbt). There is a jinja2 grammar and a sql grammar for Treesitter. But the Playground shows me ERROR for the jinja blocks, so I cannot use "string_literal' as you showed. I suspect that I have to pattern match on the jinja blocks {{ code }}...

  • @AntonyXavier-v9j
    @AntonyXavier-v9j 9 หลายเดือนก่อน

    why is the formatter in neovim slower than vs code ? i tried to fomat a html file with 1000 lines
    in neovim it was taking more time than vscode is there a way to fix it ?

  • @asainzp
    @asainzp 2 ปีที่แล้ว

    Thanks for the video TJ!
    Neovim mola! Neovim es guay!

  • @avimehenwal
    @avimehenwal 2 ปีที่แล้ว

    I love all your videos :D Neovim is super-coooollll

  • @mattetis
    @mattetis 2 ปีที่แล้ว

    Where do I put the injection query? I cannot understand it from the help pages 😶

  • @beimer-official
    @beimer-official 2 ปีที่แล้ว +1

    is it posible to activate a specific lsp autocompletion too?

  • @guillaumebouchard5109
    @guillaumebouchard5109 2 ปีที่แล้ว

    Super nice video, thank you.
    I was wondering, how can I only highlight part of the substring.
    For example, if I have something like r#"First query: SELECT * from foo; Second query: SELECT * from bar"#
    Is there a way to "refine" the parser so I'm not parsing on the complete "raw_string_literal", but instead on a sub string?

    • @RyanHart92
      @RyanHart92 2 ปีที่แล้ว

      Same! Was trying to use `#offset!` like in the video but didn't seem to work 🤔

    • @guillaumebouchard5109
      @guillaumebouchard5109 2 ปีที่แล้ว +1

      @@RyanHart92 offset works but I was not able to "detect" the values for its arguments.
      Instead I wrote a custom parser, that's actually straightforwards, just a bit more difficult to package.

    • @RyanHart92
      @RyanHart92 2 ปีที่แล้ว

      @@guillaumebouchard5109 custom tree sitter parser or just string manipulation in lua/python? I ended up giving up on offset and just doing the parsing in lua 😅

  • @nickshv8727
    @nickshv8727 ปีที่แล้ว +1

    Syntax highlight for sqlx queries doesn't work anymore. Code is outdated!

  • @mvargasmoran
    @mvargasmoran ปีที่แล้ว

    This looks like Emacs MuMaMo, multiple major modes, I don't know if that still has support.
    but you could have a lot of langs in the same file, just like Teej example.
    but the example back in 2009 was Html Php Js and Css.

  • @dontwanttousemyrealnametol6765
    @dontwanttousemyrealnametol6765 2 ปีที่แล้ว

    I do the comma-first thing in latex; it makes it easier to comment arguments out.

  • @zeocamo
    @zeocamo 2 ปีที่แล้ว +1

    neovim er sejt, neovim is cool, Rust btw, i love you making videos like this Teej, i can just send to a coworker.

  • @stevenlander3325
    @stevenlander3325 2 ปีที่แล้ว

    Hey TJ, great video! I am on 0.7.x but it looks like TSPlayground is only available in Neovim nightly (0.8x) builds, is that right?

  • @berkeleytrue
    @berkeleytrue 2 ปีที่แล้ว +2

    you are the GOAT

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว

      thank you :)

  • @007arek
    @007arek 2 ปีที่แล้ว

    Unfortunately asciidoc doesn't support Treesitter. Is it a way to add that functionality to the ascii format?

  • @medfahmy6465
    @medfahmy6465 2 ปีที่แล้ว

    Any idea how to highlight them as sql?

  • @Kaszanas
    @Kaszanas ปีที่แล้ว

    How about syntax highlighting embedded languages?

  • @JohnWasinger
    @JohnWasinger ปีที่แล้ว

    This would’ve come in handy when I was writing JavaScript inside a PHP wrapper.
    Filetype was .html I think.

  • @WaylonWalker
    @WaylonWalker 2 ปีที่แล้ว +1

    Consider that like button smashed

  • @Basheski
    @Basheski 2 ปีที่แล้ว

    Неовим е страхотен!

  • @astipple
    @astipple 2 ปีที่แล้ว

    Great content, as always. Tried to get the highlighting, when entering a query in the scratchpad of TSPlayground. Everything else seems to work flawless, but I do not get highlighting for the simplest query (language is C99). A bit frustrating, because exactly this feature would be really more than helpful. Anyone an idea?

    • @anon-qn5fc
      @anon-qn5fc ปีที่แล้ว

      11 months late, but I solved this by running :TSInstall query

  • @chyldstudios
    @chyldstudios 2 ปีที่แล้ว +3

    What if there was a community marketplace, where people could A) submit scripts with descriptions and B) download scripts that other people wrote. Kind of like VS Code marketplace, but for Neovim addons, scripts, etc. Could be very useful.

    • @kaporos
      @kaporos 2 ปีที่แล้ว +3

      This is called github lmao

    • @tomaszgalkowski8701
      @tomaszgalkowski8701 ปีที่แล้ว

      You literally reinvented GitHub.

    • @CNich90
      @CNich90 หลายเดือนก่อน

      @@kaporos LOL I thought the same. This describes every open source project known to man.

  • @haomingli6175
    @haomingli6175 2 ปีที่แล้ว

    What font are you using here? It looks great

  • @ciaran.downey
    @ciaran.downey 2 ปีที่แล้ว +2

    Wow that’s cool, what language is this in?

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว +2

      Oh, I think I forgot to mention. Great question. It's rust btw ™

  • @codeman99-dev
    @codeman99-dev ปีที่แล้ว

    I want to see this again. Except, the primary language is bash and the embeds are heredocs. Detect the type of the embed from the first line shebang, the the extension of the output redirect, or the executing command.

  • @elyezer
    @elyezer 2 ปีที่แล้ว +1

    When you click on like even before starting the video and then hear on the video to smash the like button before anything... Am I predicting the future?

  • @Max-bh8tg
    @Max-bh8tg ปีที่แล้ว

    Could you share the source code for this?

  • @BennyPowers
    @BennyPowers 2 ปีที่แล้ว

    shows you how to embed queries in neovim
    the scheme query language in the neovim lua conf... not highlighted ;)

  • @tomaszgalkowski8701
    @tomaszgalkowski8701 ปีที่แล้ว

    Neovim jest zajebisty.

  • @uskensun
    @uskensun 2 ปีที่แล้ว

    Neovim 是最讚的編輯器,感謝 TJ。我想要學 Rust

  • @BUtZUe
    @BUtZUe 2 ปีที่แล้ว

    Neovim is cool "นีโอวิม โคตร เจ๋ง"

  • @Ipanienko
    @Ipanienko 2 ปีที่แล้ว

    Neovim jest świetny ☺

  • @_jdfx
    @_jdfx 2 ปีที่แล้ว +3

    So good! thanks TJ!
    println!("Neovim is cool");

  • @manuelschmidt570
    @manuelschmidt570 2 ปีที่แล้ว

    Neovim ist toll! 😁

  • @stevenhe3462
    @stevenhe3462 ปีที่แล้ว

    This needs to be in `rust-tools`.

  • @yourdadsbestfriend7101
    @yourdadsbestfriend7101 2 ปีที่แล้ว +1

    this could be crazy with markdown files

    • @jmbuhr
      @jmbuhr 2 ปีที่แล้ว +1

      The markdown treesitter grammar already has injected languages, so it's even easier to get a certain language

  • @lucastperez
    @lucastperez 2 ปีที่แล้ว +1

    I can see you putting rust twice in the thumbnail 👀

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว +1

      Haha glad someone caught the joke 😁

  • @raqueebuddinaziz
    @raqueebuddinaziz 2 ปีที่แล้ว

    Would it be somehow possible to combine lsp + treesitter to make so that every filepath in a file is somehow checked and if it doesn't exist its highlighted differently maybe underlined
    print("neovim is cool")

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว

      why would you need to use lsp? you can do it with the same strategy as I just mentioned and add it to vim.diagnostic.set

    • @raqueebuddinaziz
      @raqueebuddinaziz 2 ปีที่แล้ว

      I thought lsp could help with relative paths but maybe I am thinking this wrong as some langs have path aliases too like typescript aliases

    • @reo101
      @reo101 2 ปีที่แล้ว

      tsserver will take care of the special ones but other than that its a great idea for treesitter + diagnostics

    • @jmbuhr
      @jmbuhr 2 ปีที่แล้ว +1

      I have been trying to use treesitter and hidden buffers to add code completion, lsp things and diagnostics to embedded languages in markdown, but currently I am a bit stuck. Does anyone have pointers for e.g. asking cmp or diagnostics for completions or decorations from another buffer?

  • @Nilithus
    @Nilithus 2 ปีที่แล้ว

    neovim is cool!

  • @ChrisPatti
    @ChrisPatti ปีที่แล้ว

    please don’t tase me, but the more I learn about the modern day neovim ecosystem, the more it reminds me of Emacs :-) (this brought to you by the fact that TIL TreeSitter uses scheme for queries)

  • @gingergoat3027
    @gingergoat3027 2 ปีที่แล้ว

    rost är häftigt

  • @CNich90
    @CNich90 หลายเดือนก่อน

    select
    ‘Neovim is cool!’ as comment
    from my_heart

  • @zamboney100
    @zamboney100 2 ปีที่แล้ว

    אני אוהב neovim!!!

  • @nagkanya
    @nagkanya 2 ปีที่แล้ว

    lets go teej

  • @spicybaguette7706
    @spicybaguette7706 2 ปีที่แล้ว

    Commenting "Rust" for the algorithm.
    Trouwens, neovim is supergaaf

  • @christophervalerio5964
    @christophervalerio5964 2 ปีที่แล้ว

    lua esta demasiado tuanis (costa rican spanish)

  • @vadifly
    @vadifly ปีที่แล้ว

    Nvim is cool.

  • @7xr1e20ln8
    @7xr1e20ln8 2 ปีที่แล้ว

    నెఒవిం ఇజ్ కూల్ (You asked for it)

  • @prasadsawool
    @prasadsawool 2 ปีที่แล้ว

    noice

  • @billywang3829
    @billywang3829 2 ปีที่แล้ว

    this is so fucking useful

  • @b4mbus60
    @b4mbus60 2 ปีที่แล้ว +6

    Ah yes 360p

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว +2

      IT SAID IT WAS DONE PROCESSING HD?!? WHY HAVE YOU DONE THIS TO ME TH-cam????

    • @b4mbus60
      @b4mbus60 2 ปีที่แล้ว +1

      @@teej_dv Haha, what a liar :D it's HD now, very cool.

    • @teej_dv
      @teej_dv  2 ปีที่แล้ว +2

      @@b4mbus60 phew, that's good haha

  • @艾曦-e4g
    @艾曦-e4g 2 ปีที่แล้ว

    echo ”Cooooool..." >>TJ