Commit graph

55 commits

Author SHA1 Message Date
Christian Clason
a838a35b2b chore: placate luacheck 2022-03-26 10:20:26 +01:00
Munif Tanjim
85140a7a47 feat(indent): use native Query:iter_captures 2022-01-21 10:51:51 +01:00
Santos Gallegos
ddcfc01979
Query: allow to pass a list to get_capture_matches (#1693) 2021-08-22 20:22:20 -05:00
Santos Gallegos
be8f656087
Use stylua for autoformat code (#1480) 2021-07-04 21:12:17 +00:00
Folke Lemaitre
917ae3da7c fix: check if invalidate_query_cache[lang] is set before invalidating 2021-06-29 20:06:16 +02:00
Folke Lemaitre
90024c24aa perf: cache has_query_files: fixes TS slowness 2021-06-28 16:17:23 +02:00
Santos Gallegos
c1f61d4ca1
Improve check-queries (#1253)
- Add checks for injections.
- Allow queries that start with [A-Z] for highlights only.
- Don't stop on the first error, finish checking all queries.
2021-05-31 17:03:27 +00:00
Stephan Seitz
4214646953 feat: Add TSEditQuery 2021-04-14 16:23:21 +02:00
Santos Gallegos
5f53f55371
Fix usage of string.sub (#1164)
From https://www.lua.org/pil/20.html

> The call string.sub(s,i,j) extracts a piece of the string s, from the i-th to the j-th character inclusive.

This was breaking textobjects movement.
2021-04-07 19:23:14 -05:00
Stephan Seitz
826683b1bf Fix: allow empty path in utils.get_at_path 2021-04-06 21:48:25 +02:00
Steven Sojka
6863f79118
refactor(all): language tree adaption (#1105) 2021-03-30 08:18:24 -05:00
Stephan Seitz
1375cc5c1f fix(checkhealth): display error messages of failed queries 2021-03-23 21:25:37 +01:00
kiyan
9d57216c0d chore: remove useless code and indent files 2021-02-27 13:36:33 +01:00
Stephan Seitz
db0ccfe9ab fix: remove debug print on query cache invalidation
The message does not even provide any context where it's coming from
and what it is exactly doing and has to be acknowledged when printed in
conjunction with the "wrote xxx bytes message"
2021-02-11 20:42:51 +01:00
oberblastmeister
64ffea57f4
feat(query): add cache for get_query (#879)
* added cached to get_query

* added reload function

* fixed message

* added autocommand to reload cache on bufwrite for query file

* pass filename to autocommand v:lua fn

* removed comment

* added metatable

* fixed loop

* Update lua/nvim-treesitter/query.lua

Co-authored-by: Thomas Vigouroux <tomvig38@gmail.com>

* Update lua/nvim-treesitter/query.lua

Co-authored-by: Thomas Vigouroux <tomvig38@gmail.com>

* added do ... end to local query_cache

* made line shorter

Co-authored-by: Thomas Vigouroux <tomvig38@gmail.com>
2021-01-28 19:56:55 +01:00
Thomas Vigouroux
808765a6c8
fix: update interface following languagetree merge (#687) 2020-11-23 12:46:27 -06:00
Stephan Seitz
aa4c3e83e3 Add virtual range for creating node-like objects from multiple nodes 2020-10-26 18:22:19 +01:00
Stephan Seitz
4da47d6dea Remove textobjects from built_in_query_groups 2020-10-19 22:36:38 +02:00
kiyan42
1735528db5 Treesitter indent
also fixes the memoize_by_buf_tick function
2020-10-19 21:08:15 +02:00
Stephan Seitz
994e42fac4 Fix: avoid overwriting tables in insert_to_path
The following query will result in matches with only one node though it
requires two nodes to be a match.

```scheme
(function_definition
 (comment) @function.inner.start
  body: (block) @function.inner)
```
Why? First `insert_to_path` is called for `@function.inner.start` which
will result int the following table.

```lua
{ function = { inner = { start { node } } } }
```
`insert_to_path` will overwrite the result
```lua
{ function = { inner = { node  } } }
```

Related #552
2020-10-16 13:48:59 +02:00
Thomas Vigouroux
3b7b4daadb query: remove unnecessary query parsing 2020-10-12 20:04:31 +02:00
Thomas Vigouroux
c055899dc0 feat(queries): modeline mechanism for base langs
This implements https://github.com/neovim/neovim/pull/13059#issuecomment-704414189

This behaves like modelines and remove the use of the base_language map.
Also, this allows to fine-tune what we actually want to include per
query, which is better IMO.
2020-10-11 19:09:22 +02:00
Pau Ruiz Safont
749a8a7f25 feat: add parser for ocaml interface files
The files have the mli extension. The parser grammar uses the name
ocaml_interface, but since vim the underscore has a special meaning
ocamlinterface is used as the filetype.
2020-09-19 13:35:12 +02:00
Santos Gallegos
50991e370b Folds: rename query files to folds.scm to be consistent
We use plural names for all query files except folds.
2020-09-14 18:26:30 +02:00
Stephan Seitz
3c1399b94e Fix #418: iterator function should always return an iterator
Even if it's an empty iterator.
2020-09-08 22:02:11 +02:00
Santos Gallegos
77c2730a62 Improve startup performance 2020-09-08 19:37:32 +02:00
Santos Gallegos
95a7d24180 Queries: merge query_extensions into base_language_map
These two are doing the same currently.
2020-09-08 19:16:54 +02:00
kyazdani42
8d6c40ce24 fix using highlight query extension for every query type 2020-09-07 21:57:56 +02:00
Thomas Vigouroux
419388d887 health: add fold queries to check health 2020-09-01 21:51:17 +02:00
Steven Sojka
3fe8bbcf9c fix(modules): do not reattach if already attached 2020-08-22 06:07:21 -05:00
Steven Sojka
b796f0725d
Merge pull request #305 from theHamsta/textobjects-submodules
Textobjects submodules
2020-08-17 11:39:22 -05:00
kiyan42
20e448882e some refacto, doc fixes and jsx queries
- compute query language extensions *after* default ones
(jsx after javascript)
- remove outdated ts_utils functions from docs
- add better regex detection to javascript
- javascriptreact to use javascript queries
- add javascript.jsx to javascript queries
- write jsx.scm hl file
2020-08-17 17:48:33 +02:00
Stephan Seitz
f6681c230f chore(textobject): use query.find_best_match to find next/previous textobject 2020-08-17 17:44:40 +02:00
Rafał Camlet
83210fa412 fix: check 'after' against third directory 2020-08-15 22:03:33 +02:00
Steven Sojka
994baf4539
Merge pull request #291 from vigoux/post-upstream-work
fix: refactor after upstream refactor
2020-08-15 08:22:14 -05:00
Thomas Vigouroux
26c8d1eac0 feat: intuitive runtime queries
Starting now, runtime queries will be sourced in this order :

- Queries that are not in any `after` folder, will serve as a base, with
each occurence overwriting the others (that is, .config/nvim/queries has
the highest priority)
- Queries within the `after` directory will be sourced one after the
other.

The rationale is that this reminds all the `.vim` files (ftplugin) for
example, and this allows both to experiment and to override queries
easily.
2020-08-14 16:42:53 +02:00
Thomas Vigouroux
98b7515014 fix: refactor after upstream refactor 2020-08-14 15:00:13 +02:00
Steven Sojka
282e33ad9c fix(definitions): optimize and fix definition highlighting 2020-08-13 07:43:09 -05:00
Steven Sojka
4982d05ec7 fix(queries): don't load queries on startup 2020-08-11 09:50:30 +02:00
Stephan Seitz
5462fc92cb Add predicates module 2020-07-27 10:15:33 +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
31d1f068fd checkhealth for all query groups 2020-07-15 16:28:48 +02:00
Stephan Seitz
69cabc69be Add textobjects module 2020-07-14 22:34:43 +02:00
kiyan42
2bb6374c34 Define multiple query for a language
Allows using another query file for a language, or use a query file
from another language
2020-06-30 08:38:31 +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
Thomas Vigouroux
3000b878fe fix: separate queries with newlines 2020-06-21 23:06:13 +02:00
kiyan42
df17a48c85 refactor: parser list and lang->ft/ft->lang
- move parser list in `parsers.lua`
- most `ft` variable where changed to `lang`, `ft` is only used on
  autocmd binding, and lang is used for everything else. Functions have
  been defined to make the switch between `ft` and `lang`
2020-06-20 12:31:52 +02:00
Stephan Seitz
0671c0c6a2 Fixup: Introduce base languages for queries
Use same argument for nvim_get_runtime_file for base language
2020-06-15 12:09:51 +02:00
Stephan Seitz
df06026110 Introduce base languages for queries
Some treesitter grammars just extend another treesitter grammar.
This enables us to use the C queries also for C++.
We only need to put additional queries in the C++ files.
2020-06-15 11:51:28 +02:00