nvim-treesitter / nvim-treesitter-textobjects

Apache License 2.0
2.21k stars 200 forks source link

error navigating markdown #149

Closed dimbleby closed 2 years ago

dimbleby commented 2 years ago

Describe the bug

Error when trying to navigate markdown file using text objects

To Reproduce

markdown file like this

# Heading

Text

configuration like this:

      ...
      goto_previous_end = {
        ['[]'] = '@class.outer',
      },

Hit [], error out:

E5108: Error executing lua ...r/start/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua:389: Column value outside range
stack traceback:
        [C]: in function 'nvim_win_set_cursor'
        ...r/start/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua:389: in function 'goto_node'
        ...ter-textobjects/lua/nvim-treesitter/textobjects/move.lua:47: in function 'move'
        ...ter-textobjects/lua/nvim-treesitter/textobjects/move.lua:60: in function 'goto_previous_end'
        [string ":lua"]:1: in main chunk

Expected behavior

Cursor is moved, no error.

Output of :checkhealth nvim_treesitter

nvim_treesitter: health#nvim_treesitter#check ======================================================================== ## Installation - OK: `tree-sitter` found 0.20.1 (062421dece3315bd6f228ad6d468cba083d0a2d5) (parser generator, only needed for :TSInstallFromGrammar) - OK: `node` found v15.14.0 (only needed for :TSInstallFromGrammar) - OK: `git` executable found. - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" } Version: cc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0 - OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI. ## Parser/Features H L F I J - json ✓ ✓ ✓ ✓ .- - vim ✓ ✓ . . ✓- - haskell ✓ . . . ✓- - supercollider ✓ ✓ ✓ ✓ ✓- - scala ✓ . ✓ . ✓- - go ✓ ✓ ✓ ✓ ✓- - prisma ✓ . . . .- - tsx ✓ ✓ ✓ ✓ ✓- - typescript ✓ ✓ ✓ ✓ ✓- - r ✓ ✓ . . .- - c_sharp ✓ ✓ ✓ . ✓- - swift . . . . .- - cmake ✓ . ✓ . .- - ocamllex ✓ . . . ✓- - zig ✓ . ✓ ✓ ✓- - ocaml_interface✓ ✓ ✓ . ✓- - ocaml ✓ ✓ ✓ . ✓- - bibtex ✓ . ✓ ✓ .- - heex ✓ . ✓ ✓ ✓- - make ✓ . . . ✓- - surface ✓ . ✓ ✓ ✓- - elixir ✓ ✓ ✓ ✓ ✓- - erlang . . . . .- - svelte ✓ . ✓ ✓ ✓- - scss ✓ . . ✓ .- - dockerfile ✓ . . . ✓- - devicetree ✓ ✓ ✓ ✓ ✓- - glsl ✓ ✓ ✓ ✓ ✓- - julia ✓ ✓ ✓ ✓ ✓- - d ✓ . ✓ ✓ ✓- - cuda ✓ ✓ ✓ ✓ ✓- - kotlin ✓ . . . ✓- - cpp ✓ ✓ ✓ ✓ ✓- - commonlisp ✓ ✓ ✓ . .- - php ✓ ✓ ✓ ✓ ✓- - clojure ✓ ✓ ✓ . ✓- - sparql ✓ ✓ ✓ ✓ ✓- - fish ✓ ✓ ✓ ✓ ✓- - bash ✓ ✓ ✓ . ✓- - jsdoc ✓ . . . .- - javascript ✓ ✓ ✓ ✓ ✓- - perl ✓ . . . .- - comment ✓ . . . .- - ruby ✓ ✓ ✓ ✓ ✓- - graphql ✓ . . ✓ ✓- - verilog ✓ ✓ ✓ . ✓- - ql ✓ ✓ . ✓ ✓- - teal ✓ ✓ ✓ ✓ ✓- - python ✓ ✓ ✓ ✓ ✓- - fennel ✓ ✓ . . ✓- - rst ✓ ✓ . . ✓- - regex ✓ . . . .- - dart ✓ ✓ . ✓ ✓- - fusion ✓ ✓ . . .- - nix ✓ ✓ ✓ . ✓- - rust ✓ ✓ ✓ ✓ ✓- - yang ✓ . ✓ . .- - http ✓ . . . ✓- - llvm ✓ . . . .- - yaml ✓ ✓ ✓ ✓ ✓- - hjson ✓ ✓ ✓ ✓ ✓- - elm ✓ . . . ✓- - pioasm ✓ . . . ✓- - json5 ✓ . . . ✓- - fortran ✓ . ✓ ✓ .- - jsonc ✓ ✓ ✓ ✓ ✓- - latex ✓ . ✓ . ✓- - vue ✓ . ✓ ✓ ✓- - beancount ✓ . ✓ . .- - pug ✓ . . . ✓- - turtle ✓ ✓ ✓ ✓ ✓- - godot_resource ✓ ✓ ✓ . .- - gdscript ✓ ✓ . . ✓- - query ✓ ✓ ✓ ✓ ✓- - ledger ✓ . ✓ ✓ ✓- - java ✓ ✓ . ✓ ✓- - glimmer ✓ . . . .- - lua ✓ ✓ ✓ ✓ ✓- - c ✓ ✓ ✓ ✓ ✓- - toml ✓ ✓ ✓ ✓ ✓- - html ✓ ✓ ✓ ✓ ✓- - dot ✓ . . . ✓- - css ✓ . ✓ ✓ ✓- - tlaplus ✓ . ✓ . ✓- - hcl ✓ . ✓ ✓ ✓- - markdown ✓ . . . ✓- - gomod ✓ . . . ✓- - gowork ✓ . . . ✓- 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

NVIM v0.7.0-dev+751-g67bb01ae2
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/dch/neovim/build/config -I/home/dch/neovim/src -I/home/dch/neovim/.deps/usr/include -I/usr/include -I/home/dch/neovim/build/src/nvim/auto -I/home/dch/neovim/build/include
Compiled by dch@DESKTOP-NA4O3IV

Features: +acl +iconv +tui
See ":help feature-compile"

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

Run :checkhealth for more info
stsewd commented 2 years ago

Hmm. looks like nvim_win_set_cursor no longer works with [1, -1], the docs say -1 means the last index, or maybe it never worked? I'll try with an older version of neovim.

stsewd commented 2 years ago

Nope, it doesn't work on 5.0, so we need to pass the actual position.