Commit graph

23 commits

Author SHA1 Message Date
Amaan Qureshi
853b1ab39a style: fill in missing code docs wherever applicable 2023-02-24 01:08:23 -08:00
Stephan Seitz
507527711f feat: allow to set keymappings to false
Fixes #3954
2022-12-15 14:55:15 +01:00
itepechi / いてぺち
abb8b5756a
fix: node_incremental for incremental selection jumping around (#3257) 2022-08-02 12:40:25 +00:00
Stephan Seitz
2282461416 docs: add descriptions to incremental_selection keymaps 2022-07-31 17:33:41 +02:00
Santos Gallegos
e4c56e691a
Use vim-range style (1-index based) when possible (#1841)
https://github.com/nvim-treesitter/nvim-treesitter/pull/1829
half fixed incremental selection for the vim parser,
but other bugs still remain (infinite selection and skip selecting the
root node).

Problems can be replicated with these two files:

(missing selecting the root node)

```vim
set scrolloff=7
set scrolloff=7
```

(infinite loop)

```vim
set scrolloff=7
```

The main problem is that we try to map
the current selection range to a TS range,
but the TS range of a node could include the EOL/EOL marks
so it's impossible to know when to change the vim range
to match the TS range, is more easy to transform the
TS range to a vim range and do the comparison.
2021-09-24 17:46:44 -05:00
Santos Gallegos
be8f656087
Use stylua for autoformat code (#1480) 2021-07-04 21:12:17 +00:00
Thomas Vigouroux
afd5d11519 feat(incremental_selection): don't require locals 2021-04-22 18:12:03 +02:00
Santos Gallegos
79040e539d
Fix incremental selection (#1135)
So, there are two problems:

- There was an infinite loop when inc selection was initiated
  from an injection.
- The comparison was wrong when the whole file was selected,
  this is because ts matches the EOF.
  This is an extra line with one char (EOF).

I put a workaround to try to select the node from the main
tree, but we should try to select the node from the parent tree of the
injection, but I wasn't able to get the parent tree from the node.
2021-04-05 20:02:58 -05:00
Thomas Vigouroux
808765a6c8
fix: update interface following languagetree merge (#687) 2020-11-23 12:46:27 -06:00
Thomas Vigouroux
6eca8d2f38 parser: only use parse to get a tree
This will avoid using internal data.
2020-11-03 21:16:51 +01:00
Santos Gallegos
9c456edb3a Incremental selection: fix skipping some nodes
The range from ts nodes are a little different than
neovim's nodes. They start at 0 and the end is exclusive.
For example, a nvim range (1, 3, 2, 4) is the equivalent to the ts
range (0, 2, 1, 4).

Since we may hit parent nodes that have the same range as its child,
we skip those till we find one that actually changes the selection
(since this is the relevant part for the user).

Fixes https://github.com/nvim-treesitter/nvim-treesitter/issues/232
2020-09-07 18:24:55 +02:00
evakuator
92c18c8efa use xmap in detach 2020-09-01 20:50:31 +02:00
evakuator
c5d5e48e0f use xmap instead of vmap in textobjects 2020-09-01 20:50:31 +02:00
Steven Sojka
3fe8bbcf9c fix(modules): do not reattach if already attached 2020-08-22 06:07:21 -05:00
Rafał Camlet
3c7528a294 Add noremap option to mappings 2020-08-06 13:28:53 +02:00
kiyan42
a855538e0a fix decremental selection 2020-08-02 20:14:34 +02:00
Stephan Seitz
8cf2dc7f9a Refactor locals.lua:
- shared query group stuff -> query.lua
- local-specific stuff from ts_utils -> locals.lua
2020-07-16 09:34:31 +02:00
Stephan Seitz
69cabc69be Add textobjects module 2020-07-14 22:34:43 +02:00
Stephan Seitz
5642507f6a Make luacheck happy 2020-07-05 19:21:06 +02:00
kiyan42
38af29a912 refacto: remove buf_state
- remove buf_state and related code
- add get_node_at_cursor()
- better incremental selection (code is localized)
2020-06-19 13:45:33 +02:00
Stephan Seitz
3b3a692e2c Remove postspaces and avoid one global 2020-05-22 17:07:28 +02:00
kiyan42
45dcebb15f refacto/feat: better handling of parser updates
features:
- node_movement is moving between scopes.
- add selection initialization from normal mode
- add a decremental selection

improvements:
- attach to buffer to run tree parsing on change
- run state update on CursorMoved
- the buffer state is:
```
{
  cursor_pos = { row=row, col=col },
  current_node = node_under_cursor,
  selection = {
      range = nil, -- activates when starting a selection
      nodes = {} -- filling up when starting an incremental selection
  },
  parser = parser, -- parser for current buffer
}
```
- refacto all the modules reliant on parsing the tree, update the current nodes, get the current nodes...

fixes:
- fix has_parser to look for .so libraries
- fix should select the whole file when selection root in selection
2020-05-12 16:16:48 +02:00
Thomas Vigouroux
39da51bbd1 modules: move textobj to incremental_selection
As suggested in #37, rename the textobj module to incremental_selection.
Also adds a utility function to get the config of a module.
2020-05-02 13:29:40 +02:00
Renamed from lua/nvim-treesitter/textobj.lua (Browse further)