Commit Graph

133 Commits

Author SHA1 Message Date
c2a211b8e3 docs: make Lua docstrings consistent #15255
The official developer documentation in in :h dev-lua-doc specifies to
use "--@" for special/magic tokens. However, this format is not
consistent with EmmyLua notation (used by some Lua language servers) nor
with the C version of the magic docstring tokens which use three comment
characters.

Further, the code base is currently split between usage of "--@",
"---@", and "--- @". In an effort to remain consistent, change all Lua
magic tokens to use "---@" and update the developer documentation
accordingly.
2021-08-22 13:55:28 -07:00
5c42e2a87f docs(ts): add documentation for listing fns 2021-07-25 20:52:05 +02:00
b2a9afef6d treesitter: add query.list_directives 2021-07-24 20:57:45 +02:00
7c95697026 treesitter: add predicate "any-of?" (#14344)
For the case of Clojure and other Lisp syntax highlighting, it is
necessary to create huge regexps consisting of hundreds of symbols with
the pipe (|) character. To make things more difficult, these Lisp
symbols sometimes consists of special characters that are themselves
part of special regexp characters like '*'. In addition to being
difficult to maintain, it's performance is suboptimal.

This patch introduces a new predicate to perform 'source' matching in
amortized constant time. This is accomplished by compiling a hash table
on the first use.
2021-05-14 17:41:20 +02:00
5c9b4948d4 treesitter: do not escape in match? (#14382) 2021-05-11 11:52:47 +02:00
3fc71ea228 Merge pull request #14418 from DerekStride/treesitter-set-directive
[RDY] tree-sitter ensure there is a nested table allocated for `#set!`
2021-05-03 21:41:39 +02:00
27da5511a0 docs: Treesitter (#13260)
* doc & fixes: Generate treesitter docs

* fixup to treesitter-core

* docs(treesitter): fix docs for most functions

Co-authored-by: Thomas Vigouroux <tomvig38@gmail.com>
2021-05-01 08:19:48 -04:00
44d4526e18 Ensure there is a nested table allocated for #set!
Fixes the following bug:
```
test/functional/helpers.lua:107: Error executing lua:
vim/treesitter/query.lua:256: attempt to index a nil value
```
2021-04-27 12:29:37 -02:30
e652b2987a Merge pull request #14046 from nvim-treesitter/feature/language-tree-directive-config
feat(treesitter): allow injections to be configured through directives
2021-04-14 05:36:05 +02:00
8bea39f372 feat(treesitter): allow injections to be configured through directives 2021-04-02 12:48:16 -05:00
43eb22d4c9 Fix #14192: Handle IO errors and close files in query.lua 2021-04-02 16:21:49 +02:00
04fb94cd80 ts: Add per-language query overriding 2021-03-30 08:25:11 -04:00
2a794b8f5d fix(treesitter): dedupe runtime file list 2021-03-23 12:58:27 -05:00
947f9a04d4 treesitter: small fixes
Mostly typos I found while reading the code.
2021-02-07 01:27:38 -05:00
9bed991cfb treesitter: Fix linter warning and add helper function to remove duplicated logic
This function returns the start and stop value if set else the node's range is used
When the node's range is used, the stop is incremented by 1 to make the search inclusive
2021-01-18 08:17:12 +01:00
a2818819bb treesitter: default start and end row when omitted
Add support for default start and end row when omitted in the
query:iter_captures and query:iter_matches functions.

When the start and end row values are omitted, the values of the given
node is used. The end row value is incremented by 1 to include the node end
row in the match.

Updated tests and docs accordingly.
2021-01-15 21:44:40 +01:00
885c2f7281 treesitter: simplify query reading logic
Only the plugin/package manager should "manage" after/. Consumers of
nvim_get_runtime_file() should not need to special case it (if your plugin
manager is broken then fix it instead).

Don't use vim.fn.readfile(). Lua can already read files. It is even
better at it than vim script.

expose M.get_query_files(). Listing the queries is essential for user
config debug, and let plugins do fun things with it.
Abstraction-by-obscurity is not useful (plugins can just cargo cult copy
the code anyway, better with public entry points).
2021-01-04 11:06:02 +01:00
929f194145 feat(treesitter): add offset predicate for language injection
refactor(treesitter): add directives to queries
2020-12-15 07:03:47 -06:00
0276c8addd tree-sitter: Put base languages first in queries
This reverts the handling of base languages to the old way how
nvim-treesitter handled them. When a language extends a base language
it usually wants to be able to overwrite queries.

Related: https://github.com/nvim-treesitter/nvim-treesitter/issues/633
2020-11-08 13:55:42 +01:00
e27af09052 fix(treesitter): account for no main query file 2020-10-28 07:34:11 -05:00
d3f544002c treesitter: runtime queries
Runtime queries just work like ftplugins, that is:

- Queries in the `after` directory are sourced _after_ the "base" query
- Otherwise, the last define query takes precedence.

Queries can be found in the `queries` directory.

Update runtime/lua/vim/treesitter/query.lua

Co-authored-by: Paul Burlumi <paul@burlumi.com>
2020-10-11 21:18:28 +02:00
3c5141d2cf treesitter: add string parser (#13008) 2020-09-30 09:32:43 -04:00
9c929e7d23 lint: just bit twiddlin' 2020-09-06 11:25:23 +02:00
20c1526552 treesitter: simplify match_preds 2020-09-06 10:30:39 +02:00
2d6437f5fb treesitter: use lua-match? instead of match? 2020-09-06 10:29:47 +02:00
3fd6e3b923 treesitter: allow to list supported predicates 2020-09-04 15:24:23 +02:00
b058c671d2 treesitter: avoid escaping complete query strings
Escape "\\" only for `vim-match?` not for `match?`
Fixes #12595
2020-08-31 17:24:38 +02:00
6a8dcfab4b treesitter: allow to force predicate addition 2020-08-13 20:40:40 +02:00
9564803d1a treesitter: add predicate negation 2020-08-13 20:30:15 +02:00
d7b12e58df treesitter: add and test vim-match? predicate 2020-08-13 20:30:15 +02:00
58e37d7df8 treesitter: add contains? predicate 2020-08-13 20:30:15 +02:00
18c0e77528 treesitter(docs): update and refresh docs 2020-08-13 20:30:15 +02:00
613068071e treesitter: refactor and use lua regexes 2020-08-13 20:30:15 +02:00