tree-sitter / tree-sitter-ruby

Ruby grammar for tree-sitter
MIT License
176 stars 58 forks source link

bug: can not collapse a ruby lambda function inside a ruby method without collapsing the entire method when using code folds with neovim #263

Open ipatch opened 1 month ago

ipatch commented 1 month ago

Did you check existing issues?

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

not sure

Describe the bug

i do not have a tree-sitter cli cmd fwiw. not sure why. maybe because i compiled neovim from source.

nvim --version
NVIM v0.11.0-dev-3607+ge29f245a1
Build type: RelWithDebInfo
LuaJIT 2.1.1720049189
Run "nvim -V1 -v" for more info
nvim -V1 -v
NVIM v0.11.0-dev-3607+ge29f245a1
Build type: RelWithDebInfo
LuaJIT 2.1.1720049189
Compilation: /Library/Developer/CommandLineTools/usr/bin/cc -O2 -g -Og -g -flto=thin -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -fsigned-char -fstack-protector-strong -Wimplicit-fallthrough -fdiagnostics-color=auto -Wl,-export_dynamic -Wl,-no_deduplicate -DUNIT_TESTING -DHAVE_UNIBILIUM -D_GNU_SOURCE -DINCLUDE_GENERATED_DECLARATIONS -DUTF8PROC_STATIC -I/Volumes/STORAGE/ipatch/code/neovim-git/neovim-src/.deps/usr/include/luajit-2.1 -I/Volumes/STORAGE/ipatch/code/neovim-git/neovim-src/.deps/usr/include -I/Volumes/STORAGE/ipatch/code/neovim-git/neovim-src/build/src/nvim/auto -I/Volumes/STORAGE/ipatch/code/neovim-git/neovim-src/build/include -I/Volumes/STORAGE/ipatch/code/neovim-git/neovim-src/build/cmake.config -I/Volumes/STORAGE/ipatch/code/neovim-git/neovim-src/src -I/Library/Developer/CommandLineTools/SDKs/MacOSX13.1.sdk/usr/include -I/Users/ipatch/homebrew/opt/gettext/include

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/Users/ipatch/.local/share/nvim"

Run :checkhealth for more info

running checkhealth inside neovim

nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- WARNING `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- WARNING `node` executable not found (only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: Apple clang version 14.0.0 (clang-1400.0.29.202)
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "arm64",
  release = "21.6.0",
  sysname = "Darwin",
  version = "Darwin Kernel Version 21.6.0: Mon Aug 22 20:20:05 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8101"
} ~

Parser/Features         H L F I J
  - bash                ✓ ✓ ✓ . ✓
  - c                   ✓ ✓ ✓ ✓ ✓
  - cpp                 ✓ ✓ ✓ ✓ ✓
  - css                 ✓ . ✓ ✓ ✓
  - fish                ✓ ✓ ✓ ✓ ✓
  - html                ✓ ✓ ✓ ✓ ✓
  - javascript          ✓ ✓ ✓ ✓ ✓
  - json                ✓ ✓ ✓ ✓ .
  - lua                 ✓ ✓ ✓ ✓ ✓
  - luadoc              ✓ . . . .
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . . ✓
  - python              ✓ ✓ ✓ ✓ ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - rasi                ✓ ✓ ✓ ✓ ✓
  - ruby                ✓ ✓ ✓ ✓ ✓
  - rust                ✓ ✓ ✓ ✓ ✓
  - tsx                 ✓ ✓ ✓ ✓ ✓
  - typescript          ✓ ✓ ✓ ✓ ✓
  - vim                 ✓ ✓ ✓ . ✓
  - vimdoc              ✓ . . . ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang} ~

Steps To Reproduce/Bad Parse Tree

open the sample snippet / file below, ie. sample.rb and attempt to collapse just the lambda function inside neovim. on my setup the entire install method is collapsed.

Expected Behavior/Parse Tree

i would expect the lambda function could be folded using the standard zc in normal mode while keeping the rest of the def install method / function open.

Repro

def install
# some foo code here

cmake_prefix_paths = lambda {
[
Formula["doxygen"].prefix
# add additional formula prefixes below
]
}

# some more foo code here
end