Commit graph

47 commits

Author SHA1 Message Date
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
Stephan Seitz
5642507f6a Make luacheck happy 2020-07-05 19:21:06 +02:00
Steven Sojka
d73500eaa6 refactor(refactor): use higher local apis and some cleanup 2020-06-30 08:21:01 +02:00
Steven Sojka
6f8e4c97a4 feat(refactor): add definition navigation module 2020-06-30 08:21:01 +02:00
Steven Sojka
64838e51c0 feat(refactor): add smart rename module 2020-06-30 08:21:01 +02:00
Steven Sojka
058e8d2296 feat(refactor): highlight usages module 2020-06-30 08:21:01 +02:00
kiyan42
cf72524b2f add winnr to get_node_at_cursor 2020-06-19 14:13:23 +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
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