ayamir / nvimdots

A well configured and structured Neovim.
BSD 3-Clause "New" or "Revised" License
2.93k stars 466 forks source link

how can i to tabout in string #596

Closed asaning closed 1 year ago

asaning commented 1 year ago

Feature description

image

when the cursor is in the string, i can't use tab to jump out it.

Additional information

No response

Jint-lzxy commented 1 year ago

Since <Tab> has been reserved for other purposes, we set <A-l> and <A-h> as tabkey for tabout.

https://github.com/ayamir/nvimdots/blob/9388a9bc431b7ce77b91ece122886ecc06599026/lua/keymap/editor.lua#L93-L95

asaning commented 1 year ago

image

@Jint-lzxy thx for answer me, but when i use the A-h it will jump to the end of the " not the ].

Jint-lzxy commented 1 year ago

@asaning This is not the way tabout works - tabout understands your code based on the syntax tree returned by treesitter. Since in this case treesitter does not mark that pair of [] as a correct node (it's inside a string literal) and thus tabout does not work.

More info:

eprintln!("[fd error]")

Produces:

source_file [0, 0] - [1, 0]
  macro_invocation [0, 0] - [0, 23]
    macro: identifier [0, 0] - [0, 8]
    token_tree [0, 9] - [0, 23]
      string_literal [0, 10] - [0, 22]
           ^^^ no information for that pair of square brackets

Please use the builtin command f] instead.

                            *f*
f{char}         To [count]'th occurrence of {char} to the right.  The
            cursor is placed on {char} |inclusive|.
            {char} can be entered as a digraph |digraph-arg|.
            When 'encoding' is set to Unicode, composing
            characters may be used, see |utf-8-char-arg|.
            |:lmap| mappings apply to {char}.  The CTRL-^ command
            in Insert mode can be used to switch this on/off
            |i_CTRL-^|.