Magically format embedded languages in Neovim

Поділитися
Вставка

КОМЕНТАРІ • 154

  • @joeycozza2600
    @joeycozza2600 2 роки тому +101

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

    • @teej_dv
      @teej_dv  2 роки тому +19

      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 роки тому +39

    Loving these more advanced videos! Good stuff!

    • @teej_dv
      @teej_dv  2 роки тому +6

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

  • @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!

  • @mosheavni404
    @mosheavni404 2 роки тому +11

    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.
    נאו-ווים זה מגניב!

  • @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.

  • @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!

  • @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.

  • @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.

  • @alexwexov4298
    @alexwexov4298 2 роки тому

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

  • @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

  • @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

  • @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!

  • @arnaudf.67
    @arnaudf.67 2 роки тому

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

  • @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 :)

  • @maximilianmuecke8552
    @maximilianmuecke8552 2 роки тому +1

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

  • @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

  • @wouldbabyhitlerkillyou4217
    @wouldbabyhitlerkillyou4217 Рік тому +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?

  • @jefmyers502
    @jefmyers502 2 роки тому

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

  • @devonduty
    @devonduty 2 роки тому +1

    Neovim ist fantastisch!

  • @daephx
    @daephx 27 днів тому

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

  • @thiagoritcher
    @thiagoritcher Рік тому

    So nice. Thanks for that!

  • @MinNyeAccount
    @MinNyeAccount Рік тому

    you create some cool stuff brohan

  • @jesseleite
    @jesseleite 2 роки тому

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

  • @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.

  • @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..

  • @ricardokullock2535
    @ricardokullock2535 2 роки тому +2

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

  • @CarmenGeelhaar
    @CarmenGeelhaar 7 місяців тому

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

  • @Unaimend
    @Unaimend Рік тому

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

  • @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 ™

  • @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!

  • @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 !!

  • @davidsicilia5316
    @davidsicilia5316 2 роки тому

    Thanks for this video, much better than reading docs!

  • @darkarie
    @darkarie 2 роки тому

    Amazing video TJ!

  • @berkeleytrue
    @berkeleytrue 2 роки тому +2

    you are the GOAT

  • @craigrodrigues3435
    @craigrodrigues3435 2 роки тому

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

  • @TNeulaender
    @TNeulaender 2 роки тому

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

  • @fabiomc
    @fabiomc 2 роки тому

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

  • @Basheski
    @Basheski Рік тому

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

  • @philippemassicotte5401
    @philippemassicotte5401 Рік тому

    Thank you very much. This was very helpful!

  • @armynyus9123
    @armynyus9123 Рік тому

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

  • @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?

  • @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

  • @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?

  • @dontwanttousemyrealnametol6765
    @dontwanttousemyrealnametol6765 2 роки тому

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

  • @WaylonWalker
    @WaylonWalker 2 роки тому +1

    Consider that like button smashed

  • @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!

  • @mahdiaghaei8154
    @mahdiaghaei8154 2 роки тому

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

  • @cadetriestocode
    @cadetriestocode Рік тому

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

    • @teej_dv
      @teej_dv  Рік тому

      thanks :) I'm glad you enjoyed it!

  • @AntonyXavier-v9j
    @AntonyXavier-v9j 5 місяців тому

    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!

  • @JohnWasinger
    @JohnWasinger Рік тому

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

  • @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.

  • @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.

  • @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.

  • @avimehenwal
    @avimehenwal 2 роки тому

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

  • @weeb3277
    @weeb3277 6 місяців тому +1

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

    • @germandavid2520
      @germandavid2520 5 місяців тому

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

  • @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 }}...

  • @cherryramatis2508
    @cherryramatis2508 Рік тому

    Neovim é muito incrivel! Cheers from brazil

  • @nickshv8727
    @nickshv8727 Рік тому +1

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

  • @rafaelcolladojr
    @rafaelcolladojr 6 місяців тому

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

  • @masoudesmaeilian5083
    @masoudesmaeilian5083 Рік тому

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

  • @sebastianmangelsen8056
    @sebastianmangelsen8056 Рік тому

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

  • @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 😁

  • @beimercamposmezones6487
    @beimercamposmezones6487 2 роки тому +1

    is it posible to activate a specific lsp autocompletion too?

  • @haomingli6175
    @haomingli6175 2 роки тому

    What font are you using here? It looks great

  • @007arek
    @007arek 2 роки тому

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

  • @Nilithus
    @Nilithus 2 роки тому

    neovim is cool!

  • @stevenhe3462
    @stevenhe3462 Рік тому

    This needs to be in `rust-tools`.

  • @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?

  • @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.

  • @Kaszanas
    @Kaszanas Рік тому

    How about syntax highlighting embedded languages?

  • @tomaszgalkowski8701
    @tomaszgalkowski8701 Рік тому

    Neovim jest zajebisty.

  • @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

  • @mattetis
    @mattetis 2 роки тому

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

  • @celsopatiri2846
    @celsopatiri2846 2 роки тому

    lets go teej

  • @alexa.davronov1537
    @alexa.davronov1537 Рік тому +1

    TreeSitter is very cool, powerful thing. Wouldn't be it simpler to embed formatter into a Rust LSP? There are options to extend embedded languages into a primary one.

  • @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 😅

  • @uskensun
    @uskensun 2 роки тому

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

  • @BennyPowers
    @BennyPowers 2 роки тому

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

  • @billywang3829
    @billywang3829 2 роки тому

    this is so fucking useful

  • @BUtZUe
    @BUtZUe 2 роки тому

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

  • @manuelschmidt570
    @manuelschmidt570 2 роки тому

    Neovim ist toll! 😁

  • @gingergoat3027
    @gingergoat3027 2 роки тому

    rost är häftigt

  • @_jdfx
    @_jdfx 2 роки тому +3

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

  • @medfahmy6465
    @medfahmy6465 Рік тому

    Any idea how to highlight them as sql?

  • @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

  • @zamboney100
    @zamboney100 2 роки тому

    אני אוהב neovim!!!

  • @vadifly
    @vadifly Рік тому

    Nvim is cool.

  • @spicybaguette7706
    @spicybaguette7706 2 роки тому

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

  • @Ipanienko
    @Ipanienko Рік тому

    Neovim jest świetny ☺

  • @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 UA-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

  • @prasadsawool
    @prasadsawool 2 роки тому

    noice

  • @Max-bh8tg
    @Max-bh8tg Рік тому

    Could you share the source code for this?

  • @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)

  • @christophervalerio5964
    @christophervalerio5964 2 роки тому

    lua esta demasiado tuanis (costa rican spanish)

  • @7xr1e20ln8
    @7xr1e20ln8 Рік тому

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

  • @ahmet_ed_8683
    @ahmet_ed_8683 2 роки тому

    ong

  • @user-xd5gd4pc9h
    @user-xd5gd4pc9h 2 роки тому

    echo ”Cooooool..." >>TJ

  • @Spikey8d
    @Spikey8d 2 роки тому

    print("Neovim is cool")

  • @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?