Commit Graph

74 Commits

Author SHA1 Message Date
Thomas Vandal
42c9f7152b feat(treesitter): support query table in treesitter-textobjects mappings (#6736)
## Description

<!-- Describe the big picture of your changes to communicate to the
maintainers
  why we should accept this pull request. -->

`treesitter-textobjects` mappings accept a table query (for the "move"
mappings, at least, I haven't checked the others). Currently, in
LazyVim, using a table causes an error due to the assumption that
`query` is a string in the `config` function that creates the keymap
description. This PR adds a simple loop to gather the queries from a
table and join them with "or" in the description.

Here is an example config and the resulting error. Everything works as
expected with the PR and string (single) queries still behave as
expected.

```lua
  {
    "nvim-treesitter/nvim-treesitter-textobjects",
    opts = {
      move = {
        keys = {
          goto_next_start = { ["]j"] = { "@function.outer", "@class.outer" } },
          goto_next_end = { ["]J"] = { "@function.outer", "@class.outer" } },
          goto_previous_start = { ["[j"] = { "@function.outer", "@class.outer" } },
          goto_previous_end = { ["[J"] = { "@function.outer", "@class.outer" } },
        },
      },
    },
  }
```

```lua
Failed to run `config` for nvim-treesitter-textobjects

...vim-local/opt/LazyVim/lua/lazyvim/plugins/treesitter.lua:174: attempt to call method 'gsub' (a nil value)

# stacktrace:
  - repos/nvim-local/opt/LazyVim/lua/lazyvim/plugins/treesitter.lua:174
  - vim/shared.lua:0 _in_ **tbl_map**
  - repos/nvim-local/opt/LazyVim/lua/lazyvim/plugins/treesitter.lua:197 _in_ **config**
```



## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
2025-11-03 07:51:07 +01:00
Folke Lemaitre
3ffb471c18 fix(treesitter): added buf to treesitter start just to be sure 2025-10-20 14:34:01 +02:00
Folke Lemaitre
92a7728732 fix(treesitter): attach textobject keymaps to existing buffers on load. Closes #6642. Closes #6639 2025-10-18 15:26:41 +02:00
Folke Lemaitre
62ce8a23d8 fix(treesitter): reload lazyvim.tresitter.util to prevent issues with stale modules when upgrading 2025-10-18 06:38:45 +02:00
Folke Lemaitre
5effc77185 fix(treesitter): better check on windows if microsoft build tools is installed 2025-10-15 19:43:44 +02:00
Folke Lemaitre
413b9d5fa9 feat(treesitter): better health checks for treesitter requirements 2025-10-15 08:38:37 +02:00
Folke Lemaitre
2a1f3c3701 feat(treesitter): on windows, use gcc if available and cl.exe is not available for building parsers 2025-10-15 08:38:37 +02:00
Folke Lemaitre
e8c5fa7eae fix(treesiter): check that disable options are tables 2025-10-10 20:57:44 +02:00
Folke Lemaitre
0e8069c78e feat(treesitter): added support for disable langs to indent/highlight/folds. Closes #6608 2025-10-10 06:45:12 +02:00
Folke Lemaitre
5985ca0cf1 fix(treesitter): create buffer-local textobjects keymaps only when available. Closes #6508 2025-09-25 07:35:59 +02:00
Folke Lemaitre
89ff1fd600 feat(treesitter): show an error if the user tries to set a custom treesitter compiler 2025-09-21 11:04:25 +02:00
Folke Lemaitre
5ce7cd650a fix(treesitter): check if queries for indent/fold exists before enabling it. Fixes #6474 2025-09-19 19:58:28 +02:00
Folke Lemaitre
ccbaf55c2f feat(options): don't overwrite indentexpr/foldexpr/foldmethod when set by plugins. Fixes #6464 2025-09-18 22:19:03 +02:00
Folke Lemaitre
725d048e00 feat(treesitter): automatically install and use mason's tree-sitter-cli if not installed on system 2025-09-18 09:49:54 +02:00
Folke Lemaitre
b93303d233 feat(treesitter): refactored setting up treesitter indent/highlight/folds 2025-09-18 09:49:54 +02:00
Folke Lemaitre
c28f599d4f fix(treesitter): properly update installedd languages after setup 2025-09-17 23:39:19 +02:00
Folke Lemaitre
a6b38de763 fix(treesitter): indentexpr/foldexpr now work as intended and override ftplugin settings. Fixes #6447 2025-09-17 22:46:14 +02:00
Folke Lemaitre
2d56d3b37c fix(treesitter): TS update during inital build 2025-09-17 16:54:36 +02:00
Folke Lemaitre
72e1ee5b0d refactor(treesitter): cleanup 2025-09-17 15:33:37 +02:00
Alexey Svirshchevskiy
014b5bf6ac docs(treesitter): fix checkhealth command (#6433) 2025-09-17 10:40:37 +02:00
Folke Lemaitre
e9344e5319 docs: better error and ref to checkhealth for nvim-treesitter main 2025-09-17 10:10:34 +02:00
Folke Lemaitre
5eac460c09 feat(treesitter)!: migrate to nvim-treesitter **main** branch 2025-09-17 09:52:44 +02:00
Folke Lemaitre
78cf0320bf feat(keymaps): dynamic which-key icons/descriptions for toggles (#4050)
## Description

<!-- Describe the big picture of your changes to communicate to the
maintainers
  why we should accept this pull request. -->

## Related Issue(s)

- [ ] Closes #4025

## Screenshots


![image](https://github.com/user-attachments/assets/8453c23c-d560-490c-9f96-a22ea88f45fd)

## Checklist

- [ ] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
2024-07-15 15:47:44 +02:00
Folke Lemaitre
18c7731281 feat(treesitter-textobjects): added ]a and [a to move between parameters 2024-06-16 19:18:32 +02:00
Folke Lemaitre
ab41ff551b refactor: use lazy's new opts_extend functionality for treesitter and mason 2024-06-07 09:03:59 +02:00
Amaan Qureshi
0a2f40c2fb feat(treesitter): add printf (#2450)
```c
printf("%s\n", "Finally!");
```
2024-06-06 12:42:09 +02:00
Folke Lemaitre
fe552853f5 fix(treesitter): refactored treesitter code and fixed nvim-treesitter-textobjects 2024-05-18 21:53:26 +02:00
Folke Lemaitre
03704e2299 feat(ui)!: moved treesitter-context to an extra. No longer a core plugin 2024-05-16 21:25:51 +02:00
Folke Lemaitre
b29d169afb perf(treesitter): load treesitter early during startup when opening a file from the cmdline 2024-05-14 21:41:56 +02:00
Folke Lemaitre
8301096c31 perf(treesitter): dont let nvim-treesitter-textobjects stall loading treesitter 2024-05-14 21:36:43 +02:00
Kevin Traver
eb9f9a8862 fix(keymaps): update all keymap descriptions to be Title Case (#2844) 2024-03-27 08:56:44 +01:00
Folke Lemaitre
7a5dbeae75 feat: use LazyVim everywhere instead of require("lazyvim.util") 2024-03-22 09:15:09 +01:00
Frederik Buchlák
ddbba85408 chore(treesitter.lua): fix typo (#2026)
* fix typo

* fix typo
2024-03-07 11:48:37 +01:00
Amaan Qureshi
1b0b899ab3 feat(treesitter): add xml to ensure_installed (#1962) 2024-03-07 11:47:45 +01:00
Folke Lemaitre
1e1b68d633 fix(treesitter): make treesitter queries available at startup. See #1816 Fixes #1858 2023-10-25 15:40:25 +02:00
Folke Lemaitre
82da2440e4 fix(nvim-ts-autotag): make it actually work :) 2023-10-19 19:54:36 +02:00
Folke Lemaitre
0ac8f6fb3b fix(treesitter-context): set default max_lines=3 2023-10-19 07:52:47 +02:00
Kevin Traver
5e1a86d3b2 feat(toggle): add keymap to toggle treesitter context (#1711)
* feat: add keymap to toggle treesitter context

* fix: get correct enabled state

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
2023-10-14 14:40:25 +02:00
Folke Lemaitre
7b2c317407 feat(treesitter): add nvim-treesitter-context by default 2023-10-12 11:48:02 +02:00
Folke Lemaitre
cb7f5aca7a feat(treesitter): install nvim-ts-autotag by default 2023-10-12 11:48:02 +02:00
Folke Lemaitre
599798a366 fix(treesitter): typo with commands 2023-10-10 11:07:58 +02:00
Folke Lemaitre
88d465c3ef fix(hypr): automatically update/install hypr treesitter parser when needed 2023-10-10 07:51:02 +02:00
Folke Lemaitre
e11a3cbe80 fix(config): trigger LazyFile additionally on BufWritePre for saving unnamed files 2023-10-08 15:17:50 +02:00
Folke Lemaitre
c9bbb922e5 feat(treesitter): add diff, jsonc and yaml by default 2023-10-08 12:56:27 +02:00
Folke Lemaitre
1935486ff1 fix(treesitter-textobjects): use normal ]c,]C,[c,[C when in diff-mode instead of goto class. Fixes #1610 2023-10-07 15:06:13 +02:00
Folke Lemaitre
86de423ef0 fix(treesitter): dont enable ]c, [c, ... in diff-mode 2023-10-04 21:00:32 +02:00
Folke Lemaitre
936d74bb61 perf: added support for LazyFile event that properly loads file based plugins without blocking the ui 2023-10-04 10:45:10 +02:00
Folke Lemaitre
0e66ef8393 feat(treesitter): added ]f, [f, ]F, [F, ]c, ]C, [c, [C for treesitter-textobjects 2023-10-04 00:21:47 +02:00
Võ Quang Chiến
566049aa4a feat(treesitter): add jsdoc to ensure_installed (#1252)
better highlighting for jsdoc comment
2023-07-30 11:10:45 +02:00
Tom MacWright
6323b419fd docs: Add more documentation (#1174) 2023-07-20 23:16:13 +02:00