diff options
| author | kiyan42 <yazdani.kiyan@protonmail.com> | 2020-08-17 00:21:34 +0200 |
|---|---|---|
| committer | Stephan Seitz <stephan.lauf@yahoo.de> | 2020-08-17 17:48:33 +0200 |
| commit | 20e448882e1463958d13219d9418de9a4b73480b (patch) | |
| tree | befdbee884f0fea5e1ea80fad3b27abf37a9fbd7 | |
| parent | Merge pull request #316 from TravonteD/fennel (diff) | |
| download | nvim-treesitter-20e448882e1463958d13219d9418de9a4b73480b.tar nvim-treesitter-20e448882e1463958d13219d9418de9a4b73480b.tar.gz nvim-treesitter-20e448882e1463958d13219d9418de9a4b73480b.tar.bz2 nvim-treesitter-20e448882e1463958d13219d9418de9a4b73480b.tar.lz nvim-treesitter-20e448882e1463958d13219d9418de9a4b73480b.tar.xz nvim-treesitter-20e448882e1463958d13219d9418de9a4b73480b.tar.zst nvim-treesitter-20e448882e1463958d13219d9418de9a4b73480b.zip | |
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
| -rw-r--r-- | doc/nvim-treesitter.txt | 27 | ||||
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 3 | ||||
| -rw-r--r-- | lua/nvim-treesitter/query.lua | 9 | ||||
| -rw-r--r-- | queries/javascript/highlights.scm | 3 | ||||
| -rw-r--r-- | queries/javascript/jsx.scm | 9 |
5 files changed, 18 insertions, 33 deletions
diff --git a/doc/nvim-treesitter.txt b/doc/nvim-treesitter.txt index ed992e2d9..5cec85c57 100644 --- a/doc/nvim-treesitter.txt +++ b/doc/nvim-treesitter.txt @@ -228,33 +228,6 @@ Returns the previous node within the same parent. `allow_switch_parent` and `allow_prev_parent` follow the same rule as |ts_utils.get_next_node| but if the node is the first node. - *ts_utils.containing_scope* -containing_scope(node)~ - -Returns the smallest scope containing the node. - - *ts_utils.parent_scope* -parent_scope(node, cursor_pos)~ - -Returns the parent scope of the current scope that contains the node. -`cursor_pos` should be `{ row = number, col = number }` - - *ts_utils.nested_scope* -nested_scope(node, cursor_pos)~ - -Returns the first scope within current scope that contains the node. -`cursor_pos` should be `{ row = number, col = number }` - - *ts_utils.next_scope* -next_scope(node)~ - -Returns the neighbour scope of the current node. - - *ts_utils.previous_scope* -previous_scope(node)~ - -Returns the previous neighbour scope of the current node. - ============================================================================== FUNCTIONS *nvim-treesitter-functions* diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 38c6097ca..d7a87d629 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -7,7 +7,8 @@ list.javascript = { install_info = { url = "https://github.com/tree-sitter/tree-sitter-javascript", files = { "src/parser.c", "src/scanner.c" }, - } + }, + used_by = { 'javascriptreact' } } list.c = { diff --git a/lua/nvim-treesitter/query.lua b/lua/nvim-treesitter/query.lua index c630b366c..ec93d5bbb 100644 --- a/lua/nvim-treesitter/query.lua +++ b/lua/nvim-treesitter/query.lua @@ -26,7 +26,7 @@ M.base_language_map = { } M.query_extensions = { - javascript = { 'jsx' }, + javascript = { 'javascript.jsx' }, tsx = {'javascript.jsx'} } @@ -95,6 +95,9 @@ function M.get_query_files(lang, query_name) local query_files = {} local extensions = M.query_extensions[lang] or {} + local lang_files = filtered_runtime_queries(lang, query_name) + vim.list_extend(query_files, lang_files) + for _, ext in ipairs(extensions) do local l = lang local e = ext @@ -111,9 +114,7 @@ function M.get_query_files(lang, query_name) vim.list_extend(query_files, base_files) end - local lang_files = filtered_runtime_queries(lang, query_name) - - return vim.list_extend(query_files, lang_files) + return query_files end function M.has_query_files(lang, query_name) diff --git a/queries/javascript/highlights.scm b/queries/javascript/highlights.scm index e05cc4141..4f228f3c1 100644 --- a/queries/javascript/highlights.scm +++ b/queries/javascript/highlights.scm @@ -103,7 +103,8 @@ (null) @constant.builtin (comment) @comment (string) @string -(regex) @string.special +(regex) @punctuation.delimiter +(regex_pattern) @string.regex (template_string) @string (number) @number diff --git a/queries/javascript/jsx.scm b/queries/javascript/jsx.scm new file mode 100644 index 000000000..9d727e512 --- /dev/null +++ b/queries/javascript/jsx.scm @@ -0,0 +1,9 @@ +(jsx_element + open_tag: (jsx_opening_element ["<" ">"] @operator)) +(jsx_element + close_tag: (jsx_closing_element ["<" "/" ">"] @operator)) + +(jsx_closing_element name: (identifier) @variable.builtin) +(jsx_opening_element name: (identifier) @variable.builtin) + +(jsx_text) @none |
