From bfb875673efd0398428166babf5f145200fd56a6 Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 13 Dec 2022 20:18:50 +0000 Subject: [PATCH 0001/3010] Update lockfile.json --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index 201c0c8db..0531fe474 100644 --- a/lockfile.json +++ b/lockfile.json @@ -198,7 +198,7 @@ "revision": "02b01653c8a1c198ae7287d566efa86a135b30d5" }, "jsonnet": { - "revision": "44c0d58dfb523b7f1066ef4013cc543afc696960" + "revision": "768a384989391237c6d55ff3d878a0d1e0d2b4fa" }, "julia": { "revision": "91ba1c3c9b50f388d4b67518c04bc9a003ed3475" From d31c71c959348b7b15f7e69608a47aea05ed7bc6 Mon Sep 17 00:00:00 2001 From: "Sergio A. Vargas" Date: Wed, 14 Dec 2022 03:06:08 -0500 Subject: [PATCH 0002/3010] julia: update queries to parser change (#3956) --- lockfile.json | 2 +- queries/julia/highlights.scm | 25 ++++++++----------------- queries/julia/indents.scm | 7 ++++--- queries/julia/injections.scm | 9 +++++++++ 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/lockfile.json b/lockfile.json index 0531fe474..f801df1d6 100644 --- a/lockfile.json +++ b/lockfile.json @@ -201,7 +201,7 @@ "revision": "768a384989391237c6d55ff3d878a0d1e0d2b4fa" }, "julia": { - "revision": "91ba1c3c9b50f388d4b67518c04bc9a003ed3475" + "revision": "36b099e9ea577f64ba53323115028dadd2991d2c" }, "kotlin": { "revision": "b953dbdd05257fcb2b64bc4d9c1578fac12e3c28" diff --git a/queries/julia/highlights.scm b/queries/julia/highlights.scm index e8d9ac9ff..5e4922e14 100644 --- a/queries/julia/highlights.scm +++ b/queries/julia/highlights.scm @@ -15,17 +15,9 @@ (quote_expression ":" (identifier)) @symbol - -;;; Fields and indexes - (field_expression (identifier) @field .) -(index_expression - (_) - (range_expression - (identifier) @constant.builtin .) - (#eq? @constant.builtin "end")) ;;; Function names @@ -79,13 +71,14 @@ ;; Definitions (abstract_definition - name: (identifier) @type.definition - (subtype_clause (identifier) @type)) + name: (identifier) @type.definition) (primitive_definition - name: (identifier) @type.definition - (subtype_clause (identifier) @type)) + name: (identifier) @type.definition) (struct_definition name: (identifier) @type) +(subtype_clause [ + (identifier) @type + (field_expression (identifier) @type .)]) ;; Annotations @@ -109,6 +102,8 @@ ;;; Keywords [ + "global" + "local" "macro" "struct" "type" @@ -117,9 +112,6 @@ "end" @keyword -((identifier) @keyword - (#any-of? @keyword "global" "local")) ; Grammar error - (compound_statement ["begin" "end"] @keyword) (quote_statement @@ -185,11 +177,10 @@ (operator) @operator (for_binding ["in" "=" "∈"] @operator) -(pair_expression "=>" @operator) (range_expression ":" @operator) (slurp_parameter "..." @operator) -(spread_expression "..." @operator) +(splat_expression "..." @operator) "." @operator ["::" "<:"] @operator diff --git a/queries/julia/indents.scm b/queries/julia/indents.scm index 47be570f2..5e88c697c 100644 --- a/queries/julia/indents.scm +++ b/queries/julia/indents.scm @@ -3,24 +3,25 @@ (macro_definition) (function_definition) + (compound_statement) (if_statement) (try_statement) (for_statement) (while_statement) (let_statement) (quote_statement) - (do_clause) - (compound_statement) (assignment) + (for_binding) (binary_expression) (call_expression) - (array_expression) (tuple_expression) + (comprehension_expression) (matrix_expression) + (vector_expression) ] @indent [ diff --git a/queries/julia/injections.scm b/queries/julia/injections.scm index ac1721b33..ff79619c0 100644 --- a/queries/julia/injections.scm +++ b/queries/julia/injections.scm @@ -1,4 +1,13 @@ +;; Inject markdown in docstrings ((string_literal) @markdown + . [ + (module_definition) + (abstract_definition) + (struct_definition) + (function_definition) + (assignment) + (const_declaration) + ] (#match? @markdown "^\"\"\"") (#offset! @markdown 0 3 0 -3)) From 8b5080b1bfffed50e41de2db481b4866bb30d755 Mon Sep 17 00:00:00 2001 From: Attila Tajti Date: Wed, 30 Nov 2022 11:39:18 +0100 Subject: [PATCH 0003/3010] shell: respect shellslash option on Windows Always use backlashes as path separators in commands when they are used in cmd.exe. Fixes #2844 #1965 --- .../shell_command_selectors.lua | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lua/nvim-treesitter/shell_command_selectors.lua b/lua/nvim-treesitter/shell_command_selectors.lua index 59bbb0e41..fd53bbee8 100644 --- a/lua/nvim-treesitter/shell_command_selectors.lua +++ b/lua/nvim-treesitter/shell_command_selectors.lua @@ -1,6 +1,17 @@ local fn = vim.fn local utils = require "nvim-treesitter.utils" +-- Convert path for cmd.exe on Windows. +-- This is needed when vim.opt.shellslash is in use. +local function cmdpath(p) + if vim.opt.shellslash:get() then + local r = p:gsub("/", "\\") + return r + else + return p + end +end + local M = {} function M.select_mkdir_cmd(directory, cwd, info_msg) @@ -8,7 +19,7 @@ function M.select_mkdir_cmd(directory, cwd, info_msg) return { cmd = "cmd", opts = { - args = { "/C", "mkdir", directory }, + args = { "/C", "mkdir", cmdpath(directory) }, cwd = cwd, }, info = info_msg, @@ -32,7 +43,7 @@ function M.select_rm_file_cmd(file, info_msg) return { cmd = "cmd", opts = { - args = { "/C", "if", "exist", file, "del", file }, + args = { "/C", "if", "exist", cmdpath(file), "del", cmdpath(file) }, }, info = info_msg, err = "Could not delete " .. file, @@ -135,7 +146,7 @@ function M.select_install_rm_cmd(cache_folder, project_name) return { cmd = "cmd", opts = { - args = { "/C", "if", "exist", dir, "rmdir", "/s", "/q", dir }, + args = { "/C", "if", "exist", cmdpath(dir), "rmdir", "/s", "/q", cmdpath(dir) }, }, } else @@ -153,7 +164,7 @@ function M.select_mv_cmd(from, to, cwd) return { cmd = "cmd", opts = { - args = { "/C", "move", "/Y", from, to }, + args = { "/C", "move", "/Y", cmdpath(from), cmdpath(to) }, cwd = cwd, }, } @@ -261,7 +272,7 @@ end function M.make_directory_change_for_command(dir, command) if fn.has "win32" == 1 then - return string.format("pushd %s & %s & popd", dir, command) + return string.format("pushd %s & %s & popd", cmdpath(dir), command) else return string.format("cd %s;\n %s", dir, command) end From 07ff07ae4c7d6f09883ff592f11722050dab5885 Mon Sep 17 00:00:00 2001 From: Attila Tajti Date: Wed, 30 Nov 2022 20:07:51 +0100 Subject: [PATCH 0004/3010] install: fix is_installed checks with shellslash Convert paths to use backslashes on Windows. --- lua/nvim-treesitter/install.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index b0428bd8f..54a813cd4 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -95,6 +95,17 @@ local function get_installed_revision(lang) end end +-- Clean path for use in a prefix comparison +-- @param input string +-- @return string +local function clean_path(input) + local pth = vim.fn.fnamemodify(input, ":p") + if fn.has "win32" == 1 then + pth = pth:gsub("/", "\\") + end + return pth +end + ---Checks if parser is installed with nvim-treesitter ---@param lang string ---@return boolean @@ -104,9 +115,9 @@ local function is_installed(lang) if not install_dir then return false end - install_dir = vim.fn.fnamemodify(install_dir, ":p") + install_dir = clean_path(install_dir) for _, path in ipairs(matched_parsers) do - local abspath = vim.fn.fnamemodify(path, ":p") + local abspath = clean_path(path) if vim.startswith(abspath, install_dir) then return true end From 6ed8a41bd594e14652318650a83442d385b193a9 Mon Sep 17 00:00:00 2001 From: Attila Tajti Date: Wed, 30 Nov 2022 20:42:27 +0100 Subject: [PATCH 0005/3010] utils: respect shellslash setting Use '/' as path separator on Windows when shellslash is set. --- lua/nvim-treesitter/utils.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/nvim-treesitter/utils.lua b/lua/nvim-treesitter/utils.lua index 156ba9c31..c738ee56e 100644 --- a/lua/nvim-treesitter/utils.lua +++ b/lua/nvim-treesitter/utils.lua @@ -13,7 +13,7 @@ end -- Returns the system specific path seperator. ---@return string function M.get_path_sep() - return fn.has "win32" == 1 and "\\" or "/" + return (fn.has "win32" == 1 and not vim.opt.shellslash:get()) and "\\" or "/" end -- Returns a function that joins the given arguments with separator. Arguments From c5d025c467c5c16d37eb24ce3e350a85079c7581 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 15 Dec 2022 08:22:26 +0000 Subject: [PATCH 0006/3010] Update lockfile.json (#3976) Co-authored-by: GitHub --- lockfile.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lockfile.json b/lockfile.json index f801df1d6..e308053b9 100644 --- a/lockfile.json +++ b/lockfile.json @@ -255,10 +255,10 @@ "revision": "8ad20059c6f128861c4506fff866150ffee1d6f4" }, "ocaml": { - "revision": "cc26b1ef111100f26a137bcbcd39fd4e35be9a59" + "revision": "de07323343946c32759933cb3b7c78e821098cad" }, "ocaml_interface": { - "revision": "cc26b1ef111100f26a137bcbcd39fd4e35be9a59" + "revision": "de07323343946c32759933cb3b7c78e821098cad" }, "ocamllex": { "revision": "ac1d5957e719d49bd6acd27439b79843e4daf8ed" From 818fb3b96b875e46417bb8f9bb412450f2617b66 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Wed, 14 Dec 2022 22:56:43 +0100 Subject: [PATCH 0007/3010] ci: Add name of updated parsers to commit message Fixes #3962 --- .github/workflows/update-lockfile.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-lockfile.yml b/.github/workflows/update-lockfile.yml index c3ea4515c..de70b5704 100644 --- a/.github/workflows/update-lockfile.yml +++ b/.github/workflows/update-lockfile.yml @@ -24,6 +24,9 @@ jobs: wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 mv ./jq-linux64 /tmp/jq chmod +x /tmp/jq + wget https://github.com/josephburnett/jd/releases/download/v1.6.1/jd-amd64-linux + mv ./jd-amd64-linux /tmp/jd + chmod +x /tmp/jd sudo apt install libfuse2 wget https://github.com/neovim/neovim/releases/download/${NVIM_TAG}/nvim.appimage chmod u+x nvim.appimage @@ -34,6 +37,7 @@ jobs: env: SKIP_LOCKFILE_UPDATE_FOR_LANGS: verilog,gleam,nix run: | + cp lockfile.json /tmp/old_lockfile.json ./nvim.appimage --headless -c "luafile ./scripts/write-lockfile.lua" -c "q" # Pretty print cp lockfile.json /tmp/lockfile.json @@ -44,14 +48,15 @@ jobs: git config user.name "GitHub" git config user.email "noreply@github.com" git add lockfile.json - git commit -m "Update lockfile.json" || echo 'No commit necessary!' + UPDATED_PARSERS=$(echo $(/tmp/jd -set /tmp/old_lockfile.json lockfile.json | grep @ | sed 's/","revision"\]//' | sed 's/@ \["//') | sed 's/ /, /g') + echo "UPDATED_PARSERS=$UPDATED_PARSERS" >> $GITHUB_ENV + git commit -m "Update parsers: $UPDATED_PARSERS" || echo 'No commit necessary!' git clean -xf - name: Create Pull Request uses: peter-evans/create-pull-request@v3 with: - commit-message: Update lockfile.json - title: Update lockfile.json + title: "Update lockfile.json: ${{ env.UPDATED_PARSERS }}" branch: update-lockfile-pr base: ${{ github.head_ref }} draft: true From a0dc6c8635a1d4fc700c82f4008414d021d9a6d2 Mon Sep 17 00:00:00 2001 From: Jaehwang Jung Date: Sun, 11 Dec 2022 23:10:33 +0900 Subject: [PATCH 0008/3010] highlights(lua): use @method.call --- queries/lua/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries/lua/highlights.scm b/queries/lua/highlights.scm index 48aed0529..1c17d823b 100644 --- a/queries/lua/highlights.scm +++ b/queries/lua/highlights.scm @@ -172,7 +172,7 @@ (function_call name: (dot_index_expression field: (identifier) @function.call)) (function_declaration name: (dot_index_expression field: (identifier) @function)) -(method_index_expression method: (identifier) @method) +(method_index_expression method: (identifier) @method.call) (function_call (identifier) @function.builtin From 507527711fdd8f701544024aeb1a9a068f986d89 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Wed, 14 Dec 2022 22:27:23 +0100 Subject: [PATCH 0009/3010] feat: allow to set keymappings to `false` Fixes #3954 --- README.md | 2 +- lua/nvim-treesitter/configs.lua | 2 +- lua/nvim-treesitter/incremental_selection.lua | 44 ++++++++++--------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index a3db5d966..d07855710 100644 --- a/README.md +++ b/README.md @@ -366,7 +366,7 @@ require'nvim-treesitter.configs'.setup { incremental_selection = { enable = true, keymaps = { - init_selection = "gnn", + init_selection = "gnn", -- set to `false` to disable one of the mappings node_incremental = "grn", scope_incremental = "grc", node_decremental = "grm", diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua index cad4bb788..0b9eaa512 100644 --- a/lua/nvim-treesitter/configs.lua +++ b/lua/nvim-treesitter/configs.lua @@ -57,7 +57,7 @@ local builtin_modules = { module_path = "nvim-treesitter.incremental_selection", enable = false, keymaps = { - init_selection = "gnn", + init_selection = "gnn", -- set to `false` to disable one of the mappings node_incremental = "grn", scope_incremental = "grc", node_decremental = "grm", diff --git a/lua/nvim-treesitter/incremental_selection.lua b/lua/nvim-treesitter/incremental_selection.lua index 5deaaf84e..4d4f2aad6 100644 --- a/lua/nvim-treesitter/incremental_selection.lua +++ b/lua/nvim-treesitter/incremental_selection.lua @@ -130,33 +130,37 @@ local FUNCTION_DESCRIPTIONS = { function M.attach(bufnr) local config = configs.get_module "incremental_selection" for funcname, mapping in pairs(config.keymaps) do - local mode - local rhs - if funcname == "init_selection" then - mode = "n" - rhs = M[funcname] - else - mode = "x" - -- We need to move to command mode to access marks '< (visual area start) and '> (visual area end) which are not - -- properly accessible in visual mode. - rhs = string.format(":lua require'nvim-treesitter.incremental_selection'.%s()", funcname) + if mapping then + local mode + local rhs + if funcname == "init_selection" then + mode = "n" + rhs = M[funcname] + else + mode = "x" + -- We need to move to command mode to access marks '< (visual area start) and '> (visual area end) which are not + -- properly accessible in visual mode. + rhs = string.format(":lua require'nvim-treesitter.incremental_selection'.%s()", funcname) + end + vim.keymap.set( + mode, + mapping, + rhs, + { buffer = bufnr, silent = true, noremap = true, desc = FUNCTION_DESCRIPTIONS[funcname] } + ) end - vim.keymap.set( - mode, - mapping, - rhs, - { buffer = bufnr, silent = true, noremap = true, desc = FUNCTION_DESCRIPTIONS[funcname] } - ) end end function M.detach(bufnr) local config = configs.get_module "incremental_selection" for f, mapping in pairs(config.keymaps) do - if f == "init_selection" then - vim.keymap.del("n", mapping, { buffer = bufnr }) - else - vim.keymap.del("x", mapping, { buffer = bufnr }) + if mapping then + if f == "init_selection" then + vim.keymap.del("n", mapping, { buffer = bufnr }) + else + vim.keymap.del("x", mapping, { buffer = bufnr }) + end end end end From 36c6826274ac85e04558e875a30e82aca676e3fe Mon Sep 17 00:00:00 2001 From: GitHub Date: Fri, 16 Dec 2022 06:38:27 +0000 Subject: [PATCH 0010/3010] Update parsers: c_sharp, php, sql --- lockfile.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lockfile.json b/lockfile.json index e308053b9..6579a78c8 100644 --- a/lockfile.json +++ b/lockfile.json @@ -27,7 +27,7 @@ "revision": "7175a6dd5fc1cee660dce6fe23f6043d75af424a" }, "c_sharp": { - "revision": "3ef3f7f99e16e528e6689eae44dff35150993307" + "revision": "8e4ec08f1dae1d72f082df0f7e1176772f553d47" }, "clojure": { "revision": "8c23e0ec078af461ccad43fffbbfc204aa6bc238" @@ -273,7 +273,7 @@ "revision": "749d26fe13fb131b92e6515416096e572575b981" }, "php": { - "revision": "680244ac3a8092154125e91145fe8d631cd4583b" + "revision": "47dd3532df8204a444dd6eb042135f1e7964f9cb" }, "phpdoc": { "revision": "2f4d16c861b5a454b577d057f247f9902d7b47f5" @@ -348,7 +348,7 @@ "revision": "05f949d3c1c15e3261473a244d3ce87777374dec" }, "sql": { - "revision": "a4dd131eeb9fe7f3c9c2ca0f506f6d58d9986a97" + "revision": "8dc7fa0e51145f0312eedbb5aff9945bd967fb8f" }, "supercollider": { "revision": "90c6d9f777d2b8c4ce497c48b5f270a44bcf3ea0" From 69cbb6c6d3418476c3dc602141c45a8882fba045 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sat, 17 Dec 2022 06:36:31 +0000 Subject: [PATCH 0011/3010] Update parsers: c_sharp, lua --- lockfile.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lockfile.json b/lockfile.json index 6579a78c8..1f87f319b 100644 --- a/lockfile.json +++ b/lockfile.json @@ -27,7 +27,7 @@ "revision": "7175a6dd5fc1cee660dce6fe23f6043d75af424a" }, "c_sharp": { - "revision": "8e4ec08f1dae1d72f082df0f7e1176772f553d47" + "revision": "d83b3c661db34fde4dcd80e79ce1653d4524998d" }, "clojure": { "revision": "8c23e0ec078af461ccad43fffbbfc204aa6bc238" @@ -219,7 +219,7 @@ "revision": "e9948edc41e9e5869af99dddb2b5ff5cc5581af6" }, "lua": { - "revision": "f5e84ffc2b06858401e0d2edf5dce009efbe34b3" + "revision": "0fc89962b7ff5c7d676b8592c1cbce1ceaa806fd" }, "m68k": { "revision": "d097b123f19c6eaba2bf181c05420d88b9fc489d" From f2a5524add2b79cc656956a44b8a00e1ce6742e7 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 17 Dec 2022 11:52:32 +0100 Subject: [PATCH 0012/3010] ci: bump action versions --- .github/workflows/lint.yml | 4 ++-- .github/workflows/test-queries.yml | 6 +++--- .github/workflows/tests.yml | 6 +++--- .github/workflows/update-lockfile.yml | 4 ++-- .github/workflows/update-readme.yml | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8d0bb121f..021d53568 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,7 +10,7 @@ jobs: name: Luacheck runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Prepare run: | @@ -25,7 +25,7 @@ jobs: name: StyLua runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Lint with stylua uses: JohnnyMorganz/stylua-action@v1 with: diff --git a/.github/workflows/test-queries.yml b/.github/workflows/test-queries.yml index 738bad9a4..a39190104 100644 --- a/.github/workflows/test-queries.yml +++ b/.github/workflows/test-queries.yml @@ -55,9 +55,9 @@ jobs: NVIM: ${{ matrix.os == 'windows-2022' && 'nvim-win64\\bin\\nvim.exe' || 'nvim' }} ALLOWED_INSTALLATION_FAILURES: ${{ matrix.os == 'windows-2022' && 'rnoweb' }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: ilammy/msvc-dev-cmd@v1 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v3 - name: Install and prepare Neovim env: @@ -68,7 +68,7 @@ jobs: - name: Setup Parsers Cache id: parsers-cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ./parser/ diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e8f462119..8e4551bf7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,8 +27,8 @@ jobs: env: CC: ${{ matrix.cc }} steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 - name: Test Dependencies run: | @@ -47,7 +47,7 @@ jobs: - name: Setup Parsers Cache id: parsers-cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: | ./parser/ diff --git a/.github/workflows/update-lockfile.yml b/.github/workflows/update-lockfile.yml index de70b5704..a42c4e077 100644 --- a/.github/workflows/update-lockfile.yml +++ b/.github/workflows/update-lockfile.yml @@ -13,7 +13,7 @@ jobs: name: Update lockfile runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: ref: master @@ -54,7 +54,7 @@ jobs: git clean -xf - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v4 with: title: "Update lockfile.json: ${{ env.UPDATED_PARSERS }}" branch: update-lockfile-pr diff --git a/.github/workflows/update-readme.yml b/.github/workflows/update-readme.yml index 62f8bd4fc..b8d40a009 100644 --- a/.github/workflows/update-readme.yml +++ b/.github/workflows/update-readme.yml @@ -11,7 +11,7 @@ jobs: name: Update README runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Prepare env: @@ -32,7 +32,7 @@ jobs: git clean -xf - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v4 with: commit-message: Update README title: Update README From 2603f1d4316acb0e569d1cdf04c631e867468e37 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sat, 17 Dec 2022 11:58:10 +0000 Subject: [PATCH 0013/3010] Update parsers: astro --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index 1f87f319b..b97880625 100644 --- a/lockfile.json +++ b/lockfile.json @@ -6,7 +6,7 @@ "revision": "c473c09f23b13d9404ec5208fad3eddea89d70f8" }, "astro": { - "revision": "947e93089e60c66e681eba22283f4037841451e7" + "revision": "22697b0e2413464b7abaea9269c5e83a59e39a83" }, "awk": { "revision": "e559793754c60c2cdf00cbb0409842d75f0a41dc" From 225846c5e8a30f70c930535946decf6ef648cc72 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 17 Dec 2022 13:08:06 +0100 Subject: [PATCH 0014/3010] ci: bump stylua action to v2 --- .github/workflows/lint.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 021d53568..71510b1b9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -27,7 +27,8 @@ jobs: steps: - uses: actions/checkout@v3 - name: Lint with stylua - uses: JohnnyMorganz/stylua-action@v1 + uses: JohnnyMorganz/stylua-action@v2 with: token: ${{ secrets.GITHUB_TOKEN }} + version: latest args: --check . From ee095abeac5842943a94a27c0ca75c61e7c614a2 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sat, 17 Dec 2022 17:57:09 +0000 Subject: [PATCH 0015/3010] Update parsers: help --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index b97880625..587c9f9e2 100644 --- a/lockfile.json +++ b/lockfile.json @@ -159,7 +159,7 @@ "revision": "2e1348c3cf2c9323e87c2744796cf3f3868aa82a" }, "help": { - "revision": "ce20f13c3f12506185754888feaae3f2ad54c287" + "revision": "61c75058299f3d1cf565697e4073d7b2cc6a6d6c" }, "hjson": { "revision": "02fa3b79b3ff9a296066da6277adfc3f26cbc9e0" From a75aded7aeba98a89d018f9a6ae0cad9dfbe7c2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20Lito=C5=A1?= <54900518+JosefLitos@users.noreply.github.com> Date: Sat, 17 Dec 2022 22:27:55 +0100 Subject: [PATCH 0016/3010] highlights(java): fix '!',param,global group --- queries/java/highlights.scm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/queries/java/highlights.scm b/queries/java/highlights.scm index 63cb01237..625c2b5b7 100644 --- a/queries/java/highlights.scm +++ b/queries/java/highlights.scm @@ -20,7 +20,8 @@ name: (identifier) @parameter) (spread_parameter - (variable_declarator) @parameter) ; int... foo + (variable_declarator + name: (identifier) @parameter)) ; int... foo ;; Lambda parameter (inferred_parameters (identifier) @parameter) ; (x,y) -> ... @@ -50,6 +51,7 @@ "&&" "|" "||" +"!" "!=" "==" "*" @@ -109,7 +111,8 @@ ; Fields (field_declaration - declarator: (variable_declarator) @field) + declarator: (variable_declarator + name: (identifier) @field)) (field_access field: (identifier) @field) From 6e37050e50e80e4324202a6b8fbac6c7fb90c546 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 18 Dec 2022 22:04:05 +0000 Subject: [PATCH 0017/3010] Update parsers: swift --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index 587c9f9e2..ecc810e3e 100644 --- a/lockfile.json +++ b/lockfile.json @@ -360,7 +360,7 @@ "revision": "52e122ae68b316d3aa960a0a422d3645ba717f42" }, "swift": { - "revision": "693411cb5a1167311ccd84708348281630562726" + "revision": "f94e1d6dd8f4df6c7c8aa07da625e498ebb27d09" }, "sxhkdrc": { "revision": "440d5f913d9465c9c776a1bd92334d32febcf065" From 8498ebd49b1ec1c55656eef85604e277cbb12c30 Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 20 Dec 2022 06:40:33 +0000 Subject: [PATCH 0018/3010] Update parsers: c_sharp, jsonnet, query --- lockfile.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lockfile.json b/lockfile.json index ecc810e3e..1033d5854 100644 --- a/lockfile.json +++ b/lockfile.json @@ -27,7 +27,7 @@ "revision": "7175a6dd5fc1cee660dce6fe23f6043d75af424a" }, "c_sharp": { - "revision": "d83b3c661db34fde4dcd80e79ce1653d4524998d" + "revision": "f0e31b964d67598da03b54854eb7471f5c2560b5" }, "clojure": { "revision": "8c23e0ec078af461ccad43fffbbfc204aa6bc238" @@ -198,7 +198,7 @@ "revision": "02b01653c8a1c198ae7287d566efa86a135b30d5" }, "jsonnet": { - "revision": "768a384989391237c6d55ff3d878a0d1e0d2b4fa" + "revision": "505f5bd90053ae895aa3d6f2bac8071dd9abd8b2" }, "julia": { "revision": "36b099e9ea577f64ba53323115028dadd2991d2c" @@ -300,7 +300,7 @@ "revision": "0b2b25bcaa7d4925d5f0dda16f6a99c588a437f1" }, "query": { - "revision": "0695cd0760532de7b54f23c667d459b5d1332b44" + "revision": "0717de07078a20a8608c98ad5f26c208949d0e15" }, "r": { "revision": "80efda55672d1293aa738f956c7ae384ecdc31b4" From eedb7b9c69b13afe86461b0742266bb62b811ece Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 20 Dec 2022 08:27:57 +0100 Subject: [PATCH 0019/3010] csharp: update query to parser change --- queries/c_sharp/highlights.scm | 1 - 1 file changed, 1 deletion(-) diff --git a/queries/c_sharp/highlights.scm b/queries/c_sharp/highlights.scm index 3ecdffb6e..ee56f21da 100644 --- a/queries/c_sharp/highlights.scm +++ b/queries/c_sharp/highlights.scm @@ -69,7 +69,6 @@ [ (predefined_type) - (void_keyword) ] @type.builtin (implicit_type) @keyword From ca097525758a1d9a751d07fb7fd045ddfe047c0a Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 21 Dec 2022 06:38:40 +0000 Subject: [PATCH 0020/3010] Update parsers: c_sharp, gdscript, sql --- lockfile.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lockfile.json b/lockfile.json index 1033d5854..efb6e3ae1 100644 --- a/lockfile.json +++ b/lockfile.json @@ -27,7 +27,7 @@ "revision": "7175a6dd5fc1cee660dce6fe23f6043d75af424a" }, "c_sharp": { - "revision": "f0e31b964d67598da03b54854eb7471f5c2560b5" + "revision": "c86fd921a48f517730b2d73bbb5652da65270f6a" }, "clojure": { "revision": "8c23e0ec078af461ccad43fffbbfc204aa6bc238" @@ -108,7 +108,7 @@ "revision": "19db2f47ba4c3a0f6238d4ae0e2abfca16e61dd6" }, "gdscript": { - "revision": "2a6abdaa47fcb91397e09a97c7433fd995ea46c6" + "revision": "a8fa839150d05baaf4d5a472520ee71e9b1d8b3c" }, "git_rebase": { "revision": "127f5b56c1ad3e8a449a7d6e0c7412ead7f7724c" @@ -348,7 +348,7 @@ "revision": "05f949d3c1c15e3261473a244d3ce87777374dec" }, "sql": { - "revision": "8dc7fa0e51145f0312eedbb5aff9945bd967fb8f" + "revision": "8635357363f8b01931ce6abbe0c937aa73e47bf8" }, "supercollider": { "revision": "90c6d9f777d2b8c4ce497c48b5f270a44bcf3ea0" From 87dd482e1a7056fee95891af6ba3e662e766af77 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Wed, 21 Dec 2022 12:22:45 +0100 Subject: [PATCH 0021/3010] fix(health): align the list of parsers when doing checkhealth Some parser names are too long for the given space, which shifts the features so they aren't in line. --- lua/nvim-treesitter/health.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/nvim-treesitter/health.lua b/lua/nvim-treesitter/health.lua index 9501008df..40ec3448e 100644 --- a/lua/nvim-treesitter/health.lua +++ b/lua/nvim-treesitter/health.lua @@ -115,14 +115,14 @@ function M.check() install_health() queries.invalidate_query_cache() -- Parser installation checks - local parser_installation = { "Parser/Features H L F I J" } + local parser_installation = { "Parser/Features" .. string.rep(" ", 9) .. "H L F I J" } for _, parser_name in pairs(info.installed_parsers()) do local installed = #api.nvim_get_runtime_file("parser/" .. parser_name .. ".so", false) -- Only append information about installed parsers if installed >= 1 then local multiple_parsers = installed > 1 and "+" or "" - local out = " - " .. parser_name .. multiple_parsers .. string.rep(" ", 15 - (#parser_name + #multiple_parsers)) + local out = " - " .. parser_name .. multiple_parsers .. string.rep(" ", 20 - (#parser_name + #multiple_parsers)) for _, query_group in pairs(queries.built_in_query_groups) do local status, err = query_status(parser_name, query_group) out = out .. status .. " " From 770c66d43fa26cdf66227ed4ab66bd5fede85c21 Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 21 Dec 2022 12:09:14 +0000 Subject: [PATCH 0022/3010] Update parsers: v --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index efb6e3ae1..f6489ab9c 100644 --- a/lockfile.json +++ b/lockfile.json @@ -393,7 +393,7 @@ "revision": "faad9094f4061a43d4e9005439e9e85c6541ebe7" }, "v": { - "revision": "66b92a89ef1e149300df79c0b2a934ad959c8eec" + "revision": "f0aa56eec7689f08a389c90ad8d3e5e0d18b3cd7" }, "vala": { "revision": "8f690bfa639f2b83d1fb938ed3dd98a7ba453e8b" From e8b765bee1f760b0153fb4edf2391ff5d7a85475 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Wed, 21 Dec 2022 14:15:02 +0100 Subject: [PATCH 0023/3010] ci: use builtin jq instead of downloading it --- .github/workflows/update-lockfile.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/update-lockfile.yml b/.github/workflows/update-lockfile.yml index a42c4e077..c95ecf73a 100644 --- a/.github/workflows/update-lockfile.yml +++ b/.github/workflows/update-lockfile.yml @@ -21,9 +21,6 @@ jobs: env: NVIM_TAG: stable run: | - wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 - mv ./jq-linux64 /tmp/jq - chmod +x /tmp/jq wget https://github.com/josephburnett/jd/releases/download/v1.6.1/jd-amd64-linux mv ./jd-amd64-linux /tmp/jd chmod +x /tmp/jd @@ -41,7 +38,7 @@ jobs: ./nvim.appimage --headless -c "luafile ./scripts/write-lockfile.lua" -c "q" # Pretty print cp lockfile.json /tmp/lockfile.json - cat /tmp/lockfile.json | /tmp/jq --sort-keys > lockfile.json + cat /tmp/lockfile.json | jq --sort-keys > lockfile.json - name: Commit changes run: | From d2d8980c5cef0d42aa7a2444d95d3c06fd216720 Mon Sep 17 00:00:00 2001 From: figsoda Date: Thu, 1 Dec 2022 10:38:01 -0500 Subject: [PATCH 0024/3010] injections(yaml): fix injections --- queries/yaml/highlights.scm | 2 +- queries/yaml/injections.scm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/queries/yaml/highlights.scm b/queries/yaml/highlights.scm index 7e3c3a5e6..fb3338eb3 100644 --- a/queries/yaml/highlights.scm +++ b/queries/yaml/highlights.scm @@ -2,7 +2,7 @@ (null_scalar) @constant.builtin (double_quote_scalar) @string (single_quote_scalar) @string -(block_scalar) @string +((block_scalar) @string (#set! "priority" 99)) (string_scalar) @string (escape_sequence) @string.escape (integer_scalar) @number diff --git a/queries/yaml/injections.scm b/queries/yaml/injections.scm index c2b5bf619..40727bbd2 100644 --- a/queries/yaml/injections.scm +++ b/queries/yaml/injections.scm @@ -9,7 +9,7 @@ (block_mapping_pair key: (flow_node) @_run (#any-of? @_run "run" "script" "before_script" "after_script") value: (block_node - (block_scalar) @bash (#offset! @bash 0 0 0 0))) + (block_scalar) @bash (#offset! @bash 0 1 0 0))) (block_mapping_pair key: (flow_node) @_run (#any-of? @_run "run" "script" "before_script" "after_script") @@ -24,4 +24,4 @@ (block_sequence (block_sequence_item (block_node - (block_scalar) @bash))))) + (block_scalar) @bash (#offset! @bash 0 1 0 0)))))) From 51df4212e7ae76d324ca406197185d913163e1ae Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 21 Dec 2022 22:38:59 +0000 Subject: [PATCH 0025/3010] Update parsers: c_sharp --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index f6489ab9c..5320ab7ff 100644 --- a/lockfile.json +++ b/lockfile.json @@ -27,7 +27,7 @@ "revision": "7175a6dd5fc1cee660dce6fe23f6043d75af424a" }, "c_sharp": { - "revision": "c86fd921a48f517730b2d73bbb5652da65270f6a" + "revision": "b5f3edbf6b98ad8519445a69df6c2142336ba6c7" }, "clojure": { "revision": "8c23e0ec078af461ccad43fffbbfc204aa6bc238" From 2d48cbc831dcfc4ccce4380467d82e908effd0ee Mon Sep 17 00:00:00 2001 From: xasc Date: Sun, 6 Nov 2022 17:44:50 +0100 Subject: [PATCH 0026/3010] feat(t32): initial support --- lockfile.json | 3 + lua/nvim-treesitter/parsers.lua | 13 +++ queries/t32/folds.scm | 1 + queries/t32/highlights.scm | 141 ++++++++++++++++++++++++ queries/t32/injections.scm | 1 + queries/t32/locals.scm | 35 ++++++ tests/query/highlights/t32/comments.cmm | 10 ++ tests/query/highlights/t32/keywords.cmm | 103 +++++++++++++++++ tests/query/highlights/t32/literals.cmm | 37 +++++++ tests/query/highlights/t32/var.cmm | 27 +++++ 10 files changed, 371 insertions(+) create mode 100644 queries/t32/folds.scm create mode 100644 queries/t32/highlights.scm create mode 100644 queries/t32/injections.scm create mode 100644 queries/t32/locals.scm create mode 100644 tests/query/highlights/t32/comments.cmm create mode 100644 tests/query/highlights/t32/keywords.cmm create mode 100644 tests/query/highlights/t32/literals.cmm create mode 100644 tests/query/highlights/t32/var.cmm diff --git a/lockfile.json b/lockfile.json index 5320ab7ff..18f9e4b57 100644 --- a/lockfile.json +++ b/lockfile.json @@ -365,6 +365,9 @@ "sxhkdrc": { "revision": "440d5f913d9465c9c776a1bd92334d32febcf065" }, + "t32": { + "revision": "20fe21a5a4eb79e1788f6424dcc6a1f2bd023ffa" + }, "teal": { "revision": "1ae8c68e90523b26b93af56feb7868fe4214e2b2" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 0246cde81..d0ef4a97a 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1206,6 +1206,19 @@ list.tiger = { maintainers = { "@ambroisie" }, } +list.t32 = { + install_info = { + url = "https://codeberg.org/xasc/tree-sitter-t32", + files = { "src/parser.c", "src/scanner.c" }, + branch = "main", + revision = "675cd7de4eb80f2faa1e6d3bc9ee195fa9ef9790", + generate_requires_npm = false, + requires_generate_from_grammar = false, + }, + filetype = "t32", + maintainers = { "@xasc" }, +} + list.sxhkdrc = { install_info = { url = "https://github.com/RaafatTurki/tree-sitter-sxhkdrc", diff --git a/queries/t32/folds.scm b/queries/t32/folds.scm new file mode 100644 index 000000000..fd7d23999 --- /dev/null +++ b/queries/t32/folds.scm @@ -0,0 +1 @@ +(block) @fold diff --git a/queries/t32/highlights.scm b/queries/t32/highlights.scm new file mode 100644 index 000000000..9fd1816ba --- /dev/null +++ b/queries/t32/highlights.scm @@ -0,0 +1,141 @@ +[ + "=" + "^^" + "||" + "&&" + "+" + "-" + "*" + "/" + "%" + "|" + "^" + "==" + "!=" + ">" + ">=" + "<=" + "<" + "<<" + ">>" + ".." + "--" + "++" + "+" + "-" + "~" + "!" + "&" + "->" + "*" +] @operator + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + "," + "." + ";" +] @punctuation.delimiter + +[ + (access_class) + (address) + (bitmask) + (file_handle) + (frequency) + (integer) + (percentage) + (time) +] @number + +(float) @float + +(string) @string + +(path) @string.special + +(symbol) @symbol + +(character) @character + +; Commands +(command_expression + command: (identifier) @keyword) +(macro_definition + command: (identifier) @keyword) + +; Returns +( + (command_expression + command: (identifier) @keyword.return) + (#match? @keyword.return "^[eE][nN][dD]([dD][oO])?$") +) +( + (command_expression + command: (identifier) @keyword.return) + (#match? @keyword.return "^[rR][eE][tT][uU][rR][nN]$") +) + +; Subroutine calls +(subroutine_call_expression + command: (identifier) @keyword + subroutine: (identifier) @function.call) + +; Variables, constants and labels +(macro) @variable.builtin +(internal_c_variable) @variable.builtin + +(argument_list + (identifier) @constant) +( + (argument_list (identifier) @constant.builtin) + (#match? @constant.builtin "^[%/][a-zA-Z][a-zA-Z0-9.]*$") +) + +( + (command_expression + command: (identifier) @keyword + arguments: (argument_list . (identifier) @label)) + (#match? @keyword "^[gG][oO][tT][oO]$") +) +(labeled_expression + label: (identifier) @label) + +; Subroutine blocks +(subroutine_block + command: (identifier) @keyword + subroutine: (identifier) @function) + +(labeled_expression + label: (identifier) @function + (block)) + +; Parameter declarations +(parameter_declaration + command: (identifier) @keyword + macro: (macro) @parameter) + +; Control flow +(if_block + command: (identifier) @conditional) +(else_block + command: (identifier) @conditional) + +(while_block + command: (identifier) @repeat) +(repeat_block + command: (identifier) @repeat) + +(call_expression + function: (identifier) @function.builtin) + +(type_identifier) @type +(comment) @comment @spell diff --git a/queries/t32/injections.scm b/queries/t32/injections.scm new file mode 100644 index 000000000..4bb7d675d --- /dev/null +++ b/queries/t32/injections.scm @@ -0,0 +1 @@ +(comment) @comment diff --git a/queries/t32/locals.scm b/queries/t32/locals.scm new file mode 100644 index 000000000..dd03b4246 --- /dev/null +++ b/queries/t32/locals.scm @@ -0,0 +1,35 @@ +(block) @scope + +; Parameter definitions +(parameter_declaration + command: (identifier) + macro: (macro) @definition.parameter) + +; Variable definitions +(macro_definition + command: (identifier) + macro: (macro) @definition.var) + +(command_expression + command: (identifier) + arguments: (argument_list + variable: (identifier) @definition.var)) + +; Function definitions +(subroutine_block + command: (identifier) + subroutine: (identifier) @definition.function) + +(labeled_expression + label: (identifier) @definition.function + (block)) + +; References +( + (subroutine_call_expression + command: (identifier) + subroutine: (identifier) @reference) + (set! reference.kind "function") +) + +(macro) @reference diff --git a/tests/query/highlights/t32/comments.cmm b/tests/query/highlights/t32/comments.cmm new file mode 100644 index 000000000..0bab130f6 --- /dev/null +++ b/tests/query/highlights/t32/comments.cmm @@ -0,0 +1,10 @@ +// This is a comment +; <- comment + +; Another comment +; <- comment + +ECHO &a // This is a trailing comment +; ^ comment + +// vim: set ft=t32: diff --git a/tests/query/highlights/t32/keywords.cmm b/tests/query/highlights/t32/keywords.cmm new file mode 100644 index 000000000..e9eb0e37f --- /dev/null +++ b/tests/query/highlights/t32/keywords.cmm @@ -0,0 +1,103 @@ +PRIVATE &password +; <- keyword +; ^ variable.builtin +ENTRY &password +; <- keyword +; ^ parameter + +IF "&password"=="" +; <- conditional +; ^ string +; ^ variable.builtin +; ^ operator +( + ECHO "Failed to provide password." + ENDDO +; ^ keyword.return +) +ELSE +; <- conditional +( + PRIVATE &pass + + &pass=FALSE() +; ^ function.builtin + WHILE !&pass +; ^ operator + ( + GOSUB verify_password "&password" +; ^ function.call + RETURNVALUES &pass +; ^ parameter + WAIT 10.ms +; ^ number + ) + + IF !&pass + GOTO fail +; ^ label + ELSE + ( + GOSUB start_debug +; ^ function.call + ) +) + +LOCAL &num +; ^ variable.builtin + +&num = 2. +; ^ number + +RePeaT &num PRINT "Password: &password" +; ^ variable.builtin +; ^ variable.builtin + +WinCLEAR +FramePOS ,,,,Maximized +; ^ punctuation.delimiter +; ^ constant +WinPOS 0% 50% 100% 35% +; ^ number +COVerage.ListFunc + +ENDDO + + +fail: +; <- label + PRINT %ERROR "Password verification failed." + END +; ^ keyword.return + + +verify_password: +; <- function +( + PARAMETERS &password +; ^ parameter + + SYStem.Option.KEYCODE "&password" + SYStem.JtagClock 1kHz +; ^ number + SYStem.Mode.Attach + + Data.Set EAXI:0x34000000 %Long 0x34000100 0x34000021 /verify +; ^ number +; ^ constant.builtin +; ^ constant + + RETURN TRUE() +; ^ keyword.return +) + + +SUBROUTINE start_debug +; ^ function +( + Go main + RETURN +; ^ keyword.return +) + +// vim: set ft=t32: diff --git a/tests/query/highlights/t32/literals.cmm b/tests/query/highlights/t32/literals.cmm new file mode 100644 index 000000000..f63348490 --- /dev/null +++ b/tests/query/highlights/t32/literals.cmm @@ -0,0 +1,37 @@ +WinPOS ,,1000.,,,,myWatchWindow +; ^ number + +PRinTer.OPEN "~~~/varwatch.txt" ASCIIE +; ^ string + +sYmbol.NEW _InitialSP 0x34000100 +; ^ number + +DO ~~~~/test.cmm +; ^ string.special + +WAIT 1.ns +; ^ number + +SYStem.JtagClock 100.GHZ +; ^ number + +DATA.SET P:&HEAD+0x4 %LONG DATA.LONG(EA:&HEAD+0x4)&0xFFFFFF +; ^ number + +List `main` +; ^ symbol + +&range = 'a'--'z'||'0'--'9' +; ^ character +; ^ operator +; ^ character + +Data.Set 0xffff800000 0y0011xx01xx&&a +; ^ number +; ^ operator + +WinPOS 0% 85% 100% 15% +; ^ number + +// vim: set ft=t32: diff --git a/tests/query/highlights/t32/var.cmm b/tests/query/highlights/t32/var.cmm new file mode 100644 index 000000000..a2d6f9b2a --- /dev/null +++ b/tests/query/highlights/t32/var.cmm @@ -0,0 +1,27 @@ +Var.NEWGLOBAL char[4][32] \myarr +; <- keyword +; ^ type +; ^ variable.builtin +LOCAL &i &data + +&data="zero|one|two|three" + +&i=0. +WHILE &i<4 +( + PRIVATE &val + &val=STRing.SPLIT("&data","|",&i) + Var.Assign \myarr[&i]="&val" +; ^ variable.builtin + &i=&i+1. +) + +Var.NEWLOCAL \x +; <- keyword +; ^ variable.builtin +Var.set \x=func3(5,3) +; ^ variable.builtin +PRINT Var.VALUE(\x) +; ^ variable.builtin + +// vim: set ft=t32: From 9efc2dffc3367e0c724b628675ca7cac13357dc6 Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 21 Dec 2022 22:48:57 +0000 Subject: [PATCH 0027/3010] Update parsers: c_sharp --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index 18f9e4b57..9ae81de91 100644 --- a/lockfile.json +++ b/lockfile.json @@ -27,7 +27,7 @@ "revision": "7175a6dd5fc1cee660dce6fe23f6043d75af424a" }, "c_sharp": { - "revision": "b5f3edbf6b98ad8519445a69df6c2142336ba6c7" + "revision": "44630a63192399da9e17f9105e0fa53412d78961" }, "clojure": { "revision": "8c23e0ec078af461ccad43fffbbfc204aa6bc238" From 38845442b715278fb848c8202d1345d9d0b10aa7 Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 21 Dec 2022 22:58:22 +0000 Subject: [PATCH 0028/3010] Update parsers: c_sharp, t32 --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index 9ae81de91..998a1a497 100644 --- a/lockfile.json +++ b/lockfile.json @@ -366,7 +366,7 @@ "revision": "440d5f913d9465c9c776a1bd92334d32febcf065" }, "t32": { - "revision": "20fe21a5a4eb79e1788f6424dcc6a1f2bd023ffa" + "revision": "f8106fcf5a27f905b3d9d55d9cd3e910bea70c60" }, "teal": { "revision": "1ae8c68e90523b26b93af56feb7868fe4214e2b2" From 779b4222a3734c165295c146b39351508822735c Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Mon, 28 Nov 2022 23:29:45 +0100 Subject: [PATCH 0029/3010] injections(go): inject regex into some regexp functions --- queries/go/injections.scm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/queries/go/injections.scm b/queries/go/injections.scm index 4bb7d675d..e0bdc99b9 100644 --- a/queries/go/injections.scm +++ b/queries/go/injections.scm @@ -1 +1,13 @@ (comment) @comment + +(call_expression + (selector_expression) @_function (#any-of? @_function + "regexp.Match" + "regexp.MatchReader" + "regexp.MatchString" + "regexp.Compile" + "regexp.CompilePOSIX" + "regexp.MustCompile" + "regexp.MustCompilePOSIX") + (argument_list + . [(raw_string_literal) (interpreted_string_literal)] @regex (#offset! @regex 0 1 0 -1))) From 23906e8838da6793effc46aaf52f82607d56c6d6 Mon Sep 17 00:00:00 2001 From: Emmanuel Briot Date: Wed, 14 Dec 2022 15:59:24 +0100 Subject: [PATCH 0030/3010] feat: add Ada --- README.md | 1 + lockfile.json | 3 + lua/nvim-treesitter/parsers.lua | 10 ++ queries/ada/folds.scm | 13 +++ queries/ada/highlights.scm | 179 ++++++++++++++++++++++++++++++++ queries/ada/locals.scm | 33 ++++++ 6 files changed, 239 insertions(+) create mode 100644 queries/ada/folds.scm create mode 100644 queries/ada/highlights.scm create mode 100644 queries/ada/locals.scm diff --git a/README.md b/README.md index d07855710..40aa11d6a 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,7 @@ We are looking for maintainers to add more parsers and to write query files for +- [x] [ada](https://github.com/briot/tree-sitter-ada) (maintained by @briot) - [x] [agda](https://github.com/AusCyberman/tree-sitter-agda) (maintained by @Decodetalkers) - [x] [arduino](https://github.com/ObserverOfTime/tree-sitter-arduino) (maintained by @ObserverOfTime) - [x] [astro](https://github.com/virchau13/tree-sitter-astro) (maintained by @virchau13) diff --git a/lockfile.json b/lockfile.json index 998a1a497..b03afb585 100644 --- a/lockfile.json +++ b/lockfile.json @@ -1,4 +1,7 @@ { + "ada": { + "revision": "0210164cce71a6b6010ab24fb4fe77693469db14" + }, "agda": { "revision": "80ea622cf952a0059e168e5c92a798b2f1925652" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index d0ef4a97a..04a4cea66 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -60,6 +60,16 @@ local list = setmetatable({}, { end, }) +list.ada = { + install_info = { + url = "https://github.com/briot/tree-sitter-ada", + branch = "master", + files = { "src/parser.c" }, + }, + filetype = "ada", + maintainers = { "@briot" }, +} + list.agda = { install_info = { url = "https://github.com/AusCyberman/tree-sitter-agda", diff --git a/queries/ada/folds.scm b/queries/ada/folds.scm new file mode 100644 index 000000000..f6f908483 --- /dev/null +++ b/queries/ada/folds.scm @@ -0,0 +1,13 @@ +;; Support for folding in Ada +;; za toggles folding a package, subprogram, if statement or loop + +[ + (package_specification) + (package_body) + (subprogram_body) + (block_statement) + (if_statement) + (loop_statement) + (gnatprep_declarative_if_statement) + (gnatprep_if_statement) +] @fold diff --git a/queries/ada/highlights.scm b/queries/ada/highlights.scm new file mode 100644 index 000000000..0adb377ab --- /dev/null +++ b/queries/ada/highlights.scm @@ -0,0 +1,179 @@ +;; highlight queries. +;; See the syntax at https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries +;; See also https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#parser-configurations +;; for a list of recommended @ tags, though not all of them have matching +;; highlights in neovim. + +[ + "abort" + "abs" + "abstract" + "accept" + "access" + "all" + "array" + "at" + "begin" + "declare" + "delay" + "delta" + "digits" + "do" + "end" + "entry" + "exit" + "generic" + "interface" + "is" + "limited" + "null" + "of" + "others" + "out" + "pragma" + "private" + "range" + "synchronized" + "tagged" + "task" + "terminate" + "until" + "when" +] @keyword +[ + "aliased" + "constant" + "renames" +] @storageclass +[ + "mod" + "new" + "protected" + "record" + "subtype" + "type" +] @keyword.type +[ + "with" + "use" +] @include +[ + "body" + "function" + "overriding" + "procedure" + "package" + "separate" +] @keyword.function +[ + "and" + "in" + "not" + "or" + "xor" +] @keyword.operator +[ + "while" + "loop" + "for" + "parallel" + "reverse" + "some" +] @repeat +[ + "return" +] @keyword.return +[ + "case" + "if" + "else" + "then" + "elsif" + "select" +] @conditional +[ + "exception" + "raise" +] @exception +(comment) @comment +(comment) @spell ;; spell-check comments +(string_literal) @string +(string_literal) @spell ;; spell-check strings +(character_literal) @string +(numeric_literal) @number + +;; Highlight the name of subprograms +(procedure_specification name: (_) @function) +(function_specification name: (_) @function) +(package_specification name: (_) @function) +(package_body name: (_) @function) +(generic_instantiation name: (_) @function) + +;; Some keywords should take different categories depending on the context +(use_clause "use" @include "type" @include) +(with_clause "private" @include) +(with_clause "limited" @include) +(use_clause (_) @namespace) +(with_clause (_) @namespace) + +(loop_statement "end" @keyword.repeat) +(if_statement "end" @conditional) +(loop_parameter_specification "in" @keyword.repeat) +(loop_parameter_specification "in" @keyword.repeat) +(iterator_specification ["in" "of"] @keyword.repeat) +(range_attribute_designator "range" @keyword.repeat) + +(raise_statement "with" @exception) + +(gnatprep_declarative_if_statement) @preproc +(gnatprep_if_statement) @preproc +(gnatprep_identifier) @preproc + +(subprogram_declaration "is" @keyword.function "abstract" @keyword.function) +(aspect_specification "with" @keyword.function) + +(full_type_declaration "is" @keyword.type) +(subtype_declaration "is" @keyword.type) +(record_definition "end" @keyword.type) +(full_type_declaration (_ "access" @keyword.type)) +(array_type_definition "array" @keyword.type "of" @keyword.type) +(access_to_object_definition "access" @keyword.type) +(access_to_object_definition "access" @keyword.type + [ + (general_access_modifier "constant" @keyword.type) + (general_access_modifier "all" @keyword.type) + ] +) +(range_constraint "range" @keyword.type) +(signed_integer_type_definition "range" @keyword.type) +(index_subtype_definition "range" @keyword.type) +(record_type_definition "abstract" @keyword.type) +(record_type_definition "tagged" @keyword.type) +(record_type_definition "limited" @keyword.type) +(record_type_definition (record_definition "null" @keyword.type)) +(private_type_declaration "is" @keyword.type "private" @keyword.type) +(private_type_declaration "tagged" @keyword.type) +(private_type_declaration "limited" @keyword.type) +(task_type_declaration "task" @keyword.type "is" @keyword.type) + +;; Gray the body of expression functions +(expression_function_declaration + (function_specification) + "is" + (_) @attribute +) +(subprogram_declaration (aspect_specification) @attribute) + +;; Highlight full subprogram specifications +;(subprogram_body +; [ +; (procedure_specification) +; (function_specification) +; ] @function.spec +;) + +;; Highlight errors in red. This is not very useful in practice, as text will +;; be highlighted as user types, and the error could be elsewhere in the code. +;; This also requires defining :hi @error guifg=Red for instance. +(ERROR) @error + diff --git a/queries/ada/locals.scm b/queries/ada/locals.scm new file mode 100644 index 000000000..a1460153c --- /dev/null +++ b/queries/ada/locals.scm @@ -0,0 +1,33 @@ +;; Better highlighting by referencing to the definition, for variable +;; references. However, this is not yet supported by neovim +;; See https://tree-sitter.github.io/tree-sitter/syntax-highlighting#local-variables + +(compilation) @scope +(package_specification) @scope +(package_body) @scope +(subprogram_declaration) @scope +(subprogram_body) @scope +(block_statement) @scope + +(with_clause (identifier) @definition.import) +(procedure_specification name: (_) @definition.function) +(function_specification name: (_) @definition.function) +(package_specification name: (_) @definition.var) +(package_body name: (_) @definition.var) +(generic_instantiation . name: (_) @definition.var) +(component_declaration . (identifier) @definition.var) +(exception_declaration . (identifier) @definition.var) +(formal_object_declaration . (identifier) @definition.var) +(object_declaration . (identifier) @definition.var) +(parameter_specification . (identifier) @definition.var) +(full_type_declaration . (identifier) @definition.type) +(private_type_declaration . (identifier) @definition.type) +(private_extension_declaration . (identifier) @definition.type) +(incomplete_type_declaration . (identifier) @definition.type) +(protected_type_declaration . (identifier) @definition.type) +(formal_complete_type_declaration . (identifier) @definition.type) +(formal_incomplete_type_declaration . (identifier) @definition.type) +(task_type_declaration . (identifier) @definition.type) +(subtype_declaration . (identifier) @definition.type) + +(identifier) @reference From 6f9e5cdba77ff735e8a4b8a9022b23292a41ba95 Mon Sep 17 00:00:00 2001 From: GitHub Date: Thu, 22 Dec 2022 13:47:43 +0000 Subject: [PATCH 0031/3010] Update parsers: ada, c_sharp --- lockfile.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lockfile.json b/lockfile.json index b03afb585..20e7c6885 100644 --- a/lockfile.json +++ b/lockfile.json @@ -1,6 +1,6 @@ { "ada": { - "revision": "0210164cce71a6b6010ab24fb4fe77693469db14" + "revision": "e9e2ec9d3b6302e9b455901bec00036e29d1c121" }, "agda": { "revision": "80ea622cf952a0059e168e5c92a798b2f1925652" @@ -30,7 +30,7 @@ "revision": "7175a6dd5fc1cee660dce6fe23f6043d75af424a" }, "c_sharp": { - "revision": "44630a63192399da9e17f9105e0fa53412d78961" + "revision": "0588adfffbec65dfb2bd845c84d35127932d930b" }, "clojure": { "revision": "8c23e0ec078af461ccad43fffbbfc204aa6bc238" From eaeedfb80419e8145760d95d1840996a2746af7c Mon Sep 17 00:00:00 2001 From: Lucario387 Date: Sat, 17 Dec 2022 12:27:14 +0900 Subject: [PATCH 0032/3010] Fix vue injection queries --- queries/vue/injections.scm | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/queries/vue/injections.scm b/queries/vue/injections.scm index 34949ea29..36e3286e1 100644 --- a/queries/vue/injections.scm +++ b/queries/vue/injections.scm @@ -1,4 +1,35 @@ -; inherits: html_tags +( + (style_element + (start_tag) @_no_lang + (raw_text) @css) + (#not-contains? @_no_lang "lang=") +) + +( + (style_element + (start_tag + (attribute + (quoted_attribute_value (attribute_value) @_lang))) + (raw_text) @css) + (#eq? @_lang "css") +) + +; if start_tag does not specify `lang="..."` then set it to javascript +( + (script_element + (start_tag) @_no_lang + (raw_text) @javascript) + (#not-contains? @_no_lang "lang=") +) + +( + (script_element + (start_tag + (attribute + (quoted_attribute_value (attribute_value) @_lang))) + (raw_text) @javascript) + (#eq? @_lang "js") +) ( (style_element @@ -15,7 +46,7 @@ (attribute (quoted_attribute_value (attribute_value) @_lang))) (raw_text) @typescript) - (#any-of? @_lang "ts" "typescript") + (#eq? @_lang "ts") ) ((interpolation From 895d4a1202f36df561ba032c93b9deb72e1edee8 Mon Sep 17 00:00:00 2001 From: GitHub Date: Thu, 22 Dec 2022 21:42:38 +0000 Subject: [PATCH 0033/3010] Update parsers: c_sharp --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index 20e7c6885..1c691db18 100644 --- a/lockfile.json +++ b/lockfile.json @@ -30,7 +30,7 @@ "revision": "7175a6dd5fc1cee660dce6fe23f6043d75af424a" }, "c_sharp": { - "revision": "0588adfffbec65dfb2bd845c84d35127932d930b" + "revision": "4f729938e8e368182dfa55c11743e49f4f8549cd" }, "clojure": { "revision": "8c23e0ec078af461ccad43fffbbfc204aa6bc238" From 82cff67988b36450caefb557414ef697a83a58af Mon Sep 17 00:00:00 2001 From: "Sergio A. Vargas" Date: Fri, 23 Dec 2022 04:34:24 -0500 Subject: [PATCH 0034/3010] julia: update parser and highlights (#4016) - Replace `scoped_identifier` with `field_expression` in function names - Replace true and false with `boolean_literal` --- lockfile.json | 2 +- queries/julia/highlights.scm | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lockfile.json b/lockfile.json index 1c691db18..81e9cb850 100644 --- a/lockfile.json +++ b/lockfile.json @@ -204,7 +204,7 @@ "revision": "505f5bd90053ae895aa3d6f2bac8071dd9abd8b2" }, "julia": { - "revision": "36b099e9ea577f64ba53323115028dadd2991d2c" + "revision": "f254ff9c52e994f629a60821662917d2c6c0e8eb" }, "kotlin": { "revision": "b953dbdd05257fcb2b64bc4d9c1578fac12e3c28" diff --git a/queries/julia/highlights.scm b/queries/julia/highlights.scm index 5e4922e14..89840dafe 100644 --- a/queries/julia/highlights.scm +++ b/queries/julia/highlights.scm @@ -30,9 +30,9 @@ name: (identifier) @function) (function_definition - name: (scoped_identifier (identifier) @function .)) + name: (field_expression (identifier) @function .)) (short_function_definition - name: (scoped_identifier (identifier) @function .)) + name: (field_expression (identifier) @function .)) ;; calls @@ -191,11 +191,7 @@ ;;; Literals -[ - (true) - (false) -] @boolean - +(boolean_literal) @boolean (integer_literal) @number (float_literal) @float From 7f7b5778ffbb7185e29f357082845bef9ecce5de Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 23 Dec 2022 09:44:32 +0000 Subject: [PATCH 0035/3010] Update parsers: c_sharp (#4019) Co-authored-by: GitHub --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index 81e9cb850..10253c5a3 100644 --- a/lockfile.json +++ b/lockfile.json @@ -30,7 +30,7 @@ "revision": "7175a6dd5fc1cee660dce6fe23f6043d75af424a" }, "c_sharp": { - "revision": "4f729938e8e368182dfa55c11743e49f4f8549cd" + "revision": "530d86abae6ea264bf19ae347ad250b1b4bb81a7" }, "clojure": { "revision": "8c23e0ec078af461ccad43fffbbfc204aa6bc238" From a851cef248f8a69fa644b04bba0cc308c632de63 Mon Sep 17 00:00:00 2001 From: figsoda Date: Mon, 28 Nov 2022 19:33:17 -0500 Subject: [PATCH 0036/3010] injections(nix): fix runCommand* --- queries/nix/injections.scm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/queries/nix/injections.scm b/queries/nix/injections.scm index 3b32b0eae..9765033a4 100644 --- a/queries/nix/injections.scm +++ b/queries/nix/injections.scm @@ -28,13 +28,13 @@ (#match? @_path "^text$")) (apply_expression - (apply_expression - function: (apply_expression function: (_) @_func) - argument: [ - (string_expression (string_fragment) @bash) - (indented_string_expression (string_fragment) @bash) - ]) - (#match? @_func "(^|\\.)runCommand(((No)?CC)?(Local)?)?$")) + function: (apply_expression + function: (apply_expression function: (_) @_func)) + argument: [ + (string_expression (string_fragment) @bash) + (indented_string_expression (string_fragment) @bash) + ] + (#match? @_func "(^|\\.)runCommand((No)?CC)?(Local)?$")) ((apply_expression function: (apply_expression function: (_) @_func) From df67a47a7e68c6df045e5a51ca87bca383891f1e Mon Sep 17 00:00:00 2001 From: figsoda Date: Mon, 28 Nov 2022 20:19:27 -0500 Subject: [PATCH 0037/3010] highlights(nix): improve highlights --- queries/nix/highlights.scm | 148 ++++++++++++++++++++++++++++++------- 1 file changed, 120 insertions(+), 28 deletions(-) diff --git a/queries/nix/highlights.scm b/queries/nix/highlights.scm index 3885d5d90..94ff7b2f1 100644 --- a/queries/nix/highlights.scm +++ b/queries/nix/highlights.scm @@ -1,22 +1,26 @@ ; basic keywords [ - ("assert") - ("with") - ("let") - ("in") - ("rec") - ("inherit") + "assert" + "in" + "inherit" + "let" + "rec" + "with" ] @keyword +; these are technically functions but they act more like keywords (abort and throw are control flow, derivation is a core language construct) +((identifier) @keyword + (#any-of? @keyword "abort" "derivation" "throw")) + ; if/then/else [ - ("if") - ("then") - ("else") + "if" + "then" + "else" ] @conditional ; field access default (`a.b or c`) -("or") @keyword.operator +"or" @keyword.operator ; comments (comment) @comment @@ -48,10 +52,9 @@ ] @punctuation.bracket ; `?` in `{ x ? y }:`, used to set defaults for named function arguments -; I'm not really sure what group this should go in, but it should probably have highlighting, so I'm putting it in @punctuation.special (formal name: (identifier) @parameter - "?"? @punctuation.special) + "?"? @operator) ; `...` in `{ ... }`, used to ignore unknown named function arguments (see above) (ellipses) @punctuation.special @@ -62,33 +65,122 @@ universal: (identifier) @parameter ":" @punctuation.special) +; function calls +(apply_expression + function: (variable_expression + name: (identifier) @function.call)) + ; basic identifiers (variable_expression) @variable ; builtin functions -((identifier) @_i (#match? @_i "^(builtins|baseNameOf|dirOf|fetchTarball|map|removeAttrs|toString)$")) @variable.builtin +; modified from `nix __dump-builtins | jq keys` +((identifier) @function.builtin (#any-of? @function.builtin + "add" + "all" + "any" + "attrNames" + "attrValues" + "baseNameOf" + "bitAnd" + "bitOr" + "bitXor" + "break" + "catAttrs" + "ceil" + "compareVersions" + "concatLists" + "concatMap" + "concatStringsSep" + "deepSeq" + "dirOf" + "div" + "elem" + "elemAt" + "fetchClosure" + "fetchGit" + "fetchTarball" + "fetchurl" + "filter" + "filterSource" + "floor" + "foldl'" + "fromJSON" + "functionArgs" + "genList" + "genericClosure" + "getAttr" + "getEnv" + "getFlake" + "groupBy" + "hasAttr" + "hashFile" + "hashString" + "head" + "intersectAttrs" + "isAttrs" + "isBool" + "isFloat" + "isFunction" + "isInt" + "isList" + "isNull" + "isPath" + "isString" + "length" + "lessThan" + "listToAttrs" + "map" + "mapAttrs" + "match" + "mul" + "parseDrvName" + "partition" + "path" + "pathExists" + "placeholder" + "readDir" + "readFile" + "removeAttrs" + "replaceStrings" + "seq" + "sort" + "split" + "splitVersion" + "storePath" + "stringLength" + "sub" + "substring" + "tail" + "toFile" + "toJSON" + "toPath" + "toString" + "toXML" + "trace" + "traceVerbose" + "tryEval" + "typeOf" + "zipAttrsWith" +)) -; display entire builtins path as builtin (ex. `builtins.filter` is highlighted as one long builtin) -(select_expression - expression: ((variable_expression) @_i (#eq? @_i "builtins")) - attrpath: (attrpath attr: (identifier) @variable.builtin)) @variable.builtin - -; import -((identifier) @_i (#eq? @_i "import")) @include - -; null -((identifier) @_i (#eq? @_i "import")) @constant.builtin - -; these are technically functions but they act more like keywords (abort and throw are control flow, derivation is a core language construct) -((identifier) @_i (#match? @_i "^(abort|derivation|throw)$")) @keyword +((identifier) @include (#eq? @include "import")) ; booleans -((identifier) @_i (#match? @_i "^(true|false)$")) @boolean +((identifier) @boolean (#any-of? @boolean "true" "false")) + +; constants +((identifier) @constant.builtin (#any-of? @constant.builtin "builtins" "null")) ; string interpolation (this was very annoying to get working properly) (interpolation "${" @punctuation.special (_) "}" @punctuation.special) @none -; fields (the `.` in `a.b = c;` isn't included) +; display entire builtins path as builtin (ex. `builtins.filter` is highlighted as one long builtin) +(select_expression + expression: ((variable_expression) @_i (#eq? @_i "builtins")) + attrpath: (attrpath attr: (identifier) @function.builtin)) + +(select_expression attrpath: (attrpath attr: (identifier) @field)) (attrset_expression (binding_set (binding . (attrpath (identifier) @field)))) (rec_attrset_expression (binding_set (binding . (attrpath (identifier) @field)))) From 90edaba46a1cd411d9a67794bfdaa64f004e1ed1 Mon Sep 17 00:00:00 2001 From: figsoda Date: Wed, 30 Nov 2022 10:19:53 -0500 Subject: [PATCH 0038/3010] highlights(nix): add all builtins --- queries/nix/highlights.scm | 115 ++++++------------------------------- 1 file changed, 16 insertions(+), 99 deletions(-) diff --git a/queries/nix/highlights.scm b/queries/nix/highlights.scm index 94ff7b2f1..e60091436 100644 --- a/queries/nix/highlights.scm +++ b/queries/nix/highlights.scm @@ -73,114 +73,31 @@ ; basic identifiers (variable_expression) @variable -; builtin functions -; modified from `nix __dump-builtins | jq keys` -((identifier) @function.builtin (#any-of? @function.builtin - "add" - "all" - "any" - "attrNames" - "attrValues" - "baseNameOf" - "bitAnd" - "bitOr" - "bitXor" - "break" - "catAttrs" - "ceil" - "compareVersions" - "concatLists" - "concatMap" - "concatStringsSep" - "deepSeq" - "dirOf" - "div" - "elem" - "elemAt" - "fetchClosure" - "fetchGit" - "fetchTarball" - "fetchurl" - "filter" - "filterSource" - "floor" - "foldl'" - "fromJSON" - "functionArgs" - "genList" - "genericClosure" - "getAttr" - "getEnv" - "getFlake" - "groupBy" - "hasAttr" - "hashFile" - "hashString" - "head" - "intersectAttrs" - "isAttrs" - "isBool" - "isFloat" - "isFunction" - "isInt" - "isList" - "isNull" - "isPath" - "isString" - "length" - "lessThan" - "listToAttrs" - "map" - "mapAttrs" - "match" - "mul" - "parseDrvName" - "partition" - "path" - "pathExists" - "placeholder" - "readDir" - "readFile" - "removeAttrs" - "replaceStrings" - "seq" - "sort" - "split" - "splitVersion" - "storePath" - "stringLength" - "sub" - "substring" - "tail" - "toFile" - "toJSON" - "toPath" - "toString" - "toXML" - "trace" - "traceVerbose" - "tryEval" - "typeOf" - "zipAttrsWith" -)) - ((identifier) @include (#eq? @include "import")) - -; booleans ((identifier) @boolean (#any-of? @boolean "true" "false")) +; builtin functions +((identifier) @function.builtin (#any-of? @function.builtin + ; nix eval --impure --expr 'with builtins; filter (x: x != "import" && isFunction builtins.${x}) (attrNames builtins)' + "abort" "add" "addErrorContext" "all" "any" "appendContext" "attrNames" "attrValues" "baseNameOf" "bitAnd" "bitOr" "bitXor" "break" "catAttrs" "ceil" "compareVersions" "concatLists" "concatMap" "concatStringsSep" "deepSeq" "derivation" "derivationStrict" "dirOf" "div" "elem" "elemAt" "fetchGit" "fetchMercurial" "fetchTarball" "fetchTree" "fetchurl" "filter" "filterSource" "findFile" "floor" "foldl'" "fromJSON" "fromTOML" "functionArgs" "genList" "genericClosure" "getAttr" "getContext" "getEnv" "getFlake" "groupBy" "hasAttr" "hasContext" "hashFile" "hashString" "head" "intersectAttrs" "isAttrs" "isBool" "isFloat" "isFunction" "isInt" "isList" "isNull" "isPath" "isString" "length" "lessThan" "listToAttrs" "map" "mapAttrs" "match" "mul" "parseDrvName" "partition" "path" "pathExists" "placeholder" "readDir" "readFile" "removeAttrs" "replaceStrings" "scopedImport" "seq" "sort" "split" "splitVersion" "storePath" "stringLength" "sub" "substring" "tail" "throw" "toFile" "toJSON" "toPath" "toString" "toXML" "trace" "traceVerbose" "tryEval" "typeOf" "unsafeDiscardOutputDependency" "unsafeDiscardStringContext" "unsafeGetAttrPos" "zipAttrsWith" + ; primops, `__` in `nix repl` + "__add" "__filter" "__isFunction" "__split" "__addErrorContext" "__filterSource" "__isInt" "__splitVersion" "__all" "__findFile" "__isList" "__storeDir" "__any" "__floor" "__isPath" "__storePath" "__appendContext" "__foldl'" "__isString" "__stringLength" "__attrNames" "__fromJSON" "__langVersion" "__sub" "__attrValues" "__functionArgs" "__length" "__substring" "__bitAnd" "__genList" "__lessThan" "__tail" "__bitOr" "__genericClosure" "__listToAttrs" "__toFile" "__bitXor" "__getAttr" "__mapAttrs" "__toJSON" "__catAttrs" "__getContext" "__match" "__toPath" "__ceil" "__getEnv" "__mul" "__toXML" "__compareVersions" "__getFlake" "__nixPath" "__trace" "__concatLists" "__groupBy" "__nixVersion" "__traceVerbose" "__concatMap" "__hasAttr" "__parseDrvName" "__tryEval" "__concatStringsSep" "__hasContext" "__partition" "__typeOf" "__currentSystem" "__hashFile" "__path" "__unsafeDiscardOutputDependency" "__currentTime" "__hashString" "__pathExists" "__unsafeDiscardStringContext" "__deepSeq" "__head" "__readDir" "__unsafeGetAttrPos" "__div" "__intersectAttrs" "__readFile" "__zipAttrsWith" "__elem" "__isAttrs" "__replaceStrings" "__elemAt" "__isBool" "__seq" "__fetchurl" "__isFloat" "__sort" +)) + ; constants -((identifier) @constant.builtin (#any-of? @constant.builtin "builtins" "null")) +((identifier) @constant.builtin (#any-of? @constant.builtin + ; nix eval --impure --expr 'with builtins; filter (x: !(isFunction builtins.${x} || isBool builtins.${x})) (attrNames builtins)' + "builtins" "currentSystem" "currentTime" "langVersion" "nixPath" "nixVersion" "null" "storeDir" +)) ; string interpolation (this was very annoying to get working properly) (interpolation "${" @punctuation.special (_) "}" @punctuation.special) @none -; display entire builtins path as builtin (ex. `builtins.filter` is highlighted as one long builtin) (select_expression - expression: ((variable_expression) @_i (#eq? @_i "builtins")) - attrpath: (attrpath attr: (identifier) @function.builtin)) - -(select_expression attrpath: (attrpath attr: (identifier) @field)) + expression: (_) @_expr + attrpath: (attrpath attr: (identifier) @field) + (#not-eq? @_expr "builtins") +) (attrset_expression (binding_set (binding . (attrpath (identifier) @field)))) (rec_attrset_expression (binding_set (binding . (attrpath (identifier) @field)))) From 668dec2903577517ef88f44d7de845a580148941 Mon Sep 17 00:00:00 2001 From: figsoda Date: Wed, 30 Nov 2022 12:18:58 -0500 Subject: [PATCH 0039/3010] highlights(nix): improve builtins and exceptions highlights --- queries/nix/highlights.scm | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/queries/nix/highlights.scm b/queries/nix/highlights.scm index e60091436..bce901a47 100644 --- a/queries/nix/highlights.scm +++ b/queries/nix/highlights.scm @@ -8,9 +8,16 @@ "with" ] @keyword -; these are technically functions but they act more like keywords (abort and throw are control flow, derivation is a core language construct) -((identifier) @keyword - (#any-of? @keyword "abort" "derivation" "throw")) +(variable_expression + name: (identifier) @keyword + (#eq? @keyword "derivation") + (#set! "priority" 101)) + +; exceptions +(variable_expression + name: (identifier) @exception + (#any-of? @exception "abort" "throw") + (#set! "priority" 101)) ; if/then/else [ @@ -73,19 +80,24 @@ ; basic identifiers (variable_expression) @variable -((identifier) @include (#eq? @include "import")) -((identifier) @boolean (#any-of? @boolean "true" "false")) +(variable_expression + name: (identifier) @include + (#eq? @include "import")) + +(variable_expression + name: (identifier) @boolean + (#any-of? @boolean "true" "false")) ; builtin functions -((identifier) @function.builtin (#any-of? @function.builtin - ; nix eval --impure --expr 'with builtins; filter (x: x != "import" && isFunction builtins.${x}) (attrNames builtins)' - "abort" "add" "addErrorContext" "all" "any" "appendContext" "attrNames" "attrValues" "baseNameOf" "bitAnd" "bitOr" "bitXor" "break" "catAttrs" "ceil" "compareVersions" "concatLists" "concatMap" "concatStringsSep" "deepSeq" "derivation" "derivationStrict" "dirOf" "div" "elem" "elemAt" "fetchGit" "fetchMercurial" "fetchTarball" "fetchTree" "fetchurl" "filter" "filterSource" "findFile" "floor" "foldl'" "fromJSON" "fromTOML" "functionArgs" "genList" "genericClosure" "getAttr" "getContext" "getEnv" "getFlake" "groupBy" "hasAttr" "hasContext" "hashFile" "hashString" "head" "intersectAttrs" "isAttrs" "isBool" "isFloat" "isFunction" "isInt" "isList" "isNull" "isPath" "isString" "length" "lessThan" "listToAttrs" "map" "mapAttrs" "match" "mul" "parseDrvName" "partition" "path" "pathExists" "placeholder" "readDir" "readFile" "removeAttrs" "replaceStrings" "scopedImport" "seq" "sort" "split" "splitVersion" "storePath" "stringLength" "sub" "substring" "tail" "throw" "toFile" "toJSON" "toPath" "toString" "toXML" "trace" "traceVerbose" "tryEval" "typeOf" "unsafeDiscardOutputDependency" "unsafeDiscardStringContext" "unsafeGetAttrPos" "zipAttrsWith" +(variable_expression name: (identifier) @function.builtin (#any-of? @function.builtin + ; nix eval --impure --expr 'with builtins; filter (x: !(elem x [ "abort" "derivation" "import" "throw" ]) && isFunction builtins.${x}) (attrNames builtins)' + "add" "addErrorContext" "all" "any" "appendContext" "attrNames" "attrValues" "baseNameOf" "bitAnd" "bitOr" "bitXor" "break" "catAttrs" "ceil" "compareVersions" "concatLists" "concatMap" "concatStringsSep" "deepSeq" "derivationStrict" "dirOf" "div" "elem" "elemAt" "fetchGit" "fetchMercurial" "fetchTarball" "fetchTree" "fetchurl" "filter" "filterSource" "findFile" "floor" "foldl'" "fromJSON" "fromTOML" "functionArgs" "genList" "genericClosure" "getAttr" "getContext" "getEnv" "getFlake" "groupBy" "hasAttr" "hasContext" "hashFile" "hashString" "head" "intersectAttrs" "isAttrs" "isBool" "isFloat" "isFunction" "isInt" "isList" "isNull" "isPath" "isString" "length" "lessThan" "listToAttrs" "map" "mapAttrs" "match" "mul" "parseDrvName" "partition" "path" "pathExists" "placeholder" "readDir" "readFile" "removeAttrs" "replaceStrings" "scopedImport" "seq" "sort" "split" "splitVersion" "storePath" "stringLength" "sub" "substring" "tail" "toFile" "toJSON" "toPath" "toString" "toXML" "trace" "traceVerbose" "tryEval" "typeOf" "unsafeDiscardOutputDependency" "unsafeDiscardStringContext" "unsafeGetAttrPos" "zipAttrsWith" ; primops, `__` in `nix repl` "__add" "__filter" "__isFunction" "__split" "__addErrorContext" "__filterSource" "__isInt" "__splitVersion" "__all" "__findFile" "__isList" "__storeDir" "__any" "__floor" "__isPath" "__storePath" "__appendContext" "__foldl'" "__isString" "__stringLength" "__attrNames" "__fromJSON" "__langVersion" "__sub" "__attrValues" "__functionArgs" "__length" "__substring" "__bitAnd" "__genList" "__lessThan" "__tail" "__bitOr" "__genericClosure" "__listToAttrs" "__toFile" "__bitXor" "__getAttr" "__mapAttrs" "__toJSON" "__catAttrs" "__getContext" "__match" "__toPath" "__ceil" "__getEnv" "__mul" "__toXML" "__compareVersions" "__getFlake" "__nixPath" "__trace" "__concatLists" "__groupBy" "__nixVersion" "__traceVerbose" "__concatMap" "__hasAttr" "__parseDrvName" "__tryEval" "__concatStringsSep" "__hasContext" "__partition" "__typeOf" "__currentSystem" "__hashFile" "__path" "__unsafeDiscardOutputDependency" "__currentTime" "__hashString" "__pathExists" "__unsafeDiscardStringContext" "__deepSeq" "__head" "__readDir" "__unsafeGetAttrPos" "__div" "__intersectAttrs" "__readFile" "__zipAttrsWith" "__elem" "__isAttrs" "__replaceStrings" "__elemAt" "__isBool" "__seq" "__fetchurl" "__isFloat" "__sort" )) ; constants -((identifier) @constant.builtin (#any-of? @constant.builtin +(variable_expression name: (identifier) @constant.builtin (#any-of? @constant.builtin ; nix eval --impure --expr 'with builtins; filter (x: !(isFunction builtins.${x} || isBool builtins.${x})) (attrNames builtins)' "builtins" "currentSystem" "currentTime" "langVersion" "nixPath" "nixVersion" "null" "storeDir" )) From 06989a933e24d1ae5c140e3934545218a1c1b48f Mon Sep 17 00:00:00 2001 From: figsoda Date: Sat, 3 Dec 2022 16:33:50 -0500 Subject: [PATCH 0040/3010] injections(nix): combine injections to work better with interpolations --- queries/nix/highlights.scm | 3 ++- queries/nix/injections.scm | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/queries/nix/highlights.scm b/queries/nix/highlights.scm index bce901a47..86b497e9f 100644 --- a/queries/nix/highlights.scm +++ b/queries/nix/highlights.scm @@ -33,7 +33,8 @@ (comment) @comment ; strings -[ (string_expression) (indented_string_expression) ] @string +([ (string_expression) (indented_string_expression) ] + (#set! "priority" 99)) @string ; paths and URLs [ (path_expression) (spath_expression) (uri_expression) ] @string.special diff --git a/queries/nix/injections.scm b/queries/nix/injections.scm index 9765033a4..3d965289a 100644 --- a/queries/nix/injections.scm +++ b/queries/nix/injections.scm @@ -7,6 +7,7 @@ (indented_string_expression (string_fragment) @regex) ] (#match? @_func "(^|\\.)match$")) + @combined (binding attrpath: (attrpath (identifier) @_path) @@ -15,6 +16,7 @@ (indented_string_expression (string_fragment) @bash) ] (#match? @_path "(^\\w*Phase|(pre|post)\\w*|(.*\\.)?\\w*([sS]cript|[hH]ook)|(.*\\.)?startup)$")) + @combined (apply_expression function: (_) @_func @@ -26,6 +28,7 @@ ]))) (#match? @_func "(^|\\.)writeShellApplication$") (#match? @_path "^text$")) + @combined (apply_expression function: (apply_expression @@ -35,6 +38,7 @@ (indented_string_expression (string_fragment) @bash) ] (#match? @_func "(^|\\.)runCommand((No)?CC)?(Local)?$")) + @combined ((apply_expression function: (apply_expression function: (_) @_func) @@ -43,6 +47,7 @@ (indented_string_expression (string_fragment) @bash) ]) (#match? @_func "(^|\\.)write(Bash|Dash|ShellScript)(Bin)?$")) + @combined ((apply_expression function: (apply_expression function: (_) @_func) @@ -51,6 +56,7 @@ (indented_string_expression (string_fragment) @fish) ]) (#match? @_func "(^|\\.)writeFish(Bin)?$")) + @combined ((apply_expression function: (apply_expression @@ -60,6 +66,7 @@ (indented_string_expression (string_fragment) @haskell) ]) (#match? @_func "(^|\\.)writeHaskell(Bin)?$")) + @combined ((apply_expression function: (apply_expression @@ -69,6 +76,7 @@ (indented_string_expression (string_fragment) @javascript) ]) (#match? @_func "(^|\\.)writeJS(Bin)?$")) + @combined ((apply_expression function: (apply_expression @@ -78,6 +86,7 @@ (indented_string_expression (string_fragment) @perl) ]) (#match? @_func "(^|\\.)writePerl(Bin)?$")) + @combined ((apply_expression function: (apply_expression @@ -87,6 +96,7 @@ (indented_string_expression (string_fragment) @python) ]) (#match? @_func "(^|\\.)write(PyPy|Python)[23](Bin)?$")) + @combined ((apply_expression function: (apply_expression @@ -96,3 +106,4 @@ (indented_string_expression (string_fragment) @rust) ]) (#match? @_func "(^|\\.)writeRust(Bin)?$")) + @combined From 381573a9d6ba444f35aba19c9de6d1ad4557ec5e Mon Sep 17 00:00:00 2001 From: Rishi Date: Sat, 1 Oct 2022 14:51:02 +0530 Subject: [PATCH 0041/3010] Inherit folds for SCSS from CSS --- queries/scss/folds.scm | 1 + 1 file changed, 1 insertion(+) create mode 100644 queries/scss/folds.scm diff --git a/queries/scss/folds.scm b/queries/scss/folds.scm new file mode 100644 index 000000000..cbe41875e --- /dev/null +++ b/queries/scss/folds.scm @@ -0,0 +1 @@ +; inherits: css From cf6b5cb1ede83741d5cca7071fd75df3b942d3ca Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 23 Dec 2022 22:15:17 +0000 Subject: [PATCH 0042/3010] Update parsers: c_sharp (#4023) Co-authored-by: GitHub --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index 10253c5a3..8e48ad7fb 100644 --- a/lockfile.json +++ b/lockfile.json @@ -30,7 +30,7 @@ "revision": "7175a6dd5fc1cee660dce6fe23f6043d75af424a" }, "c_sharp": { - "revision": "530d86abae6ea264bf19ae347ad250b1b4bb81a7" + "revision": "1bd772f69b0db577122533514a239b184650adf2" }, "clojure": { "revision": "8c23e0ec078af461ccad43fffbbfc204aa6bc238" From 48a3da710369688df80beb2847dabbbd02e2180e Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sat, 24 Dec 2022 00:44:36 +0100 Subject: [PATCH 0043/3010] highlights(c_sharp): add ">>>" ">>>=" From upstream change https://github.com/tree-sitter/tree-sitter-c-sharp/pull/266/files --- queries/c_sharp/highlights.scm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/queries/c_sharp/highlights.scm b/queries/c_sharp/highlights.scm index ee56f21da..878ac75b9 100644 --- a/queries/c_sharp/highlights.scm +++ b/queries/c_sharp/highlights.scm @@ -275,9 +275,11 @@ "|=" "~" ">>" + ">>>" "<<" "<<=" ">>=" + ">>>=" "=>" ] @operator From f2b1d727e6ad46238baa84c4d1f968a297e415ab Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sun, 25 Dec 2022 13:23:36 +0100 Subject: [PATCH 0044/3010] chore: update usage `vim.split` to new signature Old usage was still working because of backward compatibility of nvim code: ```lua if type(kwargs) == 'boolean' then -- Support old signature for backward compatibility plain = kwargs else ``` `:h vim-split()` https://neovim.io/doc/user/lua.html#vim.split() --- lua/nvim-treesitter/parsers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 04a4cea66..f4e13974b 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1377,7 +1377,7 @@ function M.ft_to_lang(ft) if result then return result else - ft = vim.split(ft, ".", true)[1] + ft = vim.split(ft, ".", { plain = true })[1] return filetype_to_parsername[ft] or ft end end From 4547a3687c21be5dea6750cccf63f76883f412d9 Mon Sep 17 00:00:00 2001 From: Lucario387 Date: Sat, 24 Dec 2022 01:59:30 +0900 Subject: [PATCH 0045/3010] injections(vue): Update injection queries --- queries/vue/injections.scm | 82 +++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 27 deletions(-) diff --git a/queries/vue/injections.scm b/queries/vue/injections.scm index 36e3286e1..71faa74cf 100644 --- a/queries/vue/injections.scm +++ b/queries/vue/injections.scm @@ -1,52 +1,80 @@ ( (style_element - (start_tag) @_no_lang + (start_tag) @_no_attribute (raw_text) @css) - (#not-contains? @_no_lang "lang=") + (#match? @_no_attribute "<\\s*style\\s*>") ) ( (style_element (start_tag (attribute - (quoted_attribute_value (attribute_value) @_lang))) + (attribute_name) @_no_lang)) (raw_text) @css) - (#eq? @_lang "css") -) - -; if start_tag does not specify `lang="..."` then set it to javascript -( - (script_element - (start_tag) @_no_lang - (raw_text) @javascript) - (#not-contains? @_no_lang "lang=") -) - -( - (script_element - (start_tag - (attribute - (quoted_attribute_value (attribute_value) @_lang))) - (raw_text) @javascript) - (#eq? @_lang "js") -) + (#not-eq? @_no_lang "lang") +) ( (style_element (start_tag (attribute - (quoted_attribute_value (attribute_value) @_lang))) - (raw_text) @scss) - (#any-of? @_lang "scss" "postcss" "less") + (attribute_name) @_lang + (quoted_attribute_value (attribute_value) @_css))) + (raw_text) @css) + (#eq? @_lang "lang") + (#eq? @_css "css") +) + +; If script tag does not have any extra attributes, set it to javascript +( + (script_element + (start_tag) @_no_attribute + (raw_text) @javascript) + (#match? @_no_attribute "<\\s*script\\s*>") +) + +; if start_tag does not specify `lang="..."` then set it to javascript +( + (script_element + (start_tag + (attribute + (attribute_name) @_no_lang)) + (raw_text) @javascript) + (#not-eq? @_no_lang "lang") ) ( (script_element (start_tag (attribute - (quoted_attribute_value (attribute_value) @_lang))) + (attribute_name) @_lang + (quoted_attribute_value (attribute_value) @_js))) + (raw_text) @javascript) + (#eq? @_lang "lang") + (#eq? @_js "js") +) + +; TODO: When nvim-treesitter have postcss and less parser, use @language and @content instead +( + (style_element + (start_tag + (attribute + (attribute_name) @_lang + (quoted_attribute_value (attribute_value) @_scss))) + (raw_text) @scss) + (#eq? @_lang "lang") + (#any-of? @_scss "scss" "less" "postcss") +) + +( + (script_element + (start_tag + (attribute + (attribute_name) @_lang + (quoted_attribute_value (attribute_value) @_ts))) (raw_text) @typescript) - (#eq? @_lang "ts") + (#eq? @_lang "lang") + (#eq? @_ts "ts") ) ((interpolation From bbd7ecb25d607ce2bfd5294669014ede4669cc19 Mon Sep 17 00:00:00 2001 From: Lucario387 Date: Sat, 24 Dec 2022 16:30:19 +0900 Subject: [PATCH 0046/3010] add test file --- .../injections/vue/test-vue-injections.vue | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/query/injections/vue/test-vue-injections.vue diff --git a/tests/query/injections/vue/test-vue-injections.vue b/tests/query/injections/vue/test-vue-injections.vue new file mode 100644 index 000000000..522dbb392 --- /dev/null +++ b/tests/query/injections/vue/test-vue-injections.vue @@ -0,0 +1,41 @@ + + + + + + From 4bcd3a3cc31b9628a48ff126938262292b1ed988 Mon Sep 17 00:00:00 2001 From: Philip Gaudreau Date: Thu, 22 Dec 2022 14:28:28 -0500 Subject: [PATCH 0047/3010] Fix `update_selection` --- lua/nvim-treesitter/ts_utils.lua | 36 ++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/lua/nvim-treesitter/ts_utils.lua b/lua/nvim-treesitter/ts_utils.lua index 5994e4bcb..3d804ccba 100644 --- a/lua/nvim-treesitter/ts_utils.lua +++ b/lua/nvim-treesitter/ts_utils.lua @@ -259,18 +259,36 @@ end -- @param selection_mode One of "charwise" (default) or "v", "linewise" or "V", -- "blockwise" or "" (as a string with 5 characters or a single character) function M.update_selection(buf, node, selection_mode) - selection_mode = selection_mode or "charwise" local start_row, start_col, end_row, end_col = M.get_vim_range({ M.get_node_range(node) }, buf) + api.nvim_buf_set_mark(0, "<", start_row, start_col - 1, {}) + api.nvim_buf_set_mark(0, ">", end_row, end_col - 1, {}) - -- Start visual selection in appropriate mode local v_table = { charwise = "v", linewise = "V", blockwise = "" } - ---- Call to `nvim_replace_termcodes()` is needed for sending appropriate - ---- command to enter blockwise mode - local mode_string = vim.api.nvim_replace_termcodes(v_table[selection_mode] or selection_mode, true, true, true) - vim.cmd("normal! " .. mode_string) - vim.fn.setpos(".", { buf, start_row, start_col, 0 }) - vim.cmd "normal! o" - vim.fn.setpos(".", { buf, end_row, end_col, 0 }) + selection_mode = selection_mode or "charwise" + + -- Normalise selection_mode + if vim.tbl_contains(vim.tbl_keys(v_table), selection_mode) then + selection_mode = v_table[selection_mode] + end + + -- Call to `nvim_replace_termcodes()` is needed for sending appropriate command to enter blockwise mode + selection_mode = vim.api.nvim_replace_termcodes(selection_mode, true, true, true) + + local previous_mode = vim.fn.visualmode() + + -- visualmode() is set to "" when no visual selection has yet been made. Defaults it to "v" + if previous_mode == "" then + previous_mode = "v" + end + + if previous_mode == selection_mode then + selection_mode = "" + end + + -- "gv": Start Visual mode with the same area as the previous area and the same mode. + -- Hence, area will be what we defined in "<" and ">" marks. We only feed `selection_mode` if it is + -- different than previous `visualmode`, otherwise it will stop visual mode. + api.nvim_feedkeys("gv" .. selection_mode, "x", false) end -- Byte length of node range From 8abb563ca989569fd6778a86bb994291bd342cfc Mon Sep 17 00:00:00 2001 From: Lucario387 Date: Mon, 26 Dec 2022 00:38:57 +0900 Subject: [PATCH 0048/3010] Fix(vue): Invalid match queries --- queries/vue/injections.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/queries/vue/injections.scm b/queries/vue/injections.scm index 71faa74cf..dcb7333db 100644 --- a/queries/vue/injections.scm +++ b/queries/vue/injections.scm @@ -2,7 +2,7 @@ (style_element (start_tag) @_no_attribute (raw_text) @css) - (#match? @_no_attribute "<\\s*style\\s*>") + (#match? @_no_attribute "^\\<\\s*style\\s*\\>$") ) ( @@ -30,7 +30,7 @@ (script_element (start_tag) @_no_attribute (raw_text) @javascript) - (#match? @_no_attribute "<\\s*script\\s*>") + (#match? @_no_attribute "^\\<\\s*script\\s*\\>$") ) ; if start_tag does not specify `lang="..."` then set it to javascript From f5d517f4a71e2570d1d63e7432471972a6b5418e Mon Sep 17 00:00:00 2001 From: Lucario387 Date: Mon, 26 Dec 2022 00:38:57 +0900 Subject: [PATCH 0049/3010] Fix(vue): Invalid match queries --- queries/vue/injections.scm | 1 + .../injections/vue/test-vue-injections.vue | 41 +++++++++++++++---- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/queries/vue/injections.scm b/queries/vue/injections.scm index dcb7333db..223791c09 100644 --- a/queries/vue/injections.scm +++ b/queries/vue/injections.scm @@ -3,6 +3,7 @@ (start_tag) @_no_attribute (raw_text) @css) (#match? @_no_attribute "^\\<\\s*style\\s*\\>$") + ; unsure why, but without escaping < and > the query breaks ) ( diff --git a/tests/query/injections/vue/test-vue-injections.vue b/tests/query/injections/vue/test-vue-injections.vue index 522dbb392..c7442a027 100644 --- a/tests/query/injections/vue/test-vue-injections.vue +++ b/tests/query/injections/vue/test-vue-injections.vue @@ -1,17 +1,17 @@ @@ -19,23 +19,50 @@ const foo = "1" // ^ javascript - + + + From a2d7e78b0714a0dc066416100b7398d3f0941c23 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 25 Dec 2022 16:44:36 +0000 Subject: [PATCH 0050/3010] Update parsers: hlsl --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index 8e48ad7fb..7fd333023 100644 --- a/lockfile.json +++ b/lockfile.json @@ -168,7 +168,7 @@ "revision": "02fa3b79b3ff9a296066da6277adfc3f26cbc9e0" }, "hlsl": { - "revision": "329e3c8bd6f696a6128e0dccba34b2799dc3037e" + "revision": "39c822b795bd6533815d100b5e7d1ec7778a1c2a" }, "hocon": { "revision": "c390f10519ae69fdb03b3e5764f5592fb6924bcc" From cf6056489135f22dfe00b50b34e41439e2ea72dd Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sun, 25 Dec 2022 22:41:59 +0100 Subject: [PATCH 0051/3010] fix: do `vim.treesitter.start()` on highlight module attach Fixes #4026 --- lua/nvim-treesitter/highlight.lua | 38 ++++++++++++++++--------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/lua/nvim-treesitter/highlight.lua b/lua/nvim-treesitter/highlight.lua index 5f7dead61..b97b7a039 100644 --- a/lua/nvim-treesitter/highlight.lua +++ b/lua/nvim-treesitter/highlight.lua @@ -1,7 +1,5 @@ local api = vim.api -local ts = vim.treesitter -local parsers = require "nvim-treesitter.parsers" local configs = require "nvim-treesitter.configs" local M = {} @@ -21,25 +19,11 @@ local function enable_syntax(bufnr) api.nvim_buf_set_option(bufnr, "syntax", "ON") end ----@param bufnr integer -function M.stop(bufnr) - if ts.highlighter.active[bufnr] then - ts.highlighter.active[bufnr]:destroy() - end -end - ----@param bufnr integer ----@param lang string -function M.start(bufnr, lang) - local parser = parsers.get_parser(bufnr, lang) - ts.highlighter.new(parser, {}) -end - ---@param bufnr integer ---@param lang string function M.attach(bufnr, lang) local config = configs.get_module "highlight" - M.start(bufnr, lang) + vim.treesitter.start(bufnr, lang) if config and should_enable_vim_regex(config, lang) then enable_syntax(bufnr) end @@ -47,8 +31,26 @@ end ---@param bufnr integer function M.detach(bufnr) - M.stop(bufnr) + vim.treesitter.stop(bufnr) enable_syntax(bufnr) end +---@deprecated +function M.start(...) + vim.notify( + "`nvim-treesitter.highlight.start` is deprecated: use `nvim-treesitter.highlight.attach` or `vim.treesitter.start`", + vim.log.levels.WARN + ) + M.attach(...) +end + +---@deprecated +function M.stop(...) + vim.notify( + "`nvim-treesitter.highlight.stop` is deprecated: use `nvim-treesitter.highlight.detach` or `vim.treesitter.stop`", + vim.log.levels.WARN + ) + M.detach(...) +end + return M From f0a1c3df2403343bca1f636dfb60c36f7d96627c Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Mon, 26 Dec 2022 15:03:24 +0100 Subject: [PATCH 0052/3010] fix: require_language is needed after installation to update Vim's language table Fixes #4026 --- lua/nvim-treesitter/install.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index 54a813cd4..26524d851 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -387,6 +387,7 @@ local function run_install(cache_folder, install_folder, lang, repo, with_sync, cmd = function() for _, buf in ipairs(vim.api.nvim_list_bufs()) do if parsers.get_buf_lang(buf) == lang then + vim.treesitter.language.require_language(lang) for _, mod in ipairs(require("nvim-treesitter.configs").available_modules()) do require("nvim-treesitter.configs").reattach_module(mod, buf) end From 7c9ddb72d198d45895d73bc7495e1b7e9627f6ca Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Mon, 26 Dec 2022 15:15:06 +0100 Subject: [PATCH 0053/3010] feat: allow hot-reloading parser after installation --- lua/nvim-treesitter/install.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index 26524d851..2942f5117 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -387,6 +387,7 @@ local function run_install(cache_folder, install_folder, lang, repo, with_sync, cmd = function() for _, buf in ipairs(vim.api.nvim_list_bufs()) do if parsers.get_buf_lang(buf) == lang then + vim._ts_remove_language(lang) vim.treesitter.language.require_language(lang) for _, mod in ipairs(require("nvim-treesitter.configs").available_modules()) do require("nvim-treesitter.configs").reattach_module(mod, buf) From 0cb637ca9f4389172933e5aba36387ab8430b6fb Mon Sep 17 00:00:00 2001 From: "Sergio A. Vargas" Date: Tue, 27 Dec 2022 04:27:22 -0500 Subject: [PATCH 0054/3010] julia: update parser and highlights (#4035) - Update patterns for type definitions: The grammar was updated to parse `abstract type` and `primitive type` as a single token. - Update @symbol capture to highlight quoted operators as symbols. - Add pattern to highlight adjoint operator. - Update patterns and captures for: - "keyword" operators (in, isa, where) - type operators (<:, >:) - Parametrized types. --- lockfile.json | 2 +- queries/julia/highlights.scm | 41 ++++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/lockfile.json b/lockfile.json index 7fd333023..0e98edf76 100644 --- a/lockfile.json +++ b/lockfile.json @@ -204,7 +204,7 @@ "revision": "505f5bd90053ae895aa3d6f2bac8071dd9abd8b2" }, "julia": { - "revision": "f254ff9c52e994f629a60821662917d2c6c0e8eb" + "revision": "1cd300bda52e680872053cd55a228c1809cb0c3a" }, "kotlin": { "revision": "b953dbdd05257fcb2b64bc4d9c1578fac12e3c28" diff --git a/queries/julia/highlights.scm b/queries/julia/highlights.scm index 89840dafe..f0b7609f5 100644 --- a/queries/julia/highlights.scm +++ b/queries/julia/highlights.scm @@ -13,7 +13,7 @@ (macro_definition name: (identifier) @function.macro) -(quote_expression ":" (identifier)) @symbol +(quote_expression ":" [(identifier) (operator)]) @symbol (field_expression (identifier) @field .) @@ -71,18 +71,21 @@ ;; Definitions (abstract_definition - name: (identifier) @type.definition) + name: (identifier) @type.definition) @keyword (primitive_definition - name: (identifier) @type.definition) + name: (identifier) @type.definition) @keyword (struct_definition name: (identifier) @type) -(subtype_clause [ - (identifier) @type - (field_expression (identifier) @type .)]) +(type_clause + ["<:" ">:"] @operator + [(identifier) @type + (field_expression (identifier) @type .)]) ;; Annotations -(parametrized_type_expression (_) @type) +(parametrized_type_expression + (_) @type + (curly_expression (_) @type)) (type_parameter_list (identifier) @type) @@ -96,7 +99,9 @@ return_type: (identifier) @type) (where_clause - (identifier) @type) ; where clause without braces + (identifier) @type) +(where_clause + (curly_expression (_) @type)) ;;; Keywords @@ -106,8 +111,6 @@ "local" "macro" "struct" - "type" - "where" ] @keyword "end" @keyword @@ -166,24 +169,30 @@ "return" @keyword.return) [ - "abstract" "const" "mutable" - "primitive" ] @type.qualifier ;;; Operators & Punctuation (operator) @operator -(for_binding ["in" "=" "∈"] @operator) -(range_expression ":" @operator) +(adjoint_expression "'" @operator) +(range_expression ":" @operator) (slurp_parameter "..." @operator) (splat_expression "..." @operator) -"." @operator -["::" "<:"] @operator +((operator) @keyword.operator + (#any-of? @keyword.operator "in" "isa")) + +(for_binding "in" @keyword.operator) +(for_binding ["=" "∈"] @operator) + +(where_clause "where" @keyword.operator) +(where_expression "where" @keyword.operator) + +["." "::"] @operator ["," ";"] @punctuation.delimiter ["(" ")" "[" "]" "{" "}"] @punctuation.bracket From 57e9e48f88acb228e39136cf13fda93a5955be5c Mon Sep 17 00:00:00 2001 From: Jared Moulton Date: Sun, 25 Dec 2022 15:09:16 -0500 Subject: [PATCH 0055/3010] update lockfile (slint) --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index 0e98edf76..5582b92a3 100644 --- a/lockfile.json +++ b/lockfile.json @@ -342,7 +342,7 @@ "revision": "c478c6868648eff49eb04a4df90d703dc45b312a" }, "slint": { - "revision": "d422300f5d6ccce8f9a617dfed57aafb636fadb2" + "revision": "07547525cdf4627343dca5891f1743ae45e879bb" }, "solidity": { "revision": "52ed0880c0126df2f2c7693f215fe6f38e4a2e0a" From 55a9e3bbbc095b49c1b36a0ef1f01b5c7dc09568 Mon Sep 17 00:00:00 2001 From: Jared Moulton Date: Sun, 25 Dec 2022 14:36:28 -0500 Subject: [PATCH 0056/3010] Update slint highlight queries for rewrite --- queries/slint/highlights.scm | 92 ++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/queries/slint/highlights.scm b/queries/slint/highlights.scm index 54dc20369..280e24b08 100644 --- a/queries/slint/highlights.scm +++ b/queries/slint/highlights.scm @@ -1,23 +1,31 @@ - -(user_type_identifier) @type - -(var_identifier) @variable - -(state_identifier) @field - -(var_identifier - (post_identifier) @variable) - -(function_identifier) @function - -(reference_identifier) @keyword -(visibility_modifier) @include - +(identifier) @variable +(type_identifier) @type (comment) @comment +(int_literal) @number +(float_literal) @float +(string_literal) @string +(function_identifier) @function +[ +(image_macro) +(children_macro) +(radial_grad_macro) +(linear_grad_macro) +] @function.macro +(call_expression + function: (identifier) @function.call) +(call_expression + function: (field_expression + field: (identifier) @function.call)) +(vis) @include +(units) @type +(array_literal + (identifier) @type) +(transition_statement state: (identifier) @field) +(state_expression state: (identifier) @field) +(struct_block_definition + (identifier) @field) -(value) @number -(int_number) @number -(string) @string +; (state_identifier) @field [ "in" @@ -39,7 +47,8 @@ [ "root" "parent" -"this" +"duration" +"easing" ] @variable.builtin [ @@ -62,23 +71,25 @@ ] @keyword [ - "black" - "transparent" - "blue" - "ease" - "ease_in" - "ease-in" - "ease_in_out" - "ease-in-out" - "ease_out" - "ease-out" - "end" - "green" - "red" - "red" - "start" - "yellow" - ] @constant.builtin +"black" +"transparent" +"blue" +"ease" +"ease_in" +"ease-in" +"ease_in_out" +"ease-in-out" +"ease_out" +"ease-out" +"end" +"green" +"red" +"red" +"start" +"yellow" +"white" +"gray" +] @constant.builtin ; Punctuation @@ -99,15 +110,13 @@ "}" ] @punctuation.bracket -(property_definition ["<" ">"] @punctuation.bracket) +(define_property ["<" ">"] @punctuation.bracket) [ "angle" "bool" "brush" -; "color" // This causes problems -"duration" -"easing" +"color" "float" "image" "int" @@ -139,8 +148,7 @@ "*=" "/=" "?" - "=>" ] @operator -(ternary_expression [":" "?"] @conditional.ternary) +(ternary_expression [":" "?"] @conditional.ternary) \ No newline at end of file From fa09c1f3ef2128474914ef6d755666fad0dce08b Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Tue, 27 Dec 2022 16:28:56 +0100 Subject: [PATCH 0057/3010] Update slint indent queries --- queries/slint/highlights.scm | 10 +++++----- queries/slint/indents.scm | 13 +++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/queries/slint/highlights.scm b/queries/slint/highlights.scm index 280e24b08..8928bc9a5 100644 --- a/queries/slint/highlights.scm +++ b/queries/slint/highlights.scm @@ -18,11 +18,11 @@ field: (identifier) @function.call)) (vis) @include (units) @type -(array_literal +(array_literal (identifier) @type) (transition_statement state: (identifier) @field) (state_expression state: (identifier) @field) -(struct_block_definition +(struct_block_definition (identifier) @field) ; (state_identifier) @field @@ -35,7 +35,7 @@ "@" @keyword [ -"import" +"import" "from" ] @include @@ -116,7 +116,7 @@ "angle" "bool" "brush" -"color" +"color" "float" "image" "int" @@ -151,4 +151,4 @@ "=>" ] @operator -(ternary_expression [":" "?"] @conditional.ternary) \ No newline at end of file +(ternary_expression [":" "?"] @conditional.ternary) diff --git a/queries/slint/indents.scm b/queries/slint/indents.scm index 30761ef8f..44e426493 100644 --- a/queries/slint/indents.scm +++ b/queries/slint/indents.scm @@ -1,13 +1,14 @@ - [ -(field_declaration_list_body) -(list_definition_body) -(struct_field_declaration_list_body) +(comp_body) +(state_statement) +(transition_statement) +(handler_body) +(consequence_body) +(global_single) ] @indent "}" @indent_end (comment) @auto -(string) @auto - +(string_literal) @auto From 41e013dd9a4d27d0154475318b59fd2ca59cbe3d Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Mon, 26 Dec 2022 13:45:12 +0100 Subject: [PATCH 0058/3010] ci: improve CI output on query error --- scripts/check-queries.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/check-queries.lua b/scripts/check-queries.lua index 083e951ca..c142084de 100755 --- a/scripts/check-queries.lua +++ b/scripts/check-queries.lua @@ -65,8 +65,9 @@ local function do_check() table.insert(timings, { duration = duration, lang = lang, query_type = query_type }) io_print("Checking " .. lang .. " " .. query_type .. string.format(" (%.02fms)", duration * 1e-6)) if not ok then - vim.api.nvim_err_writeln(query) - last_error = query + local err_msg = lang .. " (" .. query_type .. "): " .. query + io_print(err_msg) + last_error = err_msg else if query then for _, capture in ipairs(query.captures) do From fb36ed4c9e962d9fbfa608cd4a5d9313b1e8a8b1 Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 27 Dec 2022 16:53:19 +0000 Subject: [PATCH 0059/3010] Update parsers: tlaplus --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index 5582b92a3..c1bc23c9c 100644 --- a/lockfile.json +++ b/lockfile.json @@ -378,7 +378,7 @@ "revision": "a233ebe360a73a92c50978e5c4e9e471bc59ff42" }, "tlaplus": { - "revision": "27e6d238a5708b0490f43351f6e0baeaab4c9c1f" + "revision": "f2ad7272d145598ff2d27fda15379d26aa33a7e1" }, "todotxt": { "revision": "0207f6a4ab6aeafc4b091914d31d8235049a2578" From e5dd204291d16f1061157711a69884f7a2fe02b1 Mon Sep 17 00:00:00 2001 From: Ananda Umamil Date: Fri, 30 Dec 2022 02:11:49 +0700 Subject: [PATCH 0060/3010] highlights(haskell): lambda and function with type signature --- queries/haskell/highlights.scm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/queries/haskell/highlights.scm b/queries/haskell/highlights.scm index fa342fb8e..297a410da 100644 --- a/queries/haskell/highlights.scm +++ b/queries/haskell/highlights.scm @@ -111,9 +111,12 @@ (function name: (variable) @function patterns: (patterns)) -((signature (fun)) . (function (variable) @function)) -((signature (context (fun))) . (function (variable) @function)) -((signature (forall (context (fun)))) . (function (variable) @function)) +(function + name: (variable) @function + rhs: (exp_lambda)) +((signature (variable) @_type (fun)) . (function (variable) @function) (#eq? @function @_type)) +((signature (variable) @_type (context (fun))) . (function (variable) @function) (#eq? @function @_type)) +((signature (variable) @_type (forall (context (fun)))) . (function (variable) @function) (#eq? @function @_type)) (exp_infix (variable) @operator) ; consider infix functions as operators From c06baac6a19710d41ca871d5dc030fd986958bfd Mon Sep 17 00:00:00 2001 From: GitHub Date: Thu, 29 Dec 2022 20:05:30 +0000 Subject: [PATCH 0061/3010] Update parsers: astro, ocaml, ocaml_interface --- lockfile.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lockfile.json b/lockfile.json index c1bc23c9c..bb4e18ade 100644 --- a/lockfile.json +++ b/lockfile.json @@ -9,7 +9,7 @@ "revision": "c473c09f23b13d9404ec5208fad3eddea89d70f8" }, "astro": { - "revision": "22697b0e2413464b7abaea9269c5e83a59e39a83" + "revision": "a1f66bf72ed68b87f779bce9a52e5c6521fc867e" }, "awk": { "revision": "e559793754c60c2cdf00cbb0409842d75f0a41dc" @@ -258,10 +258,10 @@ "revision": "8ad20059c6f128861c4506fff866150ffee1d6f4" }, "ocaml": { - "revision": "de07323343946c32759933cb3b7c78e821098cad" + "revision": "f1106bf834703f1f2f795da1a3b5f8f40174ffcc" }, "ocaml_interface": { - "revision": "de07323343946c32759933cb3b7c78e821098cad" + "revision": "f1106bf834703f1f2f795da1a3b5f8f40174ffcc" }, "ocamllex": { "revision": "ac1d5957e719d49bd6acd27439b79843e4daf8ed" From ee3e9f4dc0e5ee9e2bfb1ee47638375840b8fe0f Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Fri, 2 Dec 2022 23:47:19 +0100 Subject: [PATCH 0062/3010] feat(hcl,terraform): split terraform from hcl, add specialized queries for tf This enables us to have different queries for terraform and general hcl. It solve the situation where other dialects of hcl (nomad, packer, etc) might use a terraform keyword and get highlighted out of place. --- README.md | 1 + lockfile.json | 3 +++ lua/nvim-treesitter/parsers.lua | 12 ++++++++++- queries/hcl/highlights.scm | 15 ++++++------- queries/terraform/folds.scm | 1 + queries/terraform/highlights.scm | 21 +++++++++++++++++++ queries/terraform/indents.scm | 1 + queries/terraform/injections.scm | 1 + .../{hcl => terraform}/function_call.tf | 0 .../indent-in-multiline-objects.tf | 0 .../indent-in-multiline-tuples.tf | 0 .../{hcl => terraform}/multiline-comments.tf | 0 .../{hcl => terraform}/multiple-attributes.tf | 0 .../{hcl => terraform}/multiple-blocks.tf | 0 .../{hcl => terraform}/nested_blocks.tf | 0 .../no-indent-after-brace.tf | 0 .../{hcl_spec.lua => terraform_spec.lua} | 4 ++-- 17 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 queries/terraform/folds.scm create mode 100644 queries/terraform/highlights.scm create mode 100644 queries/terraform/indents.scm create mode 100644 queries/terraform/injections.scm rename tests/indent/{hcl => terraform}/function_call.tf (100%) rename tests/indent/{hcl => terraform}/indent-in-multiline-objects.tf (100%) rename tests/indent/{hcl => terraform}/indent-in-multiline-tuples.tf (100%) rename tests/indent/{hcl => terraform}/multiline-comments.tf (100%) rename tests/indent/{hcl => terraform}/multiple-attributes.tf (100%) rename tests/indent/{hcl => terraform}/multiple-blocks.tf (100%) rename tests/indent/{hcl => terraform}/nested_blocks.tf (100%) rename tests/indent/{hcl => terraform}/no-indent-after-brace.tf (100%) rename tests/indent/{hcl_spec.lua => terraform_spec.lua} (95%) diff --git a/README.md b/README.md index 40aa11d6a..2f210f718 100644 --- a/README.md +++ b/README.md @@ -296,6 +296,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [swift](https://github.com/alex-pinkus/tree-sitter-swift) (maintained by @alex-pinkus) - [x] [sxhkdrc](https://github.com/RaafatTurki/tree-sitter-sxhkdrc) (maintained by @RaafatTurki) - [x] [teal](https://github.com/euclidianAce/tree-sitter-teal) (maintained by @euclidianAce) +- [x] [terraform](https://github.com/MichaHoffmann/tree-sitter-hcl) (maintained by @MichaHoffmann) - [x] [tiger](https://github.com/ambroisie/tree-sitter-tiger) (maintained by @ambroisie) - [x] [tlaplus](https://github.com/tlaplus-community/tree-sitter-tlaplus) (maintained by @ahelwer, @susliko) - [x] [todotxt](https://github.com/arnarg/tree-sitter-todotxt.git) (experimental, maintained by @arnarg) diff --git a/lockfile.json b/lockfile.json index bb4e18ade..97aad4ec5 100644 --- a/lockfile.json +++ b/lockfile.json @@ -374,6 +374,9 @@ "teal": { "revision": "1ae8c68e90523b26b93af56feb7868fe4214e2b2" }, + "terraform": { + "revision": "0ff887f2a60a147452d52db060de6b42f42f1441" + }, "tiger": { "revision": "a233ebe360a73a92c50978e5c4e9e471bc59ff42" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index f4e13974b..6bd94f93b 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -8,7 +8,6 @@ local filetype_to_parsername = { PKGBUILD = "bash", html_tags = "html", ["typescript.tsx"] = "tsx", - terraform = "hcl", ["html.handlebars"] = "glimmer", systemverilog = "verilog", cls = "latex", @@ -618,6 +617,17 @@ list.hcl = { filetype = "hcl", } +list.terraform = { + install_info = { + url = "https://github.com/MichaHoffmann/tree-sitter-hcl", + files = { "src/parser.c", "src/scanner.cc" }, + branch = "main", + location = "dialects/terraform", + }, + maintainers = { "@MichaHoffmann" }, + filetype = "terraform", +} + list.markdown = { install_info = { url = "https://github.com/MDeiml/tree-sitter-markdown", diff --git a/queries/hcl/highlights.scm b/queries/hcl/highlights.scm index 658369292..4f2eb2300 100644 --- a/queries/hcl/highlights.scm +++ b/queries/hcl/highlights.scm @@ -81,7 +81,8 @@ (comment) @comment @spell (identifier) @variable -(block (identifier) @type) +(body (block (identifier) @keyword)) +(body (block (body (block (identifier) @type)))) (function_call (identifier) @function) (attribute (identifier) @field) @@ -90,13 +91,9 @@ ; highlight identifier keys as though they were block attributes (object_elem key: (expression (variable_expr (identifier) @field))) -((identifier) @keyword (#any-of? @keyword "module" "root" "cwd" "resource" "variable" "data" "locals" "terraform" "provider" "output")) -((identifier) @type.builtin (#any-of? @type.builtin "bool" "string" "number" "object" "tuple" "list" "map" "set" "any")) -(variable_expr (identifier) @variable.builtin (#any-of? @variable.builtin "var" "local" "path")) -(get_attr (identifier) @variable.builtin (#any-of? @variable.builtin "root" "cwd" "module")) - -(object_elem val: (expression - (variable_expr - (identifier) @type.builtin (#any-of? @type.builtin "bool" "string" "number" "object" "tuple" "list" "map" "set" "any")))) +; var.foo, data.bar +; +; first element in get_attr is a keyword or a reference to a keyword +(expression (variable_expr (identifier) @keyword) (get_attr (identifier) @field)) (ERROR) @error diff --git a/queries/terraform/folds.scm b/queries/terraform/folds.scm new file mode 100644 index 000000000..0e5ffc2db --- /dev/null +++ b/queries/terraform/folds.scm @@ -0,0 +1 @@ +; inherits: hcl diff --git a/queries/terraform/highlights.scm b/queries/terraform/highlights.scm new file mode 100644 index 000000000..d31b83c82 --- /dev/null +++ b/queries/terraform/highlights.scm @@ -0,0 +1,21 @@ +; inherits: hcl + +; Terraform specific references +; +; +; local/module/data/var/output +(expression (variable_expr (identifier) @type.builtin (#any-of? @type.builtin "data" "var" "local" "module" "output")) (get_attr (identifier) @field)) + +; path.root/cwd/module +(expression (variable_expr (identifier) @type.builtin (#eq? @type.builtin "path")) (get_attr (identifier) @variable.builtin (#any-of? @variable.builtin "root" "cwd" "module"))) + +; terraform.workspace +(expression (variable_expr (identifier) @type.builtin (#eq? @type.builtin "terraform")) (get_attr (identifier) @variable.builtin (#any-of? @variable.builtin "workspace"))) + +; Terraform specific keywords + +; FIXME: ideally only for identifiers under a `variable` block to minimize false positives +((identifier) @type.builtin (#any-of? @type.builtin "bool" "string" "number" "object" "tuple" "list" "map" "set" "any")) +(object_elem val: (expression + (variable_expr + (identifier) @type.builtin (#any-of? @type.builtin "bool" "string" "number" "object" "tuple" "list" "map" "set" "any")))) diff --git a/queries/terraform/indents.scm b/queries/terraform/indents.scm new file mode 100644 index 000000000..0e5ffc2db --- /dev/null +++ b/queries/terraform/indents.scm @@ -0,0 +1 @@ +; inherits: hcl diff --git a/queries/terraform/injections.scm b/queries/terraform/injections.scm new file mode 100644 index 000000000..0e5ffc2db --- /dev/null +++ b/queries/terraform/injections.scm @@ -0,0 +1 @@ +; inherits: hcl diff --git a/tests/indent/hcl/function_call.tf b/tests/indent/terraform/function_call.tf similarity index 100% rename from tests/indent/hcl/function_call.tf rename to tests/indent/terraform/function_call.tf diff --git a/tests/indent/hcl/indent-in-multiline-objects.tf b/tests/indent/terraform/indent-in-multiline-objects.tf similarity index 100% rename from tests/indent/hcl/indent-in-multiline-objects.tf rename to tests/indent/terraform/indent-in-multiline-objects.tf diff --git a/tests/indent/hcl/indent-in-multiline-tuples.tf b/tests/indent/terraform/indent-in-multiline-tuples.tf similarity index 100% rename from tests/indent/hcl/indent-in-multiline-tuples.tf rename to tests/indent/terraform/indent-in-multiline-tuples.tf diff --git a/tests/indent/hcl/multiline-comments.tf b/tests/indent/terraform/multiline-comments.tf similarity index 100% rename from tests/indent/hcl/multiline-comments.tf rename to tests/indent/terraform/multiline-comments.tf diff --git a/tests/indent/hcl/multiple-attributes.tf b/tests/indent/terraform/multiple-attributes.tf similarity index 100% rename from tests/indent/hcl/multiple-attributes.tf rename to tests/indent/terraform/multiple-attributes.tf diff --git a/tests/indent/hcl/multiple-blocks.tf b/tests/indent/terraform/multiple-blocks.tf similarity index 100% rename from tests/indent/hcl/multiple-blocks.tf rename to tests/indent/terraform/multiple-blocks.tf diff --git a/tests/indent/hcl/nested_blocks.tf b/tests/indent/terraform/nested_blocks.tf similarity index 100% rename from tests/indent/hcl/nested_blocks.tf rename to tests/indent/terraform/nested_blocks.tf diff --git a/tests/indent/hcl/no-indent-after-brace.tf b/tests/indent/terraform/no-indent-after-brace.tf similarity index 100% rename from tests/indent/hcl/no-indent-after-brace.tf rename to tests/indent/terraform/no-indent-after-brace.tf diff --git a/tests/indent/hcl_spec.lua b/tests/indent/terraform_spec.lua similarity index 95% rename from tests/indent/hcl_spec.lua rename to tests/indent/terraform_spec.lua index ee53d89fc..49fa22c20 100644 --- a/tests/indent/hcl_spec.lua +++ b/tests/indent/terraform_spec.lua @@ -1,13 +1,13 @@ local Runner = require("tests.indent.common").Runner --local XFAIL = require("tests.indent.common").XFAIL -local run = Runner:new(it, "tests/indent/hcl", { +local run = Runner:new(it, "tests/indent/terraform", { tabstop = 2, shiftwidth = 2, expandtab = true, }) -describe("indent HCL:", function() +describe("indent Terraform:", function() describe("whole file:", function() run:whole_file(".", { expected_failures = {}, From f00d610256b63cef3e35af2cbaf45212625b4cc5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 31 Dec 2022 10:21:11 +0000 Subject: [PATCH 0063/3010] Update parsers: qmljs (#4064) Co-authored-by: GitHub --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index 97aad4ec5..6c0e0290a 100644 --- a/lockfile.json +++ b/lockfile.json @@ -300,7 +300,7 @@ "revision": "bd087020f0d8c183080ca615d38de0ec827aeeaf" }, "qmljs": { - "revision": "0b2b25bcaa7d4925d5f0dda16f6a99c588a437f1" + "revision": "ab75be9750e6f2f804638824d1790034286a830c" }, "query": { "revision": "0717de07078a20a8608c98ad5f26c208949d0e15" From ae5ab287bbffc06f10e45d1e590d25fcf7f003d9 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sat, 31 Dec 2022 13:44:53 +0100 Subject: [PATCH 0064/3010] docs: link to Matrix instead of Zulip --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2f210f718..9c10ef064 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@

nvim-treesitter

- - Zulip Chat + + Matrix Chat Linting and Style From 58c0d78de8d4fee3742381d77173ea50e828b47b Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sat, 29 Oct 2022 22:53:01 -0300 Subject: [PATCH 0065/3010] r: update highlights --- queries/r/highlights.scm | 35 +++++++++++++++++------- tests/query/highlights/r/test.r | 47 +++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 tests/query/highlights/r/test.r diff --git a/queries/r/highlights.scm b/queries/r/highlights.scm index 179200d34..01d089559 100755 --- a/queries/r/highlights.scm +++ b/queries/r/highlights.scm @@ -17,10 +17,25 @@ (identifier) @variable +((dollar (identifier) @variable.builtin) + (#eq? @variable.builtin "self")) + +((dollar _ (identifier) @field)) + +; Parameters + (formal_parameters (identifier) @parameter) + (formal_parameters (default_parameter name: (identifier) @parameter)) +(default_argument name: (identifier) @parameter) + +; Namespace + +(namespace_get namespace: (identifier) @namespace) +(namespace_get_internal namespace: (identifier) @namespace) + ; Operators [ "=" @@ -34,6 +49,7 @@ "+" "!" "~" + "?" ] @operator) (binary operator: [ @@ -90,7 +106,7 @@ (nan) (na) (null) -] @type.builtin +] @constant.builtin [ "if" @@ -111,17 +127,18 @@ "function" @keyword.function -(call function: (identifier) @function) -(default_argument name: (identifier) @parameter) +; Functions/Methos -(namespace_get function: (identifier) @method) -(namespace_get_internal function: (identifier) @method) +(call function: (identifier) @function.call) -(namespace_get namespace: (identifier) @namespace - "::" @operator) +(call + (namespace_get function: (identifier) @function.call)) -(namespace_get_internal namespace: (identifier) @namespace - ":::" @operator) +(call + (namespace_get_internal function: (identifier) @function.call)) + +(call + function: ((dollar _ (identifier) @method.call))) ; Error (ERROR) @error diff --git a/tests/query/highlights/r/test.r b/tests/query/highlights/r/test.r new file mode 100644 index 000000000..8daf704ea --- /dev/null +++ b/tests/query/highlights/r/test.r @@ -0,0 +1,47 @@ +init <- 1 +# ^ @variable +# ^ @operator +# ^ @float + +r"{(\1\2)}" -> `%r%` +# ^ @string +# ^ @string.escape +# ^ @operator +# ^ @variable + + +foo <- c(1L, 2L) +# ^ @function.call +# ^ @number + +b <- list(TRUE, FALSE, NA, Inf) +# ^ @boolean +# ^ @boolean +# ^ @constant.builtin +# ^ @constant.builtin + +b <- list(name = "r", version = R.version$major) +# ^ @parameter +# ^ @string +# ^ @punctuation.special +# ^ @field + +Lang$new(name = "r")$print() +# ^ @method.call + +for(i in 1:10) { +# <- @repeat +# ^ @keyword +} + +add <- function(a, b = 1, ...) { +# ^ @keyword.function +# ^ @parameter +# ^ @parameter +# ^ @keyword + return(a + b) +} + +base::letters +# ^ @namespace +# ^ @variable From 966393dc38ddc8fd9af8bd5f987493fd83b9af35 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sat, 29 Oct 2022 23:09:50 -0300 Subject: [PATCH 0066/3010] r: move inf to constant.builtin --- queries/r/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries/r/highlights.scm b/queries/r/highlights.scm index 01d089559..e2a9da8c0 100755 --- a/queries/r/highlights.scm +++ b/queries/r/highlights.scm @@ -99,13 +99,13 @@ (dots) (break) (next) - (inf) ] @keyword [ (nan) (na) (null) + (inf) ] @constant.builtin [ From ec3d4af1045f403c2e7f45d3df8b5db0b1658739 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Tue, 29 Nov 2022 13:54:07 -0300 Subject: [PATCH 0067/3010] fix test --- queries/r/highlights.scm | 2 +- tests/query/highlights/r/test.r | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/queries/r/highlights.scm b/queries/r/highlights.scm index e2a9da8c0..07fdde88c 100755 --- a/queries/r/highlights.scm +++ b/queries/r/highlights.scm @@ -88,7 +88,7 @@ "}" ] @punctuation.bracket -(dollar "$" @operator) +(dollar _ "$" @operator) (subset2 "[[" @punctuation.bracket diff --git a/tests/query/highlights/r/test.r b/tests/query/highlights/r/test.r index 8daf704ea..5568b61b5 100644 --- a/tests/query/highlights/r/test.r +++ b/tests/query/highlights/r/test.r @@ -23,7 +23,7 @@ b <- list(TRUE, FALSE, NA, Inf) b <- list(name = "r", version = R.version$major) # ^ @parameter # ^ @string -# ^ @punctuation.special +# ^ @operator # ^ @field Lang$new(name = "r")$print() From 6d2b0bd381428f5e550234dd058215502baeb3ab Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Tue, 29 Nov 2022 14:07:39 -0300 Subject: [PATCH 0068/3010] move 'in' to repeat --- queries/r/highlights.scm | 2 +- tests/query/highlights/r/test.r | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/queries/r/highlights.scm b/queries/r/highlights.scm index 07fdde88c..c65d766bf 100755 --- a/queries/r/highlights.scm +++ b/queries/r/highlights.scm @@ -95,7 +95,6 @@ "]]" @punctuation.bracket) [ - "in" (dots) (break) (next) @@ -118,6 +117,7 @@ "while" "repeat" "for" + "in" ] @repeat [ diff --git a/tests/query/highlights/r/test.r b/tests/query/highlights/r/test.r index 5568b61b5..b6bfd1ff5 100644 --- a/tests/query/highlights/r/test.r +++ b/tests/query/highlights/r/test.r @@ -31,7 +31,7 @@ Lang$new(name = "r")$print() for(i in 1:10) { # <- @repeat -# ^ @keyword +# ^ @repeat } add <- function(a, b = 1, ...) { From c2301adfcbf1f918e0aa549fd4581f213f0ca064 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Mon, 26 Dec 2022 15:35:29 +0100 Subject: [PATCH 0069/3010] highlights(cuda): add missing `"__global__"` --- queries/cuda/highlights.scm | 1 + 1 file changed, 1 insertion(+) diff --git a/queries/cuda/highlights.scm b/queries/cuda/highlights.scm index 20a753be3..e5eada37f 100644 --- a/queries/cuda/highlights.scm +++ b/queries/cuda/highlights.scm @@ -5,6 +5,7 @@ [ "__host__" "__device__" + "__global__" "__forceinline__" ] @storageclass From 0598450eb80af38dbd071953f047afa0b574986f Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Tue, 27 Dec 2022 12:35:43 +0100 Subject: [PATCH 0070/3010] feat: also reload parsers after uninstallation --- lua/nvim-treesitter/install.lua | 35 ++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index 2942f5117..1b16d5e01 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -42,6 +42,26 @@ local function get_job_status() .. "]" end +---@param lang string +---@return function +local function reattach_if_possible_fn(lang) + return function() + for _, buf in ipairs(vim.api.nvim_list_bufs()) do + if parsers.get_buf_lang(buf) == lang then + vim._ts_remove_language(lang) + local ok = pcall(vim.treesitter.language.require_language, lang) + for _, mod in ipairs(require("nvim-treesitter.configs").available_modules()) do + if ok then + require("nvim-treesitter.configs").reattach_module(mod, buf) + else + require("nvim-treesitter.configs").detach_module(mod, buf) + end + end + end + end + end +end + ---@param lang string ---@param validate boolean|nil ---@return InstallInfo @@ -384,17 +404,7 @@ local function run_install(cache_folder, install_folder, lang, repo, with_sync, end, }, { -- auto-attach modules after installation - cmd = function() - for _, buf in ipairs(vim.api.nvim_list_bufs()) do - if parsers.get_buf_lang(buf) == lang then - vim._ts_remove_language(lang) - vim.treesitter.language.require_language(lang) - for _, mod in ipairs(require("nvim-treesitter.configs").available_modules()) do - require("nvim-treesitter.configs").reattach_module(mod, buf) - end - end - end - end, + cmd = reattach_if_possible_fn(lang), }, }) if not from_local_path then @@ -594,6 +604,9 @@ function M.uninstall(...) end end, }, + { -- auto-reattach or detach modules after uninstallation + cmd = reattach_if_possible_fn(lang), + }, } M.iter_cmd(command_list, 1, lang, "Treesitter parser for " .. lang .. " has been uninstalled") elseif #all_parsers > 0 then From 29304e16bbb74559a22cb78ef7c59f086a9cc9e2 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Tue, 27 Dec 2022 20:39:33 +0100 Subject: [PATCH 0071/3010] fix: show errors when reload after installation fails --- lua/nvim-treesitter/configs.lua | 4 ++-- lua/nvim-treesitter/install.lua | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua index 0b9eaa512..87f930b8f 100644 --- a/lua/nvim-treesitter/configs.lua +++ b/lua/nvim-treesitter/configs.lua @@ -232,7 +232,7 @@ end ---Recurses through all modules including submodules ---@param accumulator function called for each module ----@param root {[string]: TSModule} root configuration table to start at +---@param root {[string]: TSModule}|nil root configuration table to start at ---@param path string|nil prefix path local function recurse_modules(accumulator, root, path) root = root or config.modules @@ -529,7 +529,7 @@ function M.reattach_module(mod_name, bufnr, lang) end ---Gets available modules ----@param root {[string]:TSModule} table to find modules +---@param root {[string]:TSModule}|nil table to find modules function M.available_modules(root) local modules = {} diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index 1b16d5e01..c0128130b 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -44,15 +44,18 @@ end ---@param lang string ---@return function -local function reattach_if_possible_fn(lang) +local function reattach_if_possible_fn(lang, error_on_fail) return function() for _, buf in ipairs(vim.api.nvim_list_bufs()) do if parsers.get_buf_lang(buf) == lang then vim._ts_remove_language(lang) - local ok = pcall(vim.treesitter.language.require_language, lang) + local ok, err = pcall(vim.treesitter.language.require_language, lang) + if not ok and error_on_fail then + vim.notify("Could not load parser for " .. lang .. ": " .. vim.inspect(err)) + end for _, mod in ipairs(require("nvim-treesitter.configs").available_modules()) do if ok then - require("nvim-treesitter.configs").reattach_module(mod, buf) + require("nvim-treesitter.configs").reattach_module(mod, buf, lang) else require("nvim-treesitter.configs").detach_module(mod, buf) end @@ -404,7 +407,7 @@ local function run_install(cache_folder, install_folder, lang, repo, with_sync, end, }, { -- auto-attach modules after installation - cmd = reattach_if_possible_fn(lang), + cmd = reattach_if_possible_fn(lang, true), }, }) if not from_local_path then @@ -605,7 +608,7 @@ function M.uninstall(...) end, }, { -- auto-reattach or detach modules after uninstallation - cmd = reattach_if_possible_fn(lang), + cmd = reattach_if_possible_fn(lang, false), }, } M.iter_cmd(command_list, 1, lang, "Treesitter parser for " .. lang .. " has been uninstalled") From 817531ce6f0c7a6236e08aec435e9655e5835afb Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sun, 25 Dec 2022 17:40:05 +0100 Subject: [PATCH 0072/3010] parsers: add wgsl_bevy This adds an extension of tree-sitter-wgsl that understands [Bevy's](https://bevyengine.org/) preprocessor directives. --- lua/nvim-treesitter/parsers.lua | 9 +++++++++ queries/wgsl_bevy/folds.scm | 5 +++++ queries/wgsl_bevy/highlights.scm | 25 +++++++++++++++++++++++++ queries/wgsl_bevy/indents.scm | 7 +++++++ 4 files changed, 46 insertions(+) create mode 100644 queries/wgsl_bevy/folds.scm create mode 100644 queries/wgsl_bevy/highlights.scm create mode 100644 queries/wgsl_bevy/indents.scm diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 6bd94f93b..0194f776c 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1183,6 +1183,15 @@ list.wgsl = { filetype = "wgsl", } +list.wgsl_bevy = { + install_info = { + url = "https://github.com/theHamsta/tree-sitter-wgsl-bevy", + files = { "src/parser.c" }, + generate_requires_npm = true, + }, + maintainers = { "@theHamsta" }, +} + list.m68k = { install_info = { url = "https://github.com/grahambates/tree-sitter-m68k", diff --git a/queries/wgsl_bevy/folds.scm b/queries/wgsl_bevy/folds.scm new file mode 100644 index 000000000..7d2547fa0 --- /dev/null +++ b/queries/wgsl_bevy/folds.scm @@ -0,0 +1,5 @@ +; inherits wgsl + +[ + (preproc_ifdef) +] @fold diff --git a/queries/wgsl_bevy/highlights.scm b/queries/wgsl_bevy/highlights.scm new file mode 100644 index 000000000..2b33eff66 --- /dev/null +++ b/queries/wgsl_bevy/highlights.scm @@ -0,0 +1,25 @@ +; inherits wgsl + +[ + "#import" + "#define_import_path" +] @include +"::" @punctuation.delimiter + +(import_path (identifier) @namespace (identifier)) + +(struct_declaration + (preproc_ifdef (struct_member (variable_identifier_declaration (identifier) @field)))) +(struct_declaration + (preproc_ifdef + (preproc_else (struct_member (variable_identifier_declaration (identifier) @field))))) + +(preproc_ifdef + name: (identifier) @constant.macro) + +[ + "#ifdef" + "#ifndef" + "#endif" + "#else" +] @preproc diff --git a/queries/wgsl_bevy/indents.scm b/queries/wgsl_bevy/indents.scm new file mode 100644 index 000000000..84d1845c0 --- /dev/null +++ b/queries/wgsl_bevy/indents.scm @@ -0,0 +1,7 @@ +; inherits wgsl +[ + "#ifdef" + "#ifndef" + "#else" + "#endif" +] @zero_indent From 5afa9e50407c137c61082627a4456ab99cfbed18 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sat, 24 Dec 2022 17:01:23 +0100 Subject: [PATCH 0073/3010] highlights(wgsl): highlight "->" for return types as `@punctuation.delimiter` --- queries/wgsl/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries/wgsl/highlights.scm b/queries/wgsl/highlights.scm index c9ab0668f..0411880d7 100644 --- a/queries/wgsl/highlights.scm +++ b/queries/wgsl/highlights.scm @@ -50,7 +50,7 @@ "return" @keyword.return -[ "," "." ":" ";" ] @punctuation.delimiter +[ "," "." ":" ";" "->" ] @punctuation.delimiter ["(" ")" "[" "]" "{" "}"] @punctuation.bracket From 168567efb8aa3874f3da8832dbcd3d1a4ff40d3b Mon Sep 17 00:00:00 2001 From: GitHub Date: Sat, 31 Dec 2022 14:21:00 +0000 Subject: [PATCH 0074/3010] Update parsers: wgsl_bevy"] --- lockfile.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lockfile.json b/lockfile.json index 6c0e0290a..87416e4ef 100644 --- a/lockfile.json +++ b/lockfile.json @@ -422,6 +422,9 @@ "wgsl": { "revision": "61d2604525d47238ecbce8aa38f10cb81ba68fd3" }, + "wgsl_bevy": { + "revision": "c81dc770310795caea5e00996505deba024ec698" + }, "yaml": { "revision": "0e36bed171768908f331ff7dff9d956bae016efb" }, From b019eb30323635d680aa2f32e498a1831676ebb1 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Mon, 26 Dec 2022 16:47:30 +0100 Subject: [PATCH 0075/3010] indents(c): treat `"#ifndef"`, `"#elif"` like `"#ifdef"` --- queries/c/indents.scm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/queries/c/indents.scm b/queries/c/indents.scm index 1931471b9..661ae8228 100644 --- a/queries/c/indents.scm +++ b/queries/c/indents.scm @@ -31,6 +31,8 @@ [ "#define" "#ifdef" + "#ifndef" + "#elif" "#if" "#else" "#endif" From 4f3aa2af446ed31c9e8cd4ab7757883f825d448b Mon Sep 17 00:00:00 2001 From: Ananda Umamil Date: Sun, 1 Jan 2023 03:22:36 +0700 Subject: [PATCH 0076/3010] highlights(elm): improve highlights --- queries/elm/highlights.scm | 190 ++++++++++++++++++++++++++++--------- 1 file changed, 146 insertions(+), 44 deletions(-) diff --git a/queries/elm/highlights.scm b/queries/elm/highlights.scm index 63514eb3e..61601c442 100644 --- a/queries/elm/highlights.scm +++ b/queries/elm/highlights.scm @@ -1,12 +1,18 @@ -[(line_comment) (block_comment)] @comment +[ + (line_comment) + (block_comment) +] @comment + ; Keywords +;--------- + [ - "if" - "then" - "else" - (case) - (of) + "if" + "then" + "else" + (case) + (of) ] @conditional [ @@ -14,18 +20,28 @@ "in" (as) (port) - (exposing) (alias) (infix) (module) + (type) ] @keyword +[ + (import) + (exposing) +] @include + + +; Punctuation +;------------ + [ (double_dot) - "|" ] @punctuation.special + [ "," + "|" (dot) ] @punctuation.delimiter @@ -34,65 +50,151 @@ ")" "{" "}" + "[" + "]" ] @punctuation.bracket + +; Variables +;---------- + +(value_qid + (lower_case_identifier) @variable) +(value_declaration + (function_declaration_left (lower_case_identifier) @variable)) (type_annotation - (lower_case_identifier) @function) + (lower_case_identifier) @variable) (port_annotation - (lower_case_identifier) @function) + (lower_case_identifier) @variable) +(anything_pattern + (underscore) @variable) +(record_base_identifier + (lower_case_identifier) @variable) +(lower_pattern + (lower_case_identifier) @variable) +(exposed_value + (lower_case_identifier) @variable) + +(value_qid + ((dot) (lower_case_identifier) @field)) +(field_access_expr + ((dot) (lower_case_identifier) @field)) + (function_declaration_left - (lower_case_identifier) @function) + (anything_pattern (underscore) @parameter)) +(function_declaration_left + (lower_pattern (lower_case_identifier) @parameter)) + + +; Functions +;---------- + +(value_declaration + functionDeclarationLeft: + (function_declaration_left + (lower_case_identifier) @function + (pattern))) +(value_declaration + functionDeclarationLeft: + (function_declaration_left + (lower_case_identifier) @function + pattern: (_))) +(value_declaration + functionDeclarationLeft: + (function_declaration_left + (lower_case_identifier) @function) + body: (anonymous_function_expr)) +(type_annotation + name: (lower_case_identifier) @function + typeExpression: (type_expression (arrow))) +(port_annotation + name: (lower_case_identifier) @function + typeExpression: (type_expression (arrow))) + (function_call_expr - target: (value_expr) @function) + target: (value_expr + (value_qid (lower_case_identifier) @function.call))) -(value_qid (upper_case_identifier) @constructor) -(value_qid ((dot) (lower_case_identifier) @field)) -(field_access_expr ((dot) (lower_case_identifier) @field)) -(lower_pattern) @parameter -(record_base_identifier) @method - -[ - (backslash) - (underscore) -] @function +; Operators +;---------- [ (operator_identifier) (eq) (colon) (arrow) + (backslash) + "::" ] @operator -(import) @include -(number_constant_expr) @number - -(type) @keyword +; Modules +;-------- (module_declaration - (upper_case_qid (upper_case_identifier)) @constructor) -(type_declaration - (upper_case_identifier) @constructor) -(type_ref) @type -(type_alias_declaration - name: (upper_case_identifier) @type.definition) -(field_type name: - (lower_case_identifier) @property) - -(union_variant - (upper_case_identifier) @symbol) -(union_pattern) @symbol + (upper_case_qid (upper_case_identifier) @namespace)) +(import_clause + (upper_case_qid (upper_case_identifier) @namespace)) +(as_clause + (upper_case_identifier) @namespace) (value_expr - (upper_case_qid (upper_case_identifier)) @symbol) + (value_qid (upper_case_identifier) @namespace)) -; strings -(string_escape) @string -(open_quote) @string -(close_quote) @string -(regular_string_part) @string + +; Types +;------ + +(type_declaration + (upper_case_identifier) @type) +(type_ref + (upper_case_qid (upper_case_identifier) @type)) +(type_variable + (lower_case_identifier) @type) +(lower_type_name + (lower_case_identifier) @type) +(exposed_type + (upper_case_identifier) @type) + +(type_alias_declaration + (upper_case_identifier) @type.definition) + +(field_type + name: (lower_case_identifier) @property) +(field + name: (lower_case_identifier) @property) + +(type_declaration + (union_variant (upper_case_identifier) @constructor)) +(union_pattern + (upper_case_qid (upper_case_identifier) @constructor)) +(value_expr + (upper_case_qid (upper_case_identifier)) @constructor) + + +; Literals +;--------- + +(number_constant_expr + (number_literal) @number) + +(upper_case_qid + ((upper_case_identifier) @_bool (#match? @_bool "(True|False)")) @boolean) + +[ + (open_quote) + (close_quote) +] @string +(string_constant_expr + (string_escape) @string) +(string_constant_expr + (regular_string_part) @string) [ (open_char) (close_char) ] @character +(char_constant_expr + (string_escape) @character) +(char_constant_expr + (regular_string_part) @character) From ab414f8b1c84d8d321f6a56a080132c9f1ce5c0c Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sun, 1 Jan 2023 15:15:40 +0100 Subject: [PATCH 0077/3010] ci: allow negative assertions in tests --- .github/workflows/tests.yml | 2 +- tests/query/highlights/rust/super-crate-imports.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/query/highlights/rust/super-crate-imports.rs diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8e4551bf7..4c807cdcb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -35,7 +35,7 @@ jobs: mkdir -p ~/.local/share/nvim/site/pack/plenary.nvim/start cd ~/.local/share/nvim/site/pack/plenary.nvim/start git clone https://github.com/nvim-lua/plenary.nvim - curl -L https://github.com/theHamsta/highlight-assertions/releases/download/v0.1.5/highlight-assertions_v0.1.5_x86_64-unknown-linux-gnu.tar.gz | tar -xz + curl -L https://github.com/theHamsta/highlight-assertions/releases/download/v0.1.6/highlight-assertions_v0.1.6_x86_64-unknown-linux-gnu.tar.gz | tar -xz cp highlight-assertions /usr/local/bin - name: Install and prepare Neovim diff --git a/tests/query/highlights/rust/super-crate-imports.rs b/tests/query/highlights/rust/super-crate-imports.rs new file mode 100644 index 000000000..49a0c2918 --- /dev/null +++ b/tests/query/highlights/rust/super-crate-imports.rs @@ -0,0 +1,12 @@ +use crate::a; +// ^ namespace +// ^ !keyword +use crate::{b, c}; +// ^ namespace +// ^ !keyword +use super::a; +// ^ namespace +// ^ !keyword +use super::{b, c}; +// ^ namespace +// ^ !keyword From 6a31d9086e38bde36415c736ed189747971cf2af Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sun, 1 Jan 2023 15:16:04 +0100 Subject: [PATCH 0078/3010] highlights(rust): use `@namespace` for `[(crate) (self) (super)]` Fixes https://github.com/nvim-treesitter/nvim-treesitter/issues/3992 --- queries/rust/highlights.scm | 8 +++--- tests/query/highlights_spec.lua | 48 ++++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/queries/rust/highlights.scm b/queries/rust/highlights.scm index c7cd1174b..db80fbb32 100644 --- a/queries/rust/highlights.scm +++ b/queries/rust/highlights.scm @@ -209,10 +209,10 @@ (type_cast_expression "as" @keyword.operator) (qualified_type "as" @keyword.operator) -(use_list (self) @keyword) -(scoped_use_list (self) @keyword) -(scoped_identifier [(crate) (super) (self)] @keyword) -(visibility_modifier [(crate) (super) (self)] @keyword) +(use_list (self) @namespace) +(scoped_use_list (self) @namespace) +(scoped_identifier [(crate) (super) (self)] @namespace) +(visibility_modifier [(crate) (super) (self)] @namespace) [ "else" diff --git a/tests/query/highlights_spec.lua b/tests/query/highlights_spec.lua index ff022ba21..8bfd3c2ec 100644 --- a/tests/query/highlights_spec.lua +++ b/tests/query/highlights_spec.lua @@ -76,21 +76,39 @@ local function check_assertions(file) end end end, true) - assert.True( - captures[assertion.expected_capture_name] or highlights[assertion.expected_capture_name], - "Error in at " - .. file - .. ":" - .. (row + 1) - .. ":" - .. (col + 1) - .. ': expected "' - .. assertion.expected_capture_name - .. '", captures: ' - .. vim.inspect(vim.tbl_keys(captures)) - .. '", highlights: ' - .. vim.inspect(vim.tbl_keys(highlights)) - ) + if assertion.expected_capture_name:match "^!" then + assert.Falsy( + captures[assertion.expected_capture_name:sub(2)] or highlights[assertion.expected_capture_name:sub(2)], + "Error in at " + .. file + .. ":" + .. (row + 1) + .. ":" + .. (col + 1) + .. ': expected "' + .. assertion.expected_capture_name + .. '", captures: ' + .. vim.inspect(vim.tbl_keys(captures)) + .. '", highlights: ' + .. vim.inspect(vim.tbl_keys(highlights)) + ) + else + assert.True( + captures[assertion.expected_capture_name] or highlights[assertion.expected_capture_name], + "Error in at " + .. file + .. ":" + .. (row + 1) + .. ":" + .. (col + 1) + .. ': expected "' + .. assertion.expected_capture_name + .. '", captures: ' + .. vim.inspect(vim.tbl_keys(captures)) + .. '", highlights: ' + .. vim.inspect(vim.tbl_keys(highlights)) + ) + end end end From ccc42a96d92b105629cb257c5bbe33d62a35f446 Mon Sep 17 00:00:00 2001 From: GitHub Date: Sun, 1 Jan 2023 14:49:31 +0000 Subject: [PATCH 0079/3010] Update parsers: latex --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index 87416e4ef..a168dc4a0 100644 --- a/lockfile.json +++ b/lockfile.json @@ -213,7 +213,7 @@ "revision": "7744b56f03ac1e5643fad23c9dd90837fe97291e" }, "latex": { - "revision": "1ec3941b971dccfa36cb1cd6221a2e4a1cd3e250" + "revision": "dfb9bbb72f2198e73cbac67035b9e517012d4674" }, "ledger": { "revision": "47b8971448ce5e9abac865f450c1b14fb3b6eee9" From 612a76245506436dba36c3156c1317a212e6d0fb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 1 Jan 2023 15:07:05 +0000 Subject: [PATCH 0080/3010] Update parsers: latex (#4072) Co-authored-by: GitHub --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index a168dc4a0..9b95bf110 100644 --- a/lockfile.json +++ b/lockfile.json @@ -213,7 +213,7 @@ "revision": "7744b56f03ac1e5643fad23c9dd90837fe97291e" }, "latex": { - "revision": "dfb9bbb72f2198e73cbac67035b9e517012d4674" + "revision": "6b7ea839307670e6bda011f888717d3a882ecc09" }, "ledger": { "revision": "47b8971448ce5e9abac865f450c1b14fb3b6eee9" From 3a621b9a8362fac358d828254485024986d6d81b Mon Sep 17 00:00:00 2001 From: Manuel Barros Date: Wed, 30 Nov 2022 11:50:36 +0000 Subject: [PATCH 0081/3010] highlights(haskell): Fix partially applied infix functions --- queries/haskell/highlights.scm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/queries/haskell/highlights.scm b/queries/haskell/highlights.scm index 297a410da..f89375664 100644 --- a/queries/haskell/highlights.scm +++ b/queries/haskell/highlights.scm @@ -119,6 +119,8 @@ ((signature (variable) @_type (forall (context (fun)))) . (function (variable) @function) (#eq? @function @_type)) (exp_infix (variable) @operator) ; consider infix functions as operators +(exp_section_right (variable) @operator) ; partially applied infix functions (sections) also get highlighted as operators +(exp_section_left (variable) @operator) (exp_infix (exp_name) @function.call (#set! "priority" 101)) (exp_apply . (exp_name (variable) @function.call)) From b67822bf58b0fbf0c496ae21a177d02fa8388edf Mon Sep 17 00:00:00 2001 From: Ananda Umamil Date: Mon, 2 Jan 2023 01:43:56 +0700 Subject: [PATCH 0082/3010] highlights(elm): zero args constructor pattern matching --- queries/elm/highlights.scm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/queries/elm/highlights.scm b/queries/elm/highlights.scm index 61601c442..f9150c8ae 100644 --- a/queries/elm/highlights.scm +++ b/queries/elm/highlights.scm @@ -166,6 +166,8 @@ (type_declaration (union_variant (upper_case_identifier) @constructor)) +(nullary_constructor_argument_pattern + (upper_case_qid (upper_case_identifier) @constructor)) (union_pattern (upper_case_qid (upper_case_identifier) @constructor)) (value_expr From ed824394f521086ab8a7f33f9f90ec7288ce10b9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 2 Jan 2023 09:50:13 +0000 Subject: [PATCH 0083/3010] Update parsers: help (#4075) Co-authored-by: GitHub --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index 9b95bf110..c3b626321 100644 --- a/lockfile.json +++ b/lockfile.json @@ -162,7 +162,7 @@ "revision": "2e1348c3cf2c9323e87c2744796cf3f3868aa82a" }, "help": { - "revision": "61c75058299f3d1cf565697e4073d7b2cc6a6d6c" + "revision": "9dee68e3912d16e9878b06e3cd87e21ada3d9029" }, "hjson": { "revision": "02fa3b79b3ff9a296066da6277adfc3f26cbc9e0" From 12e95e160d7d45b76a36bca6303dd8447ab77490 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 2 Jan 2023 10:10:56 +0000 Subject: [PATCH 0084/3010] Update parsers: v (#4077) Co-authored-by: GitHub --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index c3b626321..3730282f1 100644 --- a/lockfile.json +++ b/lockfile.json @@ -402,7 +402,7 @@ "revision": "faad9094f4061a43d4e9005439e9e85c6541ebe7" }, "v": { - "revision": "f0aa56eec7689f08a389c90ad8d3e5e0d18b3cd7" + "revision": "0e3725a0c10d357f16b716f9a321a337bc802f02" }, "vala": { "revision": "8f690bfa639f2b83d1fb938ed3dd98a7ba453e8b" From 408d08810d875517ae094d53cea12f6bb52e1c22 Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 3 Jan 2023 06:37:53 +0000 Subject: [PATCH 0085/3010] Update parsers: gitcommit, norg, v --- lockfile.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lockfile.json b/lockfile.json index 3730282f1..20a5863a0 100644 --- a/lockfile.json +++ b/lockfile.json @@ -120,7 +120,7 @@ "revision": "577a075d46ea109905c5cb6179809df88da61ce9" }, "gitcommit": { - "revision": "f838621d00831967a39ac8293cd3c23b0f49252e" + "revision": "74b40770e6299564f0b7ca474105d7d5238d0583" }, "gitignore": { "revision": "f4685bf11ac466dd278449bcfe5fd014e94aa504" @@ -255,7 +255,7 @@ "revision": "6b71a810c0acd49b980c50fc79092561f7cee307" }, "norg": { - "revision": "8ad20059c6f128861c4506fff866150ffee1d6f4" + "revision": "6348056b999f06c2c7f43bb0a5aa7cfde5302712" }, "ocaml": { "revision": "f1106bf834703f1f2f795da1a3b5f8f40174ffcc" @@ -402,7 +402,7 @@ "revision": "faad9094f4061a43d4e9005439e9e85c6541ebe7" }, "v": { - "revision": "0e3725a0c10d357f16b716f9a321a337bc802f02" + "revision": "e5ec6a42f1af42d4101fb226a98b8db0f4f21c88" }, "vala": { "revision": "8f690bfa639f2b83d1fb938ed3dd98a7ba453e8b" From ac9b33d5bde6d266ad4020f8a9e9b5e2a5310a3b Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sat, 31 Dec 2022 15:36:04 +0100 Subject: [PATCH 0086/3010] ci: trim final `"]` when parsers get added in update-lockfile.yml See https://github.com/nvim-treesitter/nvim-treesitter/pull/4066 The diff will look different when a whole parser gets added: ``` @ ["gleam","revision"] - "cfcbca3f8f734773878e00d7bfcedea98eb10be2" + "3eb2e1783f3bf6f85c16cdd150e2f256b2f6844e" @ ["nix","revision"] - "6b71a810c0acd49b980c50fc79092561f7cee307" + "1b69cf1fa92366eefbe6863c184e5d2ece5f187d" @ ["wgsl_bevy"] + {"revision":"c81dc770310795caea5e00996505deba024ec698"} ``` Co-authored-by: ObserverOfTime --- .github/workflows/update-lockfile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-lockfile.yml b/.github/workflows/update-lockfile.yml index c95ecf73a..41ab41308 100644 --- a/.github/workflows/update-lockfile.yml +++ b/.github/workflows/update-lockfile.yml @@ -45,7 +45,7 @@ jobs: git config user.name "GitHub" git config user.email "noreply@github.com" git add lockfile.json - UPDATED_PARSERS=$(echo $(/tmp/jd -set /tmp/old_lockfile.json lockfile.json | grep @ | sed 's/","revision"\]//' | sed 's/@ \["//') | sed 's/ /, /g') + UPDATED_PARSERS=$(/tmp/jd -set /tmp/old_lockfile.json lockfile.json | sed -n '/@/s/","revision"]//;s/"]//;s/@ \["//p' | sed 'N;s/\n/, /') echo "UPDATED_PARSERS=$UPDATED_PARSERS" >> $GITHUB_ENV git commit -m "Update parsers: $UPDATED_PARSERS" || echo 'No commit necessary!' git clean -xf From 7951eb53f8f9737c247f841f6911971b150ad78a Mon Sep 17 00:00:00 2001 From: GitHub Date: Tue, 3 Jan 2023 10:33:53 +0000 Subject: [PATCH 0087/3010] Update parsers: scala --- lockfile.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockfile.json b/lockfile.json index 20a5863a0..a2a439a6d 100644 --- a/lockfile.json +++ b/lockfile.json @@ -333,7 +333,7 @@ "revision": "f7fb205c424b0962de59b26b931fe484e1262b35" }, "scala": { - "revision": "140c96cf398693189d4e50f76d19ddfcd8a018f8" + "revision": "314bc06e59b3e0a37f224b1d391fd764757abd70" }, "scheme": { "revision": "16bdcf0495865e17ae5b995257458e31e8b7f450" From 6f4b9b190baaa4c10d8e60108ceb61b486f6e1a3 Mon Sep 17 00:00:00 2001 From: Lucario387 Date: Mon, 2 Jan 2023 02:38:54 +0900 Subject: [PATCH 0088/3010] refactor(vue, html): Update injections Update html_tags injections so that html/vue/svelte parsers can use it without having a script/style tag being captured twice Signed-off-by: Pham Huy Hoang --- queries/html/injections.scm | 13 +--- queries/html_tags/injections.scm | 68 +++++++++++++++++-- queries/vue/injections.scm | 63 +++++------------ .../injections/html/test-html-injections.html | 45 ++++++++++++ 4 files changed, 126 insertions(+), 63 deletions(-) create mode 100644 tests/query/injections/html/test-html-injections.html diff --git a/queries/html/injections.scm b/queries/html/injections.scm index 682431195..7ddb5beae 100644 --- a/queries/html/injections.scm +++ b/queries/html/injections.scm @@ -1,12 +1 @@ -((style_element - (raw_text) @css)) - -((attribute - (attribute_name) @_attr - (quoted_attribute_value (attribute_value) @css)) - (#eq? @_attr "style")) - -((script_element - (raw_text) @javascript)) - -(comment) @comment +; inherits html_tags diff --git a/queries/html_tags/injections.scm b/queries/html_tags/injections.scm index 80c0d2a4a..63d00a753 100644 --- a/queries/html_tags/injections.scm +++ b/queries/html_tags/injections.scm @@ -1,7 +1,67 @@ -((style_element - (raw_text) @css)) +; +( + (style_element + (start_tag) @_no_attribute + (raw_text) @css) + (#match? @_no_attribute "^\\<\\s*style\\s*\\>$") + ; unsure why, but without escaping < and > the query breaks +) -((script_element - (raw_text) @javascript)) +; +; Add "lang" to predicate check so that vue/svelte can inherit this +; without having this element being captured twice +( + (style_element + (start_tag + (attribute + (attribute_name) @_no_set_type)) + (raw_text) @css) + (#not-any-of? @_no_set_type "type" "lang") +) + +( + (style_element + (start_tag + (attribute + (attribute_name) @_type + (quoted_attribute_value (attribute_value) @_css))) + (raw_text) @css) + (#eq? @_type "type") + (#eq? @_css "text/css") +) + +; +( + (script_element + (start_tag) @_no_attribute + (raw_text) @javascript) + (#match? @_no_attribute "^\\<\\s*script\\s*\\>$") +) + +; +( + (script_element + (start_tag + (attribute + (attribute_name) @_no_set_type)) + (raw_text) @javascript) + (#not-any-of? @_no_set_type "type" "lang") +) + +( + (script_element + (start_tag + (attribute + (attribute_name) @_type + (quoted_attribute_value (attribute_value) @_javascript))) + (raw_text) @javascript) + (#eq? @_type "type") + (#eq? @_javascript "text/javascript") +) + +((attribute + (attribute_name) @_attr + (quoted_attribute_value (attribute_value) @css)) + (#eq? @_attr "style")) (comment) @comment diff --git a/queries/vue/injections.scm b/queries/vue/injections.scm index 223791c09..84ac2160e 100644 --- a/queries/vue/injections.scm +++ b/queries/vue/injections.scm @@ -1,20 +1,6 @@ -( - (style_element - (start_tag) @_no_attribute - (raw_text) @css) - (#match? @_no_attribute "^\\<\\s*style\\s*\\>$") - ; unsure why, but without escaping < and > the query breaks -) - -( - (style_element - (start_tag - (attribute - (attribute_name) @_no_lang)) - (raw_text) @css) - (#not-eq? @_no_lang "lang") -) +; inherits html_tags +; + + +

+ + From 28baed769815c54b243f0df606ccb4114287e772 Mon Sep 17 00:00:00 2001 From: Lucario387 Date: Mon, 2 Jan 2023 10:47:46 +0900 Subject: [PATCH 0089/3010] refactor(svelte): Remove duplicated queries These injection queries are defined already in html_tags, remove them Signed-off-by: Pham Huy Hoang --- queries/svelte/injections.scm | 11 ++---- .../svelte/test-svelte-injections.svelte | 39 +++++++++++++++++++ 2 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 tests/query/injections/svelte/test-svelte-injections.svelte diff --git a/queries/svelte/injections.scm b/queries/svelte/injections.scm index d66530f7a..65adb5143 100644 --- a/queries/svelte/injections.scm +++ b/queries/svelte/injections.scm @@ -4,16 +4,13 @@ (style_element (start_tag (attribute + (attribute_name) @_attr (quoted_attribute_value (attribute_value) @_lang))) (raw_text) @scss) + (#eq? @_attr "lang") (#any-of? @_lang "scss" "postcss" "less") ) -((attribute - (attribute_name) @_attr - (quoted_attribute_value (attribute_value) @css)) - (#eq? @_attr "style")) - [ (raw_text_expr) (raw_text_each) @@ -23,9 +20,9 @@ (script_element (start_tag (attribute + (attribute_name) @_attr (quoted_attribute_value (attribute_value) @_lang))) (raw_text) @typescript) + (#eq? @_attr "lang") (#any-of? @_lang "ts" "typescript") ) - -(comment) @comment diff --git a/tests/query/injections/svelte/test-svelte-injections.svelte b/tests/query/injections/svelte/test-svelte-injections.svelte new file mode 100644 index 000000000..a821dd080 --- /dev/null +++ b/tests/query/injections/svelte/test-svelte-injections.svelte @@ -0,0 +1,39 @@ + + + + + + +
+

Test file

+ {#each someItems as someItem} + +
{someItem}
+ + {/each} + +
From 8c71c6c5edfa447aaa867858e2e913340ea964b7 Mon Sep 17 00:00:00 2001 From: Pham Huy Hoang Date: Mon, 2 Jan 2023 16:28:40 +0900 Subject: [PATCH 0090/3010] fix(html): fix wrong indents for script/style tags --- queries/html_tags/indents.scm | 27 ++++++++++++++++++++++-- tests/indent/html/issue-3986.html | 4 ++++ tests/indent/html/script_style.html | 12 +++++++++++ tests/indent/html/self_closing_tag.html | 14 +++++++++++++ tests/indent/html/start_tag.html | 8 +++++++ tests/indent/html_spec.lua | 28 +++++++++++++++++++++++++ 6 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 tests/indent/html/issue-3986.html create mode 100644 tests/indent/html/script_style.html create mode 100644 tests/indent/html/self_closing_tag.html create mode 100644 tests/indent/html/start_tag.html create mode 100644 tests/indent/html_spec.lua diff --git a/queries/html_tags/indents.scm b/queries/html_tags/indents.scm index 7b9d6afe1..a9e0794f5 100644 --- a/queries/html_tags/indents.scm +++ b/queries/html_tags/indents.scm @@ -1,9 +1,32 @@ [ - (element) + ( + (element + (start_tag + (tag_name) @_not_special) + ) + (#not-any-of? @_not_special "meta" "link") + ) + (element (self_closing_tag)) ] @indent +; These tags are usually written one-lined and doesnt use self-closing tags so special-cased them +; but add indent to the tag to make sure attributes inside them are still indented if written multi-lined +( + (start_tag + (tag_name) @_special) + (#any-of? @_special "meta" "link") +) @indent + + +; These are the nodes that will be captured when we do `normal o` +; But last element has already been ended, so capturing this +; to mark end of last element +(element (end_tag [">"] @indent_end)) +(element (self_closing_tag "/>" @indent_end)) + +; Script/style elements aren't indented, so only branch the end tag of other elements +(element (end_tag) @branch) [ - (end_tag) ">" "/>" ] @branch diff --git a/tests/indent/html/issue-3986.html b/tests/indent/html/issue-3986.html new file mode 100644 index 000000000..2e6d9f0d6 --- /dev/null +++ b/tests/indent/html/issue-3986.html @@ -0,0 +1,4 @@ +
+
+
+
diff --git a/tests/indent/html/script_style.html b/tests/indent/html/script_style.html new file mode 100644 index 000000000..b00f3f40f --- /dev/null +++ b/tests/indent/html/script_style.html @@ -0,0 +1,12 @@ + + + + + + diff --git a/tests/indent/html/self_closing_tag.html b/tests/indent/html/self_closing_tag.html new file mode 100644 index 000000000..79376b83d --- /dev/null +++ b/tests/indent/html/self_closing_tag.html @@ -0,0 +1,14 @@ + + + + + + + + + +
+ + +