text stringlengths 0 2.02k |
|---|
[3406.66 --> 3411.34] Not maybe I don't know how far away we are, but we are not there yet to be able to do that. |
[3411.50 --> 3420.08] So it sounds like TreeSitter is driving a lot of the innovation around these cool new plugins that I keep seeing that are NeoVim only, |
[3420.28 --> 3423.82] not Vim as well because of the TreeSitter support. |
[3423.82 --> 3431.70] Yeah, I can give you a really cool example of a few things that people have been doing with TreeSitter that are like much further beyond just highlighting. |
[3431.96 --> 3432.38] Please do. |
[3432.94 --> 3440.92] Yeah, so a relatively like straightforward and easy to understand one is a plugin called nvimtscommentstring, I think. |
[3441.04 --> 3442.66] Off the top of my head, I don't remember exactly the name. |
[3443.08 --> 3448.90] But what it does is TreeSitter tells you what language you are currently inside of, |
[3449.10 --> 3452.94] and those languages can be embedded inside of the same file. |
[3452.94 --> 3458.48] So for example, in JavaScript land, you can have, you know, like React elements. |
[3458.66 --> 3462.90] And so then inside of there, you're kind of like in React, or I don't really know how any of that works, |
[3462.90 --> 3464.32] because I write back-end languages. |
[3464.50 --> 3466.54] But all of a sudden, I'm like, am I reading HTML? |
[3466.78 --> 3467.82] I thought there's JavaScript. |
[3468.22 --> 3469.36] I don't know what's going on. |
[3469.84 --> 3473.24] But one thing that's kind of annoying is if you use like a commenting plugin, |
[3473.24 --> 3478.78] and you try and comment something in the like JavaScript part versus like the HTML style part, |
[3479.06 --> 3481.46] you'll comment them incorrectly, right? |
[3481.70 --> 3482.56] So yes. |
[3483.20 --> 3488.76] nvimtscommentstring, all it does is it will just update the comment string option, |
[3488.94 --> 3495.00] which is a built-in option, depending on which language TreeSitter currently detects. |
[3495.00 --> 3500.36] So if it detects that you're inside of JavaScript land, it'll set it to slash slash space percent S. |
[3500.54 --> 3505.66] If it detects that you're inside of HTML, it sets it to the long HTML thingy. |
[3505.72 --> 3506.70] That's annoying to type. |
[3507.26 --> 3507.62] Right. |
[3507.96 --> 3508.60] That's cool. |
[3508.82 --> 3513.64] That one just honestly rocked my world, because I've had that problem in my life forever. |
[3513.64 --> 3514.12] Yeah. |
[3514.86 --> 3518.24] And so this is even cooler because it doesn't just work for those languages. |
[3518.88 --> 3523.62] In Lua, you can write FFI code, which is actually C, right? |
[3523.68 --> 3529.78] And it is somewhat deterministic how you start and end those C def blocks. |
[3529.78 --> 3534.16] So you can actually write a TreeSitter query that tells Neo them, |
[3534.28 --> 3538.08] hey, inside of these, this string, it's actually C code. |
[3538.08 --> 3543.92] And so you get C highlighting in this like random string in your file that you weren't expecting. |
[3544.18 --> 3548.66] And then if you're using TS comment string and you comment out a line in there, |
[3548.74 --> 3552.12] it comments out that line like it's C code. |
[3552.24 --> 3555.68] So it's very, very powerful to be able to do something like that. |
[3555.72 --> 3556.62] It's very exciting. |
[3556.88 --> 3557.64] That's awesome stuff. |
[3558.02 --> 3558.86] That's one example. |
[3559.04 --> 3562.48] I'll give you another one that I think is, for me, it's very fun. |
[3562.64 --> 3566.76] So I use a snippets plugin called Lua Snips, and it's kind of interesting. |
[3566.76 --> 3568.38] I've just been exploring it lately. |
[3569.02 --> 3574.14] But it allows you to sort of run Lua code as you're expanding your snippets |
[3574.14 --> 3576.96] to sort of generate what the next text should be. |
[3577.46 --> 3580.72] So if you're familiar with Golang at all, you know that there's like, |
[3580.80 --> 3584.30] you write if error not equals nil like 10,000 times a day. |
[3584.60 --> 3586.00] Maybe that's an understatement. |
[3586.16 --> 3590.00] I haven't profiled myself yet, but I think it's somewhere around there. |
[3590.26 --> 3595.42] And what you do inside of those error not equal nil sections is you have to write return |
[3595.42 --> 3599.64] and then the type signature basically with the default values, right? |
[3599.68 --> 3606.46] So if you return like an int and error, then you have to do like return 0 comma error, right? |
[3606.54 --> 3609.02] So like you write this thing a ton of times. |
[3609.18 --> 3614.36] So I actually wrote a Lua snippet that will ask TreeSitter. |
[3614.58 --> 3619.62] Basically, it has a custom query that I wrote inside of Golang that will ask TreeSitter, |
[3619.62 --> 3621.92] hey, what is the return type of this function? |
[3622.32 --> 3624.16] So it can query the tree. |
[3624.46 --> 3626.50] It gets back the current node that you're in. |
[3626.68 --> 3632.28] It asks for, hey, what is the nearest function scope that I'm inside of? |
[3632.54 --> 3633.66] So it's not a regex, right? |
[3633.68 --> 3637.28] It works for like inline functions inside of another function, all these kinds of things. |
[3637.46 --> 3638.58] It asks for that. |
[3638.66 --> 3641.16] It gets what the return signature looks like. |
[3641.32 --> 3648.30] And then it generates the snippet in the corresponding things with the default values and then error. |
[3648.30 --> 3654.48] So it's very cool because I can just type like IE for if error, expand my snippet, |
[3654.90 --> 3659.88] and correspondingly the right signature is generated as a return value. |
[3660.46 --> 3665.24] These are the kinds of things that make me very, very excited about TreeSitter. |
[3665.94 --> 3670.68] And why I say like it's cool to get better highlighting and like we look at our highlighting all day and that's very fun. |
[3671.20 --> 3675.16] But for both LSP and TreeSitter, the things that I'm most excited about, |
[3675.16 --> 3684.02] like especially on NeoVim core team, is we're trying to design interfaces that empower people to have much stronger sort of tools |
[3684.02 --> 3690.22] and understanding of the code that lets them extend their editors in sort of very unique and interesting ways, |
[3690.30 --> 3694.10] which is like I think the snippets one is a fun example of being able to do that. |
[3694.70 --> 3695.16] Goodness gracious. |
[3695.60 --> 3696.76] That is really neat. |
[3696.92 --> 3700.58] We're getting tight here, but we've teased Telescope a few times. |
[3700.90 --> 3702.58] Let's hit the nail on the head. |
[3702.86 --> 3703.94] Tell everybody about your... |
[3703.94 --> 3704.48] You're into it. |
[3704.68 --> 3705.76] Ooh, there you go now. |
[3705.76 --> 3705.92] Yeah. |
[3706.40 --> 3707.54] That's why we pay you the big bucks. |
[3707.98 --> 3717.70] So Telescope is a fuzzy finder that I started and I've had a lot of contributors to over the past year. |
[3717.90 --> 3720.80] I cannot thank enough the contributors to the project. |
[3721.40 --> 3727.74] In just over the last year, it's gotten over 3,000 stars and nearly 130 contributors. |
[3727.74 --> 3741.62] And I think that by itself is somewhat of a testament to how accessible Lua is, how interested people are to extend the editor and to like continue working on it and their ability to sort of pick up little pieces and do it. |
[3741.62 --> 3755.26] But in terms of like what Telescope is and why like I made it, I partially made it just to explore writing some stuff in Lua as a way to push our API and boundaries to find out what we should be including in NeoVim core. |
[3755.26 --> 3762.90] But as I was working on it, some of the things that I've struggled with doing in the past with fuzzy finders, I just wanted to try and solve. |
[3763.34 --> 3765.38] For example, like I love FZF. |
[3765.46 --> 3766.52] It's a very awesome tool. |
[3766.62 --> 3768.12] I use it all the time on the CLI. |
[3768.12 --> 3783.30] But it's very difficult to do something like pass a function through FZF because you have to encode it in some way and then decode it again later because FZF processes standard in and standard out, right? |
[3783.90 --> 3789.98] So Telescope is all Lua from the top of the stack down or FFI, but that still counts. |
[3789.98 --> 3799.66] And so you can pass a function reference, which might be what you want to do if this item is selected at the beginning of your code. |
[3799.78 --> 3801.52] And then you can pass that all the way through. |
[3801.62 --> 3805.60] And so when you select it, you can do something with that item. |
[3805.94 --> 3813.62] So my main goal for making it was just to basically create like the most extensible fuzzy finder that I could imagine. |
[3813.78 --> 3816.52] So like every part of Telescope is configurable. |
[3816.52 --> 3820.74] So like the sorting algorithm is just an interface of a function. |
[3820.92 --> 3826.86] So you can have FZY sorting, FZF, strict matching, engram matching. |
[3827.06 --> 3831.84] You can write whatever you want to do and you can just plug that in and that will just work with everything else. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.