Open Hubro opened 5 months ago
@clason It seems to only have gotten worse. Now decorated functions can't be moved in any circumstances. Given this test file:
def test1():
pass
@foo
def test2():
pass
@foo
def test3():
pass
def test4():
pass
def test5():
pass
And the commands ts_swap.swap_next("@function.outer")
and ts_swap.swap_previous("@function.outer")
, the decorated functions no longer register as functions at all. The normal functions can be moved up and down, but jump right past the decorated functions. The decorated functions can't be moved whether the cursor is placed in the decorator or in the function.
NVIM v0.11.0-dev-492+g0cdeb06db
nvim-treesitter bfb50de
nvim-treesitter-textobjects ced6375
Describe the bug
Swapping
@function.outer
in Python doesn't work when inside a decorated function. Take the example:When in either of the un-decorated functions, swapping with the decorated function works just fine. When in the decorated function, nothing happens when you try to swap, unless the cursor is on the decorator line.
Given the queries:
My guess is that this happens because when inside the decorated function, the non-decorated
@function.outer
match is the closest match and is selected for swapping, but since it's inside a(decorated_definition ...
, it doesn't have any siblings to swap with:So nothing happens.
To Reproduce Steps to reproduce the behavior:
(See above)
I'm using these functions:
Expected behavior
If the current cursor position matches both a function_definition and a decorated_definition, the latter should have higher priority.
Output of
:checkhealth nvim-treesitter
nvim-treesitter: require("nvim-treesitter.health").check() Installation ~ - WARNING `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall) - OK `node` found v20.11.0 (only needed for :TSInstallFromGrammar) - OK `git` executable found. - OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" } Version: gcc (GCC) 13.2.0 - OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI. OS Info: { machine = "x86_64", release = "6.9.3", sysname = "Linux", version = "#1-NixOS SMP PREEMPT_DYNAMIC Thu May 30 07:45:04 UTC 2024" } ~ Parser/Features H L F I J - bash ✓ ✓ ✓ . ✓ - c ✓ ✓ ✓ ✓ ✓ - css ✓ . ✓ ✓ ✓ - diff ✓ . . . . - dockerfile ✓ . . . ✓ - git_config ✓ . ✓ . ✓ - git_rebase ✓ . . . ✓ - gitcommit ✓ . . . ✓ - gitignore ✓ . . . ✓ - hyprlang ✓ . ✓ ✓ ✓ - ini ✓ . ✓ . ✓ - javascript ✓ ✓ ✓ ✓ ✓ - json ✓ ✓ ✓ ✓ . - just ✓ ✓ ✓ ✓ ✓ - lua ✓ ✓ ✓ ✓ ✓ - make ✓ . ✓ . ✓ - markdown ✓ . ✓ ✓ ✓ - markdown_inline ✓ . . . ✓ - nix ✓ ✓ ✓ . ✓ - python ✓ ✓ ✓ ✓ ✓ - query ✓ ✓ ✓ ✓ ✓ - requirements ✓ . . . ✓ - robot ✓ . ✓ ✓ ✓ - sql ✓ . . ✓ ✓ - ssh_config ✓ ✓ ✓ ✓ ✓ - tmux ✓ . . . ✓ - toml ✓ ✓ ✓ ✓ ✓ - tsx ✓ ✓ ✓ ✓ ✓ - typescript ✓ ✓ ✓ ✓ ✓ - vim ✓ ✓ ✓ . ✓ - vimdoc ✓ . . . ✓ - xml ✓ ✓ ✓ ✓ ✓ - yaml ✓ ✓ ✓ ✓ ✓ - yang ✓ . ✓ ✓ ✓ 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} ~
Output of
nvim --version
Additional context
-