diff options
author | Sacha Chua <sacha@sachachua.com> | 2022-12-03 10:00:56 -0500 |
---|---|---|
committer | Sacha Chua <sacha@sachachua.com> | 2022-12-03 10:00:56 -0500 |
commit | f625132d2a57d6957ba522ff0e2ec119f088884a (patch) | |
tree | 730460805a6ca62eb18aafb7d9dc5e8e8dad2794 /2022/info | |
parent | 3649f978c9cf23cf93add19772c3a2e058d11467 (diff) | |
download | emacsconf-wiki-f625132d2a57d6957ba522ff0e2ec119f088884a.tar.xz emacsconf-wiki-f625132d2a57d6957ba522ff0e2ec119f088884a.zip |
Automated commit
Diffstat (limited to '')
-rw-r--r-- | 2022/info/treesitter-after.md | 247 | ||||
-rw-r--r-- | 2022/info/treesitter-before.md | 25 |
2 files changed, 271 insertions, 1 deletions
diff --git a/2022/info/treesitter-after.md b/2022/info/treesitter-after.md index 76e4e39b..ddbc3e9a 100644 --- a/2022/info/treesitter-after.md +++ b/2022/info/treesitter-after.md @@ -1,6 +1,253 @@ <!-- Automatically generated by emacsconf-publish-after-page --> +<a name="treesitter-mainVideo-transcript"></a> +# Transcript + +[[!template new="1" text="Hey everyone, my name is Abin Simon" start="00:00:00.000" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and this talk is about "Tree-sitter:" start="00:00:03.240" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Beyond Syntax Highlighting."" start="00:00:05.080" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="For those who are not aware of what Tree-sitter is," start="00:00:08.200" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="let me give you a quick intro." start="00:00:10.720" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Tree-sitter, at its core, is a parser generator tool" start="00:00:11.720" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and an incremental parsing library." start="00:00:17.120" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="What it essentially means is that it gives you" start="00:00:19.440" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="an always up-to-date" start="00:00:22.000" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="AST [abstract syntax tree] of your code." start="00:00:23.155" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="In the current Emacs frame, what you see to the right" start="00:00:24.200" video="mainVideo-treesitter" id="subtitle"]] +[[!template new="1" text="is the AST tree produced by Tree-sitter" start="00:00:27.960" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="of the code that is on the left." start="00:00:30.840" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="For example, if you go to this "if" statement," start="00:00:33.560" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="you can see it goes here." start="00:00:37.000" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="It is also really good at handling errors." start="00:00:38.840" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="For example, if I were to delete this [if statement]," start="00:00:41.440" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="it still parses out a tree as much as it can," start="00:00:44.400" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="but with an error node." start="00:00:47.960" video="mainVideo-treesitter" id="subtitle"]] +[[!template new="1" text="Now let's see how we can query the tree" start="00:00:50.280" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="to get the information that we need." start="00:00:51.760" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Let's first try to get all the identifiers in the buffer." start="00:00:54.440" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="It highlights all the identifiers in the buffer," start="00:01:01.480" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="but let's say we want to get something" start="00:01:04.000" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="a little more precise." start="00:01:05.440" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Let's say we wanted to get this "i" here." start="00:01:07.280" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="This, in our case, would be this identifier" start="00:01:10.400" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="inside this assignment expression" start="00:01:13.280" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="inside this "for" statement." start="00:01:15.200" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="We can write it out like this." start="00:01:27.320" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="I hope this gives you a basic idea" start="00:01:29.920" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="of how Tree-sitter works and how you can query" start="00:01:31.880" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="to get the information that you need." start="00:01:34.480" video="mainVideo-treesitter" id="subtitle"]] +[[!template new="1" text="First of all, let's see how Tree-sitter can help us" start="00:01:37.040" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="with syntax highlighting." start="00:01:39.520" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="This is the default syntax highlighting by Emacs for SQL." start="00:01:41.880" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Now let's see how Tree-sitter helps." start="00:01:46.480" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="This is the syntax highlighting in Emacs" start="00:01:52.000" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="which Tree-sitter enabled." start="00:01:54.240" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="You'll see that we're able to target" start="00:01:56.760" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="a lot more things and highlight them." start="00:01:58.240" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="That said, you don't always have to" start="00:02:01.240" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="highlight everything." start="00:02:03.139" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="I personally prefer a much simpler theme." start="00:02:04.200" video="mainVideo-treesitter" id="subtitle"]] +[[!template new="1" text="Now let's see how Tree-sitter helps you simplify" start="00:02:15.640" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="adding custom syntax highlighting to your code." start="00:02:17.880" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="This is a Python file which has" start="00:02:20.920" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="a class and a few member functions." start="00:02:22.200" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Anyone who has used Python will know that" start="00:02:25.640" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="the "self" keyword, while it is passed in as an argument," start="00:02:27.680" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="it has more meaning than that." start="00:02:32.040" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Let's see if you can use Tree-sitter" start="00:02:34.240" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="to highlight just the "self" keyword." start="00:02:35.480" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="If you look at the Tree-sitter tree," start="00:02:38.720" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="you can see that this is the first identifier" start="00:02:40.400" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="in the list of parameters for a function definition." start="00:02:43.120" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="This is how you would query for the first identifier" start="00:02:45.520" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="inside parameters inside a function definition." start="00:02:55.480" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Now, if you see here, it also matches "cls"," start="00:02:59.320" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="but let's restrict it to match just "self"." start="00:03:02.520" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Now we have a Tree-sitter query that identifies" start="00:03:11.360" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="the first argument to the function definition" start="00:03:14.200" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and is also called "self"." start="00:03:16.960" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="We can use this to apply custom highlighting onto this." start="00:03:19.640" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="This is pretty much all the code" start="00:03:22.520" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="that you'll need to do this." start="00:03:25.000" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="The first block here is essentially to say to" start="00:03:26.520" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Tree-sitter to highlight anything with python.self" start="00:03:29.240" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="with the face of custom-set." start="00:03:32.160" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Now the second block here essentially is" start="00:03:35.720" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="how we match for that." start="00:03:37.520" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Now if you go back into a Python buffer" start="00:03:39.800" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and re-enable python-mode, we'll see that "self"" start="00:03:41.800" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="is highlighted differently." start="00:03:44.680" video="mainVideo-treesitter" id="subtitle"]] +[[!template new="1" text="How about creating text objects?" start="00:03:47.120" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Tree-sitter can help there too." start="00:03:48.880" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="For those who don't know, text objects" start="00:03:50.440" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="is an idea that comes from Vim," start="00:03:53.080" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and you can do things like select word," start="00:03:54.440" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="delete word, things like that." start="00:03:57.760" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="There are other text objects like line and paragraph." start="00:04:00.520" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="For each text object, you can have operations" start="00:04:06.200" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="that are defined on them." start="00:04:09.000" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="For example, delete, copy, select, comment," start="00:04:09.760" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="all of these are operations that you can do." start="00:04:13.600" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Let's try and use Tree-sitter to add more text objects." start="00:04:16.400" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="This is a plugin that I wrote" start="00:04:19.400" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="which lets you add more text objects into Emacs." start="00:04:20.560" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="It helps you code aware text objects" start="00:04:25.000" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="like functions, conditionals, loops, and such." start="00:04:27.880" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Let's see an example scenario of how" start="00:04:31.880" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="something like this could come in handy." start="00:04:34.360" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="For example, I can select inside this condition" start="00:04:35.920" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="or inside this function and do things like that." start="00:04:39.280" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Let's say I want to take this conditional," start="00:04:42.960" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="move to the next function, and create it here." start="00:04:44.520" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="What I would do is something like" start="00:04:47.160" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="delete the conditional, move to the next function," start="00:04:49.640" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="create a conditional there, and paste." start="00:04:52.320" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Let's try another example." start="00:04:56.240" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Let's say I want to take this and move it to the end." start="00:04:57.160" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="If I had to do it without text objects," start="00:05:01.360" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="I'd probably have to go back to the previous comma," start="00:05:02.960" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="delete till next comma, find the closing bracket," start="00:05:06.800" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and paste before." start="00:05:10.440" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="That works, but let's see" start="00:05:11.880" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="how Tree-sitter can simplify it." start="00:05:14.040" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="With Tree-sitter, I can say delete the argument," start="00:05:16.520" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="go to the end of the next argument, and then paste." start="00:05:19.240" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Tree-sitter essentially helps Emacs" start="00:05:22.880" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="understand the code better semantically." start="00:05:25.280" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Here is yet another use case." start="00:05:27.240" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="I work at a remote company," start="00:05:29.600" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and I often find myself being in a call" start="00:05:31.480" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="with my teammates, explaining the code to them." start="00:05:33.440" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="And one thing that really comes in handy" start="00:05:35.400" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="is the narrowing accessibility of Emacs." start="00:05:38.000" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Specifically, the fancy-narrow package." start="00:05:39.760" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="I use it to narrow just the function," start="00:05:43.040" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="or I could narrow to the conditional." start="00:05:44.840" video="mainVideo-treesitter" id="subtitle"]] +[[!template new="1" text="Next to the end, the list would be code folding." start="00:05:48.760" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="This is a package which uses Tree-sitter" start="00:05:51.520" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="to improve the code folding functionalities of Emacs." start="00:05:54.480" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Code folding has always been this thing" start="00:05:57.560" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="that I've had a love-hate relationship with." start="00:06:00.200" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="It usually works most of the time," start="00:06:02.280" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="but then fails if the indentation is wrong" start="00:06:04.280" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="or we do something weird with the arguments." start="00:06:06.960" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="But now with Tree-sitter in the mix," start="00:06:09.160" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="it's a lot more precise." start="00:06:11.680" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="I can fold comments, I can fold functions," start="00:06:12.720" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="I can fold conditionals. You get the idea." start="00:06:17.040" video="mainVideo-treesitter" id="subtitle"]] +[[!template new="1" text="I work with Kubernetes, which means I end up" start="00:06:20.480" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="having to write and read a lot of YAML files." start="00:06:23.840" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="And navigating big YAML files is a mess." start="00:06:28.080" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="The two main problems are figuring out where I am," start="00:06:31.840" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and two, navigating to where I want to be." start="00:06:35.760" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Let's see how Tree-sitter can help us with both of this." start="00:06:38.760" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="This is an example YAML file." start="00:06:41.760" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="To be precise, this is the values file" start="00:06:43.840" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="of the Redis helm chart." start="00:06:47.080" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="I'm somewhere in the file on tag under image," start="00:06:48.640" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="but I don't know what this tag is for." start="00:06:52.240" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="But with the help of Tree-sitter," start="00:06:54.880" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="I've been able to add this information" start="00:06:57.240" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="into my header line." start="00:06:59.160" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="If you see in the header line," start="00:07:00.440" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="you'll see that I'm under sentinel.image." start="00:07:02.960" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Now let's see how this helps with navigation." start="00:07:05.880" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Let's say I want to enable persistence on master node." start="00:07:08.800" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="So with the help of Tree-sitter," start="00:07:12.680" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="I was able to enumerate every field" start="00:07:18.200" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="that is available in this YAML file," start="00:07:20.400" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and I can pass that information onto imenu," start="00:07:22.200" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="which I can then use to go to exactly where I want to." start="00:07:24.520" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Also, since we're not dealing with" start="00:07:28.040" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="any language specific constructs," start="00:07:30.000" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="this is very easy to extend to" start="00:07:32.600" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="other similar languages" start="00:07:34.040" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="or config files in this case." start="00:07:35.760" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="So for example, this is a JSON file," start="00:07:37.440" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and I can navigate to location or project." start="00:07:39.520" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="And just like in YAML, it shows me where I'm at." start="00:07:44.800" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="I'm in projects.name," start="00:07:48.320" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="or I'm inside projects.highlights." start="00:07:49.920" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Or how about Nix?" start="00:07:52.880" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="This is my home.nix file." start="00:07:55.600" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Again, I can search for services," start="00:07:57.480" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and this lists me all the services that I've enabled." start="00:08:01.040" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="How about just services.description?" start="00:08:04.640" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="So this is all the services" start="00:08:06.720" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="that I've enabled and have descriptions." start="00:08:08.160" video="mainVideo-treesitter" id="subtitle"]] +[[!template new="1" text="Now that we have seen this for config files," start="00:08:10.480" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="let's see how similar things apply for code." start="00:08:12.720" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Just like in config files," start="00:08:15.040" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="I can see which function I'm under," start="00:08:16.760" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and if I go to the next function, it changes." start="00:08:18.680" video="mainVideo-treesitter" id="subtitle"]] +[[!template new="1" text="Okay, here is something really awesome." start="00:08:21.560" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="This is probably one of my favorites," start="00:08:23.960" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and one of the things that actually made me understand" start="00:08:26.600" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="how powerful Tree-sitter is, and got me into it." start="00:08:30.400" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="I work with a lot of Go code," start="00:08:34.080" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and anyone who has worked with Go will tell you" start="00:08:35.680" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="how repetitive it is handling errors." start="00:08:38.840" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="For those who don't write Go," start="00:08:41.040" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="let me give you a rough idea of what I'm talking about." start="00:08:42.800" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="If you want to bubble up the error," start="00:08:45.200" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="the way you would do it is just to return the error" start="00:08:47.000" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="to the function that called it." start="00:08:49.920" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Over here, you can either return nil or an empty value," start="00:08:51.400" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and at the end, you return error." start="00:08:55.720" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Let's try and use Tree-sitter to do this." start="00:08:57.640" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Using the help of Tree-sitter, let's make Emacs" start="00:09:00.200" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="go back, figure out what the return arguments are," start="00:09:03.120" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="figure out what their default values are," start="00:09:06.422" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and automatically fill in the return statement." start="00:09:08.240" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="It would look something like this." start="00:09:11.480" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="In my case, it filled in the complete form," start="00:09:13.040" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="it figured out what the return arguments are," start="00:09:16.120" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="what their types are," start="00:09:18.320" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and what their default values are," start="00:09:19.320" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and filled out the entire return." start="00:09:20.960" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="And since this is a template," start="00:09:22.800" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="I can go to the next function, do the same thing," start="00:09:24.760" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="next function, do the same thing," start="00:09:27.720" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="next function, do the same thing." start="00:09:29.560" video="mainVideo-treesitter" id="subtitle"]] +[[!template new="1" text="Here is a really fascinating use case of Tree-sitter," start="00:09:31.520" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="structural editing." start="00:09:34.360" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="You might be aware of plugins like paredit," start="00:09:36.320" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="which seems to "know" your code." start="00:09:38.200" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="This sort of takes it onto another level." start="00:09:40.280" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="It is in its early stages, but what this lets you do" start="00:09:42.520" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="is completely treat your code as an AST," start="00:09:46.040" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and edit as if it's a tree instead of characters." start="00:09:48.920" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="I am not going to go much in depth into it," start="00:09:52.000" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="but if you're interested, there is a talk" start="00:09:54.640" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="from last year's EmacsConf around it." start="00:09:57.000" video="mainVideo-treesitter" id="subtitle"]] +[[!template new="1" text="I'm just going to end this with one last tiny thing" start="00:09:59.080" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="that I found in the tree-sitter-extras package." start="00:10:02.320" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="It's this tiny macro called tree-sitter-save-excursion." start="00:10:04.920" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="It works pretty much like save-excursion, but better." start="00:10:07.600" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="It uses the Tree-sitter syntax tree" start="00:10:11.240" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="instead of just the code" start="00:10:13.400" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="to figure out where to restore the position." start="00:10:14.800" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="My main use case for this was with code formatters." start="00:10:16.720" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="Since the code moves around a lot" start="00:10:20.200" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="when it gets formatted," start="00:10:22.080" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="save-excursion was completely useless," start="00:10:23.160" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="but this came in handy." start="00:10:25.000" video="mainVideo-treesitter" id="subtitle"]] +[[!template new="1" text="I'll just leave you off with" start="00:10:26.240" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="what the future of Tree-sitter looks like for Emacs." start="00:10:28.120" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="So far, every Tree-sitter related feature" start="00:10:31.120" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="that I've talked about is powered by this library." start="00:10:33.760" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="But there is talk about Tree-sitter coming into the core." start="00:10:36.040" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="It will most probably be landing in Emacs 29," start="00:10:42.320" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="and if you want to check out the work on Tree-sitter" start="00:10:45.840" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="in core Emacs, you can check out" start="00:10:48.720" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="the features/tree-sitter branch." start="00:10:51.200" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="You'll probably see more and more features and packages" start="00:10:52.920" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="relying upon Tree-sitter, and even major modes" start="00:10:56.640" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="being powered by Tree-sitter." start="00:10:59.640" video="mainVideo-treesitter" id="subtitle"]] +[[!template text="And that's a wrap from me. Thank you." start="00:11:01.560" video="mainVideo-treesitter" id="subtitle"]] + + Questions or comments? Please e-mail [mail@meain.io](mailto:mail@meain.io?subject=Comment%20for%20EmacsConf%202022%20treesitter%3A%20Tree-sitter%20beyond%20syntax%20highlighting) diff --git a/2022/info/treesitter-before.md b/2022/info/treesitter-before.md index dff55412..c08406e1 100644 --- a/2022/info/treesitter-before.md +++ b/2022/info/treesitter-before.md @@ -10,9 +10,32 @@ The following image shows where the talk is in the schedule for Sat 2022-12-03. Format: 12-min talk followed by IRC Q&A (<a href="https://chat.emacsconf.org/?join=emacsconf,emacsconf-org,emacsconf-accessible,emacsconf-gen,emacsconf-dev">#emacsconf-dev</a>) Etherpad: <https://pad.emacsconf.org/2022-treesitter> Discuss on IRC: [#emacsconf-dev](https://chat.emacsconf.org/?join=emacsconf,emacsconf-dev) -Status: Talk captioned +Status: Now playing on the conference livestream <div>Times in different timezones:</div><div class="times" start="2022-12-03T15:00:00Z" end="2022-12-03T15:15:00Z"><div class="conf-time">Saturday, Dec 3 2022, ~10:00 AM - 10:15 AM EST (US/Eastern)</div><div class="others"><div>which is the same as:</div>Saturday, Dec 3 2022, ~9:00 AM - 9:15 AM CST (US/Central)<br />Saturday, Dec 3 2022, ~8:00 AM - 8:15 AM MST (US/Mountain)<br />Saturday, Dec 3 2022, ~7:00 AM - 7:15 AM PST (US/Pacific)<br />Saturday, Dec 3 2022, ~3:00 PM - 3:15 PM UTC <br />Saturday, Dec 3 2022, ~4:00 PM - 4:15 PM CET (Europe/Paris)<br />Saturday, Dec 3 2022, ~5:00 PM - 5:15 PM EET (Europe/Athens)<br />Saturday, Dec 3 2022, ~8:30 PM - 8:45 PM IST (Asia/Kolkata)<br />Saturday, Dec 3 2022, ~11:00 PM - 11:15 PM +08 (Asia/Singapore)<br />Sunday, Dec 4 2022, ~12:00 AM - 12:15 AM JST (Asia/Tokyo)</div></div><div><a href="/2022/watch/dev/">Find out how to watch and participate</a></div> +[[!template id="vid" vidid="treesitter-mainVideo" src="https://media.emacsconf.org/2022/emacsconf-2022-treesitter--treesitter-beyond-syntax-highlighting--abin-simon--main.webm" poster="https://media.emacsconf.org/2022/emacsconf-2022-treesitter--treesitter-beyond-syntax-highlighting--abin-simon--main.png" captions="""<track label="English" kind="captions" srclang="en" src="/2022/captions/emacsconf-2022-treesitter--treesitter-beyond-syntax-highlighting--abin-simon--main.vtt" default />""" +size="37M" duration="11:04" other_resources="""[Download --main.webm (37MB)](https://media.emacsconf.org/2022/emacsconf-2022-treesitter--treesitter-beyond-syntax-highlighting--abin-simon--main.webm) +[Download --main.vtt](https://media.emacsconf.org/2022/emacsconf-2022-treesitter--treesitter-beyond-syntax-highlighting--abin-simon--main.vtt) +[Download --main--chapters.vtt](https://media.emacsconf.org/2022/emacsconf-2022-treesitter--treesitter-beyond-syntax-highlighting--abin-simon--main--chapters.vtt) +[View transcript](https://emacsconf.org/2022/talks/treesitter#treesitter-mainVideo-transcript) +[View on Toobnix](https://toobnix.org/w/4AKhgQA71ewnyhDUsBnfKt) +"""]] +[[!template id="chapters" vidid="treesitter-mainVideo" data=""" +00:00:00.000 Opening +00:24.201 Introduction to Tree-sitter +00:50.280 Querying Tree-sitter tree +01:37.040 Syntax highlighting +02:15.640 Custom syntax highlighting +03:47.120 Text objects +05:48.760 Code folding +06:20.480 Navigating config files +08:10.480 Navigating code +08:21.560 Intelligent templates +09:31.520 Structural editing +09:59.080 tree-sitter-save-excursion +10:26.240 The future + +"""]] # Description |