summaryrefslogtreecommitdiffstats
path: root/2022/talks/treesitter.md
blob: 1cad68c46246edf43c3eb32b278563bdde028257 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
[[!sidebar content=""]]
[[!meta title="Tree-sitter beyond syntax highlighting"]]
[[!meta copyright="Copyright © 2022 Abin Simon"]]
[[!inline pages="internal(2022/info/treesitter-nav)" raw="yes"]]

<!-- Initially generated with emacsconf-generate-talk-page and then left alone for manual editing -->
<!-- You can manually edit this file to update the abstract, add links, etc. --->


# Tree-sitter beyond syntax highlighting
Abin Simon (IRC: meain on libera.chat, Matrix: @meain:matrix.org, <mailto:mail@meain.io>)

[[!inline pages="internal(2022/info/treesitter-before)" raw="yes"]]

Tree sitter has seen a lot of development recently, but more often
than not folks are only aware of its use for syntax highliting. The
idea of this talk is to introduce some other usecases where they could
benefit from tree-sitter.

This talk will be an overview of the kind of things that they will be
able to do with tree-sitter with demos but won't go in depth into how
they would all of them. The presentation will link to the resources
mentioned during the talk where folks can learn more about each of
them.

This session will introduce them to things like (not final list):

-   textobjects using tree-sitter: <https://github.com/meain/evil-textobj-tree-sitter/>
-   Folding using tree-sitter: <https://github.com/emacs-tree-sitter/ts-fold>
-   Navigating config headings: <https://blog.meain.io/2022/navigating-config-files-using-tree-sitter/>
-   Using tree-sitter for narrowing: <https://blog.meain.io/2022/more-treesitter-emacs/#narrow-to-language-level-constructs>
-   Intelligent snippets using tree-sitter: <https://blog.meain.io/2021/intelligent-snippets-treesitter/>
-   Using tree-sitter to get which-func like functionality: <https://blog.meain.io/2022/more-treesitter-emacs/#show-current-class%2Ffunction-name-in-modeline>
-   Some useful tree-sitter functions: tree-sitter-save-excursion


# Discussion

## Notes

-   The speaker\'s blog: <https://blog.meain.io/>
-   Fancy Narrow: <https://github.com/Malabarba/fancy-narrow>
-   Text objects using tree-sitter in evil-mode:
    <https://github.com/meain/evil-textobj-tree-sitter/>
-   Notes/Slides: <https://github.com/meain/emacsconf-talk-tree-sitter>

## Questions and answers

-   Q: What treesitter package is being used I think there is 3
    different ones
    -   A:  Most of what is demoed here is using
        <https://github.com/emacs-tree-sitter/elisp-tree-sitter>
-   Q: Can the folds be treated as outlines as in outline-minor-mode
    folds?
    -   A: I don\'t think the package ts-fold which I showcased works
        with outline mode, but it should be simple enough to add
        something like that
        (<https://github.com/emacs-tree-sitter/ts-fold>)
-   Q: Is there any benefit to use tree-sitter for sexp-based languages?
    +1
    -   A: Being able to query for specific things like variables /
        conditions might come in handy
-   Q:Do you have to have an LSP set up in order to use tree-sitter?
    -   A:I still use eglot for lsp. While tree-sitter help with
        highlighting, folding, nav etc . . tree-sitter can be more
        thought of to be working on a single file. So when I need to do
        project wide things like jump to defenition, find reference or
        renames lsp comes in handy.
-   Q: Is there any example configuration for the transition from
    traditional major mode to new \*-ts-major-mode? It seems that
    configuration of major mode (xxx-mode-hook, yasnippet, etc) has to
    been rewritten
    -   A: I am just starting to work with builtin tree-sitter, so
        don\'t have much input here  unfortunately :(


[[!inline pages="internal(2022/info/treesitter-after)" raw="yes"]]

[[!inline pages="internal(2022/info/treesitter-nav)" raw="yes"]]

[[!taglink CategoryTreeSitter]]