Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Prototype of treesit.el support for ruby #47

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Commits on Jan 4, 2023

  1. Prototype of treesit.el support for ruby

    This commit is a prototype exploring what it would mean to make the
    minor mode work with the built in `treesit.el` treesitter support in
    Emacs 29. I've modified many of the functions and fold rules specific
    to the ruby language, and have tested locally with a few ruby code
    files to confirm things are working
    
    The actual work consists mostly of ...
    * swapping out functions for their `treesit.el` equivalents
    * replacing symbols for node types with strings
    * Modifying `(alist-get...` usages to support string keys
    AndrewSwerlick committed Jan 4, 2023
    Configuration menu
    Copy the full SHA
    db244a6 View commit details
    Browse the repository at this point in the history

Commits on Jan 8, 2023

  1. Configuration menu
    Copy the full SHA
    708c5f7 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    de098df View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f51f807 View commit details
    Browse the repository at this point in the history

Commits on Feb 2, 2023

  1. Add ts- modes

    garyo committed Feb 2, 2023
    Configuration menu
    Copy the full SHA
    3bd91f1 View commit details
    Browse the repository at this point in the history
  2. Check that treesit-buffer-root-node is defined

    Not sure why this is needed but I get startup errors without these.
    Perhaps an ordering issue.
    garyo committed Feb 2, 2023
    Configuration menu
    Copy the full SHA
    ad62bc7 View commit details
    Browse the repository at this point in the history
  3. Fix ts-fold-close-all

    `(car fold-range)` is not a sequence, it's a symbol, at least in my
    C++ buffers. This patch converts it using `symbol-name`.
    garyo committed Feb 2, 2023
    Configuration menu
    Copy the full SHA
    b9d44b6 View commit details
    Browse the repository at this point in the history
  4. Remove debug message

    garyo committed Feb 2, 2023
    Configuration menu
    Copy the full SHA
    ae7643e View commit details
    Browse the repository at this point in the history
  5. Fix ts-fold-indicators: treesit-query-compile needs list, not vector

    For simplicity I just converted the `patterns` vector to a list, but
    there are probably simpler ways to do this.
    garyo committed Feb 2, 2023
    Configuration menu
    Copy the full SHA
    e838f1c View commit details
    Browse the repository at this point in the history
  6. Handle errors from treesit-buffer-root-node

    It seems `treesit-buffer-root-node` returns an error when there is no
    parser for a given buffer. In my case, this happens when trying to get
    doc for an elisp variable; `ts-fold--tree-sitter-trigger` runs in an
    elisp-mode "*temp*" buffer, and `treesit-buffer-root-node` raises an
    error.
    If I just ignore the error around that call,
    `ts-fold--tree-sitter-trigger` still runs `(ts-fold-mode -1)`. Seems
    like the simplest thing is to just do nothing in that case.
    
    To repro the problem, enable ts-fold mode globally and do `C-H v
    emacs-version`.
    garyo committed Feb 2, 2023
    Configuration menu
    Copy the full SHA
    526987c View commit details
    Browse the repository at this point in the history

Commits on Feb 3, 2023

  1. Remove duplicate parser entry

    garyo committed Feb 3, 2023
    Configuration menu
    Copy the full SHA
    38f646c View commit details
    Browse the repository at this point in the history
  2. Add YAML support

    This is not perfect; when folding a node with children, it shows the
    first character of the node, then the fold indicator, then the colon.
    Ideally it would show the whole name of the key, and then the fold
    indicator. Not sure how to do that.
    garyo committed Feb 3, 2023
    Configuration menu
    Copy the full SHA
    3c0f46f View commit details
    Browse the repository at this point in the history
  3. Fix yaml support

    - Use a better ts-fold-range function for yaml
    - Remove "block_sequence" fold-parser; don't think that's useful.
    - Fix ts-fold--get-nth-child: `(treesit-node-children) is a list, not
      an array.
    garyo committed Feb 3, 2023
    Configuration menu
    Copy the full SHA
    59da027 View commit details
    Browse the repository at this point in the history

Commits on Feb 4, 2023

  1. Merge pull request #1 from garyo/garyo/treesit-el-patches

    treesit.el patches
    AndrewSwerlick authored Feb 4, 2023
    Configuration menu
    Copy the full SHA
    473ed37 View commit details
    Browse the repository at this point in the history

Commits on Mar 13, 2023

  1. Fix folding of c-preproc-if

    Some c-preproc-if have no 'else' branch and 'alternative' node.
    For example:
    
    CODE:
      #if THREAD_SIZE >= PAGE_SIZE
      void __init __weak thread_stack_cache_init(void)
      {
      }
      #endif
    
    TREE:
    (preproc_if #if
     condition: (binary_expression left: (identifier) operator: >= right: (identifier))
     \n
     (declaration type: (primitive_type) declarator: (identifier) type: ;)
     (function_definition type: (type_identifier)
      declarator:
       (function_declarator declarator: (identifier)
        parameters:
         (parameter_list (
          (parameter_declaration type: (primitive_type))
          )))
      body: (compound_statement { }))
     #endif)
    
    So we use last child node(i.e. "#endif") instead of 'alternative' node in this case.
    norris-young committed Mar 13, 2023
    Configuration menu
    Copy the full SHA
    a7bb833 View commit details
    Browse the repository at this point in the history

Commits on Mar 16, 2023

  1. Merge pull request #2 from norris-young/norris/treesit-ts-fold-fix

    Fix folding of c-preproc-if
    AndrewSwerlick authored Mar 16, 2023
    Configuration menu
    Copy the full SHA
    5253d0c View commit details
    Browse the repository at this point in the history