diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-09-08 11:17:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-08 11:17:29 +0200 |
commit | 893b659e88c61a8c3ce5b140ab475cd67e0ca6bc (patch) | |
tree | 700b6e399fd0e3edc353146954b2bc7cd7a07410 | |
parent | 0405594399741babd6d935d581eac2584b289f92 (diff) | |
download | rneovim-893b659e88c61a8c3ce5b140ab475cd67e0ca6bc.tar.gz rneovim-893b659e88c61a8c3ce5b140ab475cd67e0ca6bc.tar.bz2 rneovim-893b659e88c61a8c3ce5b140ab475cd67e0ca6bc.zip |
fix(treesitter): use the right loading order for base queries (#20117)
Use the first, not last, query for a language on runtimepath. Typically,
this implies that a user query will override a site plugin query, which
will override a bundled runtime query.
-rw-r--r-- | runtime/doc/treesitter.txt | 5 | ||||
-rw-r--r-- | runtime/lua/vim/treesitter/query.lua | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 9f688da963..9d163aa072 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -187,6 +187,11 @@ Note: The predicates listed in the web page above differ from those Neovim supports. See |lua-treesitter-predicates| for a complete list of predicates supported by Neovim. +By default, the first query on `runtimepath` is used (which usually implies +that user config takes precedence over plugins, which take precedence over +queries bundled with Neovim). If a query should extend other queries instead +of replacing them, use the `; extends` modeline below. + A `query` consists of one or more patterns. A `pattern` is defined over node types in the syntax tree. A `match` corresponds to specific elements of the syntax tree which match a pattern. Patterns may optionally define captures diff --git a/runtime/lua/vim/treesitter/query.lua b/runtime/lua/vim/treesitter/query.lua index be5b24fd95..2f6227af8e 100644 --- a/runtime/lua/vim/treesitter/query.lua +++ b/runtime/lua/vim/treesitter/query.lua @@ -97,7 +97,7 @@ function M.get_query_files(lang, query_name, is_included) if extension then table.insert(extensions, filename) - else + elseif base_query == nil then base_query = filename end io.close(file) |