Commit graph

58 commits

Author SHA1 Message Date
Pham Huy Hoang
d2b78324f2 fix indent/fold memleak 2023-05-16 13:25:02 +02:00
Kiyoon Kim
df968afd9d goto_node select last character when in operator-pending mode 2023-02-25 02:26:31 -05:00
Nat Williams
22de3532cc also pass the node to the statusline transform fn 2023-02-24 14:55:30 -08:00
Amaan Qureshi
853b1ab39a style: fill in missing code docs wherever applicable 2023-02-24 01:08:23 -08:00
kylo252
d1d00f46ce refactor(utils): clean up deprecated code
use `vim.treesitter.is_in_node_range()` directly
2023-02-17 16:54:02 -08:00
Kiyoon Kim
2c2430d42f deprecate get_node_range and is_in_node_range 2023-02-12 02:38:17 -08:00
haoxian
dd600cf1c2 fix: incremental_selection error
if some empty lines in the end of file,
would throw error messages when incremental_selection to the whole file.
2023-02-11 15:37:53 -08:00
Kiyoon Kim
dd94001fcb fix artefact in change mode 2023-01-28 23:52:12 +01:00
coinator
ef0cd56e48
Remove update_selection side-effects (#4114) 2023-01-07 14:23:00 +01:00
Michael Lan
0922634d37
fix(utils): swap_nodes calculates correct char_delta (#4110)
* fix(utils): swap_nodes calculates correct char_delta

The char_delta is not calculated correctly right now when there are two
treesitter nodes being swapped, one directly following the other. This
is rare but can happen for example when attempting to swap "print" and
"(1)" in "print(1)". In this case an incorrect char_delta is calculated
because of a bug in range comparison.

* test(swap_nodes): check cursor

* add a regression test (for multiline node swap)
* add a test with adjacent swaps that fails when char_delta is not
  calculated correctly

* test(swap_nodes): check text content after swap

* test: note language for parser

* fix tests

* use same not equal for table comparison
2023-01-07 02:53:12 +01:00
Philip Gaudreau
4bcd3a3cc3 Fix update_selection 2022-12-25 14:58:57 +01:00
ray-x
a9a6493b1e nil check for lines 2022-08-06 05:38:42 -07:00
Axel Dahlberg
0d7fab0c33
feat(ts_utils): allow starting selection after last character (#3233) 2022-07-29 17:35:29 +02:00
francisco souza
44b7c81002 fix(ts_utils): fix swap_nodes after get_node_text change
After some discussion, it looks like the easiest thing to do for now is
to keep a private copy of get_node_text (just to skip the deprecation
message) and invoke that, until core provides an equivalent function
that can return the node content in a table representing the node
"lines".

Also fixes the statusline by calling the private version for
get_node_text until a change is made in core.
2022-04-21 23:57:35 +02:00
Christian Clason
a8bce851bf fixup: restore old implementation 2022-04-18 18:50:46 +02:00
Stephan Seitz
c3848e713a chore: deprecate ts_utils.get_node_text 2022-04-18 14:17:51 +02:00
Marcus Caisey
6a437db012 remove ignore_child_trees from get_node_at_position 2022-04-16 10:42:18 +02:00
Marcus Caisey
9dff7c2d45 add ignore_injected_langs to get_node_at_cursor 2022-04-16 10:42:18 +02:00
Michael Lan
50cf31065c fix(utils): adjust truncation condition 2022-02-03 08:38:50 +01:00
Christian Clason
ca837f5218 fix(util): pass offset_encoding to apply_text_edits
Offset encoding is a mandatory argument to
`vim.lsp.util.apply_text_edits` since bc722c8a74

Since we are always within a Neovim context, we can just pass `"utf-8"`.
2022-01-15 14:59:24 +01:00
MDeiml
46b9916492 Fix get_node_text 2022-01-08 13:27:25 +01:00
Wil Thomason
35c99feae5 Fix: Account for winnr being nil in calls to get_node_at_cursor 2022-01-04 01:03:22 +01:00
Santos Gallegos
1f303c7f3c goto_node: normalize range for nvim_win_set_cursor
Looks like neovim doesn't accept -1 on nvim_win_set_cursor.
It's listed as an exception on `:h api-indexing`.

Fixes https://github.com/nvim-treesitter/nvim-treesitter-textobjects/issues/149
2021-12-20 15:12:12 +01:00
Fabian David Schmidt
fba03a304e feat: get node at cursor of other win 2021-11-12 20:56:09 +01: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
3aa122edfd Fix incremental selection for nodes that include EOL
From `:h setpos()`

> If "col" is smaller than 1 then 1 is used.

This can be tested with incremental selection on a vim file.

```vim
set title
```
2021-09-19 14:54:45 +02:00
Santos Gallegos
be8f656087
Use stylua for autoformat code (#1480) 2021-07-04 21:12:17 +00:00
Steven Sojka
6863f79118
refactor(all): language tree adaption (#1105) 2021-03-30 08:18:24 -05:00
kiyan
9d57216c0d chore: remove useless code and indent files 2021-02-27 13:36:33 +01:00
echasnovski
079dafa36e Add "v", "V", "<C-v>" as valid options of selection_mode. 2021-02-21 20:25:26 +01:00
echasnovski
a34459213e Add selection_mode argument to ts_utils.update_selection(). 2021-02-21 20:25:26 +01:00
Brian Shu
6856e23171 removed async changedtick 2021-01-08 16:16:33 +01:00
Brian Shu
33d5a03322 async buf_attach 2021-01-08 16:16:33 +01:00
Brian Shu
03fea8494c removed async changedtick 2021-01-07 11:16:16 +01:00
Brian Shu
ec5f1402e2 async buf_attach 2021-01-07 11:16:16 +01:00
Thomas Vigouroux
808765a6c8
fix: update interface following languagetree merge (#687) 2020-11-23 12:46:27 -06:00
kiyan42
1735528db5 Treesitter indent
also fixes the memoize_by_buf_tick function
2020-10-19 21:08:15 +02:00
Stephan Seitz
5948aba886 feat(refactor.navigation): add navigation.goto_{next,previous}_usage 2020-08-31 18:56:41 +02:00
Stephan Seitz
32271b26ef Textobjects: set jump before going to adjacent_textobject 2020-08-17 17:45:46 +02:00
Stephan Seitz
5cfa03f2bd Textobjects: add swap feature 2020-08-17 17:44:40 +02:00
Steven Sojka
282e33ad9c fix(definitions): optimize and fix definition highlighting 2020-08-13 07:43:09 -05:00
Thomas Vigouroux
572a4a964b configs: attach on unknown parsers too 2020-07-27 15:18:48 +02:00
Stephan Seitz
16af10999c Fix #206: Use lsp.util.apply_text_edits for smart_rename 2020-07-20 23:24:54 +02:00
Steve Vermeulen
3c0684f7f2 Fixed to use normal! instead of normal 2020-07-20 08:57:59 +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
Thomas Vigouroux
1849f30bb5 fix(ts_utils): be sure to parse to get root
Be sure to call `parser:parser()` to get a tree instead of getting the
tree directly. This will not cost anything is the buffer is freshly
parsed.

Fixes #181
2020-07-16 07:58:39 +02:00
Stephan Seitz
b480d25155 feat(textobjects): Add start to include preceding things like documentation 2020-07-15 20:12:52 +02:00
Stephan Seitz
69cabc69be Add textobjects module 2020-07-14 22:34:43 +02:00
Stephan Seitz
8dfe085c41 Add ts_utils.highlight_node 2020-07-13 22:26:17 +02:00
Steven Sojka
26b3b3311e fix(refactor): highlight def perf issue fix 2020-07-08 09:55:12 +02:00