diff --git a/pack/ant/start/nvim-treesitter/.editorconfig b/pack/ant/start/nvim-treesitter/.editorconfig new file mode 100644 index 0000000..00ea231 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.editorconfig @@ -0,0 +1,20 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +tab_width = 8 +end_of_line = lf +insert_final_newline = true +charset = utf-8 + +[*.lua] +tab_width = 2 + +[*.py] +indent_size = 4 +tab_width = 4 + +[{Makefile,**/Makefile,runtime/doc/*.txt}] +indent_style = tab +indent_size = 8 diff --git a/pack/ant/start/nvim-treesitter/.github/FUNDING.yml b/pack/ant/start/nvim-treesitter/.github/FUNDING.yml new file mode 100644 index 0000000..b2844b2 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.github/FUNDING.yml @@ -0,0 +1,2 @@ +open_collective: "nvim-treesitter" +github: "nvim-treesitter" diff --git a/pack/ant/start/nvim-treesitter/.github/ISSUE_TEMPLATE/bug_report.yml b/pack/ant/start/nvim-treesitter/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..f68dd24 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,58 @@ +name: Bug report +description: Create a report to help us improve +labels: [bug] + +body: + - type: markdown + attributes: + value: | + # Before reporting + Please do the following steps before reporting an issue. + + - I have updated my neovim version to latest _master_ + - I have updated my plugin to the latest version + - I have run `:TSUpdate` + - I have read the [troubleshooting section](https://github.com/nvim-treesitter/nvim-treesitter#troubleshooting) + + - type: textarea + attributes: + label: Describe the bug + description: A clear and concise description of what the bug is. + validations: + required: true + + - type: textarea + attributes: + label: To Reproduce + description: Steps to reproduce the behavior. + placeholder: | + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. See error + validations: + required: true + + - type: textarea + attributes: + label: Expected behavior + description: A clear and concise description of what you expected to happen. + + - type: textarea + attributes: + label: Output of `:checkhealth nvim-treesitter` + render: markdown + validations: + required: true + + - type: textarea + attributes: + label: Output of `nvim --version` + render: text + validations: + required: true + + - type: textarea + attributes: + label: Additional context + description: Add any context about the problem here. diff --git a/pack/ant/start/nvim-treesitter/.github/ISSUE_TEMPLATE/feature_request.md b/pack/ant/start/nvim-treesitter/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..d883b8f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,19 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "" +labels: enhancement +assignees: "" +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/pack/ant/start/nvim-treesitter/.github/ISSUE_TEMPLATE/highlighting_issue.yml b/pack/ant/start/nvim-treesitter/.github/ISSUE_TEMPLATE/highlighting_issue.yml new file mode 100644 index 0000000..a429b5e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.github/ISSUE_TEMPLATE/highlighting_issue.yml @@ -0,0 +1,98 @@ +name: Highlighting issue +description: Missing or incorrect highlights or you want to change the way something is highlighted +labels: [highlights] + +body: + - type: markdown + attributes: + value: | + # Before reporting + Please perform the following steps before reporting an issue. + - I have updated my neovim version to latest _master_. + - I have updated my plugin to the latest version. + - I have run `:TSUpdate`. + - I have inspected the syntax tree using `:InspectTree` and made sure + that no `ERROR` nodes are in the syntax tree. nvim-treesitter can not guarantee correct highlighting in the + presence of `ERROR`s -- in this case, please report the bug directly at corresponding parser's repository. (You can find all repository URLs in [README.md](https://github.com/nvim-treesitter/nvim-treesitter#supported-languages).) + - I have used `:Inspect` to inspect which highlight groups Neovim is using and that legacy syntax highlighting is not interfering (i.e., what you are observing is actual tree-sitter highlighting). + + - type: textarea + attributes: + label: Describe the highlighting problem + description: A clear and concise description of what should be highlighted in a different way. + validations: + required: true + + - type: textarea + attributes: + label: Example snippet that causes the problem + description: Please provide an example snippet in plain text that causes the problem. + validations: + required: true + + - type: textarea + attributes: + label: Tree-sitter parsing result + description: | + Please provide the output of `:InspectTree` (screenshot or plain text) + with the following options enabled (pressing the key): + - `I` (name of the parsed language) + - `t` (toggle injected languages) + - `a` (show anonymous nodes) + placeholder: | + This should look somehow like this: + ``` + preproc_ifdef [0, 0] - [4, 6] cpp + "#ifdef" [0, 0] - [0, 6] cpp + name: identifier [0, 7] - [0, 17] cpp + preproc_def [1, 0] - [2, 0] cpp + "#define" [1, 0] - [1, 7] cpp + name: identifier [1, 8] - [1, 16] cpp + value: preproc_arg [1, 16] - [1, 27] cpp + "\n" [1, 27] - [2, 0] cpp + alternative: preproc_else [2, 0] - [4, 0] cpp + "#else" [2, 0] - [2, 5] cpp + preproc_def [3, 0] - [4, 0] cpp + "#define" [3, 0] - [3, 7] cpp + name: identifier [3, 8] - [3, 16] cpp + value: preproc_arg [3, 16] - [3, 29] cpp + ``` + validations: + required: true + + - type: textarea + attributes: + label: Example screenshot + description: | + Please provide a screenshot of the current highlighting. Please also tell us the `:h colorscheme` you are using + and how to install it. If applicable, you can also upload a screenshot with the contents of + `:Inspect`. + validations: + required: true + + - type: textarea + attributes: + label: Expected behavior + description: | + A clear and concise description of what you expect to be changed. You can provide screenshot of + other editors or traditional Vim highlighting that don't show this problem or show a screenshot how + nvim-treesitter highlighting would look like when a problematic query would be removed/altered. + + - type: textarea + attributes: + label: Output of `:checkhealth nvim-treesitter` + render: markdown + validations: + required: true + + - type: textarea + attributes: + label: Output of `nvim --version` + render: text + validations: + required: true + + - type: textarea + attributes: + label: Additional context + description: Add any context about the problem here. diff --git a/pack/ant/start/nvim-treesitter/.github/workflows/lint.yml b/pack/ant/start/nvim-treesitter/.github/workflows/lint.yml new file mode 100644 index 0000000..cd0e519 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.github/workflows/lint.yml @@ -0,0 +1,51 @@ +name: Linting and style checking + +on: + pull_request: + branches: + - "master" + +jobs: + luacheck: + name: Luacheck + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Prepare + run: | + sudo apt-get update + sudo apt-get install luarocks -y + sudo luarocks install luacheck + + - name: Run Luacheck + run: luacheck . + + stylua: + name: StyLua + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Lint with stylua + uses: JohnnyMorganz/stylua-action@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest + args: --check . + + format-queries: + name: Lint queries + runs-on: ubuntu-latest + env: + NVIM_TAG: stable + steps: + - uses: actions/checkout@v4 + - name: Prepare + run: | + bash ./scripts/ci-install.sh + + - name: Lint + run: | + nvim --headless -c "TSInstallSync query" -c "q" + nvim -l scripts/format-queries.lua + git diff --exit-code diff --git a/pack/ant/start/nvim-treesitter/.github/workflows/release.yml b/pack/ant/start/nvim-treesitter/.github/workflows/release.yml new file mode 100644 index 0000000..11f3ffc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.github/workflows/release.yml @@ -0,0 +1,24 @@ +name: "release" +on: + push: + tags: # Will upload to luarocks.org + - "*" + pull_request: # Will test a local install without uploading to luarocks.org + paths: + - 'contrib/*.rockspec' + - .github/workflows/release.yml + +jobs: + luarocks-upload: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: nvim-neorocks/luarocks-tag-release@v5 + env: + LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }} + with: + name: nvim-treesitter + detailed_description: | + The goal of nvim-treesitter is both to provide a simple and easy way to use the interface for tree-sitter in Neovim + and to provide some basic functionality such as highlighting based on it. + template: contrib/nvim-treesitter-luarocks.template diff --git a/pack/ant/start/nvim-treesitter/.github/workflows/test-queries.yml b/pack/ant/start/nvim-treesitter/.github/workflows/test-queries.yml new file mode 100644 index 0000000..bc4a18d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.github/workflows/test-queries.yml @@ -0,0 +1,88 @@ +name: Test queries + +on: + push: + branches: + - "master" + pull_request: + branches: + - "master" + +# Cancel any in-progress CI runs for a PR if it is updated +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +defaults: + run: + shell: bash + +jobs: + check_compilation: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-14] + cc: [gcc, clang] + nvim_tag: [stable] + exclude: + - os: ubuntu-latest + cc: clang + nvim_tag: stable + + - os: macos-14 + cc: gcc + nvim_tag: stable + + - os: windows-latest + cc: clang + nvim_tag: stable + + include: + - os: windows-latest + cc: cl + nvim_tag: nightly + + - os: ubuntu-latest + cc: gcc + nvim_tag: nightly + + name: Parser compilation + runs-on: ${{ matrix.os }} + env: + CC: ${{ matrix.cc }} + NVIM: ${{ matrix.os == 'windows-latest' && 'nvim-win64\\bin\\nvim.exe' || 'nvim' }} + ALLOWED_INSTALLATION_FAILURES: ${{ matrix.os == 'windows-latest' && 'rnoweb' }} + steps: + - uses: actions/checkout@v4 + - uses: tree-sitter/setup-action/cli@v1 + - uses: ilammy/msvc-dev-cmd@v1 + + - name: Install and prepare Neovim + env: + NVIM_TAG: ${{ matrix.nvim_tag }} + run: | + bash ./scripts/ci-install.sh + + - name: Setup Parsers Cache + id: parsers-cache + uses: actions/cache@v4 + with: + path: | + ./parser/ + ~/AppData/Local/nvim/pack/nvim-treesitter/start/nvim-treesitter/parser/ + key: parsers-${{ join(matrix.*, '-') }}-${{ hashFiles( + './lockfile.json', + './lua/nvim-treesitter/install.lua', + './lua/nvim-treesitter/parsers.lua', + './lua/nvim-treesitter/shell_command_selectors.lua') }} + + - name: Compile parsers + run: $NVIM --headless -c "lua require'nvim-treesitter.install'.prefer_git=false" -c "TSInstallSync all" -c "q" + + - name: Post compile Windows + if: runner.os == 'Windows' + run: cp -r ~/AppData/Local/nvim/pack/nvim-treesitter/start/nvim-treesitter/parser/* parser + + - name: Check query files + run: $NVIM -l scripts/check-queries.lua diff --git a/pack/ant/start/nvim-treesitter/.github/workflows/tests.yml b/pack/ant/start/nvim-treesitter/.github/workflows/tests.yml new file mode 100644 index 0000000..5c775ed --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.github/workflows/tests.yml @@ -0,0 +1,64 @@ +name: Tests + +on: + push: + branches: + - "master" + pull_request: + branches: + - "master" + +# Cancel any in-progress CI runs for a PR if it is updated +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +jobs: + check_compilation: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + cc: [gcc] + + name: Run tests + runs-on: ${{ matrix.os }} + env: + CC: ${{ matrix.cc }} + steps: + - uses: actions/checkout@v4 + - uses: tree-sitter/setup-action/cli@v1 + + - name: Test Dependencies + run: | + 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.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 + env: + NVIM_TAG: stable + run: | + bash ./scripts/ci-install.sh + + - name: Setup Parsers Cache + id: parsers-cache + uses: actions/cache@v4 + with: + path: | + ./parser/ + ~/AppData/Local/nvim/pack/nvim-treesitter/start/nvim-treesitter/parser/ + key: parsers-${{ join(matrix.*, '-') }}-${{ hashFiles( + './lockfile.json', + './lua/nvim-treesitter/install.lua', + './lua/nvim-treesitter/parsers.lua', + './lua/nvim-treesitter/shell_selectors.lua') }} + + - name: Compile parsers Unix like + run: | + nvim --headless -c "TSInstallSync all" -c "q" + + - name: Tests + run: PATH=/usr/local/bin:$PATH ./scripts/run_tests.sh diff --git a/pack/ant/start/nvim-treesitter/.github/workflows/update-lockfile.yml b/pack/ant/start/nvim-treesitter/.github/workflows/update-lockfile.yml new file mode 100644 index 0000000..70d6287 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.github/workflows/update-lockfile.yml @@ -0,0 +1,58 @@ +name: Update lockfile + +on: + schedule: + - cron: "30 6 * * *" + workflow_dispatch: + +jobs: + update-lockfile: + name: Update lockfile + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: master + + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.TOKEN_ID }} + private-key: ${{ secrets.TOKEN_PRIVATE_KEY }} + + - name: Prepare + env: + NVIM_TAG: stable + run: | + wget https://github.com/josephburnett/jd/releases/download/v1.7.1/jd-amd64-linux + mv jd-amd64-linux /tmp/jd + chmod +x /tmp/jd + bash scripts/ci-install.sh + + - name: Update parsers + env: + SKIP_LOCKFILE_UPDATE_FOR_LANGS: "djot" + run: | + cp lockfile.json /tmp/old_lockfile.json + nvim -l scripts/write-lockfile.lua + # Pretty print + cp lockfile.json /tmp/lockfile.json + cat /tmp/lockfile.json | jq --sort-keys > lockfile.json + UPDATED_PARSERS=$(/tmp/jd -f merge /tmp/old_lockfile.json lockfile.json | jq -r 'keys | join(", ")') + echo "UPDATED_PARSERS=$UPDATED_PARSERS" >> $GITHUB_ENV + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ steps.app-token.outputs.token }} + sign-commits: true + commit-message: "bot(lockfile): update ${{ env.UPDATED_PARSERS }}" + title: "Update lockfile.json: ${{ env.UPDATED_PARSERS }}" + body: "[beep boop](https://github.com/peter-evans/create-pull-request)" + branch: update-lockfile-pr + base: ${{ github.head_ref }} + + - name: Enable Pull Request Automerge + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + run: gh pr merge --rebase --auto update-lockfile-pr diff --git a/pack/ant/start/nvim-treesitter/.github/workflows/update-readme.yml b/pack/ant/start/nvim-treesitter/.github/workflows/update-readme.yml new file mode 100644 index 0000000..a3fa018 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.github/workflows/update-readme.yml @@ -0,0 +1,46 @@ +name: Update README + +on: + push: + branches: + - master + workflow_dispatch: + +jobs: + update-readme: + name: Update README + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.TOKEN_ID }} + private-key: ${{ secrets.TOKEN_PRIVATE_KEY }} + + - name: Prepare + env: + NVIM_TAG: stable + run: | + bash ./scripts/ci-install.sh + + - name: Check README + run: | + nvim -l scripts/update-readme.lua || echo 'Needs update' + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ steps.app-token.outputs.token }} + sign-commits: true + commit-message: "bot(readme): update" + title: Update README + body: "[beep boop](https://github.com/peter-evans/create-pull-request)" + branch: update-readme-pr + base: ${{ github.head_ref }} + + - name: Enable Pull Request Automerge + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + run: gh pr merge --rebase --auto update-readme-pr diff --git a/pack/ant/start/nvim-treesitter/.gitignore b/pack/ant/start/nvim-treesitter/.gitignore new file mode 100644 index 0000000..0ac164c --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.gitignore @@ -0,0 +1,7 @@ +doc/tags +.luacheckcache +/tags +nvim.appimage +nvim-linux64* +nvim-macos* +nvim-win64* diff --git a/pack/ant/start/nvim-treesitter/.luacheckrc b/pack/ant/start/nvim-treesitter/.luacheckrc new file mode 100644 index 0000000..b0ee19d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.luacheckrc @@ -0,0 +1,21 @@ +-- Rerun tests only if their modification time changed. +cache = true +codes = true + +exclude_files = { + "tests/indent/lua/" +} + +-- Glorious list of warnings: https://luacheck.readthedocs.io/en/stable/warnings.html +ignore = { + "212", -- Unused argument, In the case of callback function, _arg_name is easier to understand than _, so this option is set to off. + "411", -- Redefining a local variable. + "412", -- Redefining an argument. + "422", -- Shadowing an argument + "122" -- Indirectly setting a readonly global +} + +-- Global objects defined by the C code +read_globals = { + "vim", +} diff --git a/pack/ant/start/nvim-treesitter/.luarc.json b/pack/ant/start/nvim-treesitter/.luarc.json new file mode 100644 index 0000000..8dc0605 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.luarc.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json", + "runtime": { + "version": "LuaJIT" + }, + "workspace": { + "library": [ + "lua", + "$VIMRUNTIME", + "${3rd}/luv/library" + ], + "checkThirdParty": false + }, + "diagnostics": { + "groupFileStatus": { + "strict": "Opened", + "strong": "Opened" + }, + "groupSeverity": { + "strong": "Warning", + "strict": "Warning" + }, + "unusedLocalExclude": [ "_*" ] + } +} diff --git a/pack/ant/start/nvim-treesitter/.stylua.toml b/pack/ant/start/nvim-treesitter/.stylua.toml new file mode 100644 index 0000000..ecb6dca --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.stylua.toml @@ -0,0 +1,6 @@ +column_width = 120 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferDouble" +call_parentheses = "None" diff --git a/pack/ant/start/nvim-treesitter/.styluaignore b/pack/ant/start/nvim-treesitter/.styluaignore new file mode 100644 index 0000000..2b6c4c6 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/.styluaignore @@ -0,0 +1 @@ +tests/indent/lua/ diff --git a/pack/ant/start/nvim-treesitter/CONTRIBUTING.md b/pack/ant/start/nvim-treesitter/CONTRIBUTING.md new file mode 100644 index 0000000..23321f0 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/CONTRIBUTING.md @@ -0,0 +1,401 @@ +# Contributing to `nvim-treesitter` + +First of all, thank you very much for contributing to `nvim-treesitter`. + +If you haven't already, you should really come and reach out to us on our +[Matrix channel], so we can help you with any question you might have! + +As you know, `nvim-treesitter` is roughly split in two parts: + +- Parser configurations : for various things like `locals`, `highlights` +- What we like to call _modules_ : tiny Lua modules that provide a given feature, based on parser configurations + +Depending on which part of the plugin you want to contribute to, please read the appropriate section. + +## Style Checks and Tests + +We haven't implemented any functional tests yet. Feel free to contribute. +However, we check code style with `luacheck` and `stylua`! +Please install luacheck and activate our `pre-push` hook to automatically check style before +every push: + +```bash +luarocks install luacheck +cargo install stylua +ln -s ../../scripts/pre-push .git/hooks/pre-push +``` + +## Adding new modules + +If you want to see a new functionality added to `nvim-treesitter` feel free to first open an issue +to that we can track our solution! +Thus far, there is basically two types of modules: + +- Little modules (like `incremental selection`) that are built in `nvim-treesitter`, we call them + `builtin modules`. +- Bigger modules (like `completion-treesitter`, or `nvim-tree-docs`), or modules that integrate + with other plugins, that we call `remote modules`. + +In any case, you can build your own module! To help you started in the process, we have a template +repository designed to build new modules [here](https://github.com/nvim-treesitter/module-template). +Feel free to use it, and contact us over on our +on the "Neovim tree-sitter" [Matrix channel]. + +## Parser configurations + +Contributing to parser configurations is basically modifying one of the `queries/*/*.scm`. +Each of these `scheme` files contains a _tree-sitter query_ for a given purpose. +Before going any further, we highly suggest that you [read more about tree-sitter queries](https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries). + +Each query has an appropriate name, which is then used by modules to extract data from the syntax tree. +For now these are the types of queries used by `nvim-treesitter`: + +- `highlights.scm`: used for syntax highlighting, using the `highlight` module. +- `locals.scm`: used to extract keyword definitions, scopes, references, etc, using the `locals` module. +- `textobjects.scm`: used to define text objects. +- `folds.scm`: used to define folds. +- `injections.scm`: used to define injections. + +For these types there is a _norm_ you will have to follow so that features work fine. +Here are some global advices: + +- If your language is listed [here](https://github.com/nvim-treesitter/nvim-treesitter#supported-languages), + you can install the [playground plugin](https://github.com/nvim-treesitter/playground). +- If your language is listed [here](https://github.com/nvim-treesitter/nvim-treesitter#supported-languages), + you can debug and experiment with your queries there. +- If not, you should consider installing the [tree-sitter CLI](https://github.com/tree-sitter/tree-sitter/tree/master/cli), + you should then be able to open a local playground using `tree-sitter build-wasm && tree-sitter web-ui` within the + parsers repo. +- Examples of queries can be found in [queries/](queries/) +- Matches in the bottom will override queries that are above of them. + +#### Inheriting languages + +If your language is an extension of a language (TypeScript is an extension of JavaScript for +example), you can include the queries from your base language by adding the following _as the first +line of your file_. + +```query +; inherits: lang1,(optionallang) +``` + +If you want to inherit a language, but don't want the languages inheriting from yours to inherit it, +you can mark the language as optional (by putting it between parenthesis). + +#### Formatting + +All queries are expected to follow a standard format, with every node on a single line and indented by two spaces for each level of nesting. You can automatically format the bundled queries by running the provided formatter `./scripts/format-queries.lua` on a single file (ending in `.scm`) or directory to format. + +Should you need to preserve a specific format for a node, you can exempt it (and all contained nodes) by placing before it +```query +; format-ignore +``` + +### Highlights + +As languages differ quite a lot, here is a set of captures available to you when building a `highlights.scm` query. Note that your color scheme needs to define (or link) these captures as highlight groups. + +#### Identifiers + +```query +@variable ; various variable names +@variable.builtin ; built-in variable names (e.g. `this`) +@variable.parameter ; parameters of a function +@variable.parameter.builtin ; special parameters (e.g. `_`, `it`) +@variable.member ; object and struct fields + +@constant ; constant identifiers +@constant.builtin ; built-in constant values +@constant.macro ; constants defined by the preprocessor + +@module ; modules or namespaces +@module.builtin ; built-in modules or namespaces +@label ; GOTO and other labels (e.g. `label:` in C), including heredoc labels +``` + +#### Literals + +```query +@string ; string literals +@string.documentation ; string documenting code (e.g. Python docstrings) +@string.regexp ; regular expressions +@string.escape ; escape sequences +@string.special ; other special strings (e.g. dates) +@string.special.symbol ; symbols or atoms +@string.special.url ; URIs (e.g. hyperlinks) +@string.special.path ; filenames + +@character ; character literals +@character.special ; special characters (e.g. wildcards) + +@boolean ; boolean literals +@number ; numeric literals +@number.float ; floating-point number literals +``` + +#### Types + +```query +@type ; type or class definitions and annotations +@type.builtin ; built-in types +@type.definition ; identifiers in type definitions (e.g. `typedef ` in C) + +@attribute ; attribute annotations (e.g. Python decorators, Rust lifetimes) +@attribute.builtin ; builtin annotations (e.g. `@property` in Python) +@property ; the key in key/value pairs +``` + +#### Functions + +```query +@function ; function definitions +@function.builtin ; built-in functions +@function.call ; function calls +@function.macro ; preprocessor macros + +@function.method ; method definitions +@function.method.call ; method calls + +@constructor ; constructor calls and definitions +@operator ; symbolic operators (e.g. `+` / `*`) +``` + +#### Keywords + +```query +@keyword ; keywords not fitting into specific categories +@keyword.coroutine ; keywords related to coroutines (e.g. `go` in Go, `async/await` in Python) +@keyword.function ; keywords that define a function (e.g. `func` in Go, `def` in Python) +@keyword.operator ; operators that are English words (e.g. `and` / `or`) +@keyword.import ; keywords for including or exporting modules (e.g. `import` / `from` in Python) +@keyword.type ; keywords describing namespaces and composite types (e.g. `struct`, `enum`) +@keyword.modifier ; keywords modifying other constructs (e.g. `const`, `static`, `public`) +@keyword.repeat ; keywords related to loops (e.g. `for` / `while`) +@keyword.return ; keywords like `return` and `yield` +@keyword.debug ; keywords related to debugging +@keyword.exception ; keywords related to exceptions (e.g. `throw` / `catch`) + +@keyword.conditional ; keywords related to conditionals (e.g. `if` / `else`) +@keyword.conditional.ternary ; ternary operator (e.g. `?` / `:`) + +@keyword.directive ; various preprocessor directives & shebangs +@keyword.directive.define ; preprocessor definition directives +``` + +#### Punctuation + +```query +@punctuation.delimiter ; delimiters (e.g. `;` / `.` / `,`) +@punctuation.bracket ; brackets (e.g. `()` / `{}` / `[]`) +@punctuation.special ; special symbols (e.g. `{}` in string interpolation) +``` + +#### Comments + +```query +@comment ; line and block comments +@comment.documentation ; comments documenting code + +@comment.error ; error-type comments (e.g. `ERROR`, `FIXME`, `DEPRECATED`) +@comment.warning ; warning-type comments (e.g. `WARNING`, `FIX`, `HACK`) +@comment.todo ; todo-type comments (e.g. `TODO`, `WIP`) +@comment.note ; note-type comments (e.g. `NOTE`, `INFO`, `XXX`) +``` + +#### Markup + +Mainly for markup languages. + +```query +@markup.strong ; bold text +@markup.italic ; italic text +@markup.strikethrough ; struck-through text +@markup.underline ; underlined text (only for literal underline markup!) + +@markup.heading ; headings, titles (including markers) +@markup.heading.1 ; top-level heading +@markup.heading.2 ; section heading +@markup.heading.3 ; subsection heading +@markup.heading.4 ; and so on +@markup.heading.5 ; and so forth +@markup.heading.6 ; six levels ought to be enough for anybody + +@markup.quote ; block quotes +@markup.math ; math environments (e.g. `$ ... $` in LaTeX) + +@markup.link ; text references, footnotes, citations, etc. +@markup.link.label ; link, reference descriptions +@markup.link.url ; URL-style links + +@markup.raw ; literal or verbatim text (e.g. inline code) +@markup.raw.block ; literal or verbatim text as a stand-alone block + ; (use priority 90 for blocks with injections) + +@markup.list ; list markers +@markup.list.checked ; checked todo-style list markers +@markup.list.unchecked ; unchecked todo-style list markers +``` + +```query +@diff.plus ; added text (for diff files) +@diff.minus ; deleted text (for diff files) +@diff.delta ; changed text (for diff files) +``` + +```query +@tag ; XML-style tag names (and similar) +@tag.builtin ; builtin tag names (e.g. HTML5 tags) +@tag.attribute ; XML-style tag attributes +@tag.delimiter ; XML-style tag delimiters +``` + +#### Non-highlighting captures + +```query +@none ; completely disable the highlight +@conceal ; captures that are only meant to be concealed +``` + +```query +@spell ; for defining regions to be spellchecked +@nospell ; for defining regions that should NOT be spellchecked +``` + +The main types of nodes which are spell checked are: +- Comments +- Strings; where it makes sense. Strings that have interpolation or are typically used for non text purposes are not spell checked (e.g. bash). + +#### Predicates + +Captures can be restricted according to node contents using [predicates](https://neovim.io/doc/user/treesitter.html#treesitter-predicates). For performance reasons, prefer earlier predicates in this list: + +1. `#eq?` (literal match) +2. `#any-of?` (one of several literal matches) +3. `#lua-match?` (match against a [Lua pattern](https://neovim.io/doc/user/luaref.html#lua-pattern)) +4. `#match?`/`#vim-match?` (match against a [Vim regular expression](https://neovim.io/doc/user/pattern.html#regexp) + +#### Conceal + +Captures can be concealed by setting the [`conceal` metadata](https://neovim.io/doc/user/treesitter.html#treesitter-highlight-conceal), e.g.., +```query + (fenced_code_block_delimiter @markup.raw.block (#set! conceal "")) +``` +The capture should be meaningful to allow proper highlighting when `set conceallevel=0`. If the unconcealed capture should not be highlighted (e.g., because an earlier pattern handles this), you can use `@conceal`. + +A conceal can be restricted to part of the capture via the [`#offset!` directive](https://neovim.io/doc/user/treesitter.html#treesitter-directive-offset%21). + +#### Priority + +Captures can be assigned a priority to control precedence of highlights via the +`#set! priority ` directive (see `:h treesitter-highlight-priority`). +The default priority for treesitter highlights is `100`; queries should only +set priorities between `90` and `120`, to avoid conflict with other sources of +highlighting (such as diagnostics or LSP semantic tokens). + +### Locals + +Locals are used to keep track of definitions and references in local or global +scopes, see [upstream +documentation](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#local-variables). +Note that nvim-treesitter uses more specific subcaptures for definitions and +**does not use locals for highlighting**. + +```query +@local.definition ; various definitions +@local.definition.constant ; constants +@local.definition.function ; functions +@local.definition.method ; methods +@local.definition.var ; variables +@local.definition.parameter ; parameters +@local.definition.macro ; preprocessor macros +@local.definition.type ; types or classes +@local.definition.field ; fields or properties +@local.definition.enum ; enumerations +@local.definition.namespace ; modules or namespaces +@local.definition.import ; imported names +@local.definition.associated ; the associated type of a variable + +@local.scope ; scope block +@local.reference ; identifier reference +``` + +#### Definition Scope + +You can set the scope of a definition by setting the `scope` property on the definition. + +For example, a JavaScript function declaration creates a scope. The function name is captured as the definition. +This means that the function definition would only be available WITHIN the scope of the function, which is not the case. +The definition can be used in the scope the function was defined in. + +```javascript +function doSomething() {} + +doSomething(); // Should point to the declaration as the definition +``` + +```query +(function_declaration + ((identifier) @local.definition.var) + (#set! definition.var.scope "parent")) +``` + +Possible scope values are: + +- `parent`: The definition is valid in the containing scope and one more scope above that scope +- `global`: The definition is valid in the root scope +- `local`: The definition is valid in the containing scope. This is the default behavior + +### Folds + +You can define folds for a given language by adding a `folds.scm` query : + +```query +@fold ; fold this node +``` + +If the `folds.scm` query is not present, this will fall back to the `@local.scope` captures in the `locals` +query. + +### Injections + +Some captures are related to language injection (like markdown code blocks). They are used in `injections.scm`. + +If you want to dynamically detect the language (e.g. for Markdown blocks) use the `@injection.language` to capture +the node describing the language and `@injection.content` to describe the injection region. + +```query +@injection.language ; dynamic detection of the injection language (i.e. the text of the captured node describes the language) +@injection.content ; region for the dynamically detected language +``` + +For example, to inject javascript into HTML's ` +``` + +```query +(script_element + (raw_text) @injection.content + (#set! injection.language "javascript")) ; set the parser language for @injection.content region to javascript +``` + +For regions that don't have a corresponding `@injection.language`, you need to manually set the language +through `(#set injection.language "lang_name")` + +To combine all matches of a pattern as one single block of content, add `(#set! injection.combined)` to such pattern + +### Indents + +```query +@indent.begin ; indent children when matching this node +@indent.end ; marks the end of indented block +@indent.align ; behaves like python aligned/hanging indent +@indent.dedent ; dedent children when matching this node +@indent.branch ; dedent itself when matching this node +@indent.ignore ; do not indent in this node +@indent.auto ; behaves like 'autoindent' buffer option +@indent.zero ; sets this node at position 0 (no indent) +``` + +[Matrix channel]: https://matrix.to/#/#nvim-treesitter:matrix.org diff --git a/pack/ant/start/nvim-treesitter/LICENSE b/pack/ant/start/nvim-treesitter/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/pack/ant/start/nvim-treesitter/Makefile b/pack/ant/start/nvim-treesitter/Makefile new file mode 100644 index 0000000..338c754 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/Makefile @@ -0,0 +1,7 @@ +# https://github.com/luarocks/luarocks/wiki/Creating-a-Makefile-that-plays-nice-with-LuaRocks +build: + echo "Do nothing" + +install: + mkdir -p $(INST_LUADIR) + cp -r lua/* $(INST_LUADIR) diff --git a/pack/ant/start/nvim-treesitter/README.md b/pack/ant/start/nvim-treesitter/README.md new file mode 100644 index 0000000..1205209 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/README.md @@ -0,0 +1,833 @@ +
+

nvim-treesitter

+

+ + Matrix Chat + + + Linting and Style + + + Syntax files + +

+
+ +
+

+ Logo +

+

+ Treesitter + configurations and abstraction layer for + Neovim. +

+

+ + Logo by @steelsojka + +

+
+ +The goal of `nvim-treesitter` is both to provide a simple and easy way to use the interface for [tree-sitter](https://github.com/tree-sitter/tree-sitter) in Neovim and to provide some basic functionality such as highlighting based on it: + +![example-cpp](https://user-images.githubusercontent.com/2361214/202753610-e923bf4e-e88f-494b-bb1e-d22a7688446f.png) + +Traditional highlighting (left) vs Treesitter-based highlighting (right). +More examples can be found in [our gallery](https://github.com/nvim-treesitter/nvim-treesitter/wiki/Gallery). + +**Warning: Treesitter and nvim-treesitter highlighting are an experimental feature of Neovim. +Please consider the experience with this plug-in as experimental until Tree-Sitter support in Neovim is stable! +We recommend using the nightly builds of Neovim if possible. +You can find the current roadmap [here](https://github.com/nvim-treesitter/nvim-treesitter/issues/4767). +The roadmap and all features of this plugin are open to change, and any suggestion will be highly appreciated!** + +Nvim-treesitter is based on three interlocking features: [**language parsers**](#language-parsers), [**queries**](#adding-queries), and [**modules**](#available-modules), where _modules_ provide features – e.g., highlighting – based on _queries_ for syntax objects extracted from a given buffer by _language parsers_. +Users will generally only need to interact with parsers and modules as explained in the next section. +For more detailed information on setting these up, see ["Advanced setup"](#advanced-setup). + +--- + +### Table of contents + +- [Quickstart](#quickstart) +- [Supported languages](#supported-languages) +- [Available modules](#available-modules) +- [Advanced setup](#advanced-setup) +- [Extra features](#extra-features) +- [Troubleshooting](#troubleshooting) + +--- + +# Quickstart + +## Requirements + +- **Neovim 0.9.2** or later ([nightly](https://github.com/neovim/neovim#install-from-source) recommended) +- `tar` and `curl` in your path (or alternatively `git`) +- A C compiler in your path and libstdc++ installed ([Windows users please read this!](https://github.com/nvim-treesitter/nvim-treesitter/wiki/Windows-support)). + +## Installation + +You can install `nvim-treesitter` with your favorite package manager (or using the native `package` feature of vim, see `:h packages`). + +**NOTE: This plugin is only guaranteed to work with specific versions of language parsers** (as specified in the `lockfile.json`). **When upgrading the plugin, you must make sure that all installed parsers are updated to the latest version** via `:TSUpdate`. +It is strongly recommended to automate this; e.g., if you are using [vim-plug](https://github.com/junegunn/vim-plug), put this in your `init.vim` file: + +```vim +Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} +``` + +For other plugin managers such as `packer.nvim`, see this [Installation page from the wiki](https://github.com/nvim-treesitter/nvim-treesitter/wiki/Installation) (Note that this page is community maintained). + +## Language parsers + +Treesitter uses a different _parser_ for every language, which needs to be generated via `tree-sitter-cli` from a `grammar.js` file, then compiled to a `.so` library that needs to be placed in neovim's `runtimepath` (typically under `parser/{language}.so`). +To simplify this, `nvim-treesitter` provides commands to automate this process. +If the language is already [supported by `nvim-treesitter`](#supported-languages), you can install it with + +```vim +:TSInstall +``` + +This command supports tab expansion. +You can also get a list of all available languages and their installation status with `:TSInstallInfo`. +Parsers not on this list can be added manually by following the steps described under ["Adding parsers"](#adding-parsers) below. + +To make sure a parser is at the latest compatible version (as specified in `nvim-treesitter`'s `lockfile.json`), use `:TSUpdate {language}`. To update all parsers unconditionally, use `:TSUpdate all` or just `:TSUpdate`. + +## Modules + +Each module provides a distinct tree-sitter-based feature such as [highlighting](#highlight), [indentation](#indentation), or [folding](#folding); see [`:h nvim-treesitter-modules`](doc/nvim-treesitter.txt) or ["Available modules"](#available-modules) below for a list of modules and their options. + +Following examples assume that you are configuring neovim with lua. If you are using vimscript, see `:h lua-heredoc`. +All modules are disabled by default and need to be activated explicitly in your `init.lua`, e.g., via + +```lua +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" (the listed parsers MUST always be installed) + ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "markdown", "markdown_inline" }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + -- List of parsers to ignore installing (or "all") + ignore_install = { "javascript" }, + + ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) + -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! + + highlight = { + enable = true, + + -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to + -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is + -- the name of the parser) + -- list of language that will be disabled + disable = { "c", "rust" }, + -- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files + disable = function(lang, buf) + local max_filesize = 100 * 1024 -- 100 KB + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > max_filesize then + return true + end + end, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, +} +``` + +Each module can also be enabled or disabled interactively through the following commands: + +```vim +:TSBufEnable {module} " enable module on current buffer +:TSBufDisable {module} " disable module on current buffer +:TSEnable {module} [{ft}] " enable module on every buffer. If filetype is specified, enable only for this filetype. +:TSDisable {module} [{ft}] " disable module on every buffer. If filetype is specified, disable only for this filetype. +:TSModuleInfo [{module}] " list information about modules state for each filetype +``` + +Check [`:h nvim-treesitter-commands`](doc/nvim-treesitter.txt) for a list of all available commands. +It may be necessary to reload the buffer (e.g., via `:e`) after enabling a module interactively. + +# Supported languages + +For `nvim-treesitter` to support a specific feature for a specific language requires both a parser for that language and an appropriate language-specific query file for that feature. + +The following is a list of languages for which a parser can be installed through `:TSInstall`; a checked box means that `nvim-treesitter` also contains queries at least for the `highlight` module. + +Experimental parsers are parsers that have a maintainer but are not stable enough for +daily use yet. + +We are looking for maintainers to add more parsers and to write query files for their languages. Check our [tracking issue](https://github.com/nvim-treesitter/nvim-treesitter/issues/2282) for open language requests. + + + +- [x] [ada](https://github.com/briot/tree-sitter-ada) (maintained by @briot) +- [x] [agda](https://github.com/tree-sitter/tree-sitter-agda) (maintained by @Decodetalkers) +- [x] [angular](https://github.com/dlvandenberg/tree-sitter-angular) (experimental, maintained by @dlvandenberg) +- [x] [apex](https://github.com/aheber/tree-sitter-sfapex) (maintained by @aheber, @xixiaofinland) +- [x] [arduino](https://github.com/ObserverOfTime/tree-sitter-arduino) (maintained by @ObserverOfTime) +- [x] [asm](https://github.com/RubixDev/tree-sitter-asm) (maintained by @RubixDev) +- [x] [astro](https://github.com/virchau13/tree-sitter-astro) (maintained by @virchau13) +- [x] [authzed](https://github.com/mleonidas/tree-sitter-authzed) (maintained by @mattpolzin) +- [ ] [awk](https://github.com/Beaglefoot/tree-sitter-awk) +- [x] [bash](https://github.com/tree-sitter/tree-sitter-bash) (maintained by @TravonteD) +- [x] [bass](https://github.com/vito/tree-sitter-bass) (maintained by @amaanq) +- [x] [beancount](https://github.com/polarmutex/tree-sitter-beancount) (maintained by @polarmutex) +- [x] [bibtex](https://github.com/latex-lsp/tree-sitter-bibtex) (maintained by @theHamsta, @clason) +- [x] [bicep](https://github.com/amaanq/tree-sitter-bicep) (maintained by @amaanq) +- [x] [bitbake](https://github.com/amaanq/tree-sitter-bitbake) (maintained by @amaanq) +- [x] [blueprint](https://gitlab.com/gabmus/tree-sitter-blueprint.git) (experimental, maintained by @gabmus) +- [x] [bp](https://github.com/ambroisie/tree-sitter-bp) (maintained by @ambroisie) +- [x] [c](https://github.com/tree-sitter/tree-sitter-c) (maintained by @amaanq) +- [x] [c_sharp](https://github.com/tree-sitter/tree-sitter-c-sharp) (maintained by @amaanq) +- [x] [cairo](https://github.com/amaanq/tree-sitter-cairo) (maintained by @amaanq) +- [x] [capnp](https://github.com/amaanq/tree-sitter-capnp) (maintained by @amaanq) +- [x] [chatito](https://github.com/ObserverOfTime/tree-sitter-chatito) (maintained by @ObserverOfTime) +- [x] [clojure](https://github.com/sogaiu/tree-sitter-clojure) (maintained by @NoahTheDuke) +- [x] [cmake](https://github.com/uyha/tree-sitter-cmake) (maintained by @uyha) +- [x] [comment](https://github.com/stsewd/tree-sitter-comment) (maintained by @stsewd) +- [x] [commonlisp](https://github.com/theHamsta/tree-sitter-commonlisp) (maintained by @theHamsta) +- [x] [cooklang](https://github.com/addcninblue/tree-sitter-cooklang) (maintained by @addcninblue) +- [x] [corn](https://github.com/jakestanger/tree-sitter-corn) (maintained by @jakestanger) +- [x] [cpon](https://github.com/amaanq/tree-sitter-cpon) (maintained by @amaanq) +- [x] [cpp](https://github.com/tree-sitter/tree-sitter-cpp) (maintained by @theHamsta) +- [x] [css](https://github.com/tree-sitter/tree-sitter-css) (maintained by @TravonteD) +- [x] [csv](https://github.com/amaanq/tree-sitter-csv) (maintained by @amaanq) +- [x] [cuda](https://github.com/theHamsta/tree-sitter-cuda) (maintained by @theHamsta) +- [x] [cue](https://github.com/eonpatapon/tree-sitter-cue) (maintained by @amaanq) +- [x] [d](https://github.com/gdamore/tree-sitter-d) (maintained by @amaanq) +- [x] [dart](https://github.com/UserNobody14/tree-sitter-dart) (maintained by @akinsho) +- [x] [devicetree](https://github.com/joelspadin/tree-sitter-devicetree) (maintained by @jedrzejboczar) +- [x] [dhall](https://github.com/jbellerb/tree-sitter-dhall) (maintained by @amaanq) +- [x] [diff](https://github.com/the-mikedavis/tree-sitter-diff) (maintained by @gbprod) +- [x] [disassembly](https://github.com/ColinKennedy/tree-sitter-disassembly) (maintained by @ColinKennedy) +- [x] [djot](https://github.com/treeman/tree-sitter-djot) (maintained by @NoahTheDuke) +- [x] [dockerfile](https://github.com/camdencheek/tree-sitter-dockerfile) (maintained by @camdencheek) +- [x] [dot](https://github.com/rydesun/tree-sitter-dot) (maintained by @rydesun) +- [x] [doxygen](https://github.com/amaanq/tree-sitter-doxygen) (maintained by @amaanq) +- [x] [dtd](https://github.com/tree-sitter-grammars/tree-sitter-xml) (maintained by @ObserverOfTime) +- [x] [earthfile](https://github.com/glehmann/tree-sitter-earthfile) (maintained by @glehmann) +- [x] [ebnf](https://github.com/RubixDev/ebnf) (experimental, maintained by @RubixDev) +- [x] [editorconfig](https://github.com/ValdezFOmar/tree-sitter-editorconfig) (maintained by @ValdezFOmar) +- [x] [eds](https://github.com/uyha/tree-sitter-eds) (maintained by @uyha) +- [x] [eex](https://github.com/connorlay/tree-sitter-eex) (maintained by @connorlay) +- [x] [elixir](https://github.com/elixir-lang/tree-sitter-elixir) (maintained by @connorlay) +- [x] [elm](https://github.com/elm-tooling/tree-sitter-elm) (maintained by @zweimach) +- [x] [elsa](https://github.com/glapa-grossklag/tree-sitter-elsa) (maintained by @glapa-grossklag, @amaanq) +- [x] [elvish](https://github.com/elves/tree-sitter-elvish) (maintained by @elves) +- [ ] [embedded_template](https://github.com/tree-sitter/tree-sitter-embedded-template) +- [x] [erlang](https://github.com/WhatsApp/tree-sitter-erlang) (maintained by @filmor) +- [x] [facility](https://github.com/FacilityApi/tree-sitter-facility) (maintained by @bryankenote) +- [x] [faust](https://github.com/khiner/tree-sitter-faust) (maintained by @khiner) +- [x] [fennel](https://github.com/alexmozaidze/tree-sitter-fennel) (maintained by @alexmozaidze) +- [x] [fidl](https://github.com/google/tree-sitter-fidl) (maintained by @chaopeng) +- [x] [firrtl](https://github.com/amaanq/tree-sitter-firrtl) (maintained by @amaanq) +- [x] [fish](https://github.com/ram02z/tree-sitter-fish) (maintained by @ram02z) +- [x] [foam](https://github.com/FoamScience/tree-sitter-foam) (experimental, maintained by @FoamScience) +- [x] [forth](https://github.com/AlexanderBrevig/tree-sitter-forth) (maintained by @amaanq) +- [x] [fortran](https://github.com/stadelmanma/tree-sitter-fortran) (maintained by @amaanq) +- [x] [fsh](https://github.com/mgramigna/tree-sitter-fsh) (maintained by @mgramigna) +- [x] [fsharp](https://github.com/ionide/tree-sitter-fsharp) (maintained by @nsidorenco) +- [x] [func](https://github.com/amaanq/tree-sitter-func) (maintained by @amaanq) +- [x] [fusion](https://gitlab.com/jirgn/tree-sitter-fusion.git) (maintained by @jirgn) +- [x] [GAP system](https://github.com/gap-system/tree-sitter-gap) (maintained by @reiniscirpons) +- [x] [GAP system test files](https://github.com/gap-system/tree-sitter-gaptst) (maintained by @reiniscirpons) +- [x] [Godot (gdscript)](https://github.com/PrestonKnopp/tree-sitter-gdscript) (maintained by @PrestonKnopp) +- [x] [gdshader](https://github.com/GodOfAvacyn/tree-sitter-gdshader) (maintained by @godofavacyn) +- [x] [git_config](https://github.com/the-mikedavis/tree-sitter-git-config) (maintained by @amaanq) +- [x] [git_rebase](https://github.com/the-mikedavis/tree-sitter-git-rebase) (maintained by @gbprod) +- [x] [gitattributes](https://github.com/ObserverOfTime/tree-sitter-gitattributes) (maintained by @ObserverOfTime) +- [x] [gitcommit](https://github.com/gbprod/tree-sitter-gitcommit) (maintained by @gbprod) +- [x] [gitignore](https://github.com/shunsambongi/tree-sitter-gitignore) (maintained by @theHamsta) +- [x] [gleam](https://github.com/gleam-lang/tree-sitter-gleam) (maintained by @amaanq) +- [x] [Glimmer and Ember](https://github.com/ember-tooling/tree-sitter-glimmer) (maintained by @NullVoxPopuli) +- [x] [glimmer_javascript](https://github.com/NullVoxPopuli/tree-sitter-glimmer-javascript) (maintained by @NullVoxPopuli) +- [x] [glimmer_typescript](https://github.com/NullVoxPopuli/tree-sitter-glimmer-typescript) (maintained by @NullVoxPopuli) +- [x] [glsl](https://github.com/theHamsta/tree-sitter-glsl) (maintained by @theHamsta) +- [x] [GN (Generate Ninja)](https://github.com/amaanq/tree-sitter-gn) (maintained by @amaanq) +- [x] [gnuplot](https://github.com/dpezto/tree-sitter-gnuplot) (maintained by @dpezto) +- [x] [go](https://github.com/tree-sitter/tree-sitter-go) (maintained by @theHamsta, @WinWisely268) +- [x] [goctl](https://github.com/chaozwn/tree-sitter-goctl) (maintained by @chaozwn) +- [x] [Godot Resources (gdresource)](https://github.com/PrestonKnopp/tree-sitter-godot-resource) (maintained by @pierpo) +- [x] [gomod](https://github.com/camdencheek/tree-sitter-go-mod) (maintained by @camdencheek) +- [x] [gosum](https://github.com/amaanq/tree-sitter-go-sum) (maintained by @amaanq) +- [x] [gotmpl](https://github.com/ngalaiko/tree-sitter-go-template) (maintained by @qvalentin) +- [x] [gowork](https://github.com/omertuc/tree-sitter-go-work) (maintained by @omertuc) +- [x] [gpg](https://github.com/ObserverOfTime/tree-sitter-gpg-config) (maintained by @ObserverOfTime) +- [x] [graphql](https://github.com/bkegley/tree-sitter-graphql) (maintained by @bkegley) +- [x] [gren](https://github.com/MaeBrooks/tree-sitter-gren) (maintained by @MaeBrooks) +- [x] [groovy](https://github.com/murtaza64/tree-sitter-groovy) (maintained by @murtaza64) +- [x] [gstlaunch](https://github.com/theHamsta/tree-sitter-gstlaunch) (maintained by @theHamsta) +- [ ] [hack](https://github.com/slackhq/tree-sitter-hack) +- [x] [hare](https://github.com/amaanq/tree-sitter-hare) (maintained by @amaanq) +- [x] [haskell](https://github.com/tree-sitter/tree-sitter-haskell) (maintained by @mrcjkb) +- [x] [haskell_persistent](https://github.com/MercuryTechnologies/tree-sitter-haskell-persistent) (maintained by @lykahb) +- [x] [hcl](https://github.com/MichaHoffmann/tree-sitter-hcl) (maintained by @MichaHoffmann) +- [x] [heex](https://github.com/connorlay/tree-sitter-heex) (maintained by @connorlay) +- [x] [helm](https://github.com/ngalaiko/tree-sitter-go-template) (maintained by @qvalentin) +- [x] [hjson](https://github.com/winston0410/tree-sitter-hjson) (maintained by @winston0410) +- [x] [hlsl](https://github.com/theHamsta/tree-sitter-hlsl) (maintained by @theHamsta) +- [x] [hlsplaylist](https://github.com/Freed-Wu/tree-sitter-hlsplaylist) (maintained by @Freed-Wu) +- [x] [hocon](https://github.com/antosha417/tree-sitter-hocon) (maintained by @antosha417) +- [x] [hoon](https://github.com/urbit-pilled/tree-sitter-hoon) (experimental, maintained by @urbit-pilled) +- [x] [html](https://github.com/tree-sitter/tree-sitter-html) (maintained by @TravonteD) +- [x] [htmldjango](https://github.com/interdependence/tree-sitter-htmldjango) (experimental, maintained by @ObserverOfTime) +- [x] [http](https://github.com/rest-nvim/tree-sitter-http) (maintained by @amaanq, @NTBBloodbath) +- [x] [hurl](https://github.com/pfeiferj/tree-sitter-hurl) (maintained by @pfeiferj) +- [x] [hyprlang](https://github.com/luckasRanarison/tree-sitter-hyprlang) (maintained by @luckasRanarison) +- [x] [idl](https://github.com/cathaysia/tree-sitter-idl) (maintained by @cathaysia) +- [x] [ini](https://github.com/justinmk/tree-sitter-ini) (experimental, maintained by @theHamsta) +- [x] [inko](https://github.com/inko-lang/tree-sitter-inko) (maintained by @yorickpeterse) +- [x] [ispc](https://github.com/fab4100/tree-sitter-ispc) (maintained by @fab4100) +- [x] [janet_simple](https://github.com/sogaiu/tree-sitter-janet-simple) (maintained by @sogaiu) +- [x] [java](https://github.com/tree-sitter/tree-sitter-java) (maintained by @p00f) +- [x] [javascript](https://github.com/tree-sitter/tree-sitter-javascript) (maintained by @steelsojka) +- [x] [jq](https://github.com/flurie/tree-sitter-jq) (maintained by @ObserverOfTime) +- [x] [jsdoc](https://github.com/tree-sitter/tree-sitter-jsdoc) (maintained by @steelsojka) +- [x] [json](https://github.com/tree-sitter/tree-sitter-json) (maintained by @steelsojka) +- [x] [json5](https://github.com/Joakker/tree-sitter-json5) (maintained by @Joakker) +- [x] [JSON with comments](https://gitlab.com/WhyNotHugo/tree-sitter-jsonc.git) (maintained by @WhyNotHugo) +- [x] [jsonnet](https://github.com/sourcegraph/tree-sitter-jsonnet) (maintained by @nawordar) +- [x] [julia](https://github.com/tree-sitter/tree-sitter-julia) (maintained by @theHamsta) +- [x] [just](https://github.com/IndianBoy42/tree-sitter-just) (maintained by @Hubro) +- [x] [kconfig](https://github.com/amaanq/tree-sitter-kconfig) (maintained by @amaanq) +- [x] [kdl](https://github.com/amaanq/tree-sitter-kdl) (maintained by @amaanq) +- [x] [kotlin](https://github.com/fwcd/tree-sitter-kotlin) (maintained by @SalBakraa) +- [x] [koto](https://github.com/koto-lang/tree-sitter-koto) (maintained by @irh) +- [x] [kusto](https://github.com/Willem-J-an/tree-sitter-kusto) (maintained by @Willem-J-an) +- [x] [lalrpop](https://github.com/traxys/tree-sitter-lalrpop) (maintained by @traxys) +- [x] [latex](https://github.com/latex-lsp/tree-sitter-latex) (maintained by @theHamsta, @clason) +- [x] [ledger](https://github.com/cbarrete/tree-sitter-ledger) (maintained by @cbarrete) +- [x] [leo](https://github.com/r001/tree-sitter-leo) (maintained by @r001) +- [x] [linkerscript](https://github.com/amaanq/tree-sitter-linkerscript) (maintained by @amaanq) +- [x] [liquid](https://github.com/hankthetank27/tree-sitter-liquid) (maintained by @hankthetank27) +- [x] [liquidsoap](https://github.com/savonet/tree-sitter-liquidsoap) (maintained by @toots) +- [x] [llvm](https://github.com/benwilliamgraham/tree-sitter-llvm) (maintained by @benwilliamgraham) +- [x] [lua](https://github.com/MunifTanjim/tree-sitter-lua) (maintained by @muniftanjim) +- [x] [luadoc](https://github.com/amaanq/tree-sitter-luadoc) (maintained by @amaanq) +- [x] [lua patterns](https://github.com/amaanq/tree-sitter-luap) (maintained by @amaanq) +- [x] [luau](https://github.com/amaanq/tree-sitter-luau) (maintained by @amaanq) +- [x] [m68k](https://github.com/grahambates/tree-sitter-m68k) (maintained by @grahambates) +- [x] [make](https://github.com/alemuller/tree-sitter-make) (maintained by @lewis6991) +- [x] [markdown (basic highlighting)](https://github.com/MDeiml/tree-sitter-markdown) (experimental, maintained by @MDeiml) +- [x] [markdown_inline (needed for full highlighting)](https://github.com/MDeiml/tree-sitter-markdown) (experimental, maintained by @MDeiml) +- [x] [matlab](https://github.com/acristoffers/tree-sitter-matlab) (maintained by @acristoffers) +- [x] [menhir](https://github.com/Kerl13/tree-sitter-menhir) (maintained by @Kerl13) +- [ ] [mermaid](https://github.com/monaqa/tree-sitter-mermaid) (experimental) +- [x] [meson](https://github.com/Decodetalkers/tree-sitter-meson) (maintained by @Decodetalkers) +- [x] [mlir](https://github.com/artagnon/tree-sitter-mlir) (experimental, maintained by @artagnon) +- [x] [muttrc](https://github.com/neomutt/tree-sitter-muttrc) (maintained by @Freed-Wu) +- [x] [nasm](https://github.com/naclsn/tree-sitter-nasm) (maintained by @ObserverOfTime) +- [x] [nginx](https://github.com/opa-oz/tree-sitter-nginx) (maintained by @opa-oz) +- [ ] [nickel](https://github.com/nickel-lang/tree-sitter-nickel) +- [x] [nim](https://github.com/alaviss/tree-sitter-nim) (maintained by @aMOPel) +- [x] [nim_format_string](https://github.com/aMOPel/tree-sitter-nim-format-string) (maintained by @aMOPel) +- [x] [ninja](https://github.com/alemuller/tree-sitter-ninja) (maintained by @alemuller) +- [x] [nix](https://github.com/cstrahan/tree-sitter-nix) (maintained by @leo60228) +- [x] [norg](https://github.com/nvim-neorg/tree-sitter-norg) (maintained by @JoeyGrajciar, @vhyrro) +- [x] [nqc](https://github.com/amaanq/tree-sitter-nqc) (maintained by @amaanq) +- [x] [objc](https://github.com/amaanq/tree-sitter-objc) (maintained by @amaanq) +- [x] [objdump](https://github.com/ColinKennedy/tree-sitter-objdump) (maintained by @ColinKennedy) +- [x] [ocaml](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu) +- [x] [ocaml_interface](https://github.com/tree-sitter/tree-sitter-ocaml) (maintained by @undu) +- [x] [ocamllex](https://github.com/atom-ocaml/tree-sitter-ocamllex) (maintained by @undu) +- [x] [odin](https://github.com/amaanq/tree-sitter-odin) (maintained by @amaanq) +- [ ] [org](https://github.com/milisims/tree-sitter-org) +- [x] [pascal](https://github.com/Isopod/tree-sitter-pascal) (maintained by @Isopod) +- [x] [passwd](https://github.com/ath3/tree-sitter-passwd) (maintained by @amaanq) +- [x] [pem](https://github.com/ObserverOfTime/tree-sitter-pem) (maintained by @ObserverOfTime) +- [x] [perl](https://github.com/tree-sitter-perl/tree-sitter-perl) (maintained by @RabbiVeesh, @LeoNerd) +- [x] [php](https://github.com/tree-sitter/tree-sitter-php) (maintained by @tk-shirasaka, @calebdw) +- [x] [php_only](https://github.com/tree-sitter/tree-sitter-php) (maintained by @tk-shirasaka, @calebdw) +- [x] [phpdoc](https://github.com/claytonrcarter/tree-sitter-phpdoc) (experimental, maintained by @mikehaertl) +- [x] [pioasm](https://github.com/leo60228/tree-sitter-pioasm) (maintained by @leo60228) +- [x] [po](https://github.com/erasin/tree-sitter-po) (maintained by @amaanq) +- [x] [pod](https://github.com/tree-sitter-perl/tree-sitter-pod) (maintained by @RabbiVeesh, @LeoNerd) +- [x] [Path of Exile item filter](https://github.com/ObserverOfTime/tree-sitter-poe-filter) (experimental, maintained by @ObserverOfTime) +- [x] [pony](https://github.com/amaanq/tree-sitter-pony) (maintained by @amaanq, @mfelsche) +- [x] [powershell](https://github.com/airbus-cert/tree-sitter-powershell) (maintained by @L2jLiga) +- [x] [printf](https://github.com/ObserverOfTime/tree-sitter-printf) (maintained by @ObserverOfTime) +- [x] [prisma](https://github.com/victorhqc/tree-sitter-prisma) (maintained by @elianiva) +- [x] [problog](https://github.com/foxyseta/tree-sitter-prolog) (maintained by @foxyseta) +- [x] [prolog](https://github.com/foxyseta/tree-sitter-prolog) (maintained by @foxyseta) +- [x] [promql](https://github.com/MichaHoffmann/tree-sitter-promql) (maintained by @MichaHoffmann) +- [x] [properties](https://github.com/tree-sitter-grammars/tree-sitter-properties) (maintained by @ObserverOfTime) +- [x] [proto](https://github.com/treywood/tree-sitter-proto) (maintained by @treywood) +- [x] [prql](https://github.com/PRQL/tree-sitter-prql) (maintained by @matthias-Q) +- [x] [psv](https://github.com/amaanq/tree-sitter-csv) (maintained by @amaanq) +- [x] [pug](https://github.com/zealot128/tree-sitter-pug) (experimental, maintained by @zealot128) +- [x] [puppet](https://github.com/amaanq/tree-sitter-puppet) (maintained by @amaanq) +- [x] [purescript](https://github.com/postsolar/tree-sitter-purescript) (maintained by @postsolar) +- [x] [PyPA manifest](https://github.com/ObserverOfTime/tree-sitter-pymanifest) (maintained by @ObserverOfTime) +- [x] [python](https://github.com/tree-sitter/tree-sitter-python) (maintained by @stsewd, @theHamsta) +- [x] [ql](https://github.com/tree-sitter/tree-sitter-ql) (maintained by @pwntester) +- [x] [qmldir](https://github.com/Decodetalkers/tree-sitter-qmldir) (maintained by @amaanq) +- [x] [qmljs](https://github.com/yuja/tree-sitter-qmljs) (maintained by @Decodetalkers) +- [x] [Tree-Sitter query language](https://github.com/nvim-treesitter/tree-sitter-query) (maintained by @steelsojka) +- [x] [r](https://github.com/r-lib/tree-sitter-r) (maintained by @ribru17) +- [ ] [racket](https://github.com/6cdh/tree-sitter-racket) +- [x] [ralph](https://github.com/alephium/tree-sitter-ralph) (maintained by @tdroxler) +- [x] [rasi](https://github.com/Fymyte/tree-sitter-rasi) (maintained by @Fymyte) +- [x] [rbs](https://github.com/joker1007/tree-sitter-rbs) (maintained by @joker1007) +- [x] [re2c](https://github.com/amaanq/tree-sitter-re2c) (maintained by @amaanq) +- [x] [readline](https://github.com/ribru17/tree-sitter-readline) (maintained by @ribru17) +- [x] [regex](https://github.com/tree-sitter/tree-sitter-regex) (maintained by @theHamsta) +- [x] [rego](https://github.com/FallenAngel97/tree-sitter-rego) (maintained by @FallenAngel97) +- [x] [pip requirements](https://github.com/ObserverOfTime/tree-sitter-requirements) (maintained by @ObserverOfTime) +- [x] [rescript](https://github.com/rescript-lang/tree-sitter-rescript) (maintained by @ribru17) +- [x] [rnoweb](https://github.com/bamonroe/tree-sitter-rnoweb) (maintained by @bamonroe) +- [x] [robot](https://github.com/Hubro/tree-sitter-robot) (maintained by @Hubro) +- [x] [robots](https://github.com/opa-oz/tree-sitter-robots-txt) (maintained by @opa-oz) +- [x] [roc](https://github.com/faldor20/tree-sitter-roc) (maintained by @nat-418) +- [x] [ron](https://github.com/amaanq/tree-sitter-ron) (maintained by @amaanq) +- [x] [rst](https://github.com/stsewd/tree-sitter-rst) (maintained by @stsewd) +- [x] [ruby](https://github.com/tree-sitter/tree-sitter-ruby) (maintained by @TravonteD) +- [x] [rust](https://github.com/tree-sitter/tree-sitter-rust) (maintained by @amaanq) +- [x] [scala](https://github.com/tree-sitter/tree-sitter-scala) (maintained by @stevanmilic) +- [x] [scfg](https://github.com/rockorager/tree-sitter-scfg) (maintained by @WhyNotHugo) +- [ ] [scheme](https://github.com/6cdh/tree-sitter-scheme) +- [x] [scss](https://github.com/serenadeai/tree-sitter-scss) (maintained by @elianiva) +- [x] [sflog](https://github.com/aheber/tree-sitter-sfapex) (maintained by @aheber, @xixiaofinland) +- [x] [slang](https://github.com/theHamsta/tree-sitter-slang) (experimental, maintained by @theHamsta) +- [x] [slint](https://github.com/slint-ui/tree-sitter-slint) (maintained by @hunger) +- [x] [smali](https://github.com/tree-sitter-grammars/tree-sitter-smali) (maintained by @amaanq) +- [x] [smithy](https://github.com/indoorvivants/tree-sitter-smithy) (maintained by @amaanq, @keynmol) +- [ ] [snakemake](https://github.com/osthomas/tree-sitter-snakemake) (experimental) +- [x] [solidity](https://github.com/JoranHonig/tree-sitter-solidity) (maintained by @amaanq) +- [x] [soql](https://github.com/aheber/tree-sitter-sfapex) (maintained by @aheber, @xixiaofinland) +- [x] [sosl](https://github.com/aheber/tree-sitter-sfapex) (maintained by @aheber, @xixiaofinland) +- [x] [sourcepawn](https://github.com/nilshelmig/tree-sitter-sourcepawn) (maintained by @Sarrus1) +- [x] [sparql](https://github.com/GordianDziwis/tree-sitter-sparql) (maintained by @GordianDziwis) +- [x] [sql](https://github.com/derekstride/tree-sitter-sql) (maintained by @derekstride) +- [x] [squirrel](https://github.com/amaanq/tree-sitter-squirrel) (maintained by @amaanq) +- [x] [ssh_config](https://github.com/ObserverOfTime/tree-sitter-ssh-config) (maintained by @ObserverOfTime) +- [x] [starlark](https://github.com/amaanq/tree-sitter-starlark) (maintained by @amaanq) +- [x] [strace](https://github.com/sigmaSd/tree-sitter-strace) (maintained by @amaanq) +- [x] [styled](https://github.com/mskelton/tree-sitter-styled) (maintained by @mskelton) +- [x] [supercollider](https://github.com/madskjeldgaard/tree-sitter-supercollider) (maintained by @madskjeldgaard) +- [x] [superhtml](https://github.com/kristoff-it/superhtml) (maintained by @rockorager) +- [x] [surface](https://github.com/connorlay/tree-sitter-surface) (maintained by @connorlay) +- [x] [svelte](https://github.com/tree-sitter-grammars/tree-sitter-svelte) (maintained by @amaanq) +- [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] [systemtap](https://github.com/ok-ryoko/tree-sitter-systemtap) (maintained by @ok-ryoko) +- [x] [t32](https://gitlab.com/xasc/tree-sitter-t32.git) (maintained by @xasc) +- [x] [tablegen](https://github.com/amaanq/tree-sitter-tablegen) (maintained by @amaanq) +- [x] [tact](https://github.com/tact-lang/tree-sitter-tact) (maintained by @novusnota) +- [x] [tcl](https://github.com/tree-sitter-grammars/tree-sitter-tcl) (maintained by @lewis6991) +- [x] [teal](https://github.com/euclidianAce/tree-sitter-teal) (maintained by @euclidianAce) +- [x] [templ](https://github.com/vrischmann/tree-sitter-templ) (maintained by @vrischmann) +- [x] [terraform](https://github.com/MichaHoffmann/tree-sitter-hcl) (maintained by @MichaHoffmann) +- [x] [textproto](https://github.com/PorterAtGoogle/tree-sitter-textproto) (maintained by @Porter) +- [x] [thrift](https://github.com/duskmoon314/tree-sitter-thrift) (maintained by @amaanq, @duskmoon314) +- [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] [tmux](https://github.com/Freed-Wu/tree-sitter-tmux) (maintained by @Freed-Wu) +- [x] [todotxt](https://github.com/arnarg/tree-sitter-todotxt) (experimental, maintained by @arnarg) +- [x] [toml](https://github.com/tree-sitter-grammars/tree-sitter-toml) (maintained by @tk-shirasaka) +- [x] [tsv](https://github.com/amaanq/tree-sitter-csv) (maintained by @amaanq) +- [x] [tsx](https://github.com/tree-sitter/tree-sitter-typescript) (maintained by @steelsojka) +- [x] [turtle](https://github.com/GordianDziwis/tree-sitter-turtle) (maintained by @GordianDziwis) +- [x] [twig](https://github.com/gbprod/tree-sitter-twig) (maintained by @gbprod) +- [x] [typescript](https://github.com/tree-sitter/tree-sitter-typescript) (maintained by @steelsojka) +- [x] [typespec](https://github.com/happenslol/tree-sitter-typespec) (maintained by @happenslol) +- [x] [typoscript](https://github.com/Teddytrombone/tree-sitter-typoscript) (maintained by @Teddytrombone) +- [x] [typst](https://github.com/uben0/tree-sitter-typst) (maintained by @uben0, @RaafatTurki) +- [x] [udev](https://github.com/ObserverOfTime/tree-sitter-udev) (maintained by @ObserverOfTime) +- [x] [ungrammar](https://github.com/Philipp-M/tree-sitter-ungrammar) (maintained by @Philipp-M, @amaanq) +- [x] [unison](https://github.com/kylegoetz/tree-sitter-unison) (maintained by @tapegram) +- [x] [usd](https://github.com/ColinKennedy/tree-sitter-usd) (maintained by @ColinKennedy) +- [x] [uxn tal](https://github.com/amaanq/tree-sitter-uxntal) (maintained by @amaanq) +- [x] [v](https://github.com/vlang/v-analyzer) (maintained by @kkharji, @amaanq) +- [x] [vala](https://github.com/vala-lang/tree-sitter-vala) (maintained by @Prince781) +- [x] [vento](https://github.com/ventojs/tree-sitter-vento) (maintained by @wrapperup, @oscarotero) +- [x] [verilog](https://github.com/gmlarumbe/tree-sitter-systemverilog) (maintained by @zhangwwpeng) +- [x] [vhdl](https://github.com/jpt13653903/tree-sitter-vhdl) (maintained by @jpt13653903) +- [x] [vhs](https://github.com/charmbracelet/tree-sitter-vhs) (maintained by @caarlos0) +- [x] [vim](https://github.com/neovim/tree-sitter-vim) (maintained by @clason) +- [x] [vimdoc](https://github.com/neovim/tree-sitter-vimdoc) (maintained by @clason) +- [x] [vrl](https://github.com/belltoy/tree-sitter-vrl) (maintained by @belltoy) +- [x] [vue](https://github.com/tree-sitter-grammars/tree-sitter-vue) (maintained by @WhyNotHugo, @lucario387) +- [x] [wgsl](https://github.com/szebniok/tree-sitter-wgsl) (maintained by @szebniok) +- [x] [wgsl_bevy](https://github.com/theHamsta/tree-sitter-wgsl-bevy) (maintained by @theHamsta) +- [x] [wing](https://github.com/winglang/tree-sitter-wing) (maintained by @gshpychka, @MarkMcCulloh) +- [x] [wit](https://github.com/liamwh/tree-sitter-wit) (maintained by @liamwh) +- [x] [xcompose](https://github.com/ObserverOfTime/tree-sitter-xcompose) (maintained by @ObserverOfTime) +- [x] [xml](https://github.com/tree-sitter-grammars/tree-sitter-xml) (maintained by @ObserverOfTime) +- [x] [xresources](https://github.com/ValdezFOmar/tree-sitter-xresources) (maintained by @ValdezFOmar) +- [x] [yaml](https://github.com/tree-sitter-grammars/tree-sitter-yaml) (maintained by @amaanq) +- [x] [yang](https://github.com/Hubro/tree-sitter-yang) (maintained by @Hubro) +- [x] [yuck](https://github.com/Philipp-M/tree-sitter-yuck) (maintained by @Philipp-M, @amaanq) +- [x] [zathurarc](https://github.com/Freed-Wu/tree-sitter-zathurarc) (maintained by @Freed-Wu) +- [x] [zig](https://github.com/tree-sitter-grammars/tree-sitter-zig) (maintained by @amaanq) +- [x] [ziggy](https://github.com/kristoff-it/ziggy) (maintained by @rockorager) +- [x] [ziggy_schema](https://github.com/kristoff-it/ziggy) (maintained by @rockorager) + + +For related information on the supported languages, including related plugins, see [this wiki page](https://github.com/nvim-treesitter/nvim-treesitter/wiki/Supported-Languages-Information). + +# Available modules + +Modules provide the top-level features of `nvim-treesitter`. +The following is a list of modules included in `nvim-treesitter` and their configuration via `init.lua` (where multiple modules can be combined in a single call to `setup`). +Note that not all modules work for all languages (depending on the queries available for them). +Additional modules can be provided as [external plugins](https://github.com/nvim-treesitter/nvim-treesitter/wiki/Extra-modules-and-plugins). + +#### Highlight + +Consistent syntax highlighting. + +```lua +require'nvim-treesitter.configs'.setup { + highlight = { + enable = true, + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, +} +``` + +To customize the syntax highlighting of a capture, simply define or link a highlight group of the same name: + +```lua +-- Highlight the @foo.bar capture group with the "Identifier" highlight group +vim.api.nvim_set_hl(0, "@foo.bar", { link = "Identifier" }) +``` + +For a language-specific highlight, append the name of the language: + +```lua +-- Highlight @foo.bar as "Identifier" only in Lua files +vim.api.nvim_set_hl(0, "@foo.bar.lua", { link = "Identifier" }) +``` + +See `:h treesitter-highlight-groups` for details. + +#### Incremental selection + +Incremental selection based on the named nodes from the grammar. + +```lua +require'nvim-treesitter.configs'.setup { + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", -- set to `false` to disable one of the mappings + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, +} +``` + +#### Indentation + +Indentation based on treesitter for the `=` operator. +**NOTE: This is an experimental feature**. + +```lua +require'nvim-treesitter.configs'.setup { + indent = { + enable = true + } +} +``` + +#### Folding + +Tree-sitter based folding (implemented in Neovim itself, see `:h vim.treesitter.foldexpr()`). To enable it for the current window, set + +```lua +vim.wo.foldmethod = 'expr' +vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()' +``` + +This will respect your `foldminlines` and `foldnestmax` settings. + +# Advanced setup + +## Changing the parser install directory + +If you want to install the parsers to a custom directory you can specify this +directory with `parser_install_dir` option in that is passed to `setup`. +`nvim-treesitter` will then install the parser files into this directory. + +This directory must be writeable and must be explicitly prepended to the +`runtimepath`. For example: + +```lua + -- It MUST be at the beginning of runtimepath. Otherwise the parsers from Neovim itself + -- is loaded that may not be compatible with the queries from the 'nvim-treesitter' plugin. + vim.opt.runtimepath:prepend("/some/path/to/store/parsers") + + require'nvim-treesitter.configs'.setup { + parser_install_dir = "/some/path/to/store/parsers", + + ... + + } +``` + +If this option is not included in the setup options, or is explicitly set to +`nil` then the default install directories will be used. If this value is set +the default directories will be ignored. + +Bear in mind that any parser installed into a parser folder on the runtime path +will still be considered installed. (For example if +"~/.local/share/nvim/site/parser/c.so" exists then the "c" parser will be +considered installed, even though it is not in `parser_install_dir`) + +The default paths are: + +1. first the package folder. Where `nvim-treesitter` is installed. +2. second the site directory. This is the "site" subdirectory of `stdpath("data")`. + +## Adding parsers + +If you have a parser that is not on the list of supported languages (either as a repository on Github or in a local directory), you can add it manually for use by `nvim-treesitter` as follows: + +1. Clone the repository or [create a new project](https://tree-sitter.github.io/tree-sitter/creating-parsers#project-setup) in, say, `~/projects/tree-sitter-zimbu`. Make sure that the `tree-sitter-cli` executable is installed and in your path; see for installation instructions. +2. Run `tree-sitter generate` in this directory (followed by `tree-sitter test` for good measure). +3. Add the following snippet to your `init.lua`: + +```lua +local parser_config = require "nvim-treesitter.parsers".get_parser_configs() +parser_config.zimbu = { + install_info = { + url = "~/projects/tree-sitter-zimbu", -- local path or git repo + files = {"src/parser.c"}, -- note that some parsers also require src/scanner.c or src/scanner.cc + -- optional entries: + branch = "main", -- default branch in case of git repo if different from master + generate_requires_npm = false, -- if stand-alone parser without npm dependencies + requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c + }, + filetype = "zu", -- if filetype does not match the parser name +} +``` + +If you wish to set a specific parser for a filetype, you should use `vim.treesitter.language.register()`: + +```lua +vim.treesitter.language.register('python', 'someft') -- the someft filetype will use the python parser and queries. +``` + +Note this requires Nvim v0.9. + +4. Start `nvim` and `:TSInstall zimbu`. + +You can also skip step 2 and use `:TSInstallFromGrammar zimbu` to install directly from a `grammar.js` in the top-level directory specified by `url`. +Once the parser is installed, you can update it (from the latest revision of the `main` branch if `url` is a Github repository) with `:TSUpdate zimbu`. + +Note that neither `:TSInstall` nor `:TSInstallFromGrammar` copy query files from the grammar repository. +If you want your installed grammar to be useful, you must manually [add query files](#adding-queries) to your local nvim-treesitter installation. +Note also that module functionality is only triggered if your language's filetype is correctly identified. +If Neovim does not detect your language's filetype by default, you can use [Neovim's `vim.filetype.add()`]() to add a custom detection rule. + +If you use a git repository for your parser and want to use a specific version, you can set the `revision` key +in the `install_info` table for you parser config. + +## Adding queries + +Queries are what `nvim-treesitter` uses to extract information from the syntax tree; +they are located in the `queries/{language}/*` runtime directories (see `:h rtp`), +like the `queries` folder of this plugin, e.g. `queries/{language}/{locals,highlights,textobjects}.scm`. +Other modules may require additional queries such as `folding.scm`. You can find a +list of all supported capture names in [CONTRIBUTING.md](https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#parser-configurations). + +The first query file on `runtimepath` will be used (see `:h treesitter-query`). +If you want to make a query on the user config extend other queries instead of +replacing them, see `:h treesitter-query-modeline-extends`. + +If you want to completely override a query, you can use `:h vim.treesitter.query.set()`. +For example, to override the `injections` queries from `c` with your own: + +```lua +vim.treesitter.query.set("c", "injections", "(comment) @comment") +``` + +Note: when using `query.set()`, all queries in the runtime directories will be ignored. + +## Adding modules + +If you wish you write your own module, you need to support + +- tree-sitter language detection support; +- attaching and detaching to buffers; +- all nvim-treesitter commands. + +At the top level, you can use the `define_modules` function to define one or more modules or module groups: + +```lua +require'nvim-treesitter'.define_modules { + my_cool_plugin = { + attach = function(bufnr, lang) + -- Do cool stuff here + end, + detach = function(bufnr) + -- Undo cool stuff here + end, + is_supported = function(lang) + -- Check if the language is supported + end + } +} +``` + +with the following properties: + +- `module_path` specifies a require path (string) that exports a module with an `attach` and `detach` function. This is not required if the functions are on this definition. +- `enable` determines if the module is enabled by default. This is usually overridden by the user. +- `disable` takes a list of languages that this module is disabled for. This is usually overridden by the user. +- `is_supported` takes a function that takes a language and determines if this module supports that language. +- `attach` takes a function that attaches to a buffer. This is required if `module_path` is not provided. +- `detach` takes a function that detaches from a buffer. This is required if `module_path` is not provided. + +# Extra features + +### Statusline indicator + +```vim +echo nvim_treesitter#statusline(90) " 90 can be any length +module->expression_statement->call->identifier +``` + +### Utilities + +You can get some utility functions with + +```lua +local ts_utils = require 'nvim-treesitter.ts_utils' +``` + +Check [`:h nvim-treesitter-utils`](doc/nvim-treesitter.txt) for more information. + +# Troubleshooting + +Before doing anything, make sure you have the latest version of this plugin and run `:checkhealth nvim-treesitter`. +It can also help to update the parsers via `:TSUpdate`. + +#### Feature `X` does not work for `{language}`... + +First, check the `health#nvim_treesitter#check` and the `health#treesitter#check` sections of `:checkhealth` for any warning. +If there is one, it's highly likely that this is the cause of the problem. + +Next check the `## Parser/Features` subsection of the `health#nvim_treesitter#check` section of `:checkhealth` to ensure the desired module is enabled for your language. +If not, you might be missing query files; see [Adding queries](#adding-queries). + +Finally, ensure Neovim is correctly identifying your language's filetype using the `:echo &filetype` command while one of your language's files is open in Neovim. +If not, add a short Vimscript file to nvim-treesitter's `ftdetect` runtime directory following [Neovim's documentation](https://neovim.io/doc/user/filetype.html#new-filetype) on filetype detection. +You can also quickly & temporarily set the filetype for a single buffer with the `:set filetype=langname` command to test whether it fixes the problem. + +If everything is okay, then it might be an actual error. +In that case, feel free to [open an issue here](https://github.com/nvim-treesitter/nvim-treesitter/issues/new/choose). + +#### I get `module 'vim.treesitter.query' not found` + +Make sure you have the latest version of Neovim. + +#### I get `Error detected while processing .../plugin/nvim-treesitter.vim` every time I open Neovim + +This is probably due to a change in a parser's grammar or its queries. +Try updating the parser that you suspect has changed (`:TSUpdate {language}`) or all of them (`:TSUpdate`). +If the error persists after updating all parsers, +please [open an issue](https://github.com/nvim-treesitter/nvim-treesitter/issues/new/choose). + +#### I get `query error: invalid node type at position` + +This could be due a query file outside this plugin using outdated nodes, +or due to an outdated parser. + +- Make sure you have the parsers up to date with `:TSUpdate` +- Make sure you don't have more than one `parser` runtime directory. + You can execute this command `:echo nvim_get_runtime_file('parser', v:true)` to find all runtime directories. + If you get more than one path, remove the ones that are outside this plugin (`nvim-treesitter` directory), + so the correct version of the parser is used. + +#### I experience weird highlighting issues similar to [#78](https://github.com/nvim-treesitter/nvim-treesitter/issues/78) + +This is a well known issue, which arises when the tree and the buffer have gotten out of sync. +As this is an upstream issue, we don't have any definite fix. +To get around this, you can force reparsing the buffer with + +```vim +:write | edit | TSBufEnable highlight +``` + +This will save, restore and enable highlighting for the current buffer. + +#### I experience bugs when using `nvim-treesitter`'s `foldexpr` similar to [#194](https://github.com/nvim-treesitter/nvim-treesitter/issues/194) + +This might happen, and is known to happen, with `vim-clap`. +To avoid these kind of errors, please use `setlocal` instead of `set` for the respective filetypes. + +#### I run into errors like `module 'nvim-treesitter.configs' not found` at startup + +This is because of `rtp` management in `nvim`, adding `packadd +nvim-treesitter` should fix the issue. + +#### I want to use Git instead of curl for downloading the parsers + +In your Lua config: + +```lua +require("nvim-treesitter.install").prefer_git = true +``` + +#### I want to use a HTTP proxy for downloading the parsers + +You can either configure curl to use additional CLI arguments in your Lua config: + +```lua +require("nvim-treesitter.install").command_extra_args = { + curl = { "--proxy", "" }, +} +``` + +or you can configure git via `.gitconfig` and use git instead of curl + +```lua +require("nvim-treesitter.install").prefer_git = true +``` + +#### I want to use a mirror instead of "https://github.com/" + +In your Lua config: + +```lua +for _, config in pairs(require("nvim-treesitter.parsers").get_parser_configs()) do + config.install_info.url = config.install_info.url:gsub("https://github.com/", "something else") +end + +require'nvim-treesitter.configs'.setup { + -- + -- +} +``` + +#### Using an existing parser for another filetype + +For example, to use the `bash` tree-sitter to highlight file with +`filetype=apkbuild`, use: + +```lua +vim.treesitter.language.register("bash", "apkbuild") +``` + +The `bash` tree-sitter must be installed following the usual procedure [as +described above](#language-parsers). diff --git a/pack/ant/start/nvim-treesitter/assets/logo.png b/pack/ant/start/nvim-treesitter/assets/logo.png new file mode 100644 index 0000000..a60e536 Binary files /dev/null and b/pack/ant/start/nvim-treesitter/assets/logo.png differ diff --git a/pack/ant/start/nvim-treesitter/autoload/nvim_treesitter.vim b/pack/ant/start/nvim-treesitter/autoload/nvim_treesitter.vim new file mode 100644 index 0000000..9095398 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/autoload/nvim_treesitter.vim @@ -0,0 +1,27 @@ +function! nvim_treesitter#statusline(...) abort + return luaeval("require'nvim-treesitter.statusline'.statusline(_A)", get(a:, 1, {})) +endfunction + +function! nvim_treesitter#foldexpr() abort + return luaeval(printf('require"nvim-treesitter.fold".get_fold_indic(%d)', v:lnum)) +endfunction + +function! nvim_treesitter#installable_parsers(arglead, cmdline, cursorpos) abort + return join(luaeval("require'nvim-treesitter.parsers'.available_parsers()") + ['all'], "\n") +endfunction + +function! nvim_treesitter#installed_parsers(arglead, cmdline, cursorpos) abort + return join(luaeval("require'nvim-treesitter.info'.installed_parsers()") + ['all'], "\n") +endfunction + +function! nvim_treesitter#available_modules(arglead, cmdline, cursorpos) abort + return join(luaeval("require'nvim-treesitter.configs'.available_modules()"), "\n") +endfunction + +function! nvim_treesitter#available_query_groups(arglead, cmdline, cursorpos) abort + return join(luaeval("require'nvim-treesitter.query'.available_query_groups()"), "\n") +endfunction + +function! nvim_treesitter#indent() abort + return luaeval(printf('require"nvim-treesitter.indent".get_indent(%d)', v:lnum)) +endfunction diff --git a/pack/ant/start/nvim-treesitter/contrib/nvim-treesitter-luarocks.template b/pack/ant/start/nvim-treesitter/contrib/nvim-treesitter-luarocks.template new file mode 100644 index 0000000..8109f5f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/contrib/nvim-treesitter-luarocks.template @@ -0,0 +1,41 @@ +local git_ref = '$git_ref' +local modrev = '$modrev' +local specrev = '-1' + +local repo_url = '$repo_url' + +rockspec_format = '3.0' +package = '$package' +version = modrev .. specrev + +description = { + summary = 'Nvim Treesitter configurations and abstraction layer', + detailed = $detailed_description, + labels = { 'neovim' }, + homepage = 'https://github.com/nvim-treesitter/nvim-treesitter', + license = 'Apache-2.0', +} + +dependencies = { + 'lua >= 5.1', +} + +-- source = file:///. + +source = { + url = repo_url .. '/archive/' .. git_ref .. '.zip', + dir = '$repo_name-' .. '$archive_dir_suffix', +} + +build = { + type = 'make', + build_pass = false, + install_variables = { + INST_PREFIX='$(PREFIX)', + INST_BINDIR='$(BINDIR)', + INST_LIBDIR='$(LIBDIR)', + INST_LUADIR='$(LUADIR)', + INST_CONFDIR='$(CONFDIR)', + }, + copy_directories = $copy_directories, +} diff --git a/pack/ant/start/nvim-treesitter/contrib/nvim-treesitter-scm-1.rockspec b/pack/ant/start/nvim-treesitter/contrib/nvim-treesitter-scm-1.rockspec new file mode 100644 index 0000000..a901c5b --- /dev/null +++ b/pack/ant/start/nvim-treesitter/contrib/nvim-treesitter-scm-1.rockspec @@ -0,0 +1,36 @@ +local MODREV, SPECREV = 'scm', '-1' +rockspec_format = '3.0' +package = 'nvim-treesitter' +version = MODREV .. SPECREV + +description = { + summary = 'Nvim Treesitter configurations and abstraction layer', + labels = { 'neovim' }, + homepage = 'https://github.com/nvim-treesitter/nvim-treesitter', + license = 'Apache-2.0', +} + +dependencies = { + 'lua >= 5.1', +} + +source = { + url = 'git://github.com/nvim-treesitter/nvim-treesitter', +} + +build = { + type = 'make', + install_variables = { + INST_PREFIX='$(PREFIX)', + INST_BINDIR='$(BINDIR)', + INST_LIBDIR='$(LIBDIR)', + INST_LUADIR='$(LUADIR)', + INST_CONFDIR='$(CONFDIR)', + }, + copy_directories = { + 'autoload', + 'doc', + 'plugin', + 'queries' + } +} diff --git a/pack/ant/start/nvim-treesitter/doc/nvim-treesitter.txt b/pack/ant/start/nvim-treesitter/doc/nvim-treesitter.txt new file mode 100644 index 0000000..f7a91b8 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/doc/nvim-treesitter.txt @@ -0,0 +1,590 @@ +*nvim-treesitter* Treesitter configurations and abstraction layer for Neovim. + +Minimum version of neovim: nightly + +Authors: + Kiyan Yazdani + Thomas Vigouroux + Stephan Seitz + Steven Sojka + Santos Gallegos + https://github.com/nvim-treesitter/nvim-treesitter/graphs/contributors + + Type |gO| to see the table of contents. + +============================================================================== +INTRODUCTION *nvim-treesitter-intro* + +nvim-treesitter wraps the Neovim treesitter API to provide functionalities +such as highlighting and incremental selection, and a command to easily +install parsers. + +============================================================================== +QUICK START *nvim-treesitter-quickstart* + +Install the parser for your language + +> + :TSInstall {language} +< + +To get a list of supported languages + +> + :TSInstallInfo +< + +By default, everything is disabled. +To enable supported features, put this in your `init.lua` file: + +> + require'nvim-treesitter.configs'.setup { + -- A directory to install the parsers into. + -- If this is excluded or nil parsers are installed + -- to either the package dir, or the "site" dir. + -- If a custom path is used (not nil) it must be added to the runtimepath. + parser_install_dir = "/some/path/to/store/parsers", + + -- A list of parser names, or "all" + ensure_installed = { "c", "lua", "rust" }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + auto_install = false, + + -- List of parsers to ignore installing (for "all") + ignore_install = { "javascript" }, + + highlight = { + -- `false` will disable the whole extension + enable = true, + + -- list of language that will be disabled + disable = { "c", "rust" }, + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, + } + vim.opt.runtimepath:append("/some/path/to/store/parsers") +< + +See |nvim-treesitter-modules| for a list of all available modules and its options. + +============================================================================== +MODULES *nvim-treesitter-modules* + +|nvim-treesitter| provides several functionalities via modules (and submodules), +each module makes use of the query files defined for each language, + +All modules are disabled by default, and some provide default keymaps. +Each module corresponds to an entry in the dictionary passed to the +`nvim-treesitter.configs.setup` function, this should be in your `init.lua` file. + +> + require'nvim-treesitter.configs'.setup { + -- Modules and its options go here + highlight = { enable = true }, + incremental_selection = { enable = true }, + textobjects = { enable = true }, + } +< + +All modules share some common options, like `enable` and `disable`. +When `enable` is `true` this will enable the module for all supported languages, +if you want to disable the module for some languages you can pass a list to the `disable` option. + +> + require'nvim-treesitter.configs'.setup { + highlight = { + enable = true, + disable = { "cpp", "lua" }, + }, + } +< + +For more fine-grained control, `disable` can also take a function and +whenever it returns `true`, the module is disabled for that buffer. +The function is called once when a module starts in a buffer and receives the +language and buffer number as arguments: + +> + require'nvim-treesitter.configs'.setup { + highlight = { + enable = true, + disable = function(lang, bufnr) -- Disable in large C++ buffers + return lang == "cpp" and vim.api.nvim_buf_line_count(bufnr) > 50000 + end, + }, + } +< + +Options that define or accept a keymap use the same format you use to define +keymaps in Neovim, so you can write keymaps as `gd`, `a`, `a` +`` (control + a), `` (alt + n), `` (enter), etc. + +External plugins can provide their own modules with their own options, +those can also be configured using the `nvim-treesitter.configs.setup` +function. + +------------------------------------------------------------------------------ +HIGHLIGHT *nvim-treesitter-highlight-mod* + +Consistent syntax highlighting. + +Query files: `highlights.scm`. +Supported options: + +- enable: `true` or `false`. +- disable: list of languages. +- additional_vim_regex_highlighting: `true` or `false`, or a list of languages. + Set this to `true` if you depend on 'syntax' being enabled + (like for indentation). Using this option may slow down your editor, + and you may see some duplicate highlights. + Defaults to `false`. + +> + require'nvim-treesitter.configs'.setup { + highlight = { + enable = true, + custom_captures = { + -- Highlight the @foo.bar capture group with the "Identifier" highlight group. + ["foo.bar"] = "Identifier", + }, + -- Setting this to true or a list of languages will run `:h syntax` and tree-sitter at the same time. + additional_vim_regex_highlighting = false, + }, + } +< + +You can also set custom highlight captures +> + lua < + require'nvim-treesitter.configs'.setup { + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, + } +< + +------------------------------------------------------------------------------ +INDENTATION *nvim-treesitter-indentation-mod* + +Indentation based on treesitter for the |=| operator. +NOTE: this is an experimental feature. + +Query files: `indents.scm`. +Supported options: +- enable: `true` or `false`. +- disable: list of languages. +> + require'nvim-treesitter.configs'.setup { + indent = { + enable = true + }, + } + +`@indent` *nvim-treesitter-indentation-queries* +Queries can use the following captures: `@indent.begin` and `@indent.dedent`, +`@indent.branch`, `@indent.end` or `@indent.align`. An `@indent.ignore` capture tells +treesitter to ignore indentation and a `@indent.zero` capture sets +the indentation to 0. + +`@indent.begin` *nvim-treesitter-indentation-indent.begin* +The `@indent.begin` specifies that the next line should be indented. Multiple +indents on the same line get collapsed. Eg. + +> + ( + (if_statement) + (ERROR "else") @indent.begin + ) +< +Indent can also have `indent.immediate` set using a `#set!` directive, which +permits the next line to indent even when the block intended to be indented +has no content yet, improving interactive typing. + +eg for python: +> + ((if_statement) @indent.begin + (#set! indent.immediate 1)) +< + +Will allow: +> + if True: + # Auto indent to here + +`@indent.end` *nvim-treesitter-indentation-indent.end* +An `@indent.end` capture is used to specify that the indented region ends and +any text subsequent to the capture should be dedented. + +`@indent.branch` *nvim-treesitter-indentation-indent.branch* +An `@indent.branch` capture is used to specify that a dedented region starts +at the line including the captured nodes. + +`@indent.dedent` *nvim-treesitter-indentation-indent.dedent* +A `@indent.dedent` capture specifies dedenting starting on the next line. +> +`@indent.align` *nvim-treesitter-indentation-aligned_indent.align* +Aligned indent blocks may be specified with the `@indent.align` capture. +This permits + +> + foo(a, + b, + c) +< +As well as +> + foo( + a, + b, + c) +< +and finally +> + foo( + a, + b, + c + ) +< +To specify the delimiters to use `indent.open_delimiter` and +`indent.close_delimiter` should be used. Eg. +> + ((argument_list) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) +< + +For some languages the last line of an `indent.align` block must not be +the same indent as the natural next line. + +For example in python: + +> + if (a > b and + c < d): + pass + +Is not correct, whereas +> + if (a > b and + c < d): + pass + +Would be correctly indented. This behavior may be chosen using +`indent.avoid_last_matching_next`. Eg. + +> + (if_statement + condition: (parenthesized_expression) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")") + (#set! indent.avoid_last_matching_next 1) + ) +< +Could be used to specify that the last line of an `@indent.align` capture +should be additionally indented to avoid clashing with the indent of the first +line of the block inside an if. + +============================================================================== +COMMANDS *nvim-treesitter-commands* + + *:TSInstall* +:TSInstall {language} ...~ + +Install one or more treesitter parsers. +You can use |:TSInstall| `all` to install all parsers. Use |:TSInstall!| to +force the reinstallation of already installed parsers. + *:TSInstallSync* +:TSInstallSync {language} ...~ + +Perform the |:TSInstall| operation synchronously. + + *:TSInstallInfo* +:TSInstallInfo~ + +List information about currently installed parsers + + *:TSUpdate* +:TSUpdate {language} ...~ + +Update the installed parser for one more {language} or all installed parsers +if {language} is omitted. The specified parser is installed if it is not already +installed. + + *:TSUpdateSync* +:TSUpdateSync {language} ...~ + +Perform the |:TSUpdate| operation synchronously. + + *:TSUninstall* +:TSUninstall {language} ...~ + +Deletes the parser for one or more {language}. You can use 'all' for language +to uninstall all parsers. + + *:TSBufEnable* +:TSBufEnable {module}~ + +Enable {module} on the current buffer. +A list of modules can be found at |:TSModuleInfo| + + *:TSBufDisable* +:TSBufDisable {module}~ + +Disable {module} on the current buffer. +A list of modules can be found at |:TSModuleInfo| + + *:TSBufToggle* +:TSBufToggle {module}~ + +Toggle (enable if disabled, disable if enabled) {module} on the current +buffer. +A list of modules can be found at |:TSModuleInfo| + + *:TSEnable* +:TSEnable {module} [{language}]~ + +Enable {module} for the session. +If {language} is specified, enable module for the session only for this +particular language. +A list of modules can be found at |:TSModuleInfo| +A list of languages can be found at |:TSInstallInfo| + + *:TSDisable* +:TSDisable {module} [{language}]~ + +Disable {module} for the session. +If {language} is specified, disable module for the session only for this +particular language. +A list of modules can be found at |:TSModuleInfo| +A list of languages can be found at |:TSInstallInfo| + + *:TSToggle* +:TSToggle {module} [{language}]~ + +Toggle (enable if disabled, disable if enabled) {module} for the session. +If {language} is specified, toggle module for the session only for this +particular language. +A list of modules can be found at |:TSModuleInfo| +A list of languages can be found at |:TSInstallInfo| + + *:TSModuleInfo* +:TSModuleInfo [{module}]~ + +List the state for the given module or all modules for the current session in +a new buffer. + +These highlight groups are used by default: +> + highlight default TSModuleInfoGood guifg=LightGreen gui=bold + highlight default TSModuleInfoBad guifg=Crimson + highlight default link TSModuleInfoHeader Type + highlight default link TSModuleInfoNamespace Statement + highlight default link TSModuleInfoParser Identifier +< + + *:TSEditQuery* +:TSEditQuery {query-group} [{lang}]~ + +Edit the query file for a {query-group} (e.g. highlights, locals) for given +{lang}. If there are multiple files, the user is prompted to select one of them. +If no such file exists, a buffer for a new file in the user's config directory +is created. If {lang} is not specified, the language of the current buffer +is used. + + *:TSEditQueryUserAfter* +:TSEditQueryUserAfter {query-group} [{lang}]~ + +Same as |:TSEditQuery| but edits a file in the `after` directory of the +user's config directory. Useful to add custom extensions for the queries +provided by a plugin. + +============================================================================== +UTILS *nvim-treesitter-utils* + +Nvim treesitter has some wrapper functions that you can retrieve with: +> + local ts_utils = require 'nvim-treesitter.ts_utils' +< +Methods + *ts_utils.get_node_at_cursor* +get_node_at_cursor(winnr)~ + +`winnr` will be 0 if nil. +Returns the node under the cursor. + + *ts_utils.is_parent* +is_parent(dest, source)~ + +Determines whether `dest` is a parent of `source`. +Returns a boolean. + + *ts_utils.get_named_children* +get_named_children(node)~ + +Returns a table of named children of `node`. + + *ts_utils.get_next_node* +get_next_node(node, allow_switch_parent, allow_next_parent)~ + +Returns the next node within the same parent. +If no node is found, returns `nil`. +If `allow_switch_parent` is true, it will allow switching parent +when the node is the last node. +If `allow_next_parent` is true, it will allow next parent if +the node is the last node and the next parent doesn't have children. + + *ts_utils.get_previous_node* +get_previous_node(node, allow_switch_parents, allow_prev_parent)~ + +Returns the previous node within the same parent. +`allow_switch_parent` and `allow_prev_parent` follow the same rule +as |ts_utils.get_next_node| but if the node is the first node. + + *ts_utils.goto_node* +goto_node(node, goto_end, avoid_set_jump)~ + +Sets cursor to the position of `node` in the current windows. +If `goto_end` is truthy, the cursor is set to the end the node range. +Setting `avoid_set_jump` to `true`, avoids setting the current cursor position +to the jump list. + + *ts_utils.swap_nodes* +swap_nodes(node_or_range1, node_or_range2, bufnr, cursor_to_second)~ + +Swaps the nodes or ranges. +set `cursor_to_second` to true to move the cursor to the second node + + *ts_utils.memoize_by_buf_tick* +memoize_by_buf_tick(fn, options)~ + +Caches the return value for a function and returns the cache value if the tick +of the buffer has not changed from the previous. + + `fn`: a function that takes any arguments + and returns a value to store. + `options?`: + - `bufnr`: a function/value that extracts the bufnr from the given arguments. + - `key`: a function/value that extracts the cache key from the given arguments. + `returns`: a function to call with bufnr as argument to + retrieve the value from the cache + + *ts_utils.node_to_lsp_range* +node_to_lsp_range(node)~ + +Get an lsp formatted range from a node range + + *ts_utils.node_length* +node_length(node)~ + +Get the byte length of node range + + *ts_utils.update_selection* +update_selection(buf, node)~ + +Set the selection to the node range + + *ts_utils.highlight_range* +highlight_range(range, buf, hl_namespace, hl_group)~ + +Set a highlight that spans the given range + + *ts_utils.highlight_node* +highlight_node(node, buf, hl_namespace, hl_group)~ + +Set a highlight that spans the given node's range + +============================================================================== +FUNCTIONS *nvim-treesitter-functions* + + *nvim_treesitter#statusline()* +nvim_treesitter#statusline(opts)~ + +Returns a string describing the current position in the file. This +could be used as a statusline indicator. +Default options (lua syntax): +> + { + indicator_size = 100, + type_patterns = {'class', 'function', 'method'}, + transform_fn = function(line, _node) return line:gsub('%s*[%[%(%{]*%s*$', '') end, + separator = ' -> ', + allow_duplicates = false + } +< +- `indicator_size` - How long should the string be. If longer, it is cut from + the beginning. +- `type_patterns` - Which node type patterns to match. +- `transform_fn` - Function used to transform the single item in line. By + default it removes opening brackets and spaces from end. Takes two arguments: + the text of the line in question, and the corresponding treesitter node. +- `separator` - Separator between nodes. +- `allow_duplicates` - Whether or not to remove duplicate components. + + *nvim_treesitter#foldexpr()* +nvim_treesitter#foldexpr()~ + +Functions to be used to determine the fold level at a given line number. +To use it: > + set foldmethod=expr + set foldexpr=nvim_treesitter#foldexpr() +< + +This will respect your 'foldminlines' and 'foldnestmax' settings. + +Note: This is highly experimental, and folding can break on some types of + edits. If you encounter such breakage, hitting `zx` should fix folding. + In any case, feel free to open an issue with the reproducing steps. + +============================================================================== +PERFORMANCE *nvim-treesitter-performance* + +`nvim-treesitter` checks the 'runtimepath' on startup in order to discover +available parsers and queries and index them. As a consequence, a very long +'runtimepath' might result in delayed startup times. + + +vim:tw=78:ts=8:expandtab:noet:ft=help:norl: diff --git a/pack/ant/start/nvim-treesitter/lockfile.json b/pack/ant/start/nvim-treesitter/lockfile.json new file mode 100644 index 0000000..627e8e6 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lockfile.json @@ -0,0 +1,905 @@ +{ + "ada": { + "revision": "e8e2515465cc2d7c444498e68bdb9f1d86767f95" + }, + "agda": { + "revision": "6516cfec35479d62c0ad3c8e7e546a9774b489fd" + }, + "angular": { + "revision": "745d3c65c2294aca1110b6b6ad6805124be605c9" + }, + "apex": { + "revision": "46d4a12e4e90b10a575b7b16ea3b6ead50322074" + }, + "arduino": { + "revision": "415ebc8f75eb02a748faa03f5af199f08ced120f" + }, + "asm": { + "revision": "55b2b913f1e71136027d6fce8212e760c64f3532" + }, + "astro": { + "revision": "4be180759ec13651f72bacee65fa477c64222a1a" + }, + "authzed": { + "revision": "1dec7e1af96c56924e3322cd85fdce15d0a31d00" + }, + "awk": { + "revision": "553fdc4afb3b603332c3f4baf50c711506f4e797" + }, + "bash": { + "revision": "597a5ed6ed4d932fd44697feec988f977081ae59" + }, + "bass": { + "revision": "28dc7059722be090d04cd751aed915b2fee2f89a" + }, + "beancount": { + "revision": "01c0da29e0fc7130420a09d939ecc524e09b6ba6" + }, + "bibtex": { + "revision": "ccfd77db0ed799b6c22c214fe9d2937f47bc8b34" + }, + "bicep": { + "revision": "0092c7d1bd6bb22ce0a6f78497d50ea2b87f19c0" + }, + "bitbake": { + "revision": "a5d04fdb5a69a02b8fa8eb5525a60dfb5309b73b" + }, + "blueprint": { + "revision": "60ba73739c6083c693d86a1a7cf039c07eb4ed59" + }, + "bp": { + "revision": "4e60cf3c2e613625c06f6f85540b3631e2d06cd3" + }, + "c": { + "revision": "79284a14a0d7e4495b095b38acdd8a27acbe870e" + }, + "c_sharp": { + "revision": "3a85187e0a9e8db01dec6b3eb2f4e7cdfecc9d88" + }, + "cairo": { + "revision": "6238f609bea233040fe927858156dee5515a0745" + }, + "capnp": { + "revision": "7b0883c03e5edd34ef7bcf703194204299d7099f" + }, + "chatito": { + "revision": "a461f20dedb43905febb12c1635bc7d2e43e96f0" + }, + "clojure": { + "revision": "f4236d4da8aa92bc105d9c118746474c608e6af7" + }, + "cmake": { + "revision": "e409ae33f00e04cde30f2bcffb979caf1a33562a" + }, + "comment": { + "revision": "3555706cef8b98d3e4c7379d7260548ff03ad363" + }, + "commonlisp": { + "revision": "bf2a65b1c119898a1a17389e07f2a399c05cdc0c" + }, + "cooklang": { + "revision": "4ebe237c1cf64cf3826fc249e9ec0988fe07e58e" + }, + "corn": { + "revision": "464654742cbfd3a3de560aba120998f1d5dfa844" + }, + "cpon": { + "revision": "594289eadfec719198e560f9d7fd243c4db678d5" + }, + "cpp": { + "revision": "16bf9d2c451957aee976c982c2c668b1c0d12014" + }, + "css": { + "revision": "ccc4e2c4b30ddabc4b41c577ad0550b3cac4a74a" + }, + "csv": { + "revision": "7eb7297823605392d2bbcc4c09b1cd18d6fa9529" + }, + "cuda": { + "revision": "635e8aa3747823a0c4e9660c07cef76fe8d3ef93" + }, + "cue": { + "revision": "8a5f273bfa281c66354da562f2307c2d394b6c81" + }, + "d": { + "revision": "45e5f1e9d6de2c68591bc8e5ec662cf18e950b4a" + }, + "dart": { + "revision": "9ac03bb2154316624fb4c41fe0f372a5f1597b43" + }, + "devicetree": { + "revision": "16c9cb959675bc9bc4f4e5bebe473d511a12a06d" + }, + "dhall": { + "revision": "affb6ee38d629c9296749767ab832d69bb0d9ea8" + }, + "diff": { + "revision": "63439b5e6e35750aff1e53d9eecc663d369c54bc" + }, + "disassembly": { + "revision": "0229c0211dba909c5d45129ac784a3f4d49c243a" + }, + "djot": { + "revision": "886601b67d1f4690173a4925c214343c30704d32" + }, + "dockerfile": { + "revision": "087daa20438a6cc01fa5e6fe6906d77c869d19fe" + }, + "dot": { + "revision": "9ab85550c896d8b294d9b9ca1e30698736f08cea" + }, + "doxygen": { + "revision": "ccd998f378c3f9345ea4eeb223f56d7b84d16687" + }, + "dtd": { + "revision": "cd1316e476ec40da6ce1fb5749c9d7e6b4f1090c" + }, + "earthfile": { + "revision": "1d637f2002bb8b22d4c08d26ad2bfbc22916f3ce" + }, + "ebnf": { + "revision": "8e635b0b723c620774dfb8abf382a7f531894b40" + }, + "editorconfig": { + "revision": "777f774d6381f1bb84adffa02a4e476fb61486ae" + }, + "eds": { + "revision": "26d529e6cfecde391a03c21d1474eb51e0285805" + }, + "eex": { + "revision": "f742f2fe327463335e8671a87c0b9b396905d1d1" + }, + "elixir": { + "revision": "2ac7a0f81f0731d83068b2872c4a8fee39263a85" + }, + "elm": { + "revision": "27f502ed0a1cbd3c5912d284cc7934ee0d4cdddc" + }, + "elsa": { + "revision": "0a66b2b3f3c1915e67ad2ef9f7dbd2a84820d9d7" + }, + "elvish": { + "revision": "5e7210d945425b77f82cbaebc5af4dd3e1ad40f5" + }, + "embedded_template": { + "revision": "7e319b065c5864bac2fb68f7e14a338b919e8bb3" + }, + "erlang": { + "revision": "4095e9993acc89cb311ab1be8614c21b1cf768a4" + }, + "facility": { + "revision": "2d037f2f2bf668737f72e6be6eda4b7918b68d86" + }, + "faust": { + "revision": "f3b9274514b5f9bf6b0dd4a01c30f9cc15c58bc4" + }, + "fennel": { + "revision": "cfbfa478dc2dbef267ee94ae4323d9c886f45e94" + }, + "fidl": { + "revision": "0a8910f293268e27ff554357c229ba172b0eaed2" + }, + "firrtl": { + "revision": "8503d3a0fe0f9e427863cb0055699ff2d29ae5f5" + }, + "fish": { + "revision": "a78aef9abc395c600c38a037ac779afc7e3cc9e0" + }, + "foam": { + "revision": "04664b40c0dadb7ef37028acf3422c63271d377b" + }, + "forth": { + "revision": "90189238385cf636b9ee99ce548b9e5b5e569d48" + }, + "fortran": { + "revision": "4a593dda9cbc050a6686187249f8350ceea292ce" + }, + "fsh": { + "revision": "fad2e175099a45efbc98f000cc196d3674cc45e0" + }, + "fsharp": { + "revision": "971da5ff0266bfe4a6ecfb94616548032d6d1ba0" + }, + "func": { + "revision": "f780ca55e65e7d7360d0229331763e16c452fc98" + }, + "fusion": { + "revision": "19db2f47ba4c3a0f6238d4ae0e2abfca16e61dd6" + }, + "gap": { + "revision": "141b063335e85299bde3f61b4888d02d674a1abc" + }, + "gaptst": { + "revision": "e0723dc6136309b3d5904dad2c73ef71267428c1" + }, + "gdscript": { + "revision": "1f1e782fe2600f50ae57b53876505b8282388d77" + }, + "gdshader": { + "revision": "ffd9f958df13cae04593781d7d2562295a872455" + }, + "git_config": { + "revision": "9c2a1b7894e6d9eedfe99805b829b4ecd871375e" + }, + "git_rebase": { + "revision": "bff4b66b44b020d918d67e2828eada1974a966aa" + }, + "gitattributes": { + "revision": "41940e199ba5763abea1d21b4f717014b45f01ea" + }, + "gitcommit": { + "revision": "db0e0c4fb9095fdc42a7af34019c0616c071e9eb" + }, + "gitignore": { + "revision": "f4685bf11ac466dd278449bcfe5fd014e94aa504" + }, + "gleam": { + "revision": "57c9951b290c8084d7c60b0aee7a2b30986ea031" + }, + "glimmer": { + "revision": "da605af8c5999b43e6839b575eae5e6cafabb06f" + }, + "glimmer_javascript": { + "revision": "7e8ea8cf39fc360cb97bd253442cd48e4f7a9ce3" + }, + "glimmer_typescript": { + "revision": "4006128790efb58ca82a4492d8ef0983b260fc6a" + }, + "glsl": { + "revision": "66aec57f7119c7e8e40665b723cd7af5594f15ee" + }, + "gn": { + "revision": "bc06955bc1e3c9ff8e9b2b2a55b38b94da923c05" + }, + "gnuplot": { + "revision": "3c895f5d9c0b3a3c7e02383766b462c21913c000" + }, + "go": { + "revision": "df2ce2e206d2810bf010d73055055bfcff1b55aa" + }, + "goctl": { + "revision": "49c43532689fe1f53e8b9e009d0521cab02c432b" + }, + "godot_resource": { + "revision": "2ffb90de47417018651fc3b970e5f6b67214dc9d" + }, + "gomod": { + "revision": "3b01edce2b9ea6766ca19328d1850e456fde3103" + }, + "gosum": { + "revision": "e2ac513b2240c7ff1069ae33b2df29ce90777c11" + }, + "gotmpl": { + "revision": "ca52fbfc98366c585b84f4cb3745df49f33cd140" + }, + "gowork": { + "revision": "949a8a470559543857a62102c84700d291fc984c" + }, + "gpg": { + "revision": "f99323fb8f3f10b6c69db0c2f6d0a14bd7330675" + }, + "graphql": { + "revision": "5e66e961eee421786bdda8495ed1db045e06b5fe" + }, + "gren": { + "revision": "c06e272341363c5d8e19ac34bc7c56258a37e71b" + }, + "groovy": { + "revision": "0d8884514fe10c4fa47527d9a0284d207f38ddea" + }, + "gstlaunch": { + "revision": "549aef253fd38a53995cda1bf55c501174372bf7" + }, + "hack": { + "revision": "fca1e294f6dce8ec5659233a6a21f5bd0ed5b4f2" + }, + "hare": { + "revision": "4af5d82cf9ec39f67cb1db5b7a9269d337406592" + }, + "haskell": { + "revision": "70ea0757986ea58a0d39ddfcd9d791beadeb0f43" + }, + "haskell_persistent": { + "revision": "577259b4068b2c281c9ebf94c109bd50a74d5857" + }, + "hcl": { + "revision": "9e3ec9848f28d26845ba300fd73c740459b83e9b" + }, + "heex": { + "revision": "6dd0303acf7138dd2b9b432a229e16539581c701" + }, + "helm": { + "revision": "ca52fbfc98366c585b84f4cb3745df49f33cd140" + }, + "hjson": { + "revision": "02fa3b79b3ff9a296066da6277adfc3f26cbc9e0" + }, + "hlsl": { + "revision": "b309425a7ab4456605cfe78774b80f7e275ca87d" + }, + "hlsplaylist": { + "revision": "3bfda9271e3adb08d35f47a2102fe957009e1c55" + }, + "hocon": { + "revision": "c390f10519ae69fdb03b3e5764f5592fb6924bcc" + }, + "hoon": { + "revision": "a24c5a39d1d7e993a8bee913c8e8b6a652ca5ae8" + }, + "html": { + "revision": "c30792dee70aaa1910e66a39557a841b6e4386d5" + }, + "htmldjango": { + "revision": "ea71012d3fe14dd0b69f36be4f96bdfe9155ebae" + }, + "http": { + "revision": "231f1b1bafd12e46c8ed8c21dbbdd940d9f15e94" + }, + "hurl": { + "revision": "ff07a42d9ec95443b5c1b57ed793414bf7b79be5" + }, + "hyprlang": { + "revision": "6858695eba0e63b9e0fceef081d291eb352abce8" + }, + "idl": { + "revision": "5573b295410201ed22771776b34d636900eba368" + }, + "ini": { + "revision": "962568c9efa71d25720ab42c5d36e222626ef3a6" + }, + "inko": { + "revision": "6f9c072d023c3886aabcd8012274461b35d2d0a9" + }, + "ispc": { + "revision": "9b2f9aec2106b94b4e099fe75e73ebd8ae707c04" + }, + "janet_simple": { + "revision": "12bfab7db8a5f5b1d774ef84b5831acd34936071" + }, + "java": { + "revision": "b864ed97b9675e86de7c15a70c12e4c1ca85fbf9" + }, + "javascript": { + "revision": "c4ce9dc8e7e98ea25757ea26bfe9a022043ccd77" + }, + "jq": { + "revision": "13990f530e8e6709b7978503da9bc8701d366791" + }, + "jsdoc": { + "revision": "b2237872e528b8372ed008068f717db66c16a725" + }, + "json": { + "revision": "f2503f1c437fe24560876557868ac94c9cfd3216" + }, + "json5": { + "revision": "ab0ba8229d639ec4f3fa5f674c9133477f4b77bd" + }, + "jsonc": { + "revision": "02b01653c8a1c198ae7287d566efa86a135b30d5" + }, + "jsonnet": { + "revision": "ddd075f1939aed8147b7aa67f042eda3fce22790" + }, + "julia": { + "revision": "19f62656dc7f2ff3756a8ef3dcf9ab1c01a9eb58" + }, + "just": { + "revision": "6aee3d2f5b3a47286bae0916daaa6c7a217f6fa4" + }, + "kconfig": { + "revision": "486fea71f61ad9f3fd4072a118402e97fe88d26c" + }, + "kdl": { + "revision": "b37e3d58e5c5cf8d739b315d6114e02d42e66664" + }, + "kotlin": { + "revision": "76f53c48d29e8588934fb55b0240d7bdfe00bfe5" + }, + "koto": { + "revision": "cbf637e5163065934c827d254b293f4d2f08f523" + }, + "kusto": { + "revision": "8353a1296607d6ba33db7c7e312226e5fc83e8ce" + }, + "lalrpop": { + "revision": "194c25539f435de415ee0551a5f07058833da915" + }, + "latex": { + "revision": "87e4059f01bed363230dc349f794ce4cc580e862" + }, + "ledger": { + "revision": "a2eff7fee59ee6adfc4a3646e2f41ba3b340a97d" + }, + "leo": { + "revision": "6ca11a96fc2cab51217e0cf4a2f9ed3ea63e28fb" + }, + "linkerscript": { + "revision": "f99011a3554213b654985a4b0a65b3b032ec4621" + }, + "liquid": { + "revision": "23ac814111e2b4b4b083e2c92219af2d5b74d13d" + }, + "liquidsoap": { + "revision": "14feafa91630afb1ab9988cf9b738b7ea29f3f89" + }, + "llvm": { + "revision": "c14cb839003348692158b845db9edda201374548" + }, + "lua": { + "revision": "34e60e7f45fc313463c68090d88d742a55d1bd7a" + }, + "luadoc": { + "revision": "873612aadd3f684dd4e631bdf42ea8990c57634e" + }, + "luap": { + "revision": "c134aaec6acf4fa95fe4aa0dc9aba3eacdbbe55a" + }, + "luau": { + "revision": "fbadc96272f718dba267628ba7b0e694c368cef3" + }, + "m68k": { + "revision": "e128454c2210c0e0c10b68fe45ddb8fee80182a3" + }, + "make": { + "revision": "a4b9187417d6be349ee5fd4b6e77b4172c6827dd" + }, + "markdown": { + "revision": "5cdc549ab8f461aff876c5be9741027189299cec" + }, + "markdown_inline": { + "revision": "5cdc549ab8f461aff876c5be9741027189299cec" + }, + "matlab": { + "revision": "306c43ab28b7b8a4976e40ff0a7c26b019ad52df" + }, + "menhir": { + "revision": "be8866a6bcc2b563ab0de895af69daeffa88fe70" + }, + "mermaid": { + "revision": "90ae195b31933ceb9d079abfa8a3ad0a36fee4cc" + }, + "meson": { + "revision": "c5fffb8edd39f22644084ab3f73a924a75721ee3" + }, + "mlir": { + "revision": "0238b7fb6a630f77b3fc8b8a48285ef6ed45cbcc" + }, + "muttrc": { + "revision": "173b0ab53a9c07962c9777189c4c70e90f1c1837" + }, + "nasm": { + "revision": "570f3d7be01fffc751237f4cfcf52d04e20532d1" + }, + "nginx": { + "revision": "281d184b8240b2b22670b8907b57b6d6842db6f3" + }, + "nickel": { + "revision": "ddaa2bc22355effd97c0d6b09ff5962705c6368d" + }, + "nim": { + "revision": "897e5d346f0b59ed62b517cfb0f1a845ad8f0ab7" + }, + "nim_format_string": { + "revision": "d45f75022d147cda056e98bfba68222c9c8eca3a" + }, + "ninja": { + "revision": "0a95cfdc0745b6ae82f60d3a339b37f19b7b9267" + }, + "nix": { + "revision": "456b14a2fa6315abc7e02fcffaf4a1f35d4955d3" + }, + "norg": { + "revision": "d89d95af13d409f30a6c7676387bde311ec4a2c8" + }, + "nqc": { + "revision": "14e6da1627aaef21d2b2aa0c37d04269766dcc1d" + }, + "objc": { + "revision": "62e61b6f5c0289c376d61a8c91faf6435cde9012" + }, + "objdump": { + "revision": "28d3b2e25a0b1881d1b47ed1924ca276c7003d45" + }, + "ocaml": { + "revision": "5f7a97e9757d8afe6c0b0b5dd8734cf59f35456e" + }, + "ocaml_interface": { + "revision": "5f7a97e9757d8afe6c0b0b5dd8734cf59f35456e" + }, + "ocamllex": { + "revision": "4b9898ccbf198602bb0dec9cd67cc1d2c0a4fad2" + }, + "odin": { + "revision": "3fee7964bbfb2554deef12c224344f3870d15375" + }, + "org": { + "revision": "64cfbc213f5a83da17632c95382a5a0a2f3357c1" + }, + "pascal": { + "revision": "d0ebabefaea9ac3f6fc3004cf08cd121b66da9e4" + }, + "passwd": { + "revision": "20239395eacdc2e0923a7e5683ad3605aee7b716" + }, + "pem": { + "revision": "217ff2af3f2db15a79ab7e3d21ea1e0c17e71a1a" + }, + "perl": { + "revision": "76ab9a52b9dd2a1758aae3da8286519d995037e9" + }, + "php": { + "revision": "2bce5a6588ad6d53ffe5effaf9708682f0fbfc9b" + }, + "php_only": { + "revision": "2bce5a6588ad6d53ffe5effaf9708682f0fbfc9b" + }, + "phpdoc": { + "revision": "fe3202e468bc17332bec8969f2b50ff1f1da3a46" + }, + "pioasm": { + "revision": "afece58efdb30440bddd151ef1347fa8d6f744a9" + }, + "po": { + "revision": "bd860a0f57f697162bf28e576674be9c1500db5e" + }, + "pod": { + "revision": "0bf8387987c21bf2f8ed41d2575a8f22b139687f" + }, + "poe_filter": { + "revision": "592476d81f95d2451f2ca107dc872224c76fecdf" + }, + "pony": { + "revision": "73ff874ae4c9e9b45462673cbc0a1e350e2522a7" + }, + "powershell": { + "revision": "ebe2ab2f642eda2072c68c8de02e83973c26f33c" + }, + "printf": { + "revision": "0e0aceabbf607ea09e03562f5d8a56f048ddea3d" + }, + "prisma": { + "revision": "eca2596a355b1a9952b4f80f8f9caed300a272b5" + }, + "problog": { + "revision": "93c69d2f84d8a167c0a3f4a8d51ccefe365a4dc8" + }, + "prolog": { + "revision": "93c69d2f84d8a167c0a3f4a8d51ccefe365a4dc8" + }, + "promql": { + "revision": "77625d78eebc3ffc44d114a07b2f348dff3061b0" + }, + "properties": { + "revision": "9d09f5f200c356c50c4103d36441309fd61b48d1" + }, + "proto": { + "revision": "e9f6b43f6844bd2189b50a422d4e2094313f6aa3" + }, + "prql": { + "revision": "09e158cd3650581c0af4c49c2e5b10c4834c8646" + }, + "psv": { + "revision": "7eb7297823605392d2bbcc4c09b1cd18d6fa9529" + }, + "pug": { + "revision": "a7ff31a38908df9b9f34828d21d6ca5e12413e18" + }, + "puppet": { + "revision": "584522f32495d648b18a53ccb52d988e60de127d" + }, + "purescript": { + "revision": "daf9b3e2be18b0b2996a1281f7783e0d041d8b80" + }, + "pymanifest": { + "revision": "be062582956165019d3253794b4d712f66dfeaaa" + }, + "python": { + "revision": "7f4b9c2d8039701b0579b7c060a918f8548aa7cd" + }, + "ql": { + "revision": "1d3e2ff34f1113fadc0ff174c8a01cd4227af7fd" + }, + "qmldir": { + "revision": "6b2b5e41734bd6f07ea4c36ac20fb6f14061c841" + }, + "qmljs": { + "revision": "6d4db242185721e1f5ef21fde613ca90c743ec47" + }, + "query": { + "revision": "f767fb0ac5e711b6d44c5e0c8d1f349687a86ce0" + }, + "r": { + "revision": "2097fa502efa21349d26af0ffee55d773015e481" + }, + "racket": { + "revision": "5b211bf93021d1c45f39aa96898be9f794f087e4" + }, + "ralph": { + "revision": "f6d81bf7a4599c77388035439cf5801cd461ff77" + }, + "rasi": { + "revision": "6c9bbcfdf5f0f553d9ebc01750a3aa247a37b8aa" + }, + "rbs": { + "revision": "8d8e65ac3f77fbc9e15b1cdb9f980a3e0ac3ab99" + }, + "re2c": { + "revision": "c18a3c2f4b6665e35b7e50d6048ea3cff770c572" + }, + "readline": { + "revision": "74addc90fc539d31d413c0c7cf7581997a7fa46e" + }, + "regex": { + "revision": "58f4caf9db12db3b38b81c77d274aa73c9e85aca" + }, + "rego": { + "revision": "20b5a5958c837bc9f74b231022a68a594a313f6d" + }, + "requirements": { + "revision": "5ad9b7581b3334f6ad492847d007f2fac6e6e5f2" + }, + "rescript": { + "revision": "4606cd81c4c31d1d02390fee530858323410a74c" + }, + "rnoweb": { + "revision": "1a74dc0ed731ad07db39f063e2c5a6fe528cae7f" + }, + "robot": { + "revision": "322e4cc65754d2b3fdef4f2f8a71e0762e3d13af" + }, + "robots": { + "revision": "8e3a4205b76236bb6dbebdbee5afc262ce38bb62" + }, + "roc": { + "revision": "ef46edd0c03ea30a22f7e92bc68628fb7231dc8a" + }, + "ron": { + "revision": "78938553b93075e638035f624973083451b29055" + }, + "rst": { + "revision": "5120f6e59284cb8b85b450bd2db0bd352635ba9f" + }, + "ruby": { + "revision": "83aec5f7d1659aaa79e6f24b406a9cd49b87e8e8" + }, + "rust": { + "revision": "2ace7a922a755960f44d73a7bb1efffeb4cc5501" + }, + "scala": { + "revision": "a9af6356f8e31f04e870587bca79bc2b15808ff5" + }, + "scfg": { + "revision": "a5512800ea0220da4abbae61b8aea8423d1549aa" + }, + "scheme": { + "revision": "63e25a4a84142ae7ee0ee01fe3a32c985ca16745" + }, + "scss": { + "revision": "c478c6868648eff49eb04a4df90d703dc45b312a" + }, + "sflog": { + "revision": "46d4a12e4e90b10a575b7b16ea3b6ead50322074" + }, + "slang": { + "revision": "3ed23c04a412a0559162d9cadf96dfff7cb36079" + }, + "slint": { + "revision": "4e2765d4cac1f03ada6f635eeb6008d1d0aff5a3" + }, + "smali": { + "revision": "fdfa6a1febc43c7467aa7e937b87b607956f2346" + }, + "smithy": { + "revision": "fa898ac0885d1da9a253695c3e0e91f5efc587cd" + }, + "snakemake": { + "revision": "e909815acdbe37e69440261ebb1091ed52e1dec6" + }, + "solidity": { + "revision": "ee5a2d2ba30b487c4bbf613d2ef310a454c09c7c" + }, + "soql": { + "revision": "46d4a12e4e90b10a575b7b16ea3b6ead50322074" + }, + "sosl": { + "revision": "46d4a12e4e90b10a575b7b16ea3b6ead50322074" + }, + "sourcepawn": { + "revision": "6b9bf9cbab91443380d2ca8a2f6c491cc7fac5bf" + }, + "sparql": { + "revision": "d853661ca680d8ff7f8d800182d5782b61d0dd58" + }, + "sql": { + "revision": "f551a8fa69dc9aea479b93fae34c3ea7be15f931" + }, + "squirrel": { + "revision": "072c969749e66f000dba35a33c387650e203e96e" + }, + "ssh_config": { + "revision": "77450e8bce8853921512348f83c73c168c71fdfb" + }, + "starlark": { + "revision": "018d0e09d9d0f0dd6740a37682b8ee4512e8b2ac" + }, + "strace": { + "revision": "d819cdd5dbe455bd3c859193633c8d91c0df7c36" + }, + "styled": { + "revision": "764af55fc6b8e5ae177eb272f5c5de6238db23e6" + }, + "supercollider": { + "revision": "1a8ee0da9a4f2df5a8a22f4d637ac863623a78a7" + }, + "superhtml": { + "revision": "3325bbb2dda260131a8db0cae1f1f557d17ebced" + }, + "surface": { + "revision": "f4586b35ac8548667a9aaa4eae44456c1f43d032" + }, + "svelte": { + "revision": "ae5199db47757f785e43a14b332118a5474de1a2" + }, + "swift": { + "revision": "d351cb321c28f0a3e66242ef2f61b1f890ec4b44" + }, + "sxhkdrc": { + "revision": "440d5f913d9465c9c776a1bd92334d32febcf065" + }, + "systemtap": { + "revision": "f2b378a9af0b7e1192cff67a5fb45508c927205d" + }, + "t32": { + "revision": "0f6a5b1e031c97ebf58d3c76eadb2c6bf1e4f780" + }, + "tablegen": { + "revision": "b1170880c61355aaf38fc06f4af7d3c55abdabc4" + }, + "tact": { + "revision": "83e264928fa194b7283428527259e88e54205264" + }, + "tcl": { + "revision": "cdba4ab96a9896492d0d5219b70300c8783ca4e7" + }, + "teal": { + "revision": "485fbdc00d811b01b2090dff4d0469fd1d0350f5" + }, + "templ": { + "revision": "4519e3ec9ca92754ca25659bb1fd410d5e0f8d88" + }, + "terraform": { + "revision": "9e3ec9848f28d26845ba300fd73c740459b83e9b" + }, + "textproto": { + "revision": "568471b80fd8793d37ed01865d8c2208a9fefd1b" + }, + "thrift": { + "revision": "68fd0d80943a828d9e6f49c58a74be1e9ca142cf" + }, + "tiger": { + "revision": "a7f11d946b44244f71df41d2a78af0665d618dae" + }, + "tlaplus": { + "revision": "8a8413f1d08e7ee40b347206d26eac4324db9fd9" + }, + "tmux": { + "revision": "0252ecd080016e45e6305ef1a943388f5ae2f4b4" + }, + "todotxt": { + "revision": "3937c5cd105ec4127448651a21aef45f52d19609" + }, + "toml": { + "revision": "16a30c83ce427385b8d14939c45c137fcfca6c42" + }, + "tsv": { + "revision": "7eb7297823605392d2bbcc4c09b1cd18d6fa9529" + }, + "tsx": { + "revision": "73c4447796b251295b498227bad028d88dc1918b" + }, + "turtle": { + "revision": "7f789ea7ef765080f71a298fc96b7c957fa24422" + }, + "twig": { + "revision": "085648e01d1422163a1702a44e72303b4e2a0bd1" + }, + "typescript": { + "revision": "73c4447796b251295b498227bad028d88dc1918b" + }, + "typespec": { + "revision": "0ee05546d73d8eb64635ed8125de6f35c77759fe" + }, + "typoscript": { + "revision": "43b221c0b76e77244efdaa9963e402a17c930fbc" + }, + "typst": { + "revision": "8b8b16ef1b40cbecbe3f754b1c1c966b5a0904fe" + }, + "udev": { + "revision": "8f58696e79092b4ad6bf197415bbd0970acf15cd" + }, + "ungrammar": { + "revision": "debd26fed283d80456ebafa33a06957b0c52e451" + }, + "unison": { + "revision": "bc06e1eb100e1c0fab9bd89a9ca55d646ac80fc4" + }, + "usd": { + "revision": "4e0875f724d94d0c2ff36f9b8cb0b12f8b20d216" + }, + "uxntal": { + "revision": "ad9b638b914095320de85d59c49ab271603af048" + }, + "v": { + "revision": "ea538758a1273b59774dc9179cde460d9c73fd89" + }, + "vala": { + "revision": "8f690bfa639f2b83d1fb938ed3dd98a7ba453e8b" + }, + "vento": { + "revision": "3321077d7446c1b3b017c294fd56ce028ed817fe" + }, + "verilog": { + "revision": "0dacb911daa9614a7c7e79a594d4cb9f478e6554" + }, + "vhdl": { + "revision": "d6e8301999336b47d663052d43f983c3edeb01dd" + }, + "vhs": { + "revision": "09f8fbfe40a3a699b200daca7d92e65fbbe9f9e6" + }, + "vim": { + "revision": "f3cd62d8bd043ef20507e84bb6b4b53731ccf3a7" + }, + "vimdoc": { + "revision": "59c539286e7487b267bc7808b16833f9e3ad6793" + }, + "vrl": { + "revision": "274b3ce63f72aa8ffea18e7fc280d3062d28f0ba" + }, + "vue": { + "revision": "22bdfa6c9fc0f5ffa44c6e938ec46869ac8a99ff" + }, + "wgsl": { + "revision": "40259f3c77ea856841a4e0c4c807705f3e4a2b65" + }, + "wgsl_bevy": { + "revision": "47c1818d245a6156a488c4c4d06e9336714bae9b" + }, + "wing": { + "revision": "76e0c25844a66ebc6e866d690fcc5f4e90698947" + }, + "wit": { + "revision": "81490b4e74c792369e005f72b0d46fe082d3fed2" + }, + "xcompose": { + "revision": "fff3e72242aa110ebba6441946ea4d12d200fa68" + }, + "xml": { + "revision": "cd1316e476ec40da6ce1fb5749c9d7e6b4f1090c" + }, + "xresources": { + "revision": "630af80f563ede09a652a808277950c36306e3a3" + }, + "yaml": { + "revision": "7b03feefd36b5f155465ca736c6304aca983b267" + }, + "yang": { + "revision": "2c0e6be8dd4dcb961c345fa35c309ad4f5bd3502" + }, + "yuck": { + "revision": "e877f6ade4b77d5ef8787075141053631ba12318" + }, + "zathurarc": { + "revision": "0554b4a5d313244b7fc000cbb41c04afae4f4e31" + }, + "zig": { + "revision": "eb7d58c2dc4fbeea4745019dee8df013034ae66b" + }, + "ziggy": { + "revision": "42b6f5d7320340bc5903c4c29d34065e8517a549" + }, + "ziggy_schema": { + "revision": "42b6f5d7320340bc5903c4c29d34065e8517a549" + } +} diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter.lua new file mode 100644 index 0000000..963fe73 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter.lua @@ -0,0 +1,22 @@ +local install = require "nvim-treesitter.install" +local utils = require "nvim-treesitter.utils" +local info = require "nvim-treesitter.info" +local configs = require "nvim-treesitter.configs" +local statusline = require "nvim-treesitter.statusline" + +-- Registers all query predicates +require "nvim-treesitter.query_predicates" + +local M = {} + +function M.setup() + utils.setup_commands("install", install.commands) + utils.setup_commands("info", info.commands) + utils.setup_commands("configs", configs.commands) + configs.init() +end + +M.define_modules = configs.define_modules +M.statusline = statusline.statusline + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/caching.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/caching.lua new file mode 100644 index 0000000..7733202 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/caching.lua @@ -0,0 +1,71 @@ +local api = vim.api + +local M = {} + +-- Creates a cache table for buffers keyed by a type name. +-- Cache entries attach to the buffer and cleanup entries +-- as buffers are detached. +function M.create_buffer_cache() + local cache = {} + + ---@type table> + local items = setmetatable({}, { + __index = function(tbl, key) + rawset(tbl, key, {}) + return rawget(tbl, key) + end, + }) + + ---@type table + local loaded_buffers = {} + + ---@param type_name string + ---@param bufnr integer + ---@param value any + function cache.set(type_name, bufnr, value) + if not loaded_buffers[bufnr] then + loaded_buffers[bufnr] = true + -- Clean up the cache if the buffer is detached + -- to avoid memory leaks + api.nvim_buf_attach(bufnr, false, { + on_detach = function() + cache.clear_buffer(bufnr) + loaded_buffers[bufnr] = nil + return true + end, + on_reload = function() end, -- this is needed to prevent on_detach being called on buffer reload + }) + end + + items[bufnr][type_name] = value + end + + ---@param type_name string + ---@param bufnr integer + ---@return any + function cache.get(type_name, bufnr) + return items[bufnr][type_name] + end + + ---@param type_name string + ---@param bufnr integer + ---@return boolean + function cache.has(type_name, bufnr) + return cache.get(type_name, bufnr) ~= nil + end + + ---@param type_name string + ---@param bufnr integer + function cache.remove(type_name, bufnr) + items[bufnr][type_name] = nil + end + + ---@param bufnr integer + function cache.clear_buffer(bufnr) + items[bufnr] = nil + end + + return cache +end + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/compat.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/compat.lua new file mode 100644 index 0000000..0ad0100 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/compat.lua @@ -0,0 +1,39 @@ +-- Shim module to address deprecations across nvim versions +local ts = vim.treesitter +local tsq = ts.query + +local M = {} + +function M.get_query_files(lang, query_group, is_included) + return (tsq.get_files or tsq.get_query_files)(lang, query_group, is_included) +end + +function M.get_query(lang, query_name) + return (tsq.get or tsq.get_query)(lang, query_name) +end + +function M.parse_query(lang, query) + return (tsq.parse or tsq.parse_query)(lang, query) +end + +function M.get_range(node, source, metadata) + return (ts.get_range or tsq.get_range)(node, source, metadata) +end + +function M.get_node_text(node, bufnr) + return (ts.get_node_text or tsq.get_node_text)(node, bufnr) +end + +function M.require_language(lang, opts) + return (ts.language.add or ts.language.require_language)(lang, opts) +end + +function M.flatten(t) + if vim.fn.has "nvim-0.11" == 1 then + return vim.iter(t):flatten():totable() + else + return vim.tbl_flatten(t) + end +end + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/configs.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/configs.lua new file mode 100644 index 0000000..a3ec30f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/configs.lua @@ -0,0 +1,616 @@ +local api = vim.api + +local queries = require "nvim-treesitter.query" +local ts = require "nvim-treesitter.compat" +local parsers = require "nvim-treesitter.parsers" +local utils = require "nvim-treesitter.utils" +local caching = require "nvim-treesitter.caching" + +local M = {} + +---@class TSConfig +---@field modules {[string]:TSModule} +---@field sync_install boolean +---@field ensure_installed string[]|string +---@field ignore_install string[] +---@field auto_install boolean +---@field parser_install_dir string|nil + +---@type TSConfig +local config = { + modules = {}, + sync_install = false, + ensure_installed = {}, + auto_install = false, + ignore_install = {}, + parser_install_dir = nil, +} + +-- List of modules that need to be setup on initialization. +---@type TSModule[][] +local queued_modules_defs = {} +-- Whether we've initialized the plugin yet. +local is_initialized = false + +---@class TSModule +---@field module_path string +---@field enable boolean|string[]|function(string): boolean +---@field disable boolean|string[]|function(string): boolean +---@field keymaps table +---@field is_supported function(string): boolean +---@field attach function(string) +---@field detach function(string) +---@field enabled_buffers table +---@field additional_vim_regex_highlighting boolean|string[] + +---@type {[string]: TSModule} +local builtin_modules = { + highlight = { + module_path = "nvim-treesitter.highlight", + -- @deprecated: use `highlight.set_custom_captures` instead + custom_captures = {}, + enable = false, + is_supported = function(lang) + return queries.has_highlights(lang) + end, + additional_vim_regex_highlighting = false, + }, + incremental_selection = { + module_path = "nvim-treesitter.incremental_selection", + enable = false, + keymaps = { + init_selection = "gnn", -- set to `false` to disable one of the mappings + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + is_supported = function() + return true + end, + }, + indent = { + module_path = "nvim-treesitter.indent", + enable = false, + is_supported = queries.has_indents, + }, +} + +local attached_buffers_by_module = caching.create_buffer_cache() + +---Resolves a module by requiring the `module_path` or using the module definition. +---@param mod_name string +---@return TSModule|nil +local function resolve_module(mod_name) + local config_mod = M.get_module(mod_name) + + if not config_mod then + return + end + + if type(config_mod.attach) == "function" and type(config_mod.detach) == "function" then + return config_mod + elseif type(config_mod.module_path) == "string" then + return require(config_mod.module_path) + end +end + +---Enables and attaches the module to a buffer for lang. +---@param mod string path to module +---@param bufnr integer|nil buffer number, defaults to current buffer +---@param lang string|nil language, defaults to current language +local function enable_module(mod, bufnr, lang) + local module = M.get_module(mod) + if not module then + return + end + + bufnr = bufnr or api.nvim_get_current_buf() + lang = lang or parsers.get_buf_lang(bufnr) + + if not module.enable then + if module.enabled_buffers then + module.enabled_buffers[bufnr] = true + else + module.enabled_buffers = { [bufnr] = true } + end + end + + M.attach_module(mod, bufnr, lang) +end + +---Enables autocomands for the module. +---After the module is loaded `loaded` will be set to true for the module. +---@param mod string path to module +local function enable_mod_conf_autocmd(mod) + local config_mod = M.get_module(mod) + if not config_mod or config_mod.loaded then + return + end + + api.nvim_create_autocmd("FileType", { + group = api.nvim_create_augroup("NvimTreesitter-" .. mod, {}), + callback = function(args) + require("nvim-treesitter.configs").reattach_module(mod, args.buf) + end, + desc = "Reattach module", + }) + + config_mod.loaded = true +end + +---Enables the module globally and for all current buffers. +---After enabled, `enable` will be set to true for the module. +---@param mod string path to module +local function enable_all(mod) + local config_mod = M.get_module(mod) + if not config_mod then + return + end + + enable_mod_conf_autocmd(mod) + config_mod.enable = true + config_mod.enabled_buffers = nil + + for _, bufnr in pairs(api.nvim_list_bufs()) do + enable_module(mod, bufnr) + end +end + +---Disables and detaches the module for a buffer. +---@param mod string path to module +---@param bufnr integer buffer number, defaults to current buffer +local function disable_module(mod, bufnr) + local module = M.get_module(mod) + if not module then + return + end + + bufnr = bufnr or api.nvim_get_current_buf() + if module.enabled_buffers then + module.enabled_buffers[bufnr] = false + end + M.detach_module(mod, bufnr) +end + +---Disables autocomands for the module. +---After the module is unloaded `loaded` will be set to false for the module. +---@param mod string path to module +local function disable_mod_conf_autocmd(mod) + local config_mod = M.get_module(mod) + if not config_mod or not config_mod.loaded then + return + end + api.nvim_clear_autocmds { event = "FileType", group = "NvimTreesitter-" .. mod } + config_mod.loaded = false +end + +---Disables the module globally and for all current buffers. +---After disabled, `enable` will be set to false for the module. +---@param mod string path to module +local function disable_all(mod) + local config_mod = M.get_module(mod) + if not config_mod then + return + end + + config_mod.enabled_buffers = nil + disable_mod_conf_autocmd(mod) + config_mod.enable = false + + for _, bufnr in pairs(api.nvim_list_bufs()) do + disable_module(mod, bufnr) + end +end + +---Toggles a module for a buffer +---@param mod string path to module +---@param bufnr integer buffer number, defaults to current buffer +---@param lang string language, defaults to current language +local function toggle_module(mod, bufnr, lang) + bufnr = bufnr or api.nvim_get_current_buf() + lang = lang or parsers.get_buf_lang(bufnr) + + if attached_buffers_by_module.has(mod, bufnr) then + disable_module(mod, bufnr) + else + enable_module(mod, bufnr, lang) + end +end + +-- Toggles the module globally and for all current buffers. +-- @param mod path to module +local function toggle_all(mod) + local config_mod = M.get_module(mod) + if not config_mod then + return + end + + if config_mod.enable then + disable_all(mod) + else + enable_all(mod) + end +end + +---Recurses through all modules including submodules +---@param accumulator function called for each module +---@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 + + for name, module in pairs(root) do + local new_path = path and (path .. "." .. name) or name + + if M.is_module(module) then + accumulator(name, module, new_path, root) + elseif type(module) == "table" then + recurse_modules(accumulator, module, new_path) + end + end +end + +-- Shows current configuration of all nvim-treesitter modules +---@param process_function function used as the `process` parameter +--- for vim.inspect (https://github.com/kikito/inspect.lua#optionsprocess) +local function config_info(process_function) + process_function = process_function + or function(item, path) + if path[#path] == vim.inspect.METATABLE then + return + end + if path[#path] == "is_supported" then + return + end + return item + end + print(vim.inspect(config, { process = process_function })) +end + +---@param query_group string +---@param lang string +function M.edit_query_file(query_group, lang) + lang = lang or parsers.get_buf_lang() + local files = ts.get_query_files(lang, query_group, true) + if #files == 0 then + utils.notify "No query file found! Creating a new one!" + M.edit_query_file_user_after(query_group, lang) + elseif #files == 1 then + vim.cmd(":edit " .. files[1]) + else + vim.ui.select(files, { prompt = "Select a file:" }, function(file) + if file then + vim.cmd(":edit " .. file) + end + end) + end +end + +---@param query_group string +---@param lang string +function M.edit_query_file_user_after(query_group, lang) + lang = lang or parsers.get_buf_lang() + local folder = utils.join_path(vim.fn.stdpath "config", "after", "queries", lang) + local file = utils.join_path(folder, query_group .. ".scm") + if vim.fn.isdirectory(folder) ~= 1 then + vim.ui.select({ "Yes", "No" }, { prompt = '"' .. folder .. '" does not exist. Create it?' }, function(choice) + if choice == "Yes" then + vim.fn.mkdir(folder, "p", "0755") + vim.cmd(":edit " .. file) + end + end) + else + vim.cmd(":edit " .. file) + end +end + +M.commands = { + TSBufEnable = { + run = enable_module, + args = { + "-nargs=1", + "-complete=custom,nvim_treesitter#available_modules", + }, + }, + TSBufDisable = { + run = disable_module, + args = { + "-nargs=1", + "-complete=custom,nvim_treesitter#available_modules", + }, + }, + TSBufToggle = { + run = toggle_module, + args = { + "-nargs=1", + "-complete=custom,nvim_treesitter#available_modules", + }, + }, + TSEnable = { + run = enable_all, + args = { + "-nargs=+", + "-complete=custom,nvim_treesitter#available_modules", + }, + }, + TSDisable = { + run = disable_all, + args = { + "-nargs=+", + "-complete=custom,nvim_treesitter#available_modules", + }, + }, + TSToggle = { + run = toggle_all, + args = { + "-nargs=+", + "-complete=custom,nvim_treesitter#available_modules", + }, + }, + TSConfigInfo = { + run = config_info, + args = { + "-nargs=0", + }, + }, + TSEditQuery = { + run = M.edit_query_file, + args = { + "-nargs=+", + "-complete=custom,nvim_treesitter#available_query_groups", + }, + }, + TSEditQueryUserAfter = { + run = M.edit_query_file_user_after, + args = { + "-nargs=+", + "-complete=custom,nvim_treesitter#available_query_groups", + }, + }, +} + +---@param mod string module +---@param lang string the language of the buffer +---@param bufnr integer the buffer +function M.is_enabled(mod, lang, bufnr) + if not parsers.has_parser(lang) then + return false + end + + local module_config = M.get_module(mod) + if not module_config then + return false + end + + local buffer_enabled = module_config.enabled_buffers and module_config.enabled_buffers[bufnr] + local config_enabled = module_config.enable or buffer_enabled + if not config_enabled or not module_config.is_supported(lang) then + return false + end + + local disable = module_config.disable + if type(disable) == "function" then + if disable(lang, bufnr) then + return false + end + elseif type(disable) == "table" then + -- Otherwise it's a list of languages + for _, parser in pairs(disable) do + if lang == parser then + return false + end + end + end + + return true +end + +---Setup call for users to override module configurations. +---@param user_data TSConfig module overrides +function M.setup(user_data) + config.modules = vim.tbl_deep_extend("force", config.modules, user_data) + config.ignore_install = user_data.ignore_install or {} + config.parser_install_dir = user_data.parser_install_dir or nil + if config.parser_install_dir then + config.parser_install_dir = vim.fn.expand(config.parser_install_dir, ":p") + end + + config.auto_install = user_data.auto_install or false + if config.auto_install then + require("nvim-treesitter.install").setup_auto_install() + end + + local ensure_installed = user_data.ensure_installed or {} + if #ensure_installed > 0 then + if user_data.sync_install then + require("nvim-treesitter.install").ensure_installed_sync(ensure_installed) + else + require("nvim-treesitter.install").ensure_installed(ensure_installed) + end + end + + config.modules.ensure_installed = nil + config.ensure_installed = ensure_installed + + recurse_modules(function(_, _, new_path) + local data = utils.get_at_path(config.modules, new_path) + if data.enable then + enable_all(new_path) + end + end, config.modules) +end + +-- Defines a table of modules that can be attached/detached to buffers +-- based on language support. A module consist of the following properties: +---* @enable Whether the modules is enabled. Can be true or false. +---* @disable A list of languages to disable the module for. Only relevant if enable is true. +---* @keymaps A list of user mappings for a given module if relevant. +---* @is_supported A function which, given a ft, will return true if the ft works on the module. +---* @module_path A string path to a module file using `require`. The exported module must contain +--- an `attach` and `detach` function. This path is not required if `attach` and `detach` +--- functions are provided directly on the module definition. +---* @attach An attach function that is called for each buffer that the module is enabled for. This is required +--- if a `module_path` is not specified. +---* @detach A detach function that is called for each buffer that the module is enabled for. This is required +--- if a `module_path` is not specified. +-- +-- Modules are not setup until `init` is invoked by the plugin. This allows modules to be defined in any order +-- and can be loaded lazily. +-- +---* @example +---require"nvim-treesitter".define_modules { +--- my_cool_module = { +--- attach = function() +--- do_some_cool_setup() +--- end, +--- detach = function() +--- do_some_cool_teardown() +--- end +--- } +---} +---@param mod_defs TSModule[] +function M.define_modules(mod_defs) + if not is_initialized then + table.insert(queued_modules_defs, mod_defs) + return + end + + recurse_modules(function(key, mod, _, group) + group[key] = vim.tbl_extend("keep", mod, { + enable = false, + disable = {}, + is_supported = function() + return true + end, + }) + end, mod_defs) + + config.modules = vim.tbl_deep_extend("keep", config.modules, mod_defs) + + for _, mod in ipairs(M.available_modules(mod_defs)) do + local module_config = M.get_module(mod) + if module_config and module_config.enable then + enable_mod_conf_autocmd(mod) + end + end +end + +---Attaches a module to a buffer +---@param mod_name string the module name +---@param bufnr integer the buffer +---@param lang string the language of the buffer +function M.attach_module(mod_name, bufnr, lang) + bufnr = bufnr or api.nvim_get_current_buf() + lang = lang or parsers.get_buf_lang(bufnr) + local resolved_mod = resolve_module(mod_name) + + if resolved_mod and not attached_buffers_by_module.has(mod_name, bufnr) and M.is_enabled(mod_name, lang, bufnr) then + attached_buffers_by_module.set(mod_name, bufnr, true) + resolved_mod.attach(bufnr, lang) + end +end + +-- Detaches a module to a buffer +---@param mod_name string the module name +---@param bufnr integer the buffer +function M.detach_module(mod_name, bufnr) + local resolved_mod = resolve_module(mod_name) + bufnr = bufnr or api.nvim_get_current_buf() + + if resolved_mod and attached_buffers_by_module.has(mod_name, bufnr) then + attached_buffers_by_module.remove(mod_name, bufnr) + resolved_mod.detach(bufnr) + end +end + +-- Same as attach_module, but if the module is already attached, detach it first. +---@param mod_name string the module name +---@param bufnr integer the buffer +---@param lang string the language of the buffer +function M.reattach_module(mod_name, bufnr, lang) + M.detach_module(mod_name, bufnr) + M.attach_module(mod_name, bufnr, lang) +end + +-- Gets available modules +---@param root {[string]:TSModule}|nil table to find modules +---@return string[] modules list of module paths +function M.available_modules(root) + local modules = {} + + recurse_modules(function(_, _, path) + table.insert(modules, path) + end, root) + + return modules +end + +---Gets a module config by path +---@param mod_path string path to the module +---@return TSModule|nil: the module or nil +function M.get_module(mod_path) + local mod = utils.get_at_path(config.modules, mod_path) + + return M.is_module(mod) and mod or nil +end + +-- Determines whether the provided table is a module. +-- A module should contain an attach and detach function. +---@param mod table|nil the module table +---@return boolean +function M.is_module(mod) + return type(mod) == "table" + and ((type(mod.attach) == "function" and type(mod.detach) == "function") or type(mod.module_path) == "string") +end + +-- Initializes built-in modules and any queued modules +-- registered by plugins or the user. +function M.init() + is_initialized = true + M.define_modules(builtin_modules) + + for _, mod_def in ipairs(queued_modules_defs) do + M.define_modules(mod_def) + end +end + +-- If parser_install_dir is not nil is used or created. +-- If parser_install_dir is nil try the package dir of the nvim-treesitter +-- plugin first, followed by the "site" dir from "runtimepath". "site" dir will +-- be created if it doesn't exist. Using only the package dir won't work when +-- the plugin is installed with Nix, since the "/nix/store" is read-only. +---@param folder_name string|nil +---@return string|nil, string|nil +function M.get_parser_install_dir(folder_name) + folder_name = folder_name or "parser" + + local install_dir = config.parser_install_dir or utils.get_package_path() + local parser_dir = utils.join_path(install_dir, folder_name) + + return utils.create_or_reuse_writable_dir( + parser_dir, + utils.join_space("Could not create parser dir '", parser_dir, "': "), + utils.join_space( + "Parser dir '", + parser_dir, + "' should be read/write (see README on how to configure an alternative install location)" + ) + ) +end + +function M.get_parser_info_dir() + return M.get_parser_install_dir "parser-info" +end + +function M.get_ignored_parser_installs() + return config.ignore_install or {} +end + +function M.get_ensure_installed_parsers() + if type(config.ensure_installed) == "string" then + return { config.ensure_installed } + end + return config.ensure_installed or {} +end + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/fold.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/fold.lua new file mode 100644 index 0000000..7595998 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/fold.lua @@ -0,0 +1,123 @@ +local api = vim.api +local tsutils = require "nvim-treesitter.ts_utils" +local query = require "nvim-treesitter.query" +local parsers = require "nvim-treesitter.parsers" + +local M = {} + +-- This is cached on buf tick to avoid computing that multiple times +-- Especially not for every line in the file when `zx` is hit +local folds_levels = tsutils.memoize_by_buf_tick(function(bufnr) + local max_fold_level = api.nvim_win_get_option(0, "foldnestmax") + local trim_level = function(level) + if level > max_fold_level then + return max_fold_level + end + return level + end + + local parser = parsers.get_parser(bufnr) + + if not parser then + return {} + end + + local matches = query.get_capture_matches_recursively(bufnr, function(lang) + if query.has_folds(lang) then + return "@fold", "folds" + elseif query.has_locals(lang) then + return "@scope", "locals" + end + end) + + -- start..stop is an inclusive range + + ---@type table + local start_counts = {} + ---@type table + local stop_counts = {} + + local prev_start = -1 + local prev_stop = -1 + + local min_fold_lines = api.nvim_win_get_option(0, "foldminlines") + + for _, match in ipairs(matches) do + local start, stop, stop_col ---@type integer, integer, integer + if match.metadata and match.metadata.range then + start, _, stop, stop_col = unpack(match.metadata.range) ---@type integer, integer, integer, integer + else + start, _, stop, stop_col = match.node:range() ---@type integer, integer, integer, integer + end + + if stop_col == 0 then + stop = stop - 1 + end + + local fold_length = stop - start + 1 + local should_fold = fold_length > min_fold_lines + + -- Fold only multiline nodes that are not exactly the same as previously met folds + -- Checking against just the previously found fold is sufficient if nodes + -- are returned in preorder or postorder when traversing tree + if should_fold and not (start == prev_start and stop == prev_stop) then + start_counts[start] = (start_counts[start] or 0) + 1 + stop_counts[stop] = (stop_counts[stop] or 0) + 1 + prev_start = start + prev_stop = stop + end + end + + ---@type string[] + local levels = {} + local current_level = 0 + + -- We now have the list of fold opening and closing, fill the gaps and mark where fold start + for lnum = 0, api.nvim_buf_line_count(bufnr) do + local prefix = "" + + local last_trimmed_level = trim_level(current_level) + current_level = current_level + (start_counts[lnum] or 0) + local trimmed_level = trim_level(current_level) + current_level = current_level - (stop_counts[lnum] or 0) + local next_trimmed_level = trim_level(current_level) + + -- Determine if it's the start/end of a fold + -- NB: vim's fold-expr interface does not have a mechanism to indicate that + -- two (or more) folds start at this line, so it cannot distinguish between + -- ( \n ( \n )) \n (( \n ) \n ) + -- versus + -- ( \n ( \n ) \n ( \n ) \n ) + -- If it did have such a mechanism, (trimmed_level - last_trimmed_level) + -- would be the correct number of starts to pass on. + if trimmed_level - last_trimmed_level > 0 then + prefix = ">" + elseif trimmed_level - next_trimmed_level > 0 then + -- Ending marks tend to confuse vim more than it helps, particularly when + -- the fold level changes by at least 2; we can uncomment this if + -- vim's behavior gets fixed. + -- prefix = "<" + prefix = "" + end + + levels[lnum + 1] = prefix .. tostring(trimmed_level) + end + + return levels +end) + +---@param lnum integer +---@return string +function M.get_fold_indic(lnum) + if not parsers.has_parser() or not lnum then + return "0" + end + + local buf = api.nvim_get_current_buf() + + local levels = folds_levels(buf) or {} + + return levels[lnum] or "0" +end + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/health.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/health.lua new file mode 100644 index 0000000..be265f7 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/health.lua @@ -0,0 +1,176 @@ +local api = vim.api +local fn = vim.fn + +local queries = require "nvim-treesitter.query" +local info = require "nvim-treesitter.info" +local shell = require "nvim-treesitter.shell_command_selectors" +local install = require "nvim-treesitter.install" +local utils = require "nvim-treesitter.utils" +local ts = require "nvim-treesitter.compat" + +local health = vim.health or require "health" + +-- "report_" prefix has been deprecated, use the recommended replacements if they exist. +local _start = health.start or health.report_start +local _ok = health.ok or health.report_ok +local _warn = health.warn or health.report_warn +local _error = health.error or health.report_error + +local M = {} + +local NVIM_TREESITTER_MINIMUM_ABI = 13 + +local function install_health() + _start "Installation" + + if fn.has "nvim-0.9.2" ~= 1 then + _error "Nvim-treesitter requires Nvim 0.9.2 or newer" + end + + if fn.executable "tree-sitter" == 0 then + _warn( + "`tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar," + .. " not required for :TSInstall)" + ) + else + _ok( + "`tree-sitter` found " + .. (utils.ts_cli_version() or "(unknown version)") + .. " (parser generator, only needed for :TSInstallFromGrammar)" + ) + end + + if fn.executable "node" == 0 then + _warn("`node` executable not found (only needed for :TSInstallFromGrammar," .. " not required for :TSInstall)") + else + local handle = io.popen "node --version" + local result = handle:read "*a" + handle:close() + local version = vim.split(result, "\n")[1] + _ok("`node` found " .. version .. " (only needed for :TSInstallFromGrammar)") + end + + if fn.executable "git" == 0 then + _error("`git` executable not found.", { + "Install it with your package manager.", + "Check that your `$PATH` is set correctly.", + }) + else + _ok "`git` executable found." + end + + local cc = shell.select_executable(install.compilers) + if not cc then + _error("`cc` executable not found.", { + "Check that any of " + .. vim.inspect(install.compilers) + .. " is in your $PATH" + .. ' or set the environment variable CC or `require"nvim-treesitter.install".compilers` explicitly!', + }) + else + local version = vim.fn.systemlist(cc .. (cc == "cl" and "" or " --version"))[1] + _ok( + "`" + .. cc + .. "` executable found. Selected from " + .. vim.inspect(install.compilers) + .. (version and ("\nVersion: " .. version) or "") + ) + end + if vim.treesitter.language_version then + if vim.treesitter.language_version >= NVIM_TREESITTER_MINIMUM_ABI then + _ok( + "Neovim was compiled with tree-sitter runtime ABI version " + .. vim.treesitter.language_version + .. " (required >=" + .. NVIM_TREESITTER_MINIMUM_ABI + .. "). Parsers must be compatible with runtime ABI." + ) + else + _error( + "Neovim was compiled with tree-sitter runtime ABI version " + .. vim.treesitter.language_version + .. ".\n" + .. "nvim-treesitter expects at least ABI version " + .. NVIM_TREESITTER_MINIMUM_ABI + .. "\n" + .. "Please make sure that Neovim is linked against are recent tree-sitter runtime when building" + .. " or raise an issue at your Neovim packager. Parsers must be compatible with runtime ABI." + ) + end + end + + _start("OS Info:\n" .. vim.inspect(vim.loop.os_uname())) +end + +local function query_status(lang, query_group) + local ok, err = pcall(queries.get_query, lang, query_group) + if not ok then + return "x", err + elseif not err then + return "." + else + return "✓" + end +end + +function M.check() + local error_collection = {} + -- Installation dependency checks + install_health() + queries.invalidate_query_cache() + -- Parser installation checks + 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(" ", 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 .. " " + if err then + table.insert(error_collection, { parser_name, query_group, err }) + end + end + table.insert(parser_installation, vim.fn.trim(out, " ", 2)) + end + end + local legend = [[ + + Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections + +) multiple parsers found, only one will be used + x) errors found in the query, try to run :TSUpdate {lang}]] + table.insert(parser_installation, legend) + -- Finally call the report function + _start(table.concat(parser_installation, "\n")) + if #error_collection > 0 then + _start "The following errors have been detected:" + for _, p in ipairs(error_collection) do + local lang, type, err = unpack(p) + local lines = {} + table.insert(lines, lang .. "(" .. type .. "): " .. err) + local files = ts.get_query_files(lang, type) + if #files > 0 then + table.insert(lines, lang .. "(" .. type .. ") is concatenated from the following files:") + for _, file in ipairs(files) do + local fd = io.open(file, "r") + if fd then + local ok, file_err = pcall(ts.parse_query, lang, fd:read "*a") + if ok then + table.insert(lines, '| [OK]:"' .. file .. '"') + else + table.insert(lines, '| [ERROR]:"' .. file .. '", failed to load: ' .. file_err) + end + fd:close() + end + end + end + _error(table.concat(lines, "\n")) + end + end +end + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/highlight.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/highlight.lua new file mode 100644 index 0000000..5a3cc2e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/highlight.lua @@ -0,0 +1,49 @@ +local configs = require "nvim-treesitter.configs" + +local M = {} + +---@param config TSModule +---@param lang string +---@return boolean +local function should_enable_vim_regex(config, lang) + local additional_hl = config.additional_vim_regex_highlighting + local is_table = type(additional_hl) == "table" + + ---@diagnostic disable-next-line: param-type-mismatch + return additional_hl and (not is_table or vim.tbl_contains(additional_hl, lang)) +end + +---@param bufnr integer +---@param lang string +function M.attach(bufnr, lang) + local config = configs.get_module "highlight" + vim.treesitter.start(bufnr, lang) + if config and should_enable_vim_regex(config, lang) then + vim.bo[bufnr].syntax = "ON" + end +end + +---@param bufnr integer +function M.detach(bufnr) + vim.treesitter.stop(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 diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/incremental_selection.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/incremental_selection.lua new file mode 100644 index 0000000..78f0915 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/incremental_selection.lua @@ -0,0 +1,167 @@ +local api = vim.api + +local configs = require "nvim-treesitter.configs" +local ts_utils = require "nvim-treesitter.ts_utils" +local locals = require "nvim-treesitter.locals" +local parsers = require "nvim-treesitter.parsers" +local queries = require "nvim-treesitter.query" +local utils = require "nvim-treesitter.utils" + +local M = {} + +---@type table> +local selections = {} + +function M.init_selection() + local buf = api.nvim_get_current_buf() + local node = ts_utils.get_node_at_cursor() + selections[buf] = { [1] = node } + ts_utils.update_selection(buf, node) +end + +-- Get the range of the current visual selection. +-- +-- The range starts with 1 and the ending is inclusive. +---@return integer, integer, integer, integer +local function visual_selection_range() + local _, csrow, cscol, _ = unpack(vim.fn.getpos "v") ---@type integer, integer, integer, integer + local _, cerow, cecol, _ = unpack(vim.fn.getpos ".") ---@type integer, integer, integer, integer + + local start_row, start_col, end_row, end_col ---@type integer, integer, integer, integer + + if csrow < cerow or (csrow == cerow and cscol <= cecol) then + start_row = csrow + start_col = cscol + end_row = cerow + end_col = cecol + else + start_row = cerow + start_col = cecol + end_row = csrow + end_col = cscol + end + + return start_row, start_col, end_row, end_col +end + +---@param node TSNode +---@return boolean +local function range_matches(node) + local csrow, cscol, cerow, cecol = visual_selection_range() + local srow, scol, erow, ecol = ts_utils.get_vim_range { node:range() } + return srow == csrow and scol == cscol and erow == cerow and ecol == cecol +end + +---@param get_parent fun(node: TSNode): TSNode|nil +---@return fun():nil +local function select_incremental(get_parent) + return function() + local buf = api.nvim_get_current_buf() + local nodes = selections[buf] + + local csrow, cscol, cerow, cecol = visual_selection_range() + -- Initialize incremental selection with current selection + if not nodes or #nodes == 0 or not range_matches(nodes[#nodes]) then + local root = parsers.get_parser():parse()[1]:root() + local node = root:named_descendant_for_range(csrow - 1, cscol - 1, cerow - 1, cecol) + ts_utils.update_selection(buf, node) + if nodes and #nodes > 0 then + table.insert(selections[buf], node) + else + selections[buf] = { [1] = node } + end + return + end + + -- Find a node that changes the current selection. + local node = nodes[#nodes] ---@type TSNode + while true do + local parent = get_parent(node) + if not parent or parent == node then + -- Keep searching in the main tree + -- TODO: we should search on the parent tree of the current node. + local root = parsers.get_parser():parse()[1]:root() + parent = root:named_descendant_for_range(csrow - 1, cscol - 1, cerow - 1, cecol) + if not parent or root == node or parent == node then + ts_utils.update_selection(buf, node) + return + end + end + node = parent + local srow, scol, erow, ecol = ts_utils.get_vim_range { node:range() } + local same_range = (srow == csrow and scol == cscol and erow == cerow and ecol == cecol) + if not same_range then + table.insert(selections[buf], node) + if node ~= nodes[#nodes] then + table.insert(nodes, node) + end + ts_utils.update_selection(buf, node) + return + end + end + end +end + +M.node_incremental = select_incremental(function(node) + return node:parent() or node +end) + +M.scope_incremental = select_incremental(function(node) + local lang = parsers.get_buf_lang() + if queries.has_locals(lang) then + return locals.containing_scope(node:parent() or node) + else + return node + end +end) + +function M.node_decremental() + local buf = api.nvim_get_current_buf() + local nodes = selections[buf] + if not nodes or #nodes < 2 then + return + end + + table.remove(selections[buf]) + local node = nodes[#nodes] ---@type TSNode + ts_utils.update_selection(buf, node) +end + +local FUNCTION_DESCRIPTIONS = { + init_selection = "Start selecting nodes with nvim-treesitter", + node_incremental = "Increment selection to named node", + scope_incremental = "Increment selection to surrounding scope", + node_decremental = "Shrink selection to previous named node", +} + +---@param bufnr integer +function M.attach(bufnr) + local config = configs.get_module "incremental_selection" + for funcname, mapping in pairs(config.keymaps) do + if mapping then + local mode = funcname == "init_selection" and "n" or "x" + local rhs = M[funcname] ---@type function + + if not rhs then + utils.notify("Unknown keybinding: " .. funcname .. debug.traceback(), vim.log.levels.ERROR) + else + vim.keymap.set(mode, mapping, rhs, { buffer = bufnr, silent = true, desc = FUNCTION_DESCRIPTIONS[funcname] }) + end + end + end +end + +function M.detach(bufnr) + local config = configs.get_module "incremental_selection" + for f, mapping in pairs(config.keymaps) do + if mapping then + local mode = f == "init_selection" and "n" or "x" + local ok, err = pcall(vim.keymap.del, mode, mapping, { buffer = bufnr }) + if not ok then + utils.notify(string.format('%s "%s" for mode %s', err, mapping, mode), vim.log.levels.ERROR) + end + end + end +end + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/indent.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/indent.lua new file mode 100644 index 0000000..19e7ef1 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/indent.lua @@ -0,0 +1,366 @@ +local ts = vim.treesitter +local parsers = require "nvim-treesitter.parsers" + +local M = {} + +M.avoid_force_reparsing = { + yaml = true, +} + +M.comment_parsers = { + comment = true, + jsdoc = true, + phpdoc = true, +} + +local function getline(lnum) + return vim.api.nvim_buf_get_lines(0, lnum - 1, lnum, false)[1] or "" +end + +---@param lnum integer +---@return integer +local function get_indentcols_at_line(lnum) + local _, indentcols = getline(lnum):find "^%s*" + return indentcols or 0 +end + +---@param root TSNode +---@param lnum integer +---@param col? integer +---@return TSNode +local function get_first_node_at_line(root, lnum, col) + col = col or get_indentcols_at_line(lnum) + return root:descendant_for_range(lnum - 1, col, lnum - 1, col + 1) +end + +---@param root TSNode +---@param lnum integer +---@param col? integer +---@return TSNode +local function get_last_node_at_line(root, lnum, col) + col = col or (#getline(lnum) - 1) + return root:descendant_for_range(lnum - 1, col, lnum - 1, col + 1) +end + +---@param node TSNode +---@return number +local function node_length(node) + local _, _, start_byte = node:start() + local _, _, end_byte = node:end_() + return end_byte - start_byte +end + +---@param bufnr integer +---@param node TSNode +---@param delimiter string +---@return TSNode|nil child +---@return boolean|nil is_end +local function find_delimiter(bufnr, node, delimiter) + for child, _ in node:iter_children() do + if child:type() == delimiter then + local linenr = child:start() + local line = vim.api.nvim_buf_get_lines(bufnr, linenr, linenr + 1, false)[1] + local end_char = { child:end_() } + local trimmed_after_delim + local escaped_delimiter = delimiter:gsub("[%-%.%+%[%]%(%)%$%^%%%?%*]", "%%%1") + trimmed_after_delim, _ = line:sub(end_char[2] + 1):gsub("[%s" .. escaped_delimiter .. "]*", "") + return child, #trimmed_after_delim == 0 + end + end +end + +---Memoize a function using hash_fn to hash the arguments. +---@generic F: function +---@param fn F +---@param hash_fn fun(...): any +---@return F +local function memoize(fn, hash_fn) + local cache = setmetatable({}, { __mode = "kv" }) ---@type table + + return function(...) + local key = hash_fn(...) + if cache[key] == nil then + local v = fn(...) ---@type any + cache[key] = v ~= nil and v or vim.NIL + end + + local v = cache[key] + return v ~= vim.NIL and v or nil + end +end + +local get_indents = memoize(function(bufnr, root, lang) + local map = { + ["indent.auto"] = {}, + ["indent.begin"] = {}, + ["indent.end"] = {}, + ["indent.dedent"] = {}, + ["indent.branch"] = {}, + ["indent.ignore"] = {}, + ["indent.align"] = {}, + ["indent.zero"] = {}, + } + + --TODO(clason): remove when dropping Nvim 0.8 compat + local query = (ts.query.get or ts.get_query)(lang, "indents") + if not query then + return map + end + for id, node, metadata in query:iter_captures(root, bufnr) do + if query.captures[id]:sub(1, 1) ~= "_" then + map[query.captures[id]][node:id()] = metadata or {} + end + end + + return map +end, function(bufnr, root, lang) + return tostring(bufnr) .. root:id() .. "_" .. lang +end) + +---@param lnum number (1-indexed) +function M.get_indent(lnum) + local bufnr = vim.api.nvim_get_current_buf() + local parser = parsers.get_parser(bufnr) + if not parser or not lnum then + return -1 + end + + --TODO(clason): replace when dropping Nvim 0.8 compat + local root_lang = parsers.get_buf_lang(bufnr) + + -- some languages like Python will actually have worse results when re-parsing at opened new line + if not M.avoid_force_reparsing[root_lang] then + -- Reparse in case we got triggered by ":h indentkeys" + parser:parse { vim.fn.line "w0" - 1, vim.fn.line "w$" } + end + + -- Get language tree with smallest range around node that's not a comment parser + local root, lang_tree ---@type TSNode, LanguageTree + parser:for_each_tree(function(tstree, tree) + if not tstree or M.comment_parsers[tree:lang()] then + return + end + local local_root = tstree:root() + if ts.is_in_node_range(local_root, lnum - 1, 0) then + if not root or node_length(root) >= node_length(local_root) then + root = local_root + lang_tree = tree + end + end + end) + + -- Not likely, but just in case... + if not root then + return 0 + end + + local q = get_indents(vim.api.nvim_get_current_buf(), root, lang_tree:lang()) + local is_empty_line = string.match(getline(lnum), "^%s*$") ~= nil + local node ---@type TSNode + if is_empty_line then + local prevlnum = vim.fn.prevnonblank(lnum) + local indentcols = get_indentcols_at_line(prevlnum) + local prevline = vim.trim(getline(prevlnum)) + -- The final position can be trailing spaces, which should not affect indentation + node = get_last_node_at_line(root, prevlnum, indentcols + #prevline - 1) + if node:type():match "comment" then + -- The final node we capture of the previous line can be a comment node, which should also be ignored + -- Unless the last line is an entire line of comment, ignore the comment range and find the last node again + local first_node = get_first_node_at_line(root, prevlnum, indentcols) + local _, scol, _, _ = node:range() + if first_node:id() ~= node:id() then + -- In case the last captured node is a trailing comment node, re-trim the string + prevline = vim.trim(prevline:sub(1, scol - indentcols)) + -- Add back indent as indent of prevline was trimmed away + local col = indentcols + #prevline - 1 + node = get_last_node_at_line(root, prevlnum, col) + end + end + if q["indent.end"][node:id()] then + node = get_first_node_at_line(root, lnum) + end + else + node = get_first_node_at_line(root, lnum) + end + + local indent_size = vim.fn.shiftwidth() + local indent = 0 + local _, _, root_start = root:start() + if root_start ~= 0 then + -- injected tree + indent = vim.fn.indent(root:start() + 1) + end + + -- tracks to ensure multiple indent levels are not applied for same line + local is_processed_by_row = {} + + if q["indent.zero"][node:id()] then + return 0 + end + + while node do + -- do 'autoindent' if not marked as @indent + if + not q["indent.begin"][node:id()] + and not q["indent.align"][node:id()] + and q["indent.auto"][node:id()] + and node:start() < lnum - 1 + and lnum - 1 <= node:end_() + then + return -1 + end + + -- Do not indent if we are inside an @ignore block. + -- If a node spans from L1,C1 to L2,C2, we know that lines where L1 < line <= L2 would + -- have their indentations contained by the node. + if + not q["indent.begin"][node:id()] + and q["indent.ignore"][node:id()] + and node:start() < lnum - 1 + and lnum - 1 <= node:end_() + then + return 0 + end + + local srow, _, erow = node:range() + + local is_processed = false + + if + not is_processed_by_row[srow] + and ((q["indent.branch"][node:id()] and srow == lnum - 1) or (q["indent.dedent"][node:id()] and srow ~= lnum - 1)) + then + indent = indent - indent_size + is_processed = true + end + + -- do not indent for nodes that starts-and-ends on same line and starts on target line (lnum) + local should_process = not is_processed_by_row[srow] + local is_in_err = false + if should_process then + local parent = node:parent() + is_in_err = parent and parent:has_error() + end + if + should_process + and ( + q["indent.begin"][node:id()] + and (srow ~= erow or is_in_err or q["indent.begin"][node:id()]["indent.immediate"]) + and (srow ~= lnum - 1 or q["indent.begin"][node:id()]["indent.start_at_same_line"]) + ) + then + indent = indent + indent_size + is_processed = true + end + + if is_in_err and not q["indent.align"][node:id()] then + -- only when the node is in error, promote the + -- first child's aligned indent to the error node + -- to work around ((ERROR "X" . (_)) @aligned_indent (#set! "delimiter" "AB")) + -- matching for all X, instead set do + -- (ERROR "X" @aligned_indent (#set! "delimiter" "AB") . (_)) + -- and we will fish it out here. + for c in node:iter_children() do + if q["indent.align"][c:id()] then + q["indent.align"][node:id()] = q["indent.align"][c:id()] + break + end + end + end + -- do not indent for nodes that starts-and-ends on same line and starts on target line (lnum) + if should_process and q["indent.align"][node:id()] and (srow ~= erow or is_in_err) and (srow ~= lnum - 1) then + local metadata = q["indent.align"][node:id()] + local o_delim_node, o_is_last_in_line ---@type TSNode|nil, boolean|nil + local c_delim_node, c_is_last_in_line ---@type TSNode|nil, boolean|nil, boolean|nil + local indent_is_absolute = false + if metadata["indent.open_delimiter"] then + o_delim_node, o_is_last_in_line = find_delimiter(bufnr, node, metadata["indent.open_delimiter"]) + else + o_delim_node = node + end + if metadata["indent.close_delimiter"] then + c_delim_node, c_is_last_in_line = find_delimiter(bufnr, node, metadata["indent.close_delimiter"]) + else + c_delim_node = node + end + + if o_delim_node then + local o_srow, o_scol = o_delim_node:start() + local c_srow = nil + if c_delim_node then + c_srow, _ = c_delim_node:start() + end + if o_is_last_in_line then + -- hanging indent (previous line ended with starting delimiter) + -- should be processed like indent + if should_process then + indent = indent + indent_size * 1 + if c_is_last_in_line then + -- If current line is outside the range of a node marked with `@aligned_indent` + -- Then its indent level shouldn't be affected by `@aligned_indent` node + if c_srow and c_srow < lnum - 1 then + indent = math.max(indent - indent_size, 0) + end + end + end + else + -- aligned indent + if c_is_last_in_line and c_srow and o_srow ~= c_srow and c_srow < lnum - 1 then + -- If current line is outside the range of a node marked with `@aligned_indent` + -- Then its indent level shouldn't be affected by `@aligned_indent` node + indent = math.max(indent - indent_size, 0) + else + indent = o_scol + (metadata["indent.increment"] or 1) + indent_is_absolute = true + end + end + -- deal with the final line + local avoid_last_matching_next = false + if c_srow and c_srow ~= o_srow and c_srow == lnum - 1 then + -- delims end on current line, and are not open and closed same line. + -- then this last line may need additional indent to avoid clashes + -- with the next. `indent.avoid_last_matching_next` controls this behavior, + -- for example this is needed for function parameters. + avoid_last_matching_next = metadata["indent.avoid_last_matching_next"] or false + end + if avoid_last_matching_next then + -- last line must be indented more in cases where + -- it would be same indent as next line (we determine this as one + -- width more than the open indent to avoid confusing with any + -- hanging indents) + if indent <= vim.fn.indent(o_srow + 1) + indent_size then + indent = indent + indent_size * 1 + else + indent = indent + end + end + is_processed = true + if indent_is_absolute then + -- don't allow further indenting by parent nodes, this is an absolute position + return indent + end + end + end + + is_processed_by_row[srow] = is_processed_by_row[srow] or is_processed + + node = node:parent() + end + + return indent +end + +---@type table +local indent_funcs = {} + +---@param bufnr integer +function M.attach(bufnr) + indent_funcs[bufnr] = vim.bo.indentexpr + vim.bo.indentexpr = "nvim_treesitter#indent()" +end + +function M.detach(bufnr) + vim.bo.indentexpr = indent_funcs[bufnr] +end + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/info.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/info.lua new file mode 100644 index 0000000..6e94b35 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/info.lua @@ -0,0 +1,190 @@ +local api = vim.api +local configs = require "nvim-treesitter.configs" +local parsers = require "nvim-treesitter.parsers" + +local M = {} + +local function install_info() + local max_len = 0 + for _, ft in pairs(parsers.available_parsers()) do + if #ft > max_len then + max_len = #ft + end + end + + local parser_list = parsers.available_parsers() + table.sort(parser_list) + for _, lang in pairs(parser_list) do + local is_installed = #api.nvim_get_runtime_file("parser/" .. lang .. ".so", false) > 0 + api.nvim_out_write(lang .. string.rep(" ", max_len - #lang + 1)) + if is_installed then + api.nvim_out_write "[✓] installed\n" + elseif pcall(vim.treesitter.inspect_lang, lang) then + api.nvim_out_write "[✗] not installed (but still loaded. Restart Neovim!)\n" + else + api.nvim_out_write "[✗] not installed\n" + end + end +end + +-- Sort a list of modules into namespaces. +-- {'mod1', 'mod2.sub1', 'mod2.sub2', 'mod3'} +-- -> +-- { default = {'mod1', 'mod3'}, mod2 = {'sub1', 'sub2'}} +---@param modulelist string[] +---@return table +local function namespace_modules(modulelist) + local modules = {} + for _, module in ipairs(modulelist) do + if module:find "%." then + local namespace, submodule = module:match "^(.*)%.(.*)$" + if not modules[namespace] then + modules[namespace] = {} + end + table.insert(modules[namespace], submodule) + else + if not modules.default then + modules.default = {} + end + table.insert(modules.default, module) + end + end + return modules +end + +---@param list string[] +---@return integer length +local function longest_string_length(list) + local length = 0 + for _, value in ipairs(list) do + if #value > length then + length = #value + end + end + return length +end + +---@param curbuf integer +---@param origbuf integer +---@param parserlist string[] +---@param namespace string +---@param modulelist string[] +local function append_module_table(curbuf, origbuf, parserlist, namespace, modulelist) + local maxlen_parser = longest_string_length(parserlist) + table.sort(modulelist) + + -- header + local header = ">> " .. namespace .. string.rep(" ", maxlen_parser - #namespace - 1) + for _, module in pairs(modulelist) do + header = header .. module .. " " + end + api.nvim_buf_set_lines(curbuf, -1, -1, true, { header }) + + -- actual table + for _, parser in ipairs(parserlist) do + local padding = string.rep(" ", maxlen_parser - #parser + 2) + local line = parser .. padding + local namespace_prefix = (namespace == "default") and "" or namespace .. "." + for _, module in pairs(modulelist) do + local modlen = #module + module = namespace_prefix .. module + if configs.is_enabled(module, parser, origbuf) then + line = line .. "✓" + else + line = line .. "✗" + end + line = line .. string.rep(" ", modlen + 1) + end + api.nvim_buf_set_lines(curbuf, -1, -1, true, { line }) + end + + api.nvim_buf_set_lines(curbuf, -1, -1, true, { "" }) +end + +local function print_info_modules(parserlist, module) + local origbuf = api.nvim_get_current_buf() + api.nvim_command "enew" + local curbuf = api.nvim_get_current_buf() + + local modules + if module then + modules = namespace_modules { module } + else + modules = namespace_modules(configs.available_modules()) + end + + ---@type string[] + local namespaces = {} + for k, _ in pairs(modules) do + table.insert(namespaces, k) + end + table.sort(namespaces) + + table.sort(parserlist) + for _, namespace in ipairs(namespaces) do + append_module_table(curbuf, origbuf, parserlist, namespace, modules[namespace]) + end + + api.nvim_buf_set_option(curbuf, "modified", false) + api.nvim_buf_set_option(curbuf, "buftype", "nofile") + vim.cmd [[ + syntax match TSModuleInfoGood /✓/ + syntax match TSModuleInfoBad /✗/ + syntax match TSModuleInfoHeader /^>>.*$/ contains=TSModuleInfoNamespace + syntax match TSModuleInfoNamespace /^>> \w*/ contained + syntax match TSModuleInfoParser /^[^> ]*\ze / + ]] + + local highlights = { + TSModuleInfoGood = { fg = "LightGreen", bold = true, default = true }, + TSModuleInfoBad = { fg = "Crimson", default = true }, + TSModuleInfoHeader = { link = "Type", default = true }, + TSModuleInfoNamespace = { link = "Statement", default = true }, + TSModuleInfoParser = { link = "Identifier", default = true }, + } + for k, v in pairs(highlights) do + api.nvim_set_hl(0, k, v) + end +end + +local function module_info(module) + if module and not configs.get_module(module) then + return + end + + local parserlist = parsers.available_parsers() + if module then + print_info_modules(parserlist, module) + else + print_info_modules(parserlist) + end +end + +---@return string[] +function M.installed_parsers() + local installed = {} + for _, p in pairs(parsers.available_parsers()) do + if parsers.has_parser(p) then + table.insert(installed, p) + end + end + return installed +end + +M.commands = { + TSInstallInfo = { + run = install_info, + args = { + "-nargs=0", + }, + }, + TSModuleInfo = { + run = module_info, + args = { + "-nargs=?", + "-complete=custom,nvim_treesitter#available_modules", + }, + }, +} + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/install.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/install.lua new file mode 100644 index 0000000..cd12dbb --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/install.lua @@ -0,0 +1,781 @@ +local api = vim.api +local fn = vim.fn +local luv = vim.loop + +local utils = require "nvim-treesitter.utils" +local parsers = require "nvim-treesitter.parsers" +local info = require "nvim-treesitter.info" +local configs = require "nvim-treesitter.configs" +local shell = require "nvim-treesitter.shell_command_selectors" +local compat = require "nvim-treesitter.compat" + +local M = {} + +---@class LockfileInfo +---@field revision string + +---@type table +local lockfile = {} + +M.compilers = { vim.fn.getenv "CC", "cc", "gcc", "clang", "cl", "zig" } +M.prefer_git = fn.has "win32" == 1 +M.command_extra_args = {} +M.ts_generate_args = nil + +local started_commands = 0 +local finished_commands = 0 +local failed_commands = 0 +local complete_std_output = {} +local complete_error_output = {} + +local function reset_progress_counter() + if started_commands ~= finished_commands then + return + end + started_commands = 0 + finished_commands = 0 + failed_commands = 0 + complete_std_output = {} + complete_error_output = {} +end + +local function get_job_status() + return "[nvim-treesitter] [" + .. finished_commands + .. "/" + .. started_commands + .. (failed_commands > 0 and ", failed: " .. failed_commands or "") + .. "]" +end + +---@param lang string +---@return function +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, err + if vim.treesitter.language.add then + local ft = vim.bo[buf].filetype + ok, err = pcall(vim.treesitter.language.add, lang, { filetype = ft }) + else + ok, err = pcall(compat.require_language, lang) + end + 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, lang) + else + require("nvim-treesitter.configs").detach_module(mod, buf) + end + end + end + end + end +end + +---@param lang string +---@param validate boolean|nil +---@return InstallInfo +local function get_parser_install_info(lang, validate) + local parser_config = parsers.get_parser_configs()[lang] + + if not parser_config then + error('Parser not available for language "' .. lang .. '"') + end + + local install_info = parser_config.install_info + + if validate then + vim.validate { + url = { install_info.url, "string" }, + files = { install_info.files, "table" }, + } + end + + return install_info +end + +local function load_lockfile() + local filename = utils.join_path(utils.get_package_path(), "lockfile.json") + lockfile = vim.fn.filereadable(filename) == 1 and vim.fn.json_decode(vim.fn.readfile(filename)) or {} +end + +local function is_ignored_parser(lang) + return vim.tbl_contains(configs.get_ignored_parser_installs(), lang) +end + +---@param lang string +---@return string|nil +local function get_revision(lang) + if #lockfile == 0 then + load_lockfile() + end + + local install_info = get_parser_install_info(lang) + if install_info.revision then + return install_info.revision + end + + if lockfile[lang] then + return lockfile[lang].revision + end +end + +---@param lang string +---@return string|nil +local function get_installed_revision(lang) + local lang_file = utils.join_path(configs.get_parser_info_dir(), lang .. ".revision") + if vim.fn.filereadable(lang_file) == 1 then + return vim.fn.readfile(lang_file)[1] + 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 +local function is_installed(lang) + local matched_parsers = vim.api.nvim_get_runtime_file("parser/" .. lang .. ".so", true) or {} + local install_dir = configs.get_parser_install_dir() + if not install_dir then + return false + end + install_dir = clean_path(install_dir) + for _, path in ipairs(matched_parsers) do + local abspath = clean_path(path) + if vim.startswith(abspath, install_dir) then + return true + end + end + return false +end + +---@param lang string +---@return boolean +local function needs_update(lang) + local revision = get_revision(lang) + return not revision or revision ~= get_installed_revision(lang) +end + +---@return string[] +local function outdated_parsers() + return vim.tbl_filter(function(lang) ---@param lang string + return is_installed(lang) and needs_update(lang) + end, info.installed_parsers()) +end + +---@param handle userdata +---@param is_stderr boolean +local function onread(handle, is_stderr) + return function(_, data) + if data then + if is_stderr then + complete_error_output[handle] = (complete_error_output[handle] or "") .. data + else + complete_std_output[handle] = (complete_std_output[handle] or "") .. data + end + end + end +end + +function M.iter_cmd(cmd_list, i, lang, success_message) + if i == 1 then + started_commands = started_commands + 1 + end + if i == #cmd_list + 1 then + finished_commands = finished_commands + 1 + return print(get_job_status() .. " " .. success_message) + end + + local attr = cmd_list[i] + if attr.info then + print(get_job_status() .. " " .. attr.info) + end + + if attr.opts and attr.opts.args and M.command_extra_args[attr.cmd] then + vim.list_extend(attr.opts.args, M.command_extra_args[attr.cmd]) + end + + if type(attr.cmd) == "function" then + local ok, err = pcall(attr.cmd) + if ok then + M.iter_cmd(cmd_list, i + 1, lang, success_message) + else + failed_commands = failed_commands + 1 + finished_commands = finished_commands + 1 + return api.nvim_err_writeln( + (attr.err or ("Failed to execute the following command:\n" .. vim.inspect(attr))) .. "\n" .. vim.inspect(err) + ) + end + else + local handle + local stdout = luv.new_pipe(false) + local stderr = luv.new_pipe(false) + attr.opts.stdio = { nil, stdout, stderr } + ---@type userdata + handle = luv.spawn( + attr.cmd, + attr.opts, + vim.schedule_wrap(function(code) + if code ~= 0 then + stdout:read_stop() + stderr:read_stop() + end + stdout:close() + stderr:close() + handle:close() + if code ~= 0 then + failed_commands = failed_commands + 1 + finished_commands = finished_commands + 1 + if complete_std_output[handle] and complete_std_output[handle] ~= "" then + print(complete_std_output[handle]) + end + + local err_msg = complete_error_output[handle] or "" + api.nvim_err_writeln( + "nvim-treesitter[" + .. lang + .. "]: " + .. (attr.err or ("Failed to execute the following command:\n" .. vim.inspect(attr))) + .. "\n" + .. err_msg + ) + return + end + M.iter_cmd(cmd_list, i + 1, lang, success_message) + end) + ) + luv.read_start(stdout, onread(handle, false)) + luv.read_start(stderr, onread(handle, true)) + end +end + +---@param cmd Command +---@return string command +local function get_command(cmd) + local options = "" + if cmd.opts and cmd.opts.args then + if M.command_extra_args[cmd.cmd] then + vim.list_extend(cmd.opts.args, M.command_extra_args[cmd.cmd]) + end + for _, opt in ipairs(cmd.opts.args) do + options = string.format("%s %s", options, opt) + end + end + + local command = string.format("%s %s", cmd.cmd, options) + if cmd.opts and cmd.opts.cwd then + command = shell.make_directory_change_for_command(cmd.opts.cwd, command) + end + return command +end + +---@param cmd_list Command[] +---@return boolean +local function iter_cmd_sync(cmd_list) + for _, cmd in ipairs(cmd_list) do + if cmd.info then + print(cmd.info) + end + + if type(cmd.cmd) == "function" then + cmd.cmd() + else + local ret = vim.fn.system(get_command(cmd)) + if vim.v.shell_error ~= 0 then + print(ret) + api.nvim_err_writeln( + (cmd.err and cmd.err .. "\n" or "") .. "Failed to execute the following command:\n" .. vim.inspect(cmd) + ) + return false + end + end + end + + return true +end + +---@param cache_folder string +---@param install_folder string +---@param lang string +---@param repo InstallInfo +---@param with_sync boolean +---@param generate_from_grammar boolean +local function run_install(cache_folder, install_folder, lang, repo, with_sync, generate_from_grammar) + parsers.reset_cache() + + local path_sep = utils.get_path_sep() + + local project_name = "tree-sitter-" .. lang + local maybe_local_path = vim.fn.expand(repo.url) + local from_local_path = vim.fn.isdirectory(maybe_local_path) == 1 + if from_local_path then + repo.url = maybe_local_path + end + + ---@type string compile_location only needed for typescript installs. + local compile_location + if from_local_path then + compile_location = repo.url + if repo.location then + compile_location = utils.join_path(compile_location, repo.location) + end + else + local repo_location = project_name + if repo.location then + repo_location = repo_location .. "/" .. repo.location + end + repo_location = repo_location:gsub("/", path_sep) + compile_location = utils.join_path(cache_folder, repo_location) + end + local parser_lib_name = utils.join_path(install_folder, lang) .. ".so" + + generate_from_grammar = repo.requires_generate_from_grammar or generate_from_grammar + + if generate_from_grammar and vim.fn.executable "tree-sitter" ~= 1 then + api.nvim_err_writeln "tree-sitter CLI not found: `tree-sitter` is not executable!" + if repo.requires_generate_from_grammar then + api.nvim_err_writeln( + "tree-sitter CLI is needed because `" + .. lang + .. "` is marked that it needs " + .. "to be generated from the grammar definitions to be compatible with nvim!" + ) + end + return + else + if not M.ts_generate_args then + local ts_cli_version = utils.ts_cli_version() + if ts_cli_version and vim.split(ts_cli_version, " ")[1] > "0.20.2" then + M.ts_generate_args = { "generate", "--no-bindings", "--abi", vim.treesitter.language_version } + else + M.ts_generate_args = { "generate", "--no-bindings" } + end + end + end + if generate_from_grammar and vim.fn.executable "node" ~= 1 then + api.nvim_err_writeln "Node JS not found: `node` is not executable!" + return + end + local cc = shell.select_executable(M.compilers) + if not cc then + api.nvim_err_writeln('No C compiler found! "' .. table.concat( + vim.tbl_filter(function(c) ---@param c string + return type(c) == "string" + end, M.compilers), + '", "' + ) .. '" are not executable.') + return + end + + local revision = repo.revision + if not revision then + revision = get_revision(lang) + end + + ---@class Command + ---@field cmd string + ---@field info string + ---@field err string + ---@field opts CmdOpts + + ---@class CmdOpts + ---@field args string[] + ---@field cwd string + + ---@type Command[] + local command_list = {} + if not from_local_path then + vim.list_extend(command_list, { shell.select_install_rm_cmd(cache_folder, project_name) }) + vim.list_extend( + command_list, + shell.select_download_commands(repo, project_name, cache_folder, revision, M.prefer_git) + ) + end + if generate_from_grammar then + if repo.generate_requires_npm then + if vim.fn.executable "npm" ~= 1 then + api.nvim_err_writeln("`" .. lang .. "` requires NPM to be installed from grammar.js") + return + end + vim.list_extend(command_list, { + { + cmd = "npm", + info = "Installing NPM dependencies of " .. lang .. " parser", + err = "Error during `npm install` (required for parser generation of " .. lang .. " with npm dependencies)", + opts = { + args = { "install" }, + cwd = compile_location, + }, + }, + }) + end + vim.list_extend(command_list, { + { + cmd = vim.fn.exepath "tree-sitter", + info = "Generating source files from grammar.js...", + err = 'Error during "tree-sitter generate"', + opts = { + args = M.ts_generate_args, + cwd = compile_location, + }, + }, + }) + end + vim.list_extend(command_list, { + shell.select_compile_command(repo, cc, compile_location), + shell.select_mv_cmd("parser.so", parser_lib_name, compile_location), + { + cmd = function() + vim.fn.writefile({ revision or "" }, utils.join_path(configs.get_parser_info_dir() or "", lang .. ".revision")) + end, + }, + { -- auto-attach modules after installation + cmd = reattach_if_possible_fn(lang, true), + }, + }) + if not from_local_path then + vim.list_extend(command_list, { shell.select_install_rm_cmd(cache_folder, project_name) }) + end + + if with_sync then + if iter_cmd_sync(command_list) == true then + print("Treesitter parser for " .. lang .. " has been installed") + end + else + M.iter_cmd(command_list, 1, lang, "Treesitter parser for " .. lang .. " has been installed") + end +end + +---@param lang string +---@param ask_reinstall boolean|string +---@param cache_folder string +---@param install_folder string +---@param with_sync boolean +---@param generate_from_grammar boolean +local function install_lang(lang, ask_reinstall, cache_folder, install_folder, with_sync, generate_from_grammar) + if is_installed(lang) and ask_reinstall ~= "force" then + if not ask_reinstall then + return + end + + local yesno = fn.input(lang .. " parser already available: would you like to reinstall ? y/n: ") + print "\n " + if not string.match(yesno, "^y.*") then + return + end + end + + local ok, install_info = pcall(get_parser_install_info, lang, true) + if not ok then + vim.notify("Installation not possible: " .. install_info, vim.log.levels.ERROR) + if not parsers.get_parser_configs()[lang] then + vim.notify( + "See https://github.com/nvim-treesitter/nvim-treesitter/#adding-parsers on how to add a new parser!", + vim.log.levels.INFO + ) + end + return + end + + run_install(cache_folder, install_folder, lang, install_info, with_sync, generate_from_grammar) +end + +---@class InstallOptions +---@field with_sync boolean +---@field ask_reinstall boolean|string +---@field generate_from_grammar boolean +---@field exclude_configured_parsers boolean + +-- Install a parser +---@param options? InstallOptions +---@return function +local function install(options) + options = options or {} + local with_sync = options.with_sync + local ask_reinstall = options.ask_reinstall + local generate_from_grammar = options.generate_from_grammar + local exclude_configured_parsers = options.exclude_configured_parsers + + return function(...) + if fn.executable "git" == 0 then + return api.nvim_err_writeln "Git is required on your system to run this command" + end + + local cache_folder, err = utils.get_cache_dir() + if err then + return api.nvim_err_writeln(err) + end + assert(cache_folder) + + local install_folder + install_folder, err = configs.get_parser_install_dir() + if err then + return api.nvim_err_writeln(err) + end + install_folder = install_folder and clean_path(install_folder) + assert(install_folder) + + local languages ---@type string[] + local ask ---@type boolean|string + if ... == "all" then + languages = parsers.available_parsers() + ask = false + else + languages = compat.flatten { ... } + ask = ask_reinstall + end + + if exclude_configured_parsers then + languages = utils.difference(languages, configs.get_ignored_parser_installs()) + end + + if #languages > 1 then + reset_progress_counter() + end + + for _, lang in ipairs(languages) do + install_lang(lang, ask, cache_folder, install_folder, with_sync, generate_from_grammar) + end + end +end + +function M.setup_auto_install() + local function try_install_curr_lang() + local lang = parsers.get_buf_lang() + if parsers.get_parser_configs()[lang] and not is_installed(lang) and not is_ignored_parser(lang) then + install() { lang } + end + end + + try_install_curr_lang() + + vim.api.nvim_create_autocmd("FileType", { + pattern = { "*" }, + group = vim.api.nvim_create_augroup("NvimTreesitter-auto_install", { clear = true }), + callback = try_install_curr_lang, + }) +end + +function M.update(options) + options = options or {} + return function(...) + M.lockfile = {} + reset_progress_counter() + if ... and ... ~= "all" then + ---@type string[] + local languages = compat.flatten { ... } + local installed = 0 + for _, lang in ipairs(languages) do + if (not is_installed(lang)) or (needs_update(lang)) then + installed = installed + 1 + install { + ask_reinstall = "force", + with_sync = options.with_sync, + }(lang) + end + end + if installed == 0 then + utils.notify "Parsers are up-to-date!" + end + else + local parsers_to_update = outdated_parsers() or info.installed_parsers() + if #parsers_to_update == 0 then + utils.notify "All parsers are up-to-date!" + end + for _, lang in pairs(parsers_to_update) do + install { + ask_reinstall = "force", + exclude_configured_parsers = true, + with_sync = options.with_sync, + }(lang) + end + end + end +end + +function M.uninstall(...) + if vim.tbl_contains({ "all" }, ...) then + reset_progress_counter() + local installed = info.installed_parsers() + M.uninstall(installed) + elseif ... then + local ensure_installed_parsers = configs.get_ensure_installed_parsers() + if ensure_installed_parsers == "all" then + ensure_installed_parsers = parsers.available_parsers() + end + ensure_installed_parsers = utils.difference(ensure_installed_parsers, configs.get_ignored_parser_installs()) + + ---@type string[] + local languages = compat.flatten { ... } + for _, lang in ipairs(languages) do + local install_dir, err = configs.get_parser_install_dir() + if err then + return api.nvim_err_writeln(err) + end + install_dir = install_dir and clean_path(install_dir) + + if vim.tbl_contains(ensure_installed_parsers, lang) then + vim.notify( + "Uninstalling " + .. lang + .. '. But the parser is still configured in "ensure_installed" setting of nvim-treesitter.' + .. " Please consider updating your config!", + vim.log.levels.ERROR + ) + end + + local parser_lib = utils.join_path(install_dir, lang) .. ".so" + local all_parsers = vim.api.nvim_get_runtime_file("parser/" .. lang .. ".so", true) + if vim.fn.filereadable(parser_lib) == 1 then + local command_list = { + shell.select_rm_file_cmd(parser_lib, "Uninstalling parser for " .. lang), + { + cmd = function() + local all_parsers_after_deletion = vim.api.nvim_get_runtime_file("parser/" .. lang .. ".so", true) + if #all_parsers_after_deletion > 0 then + vim.notify( + "Tried to uninstall parser for " + .. lang + .. "! But the parser is still installed (not by nvim-treesitter):" + .. table.concat(all_parsers_after_deletion, ", "), + vim.log.levels.ERROR + ) + end + end, + }, + { -- auto-reattach or detach modules after uninstallation + cmd = reattach_if_possible_fn(lang, false), + }, + } + M.iter_cmd(command_list, 1, lang, "Treesitter parser for " .. lang .. " has been uninstalled") + elseif #all_parsers > 0 then + vim.notify( + "Parser for " + .. lang + .. " is installed! But not by nvim-treesitter! Please manually remove the following files: " + .. table.concat(all_parsers, ", "), + vim.log.levels.ERROR + ) + end + end + end +end + +function M.write_lockfile(verbose, skip_langs) + local sorted_parsers = {} ---@type Parser[] + -- Load previous lockfile + load_lockfile() + skip_langs = skip_langs or {} + + for k, v in pairs(parsers.get_parser_configs()) do + table.insert(sorted_parsers, { name = k, parser = v }) + end + + ---@param a Parser + ---@param b Parser + table.sort(sorted_parsers, function(a, b) + return a.name < b.name + end) + + for _, v in ipairs(sorted_parsers) do + if not vim.tbl_contains(skip_langs, v.name) then + -- I'm sure this can be done in aync way with iter_cmd + local sha ---@type string + if v.parser.install_info.branch then + sha = vim.split( + vim.fn.systemlist( + "git ls-remote " .. v.parser.install_info.url .. " | grep refs/heads/" .. v.parser.install_info.branch + )[1], + "\t" + )[1] + else + sha = vim.split(vim.fn.systemlist("git ls-remote " .. v.parser.install_info.url)[1], "\t")[1] + end + lockfile[v.name] = { revision = sha } + if verbose then + print(v.name .. ": " .. sha) + end + else + print("Skipping " .. v.name) + end + end + + if verbose then + print(vim.inspect(lockfile)) + end + vim.fn.writefile( + vim.fn.split(vim.fn.json_encode(lockfile), "\n"), + utils.join_path(utils.get_package_path(), "lockfile.json") + ) +end + +M.ensure_installed = install { exclude_configured_parsers = true } +M.ensure_installed_sync = install { with_sync = true, exclude_configured_parsers = true } + +M.commands = { + TSInstall = { + run = install { ask_reinstall = true }, + ["run!"] = install { ask_reinstall = "force" }, + args = { + "-nargs=+", + "-bang", + "-complete=custom,nvim_treesitter#installable_parsers", + }, + }, + TSInstallFromGrammar = { + run = install { generate_from_grammar = true, ask_reinstall = true }, + ["run!"] = install { generate_from_grammar = true, ask_reinstall = "force" }, + args = { + "-nargs=+", + "-bang", + "-complete=custom,nvim_treesitter#installable_parsers", + }, + }, + TSInstallSync = { + run = install { with_sync = true, ask_reinstall = true }, + ["run!"] = install { with_sync = true, ask_reinstall = "force" }, + args = { + "-nargs=+", + "-bang", + "-complete=custom,nvim_treesitter#installable_parsers", + }, + }, + TSUpdate = { + run = M.update {}, + args = { + "-nargs=*", + "-complete=custom,nvim_treesitter#installed_parsers", + }, + }, + TSUpdateSync = { + run = M.update { with_sync = true }, + args = { + "-nargs=*", + "-complete=custom,nvim_treesitter#installed_parsers", + }, + }, + TSUninstall = { + run = M.uninstall, + args = { + "-nargs=+", + "-complete=custom,nvim_treesitter#installed_parsers", + }, + }, +} + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/locals.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/locals.lua new file mode 100644 index 0000000..fed835b --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/locals.lua @@ -0,0 +1,365 @@ +-- Functions to handle locals +-- Locals are a generalization of definition and scopes +-- its the way nvim-treesitter uses to "understand" the code + +local queries = require "nvim-treesitter.query" +local ts_utils = require "nvim-treesitter.ts_utils" +local ts = vim.treesitter +local api = vim.api + +local M = {} + +function M.collect_locals(bufnr) + return queries.collect_group_results(bufnr, "locals") +end + +-- Iterates matches from a locals query file. +-- @param bufnr the buffer +-- @param root the root node +function M.iter_locals(bufnr, root) + return queries.iter_group_results(bufnr, "locals", root) +end + +---@param bufnr integer +---@return any +function M.get_locals(bufnr) + return queries.get_matches(bufnr, "locals") +end + +-- Creates unique id for a node based on text and range +---@param scope TSNode: the scope node of the definition +---@param node_text string: the node text to use +---@return string: a string id +function M.get_definition_id(scope, node_text) + -- Add a valid starting character in case node text doesn't start with a valid one. + return table.concat({ "k", node_text or "", scope:range() }, "_") +end + +function M.get_definitions(bufnr) + local locals = M.get_locals(bufnr) + + local defs = {} + + for _, loc in ipairs(locals) do + if loc["local"]["definition"] then + table.insert(defs, loc["local"]["definition"]) + end + end + + return defs +end + +function M.get_scopes(bufnr) + local locals = M.get_locals(bufnr) + + local scopes = {} + + for _, loc in ipairs(locals) do + if loc["local"]["scope"] and loc["local"]["scope"].node then + table.insert(scopes, loc["local"]["scope"].node) + end + end + + return scopes +end + +function M.get_references(bufnr) + local locals = M.get_locals(bufnr) + + local refs = {} + + for _, loc in ipairs(locals) do + if loc["local"]["reference"] and loc["local"]["reference"].node then + table.insert(refs, loc["local"]["reference"].node) + end + end + + return refs +end + +-- Gets a table with all the scopes containing a node +-- The order is from most specific to least (bottom up) +---@param node TSNode +---@param bufnr integer +---@return TSNode[] +function M.get_scope_tree(node, bufnr) + local scopes = {} ---@type TSNode[] + + for scope in M.iter_scope_tree(node, bufnr) do + table.insert(scopes, scope) + end + + return scopes +end + +-- Iterates over a nodes scopes moving from the bottom up +---@param node TSNode +---@param bufnr integer +---@return fun(): TSNode|nil +function M.iter_scope_tree(node, bufnr) + local last_node = node + return function() + if not last_node then + return + end + + local scope = M.containing_scope(last_node, bufnr, false) or ts_utils.get_root_for_node(node) + + last_node = scope:parent() + + return scope + end +end + +-- Gets a table of all nodes and their 'kinds' from a locals list +---@param local_def any: the local list result +---@return table: a list of node entries +function M.get_local_nodes(local_def) + local result = {} + + M.recurse_local_nodes(local_def, function(def, _node, kind) + table.insert(result, vim.tbl_extend("keep", { kind = kind }, def)) + end) + + return result +end + +-- Recurse locals results until a node is found. +-- The accumulator function is given +-- * The table of the node +-- * The node +-- * The full definition match `@definition.var.something` -> 'var.something' +-- * The last definition match `@definition.var.something` -> 'something' +---@param local_def any The locals result +---@param accumulator function The accumulator function +---@param full_match? string The full match path to append to +---@param last_match? string The last match +function M.recurse_local_nodes(local_def, accumulator, full_match, last_match) + if type(local_def) ~= "table" then + return + end + + if local_def.node then + accumulator(local_def, local_def.node, full_match, last_match) + else + for match_key, def in pairs(local_def) do + M.recurse_local_nodes(def, accumulator, full_match and (full_match .. "." .. match_key) or match_key, match_key) + end + end +end + +-- Get a single dimension table to look definition nodes. +-- Keys are generated by using the range of the containing scope and the text of the definition node. +-- This makes looking up a definition for a given scope a simple key lookup. +-- +-- This is memoized by buffer tick. If the function is called in succession +-- without the buffer tick changing, then the previous result will be used +-- since the syntax tree hasn't changed. +-- +-- Usage lookups require finding the definition of the node, so `find_definition` +-- is called very frequently, which is why this lookup must be fast as possible. +-- +---@param bufnr integer: the buffer +---@return table result: a table for looking up definitions +M.get_definitions_lookup_table = ts_utils.memoize_by_buf_tick(function(bufnr) + local definitions = M.get_definitions(bufnr) + local result = {} + + for _, definition in ipairs(definitions) do + for _, node_entry in ipairs(M.get_local_nodes(definition)) do + local scopes = M.get_definition_scopes(node_entry.node, bufnr, node_entry.scope) + -- Always use the highest valid scope + local scope = scopes[#scopes] + local node_text = ts.get_node_text(node_entry.node, bufnr) + local id = M.get_definition_id(scope, node_text) + + result[id] = node_entry + end + end + + return result +end) + +-- Gets all the scopes of a definition based on the scope type +-- Scope types can be +-- +-- "parent": Uses the parent of the containing scope, basically, skipping a scope +-- "global": Uses the top most scope +-- "local": Uses the containing scope of the definition. This is the default +-- +---@param node TSNode: the definition node +---@param bufnr integer: the buffer +---@param scope_type string: the scope type +function M.get_definition_scopes(node, bufnr, scope_type) + local scopes = {} + local scope_count = 1 ---@type integer|nil + + -- Definition is valid for the containing scope + -- and the containing scope of that scope + if scope_type == "parent" then + scope_count = 2 + -- Definition is valid in all parent scopes + elseif scope_type == "global" then + scope_count = nil + end + + local i = 0 + for scope in M.iter_scope_tree(node, bufnr) do + table.insert(scopes, scope) + i = i + 1 + + if scope_count and i >= scope_count then + break + end + end + + return scopes +end + +---@param node TSNode +---@param bufnr integer +---@return TSNode node +---@return TSNode scope +---@return string|nil kind +function M.find_definition(node, bufnr) + local def_lookup = M.get_definitions_lookup_table(bufnr) + local node_text = ts.get_node_text(node, bufnr) + + for scope in M.iter_scope_tree(node, bufnr) do + local id = M.get_definition_id(scope, node_text) + + if def_lookup[id] then + local entry = def_lookup[id] + + return entry.node, scope, entry.kind + end + end + + return node, ts_utils.get_root_for_node(node), nil +end + +-- Finds usages of a node in a given scope. +---@param node TSNode the node to find usages for +---@param scope_node TSNode the node to look within +---@return TSNode[]: a list of nodes +function M.find_usages(node, scope_node, bufnr) + bufnr = bufnr or api.nvim_get_current_buf() + local node_text = ts.get_node_text(node, bufnr) + + if not node_text or #node_text < 1 then + return {} + end + + local scope_node = scope_node or ts_utils.get_root_for_node(node) + local usages = {} + + for match in M.iter_locals(bufnr, scope_node) do + match = match["local"] + if match.reference and match.reference.node and ts.get_node_text(match.reference.node, bufnr) == node_text then + local def_node, _, kind = M.find_definition(match.reference.node, bufnr) + + if kind == nil or def_node == node then + table.insert(usages, match.reference.node) + end + end + end + + return usages +end + +---@param node TSNode +---@param bufnr? integer +---@param allow_scope? boolean +---@return TSNode|nil +function M.containing_scope(node, bufnr, allow_scope) + local bufnr = bufnr or api.nvim_get_current_buf() + local allow_scope = allow_scope == nil or allow_scope == true + + local scopes = M.get_scopes(bufnr) + if not node or not scopes then + return + end + + local iter_node = node + + while iter_node ~= nil and not vim.tbl_contains(scopes, iter_node) do + iter_node = iter_node:parent() + end + + return iter_node or (allow_scope and node or nil) +end + +function M.nested_scope(node, cursor_pos) + local bufnr = api.nvim_get_current_buf() + + local scopes = M.get_scopes(bufnr) + if not node or not scopes then + return + end + + local row = cursor_pos.row ---@type integer + local col = cursor_pos.col ---@type integer + local scope = M.containing_scope(node) + + for _, child in ipairs(ts_utils.get_named_children(scope)) do + local row_, col_ = child:start() + if vim.tbl_contains(scopes, child) and ((row_ + 1 == row and col_ > col) or row_ + 1 > row) then + return child + end + end +end + +function M.next_scope(node) + local bufnr = api.nvim_get_current_buf() + + local scopes = M.get_scopes(bufnr) + if not node or not scopes then + return + end + + local scope = M.containing_scope(node) + + local parent = scope:parent() + if not parent then + return + end + + local is_prev = true + for _, child in ipairs(ts_utils.get_named_children(parent)) do + if child == scope then + is_prev = false + elseif not is_prev and vim.tbl_contains(scopes, child) then + return child + end + end +end + +---@param node TSNode +---@return TSNode|nil +function M.previous_scope(node) + local bufnr = api.nvim_get_current_buf() + + local scopes = M.get_scopes(bufnr) + if not node or not scopes then + return + end + + local scope = M.containing_scope(node) + + local parent = scope:parent() + if not parent then + return + end + + local is_prev = true + local children = ts_utils.get_named_children(parent) + for i = #children, 1, -1 do + if children[i] == scope then + is_prev = false + elseif not is_prev and vim.tbl_contains(scopes, children[i]) then + return children[i] + end + end +end + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/parsers.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/parsers.lua new file mode 100644 index 0000000..f673130 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/parsers.lua @@ -0,0 +1,2693 @@ +local api = vim.api +local ts = vim.treesitter + +for ft, lang in pairs { + automake = "make", + javascriptreact = "javascript", + ecma = "javascript", + jsx = "javascript", + gyp = "python", + html_tags = "html", + ["typescript.tsx"] = "tsx", + ["terraform-vars"] = "terraform", + ["html.handlebars"] = "glimmer", + systemverilog = "verilog", + dosini = "ini", + confini = "ini", + svg = "xml", + xsd = "xml", + xslt = "xml", + expect = "tcl", + mysql = "sql", + sbt = "scala", + neomuttrc = "muttrc", + --- short-hand list from https://github.com/helix-editor/helix/blob/master/languages.toml + rs = "rust", + ex = "elixir", + js = "javascript", + ts = "typescript", + ["c-sharp"] = "csharp", + hs = "haskell", + py = "python", + erl = "erlang", + typ = "typst", + pl = "perl", + uxn = "uxntal", +} do + ts.language.register(lang, ft) +end + +---@class InstallInfo +---@field url string +---@field branch string|nil +---@field revision string|nil +---@field files string[] +---@field generate_requires_npm boolean|nil +---@field requires_generate_from_grammar boolean|nil +---@field location string|nil +---@field use_makefile boolean|nil +---@field cxx_standard string|nil + +---@class ParserInfo +---@field install_info InstallInfo +---@field filetype string +---@field maintainers string[] +---@field experimental boolean|nil +---@field readme_name string|nil + +---@type ParserInfo[] +local list = setmetatable({}, { + __newindex = function(table, parsername, parserconfig) + rawset(table, parsername, parserconfig) + if parserconfig.filetype or vim.fn.has "nvim-0.11" == 0 then + ts.language.register(parsername, parserconfig.filetype or parsername) + end + end, +}) + +list.ada = { + install_info = { + url = "https://github.com/briot/tree-sitter-ada", + files = { "src/parser.c" }, + }, + maintainers = { "@briot" }, +} + +list.agda = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-agda", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@Decodetalkers" }, +} + +list.angular = { + install_info = { + url = "https://github.com/dlvandenberg/tree-sitter-angular", + files = { "src/parser.c", "src/scanner.c" }, + generate_requires_npm = true, + }, + filetype = "htmlangular", + maintainers = { "@dlvandenberg" }, + experimental = true, +} + +list.apex = { + install_info = { + url = "https://github.com/aheber/tree-sitter-sfapex", + files = { "src/parser.c" }, + location = "apex", + }, + maintainers = { "@aheber", "@xixiaofinland" }, +} + +list.arduino = { + install_info = { + url = "https://github.com/ObserverOfTime/tree-sitter-arduino", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@ObserverOfTime" }, +} + +list.asm = { + install_info = { + url = "https://github.com/RubixDev/tree-sitter-asm", + files = { "src/parser.c" }, + }, + maintainers = { "@RubixDev" }, +} + +list.astro = { + install_info = { + url = "https://github.com/virchau13/tree-sitter-astro", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@virchau13" }, +} + +list.authzed = { + install_info = { + url = "https://github.com/mleonidas/tree-sitter-authzed", + files = { "src/parser.c" }, + }, + maintainers = { "@mattpolzin" }, +} + +list.awk = { + install_info = { + url = "https://github.com/Beaglefoot/tree-sitter-awk", + files = { "src/parser.c", "src/scanner.c" }, + }, +} + +list.bash = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-bash", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "sh", + maintainers = { "@TravonteD" }, +} + +list.bass = { + install_info = { + url = "https://github.com/vito/tree-sitter-bass", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.beancount = { + install_info = { + url = "https://github.com/polarmutex/tree-sitter-beancount", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@polarmutex" }, +} + +list.bibtex = { + install_info = { + url = "https://github.com/latex-lsp/tree-sitter-bibtex", + files = { "src/parser.c" }, + }, + filetype = "bib", + maintainers = { "@theHamsta", "@clason" }, +} + +list.bicep = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-bicep", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.bitbake = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-bitbake", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.blueprint = { + install_info = { + url = "https://gitlab.com/gabmus/tree-sitter-blueprint.git", + files = { "src/parser.c" }, + }, + maintainers = { "@gabmus" }, + experimental = true, +} + +list.bp = { + install_info = { + url = "https://github.com/ambroisie/tree-sitter-bp", + files = { "src/parser.c" }, + }, + maintainers = { "@ambroisie" }, +} + +list.c = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-c", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.c_sharp = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-c-sharp", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "cs", + maintainers = { "@amaanq" }, +} + +list.cairo = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-cairo", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.capnp = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-capnp", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.chatito = { + install_info = { + url = "https://github.com/ObserverOfTime/tree-sitter-chatito", + files = { "src/parser.c" }, + }, + maintainers = { "@ObserverOfTime" }, +} + +list.clojure = { + install_info = { + url = "https://github.com/sogaiu/tree-sitter-clojure", + files = { "src/parser.c" }, + }, + maintainers = { "@NoahTheDuke" }, +} + +list.cmake = { + install_info = { + url = "https://github.com/uyha/tree-sitter-cmake", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@uyha" }, +} + +list.comment = { + install_info = { + url = "https://github.com/stsewd/tree-sitter-comment", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@stsewd" }, +} + +list.commonlisp = { + install_info = { + url = "https://github.com/theHamsta/tree-sitter-commonlisp", + files = { "src/parser.c" }, + generate_requires_npm = true, + }, + filetype = "lisp", + maintainers = { "@theHamsta" }, +} + +list.cooklang = { + install_info = { + url = "https://github.com/addcninblue/tree-sitter-cooklang", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@addcninblue" }, +} + +list.corn = { + install_info = { + url = "https://github.com/jakestanger/tree-sitter-corn", + files = { "src/parser.c" }, + }, + maintainers = { "@jakestanger" }, +} + +list.cpon = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-cpon", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.cpp = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-cpp", + files = { "src/parser.c", "src/scanner.c" }, + generate_requires_npm = true, + }, + maintainers = { "@theHamsta" }, +} + +list.css = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-css", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@TravonteD" }, +} + +list.csv = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-csv", + files = { "src/parser.c" }, + location = "csv", + }, + maintainers = { "@amaanq" }, +} + +list.cuda = { + install_info = { + url = "https://github.com/theHamsta/tree-sitter-cuda", + files = { "src/parser.c", "src/scanner.c" }, + generate_requires_npm = true, + }, + maintainers = { "@theHamsta" }, +} + +list.cue = { + install_info = { + url = "https://github.com/eonpatapon/tree-sitter-cue", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.d = { + install_info = { + url = "https://github.com/gdamore/tree-sitter-d", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.dart = { + install_info = { + url = "https://github.com/UserNobody14/tree-sitter-dart", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@akinsho" }, +} + +list.devicetree = { + install_info = { + url = "https://github.com/joelspadin/tree-sitter-devicetree", + files = { "src/parser.c" }, + }, + filetype = "dts", + maintainers = { "@jedrzejboczar" }, +} + +list.dhall = { + install_info = { + url = "https://github.com/jbellerb/tree-sitter-dhall", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.diff = { + install_info = { + url = "https://github.com/the-mikedavis/tree-sitter-diff", + files = { "src/parser.c" }, + }, + filetype = "gitdiff", + maintainers = { "@gbprod" }, +} + +list.disassembly = { + install_info = { + url = "https://github.com/ColinKennedy/tree-sitter-disassembly", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@ColinKennedy" }, +} + +list.djot = { + install_info = { + url = "https://github.com/treeman/tree-sitter-djot", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@NoahTheDuke" }, +} + +list.dockerfile = { + install_info = { + url = "https://github.com/camdencheek/tree-sitter-dockerfile", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@camdencheek" }, +} + +list.dot = { + install_info = { + url = "https://github.com/rydesun/tree-sitter-dot", + files = { "src/parser.c" }, + }, + maintainers = { "@rydesun" }, +} + +list.doxygen = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-doxygen", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.dtd = { + install_info = { + url = "https://github.com/tree-sitter-grammars/tree-sitter-xml", + files = { "src/parser.c", "src/scanner.c" }, + location = "dtd", + }, + maintainers = { "@ObserverOfTime" }, +} + +list.earthfile = { + install_info = { + url = "https://github.com/glehmann/tree-sitter-earthfile", + files = { "src/parser.c" }, + }, + maintainers = { "@glehmann" }, +} + +list.ebnf = { + install_info = { + url = "https://github.com/RubixDev/ebnf", + files = { "src/parser.c" }, + location = "crates/tree-sitter-ebnf", + }, + maintainers = { "@RubixDev" }, + experimental = true, +} + +list.editorconfig = { + install_info = { + url = "https://github.com/ValdezFOmar/tree-sitter-editorconfig", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@ValdezFOmar" }, +} + +list.eds = { + install_info = { + url = "https://github.com/uyha/tree-sitter-eds", + files = { "src/parser.c" }, + }, + maintainers = { "@uyha" }, +} + +list.eex = { + install_info = { + url = "https://github.com/connorlay/tree-sitter-eex", + files = { "src/parser.c" }, + }, + filetype = "eelixir", + maintainers = { "@connorlay" }, +} + +list.elixir = { + install_info = { + url = "https://github.com/elixir-lang/tree-sitter-elixir", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@connorlay" }, +} + +list.elm = { + install_info = { + url = "https://github.com/elm-tooling/tree-sitter-elm", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@zweimach" }, +} + +list.elsa = { + install_info = { + url = "https://github.com/glapa-grossklag/tree-sitter-elsa", + files = { "src/parser.c" }, + }, + maintainers = { "@glapa-grossklag", "@amaanq" }, +} + +list.elvish = { + install_info = { + url = "https://github.com/elves/tree-sitter-elvish", + files = { "src/parser.c" }, + }, + maintainers = { "@elves" }, +} + +list.embedded_template = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-embedded-template", + files = { "src/parser.c" }, + }, + filetype = "eruby", +} + +list.erlang = { + install_info = { + url = "https://github.com/WhatsApp/tree-sitter-erlang", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@filmor" }, +} + +list.facility = { + install_info = { + url = "https://github.com/FacilityApi/tree-sitter-facility", + files = { "src/parser.c" }, + }, + filetype = "fsd", + maintainers = { "@bryankenote" }, +} + +list.faust = { + install_info = { + url = "https://github.com/khiner/tree-sitter-faust", + files = { "src/parser.c" }, + }, + filetype = "dsp", + maintainers = { "@khiner" }, +} + +list.fennel = { + install_info = { + url = "https://github.com/alexmozaidze/tree-sitter-fennel", + files = { "src/parser.c", "src/scanner.c" }, + generate_requires_npm = true, + }, + maintainers = { "@alexmozaidze" }, +} + +list.fidl = { + install_info = { + url = "https://github.com/google/tree-sitter-fidl", + files = { "src/parser.c" }, + }, + maintainers = { "@chaopeng" }, +} + +list.firrtl = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-firrtl", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.fish = { + install_info = { + url = "https://github.com/ram02z/tree-sitter-fish", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@ram02z" }, +} + +list.foam = { + install_info = { + url = "https://github.com/FoamScience/tree-sitter-foam", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@FoamScience" }, + -- Queries might change over time on the grammar's side + -- Otherwise everything runs fine + experimental = true, +} + +list.forth = { + install_info = { + url = "https://github.com/AlexanderBrevig/tree-sitter-forth", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.fortran = { + install_info = { + url = "https://github.com/stadelmanma/tree-sitter-fortran", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.fsh = { + install_info = { + url = "https://github.com/mgramigna/tree-sitter-fsh", + files = { "src/parser.c" }, + }, + maintainers = { "@mgramigna" }, +} + +list.fsharp = { + install_info = { + url = "https://github.com/ionide/tree-sitter-fsharp", + files = { "src/parser.c", "src/scanner.c" }, + location = "fsharp", + }, + maintainers = { "@nsidorenco" }, +} + +list.func = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-func", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.fusion = { + install_info = { + url = "https://gitlab.com/jirgn/tree-sitter-fusion.git", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@jirgn" }, +} + +list.gap = { + install_info = { + url = "https://github.com/gap-system/tree-sitter-gap", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@reiniscirpons" }, + readme_name = "GAP system", +} + +list.gaptst = { + install_info = { + url = "https://github.com/gap-system/tree-sitter-gaptst", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@reiniscirpons" }, + readme_name = "GAP system test files", +} + +list.gdscript = { + install_info = { + url = "https://github.com/PrestonKnopp/tree-sitter-gdscript", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@PrestonKnopp" }, + readme_name = "Godot (gdscript)", +} + +list.gdshader = { + install_info = { + url = "https://github.com/GodOfAvacyn/tree-sitter-gdshader", + files = { "src/parser.c" }, + }, + filetype = "gdshaderinc", + maintainers = { "@godofavacyn" }, +} + +list.git_rebase = { + install_info = { + url = "https://github.com/the-mikedavis/tree-sitter-git-rebase", + files = { "src/parser.c" }, + }, + filetype = "gitrebase", + maintainers = { "@gbprod" }, +} + +list.gitattributes = { + install_info = { + url = "https://github.com/ObserverOfTime/tree-sitter-gitattributes", + files = { "src/parser.c" }, + }, + maintainers = { "@ObserverOfTime" }, +} + +list.gitcommit = { + install_info = { + url = "https://github.com/gbprod/tree-sitter-gitcommit", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@gbprod" }, +} + +list.git_config = { + install_info = { + url = "https://github.com/the-mikedavis/tree-sitter-git-config", + files = { "src/parser.c" }, + }, + filetype = "gitconfig", + maintainers = { "@amaanq" }, + readme_name = "git_config", +} + +list.gitignore = { + install_info = { + url = "https://github.com/shunsambongi/tree-sitter-gitignore", + files = { "src/parser.c" }, + }, + maintainers = { "@theHamsta" }, +} + +list.gleam = { + install_info = { + url = "https://github.com/gleam-lang/tree-sitter-gleam", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.glimmer = { + install_info = { + url = "https://github.com/ember-tooling/tree-sitter-glimmer", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "handlebars", + maintainers = { "@NullVoxPopuli" }, + readme_name = "Glimmer and Ember", +} + +list.glimmer_javascript = { + install_info = { + url = "https://github.com/NullVoxPopuli/tree-sitter-glimmer-javascript", + files = { "src/parser.c", "src/scanner.c" }, + generate_requires_npm = true, + }, + filetype = "javascript.glimmer", + maintainers = { "@NullVoxPopuli" }, +} + +list.glimmer_typescript = { + install_info = { + url = "https://github.com/NullVoxPopuli/tree-sitter-glimmer-typescript", + files = { "src/parser.c", "src/scanner.c" }, + generate_requires_npm = true, + }, + filetype = "typescript.glimmer", + maintainers = { "@NullVoxPopuli" }, +} + +list.glsl = { + install_info = { + url = "https://github.com/theHamsta/tree-sitter-glsl", + files = { "src/parser.c" }, + generate_requires_npm = true, + }, + maintainers = { "@theHamsta" }, +} + +list.gn = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-gn", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, + readme_name = "GN (Generate Ninja)", +} + +list.gnuplot = { + install_info = { + url = "https://github.com/dpezto/tree-sitter-gnuplot", + files = { "src/parser.c" }, + }, + maintainers = { "@dpezto" }, +} + +list.go = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-go", + files = { "src/parser.c" }, + }, + maintainers = { "@theHamsta", "@WinWisely268" }, +} + +list.goctl = { + install_info = { + url = "https://github.com/chaozwn/tree-sitter-goctl", + files = { "src/parser.c" }, + }, + maintainers = { "@chaozwn" }, +} + +list.godot_resource = { + install_info = { + url = "https://github.com/PrestonKnopp/tree-sitter-godot-resource", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "gdresource", + maintainers = { "@pierpo" }, + readme_name = "Godot Resources (gdresource)", +} + +list.gomod = { + install_info = { + url = "https://github.com/camdencheek/tree-sitter-go-mod", + files = { "src/parser.c" }, + }, + maintainers = { "@camdencheek" }, +} + +list.gosum = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-go-sum", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.gowork = { + install_info = { + url = "https://github.com/omertuc/tree-sitter-go-work", + files = { "src/parser.c" }, + }, + maintainers = { "@omertuc" }, +} + +list.gotmpl = { + install_info = { + url = "https://github.com/ngalaiko/tree-sitter-go-template", + files = { "src/parser.c" }, + }, + maintainers = { "@qvalentin" }, +} + +list.gpg = { + install_info = { + url = "https://github.com/ObserverOfTime/tree-sitter-gpg-config", + files = { "src/parser.c" }, + }, + maintainers = { "@ObserverOfTime" }, +} + +list.gren = { + install_info = { + files = { "src/parser.c", "src/scanner.c" }, + url = "https://github.com/MaeBrooks/tree-sitter-gren", + }, + maintainers = { "@MaeBrooks" }, +} + +list.groovy = { + install_info = { + url = "https://github.com/murtaza64/tree-sitter-groovy", + files = { "src/parser.c" }, + }, + maintainers = { "@murtaza64" }, +} + +list.graphql = { + install_info = { + url = "https://github.com/bkegley/tree-sitter-graphql", + files = { "src/parser.c" }, + }, + maintainers = { "@bkegley" }, +} + +list.gstlaunch = { + install_info = { + url = "https://github.com/theHamsta/tree-sitter-gstlaunch", + files = { "src/parser.c" }, + }, + maintainers = { "@theHamsta" }, +} + +list.hack = { + install_info = { + url = "https://github.com/slackhq/tree-sitter-hack", + files = { "src/parser.c", "src/scanner.c" }, + }, +} + +list.hare = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-hare", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.haskell = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-haskell", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@mrcjkb" }, +} + +list.haskell_persistent = { + install_info = { + url = "https://github.com/MercuryTechnologies/tree-sitter-haskell-persistent", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "haskellpersistent", + maintainers = { "@lykahb" }, +} + +list.hcl = { + install_info = { + url = "https://github.com/MichaHoffmann/tree-sitter-hcl", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@MichaHoffmann" }, +} + +list.heex = { + install_info = { + url = "https://github.com/connorlay/tree-sitter-heex", + files = { "src/parser.c" }, + }, + maintainers = { "@connorlay" }, +} + +list.helm = { + install_info = { + url = "https://github.com/ngalaiko/tree-sitter-go-template", + location = "dialects/helm", + files = { "src/parser.c" }, + }, + maintainers = { "@qvalentin" }, +} + +list.hjson = { + install_info = { + url = "https://github.com/winston0410/tree-sitter-hjson", + files = { "src/parser.c" }, + generate_requires_npm = true, + }, + maintainers = { "@winston0410" }, +} + +list.hlsl = { + install_info = { + url = "https://github.com/theHamsta/tree-sitter-hlsl", + files = { "src/parser.c", "src/scanner.c" }, + generate_requires_npm = true, + }, + maintainers = { "@theHamsta" }, +} + +list.hocon = { + install_info = { + url = "https://github.com/antosha417/tree-sitter-hocon", + files = { "src/parser.c" }, + generate_requires_npm = true, + }, + maintainers = { "@antosha417" }, +} + +list.hoon = { + install_info = { + url = "https://github.com/urbit-pilled/tree-sitter-hoon", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@urbit-pilled" }, + experimental = true, +} + +list.html = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-html", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@TravonteD" }, +} + +list.htmldjango = { + install_info = { + url = "https://github.com/interdependence/tree-sitter-htmldjango", + files = { "src/parser.c" }, + }, + maintainers = { "@ObserverOfTime" }, + experimental = true, +} + +list.http = { + install_info = { + url = "https://github.com/rest-nvim/tree-sitter-http", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq", "@NTBBloodbath" }, +} + +list.hurl = { + install_info = { + url = "https://github.com/pfeiferj/tree-sitter-hurl", + files = { "src/parser.c" }, + }, + maintainers = { "@pfeiferj" }, +} + +list.hyprlang = { + install_info = { + url = "https://github.com/luckasRanarison/tree-sitter-hyprlang", + files = { "src/parser.c" }, + }, + maintainers = { "@luckasRanarison" }, +} + +list.idl = { + install_info = { + url = "https://github.com/cathaysia/tree-sitter-idl", + files = { "src/parser.c" }, + }, + maintainers = { "@cathaysia" }, +} + +list.ini = { + install_info = { + url = "https://github.com/justinmk/tree-sitter-ini", + files = { "src/parser.c" }, + }, + maintainers = { "@theHamsta" }, + experimental = true, +} + +list.inko = { + install_info = { + url = "https://github.com/inko-lang/tree-sitter-inko", + files = { "src/parser.c" }, + }, + maintainers = { "@yorickpeterse" }, +} + +list.ispc = { + install_info = { + url = "https://github.com/fab4100/tree-sitter-ispc", + files = { "src/parser.c" }, + generate_requires_npm = true, + }, + maintainers = { "@fab4100" }, +} + +list.janet_simple = { + install_info = { + url = "https://github.com/sogaiu/tree-sitter-janet-simple", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "janet", + maintainers = { "@sogaiu" }, +} + +list.java = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-java", + files = { "src/parser.c" }, + }, + maintainers = { "@p00f" }, +} + +list.javascript = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-javascript", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@steelsojka" }, +} + +list.jq = { + install_info = { + url = "https://github.com/flurie/tree-sitter-jq", + files = { "src/parser.c" }, + }, + maintainers = { "@ObserverOfTime" }, +} + +list.jsdoc = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-jsdoc", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@steelsojka" }, +} + +list.json = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-json", + files = { "src/parser.c" }, + }, + maintainers = { "@steelsojka" }, +} + +list.json5 = { + install_info = { + url = "https://github.com/Joakker/tree-sitter-json5", + files = { "src/parser.c" }, + }, + maintainers = { "@Joakker" }, +} + +list.jsonc = { + install_info = { + url = "https://gitlab.com/WhyNotHugo/tree-sitter-jsonc.git", + files = { "src/parser.c" }, + generate_requires_npm = true, + }, + maintainers = { "@WhyNotHugo" }, + readme_name = "JSON with comments", +} + +list.jsonnet = { + install_info = { + url = "https://github.com/sourcegraph/tree-sitter-jsonnet", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@nawordar" }, +} + +list.julia = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-julia", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@theHamsta" }, +} + +list.just = { + install_info = { + url = "https://github.com/IndianBoy42/tree-sitter-just", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@Hubro" }, +} + +list.kconfig = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-kconfig", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.kdl = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-kdl", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.kotlin = { + install_info = { + url = "https://github.com/fwcd/tree-sitter-kotlin", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@SalBakraa" }, +} + +list.koto = { + install_info = { + url = "https://github.com/koto-lang/tree-sitter-koto", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@irh" }, +} + +list.kusto = { + install_info = { + url = "https://github.com/Willem-J-an/tree-sitter-kusto", + files = { "src/parser.c" }, + }, + maintainers = { "@Willem-J-an" }, +} + +list.lalrpop = { + install_info = { + url = "https://github.com/traxys/tree-sitter-lalrpop", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@traxys" }, +} + +list.latex = { + install_info = { + url = "https://github.com/latex-lsp/tree-sitter-latex", + files = { "src/parser.c", "src/scanner.c" }, + requires_generate_from_grammar = true, + }, + filetype = "tex", + maintainers = { "@theHamsta", "@clason" }, +} + +list.ledger = { + install_info = { + url = "https://github.com/cbarrete/tree-sitter-ledger", + files = { "src/parser.c" }, + }, + maintainers = { "@cbarrete" }, +} + +list.leo = { + install_info = { + url = "https://github.com/r001/tree-sitter-leo", + files = { "src/parser.c" }, + }, + maintainers = { "@r001" }, +} + +list.llvm = { + install_info = { + url = "https://github.com/benwilliamgraham/tree-sitter-llvm", + files = { "src/parser.c" }, + }, + maintainers = { "@benwilliamgraham" }, +} + +list.linkerscript = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-linkerscript", + files = { "src/parser.c" }, + }, + filetype = "ld", + maintainers = { "@amaanq" }, +} + +list.liquid = { + install_info = { + url = "https://github.com/hankthetank27/tree-sitter-liquid", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@hankthetank27" }, +} + +list.liquidsoap = { + install_info = { + url = "https://github.com/savonet/tree-sitter-liquidsoap", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@toots" }, +} + +list.lua = { + install_info = { + url = "https://github.com/MunifTanjim/tree-sitter-lua", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@muniftanjim" }, +} + +list.luadoc = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-luadoc", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.luap = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-luap", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, + readme_name = "lua patterns", +} + +list.luau = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-luau", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.hlsplaylist = { + install_info = { + url = "https://github.com/Freed-Wu/tree-sitter-hlsplaylist", + files = { "src/parser.c" }, + }, + maintainers = { "@Freed-Wu" }, +} + +list.m68k = { + install_info = { + url = "https://github.com/grahambates/tree-sitter-m68k", + files = { "src/parser.c" }, + }, + filetype = "asm68k", + maintainers = { "@grahambates" }, +} + +list.make = { + install_info = { + url = "https://github.com/alemuller/tree-sitter-make", + files = { "src/parser.c" }, + }, + maintainers = { "@lewis6991" }, +} + +list.markdown = { + install_info = { + url = "https://github.com/MDeiml/tree-sitter-markdown", + location = "tree-sitter-markdown", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@MDeiml" }, + readme_name = "markdown (basic highlighting)", + experimental = true, +} + +list.markdown_inline = { + install_info = { + url = "https://github.com/MDeiml/tree-sitter-markdown", + location = "tree-sitter-markdown-inline", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@MDeiml" }, + readme_name = "markdown_inline (needed for full highlighting)", + experimental = true, +} + +list.matlab = { + install_info = { + url = "https://github.com/acristoffers/tree-sitter-matlab", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@acristoffers" }, +} + +list.menhir = { + install_info = { + url = "https://github.com/Kerl13/tree-sitter-menhir", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@Kerl13" }, +} + +list.mermaid = { + install_info = { + url = "https://github.com/monaqa/tree-sitter-mermaid", + files = { "src/parser.c" }, + }, + experimental = true, +} + +list.meson = { + install_info = { + url = "https://github.com/Decodetalkers/tree-sitter-meson", + files = { "src/parser.c" }, + }, + maintainers = { "@Decodetalkers" }, +} + +list.mlir = { + install_info = { + url = "https://github.com/artagnon/tree-sitter-mlir", + files = { "src/parser.c" }, + requires_generate_from_grammar = true, + }, + experimental = true, + maintainers = { "@artagnon" }, +} + +list.muttrc = { + install_info = { + url = "https://github.com/neomutt/tree-sitter-muttrc", + files = { "src/parser.c" }, + }, + maintainers = { "@Freed-Wu" }, +} + +list.nasm = { + install_info = { + url = "https://github.com/naclsn/tree-sitter-nasm", + files = { "src/parser.c" }, + }, + maintainers = { "@ObserverOfTime" }, +} + +list.nginx = { + install_info = { + url = "https://github.com/opa-oz/tree-sitter-nginx", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@opa-oz" }, +} + +list.nickel = { + install_info = { + url = "https://github.com/nickel-lang/tree-sitter-nickel", + files = { "src/parser.c", "src/scanner.c" }, + }, +} + +list.nim = { + install_info = { + url = "https://github.com/alaviss/tree-sitter-nim", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@aMOPel" }, +} + +list.nim_format_string = { + install_info = { + url = "https://github.com/aMOPel/tree-sitter-nim-format-string", + files = { "src/parser.c" }, + }, + maintainers = { "@aMOPel" }, +} + +list.ninja = { + install_info = { + url = "https://github.com/alemuller/tree-sitter-ninja", + files = { "src/parser.c" }, + }, + maintainers = { "@alemuller" }, +} + +list.nix = { + install_info = { + url = "https://github.com/cstrahan/tree-sitter-nix", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@leo60228" }, +} + +list.norg = { + install_info = { + url = "https://github.com/nvim-neorg/tree-sitter-norg", + files = { "src/parser.c", "src/scanner.cc" }, + cxx_standard = "c++14", + use_makefile = true, + }, + maintainers = { "@JoeyGrajciar", "@vhyrro" }, +} + +list.nqc = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-nqc", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.objc = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-objc", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.objdump = { + install_info = { + url = "https://github.com/ColinKennedy/tree-sitter-objdump", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@ColinKennedy" }, +} + +list.ocaml = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-ocaml", + files = { "src/parser.c", "src/scanner.c" }, + location = "grammars/ocaml", + }, + maintainers = { "@undu" }, +} + +list.ocaml_interface = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-ocaml", + files = { "src/parser.c", "src/scanner.c" }, + location = "grammars/interface", + }, + filetype = "ocamlinterface", + maintainers = { "@undu" }, +} + +list.ocamllex = { + install_info = { + url = "https://github.com/atom-ocaml/tree-sitter-ocamllex", + files = { "src/parser.c", "src/scanner.c" }, + requires_generate_from_grammar = true, + }, + maintainers = { "@undu" }, +} + +list.odin = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-odin", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.org = { + install_info = { + url = "https://github.com/milisims/tree-sitter-org", + files = { "src/parser.c", "src/scanner.c" }, + }, +} + +list.pascal = { + install_info = { + url = "https://github.com/Isopod/tree-sitter-pascal", + files = { "src/parser.c" }, + }, + maintainers = { "@Isopod" }, +} + +list.passwd = { + install_info = { + url = "https://github.com/ath3/tree-sitter-passwd", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.pem = { + install_info = { + url = "https://github.com/ObserverOfTime/tree-sitter-pem", + files = { "src/parser.c" }, + }, + maintainers = { "@ObserverOfTime" }, +} + +list.perl = { + install_info = { + url = "https://github.com/tree-sitter-perl/tree-sitter-perl", + files = { "src/parser.c", "src/scanner.c" }, + branch = "release", + }, + maintainers = { "@RabbiVeesh", "@LeoNerd" }, +} + +list.php = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-php", + location = "php", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@tk-shirasaka", "@calebdw" }, +} + +list.php_only = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-php", + location = "php_only", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@tk-shirasaka", "@calebdw" }, +} + +-- Parsers for injections +list.phpdoc = { + install_info = { + url = "https://github.com/claytonrcarter/tree-sitter-phpdoc", + files = { "src/parser.c", "src/scanner.c" }, + generate_requires_npm = true, + }, + maintainers = { "@mikehaertl" }, + experimental = true, +} + +list.pioasm = { + install_info = { + url = "https://github.com/leo60228/tree-sitter-pioasm", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@leo60228" }, +} + +list.po = { + install_info = { + url = "https://github.com/erasin/tree-sitter-po", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.pod = { + install_info = { + url = "https://github.com/tree-sitter-perl/tree-sitter-pod", + files = { "src/parser.c", "src/scanner.c" }, + branch = "release", + }, + maintainers = { "@RabbiVeesh", "@LeoNerd" }, +} + +list.poe_filter = { + install_info = { + url = "https://github.com/ObserverOfTime/tree-sitter-poe-filter", + files = { "src/parser.c" }, + }, + filetype = "poefilter", + maintainers = { "@ObserverOfTime" }, + readme_name = "Path of Exile item filter", + experimental = true, +} + +list.pony = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-pony", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq", "@mfelsche" }, +} + +list.powershell = { + install_info = { + url = "https://github.com/airbus-cert/tree-sitter-powershell", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "ps1", + maintainers = { "@L2jLiga" }, +} + +list.printf = { + install_info = { + url = "https://github.com/ObserverOfTime/tree-sitter-printf", + files = { "src/parser.c" }, + }, + maintainers = { "@ObserverOfTime" }, +} + +list.prisma = { + install_info = { + url = "https://github.com/victorhqc/tree-sitter-prisma", + files = { "src/parser.c" }, + }, + maintainers = { "@elianiva" }, +} + +list.problog = { + install_info = { + url = "https://github.com/foxyseta/tree-sitter-prolog", + files = { "src/parser.c" }, + location = "grammars/problog", + }, + maintainers = { "@foxyseta" }, +} + +list.prolog = { + install_info = { + url = "https://github.com/foxyseta/tree-sitter-prolog", + files = { "src/parser.c" }, + location = "grammars/prolog", + }, + maintainers = { "@foxyseta" }, +} + +list.promql = { + install_info = { + url = "https://github.com/MichaHoffmann/tree-sitter-promql", + files = { "src/parser.c" }, + experimental = true, + }, + maintainers = { "@MichaHoffmann" }, +} + +list.properties = { + install_info = { + url = "https://github.com/tree-sitter-grammars/tree-sitter-properties", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "jproperties", + maintainers = { "@ObserverOfTime" }, +} + +list.proto = { + install_info = { + url = "https://github.com/treywood/tree-sitter-proto", + files = { "src/parser.c" }, + }, + maintainers = { "@treywood" }, +} + +list.prql = { + install_info = { + url = "https://github.com/PRQL/tree-sitter-prql", + files = { "src/parser.c" }, + }, + maintainers = { "@matthias-Q" }, +} + +list.psv = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-csv", + files = { "src/parser.c" }, + location = "psv", + }, + maintainers = { "@amaanq" }, +} + +list.pug = { + install_info = { + url = "https://github.com/zealot128/tree-sitter-pug", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@zealot128" }, + experimental = true, +} + +list.puppet = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-puppet", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.purescript = { + install_info = { + url = "https://github.com/postsolar/tree-sitter-purescript", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@postsolar" }, +} + +list.pymanifest = { + install_info = { + url = "https://github.com/ObserverOfTime/tree-sitter-pymanifest", + files = { "src/parser.c" }, + }, + maintainers = { "@ObserverOfTime" }, + readme_name = "PyPA manifest", +} + +list.python = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-python", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@stsewd", "@theHamsta" }, +} + +list.ql = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-ql", + files = { "src/parser.c" }, + }, + maintainers = { "@pwntester" }, +} + +list.qmldir = { + install_info = { + url = "https://github.com/Decodetalkers/tree-sitter-qmldir", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.qmljs = { + install_info = { + url = "https://github.com/yuja/tree-sitter-qmljs", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "qml", + maintainers = { "@Decodetalkers" }, +} + +list.query = { + install_info = { + url = "https://github.com/nvim-treesitter/tree-sitter-query", + files = { "src/parser.c" }, + }, + maintainers = { "@steelsojka" }, + readme_name = "Tree-Sitter query language", +} + +list.r = { + install_info = { + url = "https://github.com/r-lib/tree-sitter-r", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@ribru17" }, +} + +list.racket = { + install_info = { + url = "https://github.com/6cdh/tree-sitter-racket", + files = { "src/parser.c", "src/scanner.c" }, + }, +} + +list.ralph = { + install_info = { + url = "https://github.com/alephium/tree-sitter-ralph", + files = { "src/parser.c" }, + }, + maintainers = { "@tdroxler" }, +} + +list.rasi = { + install_info = { + url = "https://github.com/Fymyte/tree-sitter-rasi", + files = { "src/parser.c" }, + }, + maintainers = { "@Fymyte" }, +} + +list.rbs = { + install_info = { + url = "https://github.com/joker1007/tree-sitter-rbs", + files = { "src/parser.c" }, + }, + maintainers = { "@joker1007" }, +} + +list.re2c = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-re2c", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.readline = { + install_info = { + url = "https://github.com/ribru17/tree-sitter-readline", + files = { "src/parser.c" }, + }, + maintainers = { "@ribru17" }, +} + +list.regex = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-regex", + files = { "src/parser.c" }, + }, + maintainers = { "@theHamsta" }, +} + +list.rego = { + install_info = { + url = "https://github.com/FallenAngel97/tree-sitter-rego", + files = { "src/parser.c" }, + }, + maintainers = { "@FallenAngel97" }, +} + +list.requirements = { + install_info = { + url = "https://github.com/ObserverOfTime/tree-sitter-requirements", + files = { "src/parser.c" }, + }, + maintainers = { "@ObserverOfTime" }, + readme_name = "pip requirements", +} + +list.rescript = { + install_info = { + url = "https://github.com/rescript-lang/tree-sitter-rescript", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@ribru17" }, +} + +list.rnoweb = { + install_info = { + url = "https://github.com/bamonroe/tree-sitter-rnoweb", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@bamonroe" }, +} + +list.robot = { + install_info = { + url = "https://github.com/Hubro/tree-sitter-robot", + files = { "src/parser.c" }, + }, + maintainers = { "@Hubro" }, +} + +list.robots = { + install_info = { + url = "https://github.com/opa-oz/tree-sitter-robots-txt", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@opa-oz" }, +} + +list.roc = { + install_info = { + url = "https://github.com/faldor20/tree-sitter-roc", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@nat-418" }, +} + +list.ron = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-ron", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.rst = { + install_info = { + url = "https://github.com/stsewd/tree-sitter-rst", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@stsewd" }, +} + +list.ruby = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-ruby", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@TravonteD" }, +} + +list.rust = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-rust", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.scala = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-scala", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@stevanmilic" }, +} + +list.scfg = { + install_info = { + url = "https://github.com/rockorager/tree-sitter-scfg", + files = { "src/parser.c" }, + requires_generate_from_grammar = true, + }, + maintainers = { "@WhyNotHugo" }, +} + +list.scheme = { + install_info = { + url = "https://github.com/6cdh/tree-sitter-scheme", + files = { "src/parser.c" }, + }, +} + +list.scss = { + install_info = { + url = "https://github.com/serenadeai/tree-sitter-scss", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@elianiva" }, +} + +list.sflog = { + install_info = { + url = "https://github.com/aheber/tree-sitter-sfapex", + files = { "src/parser.c" }, + location = "sflog", + }, + maintainers = { "@aheber", "@xixiaofinland" }, +} + +list.slang = { + install_info = { + url = "https://github.com/theHamsta/tree-sitter-slang", + files = { "src/parser.c", "src/scanner.c" }, + generate_requires_npm = true, + }, + filetype = "shaderslang", + maintainers = { "@theHamsta" }, + experimental = true, +} + +list.slint = { + install_info = { + url = "https://github.com/slint-ui/tree-sitter-slint", + files = { "src/parser.c" }, + }, + maintainers = { "@hunger" }, +} + +list.smali = { + install_info = { + url = "https://github.com/tree-sitter-grammars/tree-sitter-smali", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.snakemake = { + install_info = { + url = "https://github.com/osthomas/tree-sitter-snakemake", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainer = { "@osthomas" }, + experimental = true, +} + +list.smithy = { + install_info = { + url = "https://github.com/indoorvivants/tree-sitter-smithy", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq", "@keynmol" }, +} + +list.solidity = { + install_info = { + url = "https://github.com/JoranHonig/tree-sitter-solidity", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.soql = { + install_info = { + url = "https://github.com/aheber/tree-sitter-sfapex", + files = { "src/parser.c" }, + location = "soql", + }, + maintainers = { "@aheber", "@xixiaofinland" }, +} + +list.sosl = { + install_info = { + url = "https://github.com/aheber/tree-sitter-sfapex", + files = { "src/parser.c" }, + location = "sosl", + }, + maintainers = { "@aheber", "@xixiaofinland" }, +} + +list.sourcepawn = { + install_info = { + url = "https://github.com/nilshelmig/tree-sitter-sourcepawn", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@Sarrus1" }, + tier = 3, +} + +list.sparql = { + install_info = { + url = "https://github.com/GordianDziwis/tree-sitter-sparql", + files = { "src/parser.c" }, + }, + maintainers = { "@GordianDziwis" }, +} + +list.sql = { + install_info = { + url = "https://github.com/derekstride/tree-sitter-sql", + files = { "src/parser.c", "src/scanner.c" }, + branch = "gh-pages", + }, + maintainers = { "@derekstride" }, +} + +list.squirrel = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-squirrel", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.ssh_config = { + install_info = { + url = "https://github.com/ObserverOfTime/tree-sitter-ssh-config", + files = { "src/parser.c" }, + }, + filetype = "sshconfig", + maintainers = { "@ObserverOfTime" }, +} + +list.starlark = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-starlark", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "bzl", + maintainers = { "@amaanq" }, +} + +list.strace = { + install_info = { + url = "https://github.com/sigmaSd/tree-sitter-strace", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.styled = { + install_info = { + url = "https://github.com/mskelton/tree-sitter-styled", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@mskelton" }, +} + +list.supercollider = { + install_info = { + url = "https://github.com/madskjeldgaard/tree-sitter-supercollider", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@madskjeldgaard" }, +} + +list.superhtml = { + install_info = { + url = "https://github.com/kristoff-it/superhtml", + files = { + "src/parser.c", + "src/scanner.c", + }, + location = "tree-sitter-superhtml", + }, + maintainers = { "@rockorager" }, +} + +list.surface = { + install_info = { + url = "https://github.com/connorlay/tree-sitter-surface", + files = { "src/parser.c" }, + }, + filetype = "sface", + maintainers = { "@connorlay" }, +} + +list.svelte = { + install_info = { + url = "https://github.com/tree-sitter-grammars/tree-sitter-svelte", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.swift = { + install_info = { + url = "https://github.com/alex-pinkus/tree-sitter-swift", + files = { "src/parser.c", "src/scanner.c" }, + requires_generate_from_grammar = true, + }, + maintainers = { "@alex-pinkus" }, +} + +list.sxhkdrc = { + install_info = { + url = "https://github.com/RaafatTurki/tree-sitter-sxhkdrc", + files = { "src/parser.c" }, + }, + maintainers = { "@RaafatTurki" }, +} + +list.systemtap = { + install_info = { + url = "https://github.com/ok-ryoko/tree-sitter-systemtap", + files = { "src/parser.c" }, + }, + maintainers = { "@ok-ryoko" }, +} + +list.t32 = { + install_info = { + url = "https://gitlab.com/xasc/tree-sitter-t32.git", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "trace32", + maintainers = { "@xasc" }, +} + +list.tablegen = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-tablegen", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.tact = { + install_info = { + url = "https://github.com/tact-lang/tree-sitter-tact", + files = { "src/parser.c" }, + }, + maintainers = { "@novusnota" }, +} + +list.teal = { + install_info = { + url = "https://github.com/euclidianAce/tree-sitter-teal", + files = { "src/parser.c", "src/scanner.c" }, + requires_generate_from_grammar = true, + }, + maintainers = { "@euclidianAce" }, +} + +list.tcl = { + install_info = { + url = "https://github.com/tree-sitter-grammars/tree-sitter-tcl", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@lewis6991" }, +} + +list.terraform = { + install_info = { + url = "https://github.com/MichaHoffmann/tree-sitter-hcl", + files = { "src/parser.c", "src/scanner.c" }, + location = "dialects/terraform", + }, + maintainers = { "@MichaHoffmann" }, +} + +list.textproto = { + install_info = { + url = "https://github.com/PorterAtGoogle/tree-sitter-textproto", + files = { "src/parser.c" }, + }, + filetype = "pbtxt", + maintainers = { "@Porter" }, +} + +list.thrift = { + install_info = { + url = "https://github.com/duskmoon314/tree-sitter-thrift", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq", "@duskmoon314" }, +} + +list.tiger = { + install_info = { + url = "https://github.com/ambroisie/tree-sitter-tiger", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@ambroisie" }, +} + +list.tlaplus = { + install_info = { + url = "https://github.com/tlaplus-community/tree-sitter-tlaplus", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "tla", + maintainers = { "@ahelwer", "@susliko" }, +} + +list.tmux = { + install_info = { + url = "https://github.com/Freed-Wu/tree-sitter-tmux", + files = { "src/parser.c" }, + }, + maintainers = { "@Freed-Wu" }, +} + +list.todotxt = { + install_info = { + url = "https://github.com/arnarg/tree-sitter-todotxt", + files = { "src/parser.c" }, + }, + maintainers = { "@arnarg" }, + experimental = true, +} + +list.toml = { + install_info = { + url = "https://github.com/tree-sitter-grammars/tree-sitter-toml", + files = { "src/parser.c", "src/scanner.c" }, + generate_requires_npm = true, + }, + maintainers = { "@tk-shirasaka" }, +} + +list.tsv = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-csv", + files = { "src/parser.c" }, + location = "tsv", + }, + maintainers = { "@amaanq" }, +} + +list.tsx = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-typescript", + files = { "src/parser.c", "src/scanner.c" }, + location = "tsx", + generate_requires_npm = true, + }, + filetype = "typescriptreact", + maintainers = { "@steelsojka" }, +} + +list.turtle = { + install_info = { + url = "https://github.com/GordianDziwis/tree-sitter-turtle", + files = { "src/parser.c" }, + }, + maintainers = { "@GordianDziwis" }, +} + +list.twig = { + install_info = { + url = "https://github.com/gbprod/tree-sitter-twig", + files = { "src/parser.c" }, + }, + maintainers = { "@gbprod" }, +} + +list.typescript = { + install_info = { + url = "https://github.com/tree-sitter/tree-sitter-typescript", + files = { "src/parser.c", "src/scanner.c" }, + location = "typescript", + generate_requires_npm = true, + }, + maintainers = { "@steelsojka" }, +} + +list.typespec = { + install_info = { + url = "https://github.com/happenslol/tree-sitter-typespec", + files = { "src/parser.c" }, + }, + maintainers = { "@happenslol" }, +} + +list.typoscript = { + install_info = { + url = "https://github.com/Teddytrombone/tree-sitter-typoscript", + files = { "src/parser.c" }, + }, + maintainers = { "@Teddytrombone" }, +} + +list.typst = { + install_info = { + url = "https://github.com/uben0/tree-sitter-typst", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@uben0", "@RaafatTurki" }, +} + +list.udev = { + install_info = { + url = "https://github.com/ObserverOfTime/tree-sitter-udev", + files = { "src/parser.c" }, + }, + filetype = "udevrules", + maintainers = { "@ObserverOfTime" }, +} + +list.ungrammar = { + install_info = { + url = "https://github.com/Philipp-M/tree-sitter-ungrammar", + files = { "src/parser.c" }, + }, + maintainers = { "@Philipp-M", "@amaanq" }, +} + +list.unison = { + install_info = { + url = "https://github.com/kylegoetz/tree-sitter-unison", + files = { "src/parser.c", "src/scanner.c" }, + requires_generate_from_grammar = true, + }, + maintainers = { "@tapegram" }, +} + +list.usd = { + install_info = { + url = "https://github.com/ColinKennedy/tree-sitter-usd", + files = { "src/parser.c" }, + }, + maintainers = { "@ColinKennedy" }, +} + +list.uxntal = { + install_info = { + url = "https://github.com/amaanq/tree-sitter-uxntal", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "tal", + maintainers = { "@amaanq" }, + readme_name = "uxn tal", +} + +list.v = { + install_info = { + url = "https://github.com/vlang/v-analyzer", + files = { "src/parser.c" }, + location = "tree_sitter_v", + }, + filetype = "vlang", + maintainers = { "@kkharji", "@amaanq" }, +} + +list.vala = { + install_info = { + url = "https://github.com/vala-lang/tree-sitter-vala", + files = { "src/parser.c" }, + }, + maintainers = { "@Prince781" }, +} + +list.vento = { + install_info = { + url = "https://github.com/ventojs/tree-sitter-vento", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "vto", + maintainers = { "@wrapperup", "@oscarotero" }, +} + +list.verilog = { + install_info = { + url = "https://github.com/gmlarumbe/tree-sitter-systemverilog", + files = { "src/parser.c" }, + }, + maintainers = { "@zhangwwpeng" }, +} + +list.vhdl = { + install_info = { + url = "https://github.com/jpt13653903/tree-sitter-vhdl", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@jpt13653903" }, +} + +list.vhs = { + install_info = { + url = "https://github.com/charmbracelet/tree-sitter-vhs", + files = { "src/parser.c" }, + }, + filetype = "tape", + maintainers = { "@caarlos0" }, +} + +list.vim = { + install_info = { + url = "https://github.com/neovim/tree-sitter-vim", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@clason" }, +} + +list.vimdoc = { + install_info = { + url = "https://github.com/neovim/tree-sitter-vimdoc", + files = { "src/parser.c" }, + }, + filetype = "help", + maintainers = { "@clason" }, +} + +list.vrl = { + install_info = { + url = "https://github.com/belltoy/tree-sitter-vrl", + files = { "src/parser.c" }, + }, + maintainers = { "@belltoy" }, +} + +list.vue = { + install_info = { + url = "https://github.com/tree-sitter-grammars/tree-sitter-vue", + files = { "src/parser.c", "src/scanner.c" }, + branch = "main", + }, + maintainers = { "@WhyNotHugo", "@lucario387" }, +} + +list.wgsl = { + install_info = { + url = "https://github.com/szebniok/tree-sitter-wgsl", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@szebniok" }, +} + +list.wgsl_bevy = { + install_info = { + url = "https://github.com/theHamsta/tree-sitter-wgsl-bevy", + files = { "src/parser.c", "src/scanner.c" }, + generate_requires_npm = true, + }, + maintainers = { "@theHamsta" }, +} + +list.wing = { + install_info = { + url = "https://github.com/winglang/tree-sitter-wing", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@gshpychka", "@MarkMcCulloh" }, +} + +list.wit = { + install_info = { + url = "https://github.com/liamwh/tree-sitter-wit", + files = { "src/parser.c" }, + }, + maintainers = { "@liamwh" }, +} + +list.xcompose = { + install_info = { + url = "https://github.com/ObserverOfTime/tree-sitter-xcompose", + files = { "src/parser.c" }, + }, + maintainers = { "@ObserverOfTime" }, +} + +list.xml = { + install_info = { + url = "https://github.com/tree-sitter-grammars/tree-sitter-xml", + files = { "src/parser.c", "src/scanner.c" }, + location = "xml", + }, + maintainers = { "@ObserverOfTime" }, +} + +list.xresources = { + install_info = { + url = "https://github.com/ValdezFOmar/tree-sitter-xresources", + files = { "src/parser.c" }, + }, + filetype = "xdefaults", + maintainers = { "@ValdezFOmar" }, +} + +list.yaml = { + install_info = { + url = "https://github.com/tree-sitter-grammars/tree-sitter-yaml", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.yang = { + install_info = { + url = "https://github.com/Hubro/tree-sitter-yang", + files = { "src/parser.c" }, + }, + maintainers = { "@Hubro" }, +} + +list.yuck = { + install_info = { + url = "https://github.com/Philipp-M/tree-sitter-yuck", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@Philipp-M", "@amaanq" }, +} + +list.zathurarc = { + install_info = { + url = "https://github.com/Freed-Wu/tree-sitter-zathurarc", + files = { "src/parser.c" }, + }, + maintainers = { "@Freed-Wu" }, +} + +list.zig = { + install_info = { + url = "https://github.com/tree-sitter-grammars/tree-sitter-zig", + files = { "src/parser.c" }, + }, + maintainers = { "@amaanq" }, +} + +list.ziggy = { + install_info = { + url = "https://github.com/kristoff-it/ziggy", + files = { "src/parser.c" }, + location = "tree-sitter-ziggy", + }, + maintainers = { "@rockorager" }, +} + +list.ziggy_schema = { + install_info = { + url = "https://github.com/kristoff-it/ziggy", + files = { "src/parser.c" }, + location = "tree-sitter-ziggy-schema", + }, + maintainers = { "@rockorager" }, +} + +list.templ = { + install_info = { + url = "https://github.com/vrischmann/tree-sitter-templ", + files = { "src/parser.c", "src/scanner.c" }, + }, + maintainers = { "@vrischmann" }, +} + +local M = { + list = list, +} + +function M.ft_to_lang(ft) + local result = ts.language.get_lang(ft) + if result then + return result + else + ft = vim.split(ft, ".", { plain = true })[1] + return ts.language.get_lang(ft) or ft + end +end + +-- Get a list of all available parsers +---@return string[] +function M.available_parsers() + local parsers = vim.tbl_keys(M.list) + table.sort(parsers) + if vim.fn.executable "tree-sitter" == 1 and vim.fn.executable "node" == 1 then + return parsers + else + return vim.tbl_filter(function(p) ---@param p string + return not M.list[p].install_info.requires_generate_from_grammar + end, parsers) + end +end + +function M.get_parser_configs() + return M.list +end + +local parser_files + +function M.reset_cache() + parser_files = setmetatable({}, { + __index = function(tbl, key) + rawset(tbl, key, api.nvim_get_runtime_file("parser/" .. key .. ".*", false)) + return rawget(tbl, key) + end, + }) +end + +M.reset_cache() + +function M.has_parser(lang) + lang = lang or M.get_buf_lang(api.nvim_get_current_buf()) + + if not lang or #lang == 0 then + return false + end + -- HACK: nvim internal API + if vim._ts_has_language(lang) then + return true + end + return #parser_files[lang] > 0 +end + +function M.get_parser(bufnr, lang) + bufnr = bufnr or api.nvim_get_current_buf() + lang = lang or M.get_buf_lang(bufnr) + + if M.has_parser(lang) then + return ts.get_parser(bufnr, lang) + end +end + +-- @deprecated This is only kept for legacy purposes. +-- All root nodes should be accounted for. +function M.get_tree_root(bufnr) + bufnr = bufnr or api.nvim_get_current_buf() + return M.get_parser(bufnr):parse()[1]:root() +end + +-- Gets the language of a given buffer +---@param bufnr number? or current buffer +---@return string +function M.get_buf_lang(bufnr) + bufnr = bufnr or api.nvim_get_current_buf() + return M.ft_to_lang(api.nvim_buf_get_option(bufnr, "ft")) +end + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/query.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/query.lua new file mode 100644 index 0000000..4aba9f2 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/query.lua @@ -0,0 +1,453 @@ +local api = vim.api +local ts = require "nvim-treesitter.compat" +local tsrange = require "nvim-treesitter.tsrange" +local utils = require "nvim-treesitter.utils" +local parsers = require "nvim-treesitter.parsers" +local caching = require "nvim-treesitter.caching" + +local M = {} + +local EMPTY_ITER = function() end + +M.built_in_query_groups = { "highlights", "locals", "folds", "indents", "injections" } + +-- Creates a function that checks whether a given query exists +-- for a specific language. +---@param query string +---@return fun(string): boolean +local function get_query_guard(query) + return function(lang) + return M.has_query_files(lang, query) + end +end + +for _, query in ipairs(M.built_in_query_groups) do + M["has_" .. query] = get_query_guard(query) +end + +---@return string[] +function M.available_query_groups() + local query_files = api.nvim_get_runtime_file("queries/*/*.scm", true) + local groups = {} + for _, f in ipairs(query_files) do + groups[vim.fn.fnamemodify(f, ":t:r")] = true + end + local list = {} + for k, _ in pairs(groups) do + table.insert(list, k) + end + return list +end + +do + local query_cache = caching.create_buffer_cache() + + local function update_cached_matches(bufnr, changed_tick, query_group) + query_cache.set(query_group, bufnr, { + tick = changed_tick, + cache = M.collect_group_results(bufnr, query_group) or {}, + }) + end + + ---@param bufnr integer + ---@param query_group string + ---@return any + function M.get_matches(bufnr, query_group) + bufnr = bufnr or api.nvim_get_current_buf() + local cached_local = query_cache.get(query_group, bufnr) + if not cached_local or api.nvim_buf_get_changedtick(bufnr) > cached_local.tick then + update_cached_matches(bufnr, api.nvim_buf_get_changedtick(bufnr), query_group) + end + + return query_cache.get(query_group, bufnr).cache + end +end + +---@param lang string +---@param query_name string +---@return string[] +local function runtime_queries(lang, query_name) + return api.nvim_get_runtime_file(string.format("queries/%s/%s.scm", lang, query_name), true) or {} +end + +---@type table> +local query_files_cache = {} + +---@param lang string +---@param query_name string +---@return boolean +function M.has_query_files(lang, query_name) + if not query_files_cache[lang] then + query_files_cache[lang] = {} + end + if query_files_cache[lang][query_name] == nil then + local files = runtime_queries(lang, query_name) + query_files_cache[lang][query_name] = files and #files > 0 + end + return query_files_cache[lang][query_name] +end + +do + local mt = {} + mt.__index = function(tbl, key) + if rawget(tbl, key) == nil then + rawset(tbl, key, {}) + end + return rawget(tbl, key) + end + + -- cache will auto set the table for each lang if it is nil + ---@type table> + local cache = setmetatable({}, mt) + + -- Same as `vim.treesitter.query` except will return cached values + ---@param lang string + ---@param query_name string + function M.get_query(lang, query_name) + if cache[lang][query_name] == nil then + cache[lang][query_name] = ts.get_query(lang, query_name) + end + + return cache[lang][query_name] + end + + -- Invalidates the query file cache. + -- + -- If lang and query_name is both present, will reload for only the lang and query_name. + -- If only lang is present, will reload all query_names for that lang + -- If none are present, will reload everything + ---@param lang? string + ---@param query_name? string + function M.invalidate_query_cache(lang, query_name) + if lang and query_name then + cache[lang][query_name] = nil + if query_files_cache[lang] then + query_files_cache[lang][query_name] = nil + end + elseif lang and not query_name then + query_files_cache[lang] = nil + for query_name0, _ in pairs(cache[lang]) do + M.invalidate_query_cache(lang, query_name0) + end + elseif not lang and not query_name then + query_files_cache = {} + for lang0, _ in pairs(cache) do + for query_name0, _ in pairs(cache[lang0]) do + M.invalidate_query_cache(lang0, query_name0) + end + end + else + error "Cannot have query_name by itself!" + end + end +end + +-- This function is meant for an autocommand and not to be used. Only use if file is a query file. +---@param fname string +function M.invalidate_query_file(fname) + local fnamemodify = vim.fn.fnamemodify + M.invalidate_query_cache(fnamemodify(fname, ":p:h:t"), fnamemodify(fname, ":t:r")) +end + +---@class QueryInfo +---@field root TSNode +---@field source integer +---@field start integer +---@field stop integer + +---@param bufnr integer +---@param query_name string +---@param root TSNode +---@param root_lang string|nil +---@return Query|nil, QueryInfo|nil +local function prepare_query(bufnr, query_name, root, root_lang) + local buf_lang = parsers.get_buf_lang(bufnr) + + if not buf_lang then + return + end + + local parser = parsers.get_parser(bufnr, buf_lang) + if not parser then + return + end + + if not root then + local first_tree = parser:trees()[1] + + if first_tree then + root = first_tree:root() + end + end + + if not root then + return + end + + local range = { root:range() } + + if not root_lang then + local lang_tree = parser:language_for_range(range) + + if lang_tree then + root_lang = lang_tree:lang() + end + end + + if not root_lang then + return + end + + local query = M.get_query(root_lang, query_name) + if not query then + return + end + + return query, + { + root = root, + source = bufnr, + start = range[1], + -- The end row is exclusive so we need to add 1 to it. + stop = range[3] + 1, + } +end + +-- Given a path (i.e. a List(String)) this functions inserts value at path +---@param object any +---@param path string[] +---@param value any +function M.insert_to_path(object, path, value) + local curr_obj = object + + for index = 1, (#path - 1) do + if curr_obj[path[index]] == nil then + curr_obj[path[index]] = {} + end + + curr_obj = curr_obj[path[index]] + end + + curr_obj[path[#path]] = value +end + +---@param query Query +---@param bufnr integer +---@param start_row integer +---@param end_row integer +function M.iter_prepared_matches(query, qnode, bufnr, start_row, end_row) + -- A function that splits a string on '.' + ---@param to_split string + ---@return string[] + local function split(to_split) + local t = {} + for str in string.gmatch(to_split, "([^.]+)") do + table.insert(t, str) + end + + return t + end + + local matches = query:iter_matches(qnode, bufnr, start_row, end_row, { all = false }) + + local function iterator() + local pattern, match, metadata = matches() + if pattern ~= nil then + local prepared_match = {} + + -- Extract capture names from each match + for id, node in pairs(match) do + local name = query.captures[id] -- name of the capture in the query + if name ~= nil then + local path = split(name .. ".node") + M.insert_to_path(prepared_match, path, node) + local metadata_path = split(name .. ".metadata") + M.insert_to_path(prepared_match, metadata_path, metadata[id]) + end + end + + -- Add some predicates for testing + ---@type string[][] ( TODO: make pred type so this can be pred[]) + local preds = query.info.patterns[pattern] + if preds then + for _, pred in pairs(preds) do + -- functions + if pred[1] == "set!" and type(pred[2]) == "string" then + M.insert_to_path(prepared_match, split(pred[2]), pred[3]) + end + if pred[1] == "make-range!" and type(pred[2]) == "string" and #pred == 4 then + M.insert_to_path( + prepared_match, + split(pred[2] .. ".node"), + tsrange.TSRange.from_nodes(bufnr, match[pred[3]], match[pred[4]]) + ) + end + end + end + + return prepared_match + end + end + return iterator +end + +-- Return all nodes corresponding to a specific capture path (like @definition.var, @reference.type) +-- Works like M.get_references or M.get_scopes except you can choose the capture +-- Can also be a nested capture like @definition.function to get all nodes defining a function. +-- +---@param bufnr integer the buffer +---@param captures string|string[] +---@param query_group string the name of query group (highlights or injections for example) +---@param root TSNode|nil node from where to start the search +---@param lang string|nil the language from where to get the captures. +--- Root nodes can have several languages. +---@return table|nil +function M.get_capture_matches(bufnr, captures, query_group, root, lang) + if type(captures) == "string" then + captures = { captures } + end + local strip_captures = {} ---@type string[] + for i, capture in ipairs(captures) do + if capture:sub(1, 1) ~= "@" then + error 'Captures must start with "@"' + return + end + -- Remove leading "@". + strip_captures[i] = capture:sub(2) + end + + local matches = {} + for match in M.iter_group_results(bufnr, query_group, root, lang) do + for _, capture in ipairs(strip_captures) do + local insert = utils.get_at_path(match, capture) + if insert then + table.insert(matches, insert) + end + end + end + return matches +end + +function M.iter_captures(bufnr, query_name, root, lang) + local query, params = prepare_query(bufnr, query_name, root, lang) + if not query then + return EMPTY_ITER + end + assert(params) + + local iter = query:iter_captures(params.root, params.source, params.start, params.stop) + + local function wrapped_iter() + local id, node, metadata = iter() + if not id then + return + end + + local name = query.captures[id] + if string.sub(name, 1, 1) == "_" then + return wrapped_iter() + end + + return name, node, metadata + end + + return wrapped_iter +end + +---@param bufnr integer +---@param capture_string string +---@param query_group string +---@param filter_predicate fun(match: table): boolean +---@param scoring_function fun(match: table): number +---@param root TSNode +---@return table|unknown +function M.find_best_match(bufnr, capture_string, query_group, filter_predicate, scoring_function, root) + if string.sub(capture_string, 1, 1) == "@" then + --remove leading "@" + capture_string = string.sub(capture_string, 2) + end + + local best ---@type table|nil + local best_score ---@type number + + for maybe_match in M.iter_group_results(bufnr, query_group, root) do + local match = utils.get_at_path(maybe_match, capture_string) + + if match and filter_predicate(match) then + local current_score = scoring_function(match) + if not best then + best = match + best_score = current_score + end + if current_score > best_score then + best = match + best_score = current_score + end + end + end + return best +end + +---Iterates matches from a query file. +---@param bufnr integer the buffer +---@param query_group string the query file to use +---@param root TSNode the root node +---@param root_lang? string the root node lang, if known +function M.iter_group_results(bufnr, query_group, root, root_lang) + local query, params = prepare_query(bufnr, query_group, root, root_lang) + if not query then + return EMPTY_ITER + end + assert(params) + + return M.iter_prepared_matches(query, params.root, params.source, params.start, params.stop) +end + +function M.collect_group_results(bufnr, query_group, root, lang) + local matches = {} + + for prepared_match in M.iter_group_results(bufnr, query_group, root, lang) do + table.insert(matches, prepared_match) + end + + return matches +end + +---@alias CaptureResFn function(string, LanguageTree, LanguageTree): string, string + +-- Same as get_capture_matches except this will recursively get matches for every language in the tree. +---@param bufnr integer The buffer +---@param capture_or_fn string|CaptureResFn The capture to get. If a function is provided then that +--- function will be used to resolve both the capture and query argument. +--- The function can return `nil` to ignore that tree. +---@param query_type string? The query to get the capture from. This is ignored if a function is provided +--- for the capture argument. +---@return table[] +function M.get_capture_matches_recursively(bufnr, capture_or_fn, query_type) + ---@type CaptureResFn + local type_fn + if type(capture_or_fn) == "function" then + type_fn = capture_or_fn + else + type_fn = function(_, _, _) + return capture_or_fn, query_type + end + end + local parser = parsers.get_parser(bufnr) + local matches = {} + + if parser then + parser:for_each_tree(function(tree, lang_tree) + local lang = lang_tree:lang() + local capture, type_ = type_fn(lang, tree, lang_tree) + + if capture then + vim.list_extend(matches, M.get_capture_matches(bufnr, capture, type_, tree:root(), lang) or {}) + end + end) + end + + return matches +end + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/query_predicates.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/query_predicates.lua new file mode 100644 index 0000000..5caaaa8 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/query_predicates.lua @@ -0,0 +1,241 @@ +local query = require "vim.treesitter.query" + +local html_script_type_languages = { + ["importmap"] = "json", + ["module"] = "javascript", + ["application/ecmascript"] = "javascript", + ["text/ecmascript"] = "javascript", +} + +local non_filetype_match_injection_language_aliases = { + ex = "elixir", + pl = "perl", + sh = "bash", + uxn = "uxntal", + ts = "typescript", +} + +-- compatibility shim for breaking change on nightly/0.11 +local opts = vim.fn.has "nvim-0.10" == 1 and { force = true, all = false } or true + +local function get_parser_from_markdown_info_string(injection_alias) + local match = vim.filetype.match { filename = "a." .. injection_alias } + return match or non_filetype_match_injection_language_aliases[injection_alias] or injection_alias +end + +local function error(str) + vim.api.nvim_err_writeln(str) +end + +local function valid_args(name, pred, count, strict_count) + local arg_count = #pred - 1 + + if strict_count then + if arg_count ~= count then + error(string.format("%s must have exactly %d arguments", name, count)) + return false + end + elseif arg_count < count then + error(string.format("%s must have at least %d arguments", name, count)) + return false + end + + return true +end + +---@param match (TSNode|nil)[] +---@param _pattern string +---@param _bufnr integer +---@param pred string[] +---@return boolean|nil +query.add_predicate("nth?", function(match, _pattern, _bufnr, pred) + if not valid_args("nth?", pred, 2, true) then + return + end + + local node = match[pred[2]] ---@type TSNode + local n = tonumber(pred[3]) + if node and node:parent() and node:parent():named_child_count() > n then + return node:parent():named_child(n) == node + end + + return false +end, opts) + +---@param match (TSNode|nil)[] +---@param _pattern string +---@param _bufnr integer +---@param pred string[] +---@return boolean|nil +local function has_ancestor(match, _pattern, _bufnr, pred) + if not valid_args(pred[1], pred, 2) then + return + end + + local node = match[pred[2]] + local ancestor_types = { unpack(pred, 3) } + if not node then + return true + end + + local just_direct_parent = pred[1]:find("has-parent", 1, true) + + node = node:parent() + while node do + if vim.tbl_contains(ancestor_types, node:type()) then + return true + end + if just_direct_parent then + node = nil + else + node = node:parent() + end + end + return false +end + +query.add_predicate("has-ancestor?", has_ancestor, opts) + +query.add_predicate("has-parent?", has_ancestor, opts) + +---@param match (TSNode|nil)[] +---@param _pattern string +---@param bufnr integer +---@param pred string[] +---@return boolean|nil +query.add_predicate("is?", function(match, _pattern, bufnr, pred) + if not valid_args("is?", pred, 2) then + return + end + + -- Avoid circular dependencies + local locals = require "nvim-treesitter.locals" + local node = match[pred[2]] + local types = { unpack(pred, 3) } + + if not node then + return true + end + + local _, _, kind = locals.find_definition(node, bufnr) + + return vim.tbl_contains(types, kind) +end, opts) + +---@param match (TSNode|nil)[] +---@param _pattern string +---@param _bufnr integer +---@param pred string[] +---@return boolean|nil +query.add_predicate("kind-eq?", function(match, _pattern, _bufnr, pred) + if not valid_args(pred[1], pred, 2) then + return + end + + local node = match[pred[2]] + local types = { unpack(pred, 3) } + + if not node then + return true + end + + return vim.tbl_contains(types, node:type()) +end, opts) + +---@param match (TSNode|nil)[] +---@param _ string +---@param bufnr integer +---@param pred string[] +---@return boolean|nil +query.add_directive("set-lang-from-mimetype!", function(match, _, bufnr, pred, metadata) + local capture_id = pred[2] + local node = match[capture_id] + if not node then + return + end + local type_attr_value = vim.treesitter.get_node_text(node, bufnr) + local configured = html_script_type_languages[type_attr_value] + if configured then + metadata["injection.language"] = configured + else + local parts = vim.split(type_attr_value, "/", {}) + metadata["injection.language"] = parts[#parts] + end +end, opts) + +---@param match (TSNode|nil)[] +---@param _ string +---@param bufnr integer +---@param pred string[] +---@return boolean|nil +query.add_directive("set-lang-from-info-string!", function(match, _, bufnr, pred, metadata) + local capture_id = pred[2] + local node = match[capture_id] + if not node then + return + end + local injection_alias = vim.treesitter.get_node_text(node, bufnr):lower() + metadata["injection.language"] = get_parser_from_markdown_info_string(injection_alias) +end, opts) + +-- Just avoid some annoying warnings for this directive +query.add_directive("make-range!", function() end, opts) + +--- transform node text to lower case (e.g., to make @injection.language case insensitive) +--- +---@param match (TSNode|nil)[] +---@param _ string +---@param bufnr integer +---@param pred string[] +---@return boolean|nil +query.add_directive("downcase!", function(match, _, bufnr, pred, metadata) + local id = pred[2] + local node = match[id] + if not node then + return + end + + local text = vim.treesitter.get_node_text(node, bufnr, { metadata = metadata[id] }) or "" + if not metadata[id] then + metadata[id] = {} + end + metadata[id].text = string.lower(text) +end, opts) + +-- Trim blank lines from end of the region +-- Arguments are the captures to trim. +---@param match (TSNode|nil)[] +---@param _ string +---@param bufnr integer +---@param pred string[] +---@param metadata table +query.add_directive("trim!", function(match, _, bufnr, pred, metadata) + for _, id in ipairs { select(2, unpack(pred)) } do + local node = match[id] + local start_row, start_col, end_row, end_col = node:range() + + -- Don't trim if region ends in middle of a line + if end_col ~= 0 then + return + end + + while true do + -- As we only care when end_col == 0, always inspect one line above end_row. + local end_line = vim.api.nvim_buf_get_lines(bufnr, end_row - 1, end_row, true)[1] + + if end_line ~= "" then + break + end + + end_row = end_row - 1 + end + + -- If this produces an invalid range, we just skip it. + if start_row < end_row or (start_row == end_row and start_col <= end_col) then + if not metadata[id] then + metadata[id] = {} + end + metadata[id].range = { start_row, start_col, end_row, end_col } + end + end +end, opts) diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/shell_command_selectors.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/shell_command_selectors.lua new file mode 100644 index 0000000..48f6101 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/shell_command_selectors.lua @@ -0,0 +1,365 @@ +local fn = vim.fn +local utils = require "nvim-treesitter.utils" +local uv = vim.uv or vim.loop + +-- Convert path for cmd.exe on Windows. +-- This is needed when vim.opt.shellslash is in use. +---@param p string +---@return string +local function cmdpath(p) + if vim.opt.shellslash:get() then + local r = p:gsub("/", "\\") + return r + else + return p + end +end + +local M = {} + +-- Returns the mkdir command based on the OS +---@param directory string +---@param cwd string +---@param info_msg string +---@return table +function M.select_mkdir_cmd(directory, cwd, info_msg) + if fn.has "win32" == 1 then + return { + cmd = "cmd", + opts = { + args = { "/C", "mkdir", cmdpath(directory) }, + cwd = cwd, + }, + info = info_msg, + err = "Could not create " .. directory, + } + else + return { + cmd = "mkdir", + opts = { + args = { directory }, + cwd = cwd, + }, + info = info_msg, + err = "Could not create " .. directory, + } + end +end + +-- Returns the remove command based on the OS +---@param file string +---@param info_msg string +---@return table +function M.select_rm_file_cmd(file, info_msg) + if fn.has "win32" == 1 then + return { + cmd = "cmd", + opts = { + args = { "/C", "if", "exist", cmdpath(file), "del", cmdpath(file) }, + }, + info = info_msg, + err = "Could not delete " .. file, + } + else + return { + cmd = "rm", + opts = { + args = { file }, + }, + info = info_msg, + err = "Could not delete " .. file, + } + end +end + +---@param executables string[] +---@return string|nil +function M.select_executable(executables) + return vim.tbl_filter(function(c) ---@param c string + return c ~= vim.NIL and fn.executable(c) == 1 + end, executables)[1] +end + +-- Returns the compiler arguments based on the compiler and OS +---@param repo InstallInfo +---@param compiler string +---@return string[] +function M.select_compiler_args(repo, compiler) + if string.match(compiler, "cl$") or string.match(compiler, "cl.exe$") then + return { + "/Fe:", + "parser.so", + "/Isrc", + repo.files, + "-Os", + "/utf-8", + "/LD", + } + elseif string.match(compiler, "zig$") or string.match(compiler, "zig.exe$") then + return { + "c++", + "-o", + "parser.so", + repo.files, + "-lc", + "-Isrc", + "-shared", + "-Os", + } + else + local args = { + "-o", + "parser.so", + "-I./src", + repo.files, + "-Os", + } + if fn.has "mac" == 1 then + table.insert(args, "-bundle") + else + table.insert(args, "-shared") + end + if + #vim.tbl_filter(function(file) ---@param file string + local ext = vim.fn.fnamemodify(file, ":e") + return ext == "cc" or ext == "cpp" or ext == "cxx" + end, repo.files) > 0 + then + table.insert(args, "-lstdc++") + end + if fn.has "win32" == 0 then + table.insert(args, "-fPIC") + end + return args + end +end + +-- Returns the compile command based on the OS and user options +---@param repo InstallInfo +---@param cc string +---@param compile_location string +---@return Command +function M.select_compile_command(repo, cc, compile_location) + local make = M.select_executable { "gmake", "make" } + if + string.match(cc, "cl$") + or string.match(cc, "cl.exe$") + or not repo.use_makefile + or fn.has "win32" == 1 + or not make + then + return { + cmd = cc, + info = "Compiling...", + err = "Error during compilation", + opts = { + args = require("nvim-treesitter.compat").flatten(M.select_compiler_args(repo, cc)), + cwd = compile_location, + }, + } + else + return { + cmd = make, + info = "Compiling...", + err = "Error during compilation", + opts = { + args = { + "--makefile=" .. utils.join_path(utils.get_package_path(), "scripts", "compile_parsers.makefile"), + "CC=" .. cc, + "CXX_STANDARD=" .. (repo.cxx_standard or "c++14"), + }, + cwd = compile_location, + }, + } + end +end + +-- Returns the remove command based on the OS +---@param cache_folder string +---@param project_name string +---@return Command +function M.select_install_rm_cmd(cache_folder, project_name) + if fn.has "win32" == 1 then + local dir = cache_folder .. "\\" .. project_name + return { + cmd = "cmd", + opts = { + args = { "/C", "if", "exist", cmdpath(dir), "rmdir", "/s", "/q", cmdpath(dir) }, + }, + } + else + return { + cmd = "rm", + opts = { + args = { "-rf", cache_folder .. "/" .. project_name }, + }, + } + end +end + +-- Returns the move command based on the OS +---@param from string +---@param to string +---@param cwd string +---@return Command +function M.select_mv_cmd(from, to, cwd) + if fn.has "win32" == 1 then + return { + cmd = "cmd", + opts = { + args = { "/C", "move", "/Y", cmdpath(from), cmdpath(to) }, + cwd = cwd, + }, + } + else + return { + cmd = "mv", + opts = { + args = { "-f", from, to }, + cwd = cwd, + }, + } + end +end + +---@param repo InstallInfo +---@param project_name string +---@param cache_folder string +---@param revision string|nil +---@param prefer_git boolean +---@return table +function M.select_download_commands(repo, project_name, cache_folder, revision, prefer_git) + local can_use_tar = vim.fn.executable "tar" == 1 and vim.fn.executable "curl" == 1 + local is_github = repo.url:find("github.com", 1, true) + local is_gitlab = repo.url:find("gitlab.com", 1, true) + + revision = revision or repo.branch or "master" + + if can_use_tar and (is_github or is_gitlab) and not prefer_git then + local path_sep = utils.get_path_sep() + local url = repo.url:gsub(".git$", "") + + local folder_rev = revision + if is_github and revision:match "^v%d" then + folder_rev = revision:sub(2) + end + + return { + M.select_install_rm_cmd(cache_folder, project_name .. "-tmp"), + { + cmd = "curl", + info = "Downloading " .. project_name .. "...", + err = "Error during download, please verify your internet connection", + opts = { + args = { + "--silent", + "--show-error", + "-L", -- follow redirects + is_github and url .. "/archive/" .. revision .. ".tar.gz" + or url .. "/-/archive/" .. revision .. "/" .. project_name .. "-" .. revision .. ".tar.gz", + "--output", + project_name .. ".tar.gz", + }, + cwd = cache_folder, + }, + }, + M.select_mkdir_cmd(project_name .. "-tmp", cache_folder, "Creating temporary directory"), + { + cmd = "tar", + info = "Extracting " .. project_name .. "...", + err = "Error during tarball extraction.", + opts = { + args = { + "-xvzf", + project_name .. ".tar.gz", + "-C", + project_name .. "-tmp", + }, + cwd = cache_folder, + }, + }, + M.select_rm_file_cmd(cache_folder .. path_sep .. project_name .. ".tar.gz"), + M.select_mv_cmd( + utils.join_path(project_name .. "-tmp", url:match "[^/]-$" .. "-" .. folder_rev), + project_name, + cache_folder + ), + M.select_install_rm_cmd(cache_folder, project_name .. "-tmp"), + } + else + local git_folder = utils.join_path(cache_folder, project_name) + local clone_error = "Error during download, please verify your internet connection" + + -- Running `git clone` or `git checkout` while running under Git (such as + -- editing a `git commit` message) will likely fail to install parsers + -- (such as 'gitcommit') and can also corrupt the index file of the current + -- Git repository. Check for typical git environment variables and abort if found. + for _, k in pairs { + "GIT_ALTERNATE_OBJECT_DIRECTORIES", + "GIT_CEILING_DIRECTORIES", + "GIT_DIR", + "GIT_INDEX", + "GIT_INDEX_FILE", + "GIT_OBJECT_DIRECTORY", + "GIT_PREFIX", + "GIT_WORK_TREE", + } do + if uv.os_getenv(k) then + vim.api.nvim_err_writeln( + string.format( + "Cannot install %s with git in an active git session. Exit the session and run ':TSInstall %s' manually", + project_name, + project_name + ) + ) + return {} + end + end + + return { + { + cmd = "git", + info = "Downloading " .. project_name .. "...", + err = clone_error, + opts = { + args = { + "clone", + repo.url, + project_name, + "--filter=blob:none", + }, + cwd = cache_folder, + }, + }, + { + cmd = "git", + info = "Checking out locked revision", + err = "Error while checking out revision", + opts = { + args = { + "checkout", + revision, + }, + cwd = git_folder, + }, + }, + } + end +end + +---@param dir string +---@param command string +---@return string command +function M.make_directory_change_for_command(dir, command) + if fn.has "win32" == 1 then + if string.find(vim.o.shell, "cmd") ~= nil then + return string.format("pushd %s & %s & popd", cmdpath(dir), command) + else + return string.format("pushd %s ; %s ; popd", cmdpath(dir), command) + end + else + return string.format("cd %s;\n%s", dir, command) + end +end + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/statusline.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/statusline.lua new file mode 100644 index 0000000..68ba41a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/statusline.lua @@ -0,0 +1,53 @@ +local parsers = require "nvim-treesitter.parsers" +local ts_utils = require "nvim-treesitter.ts_utils" + +local M = {} + +-- Trim spaces and opening brackets from end +local transform_line = function(line) + return line:gsub("%s*[%[%(%{]*%s*$", "") +end + +function M.statusline(opts) + if not parsers.has_parser() then + return + end + local options = opts or {} + if type(opts) == "number" then + options = { indicator_size = opts } + end + local bufnr = options.bufnr or 0 + local indicator_size = options.indicator_size or 100 + local type_patterns = options.type_patterns or { "class", "function", "method" } + local transform_fn = options.transform_fn or transform_line + local separator = options.separator or " -> " + local allow_duplicates = options.allow_duplicates or false + + local current_node = ts_utils.get_node_at_cursor() + if not current_node then + return "" + end + + local lines = {} + local expr = current_node + + while expr do + local line = ts_utils._get_line_for_node(expr, type_patterns, transform_fn, bufnr) + if line ~= "" then + if allow_duplicates or not vim.tbl_contains(lines, line) then + table.insert(lines, 1, line) + end + end + expr = expr:parent() + end + + local text = table.concat(lines, separator) + local text_len = #text + if text_len > indicator_size then + return "..." .. text:sub(text_len - indicator_size, text_len) + end + + return text +end + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua new file mode 100644 index 0000000..f2ee7f5 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua @@ -0,0 +1,468 @@ +local api = vim.api + +local parsers = require "nvim-treesitter.parsers" +local utils = require "nvim-treesitter.utils" +local ts = vim.treesitter + +local M = {} + +local function get_node_text(node, bufnr) + bufnr = bufnr or api.nvim_get_current_buf() + if not node then + return {} + end + + -- We have to remember that end_col is end-exclusive + local start_row, start_col, end_row, end_col = ts.get_node_range(node) + + if start_row ~= end_row then + local lines = api.nvim_buf_get_lines(bufnr, start_row, end_row + 1, false) + if next(lines) == nil then + return {} + end + lines[1] = string.sub(lines[1], start_col + 1) + -- end_row might be just after the last line. In this case the last line is not truncated. + if #lines == end_row - start_row + 1 then + lines[#lines] = string.sub(lines[#lines], 1, end_col) + end + return lines + else + local line = api.nvim_buf_get_lines(bufnr, start_row, start_row + 1, false)[1] + -- If line is nil then the line is empty + return line and { string.sub(line, start_col + 1, end_col) } or {} + end +end + +---@private +---@param node TSNode +---@param type_patterns string[] +---@param transform_fn fun(line: string): string +---@param bufnr integer +---@return string +function M._get_line_for_node(node, type_patterns, transform_fn, bufnr) + local node_type = node:type() + local is_valid = false + for _, rgx in ipairs(type_patterns) do + if node_type:find(rgx) then + is_valid = true + break + end + end + if not is_valid then + return "" + end + local line = transform_fn(vim.trim(get_node_text(node, bufnr)[1] or ""), node) + -- Escape % to avoid statusline to evaluate content as expression + return line:gsub("%%", "%%%%") +end + +-- Gets the actual text content of a node +-- @deprecated Use vim.treesitter.get_node_text +-- @param node the node to get the text from +-- @param bufnr the buffer containing the node +-- @return list of lines of text of the node +function M.get_node_text(node, bufnr) + vim.notify_once( + "nvim-treesitter.ts_utils.get_node_text is deprecated: use vim.treesitter.get_node_text", + vim.log.levels.WARN + ) + return get_node_text(node, bufnr) +end + +-- Determines whether a node is the parent of another +-- @param dest the possible parent +-- @param source the possible child node +function M.is_parent(dest, source) + if not (dest and source) then + return false + end + + local current = source + while current ~= nil do + if current == dest then + return true + end + + current = current:parent() + end + + return false +end + +-- Get next node with same parent +---@param node TSNode +---@param allow_switch_parents? boolean allow switching parents if last node +---@param allow_next_parent? boolean allow next parent if last node and next parent without children +function M.get_next_node(node, allow_switch_parents, allow_next_parent) + local destination_node ---@type TSNode + local parent = node:parent() + + if not parent then + return + end + local found_pos = 0 + for i = 0, parent:named_child_count() - 1, 1 do + if parent:named_child(i) == node then + found_pos = i + break + end + end + if parent:named_child_count() > found_pos + 1 then + destination_node = parent:named_child(found_pos + 1) + elseif allow_switch_parents then + local next_node = M.get_next_node(node:parent()) + if next_node and next_node:named_child_count() > 0 then + destination_node = next_node:named_child(0) + elseif next_node and allow_next_parent then + destination_node = next_node + end + end + + return destination_node +end + +-- Get previous node with same parent +---@param node TSNode +---@param allow_switch_parents? boolean allow switching parents if first node +---@param allow_previous_parent? boolean allow previous parent if first node and previous parent without children +function M.get_previous_node(node, allow_switch_parents, allow_previous_parent) + local destination_node ---@type TSNode + local parent = node:parent() + if not parent then + return + end + + local found_pos = 0 + for i = 0, parent:named_child_count() - 1, 1 do + if parent:named_child(i) == node then + found_pos = i + break + end + end + if 0 < found_pos then + destination_node = parent:named_child(found_pos - 1) + elseif allow_switch_parents then + local previous_node = M.get_previous_node(node:parent()) + if previous_node and previous_node:named_child_count() > 0 then + destination_node = previous_node:named_child(previous_node:named_child_count() - 1) + elseif previous_node and allow_previous_parent then + destination_node = previous_node + end + end + return destination_node +end + +function M.get_named_children(node) + local nodes = {} ---@type TSNode[] + for i = 0, node:named_child_count() - 1, 1 do + nodes[i + 1] = node:named_child(i) + end + return nodes +end + +function M.get_node_at_cursor(winnr, ignore_injected_langs) + winnr = winnr or 0 + local cursor = api.nvim_win_get_cursor(winnr) + local cursor_range = { cursor[1] - 1, cursor[2] } + + local buf = vim.api.nvim_win_get_buf(winnr) + local root_lang_tree = parsers.get_parser(buf) + if not root_lang_tree then + return + end + + local root ---@type TSNode|nil + if ignore_injected_langs then + for _, tree in pairs(root_lang_tree:trees()) do + local tree_root = tree:root() + if tree_root and ts.is_in_node_range(tree_root, cursor_range[1], cursor_range[2]) then + root = tree_root + break + end + end + else + root = M.get_root_for_position(cursor_range[1], cursor_range[2], root_lang_tree) + end + + if not root then + return + end + + return root:named_descendant_for_range(cursor_range[1], cursor_range[2], cursor_range[1], cursor_range[2]) +end + +function M.get_root_for_position(line, col, root_lang_tree) + if not root_lang_tree then + if not parsers.has_parser() then + return + end + + root_lang_tree = parsers.get_parser() + end + + local lang_tree = root_lang_tree:language_for_range { line, col, line, col } + + for _, tree in pairs(lang_tree:trees()) do + local root = tree:root() + + if root and ts.is_in_node_range(root, line, col) then + return root, tree, lang_tree + end + end + + -- This isn't a likely scenario, since the position must belong to a tree somewhere. + return nil, nil, lang_tree +end + +---comment +---@param node TSNode +---@return TSNode result +function M.get_root_for_node(node) + local parent = node + local result = node + + while parent ~= nil do + result = parent + parent = result:parent() + end + + return result +end + +function M.highlight_node(node, buf, hl_namespace, hl_group) + if not node then + return + end + M.highlight_range({ node:range() }, buf, hl_namespace, hl_group) +end + +-- Get a compatible vim range (1 index based) from a TS node range. +-- +-- TS nodes start with 0 and the end col is ending exclusive. +-- They also treat a EOF/EOL char as a char ending in the first +-- col of the next row. +---comment +---@param range integer[] +---@param buf integer|nil +---@return integer, integer, integer, integer +function M.get_vim_range(range, buf) + ---@type integer, integer, integer, integer + local srow, scol, erow, ecol = unpack(range) + srow = srow + 1 + scol = scol + 1 + erow = erow + 1 + + if ecol == 0 then + -- Use the value of the last col of the previous row instead. + erow = erow - 1 + if not buf or buf == 0 then + ecol = vim.fn.col { erow, "$" } - 1 + else + ecol = #api.nvim_buf_get_lines(buf, erow - 1, erow, false)[1] + end + ecol = math.max(ecol, 1) + end + return srow, scol, erow, ecol +end + +function M.highlight_range(range, buf, hl_namespace, hl_group) + ---@type integer, integer, integer, integer + local start_row, start_col, end_row, end_col = unpack(range) + ---@diagnostic disable-next-line: missing-parameter + vim.highlight.range(buf, hl_namespace, hl_group, { start_row, start_col }, { end_row, end_col }) +end + +-- Set visual selection to node +-- @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) + local start_row, start_col, end_row, end_col = M.get_vim_range({ ts.get_node_range(node) }, buf) + + local v_table = { charwise = "v", linewise = "V", blockwise = "" } + 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 + + -- enter visual mode if normal or operator-pending (no) mode + -- Why? According to https://learnvimscriptthehardway.stevelosh.com/chapters/15.html + -- If your operator-pending mapping ends with some text visually selected, Vim will operate on that text. + -- Otherwise, Vim will operate on the text between the original cursor position and the new position. + local mode = api.nvim_get_mode() + if mode.mode ~= selection_mode then + -- 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) + api.nvim_cmd({ cmd = "normal", bang = true, args = { selection_mode } }, {}) + end + + api.nvim_win_set_cursor(0, { start_row, start_col - 1 }) + vim.cmd "normal! o" + api.nvim_win_set_cursor(0, { end_row, end_col - 1 }) +end + +-- Byte length of node range +---@param node TSNode +---@return number +function M.node_length(node) + local _, _, start_byte = node:start() + local _, _, end_byte = node:end_() + return end_byte - start_byte +end + +---@deprecated Use `vim.treesitter.is_in_node_range()` instead +function M.is_in_node_range(node, line, col) + vim.notify_once( + "nvim-treesitter.ts_utils.is_in_node_range is deprecated: use vim.treesitter.is_in_node_range", + vim.log.levels.WARN + ) + return ts.is_in_node_range(node, line, col) +end + +---@deprecated Use `vim.treesitter.get_node_range()` instead +function M.get_node_range(node_or_range) + vim.notify_once( + "nvim-treesitter.ts_utils.get_node_range is deprecated: use vim.treesitter.get_node_range", + vim.log.levels.WARN + ) + return ts.get_node_range(node_or_range) +end + +---@param node TSNode +---@return table +function M.node_to_lsp_range(node) + local start_line, start_col, end_line, end_col = ts.get_node_range(node) + local rtn = {} + rtn.start = { line = start_line, character = start_col } + rtn["end"] = { line = end_line, character = end_col } + return rtn +end + +-- Memoizes a function based on the buffer tick of the provided bufnr. +-- The cache entry is cleared when the buffer is detached to avoid memory leaks. +-- The options argument is a table with two optional values: +-- - bufnr: extracts a bufnr from the given arguments. +-- - key: extracts the cache key from the given arguments. +---@param fn function the fn to memoize, taking the buffer as first argument +---@param options? {bufnr: integer?, key: string|fun(...): string?} the memoization options +---@return function: a memoized function +function M.memoize_by_buf_tick(fn, options) + options = options or {} + + ---@type table + local cache = setmetatable({}, { __mode = "kv" }) + local bufnr_fn = utils.to_func(options.bufnr or utils.identity) + local key_fn = utils.to_func(options.key or utils.identity) + + return function(...) + local bufnr = bufnr_fn(...) + local key = key_fn(...) + local tick = api.nvim_buf_get_changedtick(bufnr) + + if cache[key] then + if cache[key].last_tick == tick then + return cache[key].result + end + else + local function detach_handler() + cache[key] = nil + end + + -- Clean up logic only! + api.nvim_buf_attach(bufnr, false, { + on_detach = detach_handler, + on_reload = detach_handler, + }) + end + + cache[key] = { + result = fn(...), + last_tick = tick, + } + + return cache[key].result + end +end + +function M.swap_nodes(node_or_range1, node_or_range2, bufnr, cursor_to_second) + if not node_or_range1 or not node_or_range2 then + return + end + local range1 = M.node_to_lsp_range(node_or_range1) + local range2 = M.node_to_lsp_range(node_or_range2) + + local text1 = get_node_text(node_or_range1, bufnr) + local text2 = get_node_text(node_or_range2, bufnr) + + local edit1 = { range = range1, newText = table.concat(text2, "\n") } + local edit2 = { range = range2, newText = table.concat(text1, "\n") } + bufnr = bufnr == 0 and vim.api.nvim_get_current_buf() or bufnr + vim.lsp.util.apply_text_edits({ edit1, edit2 }, bufnr, "utf-8") + + if cursor_to_second then + utils.set_jump() + + local char_delta = 0 + local line_delta = 0 + if + range1["end"].line < range2.start.line + or (range1["end"].line == range2.start.line and range1["end"].character <= range2.start.character) + then + line_delta = #text2 - #text1 + end + + if range1["end"].line == range2.start.line and range1["end"].character <= range2.start.character then + if line_delta ~= 0 then + --- why? + --correction_after_line_change = -range2.start.character + --text_now_before_range2 = #(text2[#text2]) + --space_between_ranges = range2.start.character - range1["end"].character + --char_delta = correction_after_line_change + text_now_before_range2 + space_between_ranges + --- Equivalent to: + char_delta = #text2[#text2] - range1["end"].character + + -- add range1.start.character if last line of range1 (now text2) does not start at 0 + if range1.start.line == range2.start.line + line_delta then + char_delta = char_delta + range1.start.character + end + else + char_delta = #text2[#text2] - #text1[#text1] + end + end + + api.nvim_win_set_cursor( + api.nvim_get_current_win(), + { range2.start.line + 1 + line_delta, range2.start.character + char_delta } + ) + end +end + +function M.goto_node(node, goto_end, avoid_set_jump) + if not node then + return + end + if not avoid_set_jump then + utils.set_jump() + end + local range = { M.get_vim_range { node:range() } } + ---@type table + local position + if not goto_end then + position = { range[1], range[2] } + else + position = { range[3], range[4] } + end + + -- Enter visual mode if we are in operator pending mode + -- If we don't do this, it will miss the last character. + local mode = vim.api.nvim_get_mode() + if mode.mode == "no" then + vim.cmd "normal! v" + end + + -- Position is 1, 0 indexed. + api.nvim_win_set_cursor(0, { position[1], position[2] - 1 }) +end + +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/tsrange.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/tsrange.lua new file mode 100644 index 0000000..d41585c --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/tsrange.lua @@ -0,0 +1,154 @@ +local M = {} +local TSRange = {} +TSRange.__index = TSRange + +local api = vim.api +local ts_utils = require "nvim-treesitter.ts_utils" +local parsers = require "nvim-treesitter.parsers" + +local function get_byte_offset(buf, row, col) + return api.nvim_buf_get_offset(buf, row) + vim.fn.byteidx(api.nvim_buf_get_lines(buf, row, row + 1, false)[1], col) +end + +function TSRange.new(buf, start_row, start_col, end_row, end_col) + return setmetatable({ + start_pos = { start_row, start_col, get_byte_offset(buf, start_row, start_col) }, + end_pos = { end_row, end_col, get_byte_offset(buf, end_row, end_col) }, + buf = buf, + [1] = start_row, + [2] = start_col, + [3] = end_row, + [4] = end_col, + }, TSRange) +end + +function TSRange.from_nodes(buf, start_node, end_node) + TSRange.__index = TSRange + local start_pos = start_node and { start_node:start() } or { end_node:start() } + local end_pos = end_node and { end_node:end_() } or { start_node:end_() } + return setmetatable({ + start_pos = { start_pos[1], start_pos[2], start_pos[3] }, + end_pos = { end_pos[1], end_pos[2], end_pos[3] }, + buf = buf, + [1] = start_pos[1], + [2] = start_pos[2], + [3] = end_pos[1], + [4] = end_pos[2], + }, TSRange) +end + +function TSRange.from_table(buf, range) + return setmetatable({ + start_pos = { range[1], range[2], get_byte_offset(buf, range[1], range[2]) }, + end_pos = { range[3], range[4], get_byte_offset(buf, range[3], range[4]) }, + buf = buf, + [1] = range[1], + [2] = range[2], + [3] = range[3], + [4] = range[4], + }, TSRange) +end + +function TSRange:parent() + local root_lang_tree = parsers.get_parser(self.buf) + local root = ts_utils.get_root_for_position(self[1], self[2], root_lang_tree) + + return root + and root:named_descendant_for_range(self.start_pos[1], self.start_pos[2], self.end_pos[1], self.end_pos[2]) + or nil +end + +function TSRange:field() end + +function TSRange:child_count() + return #self:collect_children() +end + +function TSRange:named_child_count() + return #self:collect_children(function(c) + return c:named() + end) +end + +function TSRange:iter_children() + local raw_iterator = self:parent().iter_children() + return function() + while true do + local node = raw_iterator() + if not node then + return + end + local _, _, start_byte = node:start() + local _, _, end_byte = node:end_() + if start_byte >= self.start_pos[3] and end_byte <= self.end_pos[3] then + return node + end + end + end +end + +function TSRange:collect_children(filter_fun) + local children = {} + for _, c in self:iter_children() do + if not filter_fun or filter_fun(c) then + table.insert(children, c) + end + end + return children +end + +function TSRange:child(index) + return self:collect_children()[index + 1] +end + +function TSRange:named_child(index) + return self:collect_children(function(c) + return c.named() + end)[index + 1] +end + +function TSRange:start() + return unpack(self.start_pos) +end + +function TSRange:end_() + return unpack(self.end_pos) +end + +function TSRange:range() + return self.start_pos[1], self.start_pos[2], self.end_pos[1], self.end_pos[2] +end + +function TSRange:type() + return "nvim-treesitter-range" +end + +function TSRange:symbol() + return -1 +end + +function TSRange:named() + return false +end + +function TSRange:missing() + return false +end + +function TSRange:has_error() + return #self:collect_children(function(c) + return c:has_error() + end) > 0 and true or false +end + +function TSRange:sexpr() + return table.concat( + vim.tbl_map(function(c) + return c:sexpr() + end, self:collect_children()), + " " + ) +end + +M.TSRange = TSRange +return M diff --git a/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/utils.lua b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/utils.lua new file mode 100644 index 0000000..d920f4a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/lua/nvim-treesitter/utils.lua @@ -0,0 +1,237 @@ +local api = vim.api +local fn = vim.fn +local luv = vim.loop + +local M = {} + +-- Wrapper around vim.notify with common options set. +---@param msg string +---@param log_level number|nil +---@param opts table|nil +function M.notify(msg, log_level, opts) + local default_opts = { title = "nvim-treesitter" } + vim.notify(msg, log_level, vim.tbl_extend("force", default_opts, opts or {})) +end + +-- Returns the system-specific path separator. +---@return string +function M.get_path_sep() + 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 +-- can't be nil. Example: +-- +--[[ + print(M.generate_join(" ")("foo", "bar")) +--]] +--prints "foo bar" +---@param separator string +---@return fun(...: string): string +function M.generate_join(separator) + return function(...) + return table.concat({ ... }, separator) + end +end + +M.join_path = M.generate_join(M.get_path_sep()) + +M.join_space = M.generate_join " " + +---@class Command +---@field run function +---@field f_args string +---@field args string + +-- Define user defined vim command which calls nvim-treesitter module function +-- - If module name is 'mod', it should be defined in hierarchy 'nvim-treesitter.mod' +-- - A table with name 'commands' should be defined in 'mod' which needs to be passed as +-- the commands param of this function +-- +---@param mod string Name of the module that resides in the hierarchy - nvim-treesitter.module +---@param commands table Command list for the module +--- - {command_name} Name of the vim user defined command, Keys: +--- - {run}: (function) callback function that needs to be executed +--- - {f_args}: (string, default ) +--- - type of arguments that needs to be passed to the vim command +--- - {args}: (string, optional) +--- - vim command attributes +--- +---* @example +--- If module is nvim-treesitter.custom_mod +---
+---  M.commands = {
+---      custom_command = {
+---          run = M.module_function,
+---          f_args = "",
+---          args = {
+---              "-range"
+---          }
+---      }
+---  }
+---
+---  utils.setup_commands("custom_mod", require("nvim-treesitter.custom_mod").commands)
+---  
+--- +--- Will generate command : +---
+---  command! -range custom_command \
+---      lua require'nvim-treesitter.custom_mod'.commands.custom_command['run']()
+---  
+function M.setup_commands(mod, commands) + for command_name, def in pairs(commands) do + local f_args = def.f_args or "" + local call_fn = + string.format("lua require'nvim-treesitter.%s'.commands.%s['run'](%s)", mod, command_name, f_args) + local parts = require("nvim-treesitter.compat").flatten { + "command!", + "-bar", + def.args, + command_name, + call_fn, + } + api.nvim_command(table.concat(parts, " ")) + end +end + +---@param dir string +---@param create_err string +---@param writeable_err string +---@return string|nil, string|nil +function M.create_or_reuse_writable_dir(dir, create_err, writeable_err) + create_err = create_err or M.join_space("Could not create dir '", dir, "': ") + writeable_err = writeable_err or M.join_space("Invalid rights, '", dir, "' should be read/write") + -- Try creating and using parser_dir if it doesn't exist + if not luv.fs_stat(dir) then + local ok, error = pcall(vim.fn.mkdir, dir, "p", "0755") + if not ok then + return nil, M.join_space(create_err, error) + end + + return dir + end + + -- parser_dir exists, use it if it's read/write + if luv.fs_access(dir, "RW") then + return dir + end + + -- parser_dir exists but isn't read/write, give up + return nil, M.join_space(writeable_err, dir, "'") +end + +function M.get_package_path() + -- Path to this source file, removing the leading '@' + local source = string.sub(debug.getinfo(1, "S").source, 2) + + -- Path to the package root + return fn.fnamemodify(source, ":p:h:h:h") +end + +function M.get_cache_dir() + local cache_dir = fn.stdpath "data" + + if luv.fs_access(cache_dir, "RW") then + return cache_dir + elseif luv.fs_access("/tmp", "RW") then + return "/tmp" + end + + return nil, M.join_space("Invalid cache rights,", fn.stdpath "data", "or /tmp should be read/write") +end + +-- Returns $XDG_DATA_HOME/nvim/site, but could use any directory that is in +-- runtimepath +function M.get_site_dir() + return M.join_path(fn.stdpath "data", "site") +end + +-- Gets a property at path +---@param tbl table the table to access +---@param path string the '.' separated path +---@return table|nil result the value at path or nil +function M.get_at_path(tbl, path) + if path == "" then + return tbl + end + + local segments = vim.split(path, ".", true) + ---@type table[]|table + local result = tbl + + for _, segment in ipairs(segments) do + if type(result) == "table" then + ---@type table + -- TODO: figure out the actual type of tbl + result = result[segment] + end + end + + return result +end + +function M.set_jump() + vim.cmd "normal! m'" +end + +-- Filters a list based on the given predicate +---@param tbl any[] The list to filter +---@param predicate fun(v:any, i:number):boolean The predicate to filter with +function M.filter(tbl, predicate) + local result = {} + + for i, v in ipairs(tbl) do + if predicate(v, i) then + table.insert(result, v) + end + end + + return result +end + +-- Returns a list of all values from the first list +-- that are not present in the second list. +---@param tbl1 any[] The first table +---@param tbl2 any[] The second table +---@return table +function M.difference(tbl1, tbl2) + return M.filter(tbl1, function(v) + return not vim.tbl_contains(tbl2, v) + end) +end + +function M.identity(a) + return a +end + +-- Returns a function returning the given value +---@param a any +---@return fun():any +function M.constant(a) + return function() + return a + end +end + +-- Returns a function that returns the given value if it is a function, +-- otherwise returns a function that returns the given value. +---@param a any +---@return fun(...):any +function M.to_func(a) + return type(a) == "function" and a or M.constant(a) +end + +---@return string|nil +function M.ts_cli_version() + if fn.executable "tree-sitter" == 1 then + local handle = io.popen "tree-sitter -V" + if not handle then + return + end + local result = handle:read "*a" + handle:close() + return vim.split(result, "\n")[1]:match "[^tree%psitter ].*" + end +end + +return M diff --git a/pack/ant/start/nvim-treesitter/parser-info/.gitignore b/pack/ant/start/nvim-treesitter/parser-info/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/parser-info/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/pack/ant/start/nvim-treesitter/parser/.gitignore b/pack/ant/start/nvim-treesitter/parser/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/parser/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/pack/ant/start/nvim-treesitter/plugin/nvim-treesitter.lua b/pack/ant/start/nvim-treesitter/plugin/nvim-treesitter.lua new file mode 100644 index 0000000..4ea3925 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/plugin/nvim-treesitter.lua @@ -0,0 +1,34 @@ +-- Last Change: 2022 Apr 16 + +if vim.g.loaded_nvim_treesitter then + return +end +vim.g.loaded_nvim_treesitter = true + +-- setup modules +require("nvim-treesitter").setup() + +local api = vim.api + +-- define autocommands +local augroup = api.nvim_create_augroup("NvimTreesitter", {}) + +api.nvim_create_autocmd("Filetype", { + pattern = "query", + group = augroup, + callback = function() + api.nvim_clear_autocmds { + group = augroup, + event = "BufWritePost", + } + api.nvim_create_autocmd("BufWritePost", { + group = augroup, + buffer = 0, + callback = function(opts) + require("nvim-treesitter.query").invalidate_query_file(opts.file) + end, + desc = "Invalidate query file", + }) + end, + desc = "Reload query", +}) diff --git a/pack/ant/start/nvim-treesitter/queries/ada/folds.scm b/pack/ant/start/nvim-treesitter/queries/ada/folds.scm new file mode 100644 index 0000000..8e3defa --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/ada/folds.scm @@ -0,0 +1,13 @@ +; Support for folding in Ada +; za toggles folding a package, subprogram, if statement or loop +[ + (package_declaration) + (generic_package_declaration) + (package_body) + (subprogram_body) + (block_statement) + (if_statement) + (loop_statement) + (gnatprep_declarative_if_statement) + (gnatprep_if_statement) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/ada/highlights.scm b/pack/ant/start/nvim-treesitter/queries/ada/highlights.scm new file mode 100644 index 0000000..0d42b70 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/ada/highlights.scm @@ -0,0 +1,286 @@ +; 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" + "body" + "declare" + "delay" + "delta" + "digits" + "do" + "end" + "entry" + "exit" + "generic" + "interface" + "is" + "limited" + "mod" + "new" + "null" + "of" + "others" + "out" + "overriding" + "package" + "pragma" + "private" + "protected" + "range" + "separate" + "subtype" + "synchronized" + "tagged" + "task" + "terminate" + "type" + "until" + "when" +] @keyword + +"record" @keyword.type + +[ + "aliased" + "constant" + "renames" +] @keyword.modifier + +[ + "with" + "use" +] @keyword.import + +[ + "function" + "procedure" +] @keyword.function + +[ + "and" + "in" + "not" + "or" + "xor" +] @keyword.operator + +[ + "while" + "loop" + "for" + "parallel" + "reverse" + "some" +] @keyword.repeat + +"return" @keyword.return + +[ + "case" + "if" + "else" + "then" + "elsif" + "select" +] @keyword.conditional + +[ + "exception" + "raise" +] @keyword.exception + +(comment) @comment @spell + +(string_literal) @string + +(character_literal) @string + +(numeric_literal) @number + +; Highlight the name of subprograms +(procedure_specification + name: (_) @function) + +(function_specification + name: (_) @function) + +(package_declaration + name: (_) @function) + +(package_body + name: (_) @function) + +(generic_instantiation + name: (_) @function) + +(entry_declaration + . + (identifier) @function) + +; Some keywords should take different categories depending on the context +(use_clause + "use" @keyword.import + "type" @keyword.import) + +(with_clause + "private" @keyword.import) + +(with_clause + "limited" @keyword.import) + +(use_clause + (_) @module) + +(with_clause + (_) @module) + +(loop_statement + "end" @keyword.repeat) + +(if_statement + "end" @keyword.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" @keyword.exception) + +(gnatprep_declarative_if_statement) @keyword.directive + +(gnatprep_if_statement) @keyword.directive + +(gnatprep_identifier) @keyword.directive + +(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 +;) +((comment) @comment.documentation + . + [ + (entry_declaration) + (subprogram_declaration) + (parameter_specification) + ]) + +(compilation_unit + . + (comment) @comment.documentation) + +(component_list + (component_declaration) + . + (comment) @comment.documentation) + +(enumeration_type_definition + (identifier) + . + (comment) @comment.documentation) diff --git a/pack/ant/start/nvim-treesitter/queries/ada/injections.scm b/pack/ant/start/nvim-treesitter/queries/ada/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/ada/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/ada/locals.scm b/pack/ant/start/nvim-treesitter/queries/ada/locals.scm new file mode 100644 index 0000000..bdfc38b --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/ada/locals.scm @@ -0,0 +1,91 @@ +; 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) @local.scope + +(package_declaration) @local.scope + +(package_body) @local.scope + +(subprogram_declaration) @local.scope + +(subprogram_body) @local.scope + +(block_statement) @local.scope + +(with_clause + (identifier) @local.definition.import) + +(procedure_specification + name: (_) @local.definition.function) + +(function_specification + name: (_) @local.definition.function) + +(package_declaration + name: (_) @local.definition.var) + +(package_body + name: (_) @local.definition.var) + +(generic_instantiation + . + name: (_) @local.definition.var) + +(component_declaration + . + (identifier) @local.definition.var) + +(exception_declaration + . + (identifier) @local.definition.var) + +(formal_object_declaration + . + (identifier) @local.definition.var) + +(object_declaration + . + (identifier) @local.definition.var) + +(parameter_specification + . + (identifier) @local.definition.var) + +(full_type_declaration + . + (identifier) @local.definition.type) + +(private_type_declaration + . + (identifier) @local.definition.type) + +(private_extension_declaration + . + (identifier) @local.definition.type) + +(incomplete_type_declaration + . + (identifier) @local.definition.type) + +(protected_type_declaration + . + (identifier) @local.definition.type) + +(formal_complete_type_declaration + . + (identifier) @local.definition.type) + +(formal_incomplete_type_declaration + . + (identifier) @local.definition.type) + +(task_type_declaration + . + (identifier) @local.definition.type) + +(subtype_declaration + . + (identifier) @local.definition.type) + +(identifier) @local.reference diff --git a/pack/ant/start/nvim-treesitter/queries/agda/folds.scm b/pack/ant/start/nvim-treesitter/queries/agda/folds.scm new file mode 100644 index 0000000..5e1051f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/agda/folds.scm @@ -0,0 +1,4 @@ +[ + (record) + (module) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/agda/highlights.scm b/pack/ant/start/nvim-treesitter/queries/agda/highlights.scm new file mode 100644 index 0000000..4626a8c --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/agda/highlights.scm @@ -0,0 +1,87 @@ +; Constants +(integer) @number + +; Variables and Symbols +(typed_binding + (atom + (qid) @variable)) + +(untyped_binding) @variable + +(typed_binding + (expr) @type) + +(id) @function + +(bid) @function + +(function_name + (atom + (qid) @function)) + +(field_name) @function + +[ + (data_name) + (record_name) +] @constructor + +; Set +(SetN) @type.builtin + +(expr + . + (atom) @function) + +((atom) @boolean + (#any-of? @boolean "true" "false" "True" "False")) + +; Imports and Module Declarations +"import" @keyword.import + +(module_name) @module + +; Pragmas and comments +(pragma) @keyword.directive + +(comment) @comment @spell + +; Keywords +[ + "where" + "data" + "rewrite" + "postulate" + "public" + "private" + "tactic" + "Prop" + "quote" + "renaming" + "open" + "in" + "hiding" + "constructor" + "abstract" + "let" + "field" + "mutual" + "module" + "infix" + "infixl" + "infixr" +] @keyword + +"record" @keyword.type + +;(expr +; f_name: (atom) @function) +; Brackets +[ + "(" + ")" + "{" + "}" +] @punctuation.bracket + +"=" @operator diff --git a/pack/ant/start/nvim-treesitter/queries/agda/injections.scm b/pack/ant/start/nvim-treesitter/queries/agda/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/agda/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/angular/folds.scm b/pack/ant/start/nvim-treesitter/queries/angular/folds.scm new file mode 100644 index 0000000..1f2129c --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/angular/folds.scm @@ -0,0 +1 @@ +; inherits: html diff --git a/pack/ant/start/nvim-treesitter/queries/angular/highlights.scm b/pack/ant/start/nvim-treesitter/queries/angular/highlights.scm new file mode 100644 index 0000000..3783933 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/angular/highlights.scm @@ -0,0 +1,146 @@ +; inherits: html_tags + +(identifier) @variable + +(pipe_operator) @operator + +[ + (string) + (static_member_expression) +] @string + +(number) @number + +(pipe_call + name: (identifier) @function) + +(pipe_call + arguments: (pipe_arguments + (identifier) @variable.parameter)) + +(structural_directive + "*" @keyword + (identifier) @keyword) + +(attribute + (attribute_name) @variable.member + (#lua-match? @variable.member "#.*")) + +(binding_name + (identifier) @keyword) + +(event_binding + (binding_name + (identifier) @keyword)) + +(event_binding + "\"" @punctuation.delimiter) + +(property_binding + "\"" @punctuation.delimiter) + +(structural_assignment + operator: (identifier) @keyword) + +(member_expression + property: (identifier) @property) + +(call_expression + function: (identifier) @function) + +(call_expression + function: ((identifier) @function.builtin + (#eq? @function.builtin "$any"))) + +(pair + key: ((identifier) @variable.builtin + (#eq? @variable.builtin "$implicit"))) + +[ + (control_keyword) + (special_keyword) +] @keyword + +((control_keyword) @keyword.repeat + (#any-of? @keyword.repeat "for" "empty")) + +((control_keyword) @keyword.conditional + (#any-of? @keyword.conditional "if" "else" "switch" "case" "default")) + +((control_keyword) @keyword.coroutine + (#any-of? @keyword.coroutine "defer" "placeholder" "loading")) + +((control_keyword) @keyword.exception + (#eq? @keyword.exception "error")) + +((identifier) @boolean + (#any-of? @boolean "true" "false")) + +((identifier) @variable.builtin + (#any-of? @variable.builtin "this" "$event")) + +((identifier) @constant.builtin + (#eq? @constant.builtin "null")) + +[ + (ternary_operator) + (conditional_operator) +] @keyword.conditional.ternary + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "@" +] @punctuation.bracket + +(two_way_binding + [ + "[(" + ")]" + ] @punctuation.bracket) + +[ + "{{" + "}}" +] @punctuation.special + +[ + ";" + "." + "," + "?." +] @punctuation.delimiter + +(nullish_coalescing_expression + (coalescing_operator) @operator) + +(concatenation_expression + "+" @operator) + +(icu_clause) @keyword.operator + +(icu_category) @keyword.conditional + +(binary_expression + [ + "-" + "&&" + "+" + "<" + "<=" + "=" + "==" + "===" + "!=" + "!==" + ">" + ">=" + "*" + "/" + "||" + "%" + ] @operator) diff --git a/pack/ant/start/nvim-treesitter/queries/angular/indents.scm b/pack/ant/start/nvim-treesitter/queries/angular/indents.scm new file mode 100644 index 0000000..2f46aa5 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/angular/indents.scm @@ -0,0 +1,16 @@ +; inherits: html_tags + +[ + (statement_block) + (switch_statement) +] @indent.begin + +(statement_block + "{" @indent.branch) + +(statement_block + "}" @indent.end) + +"}" @indent.branch + +"}" @indent.end diff --git a/pack/ant/start/nvim-treesitter/queries/angular/injections.scm b/pack/ant/start/nvim-treesitter/queries/angular/injections.scm new file mode 100644 index 0000000..448e942 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/angular/injections.scm @@ -0,0 +1 @@ +; inherits: html_tags diff --git a/pack/ant/start/nvim-treesitter/queries/angular/locals.scm b/pack/ant/start/nvim-treesitter/queries/angular/locals.scm new file mode 100644 index 0000000..1f2129c --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/angular/locals.scm @@ -0,0 +1 @@ +; inherits: html diff --git a/pack/ant/start/nvim-treesitter/queries/apex/folds.scm b/pack/ant/start/nvim-treesitter/queries/apex/folds.scm new file mode 100644 index 0000000..fdfc2a1 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/apex/folds.scm @@ -0,0 +1,6 @@ +[ + (class_body) + (constructor_declaration) + (argument_list) + (annotation_argument_list) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/apex/highlights.scm b/pack/ant/start/nvim-treesitter/queries/apex/highlights.scm new file mode 100644 index 0000000..82ce234 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/apex/highlights.scm @@ -0,0 +1,257 @@ +; inherits: soql + +; Apex + SOQL +[ + "[" + "]" + "{" + "}" + "(" + ")" +] @punctuation.bracket + +[ + "," + "." + ":" + "?" + ";" +] @punctuation.delimiter + +; Default general color definition +(identifier) @variable + +(type_identifier) @type + +; Methods +(method_declaration + name: (identifier) @function.method) + +(method_invocation + name: (identifier) @function.method.call) + +(super) @function.builtin + +; Annotations +(annotation + name: (identifier) @attribute) + +; Types +(interface_declaration + name: (identifier) @type) + +(class_declaration + name: (identifier) @type) + +(class_declaration + (superclass) @type) + +(enum_declaration + name: (identifier) @type) + +(enum_constant + name: (identifier) @constant) + +(type_arguments + "<" @punctuation.delimiter) + +(type_arguments + ">" @punctuation.delimiter) + +(field_access + object: (identifier) @type) + +(field_access + field: (identifier) @property) + +((scoped_identifier + scope: (identifier) @type) + (#match? @type "^[A-Z]")) + +((method_invocation + object: (identifier) @type) + (#match? @type "^[A-Z]")) + +(method_declaration + (formal_parameters + (formal_parameter + name: (identifier) @variable.parameter))) + +(constructor_declaration + name: (identifier) @constructor) + +(dml_type) @function.builtin + +(assignment_operator) @operator + +(update_operator) @operator + +(trigger_declaration + name: (identifier) @type + object: (identifier) @type + (trigger_event) @keyword + ("," + (trigger_event) @keyword)*) + +[ + "@" + "=" + "!=" + "<=" + ">=" +] @operator + +(binary_expression + operator: [ + ">" + "<" + "==" + "===" + "!==" + "&&" + "||" + "+" + "-" + "*" + "/" + "&" + "|" + "^" + "%" + "<<" + ">>" + ">>>" + ] @operator) + +(unary_expression + operator: [ + "+" + "-" + "!" + "~" + ]) @operator + +"=>" @operator + +[ + (boolean_type) + (void_type) +] @type.builtin + +; Fields +(field_declaration + declarator: (variable_declarator + name: (identifier) @variable.member)) + +(field_access + field: (identifier) @variable.member) + +; Variables +(variable_declarator + (identifier) @property) + +(field_declaration + (modifiers + (modifier + [ + (final) + (static) + ]) + (modifier + [ + (final) + (static) + ])) + (variable_declarator + name: (identifier) @constant)) + +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z0-9_]+$")) ; SCREAM SNAKE CASE + +(this) @variable.builtin + +; Literals +[ + (int) + (decimal) + (currency_literal) +] @number + +(string_literal) @string + +[ + (line_comment) + (block_comment) +] @comment + +(null_literal) @constant.builtin + +; ;; Keywords +[ + "abstract" + "final" + "private" + "protected" + "public" + "static" +] @keyword.modifier + +[ + "if" + "else" + "switch" +] @keyword.conditional + +[ + "for" + "while" + "do" + "break" +] @keyword.repeat + +"return" @keyword.return + +[ + "throw" + "finally" + "try" + "catch" +] @keyword.exception + +"new" @keyword.operator + +[ + (abstract) + (all_rows_clause) + "continue" + "extends" + (final) + "get" + (global) + "implements" + "instanceof" + "on" + (override) + (private) + (protected) + (public) + "set" + (static) + (testMethod) + (webservice) + (transient) + "trigger" + (virtual) + "when" + (with_sharing) + (without_sharing) + (inherited_sharing) +] @keyword + +[ + "interface" + "class" + "enum" +] @keyword.type + +"System.runAs" @function.builtin diff --git a/pack/ant/start/nvim-treesitter/queries/apex/injections.scm b/pack/ant/start/nvim-treesitter/queries/apex/injections.scm new file mode 100644 index 0000000..3cd6aac --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/apex/injections.scm @@ -0,0 +1,5 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/apex/locals.scm b/pack/ant/start/nvim-treesitter/queries/apex/locals.scm new file mode 100644 index 0000000..2457752 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/apex/locals.scm @@ -0,0 +1,70 @@ +; declarations +(class_declaration) @local.scope + +(method_declaration) @local.scope + +(constructor_declaration) @local.scope + +(enum_declaration) @local.scope + +(enhanced_for_statement) @local.scope + +; if/else +(if_statement) @local.scope + +(if_statement + consequence: (_) @local.scope) ; if body in case there are no braces + +(if_statement + alternative: (_) @local.scope) ; else body in case there are no braces + +; try/catch +(try_statement) @local.scope ; covers try+catch, individual try and catch are covered by (block) + +(catch_clause) @local.scope ; needed because `Exception` variable + +; loops +(for_statement) @local.scope + +(for_statement ; "for" body in case there are no braces + body: (_) @local.scope) + +(do_statement + body: (_) @local.scope) + +(while_statement + body: (_) @local.scope) + +; Functions +(constructor_declaration) @local.scope + +(method_declaration) @local.scope + +; definitions +(enum_declaration + name: (identifier) @local.definition.enum) + +(method_declaration + name: (identifier) @local.definition.method) + +(local_variable_declaration + declarator: (variable_declarator + name: (identifier) @local.definition.var)) + +(enhanced_for_statement + name: (identifier) @local.definition.var) + +(formal_parameter + name: (identifier) @local.definition.parameter) + +(catch_formal_parameter + name: (identifier) @local.definition.parameter) + +(field_declaration + declarator: (variable_declarator + name: (identifier) @local.definition.field)) + +; REFERENCES +(identifier) @local.reference + +(type_identifier) @local.reference diff --git a/pack/ant/start/nvim-treesitter/queries/arduino/folds.scm b/pack/ant/start/nvim-treesitter/queries/arduino/folds.scm new file mode 100644 index 0000000..b617fdc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/arduino/folds.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/pack/ant/start/nvim-treesitter/queries/arduino/highlights.scm b/pack/ant/start/nvim-treesitter/queries/arduino/highlights.scm new file mode 100644 index 0000000..e6bf147 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/arduino/highlights.scm @@ -0,0 +1,53 @@ +; inherits: cpp + +((identifier) @function.builtin + (#any-of? @function.builtin + ; Digital I/O + "digitalRead" "digitalWrite" "pinMode" + ; Analog I/O + "analogRead" "analogReference" "analogWrite" + ; Zero, Due & MKR Family + "analogReadResolution" "analogWriteResolution" + ; Advanced I/O + "noTone" "pulseIn" "pulseInLong" "shiftIn" "shiftOut" "tone" + ; Time + "delay" "delayMicroseconds" "micros" "millis" + ; Math + "abs" "constrain" "map" "max" "min" "pow" "sq" "sqrt" + ; Trigonometry + "cos" "sin" "tan" + ; Characters + "isAlpha" "isAlphaNumeric" "isAscii" "isControl" "isDigit" "isGraph" "isHexadecimalDigit" + "isLowerCase" "isPrintable" "isPunct" "isSpace" "isUpperCase" "isWhitespace" + ; Random Numbers + "random" "randomSeed" + ; Bits and Bytes + "bit" "bitClear" "bitRead" "bitSet" "bitWrite" "highByte" "lowByte" + ; External Interrupts + "attachInterrupt" "detachInterrupt" + ; Interrupts + "interrupts" "noInterrupts")) + +((identifier) @type.builtin + (#any-of? @type.builtin "Serial" "SPI" "Stream" "Wire" "Keyboard" "Mouse" "String")) + +((identifier) @constant.builtin + (#any-of? @constant.builtin "HIGH" "LOW" "INPUT" "OUTPUT" "INPUT_PULLUP" "LED_BUILTIN")) + +(function_definition + (function_declarator + declarator: (identifier) @function.builtin) + (#any-of? @function.builtin "loop" "setup")) + +(call_expression + function: (primitive_type) @function.builtin) + +(call_expression + function: (identifier) @constructor + (#any-of? @constructor "SPISettings" "String")) + +(declaration + (type_identifier) @type.builtin + (function_declarator + declarator: (identifier) @constructor) + (#eq? @type.builtin "SPISettings")) diff --git a/pack/ant/start/nvim-treesitter/queries/arduino/indents.scm b/pack/ant/start/nvim-treesitter/queries/arduino/indents.scm new file mode 100644 index 0000000..b617fdc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/arduino/indents.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/pack/ant/start/nvim-treesitter/queries/arduino/injections.scm b/pack/ant/start/nvim-treesitter/queries/arduino/injections.scm new file mode 100644 index 0000000..b637d9b --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/arduino/injections.scm @@ -0,0 +1,5 @@ +((preproc_arg) @injection.content + (#set! injection.language "arduino")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/arduino/locals.scm b/pack/ant/start/nvim-treesitter/queries/arduino/locals.scm new file mode 100644 index 0000000..b617fdc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/arduino/locals.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/pack/ant/start/nvim-treesitter/queries/asm/highlights.scm b/pack/ant/start/nvim-treesitter/queries/asm/highlights.scm new file mode 100644 index 0000000..eccf9c9 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/asm/highlights.scm @@ -0,0 +1,66 @@ +; General +(label + [ + (ident) + (word) + ] @label) + +(reg) @variable.builtin + +(meta + kind: (_) @function.builtin) + +(instruction + kind: (_) @function.builtin) + +(const + name: (word) @constant) + +; Comments +[ + (line_comment) + (block_comment) +] @comment @spell + +; Literals +(int) @number + +(float) @number.float + +(string) @string + +; Keywords +[ + "byte" + "word" + "dword" + "qword" + "ptr" + "rel" + "label" + "const" +] @keyword + +; Operators & Punctuation +[ + "+" + "-" + "*" + "/" + "%" + "|" + "^" + "&" +] @operator + +[ + "(" + ")" + "[" + "]" +] @punctuation.bracket + +[ + "," + ":" +] @punctuation.delimiter diff --git a/pack/ant/start/nvim-treesitter/queries/asm/injections.scm b/pack/ant/start/nvim-treesitter/queries/asm/injections.scm new file mode 100644 index 0000000..3cd6aac --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/asm/injections.scm @@ -0,0 +1,5 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/astro/folds.scm b/pack/ant/start/nvim-treesitter/queries/astro/folds.scm new file mode 100644 index 0000000..1f2129c --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/astro/folds.scm @@ -0,0 +1 @@ +; inherits: html diff --git a/pack/ant/start/nvim-treesitter/queries/astro/highlights.scm b/pack/ant/start/nvim-treesitter/queries/astro/highlights.scm new file mode 100644 index 0000000..e4baf53 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/astro/highlights.scm @@ -0,0 +1,25 @@ +; inherits: html_tags + +(doctype) @constant + +"" + "<=" + ">=" + "==" + "!=" + "~" + "!~" + "in" + "&&" + "||" + ] @operator) + +(unary_exp + [ + "!" + "+" + "-" + ] @operator) + +(assignment_exp + [ + "=" + "+=" + "-=" + "*=" + "/=" + "%=" + "^=" + ] @operator) + +(ternary_exp + [ + "?" + ":" + ] @keyword.conditional.ternary) + +(update_exp + [ + "++" + "--" + ] @operator) + +(redirected_io_statement + [ + ">" + ">>" + ] @operator) + +(piped_io_statement + [ + "|" + "|&" + ] @operator) + +(piped_io_exp + [ + "|" + "|&" + ] @operator) + +(field_ref + "$" @punctuation.delimiter) + +(regex + "/" @punctuation.delimiter) + +(regex_constant + "@" @punctuation.delimiter) + +[ + ";" + "," +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket diff --git a/pack/ant/start/nvim-treesitter/queries/awk/injections.scm b/pack/ant/start/nvim-treesitter/queries/awk/injections.scm new file mode 100644 index 0000000..3e67da2 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/awk/injections.scm @@ -0,0 +1,17 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((regex) @injection.content + (#set! injection.language "regex")) + +((print_statement + (exp_list + . + (string) @injection.content)) + (#set! injection.language "printf")) + +((printf_statement + (exp_list + . + (string) @injection.content)) + (#set! injection.language "printf")) diff --git a/pack/ant/start/nvim-treesitter/queries/bash/folds.scm b/pack/ant/start/nvim-treesitter/queries/bash/folds.scm new file mode 100644 index 0000000..766dbe5 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bash/folds.scm @@ -0,0 +1,9 @@ +[ + (function_definition) + (if_statement) + (case_statement) + (for_statement) + (while_statement) + (c_style_for_statement) + (heredoc_redirect) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/bash/highlights.scm b/pack/ant/start/nvim-treesitter/queries/bash/highlights.scm new file mode 100644 index 0000000..0e192bb --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bash/highlights.scm @@ -0,0 +1,239 @@ +[ + "(" + ")" + "{" + "}" + "[" + "]" + "[[" + "]]" + "((" + "))" +] @punctuation.bracket + +[ + ";" + ";;" + ";&" + ";;&" + "&" +] @punctuation.delimiter + +[ + ">" + ">>" + "<" + "<<" + "&&" + "|" + "|&" + "||" + "=" + "+=" + "=~" + "==" + "!=" + "&>" + "&>>" + "<&" + ">&" + ">|" + "<&-" + ">&-" + "<<-" + "<<<" + ".." + "!" +] @operator + +; Do *not* spell check strings since they typically have some sort of +; interpolation in them, or, are typically used for things like filenames, URLs, +; flags and file content. +[ + (string) + (raw_string) + (ansi_c_string) + (heredoc_body) +] @string + +[ + (heredoc_start) + (heredoc_end) +] @label + +(variable_assignment + (word) @string) + +(command + argument: "$" @string) ; bare dollar + +(concatenation + (word) @string) + +[ + "if" + "then" + "else" + "elif" + "fi" + "case" + "in" + "esac" +] @keyword.conditional + +[ + "for" + "do" + "done" + "select" + "until" + "while" +] @keyword.repeat + +[ + "declare" + "typeset" + "readonly" + "local" + "unset" + "unsetenv" +] @keyword + +"export" @keyword.import + +"function" @keyword.function + +(special_variable_name) @constant + +; trap -l +((word) @constant.builtin + (#any-of? @constant.builtin + "SIGHUP" "SIGINT" "SIGQUIT" "SIGILL" "SIGTRAP" "SIGABRT" "SIGBUS" "SIGFPE" "SIGKILL" "SIGUSR1" + "SIGSEGV" "SIGUSR2" "SIGPIPE" "SIGALRM" "SIGTERM" "SIGSTKFLT" "SIGCHLD" "SIGCONT" "SIGSTOP" + "SIGTSTP" "SIGTTIN" "SIGTTOU" "SIGURG" "SIGXCPU" "SIGXFSZ" "SIGVTALRM" "SIGPROF" "SIGWINCH" + "SIGIO" "SIGPWR" "SIGSYS" "SIGRTMIN" "SIGRTMIN+1" "SIGRTMIN+2" "SIGRTMIN+3" "SIGRTMIN+4" + "SIGRTMIN+5" "SIGRTMIN+6" "SIGRTMIN+7" "SIGRTMIN+8" "SIGRTMIN+9" "SIGRTMIN+10" "SIGRTMIN+11" + "SIGRTMIN+12" "SIGRTMIN+13" "SIGRTMIN+14" "SIGRTMIN+15" "SIGRTMAX-14" "SIGRTMAX-13" + "SIGRTMAX-12" "SIGRTMAX-11" "SIGRTMAX-10" "SIGRTMAX-9" "SIGRTMAX-8" "SIGRTMAX-7" "SIGRTMAX-6" + "SIGRTMAX-5" "SIGRTMAX-4" "SIGRTMAX-3" "SIGRTMAX-2" "SIGRTMAX-1" "SIGRTMAX")) + +((word) @boolean + (#any-of? @boolean "true" "false")) + +(comment) @comment @spell + +(test_operator) @operator + +(command_substitution + "$(" @punctuation.special + ")" @punctuation.special) + +(process_substitution + [ + "<(" + ">(" + ] @punctuation.special + ")" @punctuation.special) + +(arithmetic_expansion + [ + "$((" + "((" + ] @punctuation.special + "))" @punctuation.special) + +(arithmetic_expansion + "," @punctuation.delimiter) + +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +(binary_expression + operator: _ @operator) + +(unary_expression + operator: _ @operator) + +(postfix_expression + operator: _ @operator) + +(function_definition + name: (word) @function) + +(command_name + (word) @function.call) + +(command_name + (word) @function.builtin + (#any-of? @function.builtin + "alias" "bg" "bind" "break" "builtin" "caller" "cd" "command" "compgen" "complete" "compopt" + "continue" "coproc" "dirs" "disown" "echo" "enable" "eval" "exec" "exit" "fc" "fg" "getopts" + "hash" "help" "history" "jobs" "kill" "let" "logout" "mapfile" "popd" "printf" "pushd" "pwd" + "read" "readarray" "return" "set" "shift" "shopt" "source" "suspend" "test" "time" "times" + "trap" "type" "typeset" "ulimit" "umask" "unalias" "wait")) + +(command + argument: [ + (word) @variable.parameter + (concatenation + (word) @variable.parameter) + ]) + +(declaration_command + (word) @variable.parameter) + +(unset_command + (word) @variable.parameter) + +(number) @number + +((word) @number + (#lua-match? @number "^[0-9]+$")) + +(file_redirect + destination: (word) @variable.parameter) + +(file_descriptor) @operator + +(simple_expansion + "$" @punctuation.special) @none + +(expansion + "${" @punctuation.special + "}" @punctuation.special) @none + +(expansion + operator: _ @punctuation.special) + +(expansion + "@" + . + operator: _ @character.special) + +((expansion + (subscript + index: (word) @character.special)) + (#any-of? @character.special "@" "*")) + +"``" @punctuation.special + +(variable_name) @variable + +((variable_name) @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + +(case_item + value: (word) @variable.parameter) + +[ + (regex) + (extglob_pattern) +] @string.regexp + +((program + . + (comment) @keyword.directive @nospell) + (#lua-match? @keyword.directive "^#!/")) diff --git a/pack/ant/start/nvim-treesitter/queries/bash/injections.scm b/pack/ant/start/nvim-treesitter/queries/bash/injections.scm new file mode 100644 index 0000000..3286308 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bash/injections.scm @@ -0,0 +1,79 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((regex) @injection.content + (#set! injection.language "regex")) + +((heredoc_redirect + (heredoc_body) @injection.content + (heredoc_end) @injection.language) + (#downcase! @injection.language)) + +; printf 'format' +((command + name: (command_name) @_command + . + argument: [ + (string + (string_content) @injection.content) + (concatenation + (string + (string_content) @injection.content)) + (raw_string) @injection.content + (concatenation + (raw_string) @injection.content) + ]) + (#eq? @_command "printf") + (#set! injection.language "printf")) + +; printf -v var 'format' +((command + name: (command_name) @_command + argument: (word) @_arg + . + (_) + . + argument: [ + (string + (string_content) @injection.content) + (concatenation + (string + (string_content) @injection.content)) + (raw_string) @injection.content + (concatenation + (raw_string) @injection.content) + ]) + (#eq? @_command "printf") + (#eq? @_arg "-v") + (#set! injection.language "printf")) + +; printf -- 'format' +((command + name: (command_name) @_command + argument: (word) @_arg + . + argument: [ + (string + (string_content) @injection.content) + (concatenation + (string + (string_content) @injection.content)) + (raw_string) @injection.content + (concatenation + (raw_string) @injection.content) + ]) + (#eq? @_command "printf") + (#eq? @_arg "--") + (#set! injection.language "printf")) + +((command + name: (command_name) @_command + . + argument: [ + (string) + (raw_string) + ] @injection.content) + (#eq? @_command "bind") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "readline")) diff --git a/pack/ant/start/nvim-treesitter/queries/bash/locals.scm b/pack/ant/start/nvim-treesitter/queries/bash/locals.scm new file mode 100644 index 0000000..347f51f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bash/locals.scm @@ -0,0 +1,14 @@ +; Scopes +(function_definition) @local.scope + +; Definitions +(variable_assignment + name: (variable_name) @local.definition.var) + +(function_definition + name: (word) @local.definition.function) + +; References +(variable_name) @local.reference + +(word) @local.reference diff --git a/pack/ant/start/nvim-treesitter/queries/bass/folds.scm b/pack/ant/start/nvim-treesitter/queries/bass/folds.scm new file mode 100644 index 0000000..d99e0c1 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bass/folds.scm @@ -0,0 +1,5 @@ +[ + (list) + (scope) + (cons) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/bass/highlights.scm b/pack/ant/start/nvim-treesitter/queries/bass/highlights.scm new file mode 100644 index 0000000..f84993a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bass/highlights.scm @@ -0,0 +1,126 @@ +; Variables +(list + (symbol) @variable) + +(cons + (symbol) @variable) + +(scope + (symbol) @variable) + +(symbind + (symbol) @variable) + +; Constants +((symbol) @constant + (#lua-match? @constant "^_*[A-Z][A-Z0-9_]*$")) + +; Functions +(list + . + (symbol) @function) + +; Namespaces +(symbind + (symbol) @module + . + (keyword)) + +; Includes +((symbol) @keyword.import + (#any-of? @keyword.import "use" "import" "load")) + +; Keywords +((symbol) @keyword + (#any-of? @keyword "do" "doc")) + +; Special Functions +; Keywords construct a symbol +(keyword) @constructor + +((list + . + (symbol) @keyword.function + . + (symbol) @function + (symbol)? @variable.parameter) + (#any-of? @keyword.function "def" "defop" "defn" "fn")) + +((cons + . + (symbol) @keyword.function + . + (symbol) @function + (symbol)? @variable.parameter) + (#any-of? @keyword.function "def" "defop" "defn" "fn")) + +((symbol) @function.builtin + (#any-of? @function.builtin + "dump" "mkfs" "json" "log" "error" "now" "cons" "wrap" "unwrap" "eval" "make-scope" "bind" + "meta" "with-meta" "null?" "ignore?" "boolean?" "number?" "string?" "symbol?" "scope?" "sink?" + "source?" "list?" "pair?" "applicative?" "operative?" "combiner?" "path?" "empty?" "thunk?" "+" + "*" "quot" "-" "max" "min" "=" ">" ">=" "<" "<=" "list->source" "across" "emit" "next" + "reduce-kv" "assoc" "symbol->string" "string->symbol" "str" "substring" "trim" "scope->list" + "string->fs-path" "string->cmd-path" "string->dir" "subpath" "path-name" "path-stem" + "with-image" "with-dir" "with-args" "with-cmd" "with-stdin" "with-env" "with-insecure" + "with-label" "with-port" "with-tls" "with-mount" "thunk-cmd" "thunk-args" "resolve" "start" + "addr" "wait" "read" "cache-dir" "binds?" "recall-memo" "store-memo" "mask" "list" "list*" + "first" "rest" "length" "second" "third" "map" "map-pairs" "foldr" "foldl" "append" "filter" + "conj" "list->scope" "merge" "apply" "id" "always" "vals" "keys" "memo" "succeeds?" "run" "last" + "take" "take-all" "insecure!" "from" "cd" "wrap-cmd" "mkfile" "path-base" "not")) + +((symbol) @function.macro + (#any-of? @function.macro + "op" "current-scope" "quote" "let" "provide" "module" "or" "and" "curryfn" "for" "$" "linux")) + +; Conditionals +((symbol) @keyword.conditional + (#any-of? @keyword.conditional "if" "case" "cond" "when")) + +; Repeats +((symbol) @keyword.repeat + (#any-of? @keyword.repeat "each")) + +; Operators +((symbol) @operator + (#any-of? @operator "&" "*" "+" "-" "<" "<=" "=" ">" ">=")) + +; Punctuation +[ + "(" + ")" +] @punctuation.bracket + +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +((symbol) @punctuation.delimiter + (#eq? @punctuation.delimiter "->")) + +; Literals +(string) @string + +(escape_sequence) @string.escape + +(path) @string.special.url + +(number) @number + +(boolean) @boolean + +[ + (ignore) + (null) +] @constant.builtin + +"^" @character.special + +; Comments +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/bass/indents.scm b/pack/ant/start/nvim-treesitter/queries/bass/indents.scm new file mode 100644 index 0000000..27b976f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bass/indents.scm @@ -0,0 +1,31 @@ +[ + (list) + (scope) + (cons) +] @indent.begin + +[ + ")" + "}" + "]" +] @indent.end + +[ + "(" + ")" +] @indent.branch + +[ + "{" + "}" +] @indent.branch + +[ + "[" + "]" +] @indent.branch + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/pack/ant/start/nvim-treesitter/queries/bass/injections.scm b/pack/ant/start/nvim-treesitter/queries/bass/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bass/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/bass/locals.scm b/pack/ant/start/nvim-treesitter/queries/bass/locals.scm new file mode 100644 index 0000000..daed7e5 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bass/locals.scm @@ -0,0 +1,26 @@ +; Scopes +[ + (list) + (scope) + (cons) +] @local.scope + +; References +(symbol) @local.reference + +; Definitions +((list + . + (symbol) @_fnkw + . + (symbol) @local.definition.function + (symbol)? @local.definition.parameter) + (#any-of? @_fnkw "def" "defop" "defn" "fn")) + +((cons + . + (symbol) @_fnkw + . + (symbol) @local.definition.function + (symbol)? @local.definition.parameter) + (#any-of? @_fnkw "def" "defop" "defn" "fn")) diff --git a/pack/ant/start/nvim-treesitter/queries/beancount/folds.scm b/pack/ant/start/nvim-treesitter/queries/beancount/folds.scm new file mode 100644 index 0000000..9f1b6cb --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/beancount/folds.scm @@ -0,0 +1,4 @@ +[ + (transaction) + (section) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/beancount/highlights.scm b/pack/ant/start/nvim-treesitter/queries/beancount/highlights.scm new file mode 100644 index 0000000..1e23d28 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/beancount/highlights.scm @@ -0,0 +1,57 @@ +(date) @variable.member + +(txn) @attribute + +(account) @type + +(amount) @number + +(incomplete_amount) @number + +(compound_amount) @number + +(amount_tolerance) @number + +(currency) @property + +(key) @label + +(string) @string + +(narration) @string @spell + +(payee) @string @spell + +(tag) @constant + +(link) @constant + +[ + (minus) + (plus) + (slash) + (asterisk) +] @operator + +(comment) @comment @spell + +[ + (balance) + (open) + (close) + (commodity) + (pad) + (event) + (price) + (note) + (document) + (query) + (custom) + (pushtag) + (poptag) + (pushmeta) + (popmeta) + (option) + (include) + (plugin) +] @keyword diff --git a/pack/ant/start/nvim-treesitter/queries/beancount/injections.scm b/pack/ant/start/nvim-treesitter/queries/beancount/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/beancount/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/bibtex/folds.scm b/pack/ant/start/nvim-treesitter/queries/bibtex/folds.scm new file mode 100644 index 0000000..321a045 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bibtex/folds.scm @@ -0,0 +1 @@ +(entry) @fold diff --git a/pack/ant/start/nvim-treesitter/queries/bibtex/highlights.scm b/pack/ant/start/nvim-treesitter/queries/bibtex/highlights.scm new file mode 100644 index 0000000..a82b371 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bibtex/highlights.scm @@ -0,0 +1,50 @@ +; CREDITS @pfoerster (adapted from https://github.com/latex-lsp/tree-sitter-bibtex) +[ + (string_type) + (preamble_type) + (entry_type) +] @keyword + +[ + (junk) + (comment) +] @comment + +(comment) @spell + +[ + "=" + "#" +] @operator + +(command) @function.builtin + +(number) @number + +(field + name: (identifier) @variable.member) + +(token + (identifier) @variable.parameter) + +[ + (brace_word) + (quote_word) +] @string + +[ + (key_brace) + (key_paren) +] @string.special.symbol + +(string + name: (identifier) @constant) + +[ + "{" + "}" + "(" + ")" +] @punctuation.bracket + +"," @punctuation.delimiter diff --git a/pack/ant/start/nvim-treesitter/queries/bibtex/indents.scm b/pack/ant/start/nvim-treesitter/queries/bibtex/indents.scm new file mode 100644 index 0000000..764172a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bibtex/indents.scm @@ -0,0 +1,8 @@ +(entry) @indent.begin + +[ + "{" + "}" +] @indent.branch + +(comment) @indent.ignore diff --git a/pack/ant/start/nvim-treesitter/queries/bibtex/injections.scm b/pack/ant/start/nvim-treesitter/queries/bibtex/injections.scm new file mode 100644 index 0000000..98ad387 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bibtex/injections.scm @@ -0,0 +1,2 @@ +((junk) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/bicep/folds.scm b/pack/ant/start/nvim-treesitter/queries/bicep/folds.scm new file mode 100644 index 0000000..217a86d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bicep/folds.scm @@ -0,0 +1,19 @@ +[ + (module_declaration) + (metadata_declaration) + (output_declaration) + (parameter_declaration) + (resource_declaration) + (type_declaration) + (variable_declaration) + (parenthesized_expression) + (decorators) + (array) + (object) + (if_statement) + (for_statement) + (subscript_expression) + (ternary_expression) + (string) + (comment) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/bicep/highlights.scm b/pack/ant/start/nvim-treesitter/queries/bicep/highlights.scm new file mode 100644 index 0000000..35c9d6c --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bicep/highlights.scm @@ -0,0 +1,234 @@ +; Includes +[ + "import" + "provider" + "with" + "as" + "from" +] @keyword.import + +; Namespaces +(module_declaration + (identifier) @module) + +; Builtins +(primitive_type) @type.builtin + +((member_expression + object: (identifier) @type.builtin) + (#eq? @type.builtin "sys")) + +; Functions +(call_expression + function: (identifier) @function.call) + +(user_defined_function + name: (identifier) @function) + +; Properties +(object_property + (identifier) @property + ":" @punctuation.delimiter + (_)) + +(object_property + (compatible_identifier) @property + ":" @punctuation.delimiter + (_)) + +(property_identifier) @property + +; Attributes +(decorator + "@" @attribute) + +(decorator + (call_expression + (identifier) @attribute)) + +(decorator + (call_expression + (member_expression + object: (identifier) @attribute + property: (property_identifier) @attribute))) + +; Types +(type_declaration + (identifier) @type) + +(type_declaration + (identifier) + "=" + (identifier) @type) + +(type + (identifier) @type) + +(resource_declaration + (identifier) @type) + +(resource_expression + (identifier) @type) + +; Parameters +(parameter_declaration + (identifier) @variable.parameter + (_)) + +(call_expression + function: (_) + (arguments + (identifier) @variable.parameter)) + +(call_expression + function: (_) + (arguments + (member_expression + object: (identifier) @variable.parameter))) + +(parameter + . + (identifier) @variable.parameter) + +; Variables +(variable_declaration + (identifier) @variable + (_)) + +(metadata_declaration + (identifier) @variable + (_)) + +(output_declaration + (identifier) @variable + (_)) + +(object_property + (_) + ":" + (identifier) @variable) + +(for_statement + "for" + (for_loop_parameters + (loop_variable) @variable + (loop_enumerator) @variable)) + +; Conditionals +"if" @keyword.conditional + +(ternary_expression + "?" @keyword.conditional.ternary + ":" @keyword.conditional.ternary) + +; Loops +(for_statement + "for" @keyword.repeat + "in" + ":" @punctuation.delimiter) + +; Keywords +[ + "module" + "metadata" + "output" + "param" + "resource" + "existing" + "targetScope" + "type" + "var" + "using" + "test" +] @keyword + +"func" @keyword.function + +"assert" @keyword.exception + +; Operators +[ + "+" + "-" + "*" + "/" + "%" + "||" + "&&" + "|" + "==" + "!=" + "=~" + "!~" + ">" + ">=" + "<=" + "<" + "??" + "=" + "!" + ".?" +] @operator + +(subscript_expression + "?" @operator) + +(nullable_type + "?" @operator) + +"in" @keyword.operator + +; Literals +(string) @string + +(escape_sequence) @string.escape + +(number) @number + +(boolean) @boolean + +(null) @constant.builtin + +; Misc +(compatible_identifier + "?" @punctuation.special) + +(nullable_return_type) @punctuation.special + +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "." + ":" + "::" + "=>" +] @punctuation.delimiter + +; Interpolation +(interpolation) @none + +(interpolation + "${" @punctuation.special + "}" @punctuation.special) + +(interpolation + (identifier) @variable) + +; Comments +[ + (comment) + (diagnostic_comment) +] @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/bicep/indents.scm b/pack/ant/start/nvim-treesitter/queries/bicep/indents.scm new file mode 100644 index 0000000..055e51b --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bicep/indents.scm @@ -0,0 +1,27 @@ +[ + (array) + (object) +] @indent.begin + +"}" @indent.end + +[ + "{" + "}" +] @indent.branch + +[ + "[" + "]" +] @indent.branch + +[ + "(" + ")" +] @indent.branch + +[ + (ERROR) + (comment) + (diagnostic_comment) +] @indent.auto diff --git a/pack/ant/start/nvim-treesitter/queries/bicep/injections.scm b/pack/ant/start/nvim-treesitter/queries/bicep/injections.scm new file mode 100644 index 0000000..5c2d4a5 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bicep/injections.scm @@ -0,0 +1,5 @@ +([ + (comment) + (diagnostic_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/bicep/locals.scm b/pack/ant/start/nvim-treesitter/queries/bicep/locals.scm new file mode 100644 index 0000000..cc9c3c2 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bicep/locals.scm @@ -0,0 +1,73 @@ +; Scopes +[ + (infrastructure) + (call_expression) + (lambda_expression) + (subscript_expression) + (if_statement) + (for_statement) + (array) + (object) + (interpolation) +] @local.scope + +; References +(property_identifier) @local.reference + +(call_expression + (identifier) @local.reference) + +(object_property + (_) + ":" + (identifier) @local.reference) + +(resource_expression + (identifier) @local.reference) + +; Definitions +(type) @local.definition.associated + +(object_property + (identifier) @local.definition.field + (_)) + +(object_property + (compatible_identifier) @local.definition.field + (_)) + +(user_defined_function + name: (identifier) @local.definition.function) + +(module_declaration + (identifier) @local.definition.namespace) + +(parameter_declaration + (identifier) @local.definition.parameter + (_)) + +(parameter + . + (identifier) @local.definition.parameter) + +(type_declaration + (identifier) @local.definition.type + (_)) + +(variable_declaration + (identifier) @local.definition.var + (_)) + +(metadata_declaration + (identifier) @local.definition.var + (_)) + +(output_declaration + (identifier) @local.definition.var + (_)) + +(for_statement + "for" + (for_loop_parameters + (loop_variable) @local.definition.var + (loop_enumerator) @local.definition.var)) diff --git a/pack/ant/start/nvim-treesitter/queries/bitbake/folds.scm b/pack/ant/start/nvim-treesitter/queries/bitbake/folds.scm new file mode 100644 index 0000000..85d2263 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bitbake/folds.scm @@ -0,0 +1,24 @@ +[ + (function_definition) + (anonymous_python_function) + (python_function_definition) + (while_statement) + (for_statement) + (if_statement) + (with_statement) + (try_statement) + (import_from_statement) + (parameters) + (argument_list) + (parenthesized_expression) + (generator_expression) + (list_comprehension) + (set_comprehension) + (dictionary_comprehension) + (tuple) + (list) + (set) + (dictionary) + (string) + (python_string) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/bitbake/highlights.scm b/pack/ant/start/nvim-treesitter/queries/bitbake/highlights.scm new file mode 100644 index 0000000..c7316de --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bitbake/highlights.scm @@ -0,0 +1,406 @@ +; Includes +[ + "inherit" + "include" + "require" + "export" + "import" +] @keyword.import + +; Keywords +[ + "unset" + "EXPORT_FUNCTIONS" + "python" + "assert" + "exec" + "global" + "nonlocal" + "pass" + "print" + "with" + "as" +] @keyword + +[ + "async" + "await" +] @keyword.coroutine + +[ + "return" + "yield" +] @keyword.return + +(yield + "from" @keyword.return) + +(future_import_statement + "from" @keyword.import + "__future__" @constant.builtin) + +(import_from_statement + "from" @keyword.import) + +"import" @keyword.import + +(aliased_import + "as" @keyword.import) + +[ + "if" + "elif" + "else" +] @keyword.conditional + +[ + "for" + "while" + "break" + "continue" +] @keyword.repeat + +[ + "try" + "except" + "except*" + "raise" + "finally" +] @keyword.exception + +(raise_statement + "from" @keyword.exception) + +(try_statement + (else_clause + "else" @keyword.exception)) + +[ + "addtask" + "deltask" + "addhandler" + "def" + "lambda" +] @keyword.function + +[ + "before" + "after" +] @keyword.modifier + +[ + "append" + "prepend" + "remove" +] @keyword.modifier + +; Variables +[ + (identifier) + (python_identifier) +] @variable + +[ + "noexec" + "OVERRIDES" + "$BB_ENV_PASSTHROUGH" + "$BB_ENV_PASSTHROUGH_ADDITIONS" +] @variable.builtin + +; Reset highlighting in f-string interpolations +(interpolation) @none + +; Identifier naming conventions +((python_identifier) @type + (#lua-match? @type "^[A-Z].*[a-z]")) + +([ + (identifier) + (python_identifier) +] @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + +((python_identifier) @constant.builtin + (#lua-match? @constant.builtin "^__[a-zA-Z0-9_]*__$")) + +((python_identifier) @constant.builtin + (#any-of? @constant.builtin + ; https://docs.python.org/3/library/constants.html + "NotImplemented" "Ellipsis" "quit" "exit" "copyright" "credits" "license")) + +((assignment + left: (python_identifier) @type.definition + (type + (python_identifier) @_annotation)) + (#eq? @_annotation "TypeAlias")) + +((assignment + left: (python_identifier) @type.definition + right: (call + function: (python_identifier) @_func)) + (#any-of? @_func "TypeVar" "NewType")) + +; Fields +(flag) @variable.member + +((attribute + attribute: (python_identifier) @variable.member) + (#lua-match? @variable.member "^[%l_].*$")) + +; Functions +(call + function: (python_identifier) @function.call) + +(call + function: (attribute + attribute: (python_identifier) @function.method.call)) + +((call + function: (python_identifier) @constructor) + (#lua-match? @constructor "^%u")) + +((call + function: (attribute + attribute: (python_identifier) @constructor)) + (#lua-match? @constructor "^%u")) + +((call + function: (python_identifier) @function.builtin) + (#any-of? @function.builtin + "abs" "all" "any" "ascii" "bin" "bool" "breakpoint" "bytearray" "bytes" "callable" "chr" + "classmethod" "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate" "eval" "exec" + "filter" "float" "format" "frozenset" "getattr" "globals" "hasattr" "hash" "help" "hex" "id" + "input" "int" "isinstance" "issubclass" "iter" "len" "list" "locals" "map" "max" "memoryview" + "min" "next" "object" "oct" "open" "ord" "pow" "print" "property" "range" "repr" "reversed" + "round" "set" "setattr" "slice" "sorted" "staticmethod" "str" "sum" "super" "tuple" "type" + "vars" "zip" "__import__")) + +(python_function_definition + name: (python_identifier) @function) + +(type + (python_identifier) @type) + +(type + (subscript + (python_identifier) @type)) ; type subscript: Tuple[int] + +((call + function: (python_identifier) @_isinstance + arguments: (argument_list + (_) + (python_identifier) @type)) + (#eq? @_isinstance "isinstance")) + +(anonymous_python_function + (identifier) @function) + +(function_definition + (identifier) @function) + +(addtask_statement + (identifier) @function) + +(deltask_statement + (identifier) @function) + +(export_functions_statement + (identifier) @function) + +(addhandler_statement + (identifier) @function) + +(python_function_definition + body: (block + . + (expression_statement + (python_string) @string.documentation @spell))) + +; Namespace +(inherit_path) @module + +; Normal parameters +(parameters + (python_identifier) @variable.parameter) + +; Lambda parameters +(lambda_parameters + (python_identifier) @variable.parameter) + +(lambda_parameters + (tuple_pattern + (python_identifier) @variable.parameter)) + +; Default parameters +(keyword_argument + name: (python_identifier) @variable.parameter) + +; Naming parameters on call-site +(default_parameter + name: (python_identifier) @variable.parameter) + +(typed_parameter + (python_identifier) @variable.parameter) + +(typed_default_parameter + (python_identifier) @variable.parameter) + +; Variadic parameters *args, **kwargs +(parameters + (list_splat_pattern + ; *args + (python_identifier) @variable.parameter)) + +(parameters + (dictionary_splat_pattern + ; **kwargs + (python_identifier) @variable.parameter)) + +; Literals +(none) @constant.builtin + +[ + (true) + (false) +] @boolean + +((python_identifier) @variable.builtin + (#any-of? @variable.builtin "self" "cls")) + +(integer) @number + +(float) @number.float + +; Operators +[ + "?=" + "??=" + ":=" + "=+" + ".=" + "=." + "-" + "-=" + ":=" + "!=" + "*" + "**" + "**=" + "*=" + "/" + "//" + "//=" + "/=" + "&" + "&=" + "%" + "%=" + "^" + "^=" + "+" + "+=" + "<" + "<<" + "<<=" + "<=" + "<>" + "=" + "==" + ">" + ">=" + ">>" + ">>=" + "@" + "@=" + "|" + "|=" + "~" + "->" +] @operator + +[ + "and" + "in" + "is" + "not" + "or" + "is not" + "not in" + "del" +] @keyword.operator + +; Literals +[ + (string) + (python_string) + "\"" +] @string + +(include_path) @string.special.path + +[ + (escape_sequence) + (escape_interpolation) +] @string.escape + +; Punctuation +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + ":" + "->" + ";" + "." + "," + (ellipsis) +] @punctuation.delimiter + +(variable_expansion + [ + "${" + "}" + ] @punctuation.special) + +(inline_python + [ + "${@" + "}" + ] @punctuation.special) + +(interpolation + "{" @punctuation.special + "}" @punctuation.special) + +(type_conversion) @function.macro + +([ + (identifier) + (python_identifier) +] @type.builtin + (#any-of? @type.builtin + ; https://docs.python.org/3/library/exceptions.html + "BaseException" "Exception" "ArithmeticError" "BufferError" "LookupError" "AssertionError" + "AttributeError" "EOFError" "FloatingPointError" "GeneratorExit" "ImportError" + "ModuleNotFoundError" "IndexError" "KeyError" "KeyboardInterrupt" "MemoryError" "NameError" + "NotImplementedError" "OSError" "OverflowError" "RecursionError" "ReferenceError" "RuntimeError" + "StopIteration" "StopAsyncIteration" "SyntaxError" "IndentationError" "TabError" "SystemError" + "SystemExit" "TypeError" "UnboundLocalError" "UnicodeError" "UnicodeEncodeError" + "UnicodeDecodeError" "UnicodeTranslateError" "ValueError" "ZeroDivisionError" "EnvironmentError" + "IOError" "WindowsError" "BlockingIOError" "ChildProcessError" "ConnectionError" + "BrokenPipeError" "ConnectionAbortedError" "ConnectionRefusedError" "ConnectionResetError" + "FileExistsError" "FileNotFoundError" "InterruptedError" "IsADirectoryError" + "NotADirectoryError" "PermissionError" "ProcessLookupError" "TimeoutError" "Warning" + "UserWarning" "DeprecationWarning" "PendingDeprecationWarning" "SyntaxWarning" "RuntimeWarning" + "FutureWarning" "ImportWarning" "UnicodeWarning" "BytesWarning" "ResourceWarning" + ; https://docs.python.org/3/library/stdtypes.html + "bool" "int" "float" "complex" "list" "tuple" "range" "str" "bytes" "bytearray" "memoryview" + "set" "frozenset" "dict" "type" "object")) + +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/bitbake/indents.scm b/pack/ant/start/nvim-treesitter/queries/bitbake/indents.scm new file mode 100644 index 0000000..5f20818 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bitbake/indents.scm @@ -0,0 +1,172 @@ +[ + (import_from_statement) + (parenthesized_expression) + (generator_expression) + (list_comprehension) + (set_comprehension) + (dictionary_comprehension) + (tuple_pattern) + (list_pattern) + (binary_operator) + (lambda) + (concatenated_string) +] @indent.begin + +((list) @indent.align + (#set! indent.open_delimiter "[") + (#set! indent.close_delimiter "]")) + +((dictionary) @indent.align + (#set! indent.open_delimiter "{") + (#set! indent.close_delimiter "}")) + +((set) @indent.align + (#set! indent.open_delimiter "{") + (#set! indent.close_delimiter "}")) + +((for_statement) @indent.begin + (#set! indent.immediate 1)) + +((if_statement) @indent.begin + (#set! indent.immediate 1)) + +((while_statement) @indent.begin + (#set! indent.immediate 1)) + +((try_statement) @indent.begin + (#set! indent.immediate 1)) + +(ERROR + "try" + ":" @indent.begin + (#set! indent.immediate 1)) + +((python_function_definition) @indent.begin + (#set! indent.immediate 1)) + +(function_definition) @indent.begin + +(anonymous_python_function) @indent.begin + +((with_statement) @indent.begin + (#set! indent.immediate 1)) + +(if_statement + condition: (parenthesized_expression) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")") + (#set! indent.avoid_last_matching_next 1)) + +(while_statement + condition: (parenthesized_expression) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")") + (#set! indent.avoid_last_matching_next 1)) + +(ERROR + "(" @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")") + . + (_)) + +((argument_list) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +((parameters) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")") + (#set! indent.avoid_last_matching_next 1)) + +((tuple) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +(ERROR + "[" @indent.align + (#set! indent.open_delimiter "[") + (#set! indent.close_delimiter "]") + . + (_)) + +(ERROR + "{" @indent.align + (#set! indent.open_delimiter "{") + (#set! indent.close_delimiter "}") + . + (_)) + +[ + (break_statement) + (continue_statement) +] @indent.dedent + +(ERROR + (_) @indent.branch + ":" + . + (#lua-match? @indent.branch "^else")) + +(ERROR + (_) @indent.branch @indent.dedent + ":" + . + (#lua-match? @indent.branch "^elif")) + +(parenthesized_expression + ")" @indent.end) + +(generator_expression + ")" @indent.end) + +(list_comprehension + "]" @indent.end) + +(set_comprehension + "}" @indent.end) + +(dictionary_comprehension + "}" @indent.end) + +(tuple_pattern + ")" @indent.end) + +(list_pattern + "]" @indent.end) + +(function_definition + "}" @indent.end) + +(anonymous_python_function + "}" @indent.end) + +(return_statement + [ + (_) @indent.end + (_ + [ + (_) + ")" + "}" + "]" + ] @indent.end .) + (attribute + attribute: (_) @indent.end) + (call + arguments: (_ + ")" @indent.end)) + "return" @indent.end + ] .) + +[ + ")" + "]" + "}" + (elif_clause) + (else_clause) + (except_clause) + (finally_clause) +] @indent.branch + +(string) @indent.auto diff --git a/pack/ant/start/nvim-treesitter/queries/bitbake/injections.scm b/pack/ant/start/nvim-treesitter/queries/bitbake/injections.scm new file mode 100644 index 0000000..35c984a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bitbake/injections.scm @@ -0,0 +1,15 @@ +(call + function: (attribute + object: (python_identifier) @_re) + arguments: (argument_list + (python_string + (string_content) @injection.content) @_string) + (#eq? @_re "re") + (#lua-match? @_string "^r.*") + (#set! injection.language "regex")) + +((shell_content) @injection.content + (#set! injection.language "bash")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/bitbake/locals.scm b/pack/ant/start/nvim-treesitter/queries/bitbake/locals.scm new file mode 100644 index 0000000..e4726ec --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bitbake/locals.scm @@ -0,0 +1,117 @@ +; References +[ + (python_identifier) + (identifier) +] @local.reference + +; Imports +(aliased_import + alias: (python_identifier) @local.definition.import) + +(import_statement + name: (dotted_name + (python_identifier) @local.definition.import)) + +(import_from_statement + name: (dotted_name + (python_identifier) @local.definition.import)) + +; Function with parameters, defines parameters +(parameters + (python_identifier) @local.definition.parameter) + +(default_parameter + (python_identifier) @local.definition.parameter) + +(typed_parameter + (python_identifier) @local.definition.parameter) + +(typed_default_parameter + (python_identifier) @local.definition.parameter) + +; *args parameter +(parameters + (list_splat_pattern + (python_identifier) @local.definition.parameter)) + +; **kwargs parameter +(parameters + (dictionary_splat_pattern + (python_identifier) @local.definition.parameter)) + +; Function defines function and scope +((python_function_definition + name: (python_identifier) @local.definition.function) @local.scope + (#set! definition.function.scope "parent")) + +(function_definition + (identifier) @local.definition.function) + +(anonymous_python_function + (identifier) @local.definition.function) + +; Loops +; not a scope! +(for_statement + left: (pattern_list + (python_identifier) @local.definition.var)) + +(for_statement + left: (tuple_pattern + (python_identifier) @local.definition.var)) + +(for_statement + left: (python_identifier) @local.definition.var) + +; not a scope! +;(while_statement) @local.scope +; for in list comprehension +(for_in_clause + left: (python_identifier) @local.definition.var) + +(for_in_clause + left: (tuple_pattern + (python_identifier) @local.definition.var)) + +(for_in_clause + left: (pattern_list + (python_identifier) @local.definition.var)) + +(dictionary_comprehension) @local.scope + +(list_comprehension) @local.scope + +(set_comprehension) @local.scope + +; Assignments +(assignment + left: (python_identifier) @local.definition.var) + +(assignment + left: (pattern_list + (python_identifier) @local.definition.var)) + +(assignment + left: (tuple_pattern + (python_identifier) @local.definition.var)) + +(assignment + left: (attribute + (python_identifier) + (python_identifier) @local.definition.field)) + +(variable_assignment + (identifier) + operator: [ + "=" + "?=" + "??=" + ":=" + ] @local.definition.var) + +; Walrus operator x := 1 +(named_expression + (python_identifier) @local.definition.var) + +(as_pattern + alias: (as_pattern_target) @local.definition.var) diff --git a/pack/ant/start/nvim-treesitter/queries/blueprint/highlights.scm b/pack/ant/start/nvim-treesitter/queries/blueprint/highlights.scm new file mode 100644 index 0000000..f3c39f2 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/blueprint/highlights.scm @@ -0,0 +1,75 @@ +(object_id) @variable + +(string) @string + +(escape_sequence) @string.escape + +(comment) @comment @spell + +(constant) @constant.builtin + +(boolean) @boolean + +(using) @keyword.import + +(template) @keyword + +(decorator) @attribute + +(property_definition + (property_name) @property) + +(object) @type + +(signal_binding + (signal_name) @function.builtin) + +(signal_binding + (function + (identifier)) @function) + +(signal_binding + "swapped" @keyword) + +(styles_list + "styles" @function.macro) + +(layout_definition + "layout" @function.macro) + +(gettext_string + "_" @function.builtin) + +(menu_definition + "menu" @keyword) + +(menu_section + "section" @keyword) + +(menu_item + "item" @function.macro) + +(import_statement + (gobject_library) @module) + +(import_statement + (version_number) @number.float) + +(float) @number.float + +(number) @number + +[ + ";" + "." + "," +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket diff --git a/pack/ant/start/nvim-treesitter/queries/blueprint/injections.scm b/pack/ant/start/nvim-treesitter/queries/blueprint/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/blueprint/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/bp/folds.scm b/pack/ant/start/nvim-treesitter/queries/bp/folds.scm new file mode 100644 index 0000000..c40ea3d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bp/folds.scm @@ -0,0 +1,6 @@ +[ + (list_expression) + (map_expression) + (module) + (select_expression) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/bp/highlights.scm b/pack/ant/start/nvim-treesitter/queries/bp/highlights.scm new file mode 100644 index 0000000..5f94f4c --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bp/highlights.scm @@ -0,0 +1,56 @@ +(comment) @comment @spell + +(operator) @operator + +(integer_literal + "-" @operator) + +[ + "," + ":" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(boolean_literal) @boolean + +(integer_literal) @number + +[ + (raw_string_literal) + (interpreted_string_literal) +] @string + +(escape_sequence) @string.escape + +(identifier) @variable + +(module + type: (identifier) @function.call) + +(module + (property + field: (identifier) @variable.parameter)) + +[ + (unset) + (default) + (any) +] @variable.builtin + +(condition + name: (identifier) @function.builtin) + +(map_expression + (property + field: (identifier) @property)) + +(select_expression + "select" @keyword.conditional) diff --git a/pack/ant/start/nvim-treesitter/queries/bp/indents.scm b/pack/ant/start/nvim-treesitter/queries/bp/indents.scm new file mode 100644 index 0000000..8cf8adc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bp/indents.scm @@ -0,0 +1,38 @@ +(list_expression) @indent.begin + +(list_expression + "]" @indent.branch) + +(map_expression) @indent.begin + +(map_expression + "}" @indent.branch) + +(select_expression) @indent.begin + +(select_expression + ")" @indent.branch) + +(select_value) @indent.begin + +(select_value + ")" @indent.branch) + +(select_pattern + "(" @indent.begin) + +(select_pattern + ")" @indent.branch) + +(select_cases) @indent.begin + +(select_cases + "}" @indent.branch) + +(module) @indent.begin + +(module + ")" @indent.branch) + +(module + "}" @indent.branch) diff --git a/pack/ant/start/nvim-treesitter/queries/bp/injections.scm b/pack/ant/start/nvim-treesitter/queries/bp/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bp/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/bp/locals.scm b/pack/ant/start/nvim-treesitter/queries/bp/locals.scm new file mode 100644 index 0000000..c8a5a17 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/bp/locals.scm @@ -0,0 +1,15 @@ +(module + (property + field: (identifier) @local.definition.parameter)) + +(map_expression + (property + field: (identifier) @local.definition.field)) + +(assignment + left: (identifier) @local.definition.var) + +(pattern_binding + binding: (identifier) @local.definition.var) + +(identifier) @local.reference diff --git a/pack/ant/start/nvim-treesitter/queries/c/folds.scm b/pack/ant/start/nvim-treesitter/queries/c/folds.scm new file mode 100644 index 0000000..bb26a62 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/c/folds.scm @@ -0,0 +1,23 @@ +[ + (for_statement) + (if_statement) + (while_statement) + (do_statement) + (switch_statement) + (case_statement) + (function_definition) + (struct_specifier) + (enum_specifier) + (comment) + (preproc_if) + (preproc_elif) + (preproc_else) + (preproc_ifdef) + (preproc_function_def) + (initializer_list) + (gnu_asm_expression) + (preproc_include)+ +] @fold + +(compound_statement + (compound_statement) @fold) diff --git a/pack/ant/start/nvim-treesitter/queries/c/highlights.scm b/pack/ant/start/nvim-treesitter/queries/c/highlights.scm new file mode 100644 index 0000000..bd6857f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/c/highlights.scm @@ -0,0 +1,341 @@ +; Lower priority to prefer @variable.parameter when identifier appears in parameter_declaration. +((identifier) @variable + (#set! priority 95)) + +(preproc_def + (preproc_arg) @variable) + +[ + "default" + "goto" + "asm" + "__asm__" +] @keyword + +[ + "enum" + "struct" + "union" + "typedef" +] @keyword.type + +[ + "sizeof" + "offsetof" +] @keyword.operator + +(alignof_expression + . + _ @keyword.operator) + +"return" @keyword.return + +[ + "while" + "for" + "do" + "continue" + "break" +] @keyword.repeat + +[ + "if" + "else" + "case" + "switch" +] @keyword.conditional + +[ + "#if" + "#ifdef" + "#ifndef" + "#else" + "#elif" + "#endif" + "#elifdef" + "#elifndef" + (preproc_directive) +] @keyword.directive + +"#define" @keyword.directive.define + +"#include" @keyword.import + +[ + ";" + ":" + "," + "::" +] @punctuation.delimiter + +"..." @punctuation.special + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "=" + "-" + "*" + "/" + "+" + "%" + "~" + "|" + "&" + "^" + "<<" + ">>" + "->" + "." + "<" + "<=" + ">=" + ">" + "==" + "!=" + "!" + "&&" + "||" + "-=" + "+=" + "*=" + "/=" + "%=" + "|=" + "&=" + "^=" + ">>=" + "<<=" + "--" + "++" +] @operator + +; Make sure the comma operator is given a highlight group after the comma +; punctuator so the operator is highlighted properly. +(comma_expression + "," @operator) + +[ + (true) + (false) +] @boolean + +(conditional_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +(string_literal) @string + +(system_lib_string) @string + +(escape_sequence) @string.escape + +(null) @constant.builtin + +(number_literal) @number + +(char_literal) @character + +(preproc_defined) @function.macro + +((field_expression + (field_identifier) @property) @_parent + (#not-has-parent? @_parent template_method function_declarator call_expression)) + +(field_designator) @property + +((field_identifier) @property + (#has-ancestor? @property field_declaration) + (#not-has-ancestor? @property function_declarator)) + +(statement_identifier) @label + +(declaration + type: (type_identifier) @_type + declarator: (identifier) @label + (#eq? @_type "__label__")) + +[ + (type_identifier) + (type_descriptor) +] @type + +(storage_class_specifier) @keyword.modifier + +[ + (type_qualifier) + (gnu_asm_qualifier) + "__extension__" +] @keyword.modifier + +(linkage_specification + "extern" @keyword.modifier) + +(type_definition + declarator: (type_identifier) @type.definition) + +(primitive_type) @type.builtin + +(sized_type_specifier + _ @type.builtin + type: _?) + +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z0-9_]+$")) + +(preproc_def + (preproc_arg) @constant + (#lua-match? @constant "^[A-Z][A-Z0-9_]+$")) + +(enumerator + name: (identifier) @constant) + +(case_statement + value: (identifier) @constant) + +((identifier) @constant.builtin + ; format-ignore + (#any-of? @constant.builtin + "stderr" "stdin" "stdout" + "__FILE__" "__LINE__" "__DATE__" "__TIME__" + "__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__" + "__cplusplus" "__OBJC__" "__ASSEMBLER__" + "__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__" + "__TIMESTAMP__" "__clang__" "__clang_major__" + "__clang_minor__" "__clang_patchlevel__" + "__clang_version__" "__clang_literal_encoding__" + "__clang_wide_literal_encoding__" + "__FUNCTION__" "__func__" "__PRETTY_FUNCTION__" + "__VA_ARGS__" "__VA_OPT__")) + +(preproc_def + (preproc_arg) @constant.builtin + ; format-ignore + (#any-of? @constant.builtin + "stderr" "stdin" "stdout" + "__FILE__" "__LINE__" "__DATE__" "__TIME__" + "__STDC__" "__STDC_VERSION__" "__STDC_HOSTED__" + "__cplusplus" "__OBJC__" "__ASSEMBLER__" + "__BASE_FILE__" "__FILE_NAME__" "__INCLUDE_LEVEL__" + "__TIMESTAMP__" "__clang__" "__clang_major__" + "__clang_minor__" "__clang_patchlevel__" + "__clang_version__" "__clang_literal_encoding__" + "__clang_wide_literal_encoding__" + "__FUNCTION__" "__func__" "__PRETTY_FUNCTION__" + "__VA_ARGS__" "__VA_OPT__")) + +(attribute_specifier + (argument_list + (identifier) @variable.builtin)) + +(attribute_specifier + (argument_list + (call_expression + function: (identifier) @variable.builtin))) + +((call_expression + function: (identifier) @function.builtin) + (#lua-match? @function.builtin "^__builtin_")) + +((call_expression + function: (identifier) @function.builtin) + (#has-ancestor? @function.builtin attribute_specifier)) + +; Preproc def / undef +(preproc_def + name: (_) @constant.macro) + +(preproc_call + directive: (preproc_directive) @_u + argument: (_) @constant.macro + (#eq? @_u "#undef")) + +(preproc_ifdef + name: (identifier) @constant.macro) + +(preproc_elifdef + name: (identifier) @constant.macro) + +(preproc_defined + (identifier) @constant.macro) + +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (field_expression + field: (field_identifier) @function.call)) + +(function_declarator + declarator: (identifier) @function) + +(function_declarator + declarator: (parenthesized_declarator + (pointer_declarator + declarator: (field_identifier) @function))) + +(preproc_function_def + name: (identifier) @function.macro) + +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +; Parameters +(parameter_declaration + declarator: (identifier) @variable.parameter) + +(parameter_declaration + declarator: (array_declarator) @variable.parameter) + +(parameter_declaration + declarator: (pointer_declarator) @variable.parameter) + +; K&R functions +; To enable support for K&R functions, +; add the following lines to your own query config and uncomment them. +; They are commented out as they'll conflict with C++ +; Note that you'll need to have `; extends` at the top of your query file. +; +; (parameter_list (identifier) @variable.parameter) +; +; (function_definition +; declarator: _ +; (declaration +; declarator: (identifier) @variable.parameter)) +; +; (function_definition +; declarator: _ +; (declaration +; declarator: (array_declarator) @variable.parameter)) +; +; (function_definition +; declarator: _ +; (declaration +; declarator: (pointer_declarator) @variable.parameter)) +(preproc_params + (identifier) @variable.parameter) + +[ + "__attribute__" + "__declspec" + "__based" + "__cdecl" + "__clrcall" + "__stdcall" + "__fastcall" + "__thiscall" + "__vectorcall" + (ms_pointer_modifier) + (attribute_declaration) +] @attribute diff --git a/pack/ant/start/nvim-treesitter/queries/c/indents.scm b/pack/ant/start/nvim-treesitter/queries/c/indents.scm new file mode 100644 index 0000000..1932ce8 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/c/indents.scm @@ -0,0 +1,99 @@ +[ + (compound_statement) + (field_declaration_list) + (case_statement) + (enumerator_list) + (compound_literal_expression) + (initializer_list) + (init_declarator) +] @indent.begin + +; With current indent logic, if we capture expression_statement with @indent.begin +; It will be affected by _parent_ node with error subnodes deep down the tree +; So narrow indent capture to check for error inside expression statement only, +(expression_statement + (_) @indent.begin + ";" @indent.end) + +(ERROR + "for" + "(" @indent.begin + ";" + ";" + ")" @indent.end) + +((for_statement + body: (_) @_body) @indent.begin + (#not-kind-eq? @_body "compound_statement")) + +(while_statement + condition: (_) @indent.begin) + +((while_statement + body: (_) @_body) @indent.begin + (#not-kind-eq? @_body "compound_statement")) + +((if_statement) + . + (ERROR + "else" @indent.begin)) + +(if_statement + condition: (_) @indent.begin) + +; Supports if without braces (but not both if-else without braces) +(if_statement + consequence: (_ + ";" @indent.end) @_consequence + (#not-kind-eq? @_consequence "compound_statement") + alternative: (else_clause + "else" @indent.branch + [ + (if_statement + (compound_statement) @indent.dedent)? @indent.dedent + (compound_statement)? @indent.dedent + (_)? @indent.dedent + ])?) @indent.begin + +(else_clause + (_ + . + "{" @indent.branch)) + +(compound_statement + "}" @indent.end) + +[ + ")" + "}" + (statement_identifier) +] @indent.branch + +[ + "#define" + "#ifdef" + "#ifndef" + "#elif" + "#if" + "#else" + "#endif" +] @indent.zero + +[ + (preproc_arg) + (string_literal) +] @indent.ignore + +((ERROR + (parameter_declaration)) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +([ + (argument_list) + (parameter_list) +] @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +(comment) @indent.auto diff --git a/pack/ant/start/nvim-treesitter/queries/c/injections.scm b/pack/ant/start/nvim-treesitter/queries/c/injections.scm new file mode 100644 index 0000000..77b4d7a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/c/injections.scm @@ -0,0 +1,128 @@ +((preproc_arg) @injection.content + (#set! injection.language "c")) + +((comment) @injection.content + (#set! injection.language "comment")) + +((comment) @injection.content + (#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c") + (#set! injection.language "re2c")) + +((comment) @injection.content + (#lua-match? @injection.content "/[*\/][!*\/]" + ">=" + "=" + "-=" + "+=" + "*=" + "/=" + "%=" + "^" + "^=" + "&=" + "|=" + "~" + ">>" + ">>>" + "<<" + "<<=" + ">>=" + ">>>=" + "=>" + "??" + "??=" + ".." +] @operator + +(list_pattern + ".." @character.special) + +(discard) @character.special + +[ + ";" + "." + "," + ":" +] @punctuation.delimiter + +(conditional_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +[ + "[" + "]" + "{" + "}" + "(" + ")" +] @punctuation.bracket + +(interpolation_brace) @punctuation.special + +(type_argument_list + [ + "<" + ">" + ] @punctuation.bracket) + +[ + "using" + "as" +] @keyword.import + +(alias_qualified_name + (identifier + "global") @keyword.import) + +[ + "with" + "new" + "typeof" + "sizeof" + "is" + "and" + "or" + "not" + "stackalloc" + "__makeref" + "__reftype" + "__refvalue" + "in" + "out" + "ref" +] @keyword.operator + +[ + "lock" + "params" + "operator" + "default" + "implicit" + "explicit" + "override" + "get" + "set" + "init" + "where" + "add" + "remove" + "checked" + "unchecked" + "fixed" + "alias" + "file" + "unsafe" +] @keyword + +(attribute_target_specifier + . + _ @keyword) + +[ + "enum" + "record" + "class" + "struct" + "interface" + "namespace" + "event" + "delegate" +] @keyword.type + +[ + "async" + "await" +] @keyword.coroutine + +[ + "const" + "extern" + "readonly" + "static" + "volatile" + "required" + "managed" + "unmanaged" + "notnull" + "abstract" + "private" + "protected" + "internal" + "public" + "partial" + "sealed" + "virtual" + "global" +] @keyword.modifier + +(scoped_type + "scoped" @keyword.modifier) + +(query_expression + (_ + [ + "from" + "orderby" + "select" + "group" + "by" + "ascending" + "descending" + "equals" + "let" + ] @keyword)) + +[ + "return" + "yield" +] @keyword.return diff --git a/pack/ant/start/nvim-treesitter/queries/c_sharp/injections.scm b/pack/ant/start/nvim-treesitter/queries/c_sharp/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/c_sharp/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/c_sharp/locals.scm b/pack/ant/start/nvim-treesitter/queries/c_sharp/locals.scm new file mode 100644 index 0000000..bef0940 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/c_sharp/locals.scm @@ -0,0 +1,42 @@ +; Definitions +(variable_declarator + . + (identifier) @local.definition.var) + +(variable_declarator + (tuple_pattern + (identifier) @local.definition.var)) + +(declaration_expression + name: (identifier) @local.definition.var) + +(foreach_statement + left: (identifier) @local.definition.var) + +(foreach_statement + left: (tuple_pattern + (identifier) @local.definition.var)) + +(parameter + (identifier) @local.definition.parameter) + +(method_declaration + name: (identifier) @local.definition.method) + +(local_function_statement + name: (identifier) @local.definition.method) + +(property_declaration + name: (identifier) @local.definition) + +(type_parameter + (identifier) @local.definition.type) + +(class_declaration + name: (identifier) @local.definition) + +; References +(identifier) @local.reference + +; Scope +(block) @local.scope diff --git a/pack/ant/start/nvim-treesitter/queries/cairo/folds.scm b/pack/ant/start/nvim-treesitter/queries/cairo/folds.scm new file mode 100644 index 0000000..9937da6 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cairo/folds.scm @@ -0,0 +1,26 @@ +[ + (mod_item) + (struct_item) + (trait_item) + (enum_item) + (impl_item) + (type_item) + (use_declaration) + (let_declaration) + (namespace_definition) + (arguments) + (implicit_arguments) + (tuple_type) + (import_statement) + (attribute_statement) + (with_statement) + (if_statement) + (function_definition) + (struct_definition) + (loop_expression) + (if_expression) + (match_expression) + (call_expression) + (tuple_expression) + (attribute_item) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/cairo/highlights.scm b/pack/ant/start/nvim-treesitter/queries/cairo/highlights.scm new file mode 100644 index 0000000..1ea6245 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cairo/highlights.scm @@ -0,0 +1,414 @@ +; Preproc +[ + "%builtins" + "%lang" +] @keyword.directive + +; Includes +(import_statement + [ + "from" + "import" + ] @keyword.import + module_name: (dotted_name + (identifier) @module .)) + +[ + "as" + "use" + "mod" +] @keyword.import + +; Variables +(identifier) @variable + +; Namespaces +(namespace_definition + (identifier) @module) + +(mod_item + name: (identifier) @module) + +(use_list + (self) @module) + +(scoped_use_list + (self) @module) + +(scoped_identifier + path: (identifier) @module) + +(scoped_identifier + (scoped_identifier + name: (identifier) @module)) + +(scoped_type_identifier + path: (identifier) @module) + +((scoped_identifier + path: (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +((scoped_identifier + name: (identifier) @type) + (#lua-match? @type "^[A-Z]")) + +((scoped_identifier + name: (identifier) @constant) + (#lua-match? @constant "^[A-Z][A-Z%d_]*$")) + +((scoped_identifier + path: (identifier) @type + name: (identifier) @constant) + (#lua-match? @type "^[A-Z]") + (#lua-match? @constant "^[A-Z]")) + +((scoped_type_identifier + path: (identifier) @type + name: (type_identifier) @constant) + (#lua-match? @type "^[A-Z]") + (#lua-match? @constant "^[A-Z]")) + +(scoped_use_list + path: (identifier) @module) + +(scoped_use_list + path: (scoped_identifier + (identifier) @module)) + +(use_list + (scoped_identifier + (identifier) @module + . + (_))) + +(use_list + (identifier) @type + (#lua-match? @type "^[A-Z]")) + +(use_as_clause + alias: (identifier) @type + (#lua-match? @type "^[A-Z]")) + +; Keywords +[ + ; 0.x + "using" + "let" + "const" + "local" + "rel" + "abs" + "dw" + "alloc_locals" + (inst_ret) + "with_attr" + "with" + "call" + "nondet" + ; 1.0 + "impl" + "implicits" + "of" + "ref" + "mut" +] @keyword + +[ + "struct" + "enum" + "namespace" + "type" + "trait" +] @keyword.type + +[ + "func" + "fn" + "end" +] @keyword.function + +"return" @keyword.return + +[ + "cast" + "new" + "and" +] @keyword.operator + +[ + "tempvar" + "extern" +] @keyword.modifier + +[ + "if" + "else" + "match" +] @keyword.conditional + +"loop" @keyword.repeat + +[ + "assert" + "static_assert" + "nopanic" +] @keyword.exception + +; Fields +(implicit_arguments + (typed_identifier + (identifier) @variable.member)) + +(member_expression + "." + (identifier) @variable.member) + +(call_expression + (assignment_expression + left: (identifier) @variable.member)) + +(tuple_expression + (assignment_expression + left: (identifier) @variable.member)) + +(field_identifier) @variable.member + +(shorthand_field_initializer + (identifier) @variable.member) + +; Parameters +(arguments + (typed_identifier + (identifier) @variable.parameter)) + +(call_expression + (tuple_expression + (assignment_expression + left: (identifier) @variable.parameter))) + +(return_type + (tuple_type + (named_type + . + (identifier) @variable.parameter))) + +(parameter + (identifier) @variable.parameter) + +; Builtins +(builtin_directive + (identifier) @variable.builtin) + +(lang_directive + (identifier) @variable.builtin) + +[ + "ap" + "fp" + (self) +] @variable.builtin + +; Functions +(function_definition + "func" + (identifier) @function) + +(function_definition + "fn" + (identifier) @function) + +(function_signature + "fn" + (identifier) @function) + +(extern_function_statement + (identifier) @function) + +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (scoped_identifier + (identifier) @function.call .)) + +(call_expression + function: (field_expression + field: (field_identifier) @function.call)) + +"jmp" @function.builtin + +; Types +(struct_definition + . + (identifier) @type + (typed_identifier + (identifier) @variable.member)?) + +(named_type + (identifier) @type .) + +[ + (builtin_type) + (primitive_type) +] @type.builtin + +((identifier) @type + (#lua-match? @type "^[A-Z][a-zA-Z0-9_]*$")) + +(type_identifier) @type + +; Constants +((identifier) @constant + (#lua-match? @constant "^[A-Z_][A-Z0-9_]*$")) + +(enum_variant + name: (identifier) @constant) + +(call_expression + function: (scoped_identifier + "::" + name: (identifier) @constant) + (#lua-match? @constant "^[A-Z]")) + +((match_arm + pattern: (match_pattern + (identifier) @constant)) + (#lua-match? @constant "^[A-Z]")) + +((match_arm + pattern: (match_pattern + (scoped_identifier + name: (identifier) @constant))) + (#lua-match? @constant "^[A-Z]")) + +((identifier) @constant.builtin + (#any-of? @constant.builtin "Some" "None" "Ok" "Err")) + +; Constructors +(unary_expression + "new" + (call_expression + . + (identifier) @constructor)) + +((call_expression + . + (identifier) @constructor) + (#lua-match? @constructor "^%u")) + +; Attributes +(decorator + "@" @attribute + (identifier) @attribute) + +(attribute_item + (identifier) @function.macro) + +(attribute_item + (scoped_identifier + (identifier) @function.macro .)) + +; Labels +(label + . + (identifier) @label) + +(inst_jmp_to_label + "jmp" + . + (identifier) @label) + +(inst_jnz_to_label + "jmp" + . + (identifier) @label) + +; Operators +[ + "+" + "-" + "*" + "/" + "**" + "==" + "!=" + "&" + "=" + "++" + "+=" + "@" + "!" + "~" + ".." + "&&" + "||" + "^" + "<" + "<=" + ">" + ">=" + "<<" + ">>" + "%" + "-=" + "*=" + "/=" + "%=" + "&=" + "|=" + "^=" + "<<=" + ">>=" + "?" +] @operator + +; Literals +(number) @number + +(boolean) @boolean + +[ + (string) + (short_string) +] @string + +; Punctuation +(attribute_item + "#" @punctuation.special) + +[ + "." + "," + ":" + ";" + "->" + "=>" + "::" +] @punctuation.delimiter + +[ + "{" + "}" + "(" + ")" + "[" + "]" + "%{" + "%}" +] @punctuation.bracket + +(type_parameters + [ + "<" + ">" + ] @punctuation.bracket) + +(type_arguments + [ + "<" + ">" + ] @punctuation.bracket) + +; Comment +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/cairo/indents.scm b/pack/ant/start/nvim-treesitter/queries/cairo/indents.scm new file mode 100644 index 0000000..f63ef36 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cairo/indents.scm @@ -0,0 +1,57 @@ +[ + (mod_item) + (struct_item) + (enum_item) + (impl_item) + (struct_expression) + (match_expression) + (tuple_expression) + (match_arm) + (match_block) + (call_expression) + (assignment_expression) + (arguments) + (block) + (use_list) + (field_declaration_list) + (enum_variant_list) + (tuple_pattern) +] @indent.begin + +(import_statement + "(") @indent.begin + +(block + "}" @indent.end) + +(enum_item + body: (enum_variant_list + "}" @indent.end)) + +(match_expression + body: (match_block + "}" @indent.end)) + +(mod_item + body: (declaration_list + "}" @indent.end)) + +(struct_item + body: (field_declaration_list + "}" @indent.end)) + +(trait_item + body: (declaration_list + "}" @indent.end)) + +[ + ")" + "]" + "}" +] @indent.branch + +[ + (comment) + (string) + (short_string) +] @indent.ignore diff --git a/pack/ant/start/nvim-treesitter/queries/cairo/injections.scm b/pack/ant/start/nvim-treesitter/queries/cairo/injections.scm new file mode 100644 index 0000000..fbb66be --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cairo/injections.scm @@ -0,0 +1,5 @@ +((python_code) @injection.content + (#set! injection.language "python")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/cairo/locals.scm b/pack/ant/start/nvim-treesitter/queries/cairo/locals.scm new file mode 100644 index 0000000..0573cf6 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cairo/locals.scm @@ -0,0 +1,66 @@ +; References +(identifier) @local.reference + +((type_identifier) @local.reference + (#set! reference.kind "type")) + +((field_identifier) @local.reference + (#set! reference.kind "field")) + +; Scopes +[ + (program) + (block) + (function_definition) + (loop_expression) + (if_expression) + (match_expression) + (match_arm) + (struct_item) + (enum_item) + (impl_item) +] @local.scope + +(use_declaration + argument: (scoped_identifier + name: (identifier) @local.definition.import)) + +(use_as_clause + alias: (identifier) @local.definition.import) + +(use_list + (identifier) @local.definition.import) ; use std::process::{Child, Command, Stdio}; + +; Functions +(function_definition + (identifier) @local.definition.function) + +(function_definition + (identifier) @local.definition.method + (parameter + (self))) + +; Function with parameters, defines parameters +(parameter + [ + (identifier) + (self) + ] @local.definition.parameter) + +; Types +(struct_item + name: (type_identifier) @local.definition.type) + +(constrained_type_parameter + left: (type_identifier) @local.definition.type) ; the P in remove_file>(path: P) + +(enum_item + name: (type_identifier) @local.definition.type) + +; Module +(mod_item + name: (identifier) @local.definition.namespace) + +; Variables +(assignment_expression + left: (identifier) @local.definition.var) diff --git a/pack/ant/start/nvim-treesitter/queries/capnp/folds.scm b/pack/ant/start/nvim-treesitter/queries/capnp/folds.scm new file mode 100644 index 0000000..6e3f9c1 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/capnp/folds.scm @@ -0,0 +1,14 @@ +[ + (annotation_targets) + (const_list) + (enum) + (interface) + (implicit_generics) + (generics) + (group) + (method_parameters) + (named_return_types) + (struct) + (struct_shorthand) + (union) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/capnp/highlights.scm b/pack/ant/start/nvim-treesitter/queries/capnp/highlights.scm new file mode 100644 index 0000000..a48c007 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/capnp/highlights.scm @@ -0,0 +1,141 @@ +; Preproc +[ + (unique_id) + (top_level_annotation_body) +] @keyword.directive + +; Includes +[ + "import" + "$import" + "embed" + "using" +] @keyword.import + +(import_path) @string.special.path + +; Keywords +"extends" @keyword + +[ + "struct" + "interface" + "union" + "enum" + "annotation" + "group" + "namespace" +] @keyword.type + +; Builtins +"const" @keyword.modifier + +[ + (primitive_type) + "List" +] @type.builtin + +; Typedefs +(type_definition) @type.definition + +; Labels (@number, @number!) +(field_version) @label + +; Methods +[ + (annotation_definition_identifier) + (method_identifier) +] @function.method + +; Fields +(field_identifier) @variable.member + +; Properties +(property) @property + +; Parameters +[ + (param_identifier) + (return_identifier) +] @variable.parameter + +(annotation_target) @variable.parameter.builtin + +; Constants +[ + (const_identifier) + (local_const) + (enum_member) +] @constant + +(void) @constant.builtin + +; Types +[ + (enum_identifier) + (extend_type) + (type_identifier) +] @type + +; Attributes +[ + (annotation_identifier) + (attribute) +] @attribute + +; Operators +"=" @operator + +; Literals +[ + (string) + (concatenated_string) + (block_text) + (namespace) +] @string + +(namespace) @string.special + +(escape_sequence) @string.escape + +(data_string) @string.special + +(number) @number + +(float) @number.float + +(boolean) @boolean + +(data_hex) @string.special.symbol + +; Punctuation +[ + "*" + "$" + ":" +] @punctuation.special + +[ + "{" + "}" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "." + "," + ";" + "->" +] @punctuation.delimiter + +; Comments +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/capnp/indents.scm b/pack/ant/start/nvim-treesitter/queries/capnp/indents.scm new file mode 100644 index 0000000..cc2f4d7 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/capnp/indents.scm @@ -0,0 +1,40 @@ +[ + (annotation_targets) + (const) + (enum) + (interface) + (implicit_generics) + (generics) + (group) + (method_parameters) + (named_return_types) + (struct) + (union) + (field) +] @indent.begin + +((struct_shorthand + (property)) @indent.align + (#set! indent.open_delimiter "(") + (#set! indent.close_delimiter ")")) + +((method + (field_version)) @indent.align + (#set! indent.open_delimiter field_version)) + +((const_list + (const_value)) @indent.align + (#set! indent.open_delimiter "[") + (#set! indent.close_delimiter "]")) + +(concatenated_string) @indent.align + +[ + "}" + ")" +] @indent.end @indent.branch + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/pack/ant/start/nvim-treesitter/queries/capnp/injections.scm b/pack/ant/start/nvim-treesitter/queries/capnp/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/capnp/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/capnp/locals.scm b/pack/ant/start/nvim-treesitter/queries/capnp/locals.scm new file mode 100644 index 0000000..d1f0cca --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/capnp/locals.scm @@ -0,0 +1,97 @@ +[ + (message) + (annotation_targets) + (const_list) + (enum) + (interface) + (implicit_generics) + (generics) + (group) + (method_parameters) + (named_return_types) + (struct) + (struct_shorthand) + (union) +] @local.scope + +[ + (extend_type) + (field_type) +] @local.reference + +(custom_type + (type_identifier) @local.reference) + +(custom_type + (generics + (generic_parameters + (generic_identifier) @local.reference))) + +(annotation_definition_identifier) @local.definition + +(const_identifier) @local.definition.constant + +(enum + (enum_identifier) @local.definition.enum) + +[ + (enum_member) + (field_identifier) +] @local.definition.field + +(method_identifier) @local.definition.method + +(namespace) @local.definition.namespace + +[ + (param_identifier) + (return_identifier) +] @local.definition.parameter + +(group + (type_identifier) @local.definition.type) + +(struct + (type_identifier) @local.definition.type) + +(union + (type_identifier) @local.definition.type) + +(interface + (type_identifier) @local.definition.type) + +; Generics Related (don't know how to combine these) +(struct + (generics + (generic_parameters + (generic_identifier) @local.definition.parameter))) + +(interface + (generics + (generic_parameters + (generic_identifier) @local.definition.parameter))) + +(method + (implicit_generics + (implicit_generic_parameters + (generic_identifier) @local.definition.parameter))) + +(method + (generics + (generic_parameters + (generic_identifier) @local.definition.parameter))) + +(annotation + (generics + (generic_parameters + (generic_identifier) @local.definition.type))) + +(replace_using + (generics + (generic_parameters + (generic_identifier) @local.definition.type))) + +(return_type + (generics + (generic_parameters + (generic_identifier) @local.definition.type))) diff --git a/pack/ant/start/nvim-treesitter/queries/chatito/folds.scm b/pack/ant/start/nvim-treesitter/queries/chatito/folds.scm new file mode 100644 index 0000000..052dd20 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/chatito/folds.scm @@ -0,0 +1,5 @@ +[ + (intent_def) + (slot_def) + (alias_def) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/chatito/highlights.scm b/pack/ant/start/nvim-treesitter/queries/chatito/highlights.scm new file mode 100644 index 0000000..47113f2 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/chatito/highlights.scm @@ -0,0 +1,54 @@ +; Punctuation +[ + "%[" + "@[" + "~[" + "*[" + "]" + "(" + ")" +] @punctuation.bracket + +"," @punctuation.delimiter + +(eq) @operator + +([ + "\"" + "'" +] @punctuation.special + (#set! conceal "")) + +[ + "%" + "?" + "#" +] @character.special + +; Entities +(intent) @module + +(slot) @type + +(variation) @attribute + +(alias) @keyword.directive + +(number) @number + +(argument + key: (string) @property + value: (string) @string) + +(escape) @string.escape + +; Import +"import" @keyword.import + +(file) @string.special.path + +; Text +(word) @spell + +; Comment +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/chatito/indents.scm b/pack/ant/start/nvim-treesitter/queries/chatito/indents.scm new file mode 100644 index 0000000..dc9e13d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/chatito/indents.scm @@ -0,0 +1,8 @@ +[ + (intent_def) + (slot_def) + (alias_def) +] @indent.begin + +(ERROR + "]") @indent.begin diff --git a/pack/ant/start/nvim-treesitter/queries/chatito/injections.scm b/pack/ant/start/nvim-treesitter/queries/chatito/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/chatito/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/chatito/locals.scm b/pack/ant/start/nvim-treesitter/queries/chatito/locals.scm new file mode 100644 index 0000000..827447f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/chatito/locals.scm @@ -0,0 +1,16 @@ +; Definitions +(intent_def + (intent) @local.definition) + +(slot_def + (slot) @local.definition) + +(alias_def + (alias) @local.definition) + +; References +(slot_ref + (slot) @local.reference) + +(alias_ref + (alias) @local.reference) diff --git a/pack/ant/start/nvim-treesitter/queries/clojure/folds.scm b/pack/ant/start/nvim-treesitter/queries/clojure/folds.scm new file mode 100644 index 0000000..eceb697 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/clojure/folds.scm @@ -0,0 +1,2 @@ +(source + (list_lit) @fold) diff --git a/pack/ant/start/nvim-treesitter/queries/clojure/highlights.scm b/pack/ant/start/nvim-treesitter/queries/clojure/highlights.scm new file mode 100644 index 0000000..2642766 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/clojure/highlights.scm @@ -0,0 +1,347 @@ +; >> Explanation +; Parsers for lisps are a bit weird in that they just return the raw forms. +; This means we have to do a bit of extra work in the queries to get things +; highlighted as they should be. +; +; For the most part this means that some things have to be assigned multiple +; groups. +; By doing this we can add a basic capture and then later refine it with more +; specialized captures. +; This can mean that sometimes things are highlighted weirdly because they +; have multiple highlight groups applied to them. +; >> Literals +((dis_expr) @comment + (#set! priority 105) + ; Higher priority to mark the whole sexpr as a comment + ) + +(kwd_lit) @string.special.symbol + +(str_lit) @string + +(num_lit) @number + +(char_lit) @character + +(bool_lit) @boolean + +(nil_lit) @constant.builtin + +(comment) @comment @spell + +(regex_lit) @string.regexp + +[ + "'" + "`" +] @string.escape + +[ + "~" + "~@" + "#" +] @punctuation.special + +[ + "{" + "}" + "[" + "]" + "(" + ")" +] @punctuation.bracket + +; >> Symbols +; General symbol highlighting +(sym_lit) @variable + +; General function calls +(list_lit + . + (sym_lit) @function.call) + +(anon_fn_lit + . + (sym_lit) @function.call) + +; Quoted symbols +(quoting_lit + (sym_lit) @string.special.symbol) + +(syn_quoting_lit + (sym_lit) @string.special.symbol) + +; Used in destructure pattern +((sym_lit) @variable.parameter + (#lua-match? @variable.parameter "^[&]")) + +; Inline function variables +((sym_lit) @variable.builtin + (#lua-match? @variable.builtin "^%%%d*$")) + +((sym_lit) @variable.builtin + (#eq? @variable.builtin "%&")) + +; Constructor +((sym_lit) @constructor + (#lua-match? @constructor "^-%>[^>].*")) + +; Builtin dynamic variables +((sym_lit) @variable.builtin + (#any-of? @variable.builtin + "*agent*" "*allow-unresolved-vars*" "*assert*" "*clojure-version*" "*command-line-args*" + "*compile-files*" "*compile-path*" "*compiler-options*" "*data-readers*" + "*default-data-reader-fn*" "*err*" "*file*" "*flush-on-newline*" "*fn-loader*" "*in*" + "*math-context*" "*ns*" "*out*" "*print-dup*" "*print-length*" "*print-level*" "*print-meta*" + "*print-namespace-maps*" "*print-readably*" "*read-eval*" "*reader-resolver*" "*source-path*" + "*suppress-read*" "*unchecked-math*" "*use-context-classloader*" "*verbose-defrecords*" + "*warn-on-reflection*")) + +; Builtin repl variables +((sym_lit) @variable.builtin + (#any-of? @variable.builtin "*1" "*2" "*3" "*e")) + +; Types +(sym_lit + name: (sym_name) @_name + (#lua-match? @_name "^[%u][^/%s]*$")) @type + +; Symbols with `.` but not `/` +(sym_lit + !namespace + name: (sym_name) @_name + (#lua-match? @_name "^[^.]+[.]")) @type + +; Interop +; (.instanceMember instance args*) +; (.instanceMember Classname args*) +((sym_lit + name: (sym_name) @_name) @function.method + (#lua-match? @_name "^%.[^-]")) + +; (.-instanceField instance) +((sym_name) @variable.member + (#lua-match? @variable.member "^%.%-%S*")) + +; Classname/staticField +(sym_lit + namespace: (sym_ns) @_namespace + (#lua-match? @_namespace "^[%u]%S*$")) @variable.member + +; (Classname/staticMethod args*) +(list_lit + . + (sym_lit + namespace: (sym_ns) @_namespace + (#lua-match? @_namespace "^%u")) @function.method) + +; TODO: Special casing for the `.` macro +; Operators +((sym_lit) @operator + (#any-of? @operator "*" "*'" "+" "+'" "-" "-'" "/" "<" "<=" ">" ">=" "=" "==")) + +((sym_lit) @keyword.operator + (#any-of? @keyword.operator "not" "not=" "and" "or")) + +; Definition functions +((sym_lit) @keyword + (#any-of? @keyword + "def" "defonce" "defrecord" "defmacro" "definline" "definterface" "defmulti" "defmethod" + "defstruct" "defprotocol" "deftype")) + +((sym_lit) @keyword + (#eq? @keyword "declare")) + +((sym_name) @keyword.coroutine + (#any-of? @keyword.coroutine + "alts!" "alts!!" "await" "await-for" "await1" "chan" "close!" "future" "go" "sync" "thread" + "timeout" "!" ">!!")) + +((sym_lit + name: (sym_name) @_keyword.function.name) @keyword.function + (#any-of? @_keyword.function.name "defn" "defn-" "fn" "fn*")) + +; Comment +((sym_lit) @comment + (#eq? @comment "comment")) + +; Conditionals +((sym_lit) @keyword.conditional + (#any-of? @keyword.conditional "case" "cond" "cond->" "cond->>" "condp")) + +((sym_lit) @keyword.conditional + (#any-of? @keyword.conditional "if" "if-let" "if-not" "if-some")) + +((sym_lit) @keyword.conditional + (#any-of? @keyword.conditional "when" "when-first" "when-let" "when-not" "when-some")) + +; Repeats +((sym_lit) @keyword.repeat + (#any-of? @keyword.repeat "doseq" "dotimes" "for" "loop" "recur" "while")) + +; Exception +((sym_lit) @keyword.exception + (#any-of? @keyword.exception "throw" "try" "catch" "finally")) + +; Includes +((sym_lit) @keyword.import + (#any-of? @keyword.import "ns" "import" "require" "use")) + +; Builtin macros +; TODO: Do all these items belong here? +((sym_lit + name: (sym_name) @function.macro) + (#any-of? @function.macro + "." ".." "->" "->>" "amap" "areduce" "as->" "assert" "binding" "bound-fn" "delay" "do" "dosync" + "doto" "extend-protocol" "extend-type" "gen-class" "gen-interface" "io!" "lazy-cat" "lazy-seq" + "let" "letfn" "locking" "memfn" "monitor-enter" "monitor-exit" "proxy" "proxy-super" "pvalues" + "refer-clojure" "reify" "set!" "some->" "some->>" "time" "unquote" "unquote-splicing" "var" + "vswap!" "with-bindings" "with-in-str" "with-loading-context" "with-local-vars" "with-open" + "with-out-str" "with-precision" "with-redefs")) + +; All builtin functions +; (->> (ns-publics *ns*) +; (keep (fn [[s v]] (when-not (:macro (meta v)) s))) +; sort +; clojure.pprint/pprint)) +; ...and then lots of manual filtering... +((sym_lit + name: (sym_name) @function.builtin) + (#any-of? @function.builtin + "->ArrayChunk" "->Eduction" "->Vec" "->VecNode" "->VecSeq" "-cache-protocol-fn" "-reset-methods" + "PrintWriter-on" "StackTraceElement->vec" "Throwable->map" "accessor" "aclone" "add-classpath" + "add-tap" "add-watch" "agent" "agent-error" "agent-errors" "aget" "alength" "alias" "all-ns" + "alter" "alter-meta!" "alter-var-root" "ancestors" "any?" "apply" "array-map" "aset" + "aset-boolean" "aset-byte" "aset-char" "aset-double" "aset-float" "aset-int" "aset-long" + "aset-short" "assoc" "assoc!" "assoc-in" "associative?" "atom" "bases" "bean" "bigdec" "bigint" + "biginteger" "bit-and" "bit-and-not" "bit-clear" "bit-flip" "bit-not" "bit-or" "bit-set" + "bit-shift-left" "bit-shift-right" "bit-test" "bit-xor" "boolean" "boolean-array" "boolean?" + "booleans" "bound-fn*" "bound?" "bounded-count" "butlast" "byte" "byte-array" "bytes" "bytes?" + "cast" "cat" "char" "char-array" "char-escape-string" "char-name-string" "char?" "chars" "chunk" + "chunk-append" "chunk-buffer" "chunk-cons" "chunk-first" "chunk-next" "chunk-rest" + "chunked-seq?" "class" "class?" "clear-agent-errors" "clojure-version" "coll?" "commute" "comp" + "comparator" "compare" "compare-and-set!" "compile" "complement" "completing" "concat" "conj" + "conj!" "cons" "constantly" "construct-proxy" "contains?" "count" "counted?" "create-ns" + "create-struct" "cycle" "dec" "dec'" "decimal?" "dedupe" "default-data-readers" "delay?" + "deliver" "denominator" "deref" "derive" "descendants" "destructure" "disj" "disj!" "dissoc" + "dissoc!" "distinct" "distinct?" "doall" "dorun" "double" "double-array" "eduction" "empty" + "empty?" "ensure" "ensure-reduced" "enumeration-seq" "error-handler" "error-mode" "eval" "even?" + "every-pred" "every?" "extend" "extenders" "extends?" "false?" "ffirst" "file-seq" "filter" + "filterv" "find" "find-keyword" "find-ns" "find-protocol-impl" "find-protocol-method" "find-var" + "first" "flatten" "float" "float-array" "float?" "floats" "flush" "fn?" "fnext" "fnil" "force" + "format" "frequencies" "future-call" "future-cancel" "future-cancelled?" "future-done?" + "future?" "gensym" "get" "get-in" "get-method" "get-proxy-class" "get-thread-bindings" + "get-validator" "group-by" "halt-when" "hash" "hash-combine" "hash-map" "hash-ordered-coll" + "hash-set" "hash-unordered-coll" "ident?" "identical?" "identity" "ifn?" "in-ns" "inc" "inc'" + "indexed?" "init-proxy" "inst-ms" "inst-ms*" "inst?" "instance?" "int" "int-array" "int?" + "integer?" "interleave" "intern" "interpose" "into" "into-array" "ints" "isa?" "iterate" + "iterator-seq" "juxt" "keep" "keep-indexed" "key" "keys" "keyword" "keyword?" "last" "line-seq" + "list" "list*" "list?" "load" "load-file" "load-reader" "load-string" "loaded-libs" "long" + "long-array" "longs" "macroexpand" "macroexpand-1" "make-array" "make-hierarchy" "map" + "map-entry?" "map-indexed" "map?" "mapcat" "mapv" "max" "max-key" "memoize" "merge" "merge-with" + "meta" "method-sig" "methods" "min" "min-key" "mix-collection-hash" "mod" "munge" "name" + "namespace" "namespace-munge" "nat-int?" "neg-int?" "neg?" "newline" "next" "nfirst" "nil?" + "nnext" "not-any?" "not-empty" "not-every?" "ns-aliases" "ns-imports" "ns-interns" "ns-map" + "ns-name" "ns-publics" "ns-refers" "ns-resolve" "ns-unalias" "ns-unmap" "nth" "nthnext" + "nthrest" "num" "number?" "numerator" "object-array" "odd?" "parents" "partial" "partition" + "partition-all" "partition-by" "pcalls" "peek" "persistent!" "pmap" "pop" "pop!" + "pop-thread-bindings" "pos-int?" "pos?" "pr" "pr-str" "prefer-method" "prefers" + "primitives-classnames" "print" "print-ctor" "print-dup" "print-method" "print-simple" + "print-str" "printf" "println" "println-str" "prn" "prn-str" "promise" "proxy-call-with-super" + "proxy-mappings" "proxy-name" "push-thread-bindings" "qualified-ident?" "qualified-keyword?" + "qualified-symbol?" "quot" "rand" "rand-int" "rand-nth" "random-sample" "range" "ratio?" + "rational?" "rationalize" "re-find" "re-groups" "re-matcher" "re-matches" "re-pattern" "re-seq" + "read" "read+string" "read-line" "read-string" "reader-conditional" "reader-conditional?" + "realized?" "record?" "reduce" "reduce-kv" "reduced" "reduced?" "reductions" "ref" + "ref-history-count" "ref-max-history" "ref-min-history" "ref-set" "refer" + "release-pending-sends" "rem" "remove" "remove-all-methods" "remove-method" "remove-ns" + "remove-tap" "remove-watch" "repeat" "repeatedly" "replace" "replicate" "requiring-resolve" + "reset!" "reset-meta!" "reset-vals!" "resolve" "rest" "restart-agent" "resultset-seq" "reverse" + "reversible?" "rseq" "rsubseq" "run!" "satisfies?" "second" "select-keys" "send" "send-off" + "send-via" "seq" "seq?" "seqable?" "seque" "sequence" "sequential?" "set" + "set-agent-send-executor!" "set-agent-send-off-executor!" "set-error-handler!" "set-error-mode!" + "set-validator!" "set?" "short" "short-array" "shorts" "shuffle" "shutdown-agents" + "simple-ident?" "simple-keyword?" "simple-symbol?" "slurp" "some" "some-fn" "some?" "sort" + "sort-by" "sorted-map" "sorted-map-by" "sorted-set" "sorted-set-by" "sorted?" "special-symbol?" + "spit" "split-at" "split-with" "str" "string?" "struct" "struct-map" "subs" "subseq" "subvec" + "supers" "swap!" "swap-vals!" "symbol" "symbol?" "tagged-literal" "tagged-literal?" "take" + "take-last" "take-nth" "take-while" "tap>" "test" "the-ns" "thread-bound?" "to-array" + "to-array-2d" "trampoline" "transduce" "transient" "tree-seq" "true?" "type" "unchecked-add" + "unchecked-add-int" "unchecked-byte" "unchecked-char" "unchecked-dec" "unchecked-dec-int" + "unchecked-divide-int" "unchecked-double" "unchecked-float" "unchecked-inc" "unchecked-inc-int" + "unchecked-int" "unchecked-long" "unchecked-multiply" "unchecked-multiply-int" + "unchecked-negate" "unchecked-negate-int" "unchecked-remainder-int" "unchecked-short" + "unchecked-subtract" "unchecked-subtract-int" "underive" "unquote" "unquote-splicing" + "unreduced" "unsigned-bit-shift-right" "update" "update-in" "update-proxy" "uri?" "uuid?" "val" + "vals" "var-get" "var-set" "var?" "vary-meta" "vec" "vector" "vector-of" "vector?" "volatile!" + "volatile?" "vreset!" "with-bindings*" "with-meta" "with-redefs-fn" "xml-seq" "zero?" "zipmap" + ; earlier + "drop" "drop-last" "drop-while" "double?" "doubles" "ex-data" "ex-info" + ; 1.10 + "ex-cause" "ex-message" + ; 1.11 + "NaN?" "abs" "infinite?" "iteration" "random-uuid" "parse-boolean" "parse-double" "parse-long" + "parse-uuid" "seq-to-map-for-destructuring" "update-keys" "update-vals" + ; 1.12 + "partitionv" "partitionv-all" "splitv-at")) + +; >> Context based highlighting +; def-likes +; Correctly highlight docstrings +;(list_lit +;. +;(sym_lit) @_keyword ; Don't really want to highlight twice +;(#any-of? @_keyword +;"def" "defonce" "defrecord" "defmacro" "definline" +;"defmulti" "defmethod" "defstruct" "defprotocol" +;"deftype") +;. +;(sym_lit) +;. +; TODO: Add @comment highlight +;(str_lit)? +;. +;(_)) +; Function definitions +(list_lit + . + ((sym_lit + name: (sym_name) @_keyword.function.name) + (#any-of? @_keyword.function.name "defn" "defn-" "fn" "fn*")) + . + (sym_lit)? @function + . + ; TODO: Add @comment highlight + (str_lit)?) + +; TODO: Fix parameter highlighting +; I think there's a bug here in nvim-treesitter +; TODO: Reproduce bug and file ticket +;. +;[(vec_lit +; (sym_lit)* @variable.parameter) +; (list_lit +; (vec_lit +; (sym_lit)* @variable.parameter))]) +;[((list_lit +; (vec_lit +; (sym_lit) @variable.parameter) +; (_) +; + +; ((vec_lit +; (sym_lit) @variable.parameter) +; (_))) +; Meta punctuation +; NOTE: When the above `Function definitions` query captures the +; the @function it also captures the child meta_lit +; We capture the meta_lit symbol (^) after so that the later +; highlighting overrides the former +"^" @punctuation.special + +; namespaces +(list_lit + . + (sym_lit) @_include + (#eq? @_include "ns") + . + (sym_lit) @module) diff --git a/pack/ant/start/nvim-treesitter/queries/clojure/injections.scm b/pack/ant/start/nvim-treesitter/queries/clojure/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/clojure/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/clojure/locals.scm b/pack/ant/start/nvim-treesitter/queries/clojure/locals.scm new file mode 100644 index 0000000..e47adce --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/clojure/locals.scm @@ -0,0 +1 @@ +; placeholder file to get incremental selection to work diff --git a/pack/ant/start/nvim-treesitter/queries/cmake/folds.scm b/pack/ant/start/nvim-treesitter/queries/cmake/folds.scm new file mode 100644 index 0000000..ef153b9 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cmake/folds.scm @@ -0,0 +1,8 @@ +[ + (if_condition) + (foreach_loop) + (while_loop) + (function_def) + (macro_def) + (block_def) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/cmake/highlights.scm b/pack/ant/start/nvim-treesitter/queries/cmake/highlights.scm new file mode 100644 index 0000000..fbbf0d5 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cmake/highlights.scm @@ -0,0 +1,221 @@ +(normal_command + (identifier) + (argument_list + (argument + (unquoted_argument)) @constant) + (#lua-match? @constant "^[%u@][%u%d_]+$")) + +[ + (quoted_argument) + (bracket_argument) +] @string + +(variable_ref) @none + +(variable) @variable + +[ + (bracket_comment) + (line_comment) +] @comment @spell + +(normal_command + (identifier) @function) + +[ + "ENV" + "CACHE" +] @module + +[ + "$" + "{" + "}" +] @punctuation.special + +[ + "(" + ")" +] @punctuation.bracket + +[ + (function) + (endfunction) + (macro) + (endmacro) +] @keyword.function + +[ + (if) + (elseif) + (else) + (endif) +] @keyword.conditional + +[ + (foreach) + (endforeach) + (while) + (endwhile) +] @keyword.repeat + +(normal_command + (identifier) @keyword.repeat + (#match? @keyword.repeat "\\c^(continue|break)$")) + +(normal_command + (identifier) @keyword.return + (#match? @keyword.return "\\c^return$")) + +(function_command + (function) + (argument_list + . + (argument) @function + (argument)* @variable.parameter)) + +(macro_command + (macro) + (argument_list + . + (argument) @function.macro + (argument)* @variable.parameter)) + +(block_def + (block_command + (block) @function.builtin + (argument_list + (argument + (unquoted_argument) @constant)) + (#any-of? @constant "SCOPE_FOR" "POLICIES" "VARIABLES" "PROPAGATE")) + (endblock_command + (endblock) @function.builtin)) + +; +((argument) @boolean + (#match? @boolean "\\c^(1|on|yes|true|y|0|off|no|false|n|ignore|notfound|.*-notfound)$")) + +; +(if_command + (if) + (argument_list + (argument) @keyword.operator) + (#any-of? @keyword.operator + "NOT" "AND" "OR" "COMMAND" "POLICY" "TARGET" "TEST" "DEFINED" "IN_LIST" "EXISTS" "IS_NEWER_THAN" + "IS_DIRECTORY" "IS_SYMLINK" "IS_ABSOLUTE" "MATCHES" "LESS" "GREATER" "EQUAL" "LESS_EQUAL" + "GREATER_EQUAL" "STRLESS" "STRGREATER" "STREQUAL" "STRLESS_EQUAL" "STRGREATER_EQUAL" + "VERSION_LESS" "VERSION_GREATER" "VERSION_EQUAL" "VERSION_LESS_EQUAL" "VERSION_GREATER_EQUAL")) + +(elseif_command + (elseif) + (argument_list + (argument) @keyword.operator) + (#any-of? @keyword.operator + "NOT" "AND" "OR" "COMMAND" "POLICY" "TARGET" "TEST" "DEFINED" "IN_LIST" "EXISTS" "IS_NEWER_THAN" + "IS_DIRECTORY" "IS_SYMLINK" "IS_ABSOLUTE" "MATCHES" "LESS" "GREATER" "EQUAL" "LESS_EQUAL" + "GREATER_EQUAL" "STRLESS" "STRGREATER" "STREQUAL" "STRLESS_EQUAL" "STRGREATER_EQUAL" + "VERSION_LESS" "VERSION_GREATER" "VERSION_EQUAL" "VERSION_LESS_EQUAL" "VERSION_GREATER_EQUAL")) + +(normal_command + (identifier) @function.builtin + (#match? @function.builtin + "\\c^(cmake_host_system_information|cmake_language|cmake_minimum_required|cmake_parse_arguments|cmake_path|cmake_policy|configure_file|execute_process|file|find_file|find_library|find_package|find_path|find_program|foreach|get_cmake_property|get_directory_property|get_filename_component|get_property|include|include_guard|list|macro|mark_as_advanced|math|message|option|separate_arguments|set|set_directory_properties|set_property|site_name|string|unset|variable_watch|add_compile_definitions|add_compile_options|add_custom_command|add_custom_target|add_definitions|add_dependencies|add_executable|add_library|add_link_options|add_subdirectory|add_test|aux_source_directory|build_command|create_test_sourcelist|define_property|enable_language|enable_testing|export|fltk_wrap_ui|get_source_file_property|get_target_property|get_test_property|include_directories|include_external_msproject|include_regular_expression|install|link_directories|link_libraries|load_cache|project|remove_definitions|set_source_files_properties|set_target_properties|set_tests_properties|source_group|target_compile_definitions|target_compile_features|target_compile_options|target_include_directories|target_link_directories|target_link_libraries|target_link_options|target_precompile_headers|target_sources|try_compile|try_run|ctest_build|ctest_configure|ctest_coverage|ctest_empty_binary_directory|ctest_memcheck|ctest_read_custom_files|ctest_run_script|ctest_sleep|ctest_start|ctest_submit|ctest_test|ctest_update|ctest_upload)$")) + +(normal_command + (identifier) @_function + (argument_list + . + (argument) @variable) + (#match? @_function "\\c^set$")) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^set$") + (argument_list + . + (argument) + ((argument) @_cache @keyword.modifier + . + (argument) @_type @type + (#any-of? @_cache "CACHE") + (#any-of? @_type "BOOL" "FILEPATH" "PATH" "STRING" "INTERNAL")))) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^unset$") + (argument_list + . + (argument) + (argument) @keyword.modifier + (#any-of? @keyword.modifier "CACHE" "PARENT_SCOPE"))) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^list$") + (argument_list + . + (argument) @constant + (#any-of? @constant "LENGTH" "GET" "JOIN" "SUBLIST" "FIND") + . + (argument) @variable + (argument) @variable .)) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^list$") + (argument_list + . + (argument) @constant + . + (argument) @variable + (#any-of? @constant + "APPEND" "FILTER" "INSERT" "POP_BACK" "POP_FRONT" "PREPEND" "REMOVE_ITEM" "REMOVE_AT" + "REMOVE_DUPLICATES" "REVERSE" "SORT"))) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^list$") + (argument_list + . + (argument) @_transform @constant + . + (argument) @variable + . + (argument) @_action @constant + (#eq? @_transform "TRANSFORM") + (#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE"))) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^list$") + (argument_list + . + (argument) @_transform @constant + . + (argument) @variable + . + (argument) @_action @constant + . + (argument)? @_selector @constant + (#eq? @_transform "TRANSFORM") + (#any-of? @_action "APPEND" "PREPEND" "TOUPPER" "TOLOWER" "STRIP" "GENEX_STRIP" "REPLACE") + (#any-of? @_selector "AT" "FOR" "REGEX"))) + +(normal_command + (identifier) @_function + (#match? @_function "\\c^list$") + (argument_list + . + (argument) @_transform @constant + (argument) @constant + . + (argument) @variable + (#eq? @_transform "TRANSFORM") + (#eq? @constant "OUTPUT_VARIABLE"))) + +(escape_sequence) @string.escape + +((source_file + . + (line_comment) @keyword.directive @nospell) + (#lua-match? @keyword.directive "^#!/")) diff --git a/pack/ant/start/nvim-treesitter/queries/cmake/indents.scm b/pack/ant/start/nvim-treesitter/queries/cmake/indents.scm new file mode 100644 index 0000000..cbd976c --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cmake/indents.scm @@ -0,0 +1,26 @@ +[ + (normal_command) + (if_condition) + (foreach_loop) + (while_loop) + (function_def) + (macro_def) + (block_def) +] @indent.begin + +[ + (elseif_command) + (else_command) + (endif_command) + (endforeach_command) + (endwhile_command) + (endfunction_command) + (endmacro_command) + (endblock_command) +] @indent.branch + +")" @indent.branch + +")" @indent.end + +(argument_list) @indent.auto diff --git a/pack/ant/start/nvim-treesitter/queries/cmake/injections.scm b/pack/ant/start/nvim-treesitter/queries/cmake/injections.scm new file mode 100644 index 0000000..eb8e215 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cmake/injections.scm @@ -0,0 +1,5 @@ +([ + (bracket_comment) + (line_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/comment/highlights.scm b/pack/ant/start/nvim-treesitter/queries/comment/highlights.scm new file mode 100644 index 0000000..5d18b79 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/comment/highlights.scm @@ -0,0 +1,49 @@ +((tag + (name) @comment.todo @nospell + ("(" @punctuation.bracket + (user) @constant + ")" @punctuation.bracket)? + ":" @punctuation.delimiter) + (#any-of? @comment.todo "TODO" "WIP")) + +("text" @comment.todo @nospell + (#any-of? @comment.todo "TODO" "WIP")) + +((tag + (name) @comment.note @nospell + ("(" @punctuation.bracket + (user) @constant + ")" @punctuation.bracket)? + ":" @punctuation.delimiter) + (#any-of? @comment.note "NOTE" "XXX" "INFO" "DOCS" "PERF" "TEST")) + +("text" @comment.note @nospell + (#any-of? @comment.note "NOTE" "XXX" "INFO" "DOCS" "PERF" "TEST")) + +((tag + (name) @comment.warning @nospell + ("(" @punctuation.bracket + (user) @constant + ")" @punctuation.bracket)? + ":" @punctuation.delimiter) + (#any-of? @comment.warning "HACK" "WARNING" "WARN" "FIX")) + +("text" @comment.warning @nospell + (#any-of? @comment.warning "HACK" "WARNING" "WARN" "FIX")) + +((tag + (name) @comment.error @nospell + ("(" @punctuation.bracket + (user) @constant + ")" @punctuation.bracket)? + ":" @punctuation.delimiter) + (#any-of? @comment.error "FIXME" "BUG" "ERROR")) + +("text" @comment.error @nospell + (#any-of? @comment.error "FIXME" "BUG" "ERROR")) + +; Issue number (#123) +("text" @number + (#lua-match? @number "^#[0-9]+$")) + +(uri) @string.special.url @nospell diff --git a/pack/ant/start/nvim-treesitter/queries/commonlisp/folds.scm b/pack/ant/start/nvim-treesitter/queries/commonlisp/folds.scm new file mode 100644 index 0000000..eceb697 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/commonlisp/folds.scm @@ -0,0 +1,2 @@ +(source + (list_lit) @fold) diff --git a/pack/ant/start/nvim-treesitter/queries/commonlisp/highlights.scm b/pack/ant/start/nvim-treesitter/queries/commonlisp/highlights.scm new file mode 100644 index 0000000..7236c84 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/commonlisp/highlights.scm @@ -0,0 +1,315 @@ +(sym_lit) @variable + +; A highlighting for functions/macros in th cl namespace is available in theHamsta/nvim-treesitter-commonlisp +;(list_lit . (sym_lit) @function.builtin (#cl-standard-function? @function.builtin)) +;(list_lit . (sym_lit) @function.builtin (#cl-standard-macro? @function.macro)) +(dis_expr) @comment + +(defun_keyword) @function.macro + +(defun_header + function_name: (_) @function) + +(defun_header + lambda_list: (list_lit + (sym_lit) @variable.parameter)) + +(defun_header + keyword: (defun_keyword + "defmethod") + lambda_list: (list_lit + (list_lit + . + (sym_lit) + . + (sym_lit) @string.special.symbol))) + +(defun_header + lambda_list: (list_lit + (list_lit + . + (sym_lit) @variable.parameter + . + (_)))) + +(defun_header + specifier: (sym_lit) @string.special.symbol) + +[ + ":" + "::" + "." +] @punctuation.special + +[ + (accumulation_verb) + (for_clause_word) + "for" + "and" + "finally" + "thereis" + "always" + "when" + "if" + "unless" + "else" + "do" + "loop" + "below" + "in" + "from" + "across" + "repeat" + "being" + "into" + "with" + "as" + "while" + "until" + "return" + "initially" +] @function.macro + +"=" @operator + +(include_reader_macro) @string.special.symbol + +[ + "#C" + "#c" +] @number + +[ + (kwd_lit) + (self_referential_reader_macro) +] @string.special.symbol + +(package_lit + package: (_) @module) + +"cl" @module + +(str_lit) @string + +(num_lit) @number + +((sym_lit) @boolean + (#any-of? @boolean "t" "T")) + +(nil_lit) @constant.builtin + +(comment) @comment @spell + +; dynamic variables +((sym_lit) @variable.builtin + (#lua-match? @variable.builtin "^[*].+[*]$")) + +; quote +(format_specifier) @string.escape + +(quoting_lit + "'" @string.escape) + +(syn_quoting_lit + "`" @string.escape) + +(unquoting_lit + "," @string.escape) + +(unquote_splicing_lit + ",@" @string.escape) + +[ + "(" + ")" +] @punctuation.bracket + +(block_comment) @comment @spell + +(with_clause + type: (_) @type) + +(for_clause + type: (_) @type) + +; defun-like things +(list_lit + . + (sym_lit) @function.macro + . + (sym_lit) @function + (#eq? @function.macro "deftest")) + +; Macros and Special Operators +(list_lit + . + (sym_lit) @function.macro + ; Generated via https://github.com/theHamsta/nvim-treesitter-commonlisp/blob/22fdc9fd6ed594176cc7299cc6f68dd21c94c63b/scripts/generate-symbols.lisp#L1-L21 + (#any-of? @function.macro + "do*" "step" "handler-bind" "decf" "prog1" "destructuring-bind" "defconstant" "do" "lambda" + "with-standard-io-syntax" "case" "restart-bind" "ignore-errors" "with-slots" "prog2" "defclass" + "define-condition" "print-unreadable-object" "defvar" "when" "with-open-file" "prog" "incf" + "declaim" "and" "loop-finish" "multiple-value-bind" "pop" "psetf" "defmacro" "with-open-stream" + "define-modify-macro" "defsetf" "formatter" "call-method" "handler-case" "pushnew" "or" + "with-hash-table-iterator" "ecase" "cond" "defun" "remf" "ccase" "define-compiler-macro" + "dotimes" "multiple-value-list" "assert" "deftype" "with-accessors" "trace" + "with-simple-restart" "do-symbols" "nth-value" "define-symbol-macro" "psetq" "rotatef" "dolist" + "check-type" "multiple-value-setq" "push" "pprint-pop" "loop" "define-setf-expander" + "pprint-exit-if-list-exhausted" "with-condition-restarts" "defstruct" "with-input-from-string" + "with-compilation-unit" "defgeneric" "with-output-to-string" "untrace" "defparameter" + "ctypecase" "do-external-symbols" "etypecase" "do-all-symbols" "with-package-iterator" "unless" + "defmethod" "in-package" "defpackage" "return" "typecase" "shiftf" "setf" "pprint-logical-block" + "time" "restart-case" "prog*" "define-method-combination" "optimize")) + +; constant +((sym_lit) @constant + (#lua-match? @constant "^[+].+[+]$")) + +(var_quoting_lit + marker: "#'" @string.special.symbol + value: (_) @string.special.symbol) + +[ + "#" + "#p" + "#P" +] @string.special.symbol + +(list_lit + . + (sym_lit) @function.builtin + ; Generated via https://github.com/theHamsta/nvim-treesitter-commonlisp/blob/22fdc9fd6ed594176cc7299cc6f68dd21c94c63b/scripts/generate-symbols.lisp#L1-L21 + (#any-of? @function.builtin + "apropos-list" "subst" "substitute" "pprint-linear" "file-namestring" "write-char" "do*" + "slot-exists-p" "file-author" "macro-function" "rassoc" "make-echo-stream" + "arithmetic-error-operation" "position-if-not" "list" "cdadr" "lisp-implementation-type" + "vector-push" "let" "length" "string-upcase" "adjoin" "digit-char" "step" "member-if" + "handler-bind" "lognot" "apply" "gcd" "slot-unbound" "stringp" "values-list" "stable-sort" + "decode-float" "make-list" "rplaca" "isqrt" "export" "synonym-stream-symbol" "function-keywords" + "replace" "tanh" "maphash" "code-char" "decf" "array-displacement" "string-not-lessp" + "slot-value" "remove-if" "cell-error-name" "vectorp" "cdddar" "two-way-stream-output-stream" + "parse-integer" "get-internal-real-time" "fourth" "make-string" "slot-missing" "byte-size" + "string-trim" "nstring-downcase" "cdaddr" "<" "labels" "interactive-stream-p" "fifth" "max" + "logxor" "pathname-name" "function" "realp" "eql" "logand" "short-site-name" "prog1" + "user-homedir-pathname" "list-all-packages" "exp" "cadar" "read-char-no-hang" + "package-error-package" "stream-external-format" "bit-andc2" "nsubstitute-if" "mapcar" + "complement" "load-logical-pathname-translations" "pprint-newline" "oddp" "caaar" + "destructuring-bind" "copy-alist" "acos" "go" "bit-nor" "defconstant" "fceiling" "tenth" + "nreverse" "=" "nunion" "slot-boundp" "string>" "count-if" "atom" "char=" "random-state-p" + "row-major-aref" "bit-andc1" "translate-pathname" "simple-vector-p" "coerce" "substitute-if-not" + "zerop" "invalid-method-error" "compile" "realpart" "remove-if-not" "pprint-tab" + "hash-table-rehash-threshold" "invoke-restart" "if" "count" "/=" "do" "initialize-instance" + "abs" "schar" "simple-condition-format-control" "delete-package" "subst-if" "lambda" + "hash-table-count" "array-has-fill-pointer-p" "bit" "with-standard-io-syntax" "parse-namestring" + "proclaim" "array-in-bounds-p" "multiple-value-call" "rplacd" "some" "graphic-char-p" + "read-from-string" "consp" "cadaar" "acons" "every" "make-pathname" "mask-field" "case" + "set-macro-character" "bit-and" "restart-bind" "echo-stream-input-stream" "compile-file" + "fill-pointer" "numberp" "acosh" "array-dimensions" "documentation" "minusp" "inspect" + "copy-structure" "integer-length" "ensure-generic-function" "char>=" "quote" "lognor" + "make-two-way-stream" "ignore-errors" "tailp" "with-slots" "fboundp" + "logical-pathname-translations" "equal" "float-sign" "shadow" "sleep" "numerator" "prog2" "getf" + "ldb-test" "round" "locally" "echo-stream-output-stream" "log" "get-macro-character" + "alphanumericp" "find-method" "nintersection" "defclass" "define-condition" + "print-unreadable-object" "defvar" "broadcast-stream-streams" "floatp" "subst-if-not" "integerp" + "translate-logical-pathname" "subsetp" "when" "write-string" "with-open-file" "clrhash" + "apropos" "intern" "min" "string-greaterp" "import" "nset-difference" "prog" "incf" + "both-case-p" "multiple-value-prog1" "characterp" "streamp" "digit-char-p" "random" + "string-lessp" "make-string-input-stream" "copy-symbol" "read-sequence" "logcount" "bit-not" + "boundp" "encode-universal-time" "third" "declaim" "map" "cons" "set-syntax-from-char" "and" + "cis" "symbol-plist" "loop-finish" "standard-char-p" "multiple-value-bind" "asin" "string" "pop" + "complex" "fdefinition" "psetf" "type-error-datum" "output-stream-p" "floor" "write-line" "<=" + "defmacro" "rational" "hash-table-test" "with-open-stream" "read-char" "string-capitalize" + "get-properties" "y-or-n-p" "use-package" "remove" "compiler-macro-function" "read" + "package-nicknames" "remove-duplicates" "make-load-form-saving-slots" "dribble" + "define-modify-macro" "make-dispatch-macro-character" "close" "cosh" "open" "finish-output" + "string-downcase" "car" "nstring-capitalize" "software-type" "read-preserving-whitespace" "cadr" + "fround" "nsublis" "defsetf" "find-all-symbols" "char>" "no-applicable-method" + "compute-restarts" "pathname" "bit-orc2" "write-sequence" "pprint-tabular" "symbol-value" + "char-name" "get-decoded-time" "formatter" "bit-vector-p" "intersection" "pathname-type" + "clear-input" "call-method" "princ-to-string" "symbolp" "make-load-form" "nsubst" + "pprint-dispatch" "handler-case" "method-combination-error" "probe-file" "atan" "string<" + "type-error-expected-type" "pushnew" "unread-char" "print" "or" "with-hash-table-iterator" + "make-sequence" "ecase" "unwind-protect" "require" "sixth" "get-dispatch-macro-character" + "char-not-lessp" "read-byte" "tagbody" "file-error-pathname" "catch" "rationalp" "char-downcase" + "char-int" "array-rank" "cond" "last" "make-string-output-stream" "array-dimension" + "host-namestring" "input-stream-p" "decode-universal-time" "defun" "eval-when" "char-code" + "pathname-directory" "evenp" "subseq" "pprint" "ftruncate" "make-instance" "pathname-host" + "logbitp" "remf" "1+" "copy-pprint-dispatch" "char-upcase" "error" "read-line" "second" + "make-package" "directory" "special-operator-p" "open-stream-p" "rassoc-if-not" "ccase" "equalp" + "substitute-if" "*" "char/=" "cdr" "sqrt" "lcm" "logical-pathname" "eval" + "define-compiler-macro" "nsubstitute-if-not" "mapcon" "imagpart" "set-exclusive-or" + "simple-condition-format-arguments" "expt" "concatenate" "file-position" "macrolet" "keywordp" + "hash-table-rehash-size" "+" "eighth" "use-value" "char-equal" "bit-xor" "format" "byte" + "dotimes" "namestring" "char-not-equal" "multiple-value-list" "assert" "append" "notany" "typep" + "delete-file" "makunbound" "cdaar" "file-write-date" ">" "cdddr" "write-to-string" "funcall" + "member-if-not" "deftype" "readtable-case" "with-accessors" "truename" "constantp" "rassoc-if" + "caaadr" "tree-equal" "nset-exclusive-or" "nsubstitute" "make-instances-obsolete" + "package-use-list" "invoke-debugger" "provide" "count-if-not" "trace" "logandc1" "nthcdr" + "char<=" "functionp" "with-simple-restart" "set-dispatch-macro-character" "logorc2" "unexport" + "rest" "unbound-slot-instance" "make-hash-table" "hash-table-p" "reinitialize-instance" "nth" + "do-symbols" "nreconc" "macroexpand" "store-value" "float-precision" "remprop" "nth-value" + "define-symbol-macro" "update-instance-for-redefined-class" "identity" "progv" "progn" + "return-from" "readtablep" "rem" "symbol-name" "psetq" "wild-pathname-p" "char" "list*" "char<" + "plusp" "pairlis" "cddar" "pprint-indent" "union" "compiled-function-p" "rotatef" "abort" + "machine-type" "concatenated-stream-streams" "string-right-trim" "enough-namestring" + "arithmetic-error-operands" "ceiling" "dolist" "delete" "make-condition" "string-left-trim" + "integer-decode-float" "check-type" "notevery" "function-lambda-expression" "-" + "multiple-value-setq" "name-char" "push" "pprint-pop" "compile-file-pathname" "list-length" + "nstring-upcase" "eq" "find-if" "method-qualifiers" "caadr" "cddr" "string=" "let*" + "remove-method" "pathname-match-p" "find-package" "truncate" "caaddr" "get-setf-expansion" + "loop" "define-setf-expander" "caddr" "package-shadowing-symbols" "force-output" + "slot-makunbound" "string-not-greaterp" "cdadar" "cdaadr" "logandc2" "make-array" + "merge-pathnames" "sin" "1-" "machine-version" "ffloor" "packagep" "set-pprint-dispatch" "flet" + "gensym" "pprint-exit-if-list-exhausted" "cos" "get" "mapl" "delete-if" + "with-condition-restarts" "atanh" "copy-list" "fill" "char-not-greaterp" "bit-orc1" "mod" + "package-used-by-list" "warn" "add-method" "simple-string-p" "find-restart" "describe" + "pathname-version" "peek-char" "yes-or-no-p" "complexp" "aref" "not" "position-if" "string>=" + "defstruct" "float-radix" "ninth" "caadar" "subtypep" "set" "butlast" "allocate-instance" + "with-input-from-string" "assoc" "write" "make-random-state" "bit-eqv" "float-digits" + "long-site-name" "with-compilation-unit" "delete-duplicates" "make-symbol" "room" "cdar" + "pprint-fill" "defgeneric" "macroexpand-1" "scale-float" "cdaaar" + "update-instance-for-different-class" "array-row-major-index" "ed" "file-string-length" + "ensure-directories-exist" "copy-readtable" "string<=" "seventh" "with-output-to-string" + "signum" "elt" "untrace" "null" "defparameter" "block" "prin1" "revappend" "gentemp" "ctypecase" + "ash" "sxhash" "listp" "do-external-symbols" "bit-ior" "etypecase" "sort" "change-class" + "find-class" "alpha-char-p" "map-into" "terpri" "do-all-symbols" "ldb" "logorc1" "search" + "fmakunbound" "load" "character" "string-not-equal" "pathnamep" "make-broadcast-stream" "arrayp" + "mapcan" "cerror" "invoke-restart-interactively" "assoc-if-not" "with-package-iterator" + "get-internal-run-time" "read-delimited-list" "unless" "lower-case-p" "restart-name" "/" "boole" + "defmethod" "float" "software-version" "vector-pop" "vector-push-extend" "caar" "ldiff" "member" + "find-symbol" "reduce" "svref" "describe-object" "logior" "string-equal" "type-of" "position" + "cddadr" "pathname-device" "get-output-stream-string" "symbol-package" "tan" + "compute-applicable-methods" "cddddr" "nsubst-if-not" "sublis" "set-difference" + "two-way-stream-input-stream" "adjustable-array-p" "machine-instance" "signal" "conjugate" + "caaaar" "endp" "lisp-implementation-version" "cddaar" "package-name" "adjust-array" "bit-nand" + "gethash" "in-package" "symbol-function" "make-concatenated-stream" "defpackage" "class-of" + "no-next-method" "logeqv" "deposit-field" "disassemble" "unuse-package" "copy-tree" "find" + "asinh" "class-name" "rename-file" "values" "print-not-readable-object" "mismatch" "cadadr" + "shadowing-import" "delete-if-not" "maplist" "listen" "return" "stream-element-type" "unintern" + "merge" "make-synonym-stream" "prin1-to-string" "nsubst-if" "byte-position" "phase" + "muffle-warning" "remhash" "continue" "load-time-value" "hash-table-size" + "upgraded-complex-part-type" "char-lessp" "sbit" "upgraded-array-element-type" "file-length" + "typecase" "cadddr" "first" "rationalize" "logtest" "find-if-not" "dpb" "mapc" "sinh" + "char-greaterp" "shiftf" "denominator" "get-universal-time" "nconc" "setf" "lognand" + "rename-package" "pprint-logical-block" "break" "symbol-macrolet" "the" "fresh-line" + "clear-output" "assoc-if" "string/=" "princ" "directory-namestring" "stream-error-stream" + "array-element-type" "setq" "copy-seq" "time" "restart-case" "prog*" "shared-initialize" + "array-total-size" "simple-bit-vector-p" "define-method-combination" "write-byte" "constantly" + "caddar" "print-object" "vector" "throw" "reverse" ">=" "upper-case-p" "nbutlast") + ) + +(list_lit + . + (sym_lit) @operator + (#match? @operator "^([+*-+=<>]|<=|>=|/=)$")) + +((sym_lit) @string.special.symbol + (#lua-match? @string.special.symbol "^[&]")) + +[ + (array_dimension) + "#0A" + "#0a" +] @number + +(char_lit) @character diff --git a/pack/ant/start/nvim-treesitter/queries/commonlisp/injections.scm b/pack/ant/start/nvim-treesitter/queries/commonlisp/injections.scm new file mode 100644 index 0000000..dc89820 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/commonlisp/injections.scm @@ -0,0 +1,5 @@ +([ + (comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/commonlisp/locals.scm b/pack/ant/start/nvim-treesitter/queries/commonlisp/locals.scm new file mode 100644 index 0000000..98036d3 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/commonlisp/locals.scm @@ -0,0 +1,109 @@ +(defun_header + function_name: (sym_lit) @local.definition.function + (#set! definition.function.scope "parent")) + +(defun_header + lambda_list: (list_lit + (sym_lit) @local.definition.parameter)) + +(defun_header + keyword: (defun_keyword + "defmethod") + lambda_list: (list_lit + (list_lit + . + (sym_lit) + . + (sym_lit) @local.definition.type))) + +(defun_header + lambda_list: (list_lit + (list_lit + . + (sym_lit) @local.definition.parameter + . + (_)))) + +(sym_lit) @local.reference + +(defun) @local.scope + +((list_lit + . + (sym_lit) @_defvar + . + (sym_lit) @local.definition.var) + (#match? @_defvar "^(cl:)?(defvar|defparameter)$")) + +(list_lit + . + (sym_lit) @_deftest + . + (sym_lit) @local.definition.function + (#eq? @_deftest "deftest")) @local.scope + +(list_lit + . + (sym_lit) @_deftest + . + (sym_lit) @local.definition.function + (#eq? @_deftest "deftest")) @local.scope + +(for_clause + . + (sym_lit) @local.definition.var) + +(with_clause + . + (sym_lit) @local.definition.var) + +(loop_macro) @local.scope + +(list_lit + . + (sym_lit) @_let + (#match? @_let "(cl:|cffi:)?(with-accessors|with-foreign-objects|let[*]?)") + . + (list_lit + (list_lit + . + (sym_lit) @local.definition.var))) @local.scope + +(list_lit + . + (sym_lit) @_let + (#match? @_let "(cl:|alexandria:)?(with-gensyms|dotimes|with-foreign-object)") + . + (list_lit + . + (sym_lit) @local.definition.var)) @local.scope + +(list_lit + . + (kwd_lit) @_import_from + (#eq? @_import_from ":import-from") + . + (_) + (kwd_lit + (kwd_symbol) @local.definition.import)) + +(list_lit + . + (kwd_lit) @_import_from + (#eq? @_import_from ":import-from") + . + (_) + (sym_lit) @local.definition.import) + +(list_lit + . + (kwd_lit) @_use + (#eq? @_use ":use") + (kwd_lit + (kwd_symbol) @local.definition.import)) + +(list_lit + . + (kwd_lit) @_use + (#eq? @_use ":use") + (sym_lit) @local.definition.import) diff --git a/pack/ant/start/nvim-treesitter/queries/cooklang/highlights.scm b/pack/ant/start/nvim-treesitter/queries/cooklang/highlights.scm new file mode 100644 index 0000000..4ac3918 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cooklang/highlights.scm @@ -0,0 +1,31 @@ +(metadata) @comment + +(comment) @comment @spell + +[ + "{" + "}" +] @punctuation.bracket + +"%" @punctuation.special + +(ingredient + "@" @punctuation.delimiter + (name)? @string.special.symbol + (amount + (quantity)? @number + (units)? @constant)?) + +(timer + "~" @punctuation.delimiter + (name)? @string.special.symbol + (amount + (quantity)? @number + (units)? @constant)?) + +(cookware + "#" @punctuation.delimiter + (name)? @string.special.symbol + (amount + (quantity)? @number + (units)? @constant)?) diff --git a/pack/ant/start/nvim-treesitter/queries/cooklang/injections.scm b/pack/ant/start/nvim-treesitter/queries/cooklang/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cooklang/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/corn/folds.scm b/pack/ant/start/nvim-treesitter/queries/corn/folds.scm new file mode 100644 index 0000000..2ce5ddb --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/corn/folds.scm @@ -0,0 +1,5 @@ +[ + (object) + (array) + (assign_block) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/corn/highlights.scm b/pack/ant/start/nvim-treesitter/queries/corn/highlights.scm new file mode 100644 index 0000000..8f394ed --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/corn/highlights.scm @@ -0,0 +1,37 @@ +[ + "let" + "in" +] @keyword + +[ + "{" + "}" + "[" + "]" +] @punctuation.bracket + +"." @punctuation.delimiter + +[ + ".." + "=" +] @operator + +(input) @constant + +(null) @constant.builtin + +(comment) @comment @spell + +(string) @string + +(integer) @number + +(float) @number.float + +(float + "." @number.float) + +(boolean) @boolean + +(path_seg) @property diff --git a/pack/ant/start/nvim-treesitter/queries/corn/indents.scm b/pack/ant/start/nvim-treesitter/queries/corn/indents.scm new file mode 100644 index 0000000..f1f5e04 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/corn/indents.scm @@ -0,0 +1,24 @@ +[ + (assign_block + "{") + (object) + (array) +] @indent.begin + +(assign_block + "}" @indent.branch) + +(assign_block + "}" @indent.end) + +(object + "}" @indent.branch) + +(object + "}" @indent.end) + +(array + "]" @indent.branch) + +(array + "]" @indent.end) diff --git a/pack/ant/start/nvim-treesitter/queries/corn/injections.scm b/pack/ant/start/nvim-treesitter/queries/corn/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/corn/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/corn/locals.scm b/pack/ant/start/nvim-treesitter/queries/corn/locals.scm new file mode 100644 index 0000000..7e78c4d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/corn/locals.scm @@ -0,0 +1,13 @@ +; scopes +[ + (object) + (array) +] @local.scope + +; definitions +(assign_block + (assignment + (input) @local.definition.constant)) + +(value + (input) @local.reference) diff --git a/pack/ant/start/nvim-treesitter/queries/cpon/folds.scm b/pack/ant/start/nvim-treesitter/queries/cpon/folds.scm new file mode 100644 index 0000000..02feec4 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cpon/folds.scm @@ -0,0 +1,5 @@ +[ + (meta_map) + (map) + (array) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/cpon/highlights.scm b/pack/ant/start/nvim-treesitter/queries/cpon/highlights.scm new file mode 100644 index 0000000..9cc438e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cpon/highlights.scm @@ -0,0 +1,54 @@ +; Literals +(string) @string + +(escape_sequence) @string.escape + +(hex_blob + "x" @character.special + (_) @string) + +(esc_blob + "b" @character.special + (_) @string) + +(datetime + "d" @character.special + (_) @string.special) + +(_ + key: (_) @property) + +(number) @number + +(float) @number.float + +(boolean) @boolean + +(null) @constant.builtin + +; Punctuation +[ + "," + ":" +] @punctuation.delimiter + +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "<" + ">" +] @punctuation.bracket + +("\"" @string + (#set! conceal "")) + +; Comments +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/cpon/indents.scm b/pack/ant/start/nvim-treesitter/queries/cpon/indents.scm new file mode 100644 index 0000000..8ec2ff5 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cpon/indents.scm @@ -0,0 +1,17 @@ +[ + (meta_map) + (map) + (imap) + (array) +] @indent.begin + +[ + "]" + "}" + ">" +] @indent.end @indent.branch + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/pack/ant/start/nvim-treesitter/queries/cpon/injections.scm b/pack/ant/start/nvim-treesitter/queries/cpon/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cpon/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/cpon/locals.scm b/pack/ant/start/nvim-treesitter/queries/cpon/locals.scm new file mode 100644 index 0000000..2a4ba47 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cpon/locals.scm @@ -0,0 +1,6 @@ +[ + (document) + (meta_map) + (map) + (array) +] @local.scope diff --git a/pack/ant/start/nvim-treesitter/queries/cpp/folds.scm b/pack/ant/start/nvim-treesitter/queries/cpp/folds.scm new file mode 100644 index 0000000..f5f5664 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cpp/folds.scm @@ -0,0 +1,14 @@ +; inherits: c + +[ + (for_range_loop) + (class_specifier) + (field_declaration + type: (enum_specifier) + default_value: (initializer_list)) + (template_declaration) + (namespace_definition) + (try_statement) + (catch_clause) + (lambda_expression) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/cpp/highlights.scm b/pack/ant/start/nvim-treesitter/queries/cpp/highlights.scm new file mode 100644 index 0000000..85ff2dc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cpp/highlights.scm @@ -0,0 +1,268 @@ +; inherits: c + +((identifier) @variable.member + (#lua-match? @variable.member "^m_.*$")) + +(parameter_declaration + declarator: (reference_declarator) @variable.parameter) + +; function(Foo ...foo) +(variadic_parameter_declaration + declarator: (variadic_declarator + (_) @variable.parameter)) + +; int foo = 0 +(optional_parameter_declaration + declarator: (_) @variable.parameter) + +;(field_expression) @variable.parameter ;; How to highlight this? +((field_expression + (field_identifier) @function.method) @_parent + (#has-parent? @_parent template_method function_declarator)) + +(field_declaration + (field_identifier) @variable.member) + +(field_initializer + (field_identifier) @property) + +(function_declarator + declarator: (field_identifier) @function.method) + +(concept_definition + name: (identifier) @type.definition) + +(alias_declaration + name: (type_identifier) @type.definition) + +(auto) @type.builtin + +(namespace_identifier) @module + +((namespace_identifier) @type + (#lua-match? @type "^[%u]")) + +(case_statement + value: (qualified_identifier + (identifier) @constant)) + +(using_declaration + . + "using" + . + "namespace" + . + [ + (qualified_identifier) + (identifier) + ] @module) + +(destructor_name + (identifier) @function.method) + +; functions +(function_declarator + (qualified_identifier + (identifier) @function)) + +(function_declarator + (qualified_identifier + (qualified_identifier + (identifier) @function))) + +(function_declarator + (qualified_identifier + (qualified_identifier + (qualified_identifier + (identifier) @function)))) + +((qualified_identifier + (qualified_identifier + (qualified_identifier + (qualified_identifier + (identifier) @function)))) @_parent + (#has-ancestor? @_parent function_declarator)) + +(function_declarator + (template_function + (identifier) @function)) + +(operator_name) @function + +"operator" @function + +"static_assert" @function.builtin + +(call_expression + (qualified_identifier + (identifier) @function.call)) + +(call_expression + (qualified_identifier + (qualified_identifier + (identifier) @function.call))) + +(call_expression + (qualified_identifier + (qualified_identifier + (qualified_identifier + (identifier) @function.call)))) + +((qualified_identifier + (qualified_identifier + (qualified_identifier + (qualified_identifier + (identifier) @function.call)))) @_parent + (#has-ancestor? @_parent call_expression)) + +(call_expression + (template_function + (identifier) @function.call)) + +(call_expression + (qualified_identifier + (template_function + (identifier) @function.call))) + +(call_expression + (qualified_identifier + (qualified_identifier + (template_function + (identifier) @function.call)))) + +(call_expression + (qualified_identifier + (qualified_identifier + (qualified_identifier + (template_function + (identifier) @function.call))))) + +((qualified_identifier + (qualified_identifier + (qualified_identifier + (qualified_identifier + (template_function + (identifier) @function.call))))) @_parent + (#has-ancestor? @_parent call_expression)) + +; methods +(function_declarator + (template_method + (field_identifier) @function.method)) + +(call_expression + (field_expression + (field_identifier) @function.method.call)) + +; constructors +((function_declarator + (qualified_identifier + (identifier) @constructor)) + (#lua-match? @constructor "^%u")) + +((call_expression + function: (identifier) @constructor) + (#lua-match? @constructor "^%u")) + +((call_expression + function: (qualified_identifier + name: (identifier) @constructor)) + (#lua-match? @constructor "^%u")) + +((call_expression + function: (field_expression + field: (field_identifier) @constructor)) + (#lua-match? @constructor "^%u")) + +; constructing a type in an initializer list: Constructor (): **SuperType (1)** +((field_initializer + (field_identifier) @constructor + (argument_list)) + (#lua-match? @constructor "^%u")) + +; Constants +(this) @variable.builtin + +(null + "nullptr" @constant.builtin) + +(true) @boolean + +(false) @boolean + +; Literals +(raw_string_literal) @string + +; Keywords +[ + "try" + "catch" + "noexcept" + "throw" +] @keyword.exception + +[ + "decltype" + "explicit" + "friend" + "override" + "using" + "requires" + "constexpr" +] @keyword + +[ + "class" + "namespace" + "template" + "typename" + "concept" +] @keyword.type + +[ + "co_await" + "co_yield" + "co_return" +] @keyword.coroutine + +[ + "public" + "private" + "protected" + "final" + "virtual" +] @keyword.modifier + +[ + "new" + "delete" + "xor" + "bitand" + "bitor" + "compl" + "not" + "xor_eq" + "and_eq" + "or_eq" + "not_eq" + "and" + "or" +] @keyword.operator + +"<=>" @operator + +"::" @punctuation.delimiter + +(template_argument_list + [ + "<" + ">" + ] @punctuation.bracket) + +(template_parameter_list + [ + "<" + ">" + ] @punctuation.bracket) + +(literal_suffix) @operator diff --git a/pack/ant/start/nvim-treesitter/queries/cpp/indents.scm b/pack/ant/start/nvim-treesitter/queries/cpp/indents.scm new file mode 100644 index 0000000..0782d22 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cpp/indents.scm @@ -0,0 +1,8 @@ +; inherits: c + +(condition_clause) @indent.begin + +((field_initializer_list) @indent.begin + (#set! indent.start_at_same_line 1)) + +(access_specifier) @indent.branch diff --git a/pack/ant/start/nvim-treesitter/queries/cpp/injections.scm b/pack/ant/start/nvim-treesitter/queries/cpp/injections.scm new file mode 100644 index 0000000..6e16572 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cpp/injections.scm @@ -0,0 +1,13 @@ +((preproc_arg) @injection.content + (#set! injection.language "cpp")) + +((comment) @injection.content + (#set! injection.language "comment")) + +((comment) @injection.content + (#lua-match? @injection.content "/[*\/][!*\/] +(type_parameter_declaration + (type_identifier) @local.definition.type) + +(template_declaration) @local.scope + +; Namespaces +(namespace_definition + name: (namespace_identifier) @local.definition.namespace + body: (_) @local.scope) + +(namespace_definition + name: (nested_namespace_specifier) @local.definition.namespace + body: (_) @local.scope) + +((namespace_identifier) @local.reference + (#set! reference.kind "namespace")) + +; Function definitions +(template_function + name: (identifier) @local.definition.function) @local.scope + +(template_method + name: (field_identifier) @local.definition.method) @local.scope + +(function_declarator + declarator: (qualified_identifier + name: (identifier) @local.definition.function)) @local.scope + +(field_declaration + declarator: (function_declarator + (field_identifier) @local.definition.method)) + +(lambda_expression) @local.scope + +; Control structures +(try_statement + body: (_) @local.scope) + +(catch_clause) @local.scope + +(requires_expression) @local.scope diff --git a/pack/ant/start/nvim-treesitter/queries/css/folds.scm b/pack/ant/start/nvim-treesitter/queries/css/folds.scm new file mode 100644 index 0000000..dc3c14d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/css/folds.scm @@ -0,0 +1,4 @@ +[ + (rule_set) + (import_statement)+ +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/css/highlights.scm b/pack/ant/start/nvim-treesitter/queries/css/highlights.scm new file mode 100644 index 0000000..acc2b63 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/css/highlights.scm @@ -0,0 +1,107 @@ +[ + "@media" + "@charset" + "@namespace" + "@supports" + "@keyframes" + (at_keyword) +] @keyword.directive + +"@import" @keyword.import + +[ + (to) + (from) +] @keyword + +(comment) @comment @spell + +(tag_name) @tag + +(class_name) @type + +(id_name) @constant + +[ + (property_name) + (feature_name) +] @property + +[ + (nesting_selector) + (universal_selector) +] @character.special + +(function_name) @function + +[ + "~" + ">" + "+" + "-" + "*" + "/" + "=" + "^=" + "|=" + "~=" + "$=" + "*=" +] @operator + +[ + "and" + "or" + "not" + "only" +] @keyword.operator + +(important) @keyword.modifier + +(attribute_selector + (plain_value) @string) + +(pseudo_element_selector + "::" + (tag_name) @attribute) + +(pseudo_class_selector + (class_name) @attribute) + +(attribute_name) @tag.attribute + +(namespace_name) @module + +((property_name) @variable + (#lua-match? @variable "^[-][-]")) + +((plain_value) @variable + (#lua-match? @variable "^[-][-]")) + +[ + (string_value) + (color_value) + (unit) +] @string + +(integer_value) @number + +(float_value) @number.float + +[ + "#" + "," + "." + ":" + "::" + ";" +] @punctuation.delimiter + +[ + "{" + ")" + "(" + "}" + "[" + "]" +] @punctuation.bracket diff --git a/pack/ant/start/nvim-treesitter/queries/css/indents.scm b/pack/ant/start/nvim-treesitter/queries/css/indents.scm new file mode 100644 index 0000000..75e4a63 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/css/indents.scm @@ -0,0 +1,11 @@ +[ + (block) + (declaration) +] @indent.begin + +(block + "}" @indent.branch) + +"}" @indent.dedent + +(comment) @indent.ignore diff --git a/pack/ant/start/nvim-treesitter/queries/css/injections.scm b/pack/ant/start/nvim-treesitter/queries/css/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/css/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/csv/highlights.scm b/pack/ant/start/nvim-treesitter/queries/csv/highlights.scm new file mode 100644 index 0000000..de2213a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/csv/highlights.scm @@ -0,0 +1,3 @@ +; inherits: tsv + +"," @punctuation.delimiter diff --git a/pack/ant/start/nvim-treesitter/queries/cuda/folds.scm b/pack/ant/start/nvim-treesitter/queries/cuda/folds.scm new file mode 100644 index 0000000..b617fdc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cuda/folds.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/pack/ant/start/nvim-treesitter/queries/cuda/highlights.scm b/pack/ant/start/nvim-treesitter/queries/cuda/highlights.scm new file mode 100644 index 0000000..6605c5a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cuda/highlights.scm @@ -0,0 +1,17 @@ +; inherits: cpp + +[ + "<<<" + ">>>" +] @punctuation.bracket + +[ + "__host__" + "__device__" + "__global__" + "__managed__" + "__forceinline__" + "__noinline__" +] @keyword.modifier + +"__launch_bounds__" @keyword.modifier diff --git a/pack/ant/start/nvim-treesitter/queries/cuda/indents.scm b/pack/ant/start/nvim-treesitter/queries/cuda/indents.scm new file mode 100644 index 0000000..b617fdc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cuda/indents.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/pack/ant/start/nvim-treesitter/queries/cuda/injections.scm b/pack/ant/start/nvim-treesitter/queries/cuda/injections.scm new file mode 100644 index 0000000..0259958 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cuda/injections.scm @@ -0,0 +1,5 @@ +((preproc_arg) @injection.content + (#set! injection.language "cuda")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/cuda/locals.scm b/pack/ant/start/nvim-treesitter/queries/cuda/locals.scm new file mode 100644 index 0000000..b617fdc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cuda/locals.scm @@ -0,0 +1 @@ +; inherits: cpp diff --git a/pack/ant/start/nvim-treesitter/queries/cue/folds.scm b/pack/ant/start/nvim-treesitter/queries/cue/folds.scm new file mode 100644 index 0000000..934b59e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cue/folds.scm @@ -0,0 +1,5 @@ +[ + (import_spec_list) + (field) + (string) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/cue/highlights.scm b/pack/ant/start/nvim-treesitter/queries/cue/highlights.scm new file mode 100644 index 0000000..27d4dad --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cue/highlights.scm @@ -0,0 +1,164 @@ +; Includes +[ + "package" + "import" +] @keyword.import + +; Namespaces +(package_identifier) @module + +(import_spec + [ + "." + "_" + ] @punctuation.special) + +[ + (attr_path) + (package_path) +] @string.special.url ; In attributes + +; Attributes +(attribute) @attribute + +; Conditionals +"if" @keyword.conditional + +; Repeats +"for" @keyword.repeat + +(for_clause + "_" @punctuation.special) + +; Keywords +"let" @keyword + +"in" @keyword.operator + +; Operators +[ + "+" + "-" + "*" + "/" + "|" + "&" + "||" + "&&" + "==" + "!=" + "<" + "<=" + ">" + ">=" + "=~" + "!~" + "!" + "=" +] @operator + +; Fields & Properties +(field + (label + (identifier) @variable.member)) + +(selector_expression + (_) + (identifier) @property) + +; Functions +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (selector_expression + (_) + (identifier) @function.call)) + +(call_expression + function: (builtin_function) @function.call) + +(builtin_function) @function.builtin + +; Variables +(identifier) @variable + +; Types +(primitive_type) @type.builtin + +((identifier) @type + (#lua-match? @type "^_?#")) + +[ + (slice_type) + (pointer_type) +] @type ; In attributes + +; Punctuation +[ + "," + ":" +] @punctuation.delimiter + +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "<" + ">" +] @punctuation.bracket + +[ + (ellipsis) + "?" +] @punctuation.special + +; Literals +(string) @string + +[ + (escape_char) + (escape_unicode) +] @string.escape + +(number) @number + +(float) @number.float + +(si_unit + (float) + (_) @string.special.symbol) + +(boolean) @boolean + +[ + (null) + (top) + (bottom) +] @constant.builtin + +; Interpolations +(interpolation + "\\(" @punctuation.special + (_) + ")" @punctuation.special) @none + +(interpolation + "\\(" + (identifier) @variable + ")") + +; Comments +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/cue/indents.scm b/pack/ant/start/nvim-treesitter/queries/cue/indents.scm new file mode 100644 index 0000000..cef2345 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cue/indents.scm @@ -0,0 +1,30 @@ +[ + (import_spec_list) + (field) +] @indent.begin + +[ + "}" + "]" + ")" +] @indent.end + +[ + "{" + "}" +] @indent.branch + +[ + "[" + "]" +] @indent.branch + +[ + "(" + ")" +] @indent.branch + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/pack/ant/start/nvim-treesitter/queries/cue/injections.scm b/pack/ant/start/nvim-treesitter/queries/cue/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cue/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/cue/locals.scm b/pack/ant/start/nvim-treesitter/queries/cue/locals.scm new file mode 100644 index 0000000..b2a8972 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/cue/locals.scm @@ -0,0 +1,31 @@ +; Scopes +[ + (source_file) + (field) + (for_clause) +] @local.scope + +; References +(identifier) @local.reference + +; Definitions +(import_spec + path: (string) @local.definition.import) + +(field + (label + (identifier) @local.definition.field)) + +(package_identifier) @local.definition.namespace + +(for_clause + (identifier) @local.definition.var + (expression)) + +(for_clause + (identifier) + (identifier) @local.definition.var + (expression)) + +(let_clause + (identifier) @local.definition.var) diff --git a/pack/ant/start/nvim-treesitter/queries/d/folds.scm b/pack/ant/start/nvim-treesitter/queries/d/folds.scm new file mode 100644 index 0000000..49d6256 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/d/folds.scm @@ -0,0 +1,4 @@ +[ + (block_statement) + (aggregate_body) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/d/highlights.scm b/pack/ant/start/nvim-treesitter/queries/d/highlights.scm new file mode 100644 index 0000000..11d08a1 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/d/highlights.scm @@ -0,0 +1,374 @@ +; Keywords +[ + (directive) + (shebang) +] @keyword.directive + +[ + (import) + (module) +] @keyword.import + +[ + (alias) + (asm) + (class) + (delegate) + (delete) + (enum) + (interface) + (invariant) + (mixin) + (pragma) + (struct) + (template) + (union) + (unittest) + (version) + (with) + (traits) + (vector) + (parameters_) + (default) + (goto) +] @keyword + +(function) @keyword.function + +(synchronized) @keyword.coroutine + +[ + (if) + (else) + (switch) + (case) + (break) +] @keyword.conditional + +[ + (do) + (for) + (foreach) + (foreach_reverse) + (while) + (continue) +] @keyword.repeat + +(return) @keyword.return + +[ + (abstract) + (deprecated) + (private) + (protected) + (public) + (package) + (immutable) + (final) + (const) + (override) + (static) +] @keyword.modifier + +[ + (assert) + (try) + (catch) + (finally) + (throw) + (nothrow) +] @keyword.exception + +[ + (cast) + (new) + (in) + (is) + (not_in) + (not_is) + (typeid) + (typeof) +] @keyword.operator + +[ + (lazy) + (align) + (extern) + (scope) + (ref) + (pure) + (export) + (shared) + (gshared) + (out) + (inout) +] @keyword.modifier + +(parameter_attribute + (return) @keyword.modifier) + +(parameter_attribute + (in) @keyword.modifier) + +(parameter_attribute + (out) @keyword.modifier) + +(debug) @keyword.debug + +; Operators +[ + "/=" + "/" + ".." + "&" + "&=" + "&&" + "|" + "|=" + "||" + "-" + "-=" + "--" + "+" + "+=" + "++" + "<" + "<=" + "<<" + "<<=" + ">" + ">=" + ">>=" + ">>>=" + ">>" + ">>>" + "!" + "!=" + "$" + "=" + "==" + "*" + "*=" + "%" + "%=" + "^" + "^=" + "^^" + "^^=" + "~" + "~=" + "@" +] @operator + +; Variables +(identifier) @variable + +[ + "exit" + "success" + "failure" + (this) + (super) +] @variable.builtin + +(linkage_attribute + "(" + _ @variable.builtin + ")") + +; Modules +(module_fqn + (identifier) @module) + +; Attributes +(at_attribute + (identifier) @attribute) + +; Constants +(enum_member + (identifier) @constant) + +(manifest_declarator + . + (identifier) @constant) + +; Members +(aggregate_body + (variable_declaration + (declarator + (identifier) @variable.member))) + +(property_expression + "." + (identifier) @variable.member) + +(type + "." + (identifier) @variable.member) + +; Types +(class_declaration + (class) + . + (identifier) @type) + +(struct_declaration + (struct) + . + (identifier) @type) + +(union_declaration + (union) + . + (identifier) @type) + +(enum_declaration + (enum) + . + (identifier) @type) + +(alias_declaration + (alias) + . + (identifier) @type) + +((identifier) @type + (#lua-match? @type "^[A-Z].*")) + +(type + . + (identifier) @type .) + +[ + (auto) + (void) + (bool) + (byte) + (ubyte) + (char) + (short) + (ushort) + (wchar) + (dchar) + (int) + (uint) + (long) + (ulong) + (real) + (double) + (float) + (cent) + (ucent) + (ireal) + (idouble) + (ifloat) + (creal) + (double) + (cfloat) +] @type.builtin + +; Functions +(function_declaration + (identifier) @function) + +(call_expression + (identifier) @function) + +(call_expression + (type + (identifier) @function .)) + +(call_expression + (property_expression + (call_expression) + (identifier) @function .)) + +; Parameters +(parameter + (_) + (identifier) @variable.parameter) + +(function_literal + "(" + (type + (identifier) @variable.parameter)) + +; Constructors +(constructor + (this) @constructor) + +(destructor + (this) @constructor) + +(postblit + . + (this) @constructor) + +; Punctuation +[ + ";" + "." + ":" + "," + "=>" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +"..." @punctuation.special + +; Ternaries +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +; Labels +(label + (identifier) @label) + +(goto_statement + (identifier) @label) + +; Literals +(string_literal) @string + +[ + (int_literal) + (float_literal) +] @number + +(char_literal) @character + +[ + (true) + (false) +] @boolean + +[ + (null) + (special_keyword) +] @constant.builtin + +; Comments +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///[^/]")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^///$")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[+][+][^+].*[+]/$")) diff --git a/pack/ant/start/nvim-treesitter/queries/d/indents.scm b/pack/ant/start/nvim-treesitter/queries/d/indents.scm new file mode 100644 index 0000000..c89b4e9 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/d/indents.scm @@ -0,0 +1,24 @@ +[ + (parameters) + (template_parameters) + (expression_statement) + (aggregate_body) + (function_body) + (scope_statement) + (block_statement) + (case_statement) +] @indent.begin + +(comment) @indent.auto + +[ + (case) + (default) + "}" + "]" +] @indent.branch + +[ + (directive) + (shebang) +] @indent.zero diff --git a/pack/ant/start/nvim-treesitter/queries/d/injections.scm b/pack/ant/start/nvim-treesitter/queries/d/injections.scm new file mode 100644 index 0000000..cfc1bf9 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/d/injections.scm @@ -0,0 +1,19 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((call_expression + (type) @_printf + (named_arguments + "(" + . + (named_argument + (expression + (string_literal) @injection.content)))) + (#eq? @_printf "printf") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "printf")) + +; TODO: uncomment when asm is added +; ((asm_inline) @injection.content +; (#set! injection.language "asm") +; (#set! injection.combined)) diff --git a/pack/ant/start/nvim-treesitter/queries/d/locals.scm b/pack/ant/start/nvim-treesitter/queries/d/locals.scm new file mode 100644 index 0000000..2cd7b9e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/d/locals.scm @@ -0,0 +1,79 @@ +; Scopes +[ + (source_file) + (block_statement) + (aggregate_body) +] @local.scope + +; References +(identifier) @local.reference + +; Definitions +(module_def + (module_declaration + (module_fqn) @local.definition.namespace) + (#set! definition.namespace.scope "global")) + +(enum_declaration + (enum_member + . + (identifier) @local.definition.enum)) + +(class_declaration + (class) + . + (identifier) @local.definition.type) + +(struct_declaration + (struct) + . + (identifier) @local.definition.type) + +(union_declaration + (union) + . + (identifier) @local.definition.type) + +(enum_declaration + (enum) + . + (identifier) @local.definition.type) + +(alias_declaration + (alias_initializer + . + (identifier) @local.definition.type)) + +(constructor + (this) @local.definition.method) + +(destructor + (this) @local.definition.method) + +(postblit + (this) @local.definition.method) + +(aggregate_body + (function_declaration + (identifier) @local.definition.method)) + +(manifest_declarator + . + (identifier) @local.definition.constant) + +(anonymous_enum_declaration + (enum_member + . + (identifier) @local.definition.constant)) + +(variable_declaration + (declarator + (identifier) @local.definition.var)) + +(aggregate_body + (variable_declaration + (declarator + (identifier) @local.definition.field))) + +(function_declaration + (identifier) @local.definition.function) diff --git a/pack/ant/start/nvim-treesitter/queries/dart/folds.scm b/pack/ant/start/nvim-treesitter/queries/dart/folds.scm new file mode 100644 index 0000000..fc75ac2 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dart/folds.scm @@ -0,0 +1,13 @@ +[ + (class_definition) + (enum_declaration) + (extension_declaration) + (arguments) + (function_body) + (block) + (switch_block) + (list_literal) + (set_or_map_literal) + (string_literal) + (import_or_export)+ +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/dart/highlights.scm b/pack/ant/start/nvim-treesitter/queries/dart/highlights.scm new file mode 100644 index 0000000..072a10d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dart/highlights.scm @@ -0,0 +1,303 @@ +(identifier) @variable + +(dotted_identifier_list) @string + +; Methods +; -------------------- +; TODO: add method/call_expression to grammar and +; distinguish method call from variable access +(function_expression_body + (identifier) @function.call) + +; ((identifier)(selector (argument_part)) @function) +; NOTE: This query is a bit of a work around for the fact that the dart grammar doesn't +; specifically identify a node as a function call +(((identifier) @function.call + (#lua-match? @function.call "^_?[%l]")) + . + (selector + . + (argument_part))) @function.call + +; Annotations +; -------------------- +(annotation + "@" @attribute + name: (identifier) @attribute) + +; Operators and Tokens +; -------------------- +(template_substitution + "$" @punctuation.special + "{" @punctuation.special + "}" @punctuation.special) @none + +(template_substitution + "$" @punctuation.special + (identifier_dollar_escaped) @variable) @none + +(escape_sequence) @string.escape + +[ + "=>" + ".." + "??" + "==" + "!" + "?" + "&&" + "%" + "<" + ">" + "=" + ">=" + "<=" + "||" + ">>>=" + ">>=" + "<<=" + "&=" + "|=" + "??=" + "%=" + "+=" + "-=" + "*=" + "/=" + "^=" + "~/=" + (shift_operator) + (multiplicative_operator) + (increment_operator) + (is_operator) + (prefix_operator) + (equality_operator) + (additive_operator) +] @operator + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +; Delimiters +; -------------------- +[ + ";" + "." + "," + ":" + "?." + "?" +] @punctuation.delimiter + +; Types +; -------------------- +(class_definition + name: (identifier) @type) + +(constructor_signature + name: (identifier) @type) + +(scoped_identifier + scope: (identifier) @type) + +(function_signature + name: (identifier) @function.method) + +(getter_signature + (identifier) @function.method) + +(setter_signature + name: (identifier) @function.method) + +(enum_declaration + name: (identifier) @type) + +(enum_constant + name: (identifier) @type) + +(void_type) @type + +((scoped_identifier + scope: (identifier) @type + name: (identifier) @type) + (#lua-match? @type "^[%u%l]")) + +(type_identifier) @type + +(type_alias + (type_identifier) @type.definition) + +(type_arguments + [ + "<" + ">" + ] @punctuation.bracket) + +; Variables +; -------------------- +; var keyword +(inferred_type) @keyword + +((identifier) @type + (#lua-match? @type "^_?[%u].*[%l]")) ; catch Classes or IClasses not CLASSES + +"Function" @type + +; properties +(unconditional_assignable_selector + (identifier) @property) + +(conditional_assignable_selector + (identifier) @property) + +(this) @variable.builtin + +; Parameters +; -------------------- +(formal_parameter + (identifier) @variable.parameter) + +(named_argument + (label + (identifier) @variable.parameter)) + +; Literals +; -------------------- +[ + (hex_integer_literal) + (decimal_integer_literal) + (decimal_floating_point_literal) + ; TODO: inaccessible nodes + ; (octal_integer_literal) + ; (hex_floating_point_literal) +] @number + +(symbol_literal) @string.special.symbol + +(string_literal) @string + +(true) @boolean + +(false) @boolean + +(null_literal) @constant.builtin + +(comment) @comment @spell + +(documentation_comment) @comment.documentation @spell + +; Keywords +; -------------------- +[ + "import" + "library" + "export" + "as" + "show" + "hide" +] @keyword.import + +; Reserved words (cannot be used as identifiers) +[ + ; TODO: + ; "rethrow" cannot be targeted at all and seems to be an invisible node + ; TODO: + ; the assert keyword cannot be specifically targeted + ; because the grammar selects the whole node or the content + ; of the assertion not just the keyword + ; assert + (case_builtin) + "late" + "required" + "on" + "extends" + "in" + "is" + "new" + "super" + "with" +] @keyword + +[ + "class" + "enum" + "extension" +] @keyword.type + +"return" @keyword.return + +; Built in identifiers: +; alone these are marked as keywords +[ + "deferred" + "factory" + "get" + "implements" + "interface" + "library" + "operator" + "mixin" + "part" + "set" + "typedef" +] @keyword + +[ + "async" + "async*" + "sync*" + "await" + "yield" +] @keyword.coroutine + +[ + (const_builtin) + (final_builtin) + "abstract" + "covariant" + "external" + "static" + "final" + "base" + "sealed" +] @keyword.modifier + +; when used as an identifier: +((identifier) @variable.builtin + (#any-of? @variable.builtin + "abstract" "as" "covariant" "deferred" "dynamic" "export" "external" "factory" "Function" "get" + "implements" "import" "interface" "library" "operator" "mixin" "part" "set" "static" "typedef")) + +[ + "if" + "else" + "switch" + "default" +] @keyword.conditional + +(conditional_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +[ + "try" + "throw" + "catch" + "finally" + (break_statement) +] @keyword.exception + +[ + "do" + "while" + "continue" + "for" +] @keyword.repeat diff --git a/pack/ant/start/nvim-treesitter/queries/dart/indents.scm b/pack/ant/start/nvim-treesitter/queries/dart/indents.scm new file mode 100644 index 0000000..03d9464 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dart/indents.scm @@ -0,0 +1,49 @@ +[ + (class_body) + (function_body) + (function_expression_body) + (declaration + (initializers)) + (switch_block) + (formal_parameter_list) + (formal_parameter) + (list_literal) + (return_statement) + (arguments) + (try_statement) +] @indent.begin + +(switch_block + (_) @indent.begin + (#set! indent.immediate 1) + (#set! indent.start_at_same_line 1)) + +[ + (switch_statement_case) + (switch_statement_default) +] @indent.branch + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @indent.branch + +"}" @indent.end + +(return_statement + ";" @indent.end) + +(break_statement + ";" @indent.end) + +(comment) @indent.ignore + +; dedenting the else block is painfully slow; replace with simpler strategy +; (if_statement) @indent.begin +; (if_statement +; (block) @indent.branch) +(if_statement) @indent.auto diff --git a/pack/ant/start/nvim-treesitter/queries/dart/injections.scm b/pack/ant/start/nvim-treesitter/queries/dart/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dart/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/dart/locals.scm b/pack/ant/start/nvim-treesitter/queries/dart/locals.scm new file mode 100644 index 0000000..3e3beb5 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dart/locals.scm @@ -0,0 +1,32 @@ +; Definitions +(function_signature + name: (identifier) @local.definition.function) + +(formal_parameter + name: (identifier) @local.definition.parameter) + +(initialized_variable_definition + name: (identifier) @local.definition.var) + +(initialized_identifier + (identifier) @local.definition.var) + +(static_final_declaration + (identifier) @local.definition.var) + +; References +(identifier) @local.reference + +; Scopes +(class_definition + body: (_) @local.scope) + +[ + (block) + (if_statement) + (for_statement) + (while_statement) + (try_statement) + (catch_clause) + (finally_clause) +] @local.scope diff --git a/pack/ant/start/nvim-treesitter/queries/devicetree/folds.scm b/pack/ant/start/nvim-treesitter/queries/devicetree/folds.scm new file mode 100644 index 0000000..206c4be --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/devicetree/folds.scm @@ -0,0 +1 @@ +(node) @fold diff --git a/pack/ant/start/nvim-treesitter/queries/devicetree/highlights.scm b/pack/ant/start/nvim-treesitter/queries/devicetree/highlights.scm new file mode 100644 index 0000000..74ec89a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/devicetree/highlights.scm @@ -0,0 +1,61 @@ +(comment) @comment @spell + +[ + (preproc_include) + (dtsi_include) +] @keyword.import + +(preproc_def) @constant.macro + +(preproc_function_def) @function.macro + +[ + (memory_reservation) + (file_version) +] @attribute + +[ + (string_literal) + (byte_string_literal) + (system_lib_string) +] @string + +(integer_literal) @number + +(identifier) @variable + +(node + (identifier) @module) + +(property + (identifier) @property) + +(node + label: (_) @label) + +(call_expression + (identifier) @function.macro) + +(reference) @label ; referencing labeled_item.identifier + +(unit_address) @constant + +"=" @operator + +[ + "(" + ")" + "[" + "]" + "{" + "}" + "<" + ">" +] @punctuation.bracket + +[ + ";" + ":" + "," + "@" +] @punctuation.delimiter diff --git a/pack/ant/start/nvim-treesitter/queries/devicetree/indents.scm b/pack/ant/start/nvim-treesitter/queries/devicetree/indents.scm new file mode 100644 index 0000000..9740060 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/devicetree/indents.scm @@ -0,0 +1,12 @@ +[ + (node) + (property) + (integer_cells) +] @indent.begin + +[ + "}" + ">" +] @indent.branch + +(comment) @indent.ignore diff --git a/pack/ant/start/nvim-treesitter/queries/devicetree/injections.scm b/pack/ant/start/nvim-treesitter/queries/devicetree/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/devicetree/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/devicetree/locals.scm b/pack/ant/start/nvim-treesitter/queries/devicetree/locals.scm new file mode 100644 index 0000000..e33a81d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/devicetree/locals.scm @@ -0,0 +1,4 @@ +[ + (node) + (integer_cells) +] @local.scope diff --git a/pack/ant/start/nvim-treesitter/queries/dhall/folds.scm b/pack/ant/start/nvim-treesitter/queries/dhall/folds.scm new file mode 100644 index 0000000..bc92797 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dhall/folds.scm @@ -0,0 +1,10 @@ +[ + (let_binding) + (application_expression) + (lambda_expression) + (record_type) + (union_type) + (list_literal) + (record_literal) + (block_comment) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/dhall/highlights.scm b/pack/ant/start/nvim-treesitter/queries/dhall/highlights.scm new file mode 100644 index 0000000..efd7fed --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dhall/highlights.scm @@ -0,0 +1,193 @@ +; Text +; Imports +(missing_import) @keyword.import + +(local_import) @string.special.path + +(http_import) @string.special.url + +[ + (env_variable) + (import_hash) +] @string.special + +[ + (import_as_location) + (import_as_text) +] @type + +; Types +([ + (let_binding + (label) @type) + (union_type_entry + (label) @type) +] + (#lua-match? @type "^%u")) + +((primitive_expression + (identifier + (label) @type) + (selector + (label) @type)) @variable + (#lua-match? @variable "^[A-Z][^.]*$")) + +; Parameters +(lambda_expression + label: (label) @variable.parameter) + +; Variables +(label) @variable + +(identifier + [ + (label) @variable + (de_bruijn_index) @operator + ]) + +(let_binding + label: (label) @variable) + +; Fields +(record_literal_entry + (label) @variable.member) + +(record_type_entry + (label) @variable.member) + +(selector + (selector_dot) + (_) @variable.member) + +; Keywords +(env_import) @keyword + +[ + "let" + "in" + "assert" +] @keyword + +[ + "using" + "as" + "with" +] @keyword.operator + +; Operators +[ + (type_operator) + (assign_operator) + (lambda_operator) + (arrow_operator) + (infix_operator) + (completion_operator) + (assert_operator) + (forall_operator) + (empty_record_literal) +] @operator + +; Builtins +(builtin_function) @function.builtin + +(builtin + [ + "Natural" + "Natural/build" + "Natural/fold" + "Natural/isZero" + "Natural/even" + "Natural/odd" + "Natural/subtract" + "Natural/toInteger" + "Natural/show" + "Integer" + "Integer/toDouble" + "Integer/show" + "Integer/negate" + "Integer/clamp" + "Double" + "Double/show" + "List" + "List/build" + "List/fold" + "List/length" + "List/head" + "List/last" + "List/indexed" + "List/reverse" + "Text" + "Text/show" + "Text/replace" + "Optional" + "Date" + "Time" + "TimeZone" + "Type" + "Kind" + "Sort" + ] @type.builtin) + +; Punctuation +[ + "," + "|" +] @punctuation.delimiter + +(selector_dot) @punctuation.delimiter + +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "<" + ">" +] @punctuation.bracket + +; Conditionals +[ + "if" + "then" + "else" +] @keyword.conditional + +; Literals +(text_literal) @string + +(interpolation + "}" @string) + +[ + (double_quote_escaped) + (single_quote_escaped) +] @string.escape + +[ + (integer_literal) + (natural_literal) +] @number + +(double_literal) @number.float + +(boolean_literal) @boolean + +(builtin + "None") @constant.builtin + +; Comments +[ + (line_comment) + (block_comment) +] @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/dhall/injections.scm b/pack/ant/start/nvim-treesitter/queries/dhall/injections.scm new file mode 100644 index 0000000..3cd6aac --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dhall/injections.scm @@ -0,0 +1,5 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/diff/folds.scm b/pack/ant/start/nvim-treesitter/queries/diff/folds.scm new file mode 100644 index 0000000..3560abb --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/diff/folds.scm @@ -0,0 +1,5 @@ +[ + (block) + (hunks) + (hunk) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/diff/highlights.scm b/pack/ant/start/nvim-treesitter/queries/diff/highlights.scm new file mode 100644 index 0000000..54c57a8 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/diff/highlights.scm @@ -0,0 +1,49 @@ +(comment) @comment @spell + +[ + (addition) + (new_file) +] @diff.plus + +[ + (deletion) + (old_file) +] @diff.minus + +(commit) @constant + +(location) @attribute + +(command + "diff" @function + (argument) @variable.parameter) + +(filename) @string.special.path + +(mode) @number + +([ + ".." + "+" + "++" + "+++" + "++++" + "-" + "--" + "---" + "----" +] @punctuation.special + (#set! priority 95)) + +[ + (binary_change) + (similarity) + (file_change) +] @label + +(index + "index" @keyword) + +(similarity + (score) @number + "%" @number) diff --git a/pack/ant/start/nvim-treesitter/queries/diff/injections.scm b/pack/ant/start/nvim-treesitter/queries/diff/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/diff/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/disassembly/highlights.scm b/pack/ant/start/nvim-treesitter/queries/disassembly/highlights.scm new file mode 100644 index 0000000..b1ece9a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/disassembly/highlights.scm @@ -0,0 +1,30 @@ +(byte) @constant + +[ + (address) + (hexadecimal) + (integer) +] @number + +(identifier) @variable + +(bad_instruction) @comment.warning + +(code_location + (identifier) @function.call) + +(comment) @comment + +(instruction) @function + +(memory_dump) @string + +[ + "<" + ">" +] @punctuation.special + +[ + "+" + ":" +] @punctuation.delimiter diff --git a/pack/ant/start/nvim-treesitter/queries/disassembly/injections.scm b/pack/ant/start/nvim-treesitter/queries/disassembly/injections.scm new file mode 100644 index 0000000..9fb52da --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/disassembly/injections.scm @@ -0,0 +1,6 @@ +; TODO: https://github.com/nvim-treesitter/nvim-treesitter/pull/5548#issuecomment-1773707396 +; +; To be added once a compatible Assembly parser is merged into nvim-treesitter +; +; ((instruction) @injection.content +; (#set! injection.language "asm")) diff --git a/pack/ant/start/nvim-treesitter/queries/djot/folds.scm b/pack/ant/start/nvim-treesitter/queries/djot/folds.scm new file mode 100644 index 0000000..94f3724 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/djot/folds.scm @@ -0,0 +1,7 @@ +[ + (section) + (code_block) + (raw_block) + (list) + (div) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/djot/highlights.scm b/pack/ant/start/nvim-treesitter/queries/djot/highlights.scm new file mode 100644 index 0000000..8df7c92 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/djot/highlights.scm @@ -0,0 +1,396 @@ +(heading1) @markup.heading.1 + +(heading2) @markup.heading.2 + +(heading3) @markup.heading.3 + +(heading4) @markup.heading.4 + +(heading5) @markup.heading.5 + +(heading6) @markup.heading.6 + +(thematic_break) @string.special + +[ + (div_marker_begin) + (div_marker_end) +] @punctuation.delimiter + +([ + (code_block) + (raw_block) + (frontmatter) +] @markup.raw.block + (#set! priority 90)) + +; Remove @markup.raw for code with a language spec +(code_block + . + (code_block_marker_begin) + (language) + (code) @none + (#set! priority 90)) + +[ + (code_block_marker_begin) + (code_block_marker_end) + (raw_block_marker_begin) + (raw_block_marker_end) +] @punctuation.delimiter + +(language) @attribute + +(inline_attribute + _ @conceal + (#set! conceal "")) + +((language_marker) @punctuation.delimiter + (#set! conceal "")) + +(block_quote) @markup.quote + +(block_quote_marker) @punctuation.special + +(table_header) @markup.heading + +(table_header + "|" @punctuation.special) + +(table_row + "|" @punctuation.special) + +(table_separator) @punctuation.special + +(table_caption + (marker) @punctuation.special) + +(table_caption) @markup.italic + +[ + (list_marker_dash) + (list_marker_plus) + (list_marker_star) + (list_marker_definition) + (list_marker_decimal_period) + (list_marker_decimal_paren) + (list_marker_decimal_parens) + (list_marker_lower_alpha_period) + (list_marker_lower_alpha_paren) + (list_marker_lower_alpha_parens) + (list_marker_upper_alpha_period) + (list_marker_upper_alpha_paren) + (list_marker_upper_alpha_parens) + (list_marker_lower_roman_period) + (list_marker_lower_roman_paren) + (list_marker_lower_roman_parens) + (list_marker_upper_roman_period) + (list_marker_upper_roman_paren) + (list_marker_upper_roman_parens) +] @markup.list + +(list_marker_task + (unchecked)) @markup.list.unchecked + +(list_marker_task + (checked)) @markup.list.checked + +; Colorize `x` in `[x]` +((checked) @constant.builtin + (#offset! @constant.builtin 0 1 0 -1)) + +[ + (ellipsis) + (en_dash) + (em_dash) + (quotation_marks) +] @string.special + +(list_item + (term) @type.definition) + +; Conceal { and } but leave " and ' +((quotation_marks) @string.special + (#any-of? @string.special "\"}" "'}") + (#offset! @string.special 0 1 0 0) + (#set! conceal "")) + +((quotation_marks) @string.special + (#any-of? @string.special "\\\"" "\\'" "{'" "{\"") + (#offset! @string.special 0 0 0 -1) + (#set! conceal "")) + +[ + (hard_line_break) + (backslash_escape) +] @string.escape + +; Only conceal \ but leave escaped character. +((backslash_escape) @string.escape + (#offset! @string.escape 0 0 0 -1) + (#set! conceal "")) + +(frontmatter_marker) @punctuation.delimiter + +(emphasis) @markup.italic + +(strong) @markup.strong + +(symbol) @string.special.symbol + +(insert) @markup.underline + +(delete) @markup.strikethrough + +[ + (highlighted) + (superscript) + (subscript) +] @string.special + +; We need to target tokens specifically because `{=` etc can exist as fallback symbols in +; regular text, which we don't want to highlight or conceal. +(highlighted + [ + "{=" + "=}" + ] @punctuation.delimiter + (#set! conceal "")) + +(insert + [ + "{+" + "+}" + ] @punctuation.delimiter + (#set! conceal "")) + +(delete + [ + "{-" + "-}" + ] @punctuation.delimiter + (#set! conceal "")) + +(superscript + [ + "^" + "{^" + "^}" + ] @punctuation.delimiter + (#set! conceal "")) + +(subscript + [ + "~" + "{~" + "~}" + ] @punctuation.delimiter + (#set! conceal "")) + +([ + (emphasis_begin) + (emphasis_end) + (strong_begin) + (strong_end) + (verbatim_marker_begin) + (verbatim_marker_end) + (math_marker) + (math_marker_begin) + (math_marker_end) + (raw_inline_attribute) + (raw_inline_marker_begin) + (raw_inline_marker_end) +] @punctuation.delimiter + (#set! conceal "")) + +((math) @markup.math + (#set! priority 90)) + +(verbatim) @markup.raw + +((raw_inline) @markup.raw + (#set! priority 90)) + +(comment + "%" @comment + (#set! conceal "")) + +(span + [ + "[" + "]" + ] @punctuation.bracket) + +(inline_attribute + [ + "{" + "}" + ] @punctuation.bracket) + +(block_attribute + [ + "{" + "}" + ] @punctuation.bracket) + +[ + (class) + (class_name) +] @type + +(identifier) @tag + +(key_value + "=" @operator) + +(key_value + (key) @property) + +(key_value + (value) @string) + +(link_text + [ + "[" + "]" + ] @punctuation.bracket + (#set! conceal "")) + +(autolink + [ + "<" + ">" + ] @punctuation.bracket + (#set! conceal "")) + +(inline_link + (inline_link_destination) @markup.link.url + (#set! conceal "")) + +(link_reference_definition + ":" @punctuation.special) + +(full_reference_link + (link_text) @markup.link) + +(full_reference_link + (link_label) @markup.link.label + (#set! conceal "")) + +(collapsed_reference_link + "[]" @punctuation.bracket + (#set! conceal "")) + +(full_reference_link + [ + "[" + "]" + ] @punctuation.bracket + (#set! conceal "")) + +(collapsed_reference_link + (link_text) @markup.link) + +(collapsed_reference_link + (link_text) @markup.link.label) + +(inline_link + (link_text) @markup.link) + +(full_reference_image + (link_label) @markup.link.label) + +(full_reference_image + [ + "![" + "[" + "]" + ] @punctuation.bracket) + +(collapsed_reference_image + [ + "![" + "]" + ] @punctuation.bracket) + +(inline_image + [ + "![" + "]" + ] @punctuation.bracket) + +(image_description) @markup.italic + +(image_description + [ + "[" + "]" + ] @punctuation.bracket) + +(link_reference_definition + [ + "[" + "]" + ] @punctuation.bracket) + +(link_reference_definition + (link_label) @markup.link.label) + +(inline_link_destination + [ + "(" + ")" + ] @punctuation.bracket) + +[ + (autolink) + (inline_link_destination) + (link_destination) + (link_reference_definition) +] @markup.link.url + +(footnote + (reference_label) @markup.link.label) + +(footnote_reference + (reference_label) @markup.link.label) + +[ + (footnote_marker_begin) + (footnote_marker_end) +] @punctuation.bracket + +(todo) @comment.todo + +(note) @comment.note + +(fixme) @comment.error + +[ + (paragraph) + (comment) + (table_cell) +] @spell + +[ + (autolink) + (inline_link_destination) + (link_destination) + (code_block) + (raw_block) + (math) + (raw_inline) + (verbatim) + (reference_label) + (class) + (class_name) + (identifier) + (key_value) + (frontmatter) +] @nospell + +(full_reference_link + (link_label) @nospell) + +(full_reference_image + (link_label) @nospell) diff --git a/pack/ant/start/nvim-treesitter/queries/djot/indents.scm b/pack/ant/start/nvim-treesitter/queries/djot/indents.scm new file mode 100644 index 0000000..3b1a56e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/djot/indents.scm @@ -0,0 +1,10 @@ +; The intention here is to rely on Neovims `autoindent` setting. +; This allows us to not indent after just a single list item +; so we can create narrow lists quickly, but indent blocks inside list items +; to the previous paragraph. +(list_item_content) @indent.auto + +(footnote_content) @indent.align + +((table_caption) @indent.begin + (#set! indent.immediate 1)) diff --git a/pack/ant/start/nvim-treesitter/queries/djot/injections.scm b/pack/ant/start/nvim-treesitter/queries/djot/injections.scm new file mode 100644 index 0000000..078b403 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/djot/injections.scm @@ -0,0 +1,20 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +(code_block + (language) @injection.language + (code) @injection.content) + +(raw_block + (raw_block_info + (language) @injection.language) + (content) @injection.content) + +(raw_inline + (content) @injection.content + (raw_inline_attribute + (language) @injection.language)) + +(frontmatter + (language) @injection.language + (frontmatter_content) @injection.content) diff --git a/pack/ant/start/nvim-treesitter/queries/djot/locals.scm b/pack/ant/start/nvim-treesitter/queries/djot/locals.scm new file mode 100644 index 0000000..1ac2752 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/djot/locals.scm @@ -0,0 +1,17 @@ +(link_reference_definition + (link_label) @local.definition) + +(footnote + (reference_label) @local.definition) + +(collapsed_reference_link + (link_text) @local.reference) + +(full_reference_link + (link_label) @local.reference) + +(full_reference_image + (link_label) @local.reference) + +(footnote_reference + (reference_label) @local.reference) diff --git a/pack/ant/start/nvim-treesitter/queries/dockerfile/highlights.scm b/pack/ant/start/nvim-treesitter/queries/dockerfile/highlights.scm new file mode 100644 index 0000000..72893f8 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dockerfile/highlights.scm @@ -0,0 +1,68 @@ +[ + "FROM" + "AS" + "RUN" + "CMD" + "LABEL" + "EXPOSE" + "ENV" + "ADD" + "COPY" + "ENTRYPOINT" + "VOLUME" + "USER" + "WORKDIR" + "ARG" + "ONBUILD" + "STOPSIGNAL" + "HEALTHCHECK" + "SHELL" + "MAINTAINER" + "CROSS_BUILD" +] @keyword + +[ + ":" + "@" +] @operator + +(comment) @comment @spell + +(image_spec + (image_tag + ":" @punctuation.special) + (image_digest + "@" @punctuation.special)) + +(double_quoted_string) @string + +[ + (heredoc_marker) + (heredoc_end) +] @label + +((heredoc_block + (heredoc_line) @string) + (#set! priority 90)) + +(expansion + [ + "$" + "{" + "}" + ] @punctuation.special) + +((variable) @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + +(arg_instruction + . + (unquoted_string) @property) + +(env_instruction + (env_pair + . + (unquoted_string) @property)) + +(expose_instruction + (expose_port) @number) diff --git a/pack/ant/start/nvim-treesitter/queries/dockerfile/injections.scm b/pack/ant/start/nvim-treesitter/queries/dockerfile/injections.scm new file mode 100644 index 0000000..5d3bbff --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dockerfile/injections.scm @@ -0,0 +1,12 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((shell_command + (shell_fragment) @injection.content) + (#set! injection.language "bash") + (#set! injection.combined)) + +((run_instruction + (heredoc_block) @injection.content) + (#set! injection.language "bash") + (#set! injection.include-children)) diff --git a/pack/ant/start/nvim-treesitter/queries/dot/highlights.scm b/pack/ant/start/nvim-treesitter/queries/dot/highlights.scm new file mode 100644 index 0000000..75ad922 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dot/highlights.scm @@ -0,0 +1,49 @@ +(identifier) @type + +[ + "strict" + "graph" + "digraph" + "subgraph" + "node" + "edge" +] @keyword + +(string_literal) @string + +(number_literal) @number + +[ + (edgeop) + (operator) +] @operator + +[ + "," + ";" +] @punctuation.delimiter + +[ + "{" + "}" + "[" + "]" + "<" + ">" +] @punctuation.bracket + +(subgraph + id: (id + (identifier) @module)) + +(attribute + name: (id + (identifier) @variable.member)) + +(attribute + value: (id + (identifier) @constant)) + +(comment) @comment @spell + +(preproc) @keyword.directive diff --git a/pack/ant/start/nvim-treesitter/queries/dot/indents.scm b/pack/ant/start/nvim-treesitter/queries/dot/indents.scm new file mode 100644 index 0000000..a951e55 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dot/indents.scm @@ -0,0 +1,9 @@ +[ + (block) + (attr_list) +] @indent.begin + +[ + "}" + "]" +] @indent.branch @indent.end diff --git a/pack/ant/start/nvim-treesitter/queries/dot/injections.scm b/pack/ant/start/nvim-treesitter/queries/dot/injections.scm new file mode 100644 index 0000000..4fe39a8 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dot/injections.scm @@ -0,0 +1,5 @@ +((html_internal) @injection.content + (#set! injection.language "html")) + +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/doxygen/highlights.scm b/pack/ant/start/nvim-treesitter/queries/doxygen/highlights.scm new file mode 100644 index 0000000..454500d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/doxygen/highlights.scm @@ -0,0 +1,61 @@ +((tag_name) @keyword + (#set! priority 105)) + +[ + "@code" + "@endcode" +] @keyword + +(identifier) @variable + +((tag + (tag_name) @_param + (identifier) @variable.parameter) + (#any-of? @_param "@param" "\\param")) + +(function + (identifier) @function) + +(function_link) @function + +(emphasis) @markup.italic + +[ + "\\a" + "\\c" +] @tag + +(code_block_language) @label + +[ + "in" + "out" + "inout" +] @keyword.modifier + +"~" @operator + +[ + "" + "" +] @tag + +[ + "." + "," + "::" + (code_block_start) + (code_block_end) +] @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +(code_block_content) @none diff --git a/pack/ant/start/nvim-treesitter/queries/doxygen/indents.scm b/pack/ant/start/nvim-treesitter/queries/doxygen/indents.scm new file mode 100644 index 0000000..ef30f1e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/doxygen/indents.scm @@ -0,0 +1 @@ +(document) @indent.auto diff --git a/pack/ant/start/nvim-treesitter/queries/doxygen/injections.scm b/pack/ant/start/nvim-treesitter/queries/doxygen/injections.scm new file mode 100644 index 0000000..994f535 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/doxygen/injections.scm @@ -0,0 +1,15 @@ +((type) @injection.content + (#set! injection.parent)) + +([ + (function_link) + (code) +] @injection.content + (#set! injection.parent)) + +((link) @injection.content + (#set! injection.language "html")) + +(code_block + (code_block_language) @injection.language + (code_block_content) @injection.content) diff --git a/pack/ant/start/nvim-treesitter/queries/dtd/folds.scm b/pack/ant/start/nvim-treesitter/queries/dtd/folds.scm new file mode 100644 index 0000000..b1bce4f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dtd/folds.scm @@ -0,0 +1,4 @@ +[ + (conditionalSect) + (Comment) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/dtd/highlights.scm b/pack/ant/start/nvim-treesitter/queries/dtd/highlights.scm new file mode 100644 index 0000000..9afd6e3 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dtd/highlights.scm @@ -0,0 +1,148 @@ +; Text declaration +(TextDecl + "xml" @keyword.directive) + +(TextDecl + [ + "version" + "encoding" + ] @tag.attribute) + +(TextDecl + (EncName) @string.special) + +(TextDecl + (VersionNum) @number) + +; Processing instructions +(PI) @keyword.directive + +; Element declaration +(elementdecl + "ELEMENT" @keyword.directive.define + (Name) @tag) + +(contentspec + (_ + (Name) @tag.attribute)) + +"#PCDATA" @type.builtin + +[ + "EMPTY" + "ANY" +] @keyword.modifier + +[ + "*" + "?" + "+" +] @character.special + +; Entity declaration +(GEDecl + "ENTITY" @keyword.directive.define + (Name) @constant) + +(GEDecl + (EntityValue) @string) + +(NDataDecl + "NDATA" @keyword + (Name) @label) + +; Parsed entity declaration +(PEDecl + "ENTITY" @keyword.directive.define + "%" @operator + (Name) @function.macro) + +(PEDecl + (EntityValue) @string) + +; Notation declaration +(NotationDecl + "NOTATION" @keyword.directive + (Name) @label) + +; Attlist declaration +(AttlistDecl + "ATTLIST" @keyword.directive.define + (Name) @tag) + +(AttDef + (Name) @tag.attribute) + +(AttDef + (Enumeration + (Nmtoken) @string)) + +[ + (StringType) + (TokenizedType) +] @type.builtin + +(NotationType + "NOTATION" @type.builtin) + +[ + "#REQUIRED" + "#IMPLIED" + "#FIXED" +] @attribute + +; Entities +(EntityRef) @constant + +((EntityRef) @constant.builtin + (#any-of? @constant.builtin "&" "<" ">" """ "'")) + +(CharRef) @character + +(PEReference) @function.macro + +; External references +[ + "PUBLIC" + "SYSTEM" +] @keyword + +(PubidLiteral) @string.special + +(SystemLiteral + (URI) @string.special.url) + +; Delimiters & punctuation +[ + "" + "" + "" +] @tag.delimiter + +[ + "(" + ")" + "[" +] @punctuation.bracket + +[ + "\"" + "'" +] @punctuation.delimiter + +[ + "," + "|" + "=" +] @operator + +; Misc +[ + "INCLUDE" + "IGNORE" +] @keyword.import + +(Comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/dtd/injections.scm b/pack/ant/start/nvim-treesitter/queries/dtd/injections.scm new file mode 100644 index 0000000..ed5557a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dtd/injections.scm @@ -0,0 +1 @@ +(Comment) @comment diff --git a/pack/ant/start/nvim-treesitter/queries/dtd/locals.scm b/pack/ant/start/nvim-treesitter/queries/dtd/locals.scm new file mode 100644 index 0000000..88246c0 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/dtd/locals.scm @@ -0,0 +1,11 @@ +(elementdecl + (Name) @local.definition.type) + +(elementdecl + (contentspec + (children + (Name) @local.reference))) + +(AttlistDecl + . + (Name) @local.reference) diff --git a/pack/ant/start/nvim-treesitter/queries/earthfile/highlights.scm b/pack/ant/start/nvim-treesitter/queries/earthfile/highlights.scm new file mode 100644 index 0000000..cc7dce2 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/earthfile/highlights.scm @@ -0,0 +1,129 @@ +(string_array + "," @punctuation.delimiter) + +(string_array + [ + "[" + "]" + ] @punctuation.bracket) + +[ + "ARG" + "AS LOCAL" + "BUILD" + "CACHE" + "CMD" + "COPY" + "DO" + "ENTRYPOINT" + "ENV" + "EXPOSE" + "FROM DOCKERFILE" + "FROM" + "FUNCTION" + "GIT CLONE" + "HOST" + "IMPORT" + "LABEL" + "LET" + "PROJECT" + "RUN" + "SAVE ARTIFACT" + "SAVE IMAGE" + "SET" + "USER" + "VERSION" + "VOLUME" + "WORKDIR" +] @keyword + +(for_command + [ + "FOR" + "IN" + "END" + ] @keyword.repeat) + +(if_command + [ + "IF" + "END" + ] @keyword.conditional) + +(elif_block + "ELSE IF" @keyword.conditional) + +(else_block + "ELSE" @keyword.conditional) + +(import_command + [ + "IMPORT" + "AS" + ] @keyword.import) + +(try_command + [ + "TRY" + "FINALLY" + "END" + ] @keyword.exception) + +(wait_command + [ + "WAIT" + "END" + ] @keyword) + +(with_docker_command + [ + "WITH DOCKER" + "END" + ] @keyword) + +[ + (comment) + (line_continuation_comment) +] @comment @spell + +[ + (target_ref) + (target_artifact) + (function_ref) +] @function + +(target + (identifier) @function) + +[ + (double_quoted_string) + (single_quoted_string) +] @string + +(unquoted_string) @string.special + +(escape_sequence) @string.escape + +(variable) @variable + +(expansion + [ + "$" + "{" + "}" + "(" + ")" + ] @punctuation.special) + +(build_arg + [ + "--" + (variable) + ] @variable.parameter) + +(options + (_) @property) + +"=" @operator + +(line_continuation) @operator diff --git a/pack/ant/start/nvim-treesitter/queries/earthfile/injections.scm b/pack/ant/start/nvim-treesitter/queries/earthfile/injections.scm new file mode 100644 index 0000000..7435a40 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/earthfile/injections.scm @@ -0,0 +1,9 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((line_continuation_comment) @injection.content + (#set! injection.language "comment")) + +((shell_fragment) @injection.content + (#set! injection.language "bash") + (#set! injection.include-children)) diff --git a/pack/ant/start/nvim-treesitter/queries/ebnf/highlights.scm b/pack/ant/start/nvim-treesitter/queries/ebnf/highlights.scm new file mode 100644 index 0000000..4254d04 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/ebnf/highlights.scm @@ -0,0 +1,42 @@ +; Simple tokens ;;;; +(terminal) @string + +(special_sequence) @string.special + +(integer) @number + +(comment) @comment @spell + +; Identifiers ;;;; +; Allow different highlighting for specific casings +((identifier) @type + (#lua-match? @type "^%u")) + +((identifier) @string.special.symbol + (#lua-match? @string.special.symbol "^%l")) + +((identifier) @constant + (#lua-match? @constant "^%u[%u%d_]+$")) + +; Punctuation ;;;; +[ + ";" + "," +] @punctuation.delimiter + +[ + "|" + "*" + "-" +] @operator + +"=" @keyword.operator + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket diff --git a/pack/ant/start/nvim-treesitter/queries/ebnf/injections.scm b/pack/ant/start/nvim-treesitter/queries/ebnf/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/ebnf/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/ecma/folds.scm b/pack/ant/start/nvim-treesitter/queries/ecma/folds.scm new file mode 100644 index 0000000..a348f34 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/ecma/folds.scm @@ -0,0 +1,24 @@ +[ + (arguments) + (for_in_statement) + (for_statement) + (while_statement) + (arrow_function) + (function_expression) + (function_declaration) + (class_declaration) + (method_definition) + (do_statement) + (with_statement) + (switch_statement) + (switch_case) + (switch_default) + (import_statement)+ + (if_statement) + (try_statement) + (catch_clause) + (array) + (object) + (generator_function) + (generator_function_declaration) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/ecma/highlights.scm b/pack/ant/start/nvim-treesitter/queries/ecma/highlights.scm new file mode 100644 index 0000000..038df56 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/ecma/highlights.scm @@ -0,0 +1,380 @@ +; Types +; Javascript +; Variables +;----------- +(identifier) @variable + +; Properties +;----------- +(property_identifier) @variable.member + +(shorthand_property_identifier) @variable.member + +(private_property_identifier) @variable.member + +(object_pattern + (shorthand_property_identifier_pattern) @variable) + +(object_pattern + (object_assignment_pattern + (shorthand_property_identifier_pattern) @variable)) + +; Special identifiers +;-------------------- +((identifier) @type + (#lua-match? @type "^[A-Z]")) + +((identifier) @constant + (#lua-match? @constant "^_*[A-Z][A-Z%d_]*$")) + +((shorthand_property_identifier) @constant + (#lua-match? @constant "^_*[A-Z][A-Z%d_]*$")) + +((identifier) @variable.builtin + (#any-of? @variable.builtin "arguments" "module" "console" "window" "document")) + +((identifier) @type.builtin + (#any-of? @type.builtin + "Object" "Function" "Boolean" "Symbol" "Number" "Math" "Date" "String" "RegExp" "Map" "Set" + "WeakMap" "WeakSet" "Promise" "Array" "Int8Array" "Uint8Array" "Uint8ClampedArray" "Int16Array" + "Uint16Array" "Int32Array" "Uint32Array" "Float32Array" "Float64Array" "ArrayBuffer" "DataView" + "Error" "EvalError" "InternalError" "RangeError" "ReferenceError" "SyntaxError" "TypeError" + "URIError")) + +(statement_identifier) @label + +; Function and method definitions +;-------------------------------- +(function_expression + name: (identifier) @function) + +(function_declaration + name: (identifier) @function) + +(generator_function + name: (identifier) @function) + +(generator_function_declaration + name: (identifier) @function) + +(method_definition + name: [ + (property_identifier) + (private_property_identifier) + ] @function.method) + +(method_definition + name: (property_identifier) @constructor + (#eq? @constructor "constructor")) + +(pair + key: (property_identifier) @function.method + value: (function_expression)) + +(pair + key: (property_identifier) @function.method + value: (arrow_function)) + +(assignment_expression + left: (member_expression + property: (property_identifier) @function.method) + right: (arrow_function)) + +(assignment_expression + left: (member_expression + property: (property_identifier) @function.method) + right: (function_expression)) + +(variable_declarator + name: (identifier) @function + value: (arrow_function)) + +(variable_declarator + name: (identifier) @function + value: (function_expression)) + +(assignment_expression + left: (identifier) @function + right: (arrow_function)) + +(assignment_expression + left: (identifier) @function + right: (function_expression)) + +; Function and method calls +;-------------------------- +(call_expression + function: (identifier) @function.call) + +(call_expression + function: (member_expression + property: [ + (property_identifier) + (private_property_identifier) + ] @function.method.call)) + +; Builtins +;--------- +((identifier) @module.builtin + (#eq? @module.builtin "Intl")) + +((identifier) @function.builtin + (#any-of? @function.builtin + "eval" "isFinite" "isNaN" "parseFloat" "parseInt" "decodeURI" "decodeURIComponent" "encodeURI" + "encodeURIComponent" "require")) + +; Constructor +;------------ +(new_expression + constructor: (identifier) @constructor) + +; Decorators +;---------- +(decorator + "@" @attribute + (identifier) @attribute) + +(decorator + "@" @attribute + (call_expression + (identifier) @attribute)) + +(decorator + "@" @attribute + (member_expression + (property_identifier) @attribute)) + +(decorator + "@" @attribute + (call_expression + (member_expression + (property_identifier) @attribute))) + +; Literals +;--------- +[ + (this) + (super) +] @variable.builtin + +((identifier) @variable.builtin + (#eq? @variable.builtin "self")) + +[ + (true) + (false) +] @boolean + +[ + (null) + (undefined) +] @constant.builtin + +[ + (comment) + (html_comment) +] @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$")) + +(hash_bang_line) @keyword.directive + +((string_fragment) @keyword.directive + (#eq? @keyword.directive "use strict")) + +(string) @string + +(template_string) @string + +(escape_sequence) @string.escape + +(regex_pattern) @string.regexp + +(regex_flags) @character.special + +(regex + "/" @punctuation.bracket) ; Regex delimiters + +(number) @number + +((identifier) @number + (#any-of? @number "NaN" "Infinity")) + +; Punctuation +;------------ +[ + ";" + "." + "," + ":" +] @punctuation.delimiter + +[ + "--" + "-" + "-=" + "&&" + "+" + "++" + "+=" + "&=" + "/=" + "**=" + "<<=" + "<" + "<=" + "<<" + "=" + "==" + "===" + "!=" + "!==" + "=>" + ">" + ">=" + ">>" + "||" + "%" + "%=" + "*" + "**" + ">>>" + "&" + "|" + "^" + "??" + "*=" + ">>=" + ">>>=" + "^=" + "|=" + "&&=" + "||=" + "??=" + "..." +] @operator + +(binary_expression + "/" @operator) + +(ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +(unary_expression + [ + "!" + "~" + "-" + "+" + ] @operator) + +(unary_expression + [ + "delete" + "void" + ] @keyword.operator) + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(template_substitution + [ + "${" + "}" + ] @punctuation.special) @none + +; Imports +;---------- +(namespace_import + "*" @character.special + (identifier) @module) + +(namespace_export + "*" @character.special + (identifier) @module) + +(export_statement + "*" @character.special) + +; Keywords +;---------- +[ + "if" + "else" + "switch" + "case" +] @keyword.conditional + +[ + "import" + "from" + "as" + "export" +] @keyword.import + +[ + "for" + "of" + "do" + "while" + "continue" +] @keyword.repeat + +[ + "break" + "const" + "debugger" + "extends" + "get" + "let" + "set" + "static" + "target" + "var" + "with" +] @keyword + +"class" @keyword.type + +[ + "async" + "await" +] @keyword.coroutine + +[ + "return" + "yield" +] @keyword.return + +"function" @keyword.function + +[ + "new" + "delete" + "in" + "instanceof" + "typeof" +] @keyword.operator + +[ + "throw" + "try" + "catch" + "finally" +] @keyword.exception + +(export_statement + "default" @keyword) + +(switch_default + "default" @keyword.conditional) diff --git a/pack/ant/start/nvim-treesitter/queries/ecma/indents.scm b/pack/ant/start/nvim-treesitter/queries/ecma/indents.scm new file mode 100644 index 0000000..d567416 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/ecma/indents.scm @@ -0,0 +1,82 @@ +[ + (arguments) + (array) + (binary_expression) + (class_body) + (export_clause) + (formal_parameters) + (named_imports) + (object) + (object_pattern) + (parenthesized_expression) + (return_statement) + (statement_block) + (switch_case) + (switch_default) + (switch_statement) + (template_substitution) + (ternary_expression) +] @indent.begin + +(arguments + (call_expression) @indent.begin) + +(binary_expression + (call_expression) @indent.begin) + +(expression_statement + (call_expression) @indent.begin) + +(arrow_function + body: (_) @_body + (#not-kind-eq? @_body "statement_block")) @indent.begin + +(assignment_expression + right: (_) @_right + (#not-kind-eq? @_right "arrow_function" "function")) @indent.begin + +(variable_declarator + value: (_) @_value + (#not-kind-eq? @_value "arrow_function" "call_expression" "function")) @indent.begin + +(arguments + ")" @indent.end) + +(object + "}" @indent.end) + +(statement_block + "}" @indent.end) + +[ + (arguments + (object)) + ")" + "}" + "]" +] @indent.branch + +(statement_block + "{" @indent.branch) + +((parenthesized_expression + "(" + (_) + ")" @indent.end) @_outer + (#not-has-parent? @_outer if_statement)) + +[ + "}" + "]" +] @indent.end + +(template_string) @indent.ignore + +[ + (comment) + (ERROR) +] @indent.auto + +(if_statement + consequence: (_) @indent.dedent + (#not-kind-eq? @indent.dedent statement_block)) @indent.begin diff --git a/pack/ant/start/nvim-treesitter/queries/ecma/injections.scm b/pack/ant/start/nvim-treesitter/queries/ecma/injections.scm new file mode 100644 index 0000000..04abafc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/ecma/injections.scm @@ -0,0 +1,203 @@ +(((comment) @_jsdoc_comment + (#lua-match? @_jsdoc_comment "^/[*][*][^*].*[*]/$")) @injection.content + (#set! injection.language "jsdoc")) + +((comment) @injection.content + (#set! injection.language "comment")) + +; html(`...`), html`...`, sql(`...`), etc. +(call_expression + function: (identifier) @injection.language + arguments: [ + (arguments + (template_string) @injection.content) + (template_string) @injection.content + ] + (#lua-match? @injection.language "^[a-zA-Z][a-zA-Z0-9]*$") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + ; Languages excluded from auto-injection due to special rules + ; - svg uses the html parser + ; - css uses the styled parser + (#not-any-of? @injection.language "svg" "css")) + +; svg`...` or svg(`...`) +(call_expression + function: (identifier) @_name + (#eq? @_name "svg") + arguments: [ + (arguments + (template_string) @injection.content) + (template_string) @injection.content + ] + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "html")) + +; Vercel PostgreSQL +; foo.sql`...` or foo.sql(`...`) +(call_expression + function: (member_expression + property: (property_identifier) @injection.language) + arguments: [ + (arguments + (template_string) @injection.content) + (template_string) @injection.content + ] + (#eq? @injection.language "sql") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children)) + +(call_expression + function: (identifier) @_name + (#eq? @_name "gql") + arguments: (template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "graphql")) + +(call_expression + function: (identifier) @_name + (#eq? @_name "hbs") + arguments: (template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "glimmer")) + +; css``, keyframes`` +(call_expression + function: (identifier) @_name + (#any-of? @_name "css" "keyframes") + arguments: (template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "styled")) + +; styled.div`` +(call_expression + function: (member_expression + object: (identifier) @_name + (#eq? @_name "styled")) + arguments: ((template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "styled"))) + +; styled(Component)`` +(call_expression + function: (call_expression + function: (identifier) @_name + (#eq? @_name "styled")) + arguments: ((template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "styled"))) + +; styled.div.attrs({ prop: "foo" })`` +(call_expression + function: (call_expression + function: (member_expression + object: (member_expression + object: (identifier) @_name + (#eq? @_name "styled")))) + arguments: ((template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "styled"))) + +; styled(Component).attrs({ prop: "foo" })`` +(call_expression + function: (call_expression + function: (member_expression + object: (call_expression + function: (identifier) @_name + (#eq? @_name "styled")))) + arguments: ((template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "styled"))) + +((regex_pattern) @injection.content + (#set! injection.language "regex")) + +; ((comment) @_gql_comment +; (#eq? @_gql_comment "/* GraphQL */") +; (template_string) @injection.content +; (#set! injection.language "graphql")) +((template_string) @injection.content + (#lua-match? @injection.content "^`#graphql") + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "graphql")) + +; el.innerHTML = `` +(assignment_expression + left: (member_expression + property: (property_identifier) @_prop + (#any-of? @_prop "outerHTML" "innerHTML")) + right: (template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "html")) + +; el.innerHTML = '' +(assignment_expression + left: (member_expression + property: (property_identifier) @_prop + (#any-of? @_prop "outerHTML" "innerHTML")) + right: (string + (string_fragment) @injection.content) + (#set! injection.language "html")) + +;---- Angular injections ----- +; @Component({ +; template: `` +; }) +(decorator + (call_expression + function: ((identifier) @_name + (#eq? @_name "Component")) + arguments: (arguments + (object + (pair + key: ((property_identifier) @_prop + (#eq? @_prop "template")) + value: ((template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "angular"))))))) + +; @Component({ +; styles: [``] +; }) +(decorator + (call_expression + function: ((identifier) @_name + (#eq? @_name "Component")) + arguments: (arguments + (object + (pair + key: ((property_identifier) @_prop + (#eq? @_prop "styles")) + value: (array + ((template_string) @injection.content + (#offset! @injection.content 0 1 0 -1) + (#set! injection.include-children) + (#set! injection.language "css")))))))) + +; @Component({ +; styles: `` +; }) +(decorator + (call_expression + function: ((identifier) @_name + (#eq? @_name "Component")) + arguments: (arguments + (object + (pair + key: ((property_identifier) @_prop + (#eq? @_prop "styles")) + value: ((template_string) @injection.content + (#set! injection.include-children) + (#offset! @injection.content 0 1 0 -1) + (#set! injection.language "css"))))))) diff --git a/pack/ant/start/nvim-treesitter/queries/ecma/locals.scm b/pack/ant/start/nvim-treesitter/queries/ecma/locals.scm new file mode 100644 index 0000000..24ea7c0 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/ecma/locals.scm @@ -0,0 +1,42 @@ +; Scopes +;------- +(statement_block) @local.scope + +(function_expression) @local.scope + +(arrow_function) @local.scope + +(function_declaration) @local.scope + +(method_definition) @local.scope + +(for_statement) @local.scope + +(for_in_statement) @local.scope + +(catch_clause) @local.scope + +; Definitions +;------------ +(variable_declarator + name: (identifier) @local.definition.var) + +(import_specifier + (identifier) @local.definition.import) + +(namespace_import + (identifier) @local.definition.import) + +(function_declaration + (identifier) @local.definition.function + (#set! definition.var.scope parent)) + +(method_definition + (property_identifier) @local.definition.function + (#set! definition.var.scope parent)) + +; References +;------------ +(identifier) @local.reference + +(shorthand_property_identifier) @local.reference diff --git a/pack/ant/start/nvim-treesitter/queries/editorconfig/folds.scm b/pack/ant/start/nvim-treesitter/queries/editorconfig/folds.scm new file mode 100644 index 0000000..911798f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/editorconfig/folds.scm @@ -0,0 +1 @@ +(section) @fold diff --git a/pack/ant/start/nvim-treesitter/queries/editorconfig/highlights.scm b/pack/ant/start/nvim-treesitter/queries/editorconfig/highlights.scm new file mode 100644 index 0000000..feb0a52 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/editorconfig/highlights.scm @@ -0,0 +1,55 @@ +(comment) @comment @spell + +(section + (section_name) @string.special.path) + +(character_choice + (character) @constant) + +(character_range + start: (character) @constant + end: (character) @constant) + +[ + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "," + ".." + (path_separator) +] @punctuation.delimiter + +[ + "-" + "=" + (negation) +] @operator + +[ + (wildcard_characters) + (wildcard_any_characters) + (wildcard_single_character) +] @character.special + +(escaped_character) @string.escape + +(pair + key: (identifier) @property + value: (_) @string) + +(boolean) @boolean + +(integer) @number + +(unset) @constant.builtin + +[ + (spelling_language) + (indent_style) + (end_of_line) + (charset) +] @string.special diff --git a/pack/ant/start/nvim-treesitter/queries/editorconfig/injections.scm b/pack/ant/start/nvim-treesitter/queries/editorconfig/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/editorconfig/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/eds/folds.scm b/pack/ant/start/nvim-treesitter/queries/eds/folds.scm new file mode 100644 index 0000000..911798f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/eds/folds.scm @@ -0,0 +1 @@ +(section) @fold diff --git a/pack/ant/start/nvim-treesitter/queries/eds/highlights.scm b/pack/ant/start/nvim-treesitter/queries/eds/highlights.scm new file mode 100644 index 0000000..0e008c9 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/eds/highlights.scm @@ -0,0 +1,45 @@ +"=" @punctuation.delimiter + +[ + "[" + "]" +] @punctuation.bracket + +((section_name) @variable.builtin + (#match? @variable.builtin + "\\c^(FileInfo|DeviceInfo|DummyUsage|MandatoryObjects|OptionalObjects)$")) + +((section_name) @variable.builtin + (#lua-match? @variable.builtin "^1")) + +(section + (section_name) @_name + (#match? @_name "\\c^Comments$")) @comment + +(section + (section_name) @_name + (statement + (key) @_key) @string + (#match? @_key "\\c^ParameterName$") + (#not-match? @_name "\\c^Comments$")) + +(section + (section_name) @_name + (statement + (key) @_key) @type + (#match? @_key "\\c^(ObjectType|DataType|AccessType)$") + (#not-match? @_name "\\c^Comments$")) + +(section + (section_name) @_name + (statement + (key) @_key) @attribute + (#match? @_key "\\c^PDOMapping$") + (#not-match? @_name "\\c^Comments$")) + +(section + (section_name) @_name + (statement + (key) @_key) @number + (#match? @_key "\\c^(DefaultValue|LowLimit|HighLimit|SubNumber)$") + (#not-match? @_name "\\c^Comments$")) diff --git a/pack/ant/start/nvim-treesitter/queries/eex/highlights.scm b/pack/ant/start/nvim-treesitter/queries/eex/highlights.scm new file mode 100644 index 0000000..d032a74 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/eex/highlights.scm @@ -0,0 +1,12 @@ +[ + "%>" + "--%>" + "<%!--" + "<%" + "<%#" + "<%%=" + "<%=" +] @tag.delimiter + +; EEx comments are highlighted as such +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/eex/injections.scm b/pack/ant/start/nvim-treesitter/queries/eex/injections.scm new file mode 100644 index 0000000..f13d3c1 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/eex/injections.scm @@ -0,0 +1,8 @@ +; EEx expressions are Elixir +((expression) @injection.content + (#set! injection.language "elixir")) + +; EEx expressions can span multiple interpolated lines +((partial_expression) @injection.content + (#set! injection.language "elixir") + (#set! injection.combined)) diff --git a/pack/ant/start/nvim-treesitter/queries/elixir/folds.scm b/pack/ant/start/nvim-treesitter/queries/elixir/folds.scm new file mode 100644 index 0000000..7abfe67 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/elixir/folds.scm @@ -0,0 +1,10 @@ +[ + (anonymous_function) + (stab_clause) + (arguments) + (block) + (do_block) + (list) + (map) + (tuple) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/elixir/highlights.scm b/pack/ant/start/nvim-treesitter/queries/elixir/highlights.scm new file mode 100644 index 0000000..cbdb40d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/elixir/highlights.scm @@ -0,0 +1,217 @@ +; Punctuation +[ + "," + ";" +] @punctuation.delimiter + +[ + "(" + ")" + "<<" + ">>" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +"%" @punctuation.special + +; Identifiers +(identifier) @variable + +; Unused Identifiers +((identifier) @comment + (#lua-match? @comment "^_")) + +; Comments +(comment) @comment @spell + +; Strings +(string) @string + +; Modules +(alias) @module + +; Atoms & Keywords +[ + (atom) + (quoted_atom) + (keyword) + (quoted_keyword) +] @string.special.symbol + +; Interpolation +(interpolation + [ + "#{" + "}" + ] @string.special) + +; Escape sequences +(escape_sequence) @string.escape + +; Integers +(integer) @number + +; Floats +(float) @number.float + +; Characters +[ + (char) + (charlist) +] @character + +; Booleans +(boolean) @boolean + +; Nil +(nil) @constant.builtin + +; Operators +(operator_identifier) @operator + +(unary_operator + operator: _ @operator) + +(binary_operator + operator: _ @operator) + +; Pipe Operator +(binary_operator + operator: "|>" + right: (identifier) @function) + +(dot + operator: _ @operator) + +(stab_clause + operator: _ @operator) + +; Local Function Calls +(call + target: (identifier) @function.call) + +; Remote Function Calls +(call + target: (dot + left: [ + (atom) @type + (_) + ] + right: (identifier) @function.call) + (arguments)) + +; Definition Function Calls +(call + target: ((identifier) @keyword.function + (#any-of? @keyword.function + "def" "defdelegate" "defexception" "defguard" "defguardp" "defimpl" "defmacro" "defmacrop" + "defmodule" "defn" "defnp" "defoverridable" "defp" "defprotocol" "defstruct")) + (arguments + [ + (call + (identifier) @function) + (identifier) @function + (binary_operator + left: (call + target: (identifier) @function) + operator: "when") + ])?) + +; Kernel Keywords & Special Forms +(call + target: ((identifier) @keyword + (#any-of? @keyword + "alias" "case" "catch" "cond" "else" "for" "if" "import" "quote" "raise" "receive" "require" + "reraise" "super" "throw" "try" "unless" "unquote" "unquote_splicing" "use" "with"))) + +; Special Constants +((identifier) @constant.builtin + (#any-of? @constant.builtin "__CALLER__" "__DIR__" "__ENV__" "__MODULE__" "__STACKTRACE__")) + +; Reserved Keywords +[ + "after" + "catch" + "do" + "end" + "fn" + "rescue" + "when" + "else" +] @keyword + +; Operator Keywords +[ + "and" + "in" + "not in" + "not" + "or" +] @keyword.operator + +; Capture Operator +(unary_operator + operator: "&" + operand: [ + (integer) @operator + (binary_operator + left: [ + (call + target: (dot + left: (_) + right: (identifier) @function)) + (identifier) @function + ] + operator: "/" + right: (integer) @operator) + ]) + +; Non-String Sigils +(sigil + "~" @string.special + (sigil_name) @string.special @_sigil_name + quoted_start: _ @string.special + quoted_end: _ @string.special + ((sigil_modifiers) @string.special)? + (#not-any-of? @_sigil_name "s" "S")) + +; String Sigils +(sigil + "~" @string + (sigil_name) @string @_sigil_name + quoted_start: _ @string + (quoted_content) @string + quoted_end: _ @string + ((sigil_modifiers) @string)? + (#any-of? @_sigil_name "s" "S")) + +; Module attributes +(unary_operator + operator: "@" + operand: [ + (identifier) + (call + target: (identifier)) + ] @constant) @constant + +; Documentation +(unary_operator + operator: "@" + operand: (call + target: ((identifier) @_identifier + (#any-of? @_identifier "moduledoc" "typedoc" "shortdoc" "doc")) @comment.documentation + (arguments + [ + (string) + (boolean) + (charlist) + (sigil + "~" @comment.documentation + (sigil_name) @comment.documentation + quoted_start: _ @comment.documentation + (quoted_content) @comment.documentation + quoted_end: _ @comment.documentation) + ] @comment.documentation))) @comment.documentation diff --git a/pack/ant/start/nvim-treesitter/queries/elixir/indents.scm b/pack/ant/start/nvim-treesitter/queries/elixir/indents.scm new file mode 100644 index 0000000..5470b64 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/elixir/indents.scm @@ -0,0 +1,25 @@ +[ + (block) + (do_block) + (list) + (map) + (stab_clause) + (tuple) + (arguments) +] @indent.begin + +[ + ")" + "]" + "after" + "catch" + "else" + "rescue" + "}" + "end" +] @indent.end @indent.branch + +; Elixir pipelines are not indented, but other binary operator chains are +((binary_operator + operator: _ @_operator) @indent.begin + (#not-eq? @_operator "|>")) diff --git a/pack/ant/start/nvim-treesitter/queries/elixir/injections.scm b/pack/ant/start/nvim-treesitter/queries/elixir/injections.scm new file mode 100644 index 0000000..cc74f79 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/elixir/injections.scm @@ -0,0 +1,59 @@ +; Comments +((comment) @injection.content + (#set! injection.language "comment")) + +; Documentation +(unary_operator + operator: "@" + operand: (call + target: ((identifier) @_identifier + (#any-of? @_identifier "moduledoc" "typedoc" "shortdoc" "doc")) + (arguments + [ + (string + (quoted_content) @injection.content) + (sigil + (quoted_content) @injection.content) + ]) + (#set! injection.language "markdown"))) + +; HEEx +(sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content + (#eq? @_sigil_name "H") + (#set! injection.language "heex")) + +; Surface +(sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content + (#eq? @_sigil_name "F") + (#set! injection.language "surface")) + +; Zigler +(sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content + (#any-of? @_sigil_name "E" "L") + (#set! injection.language "eex")) + +(sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content + (#any-of? @_sigil_name "z" "Z") + (#set! injection.language "zig")) + +; Regex +(sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content + (#any-of? @_sigil_name "r" "R") + (#set! injection.language "regex")) + +; Json +(sigil + (sigil_name) @_sigil_name + (quoted_content) @injection.content + (#any-of? @_sigil_name "j" "J") + (#set! injection.language "json")) diff --git a/pack/ant/start/nvim-treesitter/queries/elixir/locals.scm b/pack/ant/start/nvim-treesitter/queries/elixir/locals.scm new file mode 100644 index 0000000..ac9d86e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/elixir/locals.scm @@ -0,0 +1,200 @@ +; References +(identifier) @local.reference + +(alias) @local.reference + +; Module Definitions +(call + target: ((identifier) @_identifier + (#eq? @_identifier "defmodule")) + (arguments + (alias) @local.definition.type)) + +; Pattern Match Definitions +(binary_operator + ; format-ignore + left: + [ + (identifier) @local.definition.var + (_ (identifier) @local.definition.var) + (_ (_ (identifier) @local.definition.var)) + (_ (_ (_ (identifier) @local.definition.var))) + (_ (_ (_ (_ (identifier) @local.definition.var)))) + (_ (_ (_ (_ (_ (identifier) @local.definition.var))))) + (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))) + (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))))))) + ] + operator: "=") + +; Stab Clause Definitions +; format-ignore +(stab_clause + left: + [ + (arguments + [ + (identifier) @local.definition.var + (_ (identifier) @local.definition.var) + (_ (_ (identifier) @local.definition.var)) + (_ (_ (_ (identifier) @local.definition.var))) + (_ (_ (_ (_ (identifier) @local.definition.var)))) + (_ (_ (_ (_ (_ (identifier) @local.definition.var))))) + (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))) + (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))))))) + ]) + + (binary_operator + left: + (arguments + ; format-ignore + [ + (identifier) @local.definition.var + (_ (identifier) @local.definition.var) + (_ (_ (identifier) @local.definition.var)) + (_ (_ (_ (identifier) @local.definition.var))) + (_ (_ (_ (_ (identifier) @local.definition.var)))) + (_ (_ (_ (_ (_ (identifier) @local.definition.var))))) + (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))) + (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var))))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.var)))))))))))))))))))) + ]) + operator: "when") + ]) + +; Aliases +; format-ignore +(call + target: + ((identifier) @_identifier + (#any-of? @_identifier "require" "alias" "use" "import")) + (arguments + [ + (alias) @local.definition.import + (_ (alias) @local.definition.import) + (_ (_ (alias) @local.definition.import)) + (_ (_ (_ (alias) @local.definition.import))) + (_ (_ (_ (_ (alias) @local.definition.import)))) + ])) + +; Local Function Definitions & Scopes +; format-ignore +(call + target: + ((identifier) @_identifier + (#any-of? @_identifier "def" "defp" "defmacro" "defmacrop" "defguard" "defguardp" "defn" "defnp" "for")) + (arguments + [ + (identifier) @local.definition.function + (binary_operator + left: (identifier) @local.definition.function + operator: "when") + (binary_operator + (identifier) @local.definition.parameter) + (call + target: (identifier) @local.definition.function + (arguments + [ + (identifier) @local.definition.parameter + (_ (identifier) @local.definition.parameter) + (_ (_ (identifier) @local.definition.parameter)) + (_ (_ (_ (identifier) @local.definition.parameter))) + (_ (_ (_ (_ (identifier) @local.definition.parameter)))) + (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))) + (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))) + (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))))))))) + ])) + ]?) + (#set! definition.function.scope parent)(do_block)?) @local.scope + +; ExUnit Test Definitions & Scopes +; format-ignore +(call + target: + ((identifier) @_identifier + (#eq? @_identifier "test")) + (arguments + [ + (string) + ((string) + . + "," + . + [ + (identifier) @local.definition.parameter + (_ (identifier) @local.definition.parameter) + (_ (_ (identifier) @local.definition.parameter)) + (_ (_ (_ (identifier) @local.definition.parameter))) + (_ (_ (_ (_ (identifier) @local.definition.parameter)))) + (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))) + (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))) + (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter))))))))))))))))))) + (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (_ (identifier) @local.definition.parameter)))))))))))))))))))) + ]) + ]) + (do_block)?) @local.scope + +; Stab Clause Scopes +(stab_clause) @local.scope diff --git a/pack/ant/start/nvim-treesitter/queries/elm/folds.scm b/pack/ant/start/nvim-treesitter/queries/elm/folds.scm new file mode 100644 index 0000000..56987d9 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/elm/folds.scm @@ -0,0 +1,14 @@ +((function_call_expr) @_fn + (#not-has-parent? @_fn parenthesized_expr)) @fold + +[ + (case_of_branch) + (case_of_expr) + (value_declaration) + (type_declaration) + (type_alias_declaration) + (list_expr) + (record_expr) + (parenthesized_expr) + (import_clause)+ +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/elm/highlights.scm b/pack/ant/start/nvim-treesitter/queries/elm/highlights.scm new file mode 100644 index 0000000..cfa09ca --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/elm/highlights.scm @@ -0,0 +1,229 @@ +[ + (line_comment) + (block_comment) +] @comment @spell + +((block_comment) @comment.documentation + (#lua-match? @comment.documentation "^{[-]|[^|]")) + +; Keywords +;--------- +[ + "if" + "then" + "else" + (case) + (of) +] @keyword.conditional + +[ + "let" + "in" + (as) + (port) + (alias) + (infix) + (module) + (type) +] @keyword + +[ + (import) + (exposing) +] @keyword.import + +; Punctuation +;------------ +(double_dot) @punctuation.special + +[ + "," + "|" + (dot) +] @punctuation.delimiter + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +; Variables +;---------- +(value_qid + (lower_case_identifier) @variable) + +(value_declaration + (function_declaration_left + (lower_case_identifier) @variable)) + +(type_annotation + (lower_case_identifier) @variable) + +(port_annotation + (lower_case_identifier) @variable) + +(anything_pattern + (underscore) @character.special) + +(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) @variable.member)) + +(field_access_expr + ((dot) + (lower_case_identifier) @variable.member)) + +(function_declaration_left + (anything_pattern + (underscore) @character.special)) + +(function_declaration_left + (lower_pattern + (lower_case_identifier) @variable.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 + (value_qid + (lower_case_identifier) @function.call))) + +; Operators +;---------- +[ + (operator_identifier) + (eq) + (colon) + (arrow) + (backslash) + "::" +] @operator + +; Modules +;-------- +(module_declaration + (upper_case_qid + (upper_case_identifier) @module)) + +(import_clause + (upper_case_qid + (upper_case_identifier) @module)) + +(as_clause + (upper_case_identifier) @module) + +(value_expr + (value_qid + (upper_case_identifier) @module)) + +; 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)) + +(nullary_constructor_argument_pattern + (upper_case_qid + (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) @boolean + (#any-of? @boolean "True" "False"))) + +[ + (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) diff --git a/pack/ant/start/nvim-treesitter/queries/elm/injections.scm b/pack/ant/start/nvim-treesitter/queries/elm/injections.scm new file mode 100644 index 0000000..7ee6c7f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/elm/injections.scm @@ -0,0 +1,8 @@ +([ + (line_comment) + (block_comment) +] @injection.content + (#set! injection.language "comment")) + +((glsl_content) @injection.content + (#set! injection.language "glsl")) diff --git a/pack/ant/start/nvim-treesitter/queries/elsa/folds.scm b/pack/ant/start/nvim-treesitter/queries/elsa/folds.scm new file mode 100644 index 0000000..afdfec3 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/elsa/folds.scm @@ -0,0 +1 @@ +(reduction) @fold diff --git a/pack/ant/start/nvim-treesitter/queries/elsa/highlights.scm b/pack/ant/start/nvim-treesitter/queries/elsa/highlights.scm new file mode 100644 index 0000000..1a974bd --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/elsa/highlights.scm @@ -0,0 +1,36 @@ +; Keywords +[ + "eval" + "let" +] @keyword + +; Function +(function) @function + +; Method +(method) @function.method + +; Parameter +(parameter) @variable.parameter + +; Variables +(identifier) @variable + +; Operators +[ + "\\" + "->" + "=" + (step) +] @operator + +; Punctuation +[ + "(" + ")" +] @punctuation.bracket + +":" @punctuation.delimiter + +; Comments +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/elsa/indents.scm b/pack/ant/start/nvim-treesitter/queries/elsa/indents.scm new file mode 100644 index 0000000..6ddd1aa --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/elsa/indents.scm @@ -0,0 +1,6 @@ +(reduction) @indent.begin + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/pack/ant/start/nvim-treesitter/queries/elsa/injections.scm b/pack/ant/start/nvim-treesitter/queries/elsa/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/elsa/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/elsa/locals.scm b/pack/ant/start/nvim-treesitter/queries/elsa/locals.scm new file mode 100644 index 0000000..3e8197a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/elsa/locals.scm @@ -0,0 +1,12 @@ +[ + (source_file) + (reduction) +] @local.scope + +(identifier) @local.reference + +(function) @local.definition.function + +(method) @local.definition.method + +(parameter) @local.definition.parameter diff --git a/pack/ant/start/nvim-treesitter/queries/elvish/highlights.scm b/pack/ant/start/nvim-treesitter/queries/elvish/highlights.scm new file mode 100644 index 0000000..9836a6c --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/elvish/highlights.scm @@ -0,0 +1,157 @@ +(comment) @comment @spell + +[ + "if" + "elif" +] @keyword.conditional + +(if + (else + "else" @keyword.conditional)) + +[ + "while" + "for" +] @keyword.repeat + +(while + (else + "else" @keyword.repeat)) + +(for + (else + "else" @keyword.repeat)) + +[ + "try" + "catch" + "finally" +] @keyword.exception + +(try + (else + "else" @keyword.exception)) + +"use" @keyword.import + +(import + (bareword) @string.special.path) + +(wildcard + [ + "*" + "**" + "?" + ] @character.special) + +(command + argument: (bareword) @variable.parameter) + +(command + head: (identifier) @function.call) + +((command + head: (identifier) @keyword.return) + (#eq? @keyword.return "return")) + +((command + (identifier) @keyword.operator) + (#any-of? @keyword.operator "and" "or" "coalesce")) + +[ + "+" + "-" + "*" + "/" + "%" + "<" + "<=" + "==" + "!=" + ">" + ">=" + "s" + ">=s" +] @function.builtin + +[ + ">" + "<" + ">>" + "<>" + "|" +] @operator + +(io_port) @number + +(function_definition + "fn" @keyword.function + (identifier) @function) + +(parameter_list) @variable.parameter + +(parameter_list + "|" @punctuation.bracket) + +[ + "var" + "set" + "tmp" + "del" +] @keyword + +(variable_declaration + (lhs + (identifier) @variable)) + +(variable_assignment + (lhs + (identifier) @variable)) + +(temporary_assignment + (lhs + (identifier) @variable)) + +(variable_deletion + (identifier) @variable) + +(number) @number + +(string) @string + +(variable + (identifier) @variable) + +((variable + (identifier) @function) + (#lua-match? @function ".+[~]$")) + +((variable + (identifier) @boolean) + (#any-of? @boolean "true" "false")) + +((variable + (identifier) @constant.builtin) + (#any-of? @constant.builtin + "_" "after-chdir" "args" "before-chdir" "buildinfo" "nil" "notify-bg-job-success" "num-bg-jobs" + "ok" "paths" "pid" "pwd" "value-out-indicator" "version")) + +[ + "$" + "@" +] @punctuation.special + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +";" @punctuation.delimiter diff --git a/pack/ant/start/nvim-treesitter/queries/elvish/injections.scm b/pack/ant/start/nvim-treesitter/queries/elvish/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/elvish/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/embedded_template/highlights.scm b/pack/ant/start/nvim-treesitter/queries/embedded_template/highlights.scm new file mode 100644 index 0000000..410983d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/embedded_template/highlights.scm @@ -0,0 +1,12 @@ +(comment_directive) @comment @spell + +[ + "<%#" + "<%" + "<%=" + "<%_" + "<%-" + "%>" + "-%>" + "_%>" +] @keyword diff --git a/pack/ant/start/nvim-treesitter/queries/embedded_template/injections.scm b/pack/ant/start/nvim-treesitter/queries/embedded_template/injections.scm new file mode 100644 index 0000000..cdeb2cd --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/embedded_template/injections.scm @@ -0,0 +1,7 @@ +((content) @injection.content + (#set! injection.language "html") + (#set! injection.combined)) + +((code) @injection.content + (#set! injection.language "ruby") + (#set! injection.combined)) diff --git a/pack/ant/start/nvim-treesitter/queries/erlang/folds.scm b/pack/ant/start/nvim-treesitter/queries/erlang/folds.scm new file mode 100644 index 0000000..65c2d8e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/erlang/folds.scm @@ -0,0 +1,9 @@ +[ + (fun_decl) + (anonymous_fun) + (case_expr) + (maybe_expr) + (map_expr) + (export_attribute) + (export_type_attribute) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/erlang/highlights.scm b/pack/ant/start/nvim-treesitter/queries/erlang/highlights.scm new file mode 100644 index 0000000..8bba348 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/erlang/highlights.scm @@ -0,0 +1,184 @@ +((atom) @constant + (#set! priority "90")) + +(var) @variable + +(char) @character + +(integer) @number + +(float) @number.float + +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^[%%][%%]")) + +; keyword +[ + "fun" + "div" +] @keyword + +; bracket +[ + "(" + ")" + "{" + "}" + "[" + "]" + "#" +] @punctuation.bracket + +; Comparisons +[ + "==" + "=:=" + "=/=" + "=<" + ">=" + "<" + ">" +] @operator ; .comparison + +; operator +[ + ":" + ":=" + "!" + ; "-" + "+" + "=" + "->" + "=>" + "|" + "?=" +] @operator + +[ + "," + "." + ";" +] @punctuation.delimiter + +; conditional +[ + "receive" + "if" + "case" + "of" + "when" + "after" + "begin" + "end" + "maybe" + "else" +] @keyword.conditional + +[ + "catch" + "try" +] @keyword.exception + +((atom) @boolean + (#any-of? @boolean "true" "false")) + +; Macros +((macro_call_expr) @constant.macro + (#set! priority 101)) + +; Preprocessor +(pp_define + lhs: _ @constant.macro + (#set! priority 101)) + +(_preprocessor_directive) @keyword.directive +(#set! priority 99) + +; Attributes +(pp_include) @keyword.import + +(pp_include_lib) @keyword.import + +(export_attribute) @keyword.import + +(export_type_attribute) @type.definition + +(export_type_attribute + types: (fa + fun: _ @type + (#set! priority 101))) + +(behaviour_attribute) @keyword.import + +(module_attribute + (atom) @module) @keyword.import + +(wild_attribute + name: (attr_name + name: _ @attribute)) @attribute + +; Records +(record_expr) @type + +(record_field_expr + _ @variable.member) @type + +(record_field_name + _ @variable.member) @type + +(record_name + "#" @type + name: _ @type) @type + +(record_decl + name: _ @type) @type.definition + +(record_field + name: _ @variable.member) + +(record_field + name: _ @variable.member + ty: _ @type) + +; Type alias +(type_alias + name: _ @type) @type.definition + +(spec) @type.definition + +[ + (string) + (binary) +] @string + +; expr_function_call +(call + expr: [ + (atom) + (remote) + (var) + ] @function) + +(call + (atom) @keyword.exception + (#any-of? @keyword.exception "error" "throw" "exit")) + +; Parenthesized expression: (SomeFunc)(), only highlight the parens +(call + expr: (paren_expr + "(" @function.call + ")" @function.call)) + +; function +(external_fun) @function.call + +(internal_fun + fun: (atom) @function.call) + +(function_clause + name: (atom) @function) + +(fa + fun: (atom) @function) diff --git a/pack/ant/start/nvim-treesitter/queries/erlang/injections.scm b/pack/ant/start/nvim-treesitter/queries/erlang/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/erlang/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/facility/folds.scm b/pack/ant/start/nvim-treesitter/queries/facility/folds.scm new file mode 100644 index 0000000..7d8bafc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/facility/folds.scm @@ -0,0 +1,6 @@ +[ + (service) + (method) + (dto) + (enum) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/facility/highlights.scm b/pack/ant/start/nvim-treesitter/queries/facility/highlights.scm new file mode 100644 index 0000000..592bf53 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/facility/highlights.scm @@ -0,0 +1,90 @@ +[ + ";" + "." + "," +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(comment) @comment @spell + +(doc_comment) @comment.documentation @spell + +[ + "service" + "errors" +] @keyword + +[ + "method" + "event" +] @keyword.function + +[ + "enum" + "data" +] @keyword.type + +"extern" @keyword.modifier + +(type) @type.builtin + +(service + service_name: (identifier) @type) + +(error_set + (identifier) @variable.member) + +(error_set + name: (identifier) @type) + +(dto + name: (identifier) @type) + +(external_dto + name: (identifier) @type) + +(enum + (values_block + (identifier) @constant)) + +(enum + name: (identifier) @type) + +(external_enum + name: (identifier) @type) + +(type + name: (identifier) @type) + +[ + "map" + "nullable" + "result" + "required" + "http" + "csharp" + "js" + "info" + "obsolete" +] @attribute.builtin + +(parameter + name: (identifier) @variable.parameter) + +(field + name: (identifier) @variable.member) + +(method + name: (identifier) @function.method) + +(number_literal) @number + +(string_literal) @string diff --git a/pack/ant/start/nvim-treesitter/queries/facility/indents.scm b/pack/ant/start/nvim-treesitter/queries/facility/indents.scm new file mode 100644 index 0000000..247949b --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/facility/indents.scm @@ -0,0 +1,7 @@ +[ + (service_block) + (values_block) + (field_list) +] @indent.begin + +"}" @indent.branch diff --git a/pack/ant/start/nvim-treesitter/queries/facility/injections.scm b/pack/ant/start/nvim-treesitter/queries/facility/injections.scm new file mode 100644 index 0000000..5d9b783 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/facility/injections.scm @@ -0,0 +1,8 @@ +((remarks) @injection.content + (#set! injection.language "markdown")) + +([ + (comment) + (doc_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/faust/highlights.scm b/pack/ant/start/nvim-treesitter/queries/faust/highlights.scm new file mode 100644 index 0000000..6e7ef1d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/faust/highlights.scm @@ -0,0 +1,219 @@ +; Identifiers +(identifier) @variable + +[ + "process" + "effect" +] @variable.builtin + +(parameters + (identifier)) @variable.parameter + +(access + definition: (identifier) @variable.member) + +(global_metadata + key: (identifier) @variable.member) + +(function_metadata + function_name: (identifier) @variable.member) + +; Literals +(_ + filename: (string)) @string.special.path + +(documentation) @string.documentation @spell + +[ + (string) + (fstring) +] @string + +(int) @number + +(real) @number.float + +; Types +(_ + type: [ + (int_type) + (float_type) + (any_type) + ]) @type.builtin + +[ + (single_precision) + (double_precision) + (quad_precision) + (fixed_point_precision) +] @attribute + +; Functions +(function_definition + name: (identifier) @function) + +(function_names) @function + +(function_call + (identifier) @function.call) + +(function_call + (access + definition: (identifier) @function.call)) + +[ + "exp" + "log" + "log10" + "sqrt" + "abs" + "floor" + "ceil" + "rint" + "round" + "acos" + "asin" + "atan" + "cos" + "sin" + "tan" + "atan2" + "int" + "float" + "pow" + "min" + "max" + "fmod" + "remainder" + "prefix" + "attach" + "enable" + "control" + "rdtable" + "rwtable" + "select2" + "select3" + "lowest" + "highest" + "assertbounds" + (par) + (seq) + (sum) + (prod) + (component) + (library) + (vslider_type) + (hslider_type) + (nentry_type) + (vbargraph_type) + (hbargraph_type) + (vgroup_type) + (hgroup_type) + (tgroup_type) + "button" + "checkbox" + "soundfile" + "inputs" + "outputs" + "route" +] @function.builtin + +; xor is a @keyword.operator +[ + (add) + (sub) + (mult) + (div) + (mod) + (pow) + (or) + (and) + (lshift) + (rshift) + (lt) + (le) + (gt) + (ge) + (eq) + (neq) + (delay) + (one_sample_delay) + "=" + "=>" + "->" +] @operator + +(recursive + "~" @operator) + +(sequential + ":" @operator) + +(split + "<:" @operator) + +(merge + ":>" @operator) + +(parallel + "," @operator) + +; Keywords +[ + (par) + (seq) + (sum) + (prod) +] @keyword.repeat + +(file_import + "import" @keyword.import) + +[ + (wire) + (cut) + (mem) + "declare" + "with" + "environment" + "case" + "ffunction" + "fconstant" + "fvariable" +] @keyword + +(xor) @keyword.operator + +; Punctuation +[ + "," + ";" + "." +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +; Comments +(comment) @comment @spell + +; Tags +[ + "" + "" + "" + "" + "" + "" + "" + "" + "" +] @tag diff --git a/pack/ant/start/nvim-treesitter/queries/faust/injections.scm b/pack/ant/start/nvim-treesitter/queries/faust/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/faust/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/fennel/folds.scm b/pack/ant/start/nvim-treesitter/queries/fennel/folds.scm new file mode 100644 index 0000000..0862e59 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fennel/folds.scm @@ -0,0 +1,51 @@ +; compounds +[ + (list) + (table) + (sequence) +] @fold + +; sub-forms / special compounds +[ + (list_binding) + (table_binding) + (sequence_binding) + (table_metadata) + (sequence_arguments) + (let_vars) + (case_guard_or_special) + (case_guard) + (case_catch) +] @fold + +; forms +[ + (quote_form) + (unquote_form) + (local_form) + (var_form) + (set_form) + (global_form) + (let_form) + (fn_form) + (lambda_form) + (hashfn_form) + (each_form) + (collect_form) + (icollect_form) + (accumulate_form) + (for_form) + (fcollect_form) + (faccumulate_form) + (case_form) + (match_form) + (case_try_form) + (match_try_form) +] @fold + +; reader macros +(quote_reader_macro + expression: (_) @fold) + +(quasi_quote_reader_macro + expression: (_) @fold) diff --git a/pack/ant/start/nvim-treesitter/queries/fennel/highlights.scm b/pack/ant/start/nvim-treesitter/queries/fennel/highlights.scm new file mode 100644 index 0000000..2f0b5f7 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fennel/highlights.scm @@ -0,0 +1,193 @@ +; Most primitive nodes +(shebang) @keyword.directive + +(comment) @comment @spell + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + (nil) + (nil_binding) +] @constant.builtin + +[ + (boolean) + (boolean_binding) +] @boolean + +[ + (number) + (number_binding) +] @number + +[ + (string) + (string_binding) +] @string + +[ + (symbol) + (symbol_binding) +] @variable + +(symbol_option) @keyword.directive + +(escape_sequence) @string.escape + +(multi_symbol + "." @punctuation.delimiter + member: (symbol_fragment) @variable.member) + +(list + call: (symbol) @function.call) + +(list + call: (multi_symbol + member: (symbol_fragment) @function.call .)) + +(multi_symbol_method + ":" @punctuation.delimiter + method: (symbol_fragment) @function.method.call) + +(quasi_quote_reader_macro + macro: _ @punctuation.special) + +(quote_reader_macro + macro: _ @punctuation.special) + +(unquote_reader_macro + macro: _ @punctuation.special) + +(hashfn_reader_macro + macro: _ @keyword.function) + +(sequence_arguments + (symbol_binding) @variable.parameter) + +(sequence_arguments + (rest_binding + rhs: (symbol_binding) @variable.parameter)) + +(docstring) @string.documentation + +(fn_form + name: [ + (symbol) @function + (multi_symbol + member: (symbol_fragment) @function .) + ]) + +(lambda_form + name: [ + (symbol) @function + (multi_symbol + member: (symbol_fragment) @function .) + ]) + +; NOTE: The macro name is highlighted as @variable because it +; gives a nicer contrast instead of everything being the same +; color. Rust queries use this workaround too for `macro_rules!`. +(macro_form + name: [ + (symbol) @variable + (multi_symbol + member: (symbol_fragment) @variable .) + ]) + +((symbol) @variable.parameter + (#any-of? @variable.parameter "$" "$...")) + +((symbol) @variable.parameter + (#lua-match? @variable.parameter "^%$[1-9]$")) + +((symbol) @operator + (#any-of? @operator + ; arithmetic + "+" "-" "*" "/" "//" "%" "^" + ; comparison + ">" "<" ">=" "<=" "=" "~=" + ; other + "#" "." "?." "..")) + +((symbol) @keyword.operator + (#any-of? @keyword.operator + ; comparison + "not=" + ; boolean + "and" "or" "not" + ; bitwise + "lshift" "rshift" "band" "bor" "bxor" "bnot" + ; other + "length")) + +(case_guard + call: (_) @keyword.conditional) + +(case_guard_or_special + call: (_) @keyword.conditional) + +((symbol) @keyword.function + (#any-of? @keyword.function "fn" "lambda" "λ" "hashfn")) + +((symbol) @keyword.repeat + (#any-of? @keyword.repeat "for" "each" "while")) + +((symbol) @keyword.conditional + (#any-of? @keyword.conditional "if" "when" "match" "case" "match-try" "case-try")) + +((symbol) @keyword + (#any-of? @keyword + "global" "local" "let" "set" "var" "comment" "do" "doc" "eval-compiler" "lua" "macros" "unquote" + "quote" "tset" "values" "tail!")) + +((symbol) @keyword.import + (#any-of? @keyword.import "require-macros" "import-macros" "include")) + +((symbol) @function.macro + (#any-of? @function.macro + "collect" "icollect" "fcollect" "accumulate" "faccumulate" "->" "->>" "-?>" "-?>>" "?." "doto" + "macro" "macrodebug" "partial" "pick-args" "pick-values" "with-open")) + +(case_catch + call: (symbol) @keyword) + +(import_macros_form + imports: (table_binding + (table_binding_pair + value: (symbol_binding) @function.macro))) + +; TODO: Highlight builtin methods (`table.unpack`, etc) as @function.builtin +([ + (symbol) @module.builtin + (multi_symbol + base: (symbol_fragment) @module.builtin) +] + (#any-of? @module.builtin + "vim" "_G" "debug" "io" "jit" "math" "os" "package" "string" "table" "utf8")) + +([ + (symbol) @variable.builtin + (multi_symbol + . + (symbol_fragment) @variable.builtin) +] + (#eq? @variable.builtin "arg")) + +((symbol) @variable.builtin + (#eq? @variable.builtin "...")) + +((symbol) @constant.builtin + (#eq? @constant.builtin "_VERSION")) + +((symbol) @function.builtin + (#any-of? @function.builtin + "assert" "collectgarbage" "dofile" "error" "getmetatable" "ipairs" "load" "loadfile" "next" + "pairs" "pcall" "print" "rawequal" "rawget" "rawlen" "rawset" "require" "select" "setmetatable" + "tonumber" "tostring" "type" "warn" "xpcall" "module" "setfenv" "loadstring" "unpack")) diff --git a/pack/ant/start/nvim-treesitter/queries/fennel/injections.scm b/pack/ant/start/nvim-treesitter/queries/fennel/injections.scm new file mode 100644 index 0000000..f6724d3 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fennel/injections.scm @@ -0,0 +1,134 @@ +((comment_body) @injection.content + (#set! injection.language "comment")) + +(list + call: (multi_symbol) @_vimcmd_identifier + (#any-of? @_vimcmd_identifier "vim.cmd" "vim.api.nvim_command" "vim.api.nvim_exec2") + . + item: (string + (string_content) @injection.content + (#set! injection.language "vim"))) + +; NOTE: Matches *exactly* `ffi.cdef` +(list + call: (multi_symbol) @_cdef_identifier + (#eq? @_cdef_identifier "ffi.cdef") + . + item: (string + (string_content) @injection.content + (#set! injection.language "c"))) + +(list + call: (multi_symbol) @_ts_query_identifier + (#any-of? @_ts_query_identifier "vim.treesitter.query.set" "vim.treesitter.query.parse") + . + item: (_) + . + item: (_) + . + item: (string + (string_content) @injection.content + (#set! injection.language "query"))) + +(list + call: (multi_symbol) @_vimcmd_identifier + (#eq? @_vimcmd_identifier "vim.api.nvim_create_autocmd") + . + item: (_) + . + item: (table + (table_pair + key: (string + (string_content) @_command + (#eq? @_command "command")) + value: (string + (string_content) @injection.content + (#set! injection.language "vim"))))) + +(list + call: (multi_symbol) @_user_cmd + (#eq? @_user_cmd "vim.api.nvim_create_user_command") + . + item: (_) + . + item: (string + (string_content) @injection.content + (#set! injection.language "vim"))) + +(list + call: (multi_symbol) @_user_cmd + (#eq? @_user_cmd "vim.api.nvim_buf_create_user_command") + . + item: (_) + . + item: (_) + . + item: (string + (string_content) @injection.content + (#set! injection.language "vim"))) + +(list + call: (multi_symbol) @_map + (#any-of? @_map "vim.api.nvim_set_keymap" "vim.keymap.set") + . + item: (_) + . + item: (_) + . + item: (string + (string_content) @injection.content + (#set! injection.language "vim"))) + +(list + call: (multi_symbol) @_map + (#eq? @_map "vim.api.nvim_buf_set_keymap") + . + item: (_) + . + item: (_) + . + item: (_) + . + item: (string + (string_content) @injection.content + (#set! injection.language "vim"))) + +; highlight string as query if starts with `; query` +(string + (string_content) @injection.content + (#lua-match? @injection.content "^%s*;+%s?query") + (#set! injection.language "query")) + +; (string.match "123" "%d+") +(list + call: (multi_symbol + member: (symbol_fragment) @_func + . + (#any-of? @_func "find" "match" "gmatch" "gsub")) + . + item: (_) + . + item: (string + (string_content) @injection.content + (#set! injection.language "luap") + (#set! injection.include-children))) + +; (my-string:match "%d+") +(list + call: (multi_symbol_method + method: (symbol_fragment) @_method + (#any-of? @_method "find" "match" "gmatch" "gsub")) + . + item: (string + (string_content) @injection.content + (#set! injection.language "luap") + (#set! injection.include-children))) + +; (string.format "pi = %.2f" 3.14159) +(list + call: (multi_symbol) @_func + (#eq? @_func "string.format") + . + item: (string + (string_content) @injection.content + (#set! injection.language "printf"))) diff --git a/pack/ant/start/nvim-treesitter/queries/fennel/locals.scm b/pack/ant/start/nvim-treesitter/queries/fennel/locals.scm new file mode 100644 index 0000000..be63e72 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fennel/locals.scm @@ -0,0 +1,56 @@ +(program) @local.scope + +(symbol) @local.reference + +[ + (let_form) + (fn_form) + (lambda_form) + (each_form) + (for_form) + (collect_form) + (icollect_form) + (accumulate_form) + (for_form) + (fcollect_form) + (faccumulate_form) + (case_form) + (match_form) + (case_try_form) + (match_try_form) + (if_form) +] @local.scope + +(list + call: (symbol) @_call + (#any-of? @_call "while" "when" "do")) @local.scope + +(fn_form + name: [ + (symbol) @local.definition.function + (multi_symbol + member: (symbol_fragment) @local.definition.function .) + ] + args: (sequence_arguments + (symbol_binding) @local.definition.parameter) + (#set! definition.function.scope "parent")) + +(lambda_form + name: [ + (symbol) @local.definition.function + (multi_symbol + member: (symbol_fragment) @local.definition.function .) + ] + args: (sequence_arguments + (symbol_binding) @local.definition.parameter) + (#set! definition.function.scope "parent")) + +(macro_form + name: [ + (symbol) @local.definition.function + (multi_symbol + member: (symbol_fragment) @local.definition.function .) + ] + args: (sequence_arguments + (symbol_binding) @local.definition.parameter) + (#set! definition.function.scope "parent")) diff --git a/pack/ant/start/nvim-treesitter/queries/fidl/folds.scm b/pack/ant/start/nvim-treesitter/queries/fidl/folds.scm new file mode 100644 index 0000000..f524c45 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fidl/folds.scm @@ -0,0 +1,6 @@ +[ + (layout_declaration) + (protocol_declaration) + (resource_declaration) + (service_declaration) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/fidl/highlights.scm b/pack/ant/start/nvim-treesitter/queries/fidl/highlights.scm new file mode 100644 index 0000000..f1960c6 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fidl/highlights.scm @@ -0,0 +1,67 @@ +[ + "ajar" + "alias" + "as" + "bits" + "closed" + "compose" + "const" + "error" + "flexible" + "library" + "open" + ; "optional" we did not specify a node for optional yet + "overlay" + "protocol" + "reserved" + "strict" + "using" +] @keyword + +[ + "enum" + "struct" + "table" + "union" + "resource" + "service" + "type" +] @keyword.type + +(primitives_type) @type.builtin + +(builtin_complex_type) @type.builtin + +(const_declaration + (identifier) @constant) + +[ + "=" + "|" + "&" + "->" +] @operator + +(attribute + "@" @attribute + (identifier) @attribute) + +(string_literal) @string + +(numeric_literal) @number + +[ + (true) + (false) +] @boolean + +(comment) @comment + +[ + "(" + ")" + "<" + ">" + "{" + "}" +] @punctuation.bracket diff --git a/pack/ant/start/nvim-treesitter/queries/fidl/injections.scm b/pack/ant/start/nvim-treesitter/queries/fidl/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fidl/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/firrtl/folds.scm b/pack/ant/start/nvim-treesitter/queries/firrtl/folds.scm new file mode 100644 index 0000000..4c64e64 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/firrtl/folds.scm @@ -0,0 +1,6 @@ +[ + (circuit) + (module) + (when) + (else) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/firrtl/highlights.scm b/pack/ant/start/nvim-treesitter/queries/firrtl/highlights.scm new file mode 100644 index 0000000..0a90fa5 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/firrtl/highlights.scm @@ -0,0 +1,198 @@ +; Namespaces +(circuit + (identifier) @module) + +(module + (identifier) @module) + +; Types +((identifier) @type + (#lua-match? @type "^[A-Z][A-Za-z0-9_$]*$")) + +; Keywords +[ + "circuit" + "module" + "extmodule" + "flip" + "parameter" + "reset" + "wire" + "cmem" + "smem" + "mem" + "reg" + "with" + "mport" + "inst" + "of" + "node" + "is" + "invalid" + "skip" + "infer" + "read" + "write" + "rdwr" + "defname" +] @keyword + +; Qualifiers +(qualifier) @keyword.modifier + +; Storageclasses +[ + "input" + "output" +] @keyword.modifier + +; Conditionals +[ + "when" + "else" +] @keyword.conditional + +; Annotations +(info) @attribute + +; Builtins +[ + "stop" + "printf" + "assert" + "assume" + "cover" + "attach" + "mux" + "validif" +] @function.builtin + +[ + "UInt" + "SInt" + "Analog" + "Fixed" + "Clock" + "AsyncReset" + "Reset" +] @type.builtin + +; Fields +[ + "data-type" + "depth" + "read-latency" + "write-latency" + "read-under-write" + "reader" + "writer" + "readwriter" +] @variable.member + +((field_id) @variable.member + (#set! priority 105)) + +(port + (identifier) @variable.member) + +(wire + (identifier) @variable.member) + +(cmem + (identifier) @variable.member) + +(smem + (identifier) @variable.member) + +(memory + (identifier) @variable.member) + +(register + (identifier) @variable.member) + +; Parameters +(primitive_operation + (identifier) @variable.parameter) + +(mux + (identifier) @variable.parameter) + +(printf + (identifier) @variable.parameter) + +(reset + (identifier) @variable.parameter) + +(stop + (identifier) @variable.parameter) + +; Variables +(identifier) @variable + +; Operators +(primop) @keyword.operator + +[ + "+" + "-" + "=" + "=>" + "<=" + "<-" +] @operator + +; Literals +[ + (uint) + (number) +] @number + +(number_str) @string.special + +(double) @number.float + +(string) @string + +(escape_sequence) @string.escape + +[ + "old" + "new" + "undefined" +] @constant.builtin + +; Punctuation +[ + "{" + "}" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + "<" + ">" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "," + "." + ":" +] @punctuation.delimiter + +; Comments +(comment) @comment @spell + +[ + "=>" + "<=" + "=" +] @operator diff --git a/pack/ant/start/nvim-treesitter/queries/firrtl/indents.scm b/pack/ant/start/nvim-treesitter/queries/firrtl/indents.scm new file mode 100644 index 0000000..e172e1e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/firrtl/indents.scm @@ -0,0 +1,12 @@ +[ + (circuit) + (module) + (memory) + (when) + (else) +] @indent.begin + +[ + (ERROR) + (comment) +] @indent.auto diff --git a/pack/ant/start/nvim-treesitter/queries/firrtl/injections.scm b/pack/ant/start/nvim-treesitter/queries/firrtl/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/firrtl/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/firrtl/locals.scm b/pack/ant/start/nvim-treesitter/queries/firrtl/locals.scm new file mode 100644 index 0000000..97b7931 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/firrtl/locals.scm @@ -0,0 +1,45 @@ +; Scopes +[ + (source_file) + (circuit) + (module) + (else) + (when) +] @local.scope + +; References +(identifier) @local.reference + +; Definitions +(port + (identifier) @local.definition.field) + +(wire + (identifier) @local.definition.field) + +(cmem + (identifier) @local.definition.field) + +(smem + (identifier) @local.definition.field) + +(memory + (identifier) @local.definition.field) + +(register + (identifier) @local.definition.field) + +(circuit + (identifier) @local.definition.namespace) + +(module + (identifier) @local.definition.namespace) + +(parameter + (identifier) @local.definition.parameter) + +(rdwr + (identifier) @local.definition.var) + +(node + (identifier) @local.definition.var) diff --git a/pack/ant/start/nvim-treesitter/queries/fish/folds.scm b/pack/ant/start/nvim-treesitter/queries/fish/folds.scm new file mode 100644 index 0000000..06363e1 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fish/folds.scm @@ -0,0 +1,8 @@ +[ + (function_definition) + (if_statement) + (switch_statement) + (for_statement) + (while_statement) + (begin_statement) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/fish/highlights.scm b/pack/ant/start/nvim-treesitter/queries/fish/highlights.scm new file mode 100644 index 0000000..10ed533 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fish/highlights.scm @@ -0,0 +1,176 @@ +; Fish highlighting +; Operators +[ + "&&" + "||" + "|" + "&|" + "2>|" + "&" + ".." + "!" + (direction) + (stream_redirect) +] @operator + +; match operators of test command +(command + name: (word) @function.builtin + (#eq? @function.builtin "test") + argument: (word) @operator + (#match? @operator "^(!?\\=|-[a-zA-Z]+)$")) + +; match operators of [ command +(command + name: (word) @punctuation.bracket + (#eq? @punctuation.bracket "[") + argument: (word) @operator + (#match? @operator "^(!?\\=|-[a-zA-Z]+)$")) + +[ + "not" + "and" + "or" +] @keyword.operator + +; Conditionals +(if_statement + [ + "if" + "end" + ] @keyword.conditional) + +(switch_statement + [ + "switch" + "end" + ] @keyword.conditional) + +(case_clause + "case" @keyword.conditional) + +(else_clause + "else" @keyword.conditional) + +(else_if_clause + [ + "else" + "if" + ] @keyword.conditional) + +; Loops/Blocks +(while_statement + [ + "while" + "end" + ] @keyword.repeat) + +(for_statement + [ + "for" + "end" + ] @keyword.repeat) + +(begin_statement + [ + "begin" + "end" + ] @keyword.repeat) + +; Keywords +[ + "in" + (break) + (continue) +] @keyword + +"return" @keyword.return + +; Punctuation +[ + "[" + "]" + "{" + "}" + "(" + ")" +] @punctuation.bracket + +"," @punctuation.delimiter + +; Commands +(command + argument: [ + (word) @variable.parameter + (#lua-match? @variable.parameter "^[-]") + ]) + +(command_substitution + "$" @punctuation.bracket) + +; non-builtin command names +(command + name: (word) @function.call) + +; derived from builtin -n (fish 3.2.2) +(command + name: [ + (word) @function.builtin + (#any-of? @function.builtin + "." ":" "_" "alias" "argparse" "bg" "bind" "block" "breakpoint" "builtin" "cd" "command" + "commandline" "complete" "contains" "count" "disown" "echo" "emit" "eval" "exec" "exit" "fg" + "functions" "history" "isatty" "jobs" "math" "printf" "pwd" "random" "read" "realpath" "set" + "set_color" "source" "status" "string" "test" "time" "type" "ulimit" "wait") + ]) + +; Functions +(function_definition + [ + "function" + "end" + ] @keyword.function) + +(function_definition + name: [ + (word) + (concatenation) + ] @function) + +(function_definition + option: [ + (word) + (concatenation + (word)) + ] @variable.parameter + (#lua-match? @variable.parameter "^[-]")) + +; Strings +[ + (double_quote_string) + (single_quote_string) +] @string + +(escape_sequence) @string.escape + +; Variables +(variable_name) @variable + +(variable_expansion) @constant + +; Nodes +[ + (integer) + (float) +] @number + +(comment) @comment + +(comment) @spell + +((word) @boolean + (#any-of? @boolean "true" "false")) + +((program + . + (comment) @keyword.directive @nospell) + (#lua-match? @keyword.directive "^#!/")) diff --git a/pack/ant/start/nvim-treesitter/queries/fish/indents.scm b/pack/ant/start/nvim-treesitter/queries/fish/indents.scm new file mode 100644 index 0000000..4984c4c --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fish/indents.scm @@ -0,0 +1,18 @@ +[ + (function_definition) + (while_statement) + (for_statement) + (if_statement) + (begin_statement) + (switch_statement) +] @indent.begin + +[ + "else" ; else and else if must both start the line with "else", so tag the string directly + "case" + "end" +] @indent.branch + +"end" @indent.end + +(comment) @indent.ignore diff --git a/pack/ant/start/nvim-treesitter/queries/fish/injections.scm b/pack/ant/start/nvim-treesitter/queries/fish/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fish/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/fish/locals.scm b/pack/ant/start/nvim-treesitter/queries/fish/locals.scm new file mode 100644 index 0000000..904d568 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fish/locals.scm @@ -0,0 +1,19 @@ +; Scopes +[ + (command) + (function_definition) + (if_statement) + (for_statement) + (begin_statement) + (while_statement) + (switch_statement) +] @local.scope + +; Definitions +(function_definition + name: (word) @local.definition.function) + +; References +(variable_name) @local.reference + +(word) @local.reference diff --git a/pack/ant/start/nvim-treesitter/queries/foam/folds.scm b/pack/ant/start/nvim-treesitter/queries/foam/folds.scm new file mode 100644 index 0000000..e05d0db --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/foam/folds.scm @@ -0,0 +1,8 @@ +[ + (comment) + (list) + (dict_core) +] @fold + +(code + (code_body)* @fold) diff --git a/pack/ant/start/nvim-treesitter/queries/foam/highlights.scm b/pack/ant/start/nvim-treesitter/queries/foam/highlights.scm new file mode 100644 index 0000000..9c96f19 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/foam/highlights.scm @@ -0,0 +1,64 @@ +; Comments +(comment) @comment @spell + +; Generic Key-value pairs and dictionary keywords +(key_value + keyword: (identifier) @function) + +(dict + key: (identifier) @type) + +; Macros +(macro + "$" @keyword.conditional + (prev_scope)* @keyword.conditional + (identifier)* @module) + +; Directives +"#" @keyword.conditional + +(preproc_call + directive: (identifier)* @keyword.conditional + argument: (identifier)* @module) + +((preproc_call + argument: (identifier)* @module) @keyword.conditional + (#eq? @keyword.conditional "ifeq")) + +((preproc_call) @keyword.conditional + (#any-of? @keyword.conditional "else" "endif")) + +; Literals +(number_literal) @number.float + +(string_literal) @string + +(escape_sequence) @string.escape + +(boolean) @boolean + +; Treat [m^2 s^-2] the same as if it was put in numbers format +(dimensions + dimension: (identifier) @number.float) + +; Punctuation +[ + "(" + ")" + "[" + "]" + "{" + "}" + "#{" + "#}" + "|-" + "-|" + "" + "$$" +] @punctuation.bracket + +";" @punctuation.delimiter + +((identifier) @constant.builtin + (#any-of? @constant.builtin "uniform" "non-uniform" "and" "or")) diff --git a/pack/ant/start/nvim-treesitter/queries/foam/indents.scm b/pack/ant/start/nvim-treesitter/queries/foam/indents.scm new file mode 100644 index 0000000..be02b80 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/foam/indents.scm @@ -0,0 +1,11 @@ +[ + "{" + "}" +] @indent.branch + +[ + (dict) + (key_value) +] @indent.begin + +(comment) @indent.ignore diff --git a/pack/ant/start/nvim-treesitter/queries/foam/injections.scm b/pack/ant/start/nvim-treesitter/queries/foam/injections.scm new file mode 100644 index 0000000..b9f8f83 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/foam/injections.scm @@ -0,0 +1,23 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +; Pass code blocks to Cpp highlighter +(code + (code_body) @injection.content + (#set! injection.language "cpp")) + +; Pass identifiers to Go highlighter (Cheating I know) +; ((identifier) @injection.content +; (#set! injection.language "lua") +; Highlight regex syntax inside literal strings +((string_literal) @injection.content + (#set! injection.language "regex")) + +; Highlight PyFoam syntax as Python statements +(pyfoam_variable + code_body: (_) @injection.content + (#set! injection.language "python")) + +(pyfoam_expression + code_body: (_) @injection.content + (#set! injection.language "python")) diff --git a/pack/ant/start/nvim-treesitter/queries/foam/locals.scm b/pack/ant/start/nvim-treesitter/queries/foam/locals.scm new file mode 100644 index 0000000..f3f6890 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/foam/locals.scm @@ -0,0 +1,11 @@ +(dict) @local.scope + +(dict + key: (_) @local.definition.type) + +(key_value + keyword: (_) @local.definition.parameter) + +(key_value + value: (macro + (identifier)*)* @local.reference) diff --git a/pack/ant/start/nvim-treesitter/queries/forth/folds.scm b/pack/ant/start/nvim-treesitter/queries/forth/folds.scm new file mode 100644 index 0000000..443abb3 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/forth/folds.scm @@ -0,0 +1 @@ +(word_definition) @fold diff --git a/pack/ant/start/nvim-treesitter/queries/forth/highlights.scm b/pack/ant/start/nvim-treesitter/queries/forth/highlights.scm new file mode 100644 index 0000000..1e72075 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/forth/highlights.scm @@ -0,0 +1,19 @@ +(core) @function + +(operator) @operator + +(word) @variable + +((word) @constant + (#lua-match? @constant "^[A-Z_]+$")) + +(number) @number + +(string) @string + +[ + (start_definition) + (end_definition) +] @punctuation.delimiter + +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/forth/indents.scm b/pack/ant/start/nvim-treesitter/queries/forth/indents.scm new file mode 100644 index 0000000..0677554 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/forth/indents.scm @@ -0,0 +1,3 @@ +(word_definition) @indent.begin + +(end_definition) @indent.end @indent.branch diff --git a/pack/ant/start/nvim-treesitter/queries/forth/injections.scm b/pack/ant/start/nvim-treesitter/queries/forth/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/forth/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/forth/locals.scm b/pack/ant/start/nvim-treesitter/queries/forth/locals.scm new file mode 100644 index 0000000..d91d3aa --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/forth/locals.scm @@ -0,0 +1,3 @@ +(word) @local.reference + +(word_definition) @local.scope diff --git a/pack/ant/start/nvim-treesitter/queries/fortran/folds.scm b/pack/ant/start/nvim-treesitter/queries/fortran/folds.scm new file mode 100644 index 0000000..cedbdb6 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fortran/folds.scm @@ -0,0 +1,11 @@ +; by @oponkork +[ + (if_statement) + (where_statement) + (enum_statement) + (do_loop_statement) + (derived_type_definition) + (function) + (subroutine) + (interface) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/fortran/highlights.scm b/pack/ant/start/nvim-treesitter/queries/fortran/highlights.scm new file mode 100644 index 0000000..6a6dbba --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fortran/highlights.scm @@ -0,0 +1,319 @@ +; Preprocs +(preproc_directive) @keyword.directive + +; Namespaces +(program_statement + (name) @module) + +(end_program_statement + (name) @module) + +(module_statement + (name) @module) + +(end_module_statement + (name) @module) + +(submodule_statement + (name) @module) + +(end_submodule_statement + (name) @module) + +; Includes +[ + "import" + "include" + "use" +] @keyword.import + +(import_statement + "," + [ + "all" + "none" + ] @keyword) + +; Attributes +[ + (none) + "implicit" + "intent" +] @attribute + +(implicit_statement + "type" @attribute) + +; Keywords +[ + "attributes" + "associate" + "block" + "classis" + "contains" + "default" + "dimension" + "endassociate" + "endselect" + "enumerator" + "equivalence" + "extends" + "goto" + "intrinsic" + "non_intrinsic" + "namelist" + "parameter" + "quiet" + "rank" + "save" + "selectcase" + "selectrank" + "selecttype" + "sequence" + "stop" + "target" + "typeis" +] @keyword + +[ + "class" + "enum" + "endenum" + "type" + "endtype" + "module" + "endmodule" + "submodule" + "endsubmodule" + "interface" + "endinterface" +] @keyword.type + +(default) @keyword + +; Types +(type_name) @type + +(intrinsic_type) @type.builtin + +; Qualifiers +[ + "abstract" + "allocatable" + "automatic" + "constant" + "contiguous" + "data" + "deferred" + "device" + "external" + "family" + "final" + "generic" + "global" + "grid_global" + "host" + "initial" + "local" + "local_init" + "managed" + "nopass" + "non_overridable" + "optional" + "pass" + "pinned" + "pointer" + "private" + "property" + "protected" + "public" + "shared" + "static" + "texture" + "value" + "volatile" + (procedure_qualifier) +] @keyword.modifier + +[ + "common" + "in" + "inout" + "out" +] @keyword.modifier + +; Labels +[ + (statement_label) + (statement_label_reference) +] @label + +[ + "call" + "endfunction" + "endprogram" + "endprocedure" + "endsubroutine" + "function" + "procedure" + "program" + "subroutine" +] @keyword.function + +[ + "result" + "return" +] @keyword.return + +; Functions +(function_statement + (name) @function) + +(end_function_statement + (name) @function) + +(subroutine_statement + (name) @function) + +(end_subroutine_statement + (name) @function) + +(module_procedure_statement + (name) @function) + +(end_module_procedure_statement + (name) @function) + +(subroutine_call + (identifier) @function.call) + +[ + "character" + "close" + "bind" + "format" + "open" + "print" + "read" + "write" +] @function.builtin + +; Exceptions +"error" @keyword.exception + +; Conditionals +[ + "else" + "elseif" + "elsewhere" + "endif" + "endwhere" + "if" + "then" + "where" +] @keyword.conditional + +; Repeats +[ + "do" + "concurrent" + "enddo" + "endforall" + "forall" + "while" + "continue" + "cycle" + "exit" +] @keyword.repeat + +; Variables +(identifier) @variable + +; Parameters +(keyword_argument + name: (identifier) @variable.parameter) + +(parameters + (identifier) @variable.parameter) + +; Properties +(derived_type_member_expression + (type_member) @variable.member) + +; Operators +[ + "+" + "-" + "*" + "**" + "/" + "=" + "<" + ">" + "<=" + ">=" + "==" + "/=" + "//" + (assumed_rank) +] @operator + +[ + "\\.and\\." + "\\.or\\." + "\\.eqv\\." + "\\.neqv\\." + "\\.lt\\." + "\\.gt\\." + "\\.le\\." + "\\.ge\\." + "\\.eq\\." + "\\.ne\\." + "\\.not\\." +] @keyword.operator + +; Punctuation +[ + "[" + "]" +] @punctuation.bracket + +[ + "(" + ")" +] @punctuation.bracket + +[ + "<<<" + ">>>" +] @punctuation.bracket + +(array_literal + [ + "(/" + "/)" + ] @punctuation.bracket) + +[ + ":" + "," + "/" + "%" + "::" + "=>" +] @punctuation.delimiter + +; Literals +(string_literal) @string + +(number_literal) @number + +(boolean_literal) @boolean + +(null_literal) @constant.builtin + +; Comments +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^!>")) diff --git a/pack/ant/start/nvim-treesitter/queries/fortran/indents.scm b/pack/ant/start/nvim-treesitter/queries/fortran/indents.scm new file mode 100644 index 0000000..86704c4 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fortran/indents.scm @@ -0,0 +1,27 @@ +[ + (module) + (program) + (subroutine) + (function) + ; (interface) + (if_statement) + (do_loop_statement) + (where_statement) + (derived_type_definition) + (enum) +] @indent.begin + +[ + (end_module_statement) + (end_program_statement) + (end_subroutine_statement) + (end_function_statement) + ; (end_interface_statement) + (end_if_statement) + (end_do_loop_statement) + (else_clause) + (elseif_clause) + (end_type_statement) + (end_enum_statement) + (end_where_statement) +] @indent.branch diff --git a/pack/ant/start/nvim-treesitter/queries/fortran/injections.scm b/pack/ant/start/nvim-treesitter/queries/fortran/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fortran/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/fsh/highlights.scm b/pack/ant/start/nvim-treesitter/queries/fsh/highlights.scm new file mode 100644 index 0000000..2354a20 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fsh/highlights.scm @@ -0,0 +1,97 @@ +[ + "(" + ")" +] @punctuation.bracket + +[ + "^" + "=" + ":" +] @operator + +[ + "#" + ".." + "*" + "->" +] @punctuation.special + +; Entities +[ + "Profile" + "Alias" + "Extension" + "Invariant" + "Instance" + "ValueSet" + "CodeSystem" + "Mapping" + "Logical" + "Resource" + "RuleSet" +] @keyword + +; Metadata Keywords +[ + "Parent" + "Title" + "Description" + "Id" + "Severity" + "InstanceOf" + "Usage" + "Source" + "XPath" + "Target" +] @keyword + +; Rule Keywords +[ + "contentReference" + "insert" + "and" + "or" + "contains" + "named" + "only" + "obeys" + "valueset" + "codes" + "from" + "include" + "exclude" + "where" + "system" + "exactly" +] @keyword.operator + +; Types +[ + "Reference" + "Canonical" +] @type.builtin + +(sd_metadata + (parent + (name))) @type + +(target_type + (name)) @type + +; Strings +(string) @string + +(multiline_string) @string + +; Constants +(strength_value) @constant + +(bool) @boolean + +(flag) @constant + +; Special Params +(code_value) @variable.parameter + +; Extras +(fsh_comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/fsh/injections.scm b/pack/ant/start/nvim-treesitter/queries/fsh/injections.scm new file mode 100644 index 0000000..7bf6d00 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fsh/injections.scm @@ -0,0 +1,2 @@ +((fsh_comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/fsharp/highlights.scm b/pack/ant/start/nvim-treesitter/queries/fsharp/highlights.scm new file mode 100644 index 0000000..e400e35 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fsharp/highlights.scm @@ -0,0 +1,411 @@ +[ + (line_comment) + (block_comment) +] @comment @spell + +((line_comment) @comment.documentation @spell + (#lua-match? @comment.documentation "^///")) + +(const + [ + (_) @constant + (unit) @constant.builtin + ]) + +(primary_constr_args + (_) @variable.parameter) + +(class_as_reference + (_) @variable.parameter.builtin) + +(type_name + type_name: (_) @type.definition) + +[ + (_type) + (atomic_type) +] @type + +(member_signature + . + (identifier) @function.method) + +(member_signature + (curried_spec + (arguments_spec + (argument_spec + (argument_name_spec + "?"? @character.special + name: (_) @variable.parameter))))) + +(union_type_case + (identifier) @constant) + +(rules + (rule + pattern: (_) @constant + block: (_))) + +(wildcard_pattern) @character.special + +(identifier_pattern + . + (_) @constant + . + (_) @variable) + +(optional_pattern + "?" @character.special) + +(fsi_directive_decl + . + (string) @module) + +(import_decl + . + (_) @module) + +(named_module + name: (_) @module) + +(namespace + name: (_) @module) + +(module_defn + (identifier) @module) + +(ce_expression + . + (_) @constant.macro) + +(field_initializer + field: (_) @property) + +(record_fields + (record_field + . + (identifier) @property)) + +(value_declaration_left + . + (_) @variable) + +(function_declaration_left + . + (_) @function) + +(argument_patterns + [ + (const) + (long_identifier) + (_pattern) + ] @variable.parameter) + +(argument_patterns + (typed_pattern + (_pattern) @variable.parameter + (_type) @type)) + +(argument_patterns + (record_pattern + (field_pattern + . + (long_identifier) @variable.parameter))) + +(argument_patterns + (array_pattern + (_pattern)? @variable.parameter)) + +(argument_patterns + (list_pattern + (_pattern)? @variable.parameter)) + +((argument_patterns + (long_identifier + (identifier) @character.special)) + (#lua-match? @character.special "^\_.*")) + +(member_defn + (method_or_prop_defn + [ + (property_or_ident) @function + (property_or_ident + instance: (identifier) @variable.parameter.builtin + method: (identifier) @function.method) + ] + args: (_)* @variable.parameter)) + +(dot_expression + . + (_) @variable.member + . + (_)) + +(application_expression + . + (_) @function.call + . + (_) @variable) + +((infix_expression + . + (_) + . + (infix_op) @operator + . + (_) @function.call) + (#eq? @operator "|>")) + +((infix_expression + . + (_) @function.call + . + (infix_op) @operator + . + (_)) + (#eq? @operator "<|")) + +[ + (xint) + (int) + (int16) + (uint16) + (int32) + (uint32) + (int64) + (uint64) + (nativeint) + (unativeint) +] @number + +[ + (ieee32) + (ieee64) + (float) + (decimal) +] @number.float + +(bool) @boolean + +[ + (string) + (triple_quoted_string) + (verbatim_string) + (char) +] @spell @string + +(compiler_directive_decl) @keyword.directive + +(preproc_line + "#line" @keyword.directive) + +(attribute + target: (identifier)? @keyword + (_type) @attribute) + +[ + "(" + ")" + "{" + "}" + ".[" + "[" + "]" + "[|" + "|]" + "{|" + "|}" +] @punctuation.bracket + +[ + "[<" + ">]" +] @punctuation.special + +(format_string_eval + [ + "{" + "}" + ] @punctuation.special) + +[ + "," + ";" + ":" + "." +] @punctuation.delimiter + +[ + "|" + "=" + ">" + "<" + "-" + "~" + "->" + "<-" + "&" + "&&" + "|" + "||" + ":>" + ":?>" + ".." + "*" + (infix_op) + (prefix_op) + (op_identifier) +] @operator + +(generic_type + [ + "<" + ">" + ] @punctuation.bracket) + +[ + "if" + "then" + "else" + "elif" + "when" + "match" + "match!" +] @keyword.conditional + +[ + "and" + "or" + "not" + "upcast" + "downcast" +] @keyword.operator + +[ + "return" + "return!" + "yield" + "yield!" +] @keyword.return + +[ + "for" + "while" + "downto" + "to" +] @keyword.repeat + +[ + "open" + "#r" + "#load" +] @keyword.import + +[ + "abstract" + "delegate" + "static" + "inline" + "mutable" + "override" + "rec" + "global" + (access_modifier) +] @keyword.modifier + +[ + "let" + "let!" + "use" + "use!" + "member" +] @keyword.function + +[ + "enum" + "type" + "inherit" + "interface" + "and" + "class" + "struct" +] @keyword.type + +((identifier) @keyword.exception + (#any-of? @keyword.exception "failwith" "failwithf" "raise" "reraise")) + +[ + "as" + "assert" + "begin" + "end" + "done" + "default" + "in" + "do" + "do!" + "fun" + "function" + "get" + "set" + "lazy" + "new" + "of" + "struct" + "val" + "module" + "namespace" + "with" +] @keyword + +[ + "null" + (unit) +] @constant.builtin + +(match_expression + "with" @keyword.conditional) + +(try_expression + [ + "try" + "with" + "finally" + ] @keyword.exception) + +(application_expression + (unit) @function.call) + +((_type + (long_identifier + (identifier) @type.builtin)) + (#any-of? @type.builtin + "bool" "byte" "sbyte" "int16" "uint16" "int" "uint" "int64" "uint64" "nativeint" "unativeint" + "decimal" "float" "double" "float32" "single" "char" "string" "unit")) + +(preproc_if + [ + "#if" @keyword.directive + "#endif" @keyword.directive + ] + condition: (_)? @keyword.directive) + +(preproc_else + "#else" @keyword.directive) + +((identifier) @module.builtin + (#any-of? @module.builtin + "Array" "Async" "Directory" "File" "List" "Option" "Path" "Map" "Set" "Lazy" "Seq" "Task" + "String" "Result")) + +((value_declaration + (attributes + (attribute + (_type + (long_identifier + (identifier) @attribute)))) + (function_or_value_defn + (value_declaration_left + . + (_) @constant))) + (#eq? @attribute "Literal")) diff --git a/pack/ant/start/nvim-treesitter/queries/fsharp/injections.scm b/pack/ant/start/nvim-treesitter/queries/fsharp/injections.scm new file mode 100644 index 0000000..211b263 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fsharp/injections.scm @@ -0,0 +1,11 @@ +([ + (line_comment) + (block_comment_content) +] @injection.content + (#set! injection.language "comment")) + +((line_comment) @injection.content + (#lua-match? @injection.content "^///") + (#offset! @injection.content 0 3 0 0) + (#set! injection.language "xml") + (#set! injection.combined)) diff --git a/pack/ant/start/nvim-treesitter/queries/func/highlights.scm b/pack/ant/start/nvim-treesitter/queries/func/highlights.scm new file mode 100644 index 0000000..9fd6dd8 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/func/highlights.scm @@ -0,0 +1,167 @@ +; Include +"#include" @keyword.import + +(include_path) @string + +; Preproc +"#pragma" @keyword.directive + +(pragma_directive + [ + "version" + "not-version" + "test-version-set" + ] @keyword.directive) + +; Keywords +[ + "asm" + "impure" + "inline" + "inline_ref" + "method_id" + "type" +] @keyword + +"return" @keyword.return + +; Conditionals +[ + "if" + "ifnot" + "else" + "elseif" + "elseifnot" + "until" +] @keyword.conditional + +; Exceptions +[ + "try" + "catch" +] @keyword.exception + +; Repeats +[ + "do" + "forall" + "repeat" + "while" +] @keyword.repeat + +; Qualifiers +[ + "const" + "global" + (var) +] @keyword.modifier + +; Variables +(identifier) @variable + +; Constants +(const_var_declarations + name: (identifier) @constant) + +; Functions/Methods +(function_definition + name: (function_name) @function) + +(function_application + function: (identifier) @function) + +(method_call + method_name: (identifier) @function.method.call) + +; Parameters +(parameter) @variable.parameter + +; Types +(type_identifier) @type + +(primitive_type) @type.builtin + +; Operators +[ + "=" + "+=" + "-=" + "*=" + "/=" + "~/=" + "^/=" + "%=" + "~%=" + "^%=" + "<<=" + ">>=" + "~>>=" + "^>>=" + "&=" + "|=" + "^=" + "==" + "<" + ">" + "<=" + ">=" + "!=" + "<=>" + "<<" + ">>" + "~>>" + "^>>" + "-" + "+" + "|" + "^" + "*" + "/" + "%" + "~/" + "^/" + "~%" + "^%" + "/%" + "&" + "~" +] @operator + +; Literals +[ + (string) + (asm_instruction) +] @string + +[ + (string_type) + (underscore) +] @character.special + +(number) @number + +; Punctuation +[ + "{" + "}" +] @punctuation.bracket + +[ + "(" + ")" + "()" +] @punctuation.bracket + +[ + "[" + "]" +] @punctuation.bracket + +[ + ";" + "," + "->" +] @punctuation.delimiter + +; Comments +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/func/injections.scm b/pack/ant/start/nvim-treesitter/queries/func/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/func/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/fusion/folds.scm b/pack/ant/start/nvim-treesitter/queries/fusion/folds.scm new file mode 100644 index 0000000..179fc16 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fusion/folds.scm @@ -0,0 +1,6 @@ +[ + (comment) + (block) + (afx_comment) + (afx_element) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/fusion/highlights.scm b/pack/ant/start/nvim-treesitter/queries/fusion/highlights.scm new file mode 100644 index 0000000..7108e57 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fusion/highlights.scm @@ -0,0 +1,132 @@ +(comment) @comment @spell + +(afx_comment) @comment @spell + +; identifiers afx +(afx_opening_element + (afx_identifier) @tag) + +(afx_closing_element + (afx_identifier) @tag) + +(afx_element_self_closing + (afx_identifier) @tag) + +(afx_attribute + (afx_property_identifier) @tag.attribute) + +(afx_text) @spell + +; identifiers eel +(eel_object_path + (eel_path_identifier) @variable.builtin + (#any-of? @variable.builtin "this" "props")) + +(eel_object_path + (eel_path_identifier) @variable) + +(eel_object_pair + key: (eel_property_name) @property) + +(eel_method_name) @function + +(eel_parameter) @variable + +; identifiers fusion +; ----------- +(path_part) @property + +(meta_property) @attribute + +(prototype_signature + "prototype" @keyword) + +(include_statement + "include" @keyword.import + (source_file) @string.special.url) + +(namespace_declaration + "namespace" @keyword.type + (alias_namespace) @module) + +(type + name: (type_name) @type) + +; tokens +; ------ +(afx_opening_element + [ + "<" + ">" + ] @punctuation.bracket) + +(afx_closing_element + [ + "<" + ">" + "/" + ] @punctuation.bracket) + +(afx_element_self_closing + [ + "<" + "/>" + ] @punctuation.bracket) + +[ + (package_name) + (alias_namespace) +] @module + +(namespace_declaration + "=" @operator) + +(assignment + "=" @operator) + +(copy + "<" @operator) + +(deletion) @operator + +(eel_binary_expression + operator: _ @operator) + +(eel_not_expression + [ + "!" + "not" + ] @operator) + +(string) @string + +(number) @number + +(boolean) @boolean + +(null) @constant.builtin + +(value_expression + start: _ @punctuation.special + end: _ @punctuation.special) + +[ + "(" + ")" + "{" + "}" + "[" + "]" +] @punctuation.bracket + +[ + ":" + "." + "?" +] @punctuation.delimiter + +(eel_ternary_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) diff --git a/pack/ant/start/nvim-treesitter/queries/fusion/indents.scm b/pack/ant/start/nvim-treesitter/queries/fusion/indents.scm new file mode 100644 index 0000000..0ba6cf7 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fusion/indents.scm @@ -0,0 +1,24 @@ +[ + (block) + (value_dsl) + (afx_element) + (afx_element_self_closing) + (eel_array) + (eel_object) +] @indent.begin + +(block + end: _ @indent.branch) + +(value_dsl + end: _ @indent.branch) + +(eel_array + end: _ @indent.branch) + +(eel_object + end: _ @indent.branch) + +(afx_closing_element) @indent.branch + +(comment) @indent.ignore diff --git a/pack/ant/start/nvim-treesitter/queries/fusion/injections.scm b/pack/ant/start/nvim-treesitter/queries/fusion/injections.scm new file mode 100644 index 0000000..085cdb4 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fusion/injections.scm @@ -0,0 +1,5 @@ +([ + (comment) + (afx_comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/fusion/locals.scm b/pack/ant/start/nvim-treesitter/queries/fusion/locals.scm new file mode 100644 index 0000000..d23e0ab --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/fusion/locals.scm @@ -0,0 +1,23 @@ +; Fusion base +(block) @local.scope + +(namespace_declaration + (alias_namespace) @local.definition.namespace) + +(property + (path + (path_part) @local.definition.field)) + +(type + namespace: (package_name)? @local.definition.namespace + name: (type_name) @local.definition.type) + +; Eel Expressions +(eel_arrow_function) @local.scope + +(eel_object) @local.scope + +(eel_parameter) @local.definition.parameter + +(eel_object_pair + key: (eel_property_name) @local.definition.field) diff --git a/pack/ant/start/nvim-treesitter/queries/gap/folds.scm b/pack/ant/start/nvim-treesitter/queries/gap/folds.scm new file mode 100644 index 0000000..7cf0888 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gap/folds.scm @@ -0,0 +1,12 @@ +[ + (if_statement) + (elif_clause) + (else_clause) + (while_statement) + (repeat_statement) + (for_statement) + (atomic_statement) + (lambda) + (function) + (atomic_function) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/gap/highlights.scm b/pack/ant/start/nvim-treesitter/queries/gap/highlights.scm new file mode 100644 index 0000000..6c0c856 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gap/highlights.scm @@ -0,0 +1,208 @@ +(identifier) @variable + +; Functions +(assignment_statement + left: (identifier) @function + right: (function)) + +(assignment_statement + left: (identifier) @function + right: (atomic_function)) + +(assignment_statement + left: (identifier) @function + right: (lambda)) + +(call + function: (identifier) @function.call) + +((call + function: (identifier) @function.builtin) + (#any-of? @function.builtin "Assert" "Info" "IsBound" "Unbind" "TryNextMethod")) + +(parameters + (identifier) @variable.parameter) + +(qualified_parameters + (identifier) @variable.parameter) + +(qualified_parameters + (qualified_identifier + (identifier) @variable.parameter)) + +(lambda_parameters + (identifier) @variable.parameter) + +; arg is treated specially when it is the only parameter of a function +((parameters + . + (identifier) @variable.parameter.builtin .) + (#eq? @variable.parameter.builtin "arg")) + +((qualified_parameters + . + (identifier) @variable.parameter.builtin .) + (#eq? @variable.parameter.builtin "arg")) + +((qualified_parameters + . + (qualified_identifier + (identifier) @variable.parameter.builtin) .) + (#eq? @variable.parameter.builtin "arg")) + +((lambda_parameters + . + (identifier) @variable.parameter.builtin .) + (#eq? @variable.parameter.builtin "arg")) + +; Literals +(bool) @constant.builtin + +(integer) @number + +(float) @number.float + +(string) @string + +(char) @character + +(escape_sequence) @string.escape + +[ + (help_topic) + (help_book) +] @string.special + +(tilde) @variable.builtin + +; Record selectors +(record_entry + left: [ + (identifier) + (integer) + ] @variable.member) + +(record_selector + selector: [ + (identifier) + (integer) + ] @variable.member) + +(component_selector + selector: [ + (identifier) + (integer) + ] @variable.member) + +(function_call_option + [ + (identifier) + (record_entry ;Record entries specify global properties in function calls + left: [ + (identifier) + (integer) + ]) + ] @property) + +(help_statement + (help_selector) @property) + +; Operators +[ + "+" + "-" + "*" + "/" + "^" + "->" + ":=" + "<" + "<=" + "<>" + "=" + ">" + ">=" + ".." + (ellipsis) +] @operator + +(help_statement + (help_operator) @operator) + +; Keywords +[ + (break_statement) + (continue_statement) + "atomic" + (quit_statement) +] @keyword + +[ + "function" + "local" + "end" +] @keyword.function + +[ + "and" + "in" + "mod" + "not" + "or" +] @keyword.operator + +"rec" @keyword.type + +[ + "readonly" + "readwrite" +] @keyword.modifier + +(atomic_function + "atomic" @keyword.modifier) + +[ + "for" + "while" + "do" + "od" + "repeat" + "until" +] @keyword.repeat + +[ + "if" + "then" + "elif" + "else" + "fi" +] @keyword.conditional + +"return" @keyword.return + +(pragma) @keyword.directive + +;Punctuation +[ + "," + ";" + "." + "!." + ":" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "![" + "]" + "{" + "}" +] @punctuation.bracket + +(help_statement + "?" @punctuation.special) + +;Comments +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/gap/injections.scm b/pack/ant/start/nvim-treesitter/queries/gap/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gap/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/gap/locals.scm b/pack/ant/start/nvim-treesitter/queries/gap/locals.scm new file mode 100644 index 0000000..d695d1f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gap/locals.scm @@ -0,0 +1,43 @@ +[ + (lambda) + (function) + (atomic_function) +] @local.scope + +(parameters + (identifier) @local.definition.parameter) + +(qualified_parameters + (identifier) @local.definition.parameter) + +(qualified_parameters + (qualified_identifier + (identifier) @local.definition.parameter)) + +(lambda_parameters + (identifier) @local.definition.parameter) + +(locals + (identifier) @local.definition.var) + +(record_entry + left: [ + (identifier) + (integer) + ] @local.definition.field) + +(assignment_statement + left: (identifier) @local.definition.var) + +(for_statement + identifier: (identifier) @local.definition.var) + +(assignment_statement + left: (identifier) @local.definition.function + right: [ + (lambda) + (function) + (atomic_function) + ]) + +(identifier) @local.reference diff --git a/pack/ant/start/nvim-treesitter/queries/gaptst/folds.scm b/pack/ant/start/nvim-treesitter/queries/gaptst/folds.scm new file mode 100644 index 0000000..0ec72d1 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gaptst/folds.scm @@ -0,0 +1,7 @@ +[ + (if_statement) + (else_clause) + (local_statement) + (exec_statement) + (test_case) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/gaptst/highlights.scm b/pack/ant/start/nvim-treesitter/queries/gaptst/highlights.scm new file mode 100644 index 0000000..22ab2d0 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gaptst/highlights.scm @@ -0,0 +1,19 @@ +(output_line) @markup.raw.block + +[ + "#@local" + "#@exec" +] @keyword + +[ + "gap> " + "> " +] @keyword.debug + +[ + "#@if" + "#@else" + "#@fi" +] @keyword.conditional + +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/gaptst/injections.scm b/pack/ant/start/nvim-treesitter/queries/gaptst/injections.scm new file mode 100644 index 0000000..bdcba35 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gaptst/injections.scm @@ -0,0 +1,9 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((gap_expression) @injection.content + (#set! injection.language "gap")) + +((input_line) @injection.content + (#set! injection.language "gap") + (#set! injection.combined)) diff --git a/pack/ant/start/nvim-treesitter/queries/gdscript/folds.scm b/pack/ant/start/nvim-treesitter/queries/gdscript/folds.scm new file mode 100644 index 0000000..cda7090 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gdscript/folds.scm @@ -0,0 +1,26 @@ +[ + ; Body fold will "join" the next adjacent fold into a SUPER fold. + ; This is an issue with the grammar. + ; (body) + (if_statement) + (elif_clause) + (else_clause) + (for_statement) + (while_statement) + (class_definition) + (enum_definition) + (match_statement) + (pattern_section) + (function_definition) + (lambda) + (constructor_definition) +] @fold + +; It's nice to be able to fold the if/elif/else clauses and the entire +; if_statement. +(if_statement + (body) @fold) + +; Fold strings that are probably doc strings. +(expression_statement + (string) @fold) diff --git a/pack/ant/start/nvim-treesitter/queries/gdscript/highlights.scm b/pack/ant/start/nvim-treesitter/queries/gdscript/highlights.scm new file mode 100644 index 0000000..bc62bc2 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gdscript/highlights.scm @@ -0,0 +1,422 @@ +; Basic +(identifier) @variable + +(name) @variable + +(type + (identifier) @type) + +(comment) @comment @spell + +(string_name) @string + +(string) @string + +(float) @number.float + +(integer) @number + +(null) @constant + +(setter) @function + +(getter) @function + +(set_body + "set" @keyword.function) + +(get_body + "get" @keyword.function) + +(static_keyword) @keyword.modifier + +(tool_statement) @keyword + +(breakpoint_statement) @keyword.debug + +(inferred_type) @operator + +[ + (true) + (false) +] @boolean + +[ + (get_node) + (node_path) +] @string.special.url + +(class_name_statement + (name) @type) @keyword + +(const_statement + "const" @keyword.modifier + (name) @constant) + +(expression_statement + (string) @comment @spell) + +; Functions +(constructor_definition + "_init" @constructor) + +(function_definition + (name) @function) + +(parameters + (identifier) @variable.parameter) + +(typed_parameter + (identifier) @variable.parameter) + +(default_parameter + (identifier) @variable.parameter) + +(typed_default_parameter + (identifier) @variable.parameter) + +(call + (identifier) @function.call) + +(call + (identifier) @keyword.import + (#any-of? @keyword.import "preload" "load")) + +; Properties and Methods +; We'll use @property since that's the term Godot uses. +; But, should (source (variable_statement (name))) be @property, too? Since a +; script file is a class in gdscript. +(class_definition + (body + (variable_statement + (name) @property))) + +; Same question but for methods? +(class_definition + (body + (function_definition + (name) @function.method))) + +(attribute_call + (identifier) @function.method.call) + +(attribute_subscript + (identifier) @property) + +(attribute + (_) + (identifier) @property) + +; Identifier naming conventions +; - Make sure the following query is below the attribute queries so that it +; takes precedence on a `(type (attribute (identifier)))` +((identifier) @type + (#lua-match? @type "^[A-Z]")) + +((identifier) @constant + (#lua-match? @constant "^[A-Z][A-Z_0-9]*$")) + +; Enums +(enumerator + left: (identifier) @constant) + +; Special Builtins +((identifier) @variable.builtin + (#any-of? @variable.builtin "self" "super")) + +(attribute_call + (identifier) @keyword.operator + (#eq? @keyword.operator "new")) + +; Match Pattern +[ + (underscore) + (pattern_open_ending) +] @character.special + +; Alternations +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "," + "." + ":" +] @punctuation.delimiter + +[ + "if" + "elif" + "else" + "match" +] @keyword.conditional + +(pattern_guard + "when" @keyword.conditional) + +[ + "for" + "while" + "break" + "continue" +] @keyword.repeat + +[ + "~" + "-" + "*" + "/" + "%" + "+" + "-" + "<<" + ">>" + "&" + "^" + "|" + "<" + ">" + "==" + "!=" + ">=" + "<=" + "!" + "&&" + "||" + "=" + "+=" + "-=" + "*=" + "/=" + "%=" + "&=" + "|=" + "->" +] @operator + +[ + "and" + "as" + "in" + "is" + "not" + "or" +] @keyword.operator + +[ + "pass" + "class_name" + "extends" + "signal" + "var" + "onready" + "setget" + "remote" + "master" + "puppet" + "remotesync" + "mastersync" + "puppetsync" +] @keyword + +"export" @keyword.import + +[ + "enum" + "class" +] @keyword.type + +"func" @keyword.function + +"return" @keyword.return + +"await" @keyword.coroutine + +(call + (identifier) @keyword.coroutine + (#eq? @keyword.coroutine "yield")) + +; Builtins +; generated from +; - godot commit: fb10e67fef +; - https://github.com/godotengine/godot/blob/fb10e67fef/doc/classes +; - https://github.com/godotengine/godot/blob/fb10e67fef/doc/classes/@GlobalScope.xml +; - https://github.com/godotengine/godot/blob/fb10e67fef/modules/gdscript/doc_classes/@GDScript.xml +; Built-in Annotations +((annotation + "@" @attribute + (identifier) @attribute) + (#any-of? @attribute + ; from modules/gdscript/doc_classes/@GDScript.xml + "export" "export_category" "export_color_no_alpha" "export_dir" "export_enum" + "export_exp_easing" "export_file" "export_flags" "export_flags_2d_navigation" + "export_flags_2d_physics" "export_flags_2d_render" "export_flags_3d_navigation" + "export_flags_3d_physics" "export_flags_3d_render" "export_flags_avoidance" "export_global_dir" + "export_global_file" "export_group" "export_multiline" "export_node_path" "export_placeholder" + "export_range" "export_subgroup" "icon" "onready" "rpc" "static_unload" "tool" "warning_ignore")) + +; Builtin Types +((identifier) @type.builtin + (#any-of? @type.builtin + ; from doc/classes/*.xml + "AABB" "Array" "Basis" "Callable" "Color" "Dictionary" "NodePath" "PackedByteArray" + "PackedColorArray" "PackedFloat32Array" "PackedFloat64Array" "PackedInt32Array" + "PackedInt64Array" "PackedStringArray" "PackedVector2Array" "PackedVector3Array" "Plane" + "Projection" "Quaternion" "RID" "Rect2" "Rect2i" "Signal" "String" "StringName" "Transform2D" + "Transform3D" "Vector2" "Vector2i" "Vector3" "Vector3i" "Vector4" "Vector4i" "bool" "float" + "int" + ; from doc/classes/@GlobalScope.xml + "AudioServer" "CameraServer" "ClassDB" "DisplayServer" "EditorInterface" "Engine" + "EngineDebugger" "GDExtensionManager" "Geometry2D" "Geometry3D" "GodotSharp" "IP" "Input" + "InputMap" "JavaClassWrapper" "JavaScriptBridge" "Marshalls" "NavigationMeshGenerator" + "NavigationServer2D" "NavigationServer3D" "OS" "Performance" "PhysicsServer2D" + "PhysicsServer2DManager" "PhysicsServer3D" "PhysicsServer3DManager" "ProjectSettings" + "RenderingServer" "ResourceLoader" "ResourceSaver" "ResourceUID" "TextServerManager" "ThemeDB" + "Time" "TranslationServer" "WorkerThreadPool" "XRServer")) + +; Builtin Funcs +(call + (identifier) @function.builtin + (#any-of? @function.builtin + ; from doc/classes/@GlobalScope.xml + "abs" "absf" "absi" "acos" "acosh" "angle_difference" "asin" "asinh" "atan" "atan2" "atanh" + "bezier_derivative" "bezier_interpolate" "bytes_to_var" "bytes_to_var_with_objects" "ceil" + "ceilf" "ceili" "clamp" "clampf" "clampi" "cos" "cosh" "cubic_interpolate" + "cubic_interpolate_angle" "cubic_interpolate_angle_in_time" "cubic_interpolate_in_time" + "db_to_linear" "deg_to_rad" "ease" "error_string" "exp" "floor" "floorf" "floori" "fmod" + "fposmod" "hash" "instance_from_id" "inverse_lerp" "is_equal_approx" "is_finite" "is_inf" + "is_instance_id_valid" "is_instance_valid" "is_nan" "is_same" "is_zero_approx" "lerp" + "lerp_angle" "lerpf" "linear_to_db" "log" "max" "maxf" "maxi" "min" "minf" "mini" "move_toward" + "nearest_po2" "pingpong" "posmod" "pow" "print" "print_rich" "print_verbose" "printerr" + "printraw" "prints" "printt" "push_error" "push_warning" "rad_to_deg" "rand_from_seed" "randf" + "randf_range" "randfn" "randi" "randi_range" "randomize" "remap" "rid_allocate_id" + "rid_from_int64" "rotate_toward" "round" "roundf" "roundi" "seed" "sign" "signf" "signi" "sin" + "sinh" "smoothstep" "snapped" "snappedf" "snappedi" "sqrt" "step_decimals" "str" "str_to_var" + "tan" "tanh" "type_convert" "type_string" "typeof" "var_to_bytes" "var_to_bytes_with_objects" + "var_to_str" "weakref" "wrap" "wrapf" "wrapi" + ; from modules/gdscript/doc_classes/@GDScript.xml + "Color8" "assert" "char" "convert" "dict_to_inst" "get_stack" "inst_to_dict" "is_instance_of" + "len" "load" "preload" "print_debug" "print_stack" "range" "type_exists") + ) + +; Builtin Constants +((identifier) @constant.builtin + (#any-of? @constant.builtin + ; from modules/gdscript/doc_classes/@GDScript.xml + "INF" "NAN" "PI" "TAU" + ; from doc/classes/@GlobalScope.xml + "CLOCKWISE" "CORNER_BOTTOM_LEFT" "CORNER_BOTTOM_RIGHT" "CORNER_TOP_LEFT" "CORNER_TOP_RIGHT" + "COUNTERCLOCKWISE" "ERR_ALREADY_EXISTS" "ERR_ALREADY_IN_USE" "ERR_BUG" "ERR_BUSY" + "ERR_CANT_ACQUIRE_RESOURCE" "ERR_CANT_CONNECT" "ERR_CANT_CREATE" "ERR_CANT_FORK" "ERR_CANT_OPEN" + "ERR_CANT_RESOLVE" "ERR_COMPILATION_FAILED" "ERR_CONNECTION_ERROR" "ERR_CYCLIC_LINK" + "ERR_DATABASE_CANT_READ" "ERR_DATABASE_CANT_WRITE" "ERR_DOES_NOT_EXIST" "ERR_DUPLICATE_SYMBOL" + "ERR_FILE_ALREADY_IN_USE" "ERR_FILE_BAD_DRIVE" "ERR_FILE_BAD_PATH" "ERR_FILE_CANT_OPEN" + "ERR_FILE_CANT_READ" "ERR_FILE_CANT_WRITE" "ERR_FILE_CORRUPT" "ERR_FILE_EOF" + "ERR_FILE_MISSING_DEPENDENCIES" "ERR_FILE_NOT_FOUND" "ERR_FILE_NO_PERMISSION" + "ERR_FILE_UNRECOGNIZED" "ERR_HELP" "ERR_INVALID_DATA" "ERR_INVALID_DECLARATION" + "ERR_INVALID_PARAMETER" "ERR_LINK_FAILED" "ERR_LOCKED" "ERR_METHOD_NOT_FOUND" + "ERR_OUT_OF_MEMORY" "ERR_PARAMETER_RANGE_ERROR" "ERR_PARSE_ERROR" "ERR_PRINTER_ON_FIRE" + "ERR_QUERY_FAILED" "ERR_SCRIPT_FAILED" "ERR_SKIP" "ERR_TIMEOUT" "ERR_UNAUTHORIZED" + "ERR_UNAVAILABLE" "ERR_UNCONFIGURED" "EULER_ORDER_XYZ" "EULER_ORDER_XZY" "EULER_ORDER_YXZ" + "EULER_ORDER_YZX" "EULER_ORDER_ZXY" "EULER_ORDER_ZYX" "FAILED" "HORIZONTAL" + "HORIZONTAL_ALIGNMENT_CENTER" "HORIZONTAL_ALIGNMENT_FILL" "HORIZONTAL_ALIGNMENT_LEFT" + "HORIZONTAL_ALIGNMENT_RIGHT" "INLINE_ALIGNMENT_BASELINE_TO" "INLINE_ALIGNMENT_BOTTOM" + "INLINE_ALIGNMENT_BOTTOM_TO" "INLINE_ALIGNMENT_CENTER" "INLINE_ALIGNMENT_CENTER_TO" + "INLINE_ALIGNMENT_IMAGE_MASK" "INLINE_ALIGNMENT_TEXT_MASK" "INLINE_ALIGNMENT_TOP" + "INLINE_ALIGNMENT_TOP_TO" "INLINE_ALIGNMENT_TO_BASELINE" "INLINE_ALIGNMENT_TO_BOTTOM" + "INLINE_ALIGNMENT_TO_CENTER" "INLINE_ALIGNMENT_TO_TOP" "JOY_AXIS_INVALID" "JOY_AXIS_LEFT_X" + "JOY_AXIS_LEFT_Y" "JOY_AXIS_MAX" "JOY_AXIS_RIGHT_X" "JOY_AXIS_RIGHT_Y" "JOY_AXIS_SDL_MAX" + "JOY_AXIS_TRIGGER_LEFT" "JOY_AXIS_TRIGGER_RIGHT" "JOY_BUTTON_A" "JOY_BUTTON_B" "JOY_BUTTON_BACK" + "JOY_BUTTON_DPAD_DOWN" "JOY_BUTTON_DPAD_LEFT" "JOY_BUTTON_DPAD_RIGHT" "JOY_BUTTON_DPAD_UP" + "JOY_BUTTON_GUIDE" "JOY_BUTTON_INVALID" "JOY_BUTTON_LEFT_SHOULDER" "JOY_BUTTON_LEFT_STICK" + "JOY_BUTTON_MAX" "JOY_BUTTON_MISC1" "JOY_BUTTON_PADDLE1" "JOY_BUTTON_PADDLE2" + "JOY_BUTTON_PADDLE3" "JOY_BUTTON_PADDLE4" "JOY_BUTTON_RIGHT_SHOULDER" "JOY_BUTTON_RIGHT_STICK" + "JOY_BUTTON_SDL_MAX" "JOY_BUTTON_START" "JOY_BUTTON_TOUCHPAD" "JOY_BUTTON_X" "JOY_BUTTON_Y" + "KEY_0" "KEY_1" "KEY_2" "KEY_3" "KEY_4" "KEY_5" "KEY_6" "KEY_7" "KEY_8" "KEY_9" "KEY_A" + "KEY_ALT" "KEY_AMPERSAND" "KEY_APOSTROPHE" "KEY_ASCIICIRCUM" "KEY_ASCIITILDE" "KEY_ASTERISK" + "KEY_AT" "KEY_B" "KEY_BACK" "KEY_BACKSLASH" "KEY_BACKSPACE" "KEY_BACKTAB" "KEY_BAR" + "KEY_BRACELEFT" "KEY_BRACERIGHT" "KEY_BRACKETLEFT" "KEY_BRACKETRIGHT" "KEY_C" "KEY_CAPSLOCK" + "KEY_CLEAR" "KEY_CODE_MASK" "KEY_COLON" "KEY_COMMA" "KEY_CTRL" "KEY_D" "KEY_DELETE" "KEY_DOLLAR" + "KEY_DOWN" "KEY_E" "KEY_END" "KEY_ENTER" "KEY_EQUAL" "KEY_ESCAPE" "KEY_EXCLAM" "KEY_F" "KEY_F1" + "KEY_F10" "KEY_F11" "KEY_F12" "KEY_F13" "KEY_F14" "KEY_F15" "KEY_F16" "KEY_F17" "KEY_F18" + "KEY_F19" "KEY_F2" "KEY_F20" "KEY_F21" "KEY_F22" "KEY_F23" "KEY_F24" "KEY_F25" "KEY_F26" + "KEY_F27" "KEY_F28" "KEY_F29" "KEY_F3" "KEY_F30" "KEY_F31" "KEY_F32" "KEY_F33" "KEY_F34" + "KEY_F35" "KEY_F4" "KEY_F5" "KEY_F6" "KEY_F7" "KEY_F8" "KEY_F9" "KEY_FAVORITES" "KEY_FORWARD" + "KEY_G" "KEY_GLOBE" "KEY_GREATER" "KEY_H" "KEY_HELP" "KEY_HOME" "KEY_HOMEPAGE" "KEY_HYPER" + "KEY_I" "KEY_INSERT" "KEY_J" "KEY_JIS_EISU" "KEY_JIS_KANA" "KEY_K" "KEY_KEYBOARD" "KEY_KP_0" + "KEY_KP_1" "KEY_KP_2" "KEY_KP_3" "KEY_KP_4" "KEY_KP_5" "KEY_KP_6" "KEY_KP_7" "KEY_KP_8" + "KEY_KP_9" "KEY_KP_ADD" "KEY_KP_DIVIDE" "KEY_KP_ENTER" "KEY_KP_MULTIPLY" "KEY_KP_PERIOD" + "KEY_KP_SUBTRACT" "KEY_L" "KEY_LAUNCH0" "KEY_LAUNCH1" "KEY_LAUNCH2" "KEY_LAUNCH3" "KEY_LAUNCH4" + "KEY_LAUNCH5" "KEY_LAUNCH6" "KEY_LAUNCH7" "KEY_LAUNCH8" "KEY_LAUNCH9" "KEY_LAUNCHA" + "KEY_LAUNCHB" "KEY_LAUNCHC" "KEY_LAUNCHD" "KEY_LAUNCHE" "KEY_LAUNCHF" "KEY_LAUNCHMAIL" + "KEY_LAUNCHMEDIA" "KEY_LEFT" "KEY_LESS" "KEY_LOCATION_LEFT" "KEY_LOCATION_RIGHT" + "KEY_LOCATION_UNSPECIFIED" "KEY_M" "KEY_MASK_ALT" "KEY_MASK_CMD_OR_CTRL" "KEY_MASK_CTRL" + "KEY_MASK_GROUP_SWITCH" "KEY_MASK_KPAD" "KEY_MASK_META" "KEY_MASK_SHIFT" "KEY_MEDIANEXT" + "KEY_MEDIAPLAY" "KEY_MEDIAPREVIOUS" "KEY_MEDIARECORD" "KEY_MEDIASTOP" "KEY_MENU" "KEY_META" + "KEY_MINUS" "KEY_MODIFIER_MASK" "KEY_N" "KEY_NONE" "KEY_NUMBERSIGN" "KEY_NUMLOCK" "KEY_O" + "KEY_OPENURL" "KEY_P" "KEY_PAGEDOWN" "KEY_PAGEUP" "KEY_PARENLEFT" "KEY_PARENRIGHT" "KEY_PAUSE" + "KEY_PERCENT" "KEY_PERIOD" "KEY_PLUS" "KEY_PRINT" "KEY_Q" "KEY_QUESTION" "KEY_QUOTEDBL" + "KEY_QUOTELEFT" "KEY_R" "KEY_REFRESH" "KEY_RIGHT" "KEY_S" "KEY_SCROLLLOCK" "KEY_SEARCH" + "KEY_SECTION" "KEY_SEMICOLON" "KEY_SHIFT" "KEY_SLASH" "KEY_SPACE" "KEY_SPECIAL" "KEY_STANDBY" + "KEY_STOP" "KEY_SYSREQ" "KEY_T" "KEY_TAB" "KEY_U" "KEY_UNDERSCORE" "KEY_UNKNOWN" "KEY_UP" + "KEY_V" "KEY_VOLUMEDOWN" "KEY_VOLUMEMUTE" "KEY_VOLUMEUP" "KEY_W" "KEY_X" "KEY_Y" "KEY_YEN" + "KEY_Z" "METHOD_FLAGS_DEFAULT" "METHOD_FLAG_CONST" "METHOD_FLAG_EDITOR" "METHOD_FLAG_NORMAL" + "METHOD_FLAG_OBJECT_CORE" "METHOD_FLAG_STATIC" "METHOD_FLAG_VARARG" "METHOD_FLAG_VIRTUAL" + "MIDI_MESSAGE_ACTIVE_SENSING" "MIDI_MESSAGE_AFTERTOUCH" "MIDI_MESSAGE_CHANNEL_PRESSURE" + "MIDI_MESSAGE_CONTINUE" "MIDI_MESSAGE_CONTROL_CHANGE" "MIDI_MESSAGE_NONE" + "MIDI_MESSAGE_NOTE_OFF" "MIDI_MESSAGE_NOTE_ON" "MIDI_MESSAGE_PITCH_BEND" + "MIDI_MESSAGE_PROGRAM_CHANGE" "MIDI_MESSAGE_QUARTER_FRAME" "MIDI_MESSAGE_SONG_POSITION_POINTER" + "MIDI_MESSAGE_SONG_SELECT" "MIDI_MESSAGE_START" "MIDI_MESSAGE_STOP" + "MIDI_MESSAGE_SYSTEM_EXCLUSIVE" "MIDI_MESSAGE_SYSTEM_RESET" "MIDI_MESSAGE_TIMING_CLOCK" + "MIDI_MESSAGE_TUNE_REQUEST" "MOUSE_BUTTON_LEFT" "MOUSE_BUTTON_MASK_LEFT" + "MOUSE_BUTTON_MASK_MB_XBUTTON1" "MOUSE_BUTTON_MASK_MB_XBUTTON2" "MOUSE_BUTTON_MASK_MIDDLE" + "MOUSE_BUTTON_MASK_RIGHT" "MOUSE_BUTTON_MIDDLE" "MOUSE_BUTTON_NONE" "MOUSE_BUTTON_RIGHT" + "MOUSE_BUTTON_WHEEL_DOWN" "MOUSE_BUTTON_WHEEL_LEFT" "MOUSE_BUTTON_WHEEL_RIGHT" + "MOUSE_BUTTON_WHEEL_UP" "MOUSE_BUTTON_XBUTTON1" "MOUSE_BUTTON_XBUTTON2" "OK" "OP_ADD" "OP_AND" + "OP_BIT_AND" "OP_BIT_NEGATE" "OP_BIT_OR" "OP_BIT_XOR" "OP_DIVIDE" "OP_EQUAL" "OP_GREATER" + "OP_GREATER_EQUAL" "OP_IN" "OP_LESS" "OP_LESS_EQUAL" "OP_MAX" "OP_MODULE" "OP_MULTIPLY" + "OP_NEGATE" "OP_NOT" "OP_NOT_EQUAL" "OP_OR" "OP_POSITIVE" "OP_POWER" "OP_SHIFT_LEFT" + "OP_SHIFT_RIGHT" "OP_SUBTRACT" "OP_XOR" "PROPERTY_HINT_ARRAY_TYPE" + "PROPERTY_HINT_COLOR_NO_ALPHA" "PROPERTY_HINT_DIR" "PROPERTY_HINT_ENUM" + "PROPERTY_HINT_ENUM_SUGGESTION" "PROPERTY_HINT_EXPRESSION" "PROPERTY_HINT_EXP_EASING" + "PROPERTY_HINT_FILE" "PROPERTY_HINT_FLAGS" "PROPERTY_HINT_GLOBAL_DIR" + "PROPERTY_HINT_GLOBAL_FILE" "PROPERTY_HINT_GLOBAL_SAVE_FILE" + "PROPERTY_HINT_HIDE_QUATERNION_EDIT" "PROPERTY_HINT_INT_IS_OBJECTID" + "PROPERTY_HINT_INT_IS_POINTER" "PROPERTY_HINT_LAYERS_2D_NAVIGATION" + "PROPERTY_HINT_LAYERS_2D_PHYSICS" "PROPERTY_HINT_LAYERS_2D_RENDER" + "PROPERTY_HINT_LAYERS_3D_NAVIGATION" "PROPERTY_HINT_LAYERS_3D_PHYSICS" + "PROPERTY_HINT_LAYERS_3D_RENDER" "PROPERTY_HINT_LAYERS_AVOIDANCE" "PROPERTY_HINT_LINK" + "PROPERTY_HINT_LOCALE_ID" "PROPERTY_HINT_LOCALIZABLE_STRING" "PROPERTY_HINT_MAX" + "PROPERTY_HINT_MULTILINE_TEXT" "PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE" + "PROPERTY_HINT_NODE_PATH_VALID_TYPES" "PROPERTY_HINT_NODE_TYPE" "PROPERTY_HINT_NONE" + "PROPERTY_HINT_OBJECT_ID" "PROPERTY_HINT_OBJECT_TOO_BIG" "PROPERTY_HINT_PASSWORD" + "PROPERTY_HINT_PLACEHOLDER_TEXT" "PROPERTY_HINT_RANGE" "PROPERTY_HINT_RESOURCE_TYPE" + "PROPERTY_HINT_SAVE_FILE" "PROPERTY_HINT_TYPE_STRING" "PROPERTY_USAGE_ALWAYS_DUPLICATE" + "PROPERTY_USAGE_ARRAY" "PROPERTY_USAGE_CATEGORY" "PROPERTY_USAGE_CHECKABLE" + "PROPERTY_USAGE_CHECKED" "PROPERTY_USAGE_CLASS_IS_BITFIELD" "PROPERTY_USAGE_CLASS_IS_ENUM" + "PROPERTY_USAGE_DEFAULT" "PROPERTY_USAGE_DEFERRED_SET_RESOURCE" "PROPERTY_USAGE_EDITOR" + "PROPERTY_USAGE_EDITOR_BASIC_SETTING" "PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT" + "PROPERTY_USAGE_GROUP" "PROPERTY_USAGE_HIGH_END_GFX" "PROPERTY_USAGE_INTERNAL" + "PROPERTY_USAGE_KEYING_INCREMENTS" "PROPERTY_USAGE_NEVER_DUPLICATE" + "PROPERTY_USAGE_NIL_IS_VARIANT" "PROPERTY_USAGE_NODE_PATH_FROM_SCENE_ROOT" "PROPERTY_USAGE_NONE" + "PROPERTY_USAGE_NO_EDITOR" "PROPERTY_USAGE_NO_INSTANCE_STATE" "PROPERTY_USAGE_READ_ONLY" + "PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT" "PROPERTY_USAGE_RESTART_IF_CHANGED" + "PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE" "PROPERTY_USAGE_SCRIPT_VARIABLE" "PROPERTY_USAGE_SECRET" + "PROPERTY_USAGE_STORAGE" "PROPERTY_USAGE_STORE_IF_NULL" "PROPERTY_USAGE_SUBGROUP" + "PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED" "SIDE_BOTTOM" "SIDE_LEFT" "SIDE_RIGHT" "SIDE_TOP" + "TYPE_AABB" "TYPE_ARRAY" "TYPE_BASIS" "TYPE_BOOL" "TYPE_CALLABLE" "TYPE_COLOR" "TYPE_DICTIONARY" + "TYPE_FLOAT" "TYPE_INT" "TYPE_MAX" "TYPE_NIL" "TYPE_NODE_PATH" "TYPE_OBJECT" + "TYPE_PACKED_BYTE_ARRAY" "TYPE_PACKED_COLOR_ARRAY" "TYPE_PACKED_FLOAT32_ARRAY" + "TYPE_PACKED_FLOAT64_ARRAY" "TYPE_PACKED_INT32_ARRAY" "TYPE_PACKED_INT64_ARRAY" + "TYPE_PACKED_STRING_ARRAY" "TYPE_PACKED_VECTOR2_ARRAY" "TYPE_PACKED_VECTOR3_ARRAY" "TYPE_PLANE" + "TYPE_PROJECTION" "TYPE_QUATERNION" "TYPE_RECT2" "TYPE_RECT2I" "TYPE_RID" "TYPE_SIGNAL" + "TYPE_STRING" "TYPE_STRING_NAME" "TYPE_TRANSFORM2D" "TYPE_TRANSFORM3D" "TYPE_VECTOR2" + "TYPE_VECTOR2I" "TYPE_VECTOR3" "TYPE_VECTOR3I" "TYPE_VECTOR4" "TYPE_VECTOR4I" "VERTICAL" + "VERTICAL_ALIGNMENT_BOTTOM" "VERTICAL_ALIGNMENT_CENTER" "VERTICAL_ALIGNMENT_FILL" + "VERTICAL_ALIGNMENT_TOP")) diff --git a/pack/ant/start/nvim-treesitter/queries/gdscript/indents.scm b/pack/ant/start/nvim-treesitter/queries/gdscript/indents.scm new file mode 100644 index 0000000..36b989f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gdscript/indents.scm @@ -0,0 +1,78 @@ +[ + (lambda) + (function_definition) + (constructor_definition) + (for_statement) + (while_statement) + (if_statement) + (class_definition) + (match_statement) + (pattern_section) + (setget) + (match_body) + (set_body) + (get_body) +] @indent.begin + +[ + (elif_clause) + (else_clause) +] @indent.branch + +[ + (string) + (comment) + (array) + (dictionary) + (parenthesized_expression) + (ERROR) +] @indent.auto + +[ + (pass_statement) + (continue_statement) + (break_statement) + (return_statement) +] @indent.dedent + +[ + (ERROR + "[") + (ERROR + "(") + (ERROR + "{") +] @indent.begin + +; This only works with expanded tabs. +; ((parameters) @indent.align (#set! indent.open_delimiter "(") (#set! indent.close_delimiter ")")) +; ((arguments) @indent.align (#set! indent.open_delimiter "(") (#set! indent.close_delimiter ")")) +; The following queries either do not agree with the current body parsing or are +; attempted workarounds. Specifically as the last statement of a body. Opening +; a new line in between statements works well. +; +; The overall experience is poor, so I've opted for @indent.auto. +; +; The gdscript parser will need to be patched to accommodate more interactive +; edits. As far as I can tell the parser greedily consumes whitespace +; as a zero-width token which causes trouble when inserting indents. +; This indents correctly with tabs. +; (arguments) @indent.begin +; (parameters) @indent.begin +; (array) @indent.begin +; (dictionary) @indent.begin +; (parenthesized_expression) @indent.begin +; Partial workaround for when the cursor is on the bracket character and a newline +; is created with . Without this the newline is opened with extra +; indentation. +; (body (_ (array "]" @indent.end) ) _) +; Problematic behaviors occur at the last statement of a body. +; with @dedent: +; - [ | ] i will dedent ] to 0. +; - [ +; ]| o will open new line at correct indentation. +; with @auto: +; - [ | ] i same +; - [ +; ]| o will open new line with extra indent. +;(body (_ (array "]" @indent.auto) ) .) diff --git a/pack/ant/start/nvim-treesitter/queries/gdscript/injections.scm b/pack/ant/start/nvim-treesitter/queries/gdscript/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gdscript/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/gdscript/locals.scm b/pack/ant/start/nvim-treesitter/queries/gdscript/locals.scm new file mode 100644 index 0000000..62166e6 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gdscript/locals.scm @@ -0,0 +1,121 @@ +; Scopes +[ + (if_statement) + (elif_clause) + (else_clause) + (for_statement) + (while_statement) + (function_definition) + (constructor_definition) + (class_definition) + (match_statement) + (pattern_section) + (lambda) + (get_body) + (set_body) +] @local.scope + +; Parameters +(parameters + (identifier) @local.definition.parameter) + +(default_parameter + (identifier) @local.definition.parameter) + +(typed_parameter + (identifier) @local.definition.parameter) + +(typed_default_parameter + (identifier) @local.definition.parameter) + +; Signals +; Can gdscript 2 signals be considered fields? +(signal_statement + (name) @local.definition.field) + +; Variable Definitions +(const_statement + (name) @local.definition.constant) + +; onready and export variations are only properties. +(variable_statement + (name) @local.definition.var) + +(setter) @local.reference + +(getter) @local.reference + +; Function Definition +((function_definition + (name) @local.definition.function) + (#set! definition.function.scope "parent")) + +; Lambda +; lambda names are not accessible and are only for debugging. +(lambda + (name) @local.definition.function) + +; Source +(class_name_statement + (name) @local.definition.type) + +(source + (variable_statement + (name) @local.definition.field)) + +(source + (onready_variable_statement + (name) @local.definition.field)) + +(source + (export_variable_statement + (name) @local.definition.field)) + +; Class +((class_definition + (name) @local.definition.type) + (#set! definition.type.scope "parent")) + +(class_definition + (body + (variable_statement + (name) @local.definition.field))) + +(class_definition + (body + (onready_variable_statement + (name) @local.definition.field))) + +(class_definition + (body + (export_variable_statement + (name) @local.definition.field))) + +(class_definition + (body + (signal_statement + (name) @local.definition.field))) + +; Although a script is also a class, let's only define functions in an inner class as +; methods. +((class_definition + (body + (function_definition + (name) @local.definition.method))) + (#set! definition.method.scope "parent")) + +; Enum +(enum_definition + (name) @local.definition.enum) + +; Repeat +(for_statement + . + (identifier) @local.definition.var) + +; Match Statement +(pattern_binding + (identifier) @local.definition.var) + +; References +(identifier) @local.reference diff --git a/pack/ant/start/nvim-treesitter/queries/gdshader/highlights.scm b/pack/ant/start/nvim-treesitter/queries/gdshader/highlights.scm new file mode 100644 index 0000000..c93fd47 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gdshader/highlights.scm @@ -0,0 +1,142 @@ +[ + "render_mode" + "shader_type" + "group_uniforms" + "global" + "instance" + "const" + "varying" + "uniform" +] @keyword + +"struct" @keyword.type + +[ + (precision_qualifier) + (interpolation_qualifier) +] @keyword.modifier + +[ + "in" + "out" + "inout" +] @keyword.modifier + +[ + "while" + "for" +] @keyword.repeat + +[ + "continue" + "break" + "return" +] @keyword.return + +[ + "if" + "else" + "switch" + "case" + "default" +] @keyword.conditional + +[ + "#" + "include" +] @keyword.directive + +(string) @string + +[ + "=" + "+=" + "-=" + "!" + "~" + "+" + "-" + "*" + "/" + "%" + "||" + "&&" + "|" + "^" + "&" + "==" + "!=" + ">" + ">=" + "<=" + "<" + "<<" + ">>" + "++" + "--" +] @operator + +(boolean) @boolean + +(integer) @number + +(float) @number.float + +[ + "." + "," + ";" +] @punctuation.delimiter + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(builtin_type) @type.builtin + +(ident_type) @type.definition + +[ + (shader_type) + (render_mode) + (hint_name) +] @attribute + +(builtin_variable) @constant.builtin + +(builtin_function) @function.builtin + +(group_uniforms_declaration + group_name: (ident) @property + subgroup_name: (ident) @property) + +(struct_declaration + name: (ident) @type) + +(struct_member + name: (ident) @property) + +(function_declaration + name: (ident) @function) + +(parameter + name: (ident) @variable.parameter) + +(member_expr + member: (ident) @property) + +(call_expr + function: [ + (ident) + (builtin_type) + ] @function) + +(call_expr + function: (builtin_type) @function.call) + +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/gdshader/injections.scm b/pack/ant/start/nvim-treesitter/queries/gdshader/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gdshader/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/git_config/folds.scm b/pack/ant/start/nvim-treesitter/queries/git_config/folds.scm new file mode 100644 index 0000000..cb376d5 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/git_config/folds.scm @@ -0,0 +1,2 @@ +((section) @fold + (#trim! @fold)) diff --git a/pack/ant/start/nvim-treesitter/queries/git_config/highlights.scm b/pack/ant/start/nvim-treesitter/queries/git_config/highlights.scm new file mode 100644 index 0000000..6b37e90 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/git_config/highlights.scm @@ -0,0 +1,59 @@ +; Sections +(section_name) @markup.heading + +((section_name) @keyword.import + (#eq? @keyword.import "include")) + +((section_header + (section_name) @keyword.import + (subsection_name)) + (#eq? @keyword.import "includeIf")) + +(variable + (name) @property) + +; Operators +"=" @operator + +; Literals +(integer) @number + +[ + (true) + (false) +] @boolean + +(string) @string + +(escape_sequence) @string.escape + +((string) @string.special.path + (#lua-match? @string.special.path "^[.]?[.]?[/]")) + +((string) @string.special.path + (#lua-match? @string.special.path "^[~]")) + +(section_header + [ + "\"" + (subsection_name) + ] @string.special) + +((section_header + (section_name) @_name + (subsection_name) @string.special.url) + (#any-of? @_name "credential" "url")) + +((variable + (name) @_name + value: (string) @string.special.url) + (#eq? @_name "insteadOf")) + +; Punctuation +[ + "[" + "]" +] @punctuation.bracket + +; Comments +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/git_config/injections.scm b/pack/ant/start/nvim-treesitter/queries/git_config/injections.scm new file mode 100644 index 0000000..7bda697 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/git_config/injections.scm @@ -0,0 +1,69 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((variable + (name) @_name + value: (string) @injection.content) + (#any-of? @_name "cmd" "command" "textconv" "sendmailCmd") + (#set! injection.language "bash")) + +(section + (variable + (name) @_name + value: (string) @injection.content) + (#eq? @_name "tool") + (#set! injection.language "bash")) + +(section + (section_header + (section_name) @_pager) + (variable + value: (string) @injection.content) + (#eq? @_pager "pager") + (#set! injection.language "bash")) + +(section + (section_header + (section_name) @_interactive) + (variable + (name) @_name + value: (string) @injection.content) + (#eq? @_interactive "interactive") + (#eq? @_name "diffFilter") + (#set! injection.language "bash")) + +; https://github.com/git-lfs/git-lfs +; git lfs install +(section + (section_header + (section_name) @_filter + (subsection_name) @_lfs) + (variable + (name) @_name + value: (string) @injection.content) + (#eq? @_filter "filter") + (#eq? @_lfs "lfs") + (#any-of? @_name "smudge" "process" "clean") + (#set! injection.language "bash")) + +(section + (section_header + (section_name) @_alias) + (variable + value: (string) @injection.content) + (#eq? @_alias "alias") + (#lua-match? @injection.content "^!") + (#offset! @injection.content 0 1 0 0) + (#set! injection.language "bash")) + +(section + (section_header + (section_name) @_alias) + (variable + value: (string + "\"" + "\"") @injection.content) + (#eq? @_alias "alias") + (#lua-match? @injection.content "^\"!") + (#offset! @injection.content 0 2 0 -1) + (#set! injection.language "bash")) diff --git a/pack/ant/start/nvim-treesitter/queries/git_rebase/highlights.scm b/pack/ant/start/nvim-treesitter/queries/git_rebase/highlights.scm new file mode 100644 index 0000000..248366e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/git_rebase/highlights.scm @@ -0,0 +1,7 @@ +((command) @keyword + (label)? @constant + (message)? @none @spell) + +(option) @operator + +(comment) @comment diff --git a/pack/ant/start/nvim-treesitter/queries/git_rebase/injections.scm b/pack/ant/start/nvim-treesitter/queries/git_rebase/injections.scm new file mode 100644 index 0000000..c831594 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/git_rebase/injections.scm @@ -0,0 +1,8 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((operation + (command) @_command + (message) @injection.content) + (#set! injection.language "bash") + (#any-of? @_command "exec" "x")) diff --git a/pack/ant/start/nvim-treesitter/queries/gitattributes/highlights.scm b/pack/ant/start/nvim-treesitter/queries/gitattributes/highlights.scm new file mode 100644 index 0000000..aec7750 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gitattributes/highlights.scm @@ -0,0 +1,55 @@ +(dir_sep) @punctuation.delimiter + +(quoted_pattern + "\"" @punctuation.special) + +(range_notation) @string.special + +(range_notation + [ + "[" + "]" + ] @punctuation.bracket) + +(wildcard) @character.special + +(range_negation) @operator + +(character_class) @constant + +(class_range + "-" @operator) + +[ + (ansi_c_escape) + (escaped_char) +] @string.escape + +(attribute + (attr_name) @variable.parameter) + +(attribute + (builtin_attr) @variable.builtin) + +[ + (attr_reset) + (attr_unset) + (attr_set) +] @operator + +(boolean_value) @boolean + +(string_value) @string + +(macro_tag) @keyword.directive + +(macro_def + macro_name: (_) @property) + +; we do not lint syntax errors +; [ +; (pattern_negation) +; (redundant_escape) +; (trailing_slash) +; ] @error +(comment) @comment @spell diff --git a/pack/ant/start/nvim-treesitter/queries/gitattributes/injections.scm b/pack/ant/start/nvim-treesitter/queries/gitattributes/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gitattributes/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/gitattributes/locals.scm b/pack/ant/start/nvim-treesitter/queries/gitattributes/locals.scm new file mode 100644 index 0000000..2471b8b --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gitattributes/locals.scm @@ -0,0 +1,8 @@ +(macro_def + (attr_name) @local.definition.macro) + +(attribute + (attr_name) @local.reference) + +(attribute + (builtin_attr) @local.reference) diff --git a/pack/ant/start/nvim-treesitter/queries/gitcommit/highlights.scm b/pack/ant/start/nvim-treesitter/queries/gitcommit/highlights.scm new file mode 100644 index 0000000..b096056 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gitcommit/highlights.scm @@ -0,0 +1,49 @@ +(comment) @comment + +(generated_comment) @comment + +(title) @markup.heading + +; (text) @none +(branch) @markup.link + +(change) @keyword + +(filepath) @string.special.path + +(arrow) @punctuation.delimiter + +(subject) @markup.heading @spell + +(subject + (subject_prefix) @function @nospell) + +(prefix + (type) @keyword @nospell) + +(prefix + (scope) @variable.parameter @nospell) + +(prefix + [ + "(" + ")" + ":" + ] @punctuation.delimiter) + +(prefix + "!" @punctuation.special) + +(message) @spell + +(trailer + (token) @label) + +; (trailer (value) @none) +(breaking_change + (token) @comment.error) + +(breaking_change + (value) @none @spell) + +(scissor) @comment diff --git a/pack/ant/start/nvim-treesitter/queries/gitcommit/injections.scm b/pack/ant/start/nvim-treesitter/queries/gitcommit/injections.scm new file mode 100644 index 0000000..5613d7e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gitcommit/injections.scm @@ -0,0 +1,5 @@ +((diff) @injection.content + (#set! injection.language "diff")) + +((rebase_command) @injection.content + (#set! injection.language "git_rebase")) diff --git a/pack/ant/start/nvim-treesitter/queries/gitignore/highlights.scm b/pack/ant/start/nvim-treesitter/queries/gitignore/highlights.scm new file mode 100644 index 0000000..aafbe54 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gitignore/highlights.scm @@ -0,0 +1,36 @@ +(comment) @comment @spell + +(pattern_char) @string.special.path + +[ + (directory_separator) + (directory_separator_escaped) +] @punctuation.delimiter + +[ + (wildcard_char_single) + (wildcard_chars) + (wildcard_chars_allow_slash) +] @character.special + +[ + (pattern_char_escaped) + (bracket_char_escaped) +] @string.escape + +(negation) @punctuation.special + +(bracket_negation) @operator + +; bracket expressions +[ + "[" + "]" +] @punctuation.bracket + +(bracket_char) @constant + +(bracket_range + "-" @operator) + +(bracket_char_class) @constant.builtin diff --git a/pack/ant/start/nvim-treesitter/queries/gitignore/injections.scm b/pack/ant/start/nvim-treesitter/queries/gitignore/injections.scm new file mode 100644 index 0000000..2f0e58e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gitignore/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/gleam/folds.scm b/pack/ant/start/nvim-treesitter/queries/gleam/folds.scm new file mode 100644 index 0000000..b4cd225 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gleam/folds.scm @@ -0,0 +1,7 @@ +; Folds +[ + (case) + (function) + (anonymous_function) + (type_definition) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/gleam/highlights.scm b/pack/ant/start/nvim-treesitter/queries/gleam/highlights.scm new file mode 100644 index 0000000..5238c60 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gleam/highlights.scm @@ -0,0 +1,199 @@ +; Keywords +[ + "as" + "let" + "panic" + "todo" + "use" +] @keyword + +"type" @keyword.type + +; Function Keywords +"fn" @keyword.function + +; Imports +"import" @keyword.import + +; Conditionals +[ + "case" + "if" +] @keyword.conditional + +; Exceptions +"assert" @keyword.exception + +; Punctuation +[ + "(" + ")" + "<<" + ">>" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +[ + "," + "." + ":" + "->" +] @punctuation.delimiter + +"#" @punctuation.special + +; Operators +[ + "%" + "&&" + "*" + "*." + "+" + "+." + "-" + "-." + ".." + "/" + "/." + "<" + "<." + "<=" + "<=." + "=" + "==" + ">" + ">." + ">=" + ">=." + "|>" + "||" +] @operator + +; Identifiers +(identifier) @variable + +; Comments +(comment) @comment @spell + +[ + (module_comment) + (statement_comment) +] @comment.documentation @spell + +; Unused Identifiers +[ + (discard) + (hole) +] @comment + +; Modules & Imports +(module) @module + +(import + alias: ((identifier) @module)?) + +(remote_type_identifier + module: (identifier) @module) + +(unqualified_import + name: (identifier) @function) + +; Strings +(string) @string + +; Bit Strings +(bit_string_segment) @string.special + +; Numbers +(integer) @number + +(float) @number.float + +; Function Parameter Labels +(function_call + arguments: (arguments + (argument + label: (label) @label))) + +(function_parameter + label: (label)? @label + name: (identifier) @variable.parameter) + +; Records +(record + arguments: (arguments + (argument + label: (label) @variable.member)?)) + +(record_pattern_argument + label: (label) @variable.member) + +(record_update_argument + label: (label) @variable.member) + +(field_access + record: (identifier) @variable + field: (label) @variable.member) + +(data_constructor_argument + (label) @variable.member) + +; Types +[ + (type_identifier) + (type_parameter) + (type_var) +] @type + +; Type Qualifiers +[ + "const" + "external" + (opacity_modifier) + (visibility_modifier) +] @keyword.modifier + +; Tuples +(tuple_access + index: (integer) @operator) + +; Functions +(function + name: (identifier) @function) + +(function_call + function: (identifier) @function.call) + +(function_call + function: (field_access + field: (label) @function.call)) + +; External Functions +(external_function + name: (identifier) @function) + +(external_function_body + (string) @module + . + (string) @function) + +; Constructors +(constructor_name) @type @constructor + +([ + (type_identifier) + (constructor_name) +] @constant.builtin + (#any-of? @constant.builtin "Ok" "Error")) + +; Booleans +((constructor_name) @boolean + (#any-of? @boolean "True" "False")) + +; Pipe Operator +(binary_expression + operator: "|>" + right: (identifier) @function) diff --git a/pack/ant/start/nvim-treesitter/queries/gleam/indents.scm b/pack/ant/start/nvim-treesitter/queries/gleam/indents.scm new file mode 100644 index 0000000..c798545 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gleam/indents.scm @@ -0,0 +1,30 @@ +; Gleam indents similar to Rust and JavaScript +[ + (anonymous_function) + (assert) + (case) + (case_clause) + (constant) + (external_function) + (function) + (import) + (let) + (list) + (constant) + (function) + (type_definition) + (type_alias) + (todo) + (tuple) +] @indent.begin + +[ + ")" + "]" + "}" +] @indent.end @indent.branch + +; Gleam pipelines are not indented, but other binary expression chains are +((binary_expression + operator: _ @_operator) @indent.begin + (#not-eq? @_operator "|>")) diff --git a/pack/ant/start/nvim-treesitter/queries/gleam/injections.scm b/pack/ant/start/nvim-treesitter/queries/gleam/injections.scm new file mode 100644 index 0000000..11d4f5d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gleam/injections.scm @@ -0,0 +1,7 @@ +; Comments +([ + (module_comment) + (statement_comment) + (comment) +] @injection.content + (#set! injection.language "comment")) diff --git a/pack/ant/start/nvim-treesitter/queries/gleam/locals.scm b/pack/ant/start/nvim-treesitter/queries/gleam/locals.scm new file mode 100644 index 0000000..39909a4 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/gleam/locals.scm @@ -0,0 +1,34 @@ +; Let Binding Definition +(let + pattern: (identifier) @local.definition) + +; List Pattern Definitions +(list_pattern + (identifier) @local.definition) + +(list_pattern + assign: (identifier) @local.definition) + +; Tuple Pattern Definition +(tuple_pattern + (identifier) @local.definition) + +; Record Pattern Definition +(record_pattern_argument + pattern: (identifier) @local.definition) + +; Function Parameter Definition +(function_parameter + name: (identifier) @local.definition) + +; References +(identifier) @local.reference + +; Block Scope +(block) @local.scope + +; Function Body Scope +(function_body) @local.scope + +; Case Scope +(case_clause) @local.scope diff --git a/pack/ant/start/nvim-treesitter/queries/glimmer/folds.scm b/pack/ant/start/nvim-treesitter/queries/glimmer/folds.scm new file mode 100644 index 0000000..6502455 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/glimmer/folds.scm @@ -0,0 +1,5 @@ +[ + (element_node + (element_node_start)) + (block_statement) +] @fold diff --git a/pack/ant/start/nvim-treesitter/queries/glimmer/highlights.scm b/pack/ant/start/nvim-treesitter/queries/glimmer/highlights.scm new file mode 100644 index 0000000..9f11468 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/glimmer/highlights.scm @@ -0,0 +1,117 @@ +; === Tag Names === +; Tags that start with a lower case letter are HTML tags +; We'll also use this highlighting for named blocks (which start with `:`) +((tag_name) @tag + (#lua-match? @tag "^:?[%l]")) + +; Tags that start with a capital letter are Glimmer components +((tag_name) @constructor + (#lua-match? @constructor "^%u")) + +(attribute_name) @attribute + +(string_literal) @string + +(number_literal) @number + +(boolean_literal) @boolean + +(concat_statement) @string + +; === Block Statements === +; Highlight the brackets +(block_statement_start) @tag.delimiter + +(block_statement_end) @tag.delimiter + +; Highlight `if`/`each`/`let` +(block_statement_start + path: (identifier) @keyword.conditional) + +(block_statement_end + path: (identifier) @keyword.conditional) + +((mustache_statement + (identifier) @keyword.conditional) + (#lua-match? @keyword.conditional "else")) + +; == Mustache Statements === +; Highlight the whole statement, to color brackets and separators +(mustache_statement) @tag.delimiter + +; An identifier in a mustache expression is a variable +((mustache_statement + [ + (path_expression + (identifier) @variable) + (identifier) @variable + ]) + (#not-any-of? @variable "yield" "outlet" "this" "else")) + +; As are arguments in a block statement +(block_statement_start + argument: [ + (path_expression + (identifier) @variable) + (identifier) @variable + ]) + +; As is an identifier in a block param +(block_params + (identifier) @variable) + +; As are helper arguments +((helper_invocation + argument: [ + (path_expression + (identifier) @variable) + (identifier) @variable + ]) + (#not-eq? @variable "this")) + +; `this` should be highlighted as a built-in variable +((identifier) @variable.builtin + (#eq? @variable.builtin "this")) + +; If the identifier is just "yield" or "outlet", it's a keyword +((mustache_statement + (identifier) @keyword) + (#any-of? @keyword "yield" "outlet")) + +; Helpers are functions +((helper_invocation + helper: [ + (path_expression + (identifier) @function) + (identifier) @function + ]) + (#not-any-of? @function "if" "yield")) + +((helper_invocation + helper: (identifier) @keyword.conditional) + (#eq? @keyword.conditional "if")) + +((helper_invocation + helper: (identifier) @keyword) + (#eq? @keyword "yield")) + +(hash_pair + key: (identifier) @property) + +(comment_statement) @comment @spell + +(attribute_node + "=" @operator) + +(block_params + "as" @keyword) + +(block_params + "|" @operator) + +[ + "<" + ">" + "" +] @tag.delimiter diff --git a/pack/ant/start/nvim-treesitter/queries/glimmer/indents.scm b/pack/ant/start/nvim-treesitter/queries/glimmer/indents.scm new file mode 100644 index 0000000..c1ef130 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/queries/glimmer/indents.scm @@ -0,0 +1,34 @@ +[ + (element_node + (element_node_start)) + (element_node_void) + (block_statement + (block_statement_start)) + (mustache_statement) +] @indent.begin + +(element_node + (element_node_end + ">" @indent.end)) + +(element_node_void + "/>" @indent.end) + +[ + ">" + "/>" + " tags +((element_node + (element_node_start + (tag_name) @_tag_name + (#eq? @_tag_name "style"))) @injection.content + (#offset! @injection.content 0 7 0 -8) + (#set! injection.language "css") + (#set! injection.include-children)) + +; + diff --git a/pack/ant/start/nvim-treesitter/tests/indent/html/self_closing_tag.html b/pack/ant/start/nvim-treesitter/tests/indent/html/self_closing_tag.html new file mode 100644 index 0000000..79376b8 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/html/self_closing_tag.html @@ -0,0 +1,14 @@ + + + + + + + + + +
+ + + + {switch state { + | Active => + switch ReactDOM.querySelector("body") { + | Some(element) => + ReactDOM.createPortal( + scrollY} + transformItems={transformItems} + hitComponent=hit + /> + element, + ) + | None => React.null + } + | Inactive => React.null + }} + +} + +let comparable = (type key, ~cmp) => { + module N = MakeComparable({ + type t = key + let cmp = cmp + }) + module(N: Comparable with type t = key) +} + + + + {description->React.string} + children + diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rescript/conditional.res b/pack/ant/start/nvim-treesitter/tests/indent/rescript/conditional.res new file mode 100644 index 0000000..db8328f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rescript/conditional.res @@ -0,0 +1,104 @@ +include UseClient +include UseQuery +include UseMutation +include UseSubscription + +type hookResponse<'ret> = Types.Hooks.hookResponse<'ret> = { + operation: Types.operation, + fetching: bool, + data: option<'ret>, + error: option, + response: Types.Hooks.response<'ret>, + extensions: option, + stale: bool, +} + +Js.Array2.slice(~start=0, ~end_=Js.Array2.length(moduleRoute) - 1) + +let pathModule = Path.join([dir, version, `${moduleName}.json`]) + +let {Api.LocMsg.row: row, column, shortMsg} = locMsg + +let message = `${"error"->red}: failed to compile examples from ${kind} ${test.id->cyan}\n${errorMessage}` + +let version = (evt->ReactEvent.Form.target)["value"] + +let rehypePlugins = + [Rehype.WithOptions([Plugin(Rehype.slug), SlugOption({prefix: slugPrefix ++ "-"})])]->Some + +module Item = { + type t = { + name: string, + sellIn: int, + quality: int, + } + + let make = (~name, ~sellIn, ~quality): t => { + name, + sellIn, + quality, + } +} + +let updateQuality = (items: array) => { + items->Js.Array2.map(item => { + let newItem = ref(item) + + call( + asdf, + asdf + ) + + if ( + newItem.contents.name != "Aged Brie" && 5 > 2 && + newItem.contents.name != "Backstage passes to a TAFKAL80ETC concert" + ) { + if newItem.contents.quality > 0 { + if newItem.contents.name != "Sulfuras, Hand of Ragnaros" { + newItem := {...newItem.contents, quality: newItem.contents.quality - 1} + } + } + } else if newItem.contents.quality < 50 { + newItem := {...newItem.contents, quality: newItem.contents.quality + 1} + + if newItem.contents.name == "Backstage passes to a TAFKAL80ETC concert" { + if newItem.contents.sellIn < 11 { + if newItem.contents.quality < 50 { + newItem := {...newItem.contents, quality: newItem.contents.quality + 1} + } + } + + if newItem.contents.sellIn < 6 { + if newItem.contents.quality < 50 { + newItem := {...newItem.contents, quality: newItem.contents.quality + 1} + } + } + } + } + + if newItem.contents.name != "Sulfuras, Hand of Ragnaros" { + newItem := {...newItem.contents, sellIn: newItem.contents.sellIn - 1} + } + + if newItem.contents.sellIn < 0 { + if newItem.contents.name != "Aged Brie" { + if newItem.contents.name != "Backstage passes to a TAFKAL80ETC concert" { + if newItem.contents.quality > 0 { + if newItem.contents.name != "Sulfuras, Hand of Ragnaros" { + newItem := {...newItem.contents, quality: newItem.contents.quality - 1} + } + } + } else { + newItem := { + ...newItem.contents, + quality: newItem.contents.quality - newItem.contents.quality, + } + } + } else if newItem.contents.quality < 50 { + newItem := {...newItem.contents, quality: newItem.contents.quality + 1} + } + } + + newItem.contents + }) +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rescript_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/rescript_spec.lua new file mode 100644 index 0000000..5b1f06a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rescript_spec.lua @@ -0,0 +1,33 @@ +local Runner = require("tests.indent.common").Runner + +local run = Runner:new(it, "tests/indent/rescript", { + tabstop = 2, + shiftwidth = 2, + softtabstop = 0, + expandtab = true, +}) + +describe("indent ReScript:", function() + describe("whole file:", function() + run:whole_file(".", {}) + end) + + describe("new line:", function() + run:new_line("basic.res", { on_line = 5, text = "x", indent = 0 }) + run:new_line("basic.res", { on_line = 9, text = '"another": here,', indent = 2 }) + run:new_line("basic.res", { on_line = 10, text = "}", indent = 0 }) + run:new_line("basic.res", { on_line = 14, text = "~test: test,", indent = 2 }) + run:new_line("basic.res", { on_line = 18, text = "x", indent = 0 }) + + run:new_line("complex.res", { on_line = 3, text = "x", indent = 2 }) + run:new_line("complex.res", { on_line = 5, text = "x", indent = 4 }) + run:new_line("complex.res", { on_line = 17, text = "|", indent = 10 }) + run:new_line("complex.res", { on_line = 25, text = "x", indent = 2 }) + run:new_line("complex.res", { on_line = 60, text = "x", indent = 6 }) + run:new_line("complex.res", { on_line = 120, text = "x", indent = 14 }) + run:new_line("complex.res", { on_line = 136, text = "x", indent = 2 }) + + run:new_line("conditional.res", { on_line = 6, text = "test: bool,", indent = 2 }) + run:new_line("conditional.res", { on_line = 95, text = "x", indent = 10 }) + end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-assignment.rb b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-assignment.rb new file mode 100644 index 0000000..d0ae21e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-assignment.rb @@ -0,0 +1,2 @@ +ret = + 2 diff --git a/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-brackets.rb b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-brackets.rb new file mode 100644 index 0000000..ba16536 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-brackets.rb @@ -0,0 +1,5 @@ +def indent_brackets + { + {} + } +end diff --git a/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-ensure.rb b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-ensure.rb new file mode 100644 index 0000000..fce2779 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-ensure.rb @@ -0,0 +1,2 @@ +begin +end diff --git a/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-parens.rb b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-parens.rb new file mode 100644 index 0000000..821743e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-parens.rb @@ -0,0 +1,5 @@ +def indent_parens + ( + () + ) +end diff --git a/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-parenthesized-statements.rb b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-parenthesized-statements.rb new file mode 100644 index 0000000..72873dd --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-parenthesized-statements.rb @@ -0,0 +1,2 @@ +( +) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-rescue.rb b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-rescue.rb new file mode 100644 index 0000000..fce2779 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-rescue.rb @@ -0,0 +1,2 @@ +begin +end diff --git a/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-square-brackets.rb b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-square-brackets.rb new file mode 100644 index 0000000..8746d22 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-square-brackets.rb @@ -0,0 +1,5 @@ +def indent_square_brackets + [ + [] + ] +end diff --git a/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-unless.rb b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-unless.rb new file mode 100644 index 0000000..50bc2b4 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/ruby/indent-unless.rb @@ -0,0 +1,2 @@ +unless true +end diff --git a/pack/ant/start/nvim-treesitter/tests/indent/ruby/period-issue-3364.rb b/pack/ant/start/nvim-treesitter/tests/indent/ruby/period-issue-3364.rb new file mode 100644 index 0000000..6582750 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/ruby/period-issue-3364.rb @@ -0,0 +1,7 @@ +class User < ApplicationRecord + def foo + if true + self. + end + end +end diff --git a/pack/ant/start/nvim-treesitter/tests/indent/ruby_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/ruby_spec.lua new file mode 100644 index 0000000..b669b89 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/ruby_spec.lua @@ -0,0 +1,22 @@ +local Runner = require("tests.indent.common").Runner + +local run = Runner:new(it, "tests/indent/ruby", { + shiftwidth = 2, + expandtab = true, +}) + +describe("indent Ruby:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = { "./period-issue-3364.rb" }, + }) + end) + + describe("new line:", function() + run:new_line("indent-unless.rb", { on_line = 1, text = "stmt", indent = 2 }) + run:new_line("indent-assignment.rb", { on_line = 1, text = "1 +", indent = 2 }) + run:new_line("indent-parenthesized-statements.rb", { on_line = 1, text = "stmt", indent = 2 }) + run:new_line("indent-rescue.rb", { on_line = 1, text = "rescue", indent = 0 }) + run:new_line("indent-ensure.rb", { on_line = 1, text = "ensure", indent = 0 }) + end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/array.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/array.rs new file mode 100644 index 0000000..68344e0 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/array.rs @@ -0,0 +1,11 @@ +const X: [i32; 2] = [ + 1, + 2, +]; + +fn foo() { + let _x = [ + 1, + 2, + ]; +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/comment.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/comment.rs new file mode 100644 index 0000000..8f59213 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/comment.rs @@ -0,0 +1,13 @@ +/// Function foo +/// +/// Description of +/// function foo. +fn foo(x: i32, y: i32) -> i32 { + x + y +} + +impl A { + /// Do some stuff!! (put cursor here and press enter) + fn a(); +} + diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/cond.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/cond.rs new file mode 100644 index 0000000..eb96a48 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/cond.rs @@ -0,0 +1,17 @@ +fn foo(mut x: i32) -> i32 { + if x > 10 { + return 10; + } else if x == 10 { + return 9; + } else { + x += 10; + } + + if x < 0 { + if x == -1 { + return 0; + } + } + + 0 +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/enum.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/enum.rs new file mode 100644 index 0000000..996f07d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/enum.rs @@ -0,0 +1,11 @@ +enum Foo { + X, + Y( + char, + char, + ), + Z { + x: u32, + y: u32, + }, +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/func.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/func.rs new file mode 100644 index 0000000..4c9d40b --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/func.rs @@ -0,0 +1,10 @@ +fn foo() -> i32 { + 1 +} + +fn foo( + x: i32, + y: i32 +) -> i32 { + x + y +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/if_let_cond.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/if_let_cond.rs new file mode 100644 index 0000000..0d6e2ef --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/if_let_cond.rs @@ -0,0 +1,7 @@ +fn foo() -> i32 { + if let Some(v) = Some(2) { + 1 + } else { + 2 + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/impl.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/impl.rs new file mode 100644 index 0000000..2525c2e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/impl.rs @@ -0,0 +1,7 @@ +struct Foo; + +impl Foo { + fn foo() -> i32 { + 1 + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/loop.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/loop.rs new file mode 100644 index 0000000..eb845bc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/loop.rs @@ -0,0 +1,19 @@ +fn foo(mut x: i32) { + while x > 0 { + x -= 1; + } + + for i in 0..3 { + x += 1; + } + + loop { + x += 1; + + if x < 100 { + continue; + } + + break; + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/macro.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/macro.rs new file mode 100644 index 0000000..e42cf13 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/macro.rs @@ -0,0 +1,13 @@ +macro_rules! foo { + ($a:ident, $b:ident, $c:ident) => { + struct a { value: $a }; + struct b { value: $b }; + }; + ($a:ident) => { + struct a { value: $a }; + }; +} + +foo! { + A +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/match.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/match.rs new file mode 100644 index 0000000..438ba6d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/match.rs @@ -0,0 +1,11 @@ +fn foo(x: i32) -> i32 { + match x { + 0 => 1, + 1 => { + 2 + }, + 2 | 3 => { + 4 + } + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/mod.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/mod.rs new file mode 100644 index 0000000..cc7f2c8 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/mod.rs @@ -0,0 +1,8 @@ +mod foo { + const X: i32 = 1; + + mod bar { + + const Y: i32 = 1; + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/string.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/string.rs new file mode 100644 index 0000000..4d60663 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/string.rs @@ -0,0 +1,12 @@ +fn foo() { + let a = "hello +world"; + + let b = "hello\ + world"; + + let c = r#" + hello + world + "#; +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/struct.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/struct.rs new file mode 100644 index 0000000..f382897 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/struct.rs @@ -0,0 +1,4 @@ +struct Foo { + x: u32, + y: u32, +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/trait.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/trait.rs new file mode 100644 index 0000000..fb5fc7e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/trait.rs @@ -0,0 +1,11 @@ +struct Foo; + +trait Bar { + fn bar(); +} + +impl Bar for Foo { + fn bar() { + + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/tuple.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/tuple.rs new file mode 100644 index 0000000..9001f77 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/tuple.rs @@ -0,0 +1,8 @@ +fn foo() { + for ( + a, + b + ) in c.iter() { + // ... + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust/where.rs b/pack/ant/start/nvim-treesitter/tests/indent/rust/where.rs new file mode 100644 index 0000000..08c1b19 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust/where.rs @@ -0,0 +1,21 @@ +fn foo(t: T) -> i32 +where + T: Debug, +{ + 1 +} + +fn foo(t: T) -> i32 where + T: Debug, +{ + 1 +} + +struct Foo(T); + +impl Write for Foo +where + T: Debug, +{ + +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/rust_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/rust_spec.lua new file mode 100644 index 0000000..795765b --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/rust_spec.lua @@ -0,0 +1,66 @@ +local Runner = require("tests.indent.common").Runner + +local run = Runner:new(it, "tests/indent/rust", { + tabstop = 4, + shiftwidth = 4, + softtabstop = 0, + expandtab = true, +}) + +describe("indent Rust:", function() + describe("whole file:", function() + run:whole_file "." + end) + + describe("new line:", function() + run:new_line("array.rs", { on_line = 2, text = "0,", indent = 4 }) + run:new_line("array.rs", { on_line = 8, text = "0,", indent = 8 }) + run:new_line("comment.rs", { on_line = 3, text = "a", indent = "/// " }) + run:new_line("comment.rs", { on_line = 10, text = "a", indent = " /// " }) + run:new_line("cond.rs", { on_line = 11, text = "x += 1;", indent = 12 }) + run:new_line("cond.rs", { on_line = 2, text = "x += 1;", indent = 8 }) + run:new_line("cond.rs", { on_line = 4, text = "x += 1;", indent = 8 }) + run:new_line("cond.rs", { on_line = 6, text = "x += 1;", indent = 8 }) + run:new_line("cond.rs", { on_line = 8, text = "x += 1;", indent = 4 }) + run:new_line("if_let_cond.rs", { on_line = 2, text = "let a = 1;", indent = 8 }) + run:new_line("if_let_cond.rs", { on_line = 4, text = "let a = 1;", indent = 8 }) + run:new_line("if_let_cond.rs", { on_line = 6, text = "let a = 1;", indent = 4 }) + run:new_line("enum.rs", { on_line = 2, text = "Q,", indent = 4 }) + run:new_line("enum.rs", { on_line = 4, text = "i32,", indent = 8 }) + run:new_line("enum.rs", { on_line = 8, text = "z: u32,", indent = 8 }) + run:new_line("enum.rs", { on_line = 11, text = "let _x = 1;", indent = 0 }) + run:new_line("func.rs", { on_line = 1, text = "let _x = 1;", indent = 4 }) + run:new_line("func.rs", { on_line = 3, text = "let _x = 1;", indent = 0 }) + run:new_line("func.rs", { on_line = 6, text = "z: i32,", indent = 4 }) + run:new_line("impl.rs", { on_line = 3, text = "const FOO: u32 = 1;", indent = 4 }) + run:new_line("impl.rs", { on_line = 4, text = "let _x = 1;", indent = 8 }) + run:new_line("impl.rs", { on_line = 6, text = "let _x = 1;", indent = 4 }) + run:new_line("impl.rs", { on_line = 7, text = "let _x = 1;", indent = 0 }) + run:new_line("loop.rs", { on_line = 10, text = "x += 1;", indent = 8 }) + run:new_line("loop.rs", { on_line = 2, text = "x += 1;", indent = 8 }) + run:new_line("loop.rs", { on_line = 6, text = "x += 1;", indent = 8 }) + run:new_line("macro.rs", { on_line = 1, text = "() => {},", indent = 4 }) + run:new_line("macro.rs", { on_line = 12, text = "B C", indent = 4 }) + run:new_line("macro.rs", { on_line = 2, text = "struct $c;", indent = 8 }) + run:new_line("match.rs", { on_line = 2, text = "-1 => -1,", indent = 8 }) + run:new_line("match.rs", { on_line = 7, text = "let y = 1;", indent = 12 }) + run:new_line("match.rs", { on_line = 10, text = "let y = 1;", indent = 4 }) + run:new_line("mod.rs", { on_line = 1, text = "const Z: i32 = 1;", indent = 4 }) + run:new_line("mod.rs", { on_line = 2, text = "const Z: i32 = 1;", indent = 4 }) + run:new_line("mod.rs", { on_line = 6, text = "const Z: i32 = 1;", indent = 8 }) + run:new_line("mod.rs", { on_line = 7, text = "const Z: i32 = 1;", indent = 4 }) + run:new_line("string.rs", { on_line = 2, text = "brave new", indent = 0 }) + run:new_line("string.rs", { on_line = 5, text = "brave new \\", indent = 8 }) + run:new_line("string.rs", { on_line = 9, text = "brave new \\", indent = 8 }) + run:new_line("struct.rs", { on_line = 1, text = "z: i32,", indent = 4 }) + run:new_line("struct.rs", { on_line = 2, text = "z: i32,", indent = 4 }) + run:new_line("struct.rs", { on_line = 4, text = "let y = 1;", indent = 0 }) + run:new_line("trait.rs", { on_line = 4, text = "fn baz();", indent = 4 }) + run:new_line("trait.rs", { on_line = 5, text = "let y = 1;", indent = 0 }) + run:new_line("trait.rs", { on_line = 7, text = "fn baz();", indent = 4 }) + run:new_line("trait.rs", { on_line = 8, text = "()", indent = 8 }) + run:new_line("where.rs", { on_line = 17, text = "T: Debug,", indent = 4 }) + run:new_line("where.rs", { on_line = 2, text = "T: Debug,", indent = 4 }) + run:new_line("where.rs", { on_line = 9, text = "T: Debug,", indent = 4 }) + end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/smali/array_and_switch.smali b/pack/ant/start/nvim-treesitter/tests/indent/smali/array_and_switch.smali new file mode 100644 index 0000000..3ee3f6d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/smali/array_and_switch.smali @@ -0,0 +1,58 @@ +.class public Lbaksmali/test/class; +.super Ljava/lang/Object; + +.source "baksmali_test_class.smali" + +.method public testMethod(ILjava/lang/String;)Ljava/lang/String; + .registers 3 + .annotation runtime Lorg/junit/Test; + .end annotation + .annotation system Lyet/another/annotation; + somevalue = 1234 + anothervalue = 3.14159 + .end annotation + + const-string v0, "testing\n123" + + goto switch: + + sget v0, Lbaksmali/test/class;->staticField:I + + switch: + packed-switch v0, pswitch: + + try_start: + const/4 v0, 7 + const v0, 10 + nop + try_end: + .catch Ljava/lang/Exception; {try_start: .. try_end:} handler: + .catchall {try_start: .. try_end:} handler2: + + handler: + + Label10: + Label11: + Label12: + Label13: + return-object v0 + + + + .array-data 4 + 1 2 3 4 5 6 200 + .end array-data + + pswitch: + .packed-switch 10 + Label10: + Label11: + Label12: + Label13: + .end packed-switch + + handler2: + + return-void + +.end method diff --git a/pack/ant/start/nvim-treesitter/tests/indent/smali/field.smali b/pack/ant/start/nvim-treesitter/tests/indent/smali/field.smali new file mode 100644 index 0000000..ae48b7b --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/smali/field.smali @@ -0,0 +1,12 @@ +.class public Lbaksmali/test/class; +.super Ljava/lang/Object; + +.source "baksmali_test_class.smali" + +.field public static annotationStaticField:Lsome/annotation; = .subannotation Lsome/annotation; + value1 = "test" + value2 = .subannotation Lsome/annotation; + value1 = "test2" + value2 = Lsome/enum; + .end subannotation +.end subannotation diff --git a/pack/ant/start/nvim-treesitter/tests/indent/smali/method.smali b/pack/ant/start/nvim-treesitter/tests/indent/smali/method.smali new file mode 100644 index 0000000..2c139b0 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/smali/method.smali @@ -0,0 +1,8 @@ +.class public Lbaksmali/test/class; +.super Ljava/lang/Object; + +.source "baksmali_test_class.smali" + +.method public debugTest(IIIII)V + .registers 10 +.end method diff --git a/pack/ant/start/nvim-treesitter/tests/indent/smali/parameter.smali b/pack/ant/start/nvim-treesitter/tests/indent/smali/parameter.smali new file mode 100644 index 0000000..2e54da2 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/smali/parameter.smali @@ -0,0 +1,55 @@ +.class public Lbaksmali/test/class; +.super Ljava/lang/Object; + +.source "baksmali_test_class.smali" + +.method public debugTest(IIIII)V + .registers 10 + + .parameter "Blah" + .parameter + .parameter "BlahWithAnnotations" + .annotation runtime Lsome/annotation; + something = "some value" + somethingelse = 1234 + .end annotation + .annotation runtime La/second/annotation; + .end annotation + .end parameter + .parameter + .annotation runtime Lsome/annotation; + something = "some value" + somethingelse = 1234 + .end annotation + .end parameter + .parameter "LastParam" + + .prologue + + nop + nop + + .source "somefile.java" + .line 101 + + nop + + + .line 50 + + .local v0, aNumber:I + const v0, 1234 + .end local v0 + + .source "someotherfile.java" + .line 900 + + const-string v0, "1234" + + .restart local v0 + const v0, 6789 + .end local v0 + + .epilogue + +.end method diff --git a/pack/ant/start/nvim-treesitter/tests/indent/smali_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/smali_spec.lua new file mode 100644 index 0000000..cddc4f9 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/smali_spec.lua @@ -0,0 +1,25 @@ +local Runner = require("tests.indent.common").Runner + +local run = Runner:new(it, "tests/indent/smali", { + tabstop = 4, + shiftwidth = 4, + expandtab = false, +}) + +describe("indent Smali:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new line:", function() + run:new_line("field.smali", { on_line = 7, text = 'value1 = "test"', indent = 1 }) + run:new_line("field.smali", { on_line = 10, text = "value2 = Lsome/enum;", indent = 2 }) + run:new_line("array_and_switch.smali", { on_line = 43, text = "1 2 3 4 5 6 200", indent = 2 }) + run:new_line("array_and_switch.smali", { on_line = 48, text = "Label10:", indent = 2 }) + run:new_line("method.smali", { on_line = 7, text = ".registers 10", indent = 1 }) + run:new_line("parameter.smali", { on_line = 20, text = ".annotation runtime Lsome/annotation;", indent = 3 }) + run:new_line("parameter.smali", { on_line = 21, text = 'something = "some value"', indent = 3 }) + end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/sql/case.sql b/pack/ant/start/nvim-treesitter/tests/indent/sql/case.sql new file mode 100644 index 0000000..eee85a3 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/sql/case.sql @@ -0,0 +1,8 @@ +select + case + when a = 1 then '1' + when a = 2 then '2' + when a = 3 then '3' + else '0' + end as stmt1 +from tab; diff --git a/pack/ant/start/nvim-treesitter/tests/indent/sql/compound.sql b/pack/ant/start/nvim-treesitter/tests/indent/sql/compound.sql new file mode 100644 index 0000000..e645c6e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/sql/compound.sql @@ -0,0 +1,3 @@ +begin + create table foo (bar int); +end; diff --git a/pack/ant/start/nvim-treesitter/tests/indent/sql/create.sql b/pack/ant/start/nvim-treesitter/tests/indent/sql/create.sql new file mode 100644 index 0000000..9773884 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/sql/create.sql @@ -0,0 +1,4 @@ +create table my_table ( + id bigint, + date date +); diff --git a/pack/ant/start/nvim-treesitter/tests/indent/sql/cte.sql b/pack/ant/start/nvim-treesitter/tests/indent/sql/cte.sql new file mode 100644 index 0000000..55426cc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/sql/cte.sql @@ -0,0 +1,7 @@ +with data as ( + select + a, + b + from tab +) +select * from data; diff --git a/pack/ant/start/nvim-treesitter/tests/indent/sql/insert.sql b/pack/ant/start/nvim-treesitter/tests/indent/sql/insert.sql new file mode 100644 index 0000000..36fa7c0 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/sql/insert.sql @@ -0,0 +1,5 @@ +insert into mytable + (column1, column2) +values + ('john', 123), + ('jane', 124); diff --git a/pack/ant/start/nvim-treesitter/tests/indent/sql/select.sql b/pack/ant/start/nvim-treesitter/tests/indent/sql/select.sql new file mode 100644 index 0000000..85f0cc5 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/sql/select.sql @@ -0,0 +1,4 @@ +select + a, + b +from tab; diff --git a/pack/ant/start/nvim-treesitter/tests/indent/sql/subquery.sql b/pack/ant/start/nvim-treesitter/tests/indent/sql/subquery.sql new file mode 100644 index 0000000..a559d7e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/sql/subquery.sql @@ -0,0 +1,9 @@ +select + id +from foo +where id < ( + select + id + from bar + limit 1 +); diff --git a/pack/ant/start/nvim-treesitter/tests/indent/sql_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/sql_spec.lua new file mode 100644 index 0000000..2fdfc9b --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/sql_spec.lua @@ -0,0 +1,19 @@ +local Runner = require("tests.indent.common").Runner +--local XFAIL = require("tests.indent.common").XFAIL + +local run = Runner:new(it, "tests/indent/sql", { + tabstop = 4, + shiftwidth = 4, + softtabstop = 0, + expandtab = true, +}) + +describe("indent SQL:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new line:", function() end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/swift/declarations.swift b/pack/ant/start/nvim-treesitter/tests/indent/swift/declarations.swift new file mode 100644 index 0000000..67a7e55 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/swift/declarations.swift @@ -0,0 +1,56 @@ +@wrapper +@modifier( + * +) +class EquilateralTriangle: NamedShape { + var sideLength: Double = 0.0 + + @attr + init( + sideLength: Double, + name: String + ) { + self.sideLength = sideLength + } + deinit { + } + + var perimeter: Double { + willSet { + } + didSet { + + } + } + + @funcattr + override func simpleDescription(a: int, b: int) -> String { + return "An equilateral triangle with sides of length \(sideLength)." + } +} + +@attr +protocol ExampleProtocol { + var simpleDescription: String { get } + mutating func adjust() +} + +@available(*) +func test() { + +} + +@attr(*) +typealias Foo = Bar + +@attr +struct Foo< + Bar +> { + @Provider + var test = 1 + + subscript(index: Int) -> Int { + var foo = 2 + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/swift/expressions.swift b/pack/ant/start/nvim-treesitter/tests/indent/swift/expressions.swift new file mode 100644 index 0000000..4f7292a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/swift/expressions.swift @@ -0,0 +1,17 @@ +func Test() { + (1 + 2) + + [ + 1, + 2, + 3, + 4, + 5 + ].split() + + let x = [ + 1: 2, + 3: 4, + ] + +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/swift/statements.swift b/pack/ant/start/nvim-treesitter/tests/indent/swift/statements.swift new file mode 100644 index 0000000..df6e46c --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/swift/statements.swift @@ -0,0 +1,34 @@ +func Test() { + if true { + return + } else if true { + return + } + + switch x { + case "1": + print("x") + default: + print("y") + @unknown default: + print("z") + } + + for a in b { + } + + while true{ + } + + repeat { + + } while (true) + + guard let name = person["name"] else { + return + } + + return ( + x + 1 + ) +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/swift_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/swift_spec.lua new file mode 100644 index 0000000..501cbfa --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/swift_spec.lua @@ -0,0 +1,22 @@ +local Runner = require("tests.indent.common").Runner + +local run = Runner:new(it, "tests/indent/swift", { + tabstop = 2, + shiftwidth = 2, + softtabstop = 2, + expandtab = true, +}) + +describe("indent Swift:", function() + describe("whole file:", function() + run:whole_file(".", {}) + end) + describe("new line:", function() + run:new_line("declarations.swift", { on_line = 6, text = "var x = 1", indent = 2 }) + run:new_line("declarations.swift", { on_line = 12, text = "var textInsideInit = true", indent = 4 }) + run:new_line("declarations.swift", { on_line = 19, text = "var textInsideWillSet = 1", indent = 6 }) + run:new_line("declarations.swift", { on_line = 22, text = "var textInsideDidSet = 1", indent = 6 }) + run:new_line("declarations.swift", { on_line = 27, text = "var textInsideOverrideFunc", indent = 4 }) + run:new_line("declarations.swift", { on_line = 33, text = "var InsideProtocol: String { get }", indent = 2 }) + end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/t32/if_block.cmm b/pack/ant/start/nvim-treesitter/tests/indent/t32/if_block.cmm new file mode 100644 index 0000000..4bda7c6 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/t32/if_block.cmm @@ -0,0 +1,49 @@ +IF &a + STOP + +IF (TRUE()) +( + BREAK +) + +IF (&b+CouNT()) +( + continue +) + +IF FOUND() + STOP +ELSE + CONTinue + +IF &c + CONTinue +ELSE IF FALSE() + Break +ELSE + stop + +IF &d +( + STOP +) +ELSE IF &e +; comment A +( + CONTINUE +) +ELSE +; comment B +( + BREAK +) + +IF &f + IF &g + stop + ELSE + IF &h + ( + continue + ) + diff --git a/pack/ant/start/nvim-treesitter/tests/indent/t32/repeat_block.cmm b/pack/ant/start/nvim-treesitter/tests/indent/t32/repeat_block.cmm new file mode 100644 index 0000000..6384183 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/t32/repeat_block.cmm @@ -0,0 +1,27 @@ +RePeaT 10. PRINT "A" + +RePeaT &a + print + +REPEAT 0xaAfF09 +( + cont +) + +RPT +( + b +) + +rpt +( + s +) +WHILE &a + +REPEAT TRUE() +; comment +( + cont +) + diff --git a/pack/ant/start/nvim-treesitter/tests/indent/t32/subroutine_block.cmm b/pack/ant/start/nvim-treesitter/tests/indent/t32/subroutine_block.cmm new file mode 100644 index 0000000..24891c6 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/t32/subroutine_block.cmm @@ -0,0 +1,23 @@ +printA: +( + PRINT "A" + RETURN +) + +sUBROUtINE printB +( + ENTRY &in + + PRINT "&in" + RETURN +) + +SUBROUTINE printC +// comment +( + PARAMETERS &a &b + + PRINT "&a"+"&b" + ENDDO +) + diff --git a/pack/ant/start/nvim-treesitter/tests/indent/t32/while_block.cmm b/pack/ant/start/nvim-treesitter/tests/indent/t32/while_block.cmm new file mode 100644 index 0000000..bfcbd45 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/t32/while_block.cmm @@ -0,0 +1,14 @@ +WHILE &a + Step + +WHILE (sYmbol.EXIT(main)) +( + Step + Break +) + +WHILE (FALSE()) +// comment +( + ECHO "test" +) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/t32_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/t32_spec.lua new file mode 100644 index 0000000..88d2661 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/t32_spec.lua @@ -0,0 +1,138 @@ +local Runner = require("tests.indent.common").Runner +local XFAIL = require("tests.indent.common").XFAIL + +local runner = Runner:new(it, "tests/indent/t32", { + tabstop = 2, + shiftwidth = 2, + softtabstop = 0, + expandtab = true, +}) + +describe("indent t32:", function() + describe("whole file:", function() + runner:whole_file "." + end) + + describe("new line:", function() + runner:new_line("if_block.cmm", { on_line = 2, text = "GOTO start", indent = 0 }, "command after IF", XFAIL) + + runner:new_line("if_block.cmm", { on_line = 5, text = "GOTO start", indent = 2 }, "command in IF then block") + + runner:new_line("if_block.cmm", { on_line = 4, text = "(", indent = 0 }, "block after IF") + + for ii, test in ipairs { + { 1, 2 }, + { 14, 2 }, + { 19, 2 }, + { 21, 2 }, + { 41, 2 }, + { 42, 4 }, + } do + runner:new_line( + "if_block.cmm", + { on_line = test[1], text = "&x=1.", indent = test[2] }, + "command in IF then[" .. ii .. "]" + ) + end + + -- Insertion of a command right before the existing block results in + -- incorrect syntax. The parse either detect an error or incorrectly + -- assumes "ELSE IF" is a command. + for ii, test in ipairs { + { 26, 2 }, + { 30, 2 }, + } do + runner:new_line( + "if_block.cmm", + { on_line = test[1], text = 'PRINT ""', indent = test[2] }, + "displace block in IF then[" .. ii .. "]", + XFAIL + ) + end + + runner:new_line("if_block.cmm", { on_line = 45, text = "&x=1.", indent = 6 }, "command in IF then", XFAIL) + + for ii, test in ipairs { + { 16, 2 }, + { 21, 2 }, + { 23, 2 }, + { 44, 4 }, + } do + runner:new_line( + "if_block.cmm", + { on_line = test[1], text = "CONTinue\n", indent = test[2] }, + "command in IF else[" .. ii .. "]" + ) + end + + runner:new_line("while_block.cmm", { on_line = 2, text = "&x=1.", indent = 2 }, "command after WHILE") + + runner:new_line("while_block.cmm", { on_line = 4, text = "&x=1.", indent = 0 }, "command after WHILE") + + runner:new_line("while_block.cmm", { on_line = 1, text = "(\n", indent = 0 }, "block in WHILE then") + + for ii, test in ipairs { + { 5, 2 }, + { 12, 2 }, + } do + runner:new_line( + "while_block.cmm", + { on_line = test[1], text = "&x=1.", indent = test[2] }, + "command in WHILE then block[" .. ii .. "]" + ) + end + + for ii, test in ipairs { + { 1, 0 }, + { 4, 2 }, + } do + runner:new_line( + "repeat_block.cmm", + { on_line = test[1], text = "&x=1.", indent = test[2] }, + "command after RePeaT[" .. ii .. "]" + ) + end + + runner:new_line("repeat_block.cmm", { on_line = 3, text = "(\n", indent = 0 }, "block in RePeaT then") + + for ii, test in ipairs { + { 7, 2 }, + { 18, 2 }, + { 24, 2 }, + } do + runner:new_line( + "repeat_block.cmm", + { on_line = test[1], text = "&x=1.", indent = test[2] }, + "command in RePeaT then block [" .. ii .. "]" + ) + end + + runner:new_line("subroutine_block.cmm", { on_line = 1, text = "(\n", indent = 0 }, "block after call label") + + for ii, test in ipairs { + { 2, 2 }, + { 3, 2 }, + { 8, 2 }, + { 12, 2 }, + { 19, 2 }, + } do + runner:new_line( + "subroutine_block.cmm", + { on_line = test[1], text = "&x=1.", indent = test[2] }, + "command in subroutine block[" .. ii .. "]" + ) + end + + for ii, test in ipairs { + { 5, 2 }, + { 13, 2 }, + { 23, 2 }, + } do + runner:new_line( + "subroutine_block.cmm", + { on_line = test[1], text = "&x=1.", indent = test[2] }, + "command after subroutine block[" .. ii .. "]" + ) + end + end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/terraform/function_call.tf b/pack/ant/start/nvim-treesitter/tests/indent/terraform/function_call.tf new file mode 100644 index 0000000..44c477e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/terraform/function_call.tf @@ -0,0 +1,6 @@ +test { + x = f( + a, + b, + ) +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/terraform/indent-in-multiline-objects.tf b/pack/ant/start/nvim-treesitter/tests/indent/terraform/indent-in-multiline-objects.tf new file mode 100644 index 0000000..00ee9c9 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/terraform/indent-in-multiline-objects.tf @@ -0,0 +1,6 @@ +test { + x = { + 1: "foo", + 2: "bar", + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/terraform/indent-in-multiline-tuples.tf b/pack/ant/start/nvim-treesitter/tests/indent/terraform/indent-in-multiline-tuples.tf new file mode 100644 index 0000000..4024878 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/terraform/indent-in-multiline-tuples.tf @@ -0,0 +1,6 @@ +test { + x = [ + 1, + 2, + ] +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/terraform/multiline-comments.tf b/pack/ant/start/nvim-treesitter/tests/indent/terraform/multiline-comments.tf new file mode 100644 index 0000000..494aaba --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/terraform/multiline-comments.tf @@ -0,0 +1,7 @@ +test { + /* + foo + bar + baz + */ +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/terraform/multiple-attributes.tf b/pack/ant/start/nvim-treesitter/tests/indent/terraform/multiple-attributes.tf new file mode 100644 index 0000000..da6a85f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/terraform/multiple-attributes.tf @@ -0,0 +1,4 @@ +test { + x = ["foo", "bar"] + y = {"fizz": "buzz"} +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/terraform/multiple-blocks.tf b/pack/ant/start/nvim-treesitter/tests/indent/terraform/multiple-blocks.tf new file mode 100644 index 0000000..b9826c8 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/terraform/multiple-blocks.tf @@ -0,0 +1,6 @@ +test { + x = "foo" +} +test { + y = "bar" +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/terraform/nested_blocks.tf b/pack/ant/start/nvim-treesitter/tests/indent/terraform/nested_blocks.tf new file mode 100644 index 0000000..7be6492 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/terraform/nested_blocks.tf @@ -0,0 +1,5 @@ +test { + nest { + x = "bar" + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/terraform/no-indent-after-brace.tf b/pack/ant/start/nvim-treesitter/tests/indent/terraform/no-indent-after-brace.tf new file mode 100644 index 0000000..e670ad8 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/terraform/no-indent-after-brace.tf @@ -0,0 +1,4 @@ +# Issue #2590 +locals { + titles = ["test0", "test1"] +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/terraform_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/terraform_spec.lua new file mode 100644 index 0000000..49fa22c --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/terraform_spec.lua @@ -0,0 +1,35 @@ +local Runner = require("tests.indent.common").Runner +--local XFAIL = require("tests.indent.common").XFAIL + +local run = Runner:new(it, "tests/indent/terraform", { + tabstop = 2, + shiftwidth = 2, + expandtab = true, +}) + +describe("indent Terraform:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new line:", function() + run:new_line("no-indent-after-brace.tf", { on_line = 4, text = "# Wow, no indent here please", indent = 0 }) + run:new_line("indent-in-multiline-tuples.tf", { on_line = 4, text = "3,", indent = 4 }) + run:new_line("indent-in-multiline-tuples.tf", { on_line = 3, text = "# as elements", indent = 4 }) + run:new_line("indent-in-multiline-tuples.tf", { on_line = 5, text = "# as outer block", indent = 2 }) + run:new_line("indent-in-multiline-tuples.tf", { on_line = 1, text = "# as outer block", indent = 2 }) + run:new_line("indent-in-multiline-objects.tf", { on_line = 4, text = '3: "baz",', indent = 4 }) + run:new_line("indent-in-multiline-objects.tf", { on_line = 3, text = "# as elements", indent = 4 }) + run:new_line("indent-in-multiline-objects.tf", { on_line = 5, text = "# as outer block", indent = 2 }) + run:new_line("indent-in-multiline-objects.tf", { on_line = 1, text = "# as outer block", indent = 2 }) + run:new_line("multiple-attributes.tf", { on_line = 2, text = "a = 1", indent = 2 }) + run:new_line("multiple-attributes.tf", { on_line = 3, text = "a = 1", indent = 2 }) + run:new_line("multiple-attributes.tf", { on_line = 4, text = "a = 1", indent = 0 }) + run:new_line("nested_blocks.tf", { on_line = 3, text = "a = 1", indent = 4 }) + run:new_line("nested_blocks.tf", { on_line = 4, text = "a = 1", indent = 2 }) + run:new_line("function_call.tf", { on_line = 4, text = "c,", indent = 4 }) + run:new_line("function_call.tf", { on_line = 5, text = "a = 1", indent = 2 }) + end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/tiger/classes.tig b/pack/ant/start/nvim-treesitter/tests/indent/tiger/classes.tig new file mode 100644 index 0000000..542a40e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/tiger/classes.tig @@ -0,0 +1,14 @@ +class A { + var a := 12 + + method method() : int = 1 +} + +type B = class extends A { + var b := 27 + + method another_method() = ( + print("called"); + self.b + self.method() + ) +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/tiger/control-flow.tig b/pack/ant/start/nvim-treesitter/tests/indent/tiger/control-flow.tig new file mode 100644 index 0000000..abbadfa --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/tiger/control-flow.tig @@ -0,0 +1,22 @@ +( + if + 12 + then + 27 + else + 42 + ; + + for + i := 12 + to + 27 + do + 42 + ; + + while + 0 + do + break +) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/tiger/functions.tig b/pack/ant/start/nvim-treesitter/tests/indent/tiger/functions.tig new file mode 100644 index 0000000..22ce051 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/tiger/functions.tig @@ -0,0 +1,14 @@ +primitive long_parameter_list( + a: int, + b: string, + c: type +) + +function f() = + ( + long_parameter_list( + 1, + "2", + nil + ) + ) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/tiger/groupings.tig b/pack/ant/start/nvim-treesitter/tests/indent/tiger/groupings.tig new file mode 100644 index 0000000..870e0da --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/tiger/groupings.tig @@ -0,0 +1,10 @@ +let + var a := 42 +in + ( + 12; + 27; + 42 + ); + a +end diff --git a/pack/ant/start/nvim-treesitter/tests/indent/tiger/values-and-expressions.tig b/pack/ant/start/nvim-treesitter/tests/indent/tiger/values-and-expressions.tig new file mode 100644 index 0000000..5131c30 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/tiger/values-and-expressions.tig @@ -0,0 +1,30 @@ +let + type array_of_int = array of int + + type record = { + a: int, + b: string, + c: type + } + + var a := + "a string" +in + array[ + 12 + ] + ; + + array_of_int[ + 27 + ] + of + 42 + ; + + record { + a = 1, + b = "2", + c = nil + } +end diff --git a/pack/ant/start/nvim-treesitter/tests/indent/tiger_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/tiger_spec.lua new file mode 100644 index 0000000..c1f252f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/tiger_spec.lua @@ -0,0 +1,113 @@ +local Runner = require("tests.indent.common").Runner + +local runner = Runner:new(it, "tests/indent/tiger", { + tabstop = 2, + shiftwidth = 2, + softtabstop = 0, + expandtab = true, +}) + +describe("indent Tiger:", function() + describe("whole file:", function() + runner:whole_file "." + end) + + describe("new line:", function() + runner:new_line("classes.tig", { on_line = 1, text = "var a := 0", indent = 2 }, "class declaration beginning") + runner:new_line("classes.tig", { on_line = 2, text = "var a := 0", indent = 2 }, "class declaration after field") + runner:new_line("classes.tig", { on_line = 4, text = "var a := 0", indent = 2 }, "class declaration after method") + runner:new_line("classes.tig", { on_line = 5, text = "var a := 0", indent = 0 }, "after class declaration") + runner:new_line("classes.tig", { on_line = 7, text = "var a := 0", indent = 2 }, "class type beginning") + runner:new_line("classes.tig", { on_line = 8, text = "var a := 0", indent = 2 }, "class type after field") + runner:new_line("classes.tig", { on_line = 10, text = "self.a := 0", indent = 4 }, "inside method") + runner:new_line("classes.tig", { on_line = 13, text = "var a := 0", indent = 2 }, "class type after method") + runner:new_line("classes.tig", { on_line = 14, text = "var a := 0", indent = 0 }, "after class type") + + runner:new_line("control-flow.tig", { on_line = 2, text = "true", indent = 4 }, "if condition") + runner:new_line("control-flow.tig", { on_line = 4, text = "true", indent = 4 }, "if consequence") + runner:new_line("control-flow.tig", { on_line = 4, text = "true", indent = 4 }, "if alternative") + runner:new_line("control-flow.tig", { on_line = 10, text = "start := 0", indent = 4 }, "for index start") + runner:new_line("control-flow.tig", { on_line = 12, text = "the_end", indent = 4 }, "for index end") + runner:new_line("control-flow.tig", { on_line = 14, text = "break", indent = 4 }, "for body") + runner:new_line("control-flow.tig", { on_line = 18, text = "true", indent = 4 }, "while condition") + runner:new_line("control-flow.tig", { on_line = 20, text = "break", indent = 4 }, "while body") + + runner:new_line("functions.tig", { on_line = 1, text = "parameter: int,", indent = 2 }, "parameter list beginning") + runner:new_line("functions.tig", { on_line = 2, text = "parameter: int,", indent = 2 }, "parameter list middle") + runner:new_line("functions.tig", { on_line = 4, text = ",parameter: int", indent = 2 }, "parameter list end") + runner:new_line("functions.tig", { on_line = 5, text = "var a := 0", indent = 0 }, "after parameter list") + runner:new_line("functions.tig", { on_line = 7, text = "print(a)", indent = 2 }, "function body") + runner:new_line("functions.tig", { on_line = 9, text = "a,", indent = 6 }, "function call beginning") + runner:new_line("functions.tig", { on_line = 10, text = "a,", indent = 6 }, "function call middle") + runner:new_line("functions.tig", { on_line = 12, text = ",a", indent = 6 }, "function call end") + runner:new_line("functions.tig", { on_line = 13, text = "; print(a)", indent = 4 }, "after function call") + runner:new_line("functions.tig", { on_line = 14, text = "var a := 12", indent = 0 }, "after function declaration") + + runner:new_line("groupings.tig", { on_line = 2, text = "var b := 0", indent = 2 }, "let declarations") + runner:new_line("groupings.tig", { on_line = 3, text = "a := a + 1", indent = 2 }, "after 'in'") + runner:new_line("groupings.tig", { on_line = 4, text = "a := a + 1;", indent = 4 }, "sequence") + runner:new_line("groupings.tig", { on_line = 8, text = "a := a + 1;", indent = 2 }, "after sequence") + runner:new_line("groupings.tig", { on_line = 10, text = "+ 1", indent = 0 }, "after 'end'") + + runner:new_line( + "values-and-expressions.tig", + { on_line = 4, text = "field: record,", indent = 4 }, + "record type beginning" + ) + runner:new_line( + "values-and-expressions.tig", + { on_line = 5, text = "field: record,", indent = 4 }, + "record type middle" + ) + runner:new_line( + "values-and-expressions.tig", + { on_line = 7, text = ",field: record", indent = 4 }, + "record type end" + ) + runner:new_line("values-and-expressions.tig", { on_line = 8, text = "var a := 0", indent = 2 }, "after record type") + runner:new_line( + "values-and-expressions.tig", + { on_line = 10, text = "0", indent = 4 }, + "variable declaration init value" + ) + runner:new_line( + "values-and-expressions.tig", + { on_line = 11, text = "+ a", indent = 4 }, + "variable declaration init follow-up" + ) + runner:new_line("values-and-expressions.tig", { on_line = 13, text = "a", indent = 4 }, "array index") + runner:new_line("values-and-expressions.tig", { on_line = 14, text = "+ a", indent = 4 }, "array index follow-up") + runner:new_line("values-and-expressions.tig", { on_line = 15, text = "+ a", indent = 2 }, "after array value") + runner:new_line("values-and-expressions.tig", { on_line = 18, text = "a", indent = 4 }, "array expression size") + runner:new_line( + "values-and-expressions.tig", + { on_line = 20, text = "of", indent = 4 }, + "array expression after size" + ) + runner:new_line( + "values-and-expressions.tig", + { on_line = 21, text = "a", indent = 4 }, + "array expression init value" + ) + runner:new_line( + "values-and-expressions.tig", + { on_line = 25, text = "field = 0,", indent = 4 }, + "record expression beginning" + ) + runner:new_line( + "values-and-expressions.tig", + { on_line = 26, text = "field = 0,", indent = 4 }, + "record expression middle" + ) + runner:new_line( + "values-and-expressions.tig", + { on_line = 28, text = ",field = 0", indent = 4 }, + "record expression end" + ) + runner:new_line( + "values-and-expressions.tig", + { on_line = 29, text = "a := 0", indent = 2 }, + "after record expression" + ) + end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/usd/prim.usd b/pack/ant/start/nvim-treesitter/tests/indent/usd/prim.usd new file mode 100644 index 0000000..4bfbff9 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/usd/prim.usd @@ -0,0 +1,6 @@ +#usda 1.0 + +def "foo" ( +) +{ +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/usd_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/usd_spec.lua new file mode 100644 index 0000000..c4e8198 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/usd_spec.lua @@ -0,0 +1,21 @@ +local Runner = require("tests.indent.common").Runner + +local run = Runner:new(it, "tests/indent/usd", { + tabstop = 4, + shiftwidth = 4, + softtabstop = 4, + expandtab = true, +}) + +describe("indent USD:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new line:", function() + run:new_line("prim.usd", { on_line = 3, text = "active = false", indent = 4 }) + run:new_line("prim.usd", { on_line = 5, text = "custom int foo = 10", indent = 4 }) + end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/vue/template_indent.vue b/pack/ant/start/nvim-treesitter/tests/indent/vue/template_indent.vue new file mode 100644 index 0000000..95d891f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/vue/template_indent.vue @@ -0,0 +1,3 @@ + diff --git a/pack/ant/start/nvim-treesitter/tests/indent/vue_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/vue_spec.lua new file mode 100644 index 0000000..09527e4 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/vue_spec.lua @@ -0,0 +1,24 @@ +local Runner = require("tests.indent.common").Runner +-- local XFAIL = require("tests.indent.common").XFAIL + +local run = Runner:new(it, "tests/indent", { + tabstop = 2, + shiftwidth = 2, + softtabstop = 0, + expandtab = true, +}) + +describe("indent Vue:", function() + describe("whole file:", function() + run:whole_file({ "vue/" }, {}) + end) + + describe("new line:", function() + for _, info in ipairs { + { 1, 2 }, + { 3, 0 }, + } do + run:new_line("vue/template_indent.vue", { on_line = info[1], text = "Foo", indent = info[2] }, info[3], info[4]) + end + end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/wgsl/basic.wgsl b/pack/ant/start/nvim-treesitter/tests/indent/wgsl/basic.wgsl new file mode 100644 index 0000000..7dd50f8 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/wgsl/basic.wgsl @@ -0,0 +1,43 @@ +struct Vertex { + @location(0) position: vec3, + @location(1) color: vec4, +}; + +@vertex +fn vertex(vertex: Vertex) -> VertexOutput { + var out: VertexOutput; + out.a = 1; + if (1) { + out.a = 3; + } + if (2) { + dsa; + } + + loop { + if (i >= 4) { break; } + } + out.b = 2; + return out; +} + +@vertex +fn vertex(vertex: Vertex, + foo: dso, + foo: dsa +) -> VertexOutput { + var out: VertexOutput; + out.a = 1; + out.b = 2; + return out; +} + +@vertex +fn vertex(vertex: Vertex, + foo: dso, + foo: dsa) -> VertexOutput { + var out: VertexOutput; + out.a = 1; + out.b = 2; + return out; +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/wgsl_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/wgsl_spec.lua new file mode 100644 index 0000000..55d59ac --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/wgsl_spec.lua @@ -0,0 +1,19 @@ +local Runner = require("tests.indent.common").Runner +--local XFAIL = require("tests.indent.common").XFAIL + +local run = Runner:new(it, "tests/indent/wgsl", { + tabstop = 2, + shiftwidth = 2, + softtabstop = 0, + expandtab = true, +}) + +describe("indent WGSL:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new line:", function() end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/yaml/autoindent-mapping-pair.yaml b/pack/ant/start/nvim-treesitter/tests/indent/yaml/autoindent-mapping-pair.yaml new file mode 100644 index 0000000..8dadeee --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/yaml/autoindent-mapping-pair.yaml @@ -0,0 +1,2 @@ +- key1: value1 + key2: value2 diff --git a/pack/ant/start/nvim-treesitter/tests/indent/yaml/indent-sequence-items.yaml b/pack/ant/start/nvim-treesitter/tests/indent/yaml/indent-sequence-items.yaml new file mode 100644 index 0000000..8dadeee --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/yaml/indent-sequence-items.yaml @@ -0,0 +1,2 @@ +- key1: value1 + key2: value2 diff --git a/pack/ant/start/nvim-treesitter/tests/indent/yaml_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/yaml_spec.lua new file mode 100644 index 0000000..91c60c2 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/yaml_spec.lua @@ -0,0 +1,20 @@ +local Runner = require("tests.indent.common").Runner +--local XFAIL = require("tests.indent.common").XFAIL + +local run = Runner:new(it, "tests/indent/yaml", { + shiftwidth = 2, + expandtab = true, +}) + +describe("indent YAML:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new line:", function() + run:new_line("indent-sequence-items.yaml", { on_line = 2, text = "key3: value3", indent = 2 }) + run:new_line("autoindent-mapping-pair.yaml", { on_line = 1, text = "key3: value3", indent = 2 }) + end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/yang/module.yang b/pack/ant/start/nvim-treesitter/tests/indent/yang/module.yang new file mode 100644 index 0000000..29c911f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/yang/module.yang @@ -0,0 +1,58 @@ +module test-module { + yang-version 1.1; + namespace "http://example.com"; + prefix test; + + import ietf-inet-types { prefix inet; } + import tailf-ncs { + prefix ncs; + } + + description "Multi-line strings has indentation + aligned with the first line."; + + typedef foo { + type enumeration { + enum "foo"; + enum "bar"; + } + } + + ncs:plan-outline test-nano-service { + description "Testing indentation of extension statements."; + + ncs:component-type "ncs:self" { + ncs:state "ncs:init" { + ncs:create { + ncs:nano-callback; + } + } + ncs:state "ncs:ready"; + } + + ncs:component-type "alloc:resource-allocator" { + ncs:state "ncs:init"; + ncs:state "alloc:resources-allocated"; + ncs:state "ncs:ready"; + } + } + + container test { + } + + augment /alloc:resource-allocator { + description "Augmentation for the resource allocator mock services."; + + list test-nano-service { + key "id"; + + leaf id { + type string; + description + "I'm a multi-line string + + Starting on the next line from the statement."; + } + } + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/yang_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/yang_spec.lua new file mode 100644 index 0000000..618d260 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/yang_spec.lua @@ -0,0 +1,23 @@ +local Runner = require("tests.indent.common").Runner + +local run = Runner:new(it, "tests/indent/yang", { + tabstop = 2, + shiftwidth = 2, + softtabstop = 0, + expandtab = true, +}) + +describe("indent YANG:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new line:", function() + run:new_line("module.yang", { on_line = 12, text = "// Aligned indentation ended", indent = 2 }) + run:new_line("module.yang", { on_line = 37, text = "// Test", indent = 4 }) + run:new_line("module.yang", { on_line = 40, text = "// Test", indent = 4 }) + run:new_line("module.yang", { on_line = 52, text = "Aligned string!", indent = 11 }) + end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/yuck/indent.yuck b/pack/ant/start/nvim-treesitter/tests/indent/yuck/indent.yuck new file mode 100644 index 0000000..c224548 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/yuck/indent.yuck @@ -0,0 +1,17 @@ +(defwidget name + :widget parameter + (box one + :box1 parameter + (box two + :box2 parameter + ) + ) +) + +(defwidget name + :widget parameter + (box one + ) +) + +(defwidget name diff --git a/pack/ant/start/nvim-treesitter/tests/indent/yuck_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/yuck_spec.lua new file mode 100644 index 0000000..6ce15de --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/yuck_spec.lua @@ -0,0 +1,19 @@ +local Runner = require("tests.indent.common").Runner +local run = Runner:new(it, "tests/indent/yuck", { + tabstop = 2, + shiftwidth = 2, + expandtab = true, +}) + +describe("indent yuck", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new line:", function() + run:new_line("indent.yuck", { on_line = 13, text = ":box1 parameter", indent = 4 }) + run:new_line("indent.yuck", { on_line = 17, text = ")", indent = 0 }) + end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/indent/zig/pr-3269.zig b/pack/ant/start/nvim-treesitter/tests/indent/zig/pr-3269.zig new file mode 100644 index 0000000..65b6b64 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/zig/pr-3269.zig @@ -0,0 +1,10 @@ +// https://github.com/nvim-treesitter/nvim-treesitter/pull/3269 +const std = @import("std"); + +pub fn main() anyerror!void { + std.log.info("All your codebase are belong to us.", .{}); +} + +test "basic test" { + try std.testing.expectEqual(10, 3 + 7); +} diff --git a/pack/ant/start/nvim-treesitter/tests/indent/zig_spec.lua b/pack/ant/start/nvim-treesitter/tests/indent/zig_spec.lua new file mode 100644 index 0000000..c064d9a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/indent/zig_spec.lua @@ -0,0 +1,22 @@ +local Runner = require("tests.indent.common").Runner +--local XFAIL = require("tests.indent.common").XFAIL + +local run = Runner:new(it, "tests/indent/zig", { + tabstop = 4, + shiftwidth = 4, + softtabstop = 4, + expandtab = true, +}) + +describe("indent Zig:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new lines:", function() + run:new_line("pr-3269.zig", { on_line = 5, text = "return;", indent = 4 }) + run:new_line("pr-3269.zig", { on_line = 6, text = "", indent = 0 }) + end) +end) diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/bash/double-parens.sh b/pack/ant/start/nvim-treesitter/tests/query/highlights/bash/double-parens.sh new file mode 100644 index 0000000..8d841d1 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/bash/double-parens.sh @@ -0,0 +1,6 @@ +if (( $(tree-sitter parse test/Petalisp/**/*.lisp -q | wc -l) > 2 )); then +# ^ @punctuation.special +# ^ @punctuation.special +# ^ @punctuation.bracket + exit 1 +fi diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/c/enums-as-constants.c b/pack/ant/start/nvim-treesitter/tests/query/highlights/c/enums-as-constants.c new file mode 100644 index 0000000..8e64744 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/c/enums-as-constants.c @@ -0,0 +1,21 @@ +enum Foo{ + a, +// ^ @constant + aa, +// ^ @constant + C, +}; + +void foo(enum Foo f){ + switch ( f ) { + case a: + // ^ @constant + break; + case aa: + // ^ @constant + break; + case C: + break; + default: + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/capnp/test.capnp b/pack/ant/start/nvim-treesitter/tests/query/highlights/capnp/test.capnp new file mode 100644 index 0000000..b70e913 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/capnp/test.capnp @@ -0,0 +1,633 @@ +# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors +# Licensed under the MIT License: +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +@0xd508eebdc2dc42b8; +# <- @keyword.directive +# ^ @punctuation.delimiter + +using Cxx = import "c++.capnp"; +# <- @keyword.import +# ^^^ @type +# ^ @operator +# ^^^^^^ @keyword.import +# ^^^^^^^^^^^ @string.special.path + +# Use a namespace likely to cause trouble if the generated code doesn't use fully-qualified +# names for stuff in the capnproto namespace. +$Cxx.namespace("capnproto_test::capnp::test"); + +enum TestEnum { +# <- @keyword.type +# ^^^^^^^^ @type + foo @0; +# ^^^ @constant +# ^^ @label + bar @1; + baz @2; + qux @3; + quux @4; + corge @5; + grault @6; + garply @7; +} +# <- @punctuation.bracket + +struct TestAllTypes { +# <- @keyword.type + voidField @0 : Void; +# ^^^^^^^^^ @variable.member +# ^ @punctuation.special +# ^^^^ @type.builtin + boolField @1 : Bool; + int8Field @2 : Int8; + int16Field @3 : Int16; + int32Field @4 : Int32; + int64Field @5 : Int64; + uInt8Field @6 : UInt8; + uInt16Field @7 : UInt16; + uInt32Field @8 : UInt32; + uInt64Field @9 : UInt64; + float32Field @10 : Float32; + float64Field @11 : Float64; + textField @12 : Text; + dataField @13 : Data; + structField @14 : TestAllTypes; + enumField @15 : TestEnum; + interfaceField @16 : Void; # TODO + + voidList @17 : List(Void); + boolList @18 : List(Bool); + int8List @19 : List(Int8); + int16List @20 : List(Int16); + int32List @21 : List(Int32); + int64List @22 : List(Int64); + uInt8List @23 : List(UInt8); + uInt16List @24 : List(UInt16); + uInt32List @25 : List(UInt32); + uInt64List @26 : List(UInt64); + float32List @27 : List(Float32); + float64List @28 : List(Float64); + textList @29 : List(Text); + dataList @30 : List(Data); + structList @31 : List(TestAllTypes); + enumList @32 : List(TestEnum); + interfaceList @33 : List(Void); # TODO +} + +struct TestInterleavedGroups { + group1 :group { + foo @0 :UInt32; + bar @2 :UInt64; + union { +# ^^^^^ @keyword.type + qux @4 :UInt16; + corge :group { +# ^^^^^ @type + grault @6 :UInt64; + garply @8 :UInt16; + plugh @14 :Text; + xyzzy @16 :Text; + } + + fred @12 :Text; + } + + waldo @10 :Text; + } + + group2 :group { +# ^^^^^ @keyword.type + foo @1 :UInt32; + bar @3 :UInt64; + union { + qux @5 :UInt16; + corge :group { + grault @7 :UInt64; + garply @9 :UInt16; + plugh @15 :Text; + xyzzy @17 :Text; + } + + fred @13 :Text; + } + + waldo @11 :Text; + } +} + +struct TestUnionDefaults { + s16s8s64s8Set @0 :TestUnion = + (union0 = (u0f0s16 = 321), union1 = (u1f0s8 = 123), union2 = (u2f0s64 = 12345678901234567), +# ^^^ @number + union3 = (u3f0s8 = 55)); + s0sps1s32Set @1 :TestUnion = + (union0 = (u0f1s0 = void), union1 = (u1f0sp = "foo"), union2 = (u2f0s1 = true), +# ^^^^^ @string +# ^^^^ @boolean + union3 = (u3f0s32 = 12345678)); + + unnamed1 @2 :TestUnnamedUnion = (foo = 123); + unnamed2 @3 :TestUnnamedUnion = (bar = 321, before = "foo", after = "bar"); +} + +struct TestUsing { + using OuterNestedEnum = TestNestedTypes.NestedEnum; +# ^^^^^ @keyword.import + using TestNestedTypes.NestedStruct.NestedEnum; + + outerNestedEnum @1 :OuterNestedEnum = bar; + innerNestedEnum @0 :NestedEnum = quux; +} + +struct TestListDefaults { + lists @0 :TestLists = ( + list0 = [(f = void), (f = void)], +# ^^^^ @constant.builtin + list1 = [(f = true), (f = false), (f = true), (f = true)], + list8 = [(f = 123), (f = 45)], + list16 = [(f = 12345), (f = 6789)], + list32 = [(f = 123456789), (f = 234567890)], + list64 = [(f = 1234567890123456), (f = 2345678901234567)], + listP = [(f = "foo"), (f = "bar")], + int32ListList = [[1, 2, 3], [4, 5], [12341234]], + textListList = [["foo", "bar"], ["baz"], ["qux", "corge"]], + structListList = [[(int32Field = 123), (int32Field = 456)], [(int32Field = 789)]]); +} + +struct TestWholeFloatDefault { + # At one point, these failed to compile in C++ because it would produce literals like "123f", + # which is not valid; it needs to be "123.0f". + field @0 :Float32 = 123; + bigField @1 :Float32 = 2e30; + const constant :Float32 = 456; + const bigConstant :Float32 = 4e30; +# ^^^^ @number.float +} + +struct TestGenerics(Foo, Bar) { + foo @0 :Foo; + rev @1 :TestGenerics(Bar, Foo); + + union { + uv @2:Void; + ug :group { + ugfoo @3:Int32; + } + } + + list @4 :List(Inner); + # At one time this failed to compile with MSVC due to poor expression SFINAE support. + + struct Inner { + foo @0 :Foo; + bar @1 :Bar; + } + + struct Inner2(Baz) { + bar @0 :Bar; + baz @1 :Baz; + innerBound @2 :Inner; + innerUnbound @3 :TestGenerics.Inner; + + struct DeepNest(Qux) { + foo @0 :Foo; + bar @1 :Bar; + baz @2 :Baz; + qux @3 :Qux; + + interface DeepNestInterface(Quux) { +# ^^^^^^^^^ @keyword.type + # At one time this failed to compile. + call @0 () -> (); +# ^^^^ @function.method +# ^^ @punctuation.delimiter + } + } + } + + interface Interface(Qux) { + call @0 Inner2(Text) -> (qux :Qux, gen :TestGenerics(TestAllTypes, TestAnyPointer)); +# ^^^ @variable.parameter +# ^^^ @variable.parameter + } + + annotation ann(struct) :Foo; +# ^^^^^^^^^^ @keyword.type +# ^^^ @function.method +# ^^^^^^ @variable.parameter.builtin + + using AliasFoo = Foo; + using AliasInner = Inner; + using AliasInner2 = Inner2; + using AliasInner2Text = Inner2(Text); + using AliasRev = TestGenerics(Bar, Foo); + + struct UseAliases { + foo @0 :AliasFoo; + inner @1 :AliasInner; + inner2 @2 :AliasInner2; + inner2Bind @3 :AliasInner2(Text); + inner2Text @4 :AliasInner2Text; + revFoo @5 :AliasRev.AliasFoo; + } +} + +struct BoxedText { text @0 :Text; } +using BrandedAlias = TestGenerics(BoxedText, Text); + +struct TestGenericsWrapper(Foo, Bar) { + value @0 :TestGenerics(Foo, Bar); +} + +struct TestGenericsWrapper2 { + value @0 :TestGenericsWrapper(Text, TestAllTypes); +} + +interface TestImplicitMethodParams { + call @0 [T, U] (foo :T, bar :U) -> TestGenerics(T, U); +# ^ @type +# ^ @type +} + +interface TestImplicitMethodParamsInGeneric(V) { + call @0 [T, U] (foo :T, bar :U) -> TestGenerics(T, U); +} + +struct TestGenericsUnion(Foo, Bar) { + # At one point this failed to compile. + + union { + foo @0 :Foo; + bar @1 :Bar; + } +} + +struct TestUseGenerics $TestGenerics(Text, Data).ann("foo") { +# ^ @punctuation.special +# ^^^^^^^^^^^^ @attribute +# ^ @punctuation.delimiter +# ^^^ @attribute + basic @0 :TestGenerics(TestAllTypes, TestAnyPointer); + inner @1 :TestGenerics(TestAllTypes, TestAnyPointer).Inner; + inner2 @2 :TestGenerics(TestAllTypes, TestAnyPointer).Inner2(Text); + unspecified @3 :TestGenerics; + unspecifiedInner @4 :TestGenerics.Inner2(Text); + wrapper @8 :TestGenericsWrapper(TestAllTypes, TestAnyPointer); + cap @18 :TestGenerics(TestInterface, Text); + genericCap @19 :TestGenerics(TestAllTypes, List(UInt32)).Interface(Data); + + default @5 :TestGenerics(TestAllTypes, Text) = + (foo = (int16Field = 123), rev = (foo = "text", rev = (foo = (int16Field = 321)))); + defaultInner @6 :TestGenerics(TestAllTypes, Text).Inner = + (foo = (int16Field = 123), bar = "text"); + defaultUser @7 :TestUseGenerics = (basic = (foo = (int16Field = 123))); + defaultWrapper @9 :TestGenericsWrapper(Text, TestAllTypes) = + (value = (foo = "text", rev = (foo = (int16Field = 321)))); + defaultWrapper2 @10 :TestGenericsWrapper2 = + (value = (value = (foo = "text", rev = (foo = (int16Field = 321))))); + + aliasFoo @11 :TestGenerics(TestAllTypes, TestAnyPointer).AliasFoo = (int16Field = 123); + aliasInner @12 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner + = (foo = (int16Field = 123)); + aliasInner2 @13 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner2 + = (innerBound = (foo = (int16Field = 123))); + aliasInner2Bind @14 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner2(List(UInt32)) + = (baz = [12, 34], innerBound = (foo = (int16Field = 123))); + aliasInner2Text @15 :TestGenerics(TestAllTypes, TestAnyPointer).AliasInner2Text + = (baz = "text", innerBound = (foo = (int16Field = 123))); + aliasRev @16 :TestGenerics(TestAnyPointer, Text).AliasRev.AliasFoo = "text"; + + useAliases @17 :TestGenerics(TestAllTypes, List(UInt32)).UseAliases = ( + foo = (int16Field = 123), + inner = (foo = (int16Field = 123)), + inner2 = (innerBound = (foo = (int16Field = 123))), + inner2Bind = (baz = "text", innerBound = (foo = (int16Field = 123))), + inner2Text = (baz = "text", innerBound = (foo = (int16Field = 123))), + revFoo = [12, 34, 56]); +} + +struct TestEmptyStruct {} + +struct TestConstants { + const voidConst :Void = void; +# ^^^^^ @keyword.modifier + const boolConst :Bool = true; + const int8Const :Int8 = -123; + const int16Const :Int16 = -12345; + const int32Const :Int32 = -12345678; + const int64Const :Int64 = -123456789012345; + const uint8Const :UInt8 = 234; + const uint16Const :UInt16 = 45678; + const uint32Const :UInt32 = 3456789012; + const uint64Const :UInt64 = 12345678901234567890; + const float32Const :Float32 = 1234.5; + const float64Const :Float64 = -123e45; + const textConst :Text = "foo"; + const dataConst :Data = "bar"; + const structConst :TestAllTypes = ( + voidField = void, + boolField = true, + int8Field = -12, + int16Field = 3456, + int32Field = -78901234, + int64Field = 56789012345678, + uInt8Field = 90, + uInt16Field = 1234, + uInt32Field = 56789012, + uInt64Field = 345678901234567890, + float32Field = -1.25e-10, + float64Field = 345, + textField = "baz", + dataField = "qux", + structField = ( + textField = "nested", + structField = (textField = "really nested")), + enumField = baz, + # interfaceField can't have a default + + voidList = [void, void, void], + boolList = [false, true, false, true, true], + int8List = [12, -34, -0x80, 0x7f], + int16List = [1234, -5678, -0x8000, 0x7fff], + int32List = [12345678, -90123456, -0x80000000, 0x7fffffff], + int64List = [123456789012345, -678901234567890, -0x8000000000000000, 0x7fffffffffffffff], + uInt8List = [12, 34, 0, 0xff], + uInt16List = [1234, 5678, 0, 0xffff], + uInt32List = [12345678, 90123456, 0, 0xffffffff], + uInt64List = [123456789012345, 678901234567890, 0, 0xffffffffffffffff], + float32List = [0, 1234567, 1e37, -1e37, 1e-37, -1e-37], + float64List = [0, 123456789012345, 1e306, -1e306, 1e-306, -1e-306], + textList = ["quux", "corge", "grault"], + dataList = ["garply", "waldo", "fred"], + structList = [ + (textField = "x " "structlist" + " 1"), + (textField = "x structlist 2"), + (textField = "x structlist 3")], + enumList = [qux, bar, grault] + # interfaceList can't have a default + ); + const enumConst :TestEnum = corge; + + const voidListConst :List(Void) = [void, void, void, void, void, void]; + const boolListConst :List(Bool) = [true, false, false, true]; + const int8ListConst :List(Int8) = [111, -111]; + const int16ListConst :List(Int16) = [11111, -11111]; + const int32ListConst :List(Int32) = [111111111, -111111111]; + const int64ListConst :List(Int64) = [1111111111111111111, -1111111111111111111]; + const uint8ListConst :List(UInt8) = [111, 222] ; + const uint16ListConst :List(UInt16) = [33333, 44444]; + const uint32ListConst :List(UInt32) = [3333333333]; + const uint64ListConst :List(UInt64) = [11111111111111111111]; + const float32ListConst :List(Float32) = [5555.5, inf, -inf, nan]; + const float64ListConst :List(Float64) = [7777.75, inf, -inf, nan]; + const textListConst :List(Text) = ["plugh", "xyzzy", "thud"]; + const dataListConst :List(Data) = ["oops", "exhausted", "rfc3092"]; + const structListConst :List(TestAllTypes) = [ + (textField = "structlist 1"), + (textField = "structlist 2"), + (textField = "structlist 3")]; + const enumListConst :List(TestEnum) = [foo, garply]; +} + +const globalInt :UInt32 = 12345; +const globalText :Text = "foobar"; +const globalStruct :TestAllTypes = (int32Field = 54321); +const globalPrintableStruct :TestPrintInlineStructs = (someText = "foo"); +const derivedConstant :TestAllTypes = ( + uInt32Field = .globalInt, + textField = TestConstants.textConst, + structField = TestConstants.structConst, + int16List = TestConstants.int16ListConst, + structList = TestConstants.structListConst); + +const genericConstant :TestGenerics(TestAllTypes, Text) = + (foo = (int16Field = 123), rev = (foo = "text", rev = (foo = (int16Field = 321)))); + +const embeddedData :Data = embed "testdata/packed"; +# ^^^^^ @keyword.import +const embeddedText :Text = embed "testdata/short.txt"; +const embeddedStruct :TestAllTypes = embed "testdata/binary"; + +const nonAsciiText :Text = "♫ é ✓"; + +const blockText :Text = + `foo bar baz + `"qux" `corge` 'grault' + "regular\"quoted\"line" + `garply\nwaldo\tfred\"plugh\"xyzzy\'thud + ; + +struct TestAnyPointerConstants { + anyKindAsStruct @0 :AnyPointer; + anyStructAsStruct @1 :AnyStruct; + anyKindAsList @2 :AnyPointer; + anyListAsList @3 :AnyList; +} + +const anyPointerConstants :TestAnyPointerConstants = ( + anyKindAsStruct = TestConstants.structConst, + anyStructAsStruct = TestConstants.structConst, + anyKindAsList = TestConstants.int32ListConst, + anyListAsList = TestConstants.int32ListConst, +); + +interface TestInterface { + foo @0 (i :UInt32, j :Bool) -> (x :Text); +# ^ @variable.parameter + bar @1 () -> (); + baz @2 (s: TestAllTypes); +} + +interface TestExtends extends(TestInterface) { +# ^^^^^^^ @keyword + qux @0 (); + corge @1 TestAllTypes -> (); + grault @2 () -> TestAllTypes; +} + +interface TestTailCallee $Cxx.allowCancellation { + struct TailResult { + i @0 :UInt32; + t @1 :Text; + c @2 :TestCallOrder; + } + + foo @0 (i :Int32, t :Text) -> TailResult; +} + +interface TestTailCaller { + foo @0 (i :Int32, callee :TestTailCallee) -> TestTailCallee.TailResult; +} + +interface TestStreaming $Cxx.allowCancellation { + doStreamI @0 (i :UInt32) -> stream; + doStreamJ @1 (j :UInt32) -> stream; + finishStream @2 () -> (totalI :UInt32, totalJ :UInt32); + # Test streaming. finishStream() returns the totals of the values streamed to the other calls. +} + +interface TestHandle {} + +interface TestMoreStuff extends(TestCallOrder) { + # Catch-all type that contains lots of testing methods. + + callFoo @0 (cap :TestInterface) -> (s: Text); + # Call `cap.foo()`, check the result, and return "bar". + + callFooWhenResolved @1 (cap :TestInterface) -> (s: Text); + # Like callFoo but waits for `cap` to resolve first. + + neverReturn @2 (cap :TestInterface) -> (capCopy :TestInterface) $Cxx.allowCancellation; + # Doesn't return. You should cancel it. + + hold @3 (cap :TestInterface) -> (); + # Returns immediately but holds on to the capability. + + callHeld @4 () -> (s: Text); + # Calls the capability previously held using `hold` (and keeps holding it). + + getHeld @5 () -> (cap :TestInterface); + # Returns the capability previously held using `hold` (and keeps holding it). + + echo @6 (cap :TestCallOrder) -> (cap :TestCallOrder); + # Just returns the input cap. + + expectCancel @7 (cap :TestInterface) -> () $Cxx.allowCancellation; + # evalLater()-loops forever, holding `cap`. Must be canceled. + + methodWithDefaults @8 (a :Text, b :UInt32 = 123, c :Text = "foo") -> (d :Text, e :Text = "bar"); + + methodWithNullDefault @12 (a :Text, b :TestInterface = null); + + getHandle @9 () -> (handle :TestHandle); + # Get a new handle. Tests have an out-of-band way to check the current number of live handles, so + # this can be used to test garbage collection. + + getNull @10 () -> (nullCap :TestMoreStuff); + # Always returns a null capability. + + getEnormousString @11 () -> (str :Text); + # Attempts to return an 100MB string. Should always fail. + + writeToFd @13 (fdCap1 :TestInterface, fdCap2 :TestInterface) + -> (fdCap3 :TestInterface, secondFdPresent :Bool); + # Expects fdCap1 and fdCap2 wrap socket file descriptors. Writes "foo" to the first and "bar" to + # the second. Also creates a socketpair, writes "baz" to one end, and returns the other end. + + throwException @14 (); + throwRemoteException @15 (); +} + +interface TestMembrane { + makeThing @0 () -> (thing :Thing); + callPassThrough @1 (thing :Thing, tailCall :Bool) -> Result; + callIntercept @2 (thing :Thing, tailCall :Bool) -> Result; + loopback @3 (thing :Thing) -> (thing :Thing); + + waitForever @4 () $Cxx.allowCancellation; + + interface Thing { + passThrough @0 () -> Result; + intercept @1 () -> Result; + } + + struct Result { + text @0 :Text; + } +} + +struct TestNameAnnotation $Cxx.name("RenamedStruct") { + union { + badFieldName @0 :Bool $Cxx.name("goodFieldName"); + bar @1 :Int8; + } + + enum BadlyNamedEnum $Cxx.name("RenamedEnum") { + foo @0; + bar @1; + baz @2 $Cxx.name("qux"); + } + + anotherBadFieldName @2 :BadlyNamedEnum $Cxx.name("anotherGoodFieldName"); + + struct NestedStruct $Cxx.name("RenamedNestedStruct") { + badNestedFieldName @0 :Bool $Cxx.name("goodNestedFieldName"); + anotherBadNestedFieldName @1 :NestedStruct $Cxx.name("anotherGoodNestedFieldName"); + + enum DeeplyNestedEnum $Cxx.name("RenamedDeeplyNestedEnum") { + quux @0; + corge @1; + grault @2 $Cxx.name("garply"); + } + } + + badlyNamedUnion :union $Cxx.name("renamedUnion") { + badlyNamedGroup :group $Cxx.name("renamedGroup") { + foo @3 :Void; + bar @4 :Void; + } + baz @5 :NestedStruct $Cxx.name("qux"); + } +} + +interface TestNameAnnotationInterface $Cxx.name("RenamedInterface") { + badlyNamedMethod @0 (badlyNamedParam :UInt8 $Cxx.name("renamedParam")) $Cxx.name("renamedMethod"); +} + +struct TestImpliedFirstField { + struct TextStruct { + text @0 :Text; + i @1 :UInt32 = 321; + } + + textStruct @0 :TextStruct = "foo"; + textStructList @1 :List(TextStruct); + + intGroup :group { + i @2 :UInt32; + str @3 :Text = "corge"; + } +} + +const testImpliedFirstField :TestImpliedFirstField = ( + textStruct = "bar", + textStructList = ["baz", (text = "qux", i = 123)], + intGroup = 123 +); + +struct TestCycleANoCaps { + foo @0 :TestCycleBNoCaps; +} + +struct TestCycleBNoCaps { + foo @0 :List(TestCycleANoCaps); + bar @1 :TestAllTypes; +} + +struct TestCycleAWithCaps { + foo @0 :TestCycleBWithCaps; +} + +struct TestCycleBWithCaps { + foo @0 :List(TestCycleAWithCaps); + bar @1 :TestInterface; +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/clojure/test.clj b/pack/ant/start/nvim-treesitter/tests/query/highlights/clojure/test.clj new file mode 100644 index 0000000..7401019 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/clojure/test.clj @@ -0,0 +1,114 @@ +(ns test {:clj-kondo/ignore true}) +; <- @punctuation.bracket +; ^ @keyword.import +; ^ @module + + ; asdf +;^^^^^^ @comment + + #_ abc +;^^^^^^ @comment + +(func obj) +;^^^^ @function.call +; ^^^ @variable + + #(+ % %1 %& %a) +;^ @punctuation.special +; ^ @function.call +; ^ ^^ ^^ @variable.builtin +; ^^ @variable + + abc# +;^^^^ @variable + + & +;^ @variable.parameter + + ->abc +;^^^^^ @constructor + + ->>abc +;^^^^^^ @variable + + *1 *2 *3 *e +;^^ ^^ ^^ ^^ @variable.builtin + + .method +;^^^^^^^ @function.method + +(.method foo) +;^^^^^^^ @function.method + +(.-field foo) +;^^^^^^^ @variable.member + + Abc/member +;^^^^^^^^^^ @variable.member + +(Abc/method) +;^^^^^^^^^^ @function.method + + Abc +;^^^ @type + + abc. +;^^^^ @type + + ^abc +;^ @punctuation.special + +^java.io.File file +; <- @punctuation.special +;^^^^^^^^^^^^ @type +; ^^^^ @variable + +^java.io.File java.io.File. +; <- @punctuation.special +;^^^^^^^^^^^^ @type +; ^^^^ @variable + +^java.io.File file. +; <- @punctuation.special +;^^^^^^^^^^^^ @type +; ^^^^ @variable + +(^java.io.File file) +;^ @punctuation.special +; ^^^^^^^^^^^^ @type +; ^^^^ @function.call + +(^java.io.File .file foo) +;^ @punctuation.special +; ^^^^^^^^^^^^ @type +; ^^^^ @function.method +; ^^^@variable + +(^java.io.File .-file foo) +;^ @punctuation.special +; ^^^^^^^^^^^^ @type +; ^^^^ @variable.member +; ^^^@variable + +(^java.io.File Abc/method foo) +;^ @punctuation.special +; ^^^^^^^^^^^^ @type +; ^^^^^^^^^^ @function.method +; ^^^ @variable + + (defn foo [arg1] (+ arg1 1)) +;^ ^ ^ ^ ^^ @punctuation.bracket +; ^^^^ @keyword.function +; ^^^ @function +; ^^^^ ^^^^ @variable +; ^ @operator +; ^ @number + + clojure.core/dfn +;^^^^^^^^^^^^^^^^ @variable + + clojure.core/defn +;^^^^^^^^^^^^^^^^ @keyword.function + + any-ns/defn +;^^^^^^^^^^^ @keyword.function diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/cpp/concepts.cpp b/pack/ant/start/nvim-treesitter/tests/query/highlights/cpp/concepts.cpp new file mode 100644 index 0000000..3189813 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/cpp/concepts.cpp @@ -0,0 +1,22 @@ + +template +concept Derived = std::is_base_of::value; +// ^ @keyword.type +// ^ @type.definition + +template +concept Hashable = requires(T a) { +// ^ @keyword +// ^ @variable.parameter +// ^ @type + { std::hash{}(a) } -> std::convertible_to; + typename CommonType; // CommonType is valid and names a type + { CommonType{std::forward(t)} }; + { CommonType{std::forward(u)} }; +}; + + +template + requires requires (T x) { x + x; } // ad-hoc constraint, note keyword used twice +// ^ @keyword +T add(T a, T b) { return a + b; } diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/cpp/enums-as-constants.cpp b/pack/ant/start/nvim-treesitter/tests/query/highlights/cpp/enums-as-constants.cpp new file mode 100644 index 0000000..d6b93d5 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/cpp/enums-as-constants.cpp @@ -0,0 +1,25 @@ +enum class Foo{ + a, +// ^ @constant + aa, +// ^ @constant + C, +// ^ @constant +}; + +void foo(Foo f){ + switch ( f ) { + case Foo::a: + // ^ @type + // ^ @module + // ^ @constant + break; + case Foo::aa: + // ^ @constant + break; + case Foo::C: + // ^ @constant + break; + default: + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/cpp/static-namespace-functions.cpp b/pack/ant/start/nvim-treesitter/tests/query/highlights/cpp/static-namespace-functions.cpp new file mode 100644 index 0000000..3d16c43 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/cpp/static-namespace-functions.cpp @@ -0,0 +1,14 @@ +// Issue #2396 + +int main() +{ + B::foo(); + // ^ @function.call + Foo::A::foo(); + // ^ @function.call + Foo::a::A::foo(); + // ^ @function.call + Foo::a::A::B::foo(); + // ^ @function.call + return 0; +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/cpp/test.cpp b/pack/ant/start/nvim-treesitter/tests/query/highlights/cpp/test.cpp new file mode 100644 index 0000000..4a4c623 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/cpp/test.cpp @@ -0,0 +1,19 @@ +#include +#include +// ^ @keyword.import +// ^ @string + +auto main( int argc, char** argv ) -> int +// ^ @type.builtin + // ^ @variable.parameter + // ^ @type.builtin + // ^ @type.builtin + // ^ @operator +{ + std::cout << "Hello world!" << std::endl; + // ^ @punctuation.delimiter + + return EXIT_SUCCESS; + // ^ @keyword.return + // ^ @constant +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/ecma/const.js b/pack/ant/start/nvim-treesitter/tests/query/highlights/ecma/const.js new file mode 100644 index 0000000..2b778fd --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/ecma/const.js @@ -0,0 +1,13 @@ +_FOO = 4 +// <- @constant +__A__ = 2 +// <- @constant +_ = 2 +// <- @variable +A_B_C = 4 +// <- @constant +_1 = 1 +// <- @variable + +const A = 2 +// ^ @constant diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/ecma/test.ts b/pack/ant/start/nvim-treesitter/tests/query/highlights/ecma/test.ts new file mode 100644 index 0000000..fa926f9 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/ecma/test.ts @@ -0,0 +1,32 @@ +class H { + pub_field = "Hello"; + // ^ @variable.member + + #priv_field = "World!"; + // ^ @variable.member + + #private_method() { + // ^ @function.method + return `${this.pub_field} -- ${this.#priv_field}`; + // ^ @variable.member + // ^ @variable.member + } + + public_method() { + // ^ @function.method + return this.#private_method(); + // ^ @function.method.call + } + + ok() { + return this.public_method(); + // ^ @function.method.call + } +} + +function doSomething(options) { + const { + enable: on, + // ^ @punctuation.delimiter + } = options +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/fusion/afx.fusion b/pack/ant/start/nvim-treesitter/tests/query/highlights/fusion/afx.fusion new file mode 100644 index 0000000..4ccb817 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/fusion/afx.fusion @@ -0,0 +1,17 @@ +property = afx` + + + +
text
+ + + + + + + true} /> + + + + +` diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/fusion/basic.fusion b/pack/ant/start/nvim-treesitter/tests/query/highlights/fusion/basic.fusion new file mode 100644 index 0000000..5f3cc34 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/fusion/basic.fusion @@ -0,0 +1,60 @@ +include: SomeFile.fusion +//<- @keyword.import +// ^ @string.special.url + +namespace: ns = Neos.Fusion.Space +//<- @keyword.type +// ^ @module +// ^ @operator +// ^ @module + +prototype(MyType) < prototype(ns:SuperType) { +//<-keyword +// ^ @punctuation.bracket +// ^ @type +// ^ @punctuation.bracket +// ^ @operator +// ^ @module +// ^ @type + + deleteProp > + // ^ @operator + + string = 'value' + //<- @property + // ^ @operator + // ^ @string + + number = 10.2 + // ^ @number + + null = null + // ^ @constant.builtin + + boolean = true + // ^ @boolean + + property.inner = "value" + //<- @property + // ^ @property + + property.@meta = "value" + //<- @property + // ^ @attribute + + property.type = SomeType + //<- @property + // ^ @type + + property.aliasedType = ns:SomeType + //<- @property + // ^ @module + // ^ @type + + property.fullQualifiedType = SomeNamespace:SomeType + //<- @property + // ^ @module + // ^ @type + +} + diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/fusion/expressions.fusion b/pack/ant/start/nvim-treesitter/tests/query/highlights/fusion/expressions.fusion new file mode 100644 index 0000000..b1822dd --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/fusion/expressions.fusion @@ -0,0 +1,82 @@ +string = ${'foo'} +// ^string + +string = ${'foo \'bar\' baz'} +// ^string + +string = ${"foo"} +// ^string + +string = ${"foo ${test}"} +// ^string + +boolean = ${true} +// ^boolean + +number = ${1} +// ^number + +number = ${1.2} +// ^number + +propertyPath = ${property.path} +// ^variable +// ^variable + +thisorProps = ${this.path} +// ^variable.builtin +// ^variable + +thisorProps = ${props.path} +// ^variable.builtin +// ^variable + +array = ${[]} +// ^punctuation.bracket + +array = ${[true, 'string', 1, [true]]} +// ^punctuation.bracket +// ^boolean +// ^string +// ^number +// ^punctuation.bracket +// ^boolean + +object = ${{}} +// ^punctuation.bracket + +object = ${{first: 'value', second: true, third: [], fourth: object.path }} +// ^property +// ^string +// ^property +// ^boolean +// ^property +// ^punctuation.bracket +// ^property +// ^variable + +result = ${methodCall()} +// ^function + +result = ${Some.methodCall(param, param)} +// ^function +// ^variable +// ^variable + +arrowFunction = ${map(foo, (bar, buz) => bar * buz)} +// ^function +// ^variable +// ^variable + +logic = ${!foo && !(bar || baz) and not 'string'} +// ^operator +// ^operator +// ^operator +// ^operator +// ^operator + +ternary = ${ check ? true : false} +// ^@keyword.conditional.ternary +// ^@keyword.conditional.ternary + + diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/gitattributes/test.gitattributes b/pack/ant/start/nvim-treesitter/tests/query/highlights/gitattributes/test.gitattributes new file mode 100644 index 0000000..4595b94 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/gitattributes/test.gitattributes @@ -0,0 +1,37 @@ +[attr]nodiff -diff -merge +# <- @keyword.directive +# ^^^^^^ @property +# ^ @operator +# ^^^^ @variable.builtin +# ^ @operator +# ^^^^^ @variable.builtin + +vendor/** linguist-vendored=true +# ^ @punctuation.delimiter +# ^^ @character.special +# ^^^^^^^^^^^^^^^^^ @variable.parameter +# ^ @operator +# ^^^^ @boolean + + [^._]-[[:lower:]] !something +# ^ @punctuation.bracket +# ^ @operator +# ^^ @string.special +# ^ @punctuation.bracket +# ^ @punctuation.bracket +# ^^^^^^^^^ @constant +# ^ @punctuation.bracket +# ^ @operator +# ^^^^^^^^^^ @variable.parameter + +"_\u4E00\t\56txt" encoding=UTF-16 +# <- @punctuation.special +# ^^^^^^ @string.escape +# ^^ @string.escape +# ^^^ @string.escape +# ^ @punctuation.special +# ^^^^^^^^ @variable.builtin +# ^ @operator +# ^^^^^^ @string + +# vim:ft=gitattributes: diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/assert.gleam b/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/assert.gleam new file mode 100644 index 0000000..8be3992 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/assert.gleam @@ -0,0 +1,13 @@ +pub fn main() { + assert Ok(i) = parse_int("123") + // <- @keyword.exception + // ^^ @constructor + // ^ @punctuation.bracket + // ^ @variable + // ^ @punctuation.bracket + // ^ @operator + // ^^^^^^^^^ @function.call + // ^ @punctuation.bracket + // ^^^^^ @string + // ^ @punctuation.bracket +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/function.gleam b/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/function.gleam new file mode 100644 index 0000000..15fc5cc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/function.gleam @@ -0,0 +1,127 @@ +pub fn add(x: Int, y: Int) -> Int { +// <- @keyword.modifier +// ^^ @keyword.function +// ^^^ @function +// ^ @punctuation.bracket +// ^ @variable.parameter +// ^ @punctuation.delimiter +// ^^^ @type +// ^ @punctuation.delimiter +// ^ @variable.parameter +// ^ @punctuation.delimiter +// ^^^ @type +// ^ @punctuation.bracket +// ^ @punctuation.delimiter +// ^^^ @type +// ^ @punctuation.bracket +} +// <- @punctuation.bracket + +pub fn twice(f: fn(t) -> t, x: t) -> t { +// <- @keyword.modifier +// ^ @keyword.function +// ^^^^^ @function +// ^ @punctuation.bracket +// ^ @variable.parameter +// ^ @punctuation.delimiter +// ^^ @keyword.function +// ^ @punctuation.bracket +// ^ @type +// ^ @punctuation.bracket +// ^^ @punctuation.delimiter +// ^ @type +// ^ @punctuation.delimiter +// ^ @variable.parameter +// ^ @punctuation.delimiter +// ^ @type +// ^ @punctuation.bracket +// ^^ @punctuation.delimiter +// ^ @type +// ^ @punctuation.bracket +} +// <- @punctuation.bracket + +fn list_of_two(my_value: a) -> List(a) { +// <- @keyword.function +// ^ @function +// ^ @punctuation.bracket +// ^ @variable.parameter +// ^ @punctuation.delimiter +// ^ @type +// ^ @punctuation.bracket +// ^ @punctuation.delimiter +// ^^^^ @type +// ^ @punctuation.bracket +// ^ @type +// ^ @punctuation.bracket +// ^ @punctuation.bracket +} +// <- @punctuation.bracket + +fn replace( +// <- @keyword.function +// ^^^^^^^ @function +// ^ @punctuation.bracket + in string: String, + // <- @label + // ^^^^^^ @variable.parameter + // ^ @punctuation.delimiter + // ^^^^^^ @type + // ^ @punctuation.delimiter + each pattern: String, + // <- @label + // ^^^^^^^ @variable.parameter + // ^ @punctuation.delimiter + // ^^^^^^ @type + // ^ @punctuation.delimiter + with replacement: String, + // <- @label + // ^^^^^^^^^^^ @variable.parameter + // ^ @punctuation.delimiter + // ^^^^^^ @type + // ^ @punctuation.delimiter +) { + replace(in: "A,B,C", each: ",", with: " ") + // <- @function.call + // ^ @punctuation.bracket + // ^^ @label + // ^ @punctuation.delimiter + // ^^^^^^^ @string + // ^ @punctuation.delimiter + // ^^^^ @label + // ^ @punctuation.delimiter + // ^^^ @string + // ^ @punctuation.delimiter + // ^^^^ @label + // ^ @punctuation.delimiter + // ^^^ @string + // ^ @punctuation.bracket +} +// <- @punctuation.bracket + +pub external fn random_float() -> Float = "rand" "uniform" +// <- @keyword.modifier +// ^^^^^^^^ @keyword.modifier +// ^^ @keyword.function +// ^^^^^^^^^^^^ @function +// ^ @punctuation.bracket +// ^ @punctuation.bracket +// ^^ @punctuation.delimiter +// ^^^^^ @type +// ^ @operator +// ^^^^^^ @module +// ^^^^^^^^^ @function + +pub external fn inspect(a) -> a = "Elixir.IO" "inspect" +// <- @keyword.modifier +// ^^^^^^^^ @keyword.modifier +// ^^ @keyword.function +// ^^^^^^^ @function +// ^ @punctuation.bracket +// ^ @type +// ^ @punctuation.bracket +// ^^ @punctuation.delimiter +// ^ @type +// ^ @operator +// ^^^^^^^^^^^ @module +// ^^^^^^^^^ @function diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/import.gleam b/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/import.gleam new file mode 100644 index 0000000..ac452d1 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/import.gleam @@ -0,0 +1,22 @@ +import gleam/io +// <- @keyword.import +// ^ @module +// ^ @operator +// ^ @module + +import cat as kitten +// <- @keyword.import +// ^ @module +// ^ @keyword +// ^ @module + +import animal/cat.{Cat, stroke} +// <- @keyword.import +// ^ @module +// ^ @operator +// ^ @punctuation.delimiter +// ^ @punctuation.bracket +// ^^^ @type +// ^ @punctuation.delimiter +// ^^^^^^ @function +// ^ @punctuation.bracket diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/pipe.gleam b/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/pipe.gleam new file mode 100644 index 0000000..c696b02 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/pipe.gleam @@ -0,0 +1,18 @@ +pub fn run() { + 1 + // <- @number + |> add(_, 2) + // <- @operator + // ^^^ @function.call + // ^ @punctuation.bracket + // ^ @comment + // ^ @punctuation.delimiter + // ^ @number + // ^ @punctuation.bracket + |> add(3) + // <- @operator + // ^^^ @function.call + // ^ @punctuation.bracket + // ^ @number + // ^ @punctuation.bracket +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/todo.gleam b/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/todo.gleam new file mode 100644 index 0000000..b7384ec --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/todo.gleam @@ -0,0 +1,7 @@ +fn favourite_number() -> Int { + todo("We're going to decide which number is best tomorrow") + // <- @keyword + // ^ @punctuation.bracket + // ^ @string + // ^ @punctuation.bracket +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/type.gleam b/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/type.gleam new file mode 100644 index 0000000..5b0aa02 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/gleam/type.gleam @@ -0,0 +1,84 @@ +pub type Cat { +// <- @keyword.modifier +// ^^^^ @keyword.type +// ^^^ @type +// ^ @punctuation.bracket + Cat(name: String, cuteness: Int) + // <- @constructor + // ^ @punctuation.bracket + // ^^^^ @variable.member + // ^ @punctuation.delimiter + // ^^^^^^ @type + // ^ @punctuation.delimiter + // ^^^^^^^^ @variable.member + // ^ @punctuation.delimiter + // ^^^ @type + // ^ @punctuation.bracket +} + +fn cats() { + Cat(name: "Nubi", cuteness: 2001) + // <- @type + // ^ @punctuation.bracket + // ^^^^ @variable.member + // ^ @punctuation.delimiter + // ^^^^^^ @string + // ^ @punctuation.delimiter + // ^^^^^^^^ @variable.member + // ^ @punctuation.delimiter + // ^^^^ @number + // ^ @punctuation.bracket + Cat("Ginny", 1950) + // <- @constructor + // ^ @punctuation.bracket + // ^^^^^^^ @string + // ^ @punctuation.delimiter + // ^^^^ @number + // ^ @punctuation.bracket +} + +type Box(inner_type) { +// <- @keyword.type +// ^^^ @type +// ^ @punctuation.bracket +// ^^^^^^^^^^ @type +// ^ @punctuation.bracket +// ^ @punctuation.bracket + Box(inner: inner_type) + // <- @constructor + // ^ @punctuation.bracket + // ^^^^^ @variable.member + // ^ @punctuation.delimiter + // ^^^^^^^^^^ @type + // ^ @punctuation.bracket +} + +pub opaque type Counter { +// <- @keyword.modifier +// ^^^^^^ @keyword.modifier +// ^^^^ @keyword.type +// ^^^^^^^ @type +// ^ @punctuation.bracket + Counter(value: Int) +} + +pub fn have_birthday(person) { + Person(..person, age: person.age + 1, is_happy: True) + // <- @constructor + // ^ @punctuation.bracket + // ^^ @operator + // ^^^^^^ @variable + // ^ @punctuation.delimiter + // ^^^ @variable.member + // ^ @punctuation.delimiter + // ^^^^^^ @variable + // ^ @punctuation.delimiter + // ^^^ @variable.member + // ^ @operator + // ^ @number + // ^ @punctuation.delimiter + // ^^^^^^^^ @variable.member + // ^ @punctuation.delimiter + // ^^^^ @boolean + // ^ @punctuation.bracket +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/as-foreach.hack b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/as-foreach.hack new file mode 100644 index 0000000..6110271 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/as-foreach.hack @@ -0,0 +1,6 @@ +foreach (($array as vec[]) as $item) {} +// ^ @keyword.repeat +// ^ @type + +# Our expectation test for the code below intentionally includes an ERROR. +foreach ($array as vec[] as $item) {} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/async-functions.hack b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/async-functions.hack new file mode 100644 index 0000000..41779d7 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/async-functions.hack @@ -0,0 +1,8 @@ +async function func0(): void {} +// ^ @type.builtin +async function func1() {} +// ^ @type.builtin +// ^ @keyword.operator + + +async ($x) ==> $x + 1; diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/attribute-type.hack b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/attribute-type.hack new file mode 100644 index 0000000..0bd12df --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/attribute-type.hack @@ -0,0 +1,15 @@ +<> +newtype T1 = ?shape( +// TODO: ?operator (? not captureable at the moment) + ?'int' => int +// ^ @operator +); + +<> +// ^ @attribute +type T2 = (function(T1): string); +// ^ @type +// TODO: keyword.function (currently not in AST) + +<> +newtype T3 as int = int; diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/generics.hack b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/generics.hack new file mode 100644 index 0000000..50bd50e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/generics.hack @@ -0,0 +1,24 @@ +class Box { + // ^ @type + // ^ @type + protected T $data; + // ^ @keyword.modifier + // ^ @type + + public function __construct(T $data) { + // ^ @type + // ^ @variable.parameter + // ^ @keyword.function + // ^ @keyword.modifier + // ^ @function.method + $this->data = $data; + } + + public function getData(): T { + // ^ @function.method + // ^ @keyword.modifier + return $this->data; + // ^ @operator + // ^ @variable.builtin + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/heredoc-dollar.hack b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/heredoc-dollar.hack new file mode 100644 index 0000000..8ea2473 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/heredoc-dollar.hack @@ -0,0 +1,4 @@ +<< int, + // ^ @string + "b" => string, + // ^ @type.builtin + ); +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/use.hack b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/use.hack new file mode 100644 index 0000000..ab17d11 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/use.hack @@ -0,0 +1,28 @@ +use const Space\Const\C; +// ^ @keyword +// ^ @constant +use function Space\Func\F as E; +// ^ @function +// ^ @function +use type Space\Type\T; +// ^ @keyword.type +use namespace Space\Name\N as M; +// ^ @keyword.type +// ^ @module + +use namespace Space\Name2\N2, Space\Nothing\N3 as N8, type Space\Type2\N4,; +// ^ @module +// ^ @type +use namespace Space\Name\N10\{A as A2, B\}; +// ^ @module +// ^ @module +// ^ @module +use namespace Space\Name\{\C, Slash as Forward}; + +use \What\Is\This\{function A as A2, B, const H\S\L as stdlib, function F}; + +use type \{kind,}; +use Q\B\{kind2,}; +// ^ @module +use type Q\B\{kind3,}; +// <- @keyword.import diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/using.hack b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/using.hack new file mode 100644 index 0000000..c3a7be1 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/using.hack @@ -0,0 +1,3 @@ +using ($new = new Object(), $file = new File('using', '+using')) {} +// <- @keyword +// ^ @type diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/xhp.hack b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/xhp.hack new file mode 100644 index 0000000..57563a1 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/hack/xhp.hack @@ -0,0 +1,10 @@ +$user_name = 'Fred'; +echo "Hello $user_name"; + +// XHP: Typechecked, well-formed, and secure +$user_name = 'Andrew'; +$xhp = Hello {$user_name}; +// ^ @tag +// ^ @tag +// ^ @string +echo await $xhp->toStringAsync(); diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/haskell/test.hs b/pack/ant/start/nvim-treesitter/tests/query/highlights/haskell/test.hs new file mode 100644 index 0000000..f719981 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/haskell/test.hs @@ -0,0 +1,343 @@ +{-# LANGUAGE QuasiQuotes #-} +-- ^ @keyword.directive + +{-| Main module -} + -- ^ @comment.documentation +module Main +-- ^ @keyword.import + -- ^ @module + ( main + -- ^ @variable + ) where + -- ^ @keyword + +import Prelude hiding (show) +-- ^ @keyword.import + -- ^ @module + -- ^ @keyword + -- ^ @variable +import Data.Map (fromList) + -- ^ @module +import qualified Data.Map as Map + -- ^ @module + -- ^ @module +import qualified Chronos + -- ^ @module +import qualified Chronos as C + -- ^ @module + -- ^ @module +import FooMod (BarTy (barField)) + -- ^ @variable.member + +x = mempty { field = 5 } + -- ^ @variable.member + +data ADT +-- ^ @keyword + = A Int + -- ^ @constructor + -- ^ @type + | B + -- ^ @constructor + deriving (Eq, Show) + -- ^ @keyword + -- ^ @type + -- ^ @type +mkA x = A x + -- ^ @variable +mkAQualified x = SomeModule.A x + -- ^ @variable + +class Ord a => PartialOrd a + -- ^ @type + -- ^ @variable + -- ^ @type + -- ^ @variable + +instance Ord ADT where + -- ^ @type + -- ^ @type + +newtype Rec +-- ^ @keyword + -- ^ @type + = Rec + -- ^ @constructor + { field :: Double + -- ^ @punctuation.bracket + -- ^ @variable.member + -- ^ @type + } + -- ^ @punctuation.bracket + deriving Eq + -- ^ @type +recordWildCard Rec { field } = field + -- ^ @variable.member +recordDotSyntax rec = rec.field + -- ^ @variable.member + + +main :: IO () +-- ^ @function + -- ^ @operator + -- ^ @type + -- ^ @type +main = undefined +-- ^ @function + -- ^ @keyword.exception + +someFunc0 :: Int -> Int + -- ^ @operator +someFunc0 x = someFunc1 x + -- ^ @variable.parameter + -- ^ @function.call + where + -- ^ @keyword + someFunc1 _ = 5 + -- ^ @function + -- ^ @number +scopedTypeParam (x :: Int) = someFunc x + -- ^ @variable.parameter + -- ^ @type +scopedTypeParam (Just x :: Int) = someFunc x + -- ^ @constructor + -- ^ @variable.parameter + -- ^ @type +scopedTypeParam (f :: Int -> Int) = someFunc x + -- ^ @function + +someInfix :: Integral a => a -> Double + -- ^ @type + -- ^ @variable + -- ^ @operator + -- ^ @variable + -- ^ @type +someInfix x = fromIntegral x `myAdd` floatVal + -- ^ @function.call + -- ^ @variable + -- ^ @operator + -- ^ @variable + where + myAdd :: Num a => a -> a + -- ^ @function + myAdd x y = x + y + -- ^ @variable + -- ^ @variable + floatVal :: Double + -- ^ @variable + floatVal = 5.5 + -- ^ @variable + -- ^ @number.float + intVal :: Int + -- ^ @variable + intVal = getInt 5 + -- ^ @variable + boolVal :: Bool + -- ^ @variable + boolVal = bool False True $ 1 + 2 == 3 + -- ^ @variable + refVal = boolVal + -- ^ @variable + namespacedRecord = NS.Rec { field = bar } + -- ^ @variable + record = Rec { field = bar } + -- ^ @variable + constructorRef = A + -- ^ @function + isInt :: Either Double Int -> Bool + -- ^ @function + isInt eith@Left{} = False + -- ^ @variable.parameter + isInt eith@(Left x) = False + -- ^ @function + -- ^ @variable.parameter + isInt (Left x) = False + -- ^ @variable.parameter + isInt (Right _) = True + -- ^ @function + +someIOaction :: IO () +-- ^ @function +anotherIOaction :: IO () +anotherIOaction = do +-- ^ @function + -- ^ @keyword + foo <- SomeModule.someFun <$> getArgs +-- ^ @variable + -- ^ @module + -- ^ @function.call + -- ^ @operator + _ <- someFunc0 =<< someIOAction + -- ^ @function.call + let bar = SomeModule.doSomething $ "a" "b" + -- ^ @variable + -- ^ @module + -- ^ @function.call + -- ^ @operator + func x y = x + y - 7 + -- ^ @function + -- ^ @variable.parameter + -- ^ @variable + -- ^ @variable + gunc x y = func x $ y + 7 + -- ^ @variable + -- ^ @variable + valueFromList = HashSet.fromList [] + -- ^ @variable + when foo $ putStrLn $ T.showt =<< bar + -- ^ @function.call + -- ^ @variable + -- ^ @function.call + -- ^ @function.call + + pure $ func 1 2 + -- ^ @function.call + -- ^ @function.call + +intVal :: Int +intVal = 5 +-- ^ @variable + +intFun :: Int -> Int +intFun = 5 +-- ^ @function + +undefinedFun :: Int -> Int +undefinedFun = undefined +-- ^ @function + +mbInt :: Maybe Int +-- ^ @variable +mbInt = Just 5 +-- ^ @variable + +tupleVal :: (a, b) +-- ^@variable +tupleVal = (1, "x") +-- ^@variable + +listVal :: [a] +-- ^@variable +listVal = [1, 2] +-- ^@variable +-- ^@variable +condVal = if otherwise +-- ^@variable + then False + else True + +getLambda x = \y -> x `SomeModule.someInfix` y + -- ^ @variable.parameter + -- ^ @module + -- ^ @operator +lambdaTyped = \(y :: Int) -> x + -- ^ @variable.parameter +lambdaPattern = \(Just x) -> x + -- ^ @variable.parameter +lambdaPatternTyped = \(Just x :: Int) -> x + -- ^ @variable.parameter + +isVowel = (`elem` "AEIOU") + -- ^ @operator +isVowelQualified = (`SomeModule.elem` "AEIOU") + -- ^ @module + -- ^ @operator + +hasVowels = ("AEIOU" `elem`) + -- ^ @operator +hasVowelsQualified = ("AEIOU" `SomeModule.elem`) + -- ^ @module + -- ^ @operator + +quasiQuotedString = [qq|Some string|] +-- ^ @variable + -- ^ @function.call + -- ^ @string +quasiQuotedString2 = [SomeModule.qq|Some string|] + -- ^ @module + -- ^ @function.call + +composition f g = f . g + -- ^ @function + -- ^ @function +qualifiedComposition = SomeModule.f . SomeModule.g + -- ^ @function + -- ^ @function +takeMVarOrThrow = evaluate <=< takeMVar + -- ^ @function + -- ^ @function +modifyMVarOrThrow v f = modifyMVar v $ f >=> evaluate + -- ^ @variable + -- ^ @function + -- ^ @function +assertNonEmpty xs = xs `shouldSatisfy` not . null + -- ^ @variable + -- ^ @function + -- ^ @function +appliedComposition f g var = (f . g) var + -- ^ @function.call + -- ^ @function.call +appliedComposition f g var = (NS.f . NS.g) var + -- ^ @function.call + -- ^ @function.call +param1 |*| param2 = Qu $ param1 * param2 +-- ^ @variable.parameter + -- ^ @variable.parameter +(param1 :: Int) |*| (param2 :: Int) = Qu $ param1 * param2 +-- ^ @variable.parameter + -- ^ @variable.parameter +(Qu a) |/| (SomeModule.Qu b) = a / b + -- ^ @variable.parameter + -- ^ @variable.parameter +(Qu a :: Int) |/| (SomeModule.Qu b :: Int) = a / b + -- ^ @variable.parameter + -- ^ @variable.parameter +(Qu a, b, c :: Int) |/| x = undefined + -- ^ @variable.parameter + -- ^ @variable.parameter + -- ^ @variable.parameter +[Qu a, b, c :: Int] >< x = undefined + -- ^ @variable.parameter + -- ^ @variable.parameter + -- ^ @variable.parameter +listParam [a, b :: Int, Just c] = undefined + -- ^ @variable.parameter + -- ^ @variable.parameter + -- ^ @variable.parameter +tupleParam (a :: Int, b, Just c) = undefined + -- ^ @variable.parameter + -- ^ @variable.parameter + -- ^ @variable.parameter +listLambda = \[a, a :: Int, Just c] -> undefined + -- ^ @variable.parameter + -- ^ @variable.parameter + -- ^ @variable.parameter +tupleLambda = \(a, b :: Int, Just c) -> undefined + -- ^ @variable.parameter + -- ^ @variable.parameter +nestedDestructure (Left (Just a)) = undefined + -- ^ @variable.parameter +typeApplication x y = someFun @ty x y + -- ^ @variable + -- ^ @variable +encrypt key pass = encrypt (defaultOAEPParams SHA1) key pass + -- ^ @variable + -- ^ @variable +recordUpdate x y rec = someFun rec {field = 5} (x, x) y + -- ^ @variable + -- ^ @variable +viewPattern (func -> var) = 5 + -- ^ @function.call + -- ^ @variable.parameter +g (func :: a -> b) x = func y + -- ^ @variable.parameter + -- ^ @function +lambdaAlias :: LambdaAlias +lambdaAlias _ _ _ = undefined + -- ^ @function +spec :: Spec +spec = describe "test ns" $ it "test case" pending +-- ^ @variable + +composed = f . g +-- ^ @function diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/hocon/test.conf b/pack/ant/start/nvim-treesitter/tests/query/highlights/hocon/test.conf new file mode 100644 index 0000000..55f4c03 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/hocon/test.conf @@ -0,0 +1,59 @@ +HOCON = Human-Optimized Config Object Notation +// ^ @variable.member +// ^ @string +// ^ @string +// ^ @string +// ^ @string + +"it's": "a JSON\nsuperset", +// ^ @string +// ^ @string.escape +// ^ @punctuation.delimiter + +features: [ +// ^ @operator +// ^ @punctuation.bracket + less noisy / less pedantic syntax +// ^ @string + ability to refer to another part of the configuration + import/include another configuration file into the current file + a mapping to a flat properties list such as Java's system properties + ability to get values from environment variables + # ability to write comments +// ^@ comment +// ^ @comment + // this is also a comment +// ^ @comment +// ^ @comment +] + +specs url: "https://github.com/lightbend/config/blob/master/HOCON.md" +includes: { + include required(file("~/prog/tree-sitter-hocon/grammar.js")) +// ^ @keyword +//^ @keyword.import +// ^ @punctuation.bracket +// ^ @punctuation.bracket + override = true +// ^ @boolean +} + +it's: ${it's}. A ${HOCON} +// ^ @punctuation.special +// ^ @punctuation.special +// ^ @punctuation.special +// ^ @string +// ^ @string +// ^ @punctuation.special +// ^ @punctuation.special + +this.is.a."long.key" = null, +// ^ @punctuation.delimiter +// ^ @punctuation.delimiter +// ^ @punctuation.delimiter +// ^ @constant.builtin +week = 7 days +// ^ @number +// ^ @keyword + + diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/julia/test.jl b/pack/ant/start/nvim-treesitter/tests/query/highlights/julia/test.jl new file mode 100644 index 0000000..445efaa --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/julia/test.jl @@ -0,0 +1,26 @@ +function load_data(::Symbol; ::Int) :: Tuple +# <- @keyword.function +# ^ @function.call +# ^ @punctuation.bracket +# ^^ @punctuation.delimiter +# ^ @type.builtin +# ^ @punctuation.delimiter +# ^^ @punctuation.delimiter +# ^^^ @type.builtin +# ^ @punctuation.bracket +# ^^ @punctuation.delimiter +# ^ @type.builtin + dataset = CIFAR10(; Tx = Float32, split = split) +# ^^^^^^^ @variable +# ^ @operator +# ^ @function.call +# ^ @operator +# ^ @type.builtin + X = reshape(dataset.features[:, :, :, begin:n_obs], :, n_obs) # flattening the image pixels +# ^^^^^ @variable.builtin + y = categorical2onehot(dataset.targets[begin:n_obs], N_LABELS) +# ^^^^^ @variable.builtin + return X, y +# ^^^^^^ @keyword.return +end +# <- @keyword.function diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/latex/test.tex b/pack/ant/start/nvim-treesitter/tests/query/highlights/latex/test.tex new file mode 100644 index 0000000..9e65b90 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/latex/test.tex @@ -0,0 +1,33 @@ +% vim:ft=latex +% !TeX +% ^ @keyword.directive +%& filename +% ^ @keyword.directive + \begin{equation} \frac{4}{2} + 128 \text{hello} \sum_{n=1}^{\text{hi\_hi\^hi}} n \end{equation} +% ^ @markup.math ^ @none ^ @function + +\begin{equation} + a = b % Comment here +% ^ @comment +% ^ @markup.math +\end{equation} +\begin{equation} + a = b % Comment here +% ^ @comment + b = c +\end{equation} +\text{ +hi $here$ is some text % with a comment +% ^ @comment +% ^ @markup.math +} +\textbf{ +here is some text $5 + 2$ % with a comment +% ^ @comment +% ^ @markup.math +} +\textit{ +here is some text $5 + 2$ % with a comment +% ^ @comment +% ^ @markup.math +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/lua/test.lua b/pack/ant/start/nvim-treesitter/tests/query/highlights/lua/test.lua new file mode 100644 index 0000000..55818bb --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/lua/test.lua @@ -0,0 +1,18 @@ +-- luacheck: ignore +local a = { 1, 2, 3, 4, 5 } +-- ^ @number ^ @punctuation.bracket +-- ^ @variable + +local _ = next(a) +-- ^ @function.builtin +-- ^ @keyword + +_ = next(a) +-- ^ @function.builtin + +next(a) +-- ^ @function.builtin + +-- Checking for incorrect hlgroup of injected luap +string.match(s, "\0%d[^\n]+") +-- ^ @!constant diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/markdown/test.md b/pack/ant/start/nvim-treesitter/tests/query/highlights/markdown/test.md new file mode 100644 index 0000000..01acfcc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/markdown/test.md @@ -0,0 +1,28 @@ +# H1 + + +## H2 + + +- Item 1 +- Item 2 + + +1. Item 1 +2. Item 2 + + +----![image_description](https://example.com/image.jpg "awesome image title") + + + + + + + +[link_text](#local_reference "link go brr...") + + + + + diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/nix/test.nix b/pack/ant/start/nvim-treesitter/tests/query/highlights/nix/test.nix new file mode 100644 index 0000000..296a5a9 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/nix/test.nix @@ -0,0 +1,21 @@ +{ + func1 = param: builtins.readFile param; + # ^ @function + # ^ @variable.parameter + # ^ @constant.builtin + # ^ @function.builtin + func2 = { p1, p2 }: p2; + # ^ @function + # ^ @variable.parameter + readFile' = readFile; + # ^ @function.builtin + x = func1 ./path/to/file.nix; +# ^ @variable.member + # ^ @function.call + # ^ @string.special.path + hi = if true then 9 else throw "an error ${here + "string"}"; + # ^ @keyword.exception + # ^ @string + # ^ @variable + # ^ @string +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/pascal/test.pas b/pack/ant/start/nvim-treesitter/tests/query/highlights/pascal/test.pas new file mode 100644 index 0000000..3a6cc78 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/pascal/test.pas @@ -0,0 +1,39 @@ +program foobar; +// ^ @keyword + +var +// <- @keyword + foo: bar; +// ^ @variable +// ^ @type + foo: foo.bar; +// ^ @variable +// ^ @type +// ^ @type +// ^ @type +begin +// ^ @keyword + foo := bar; +// ^ @variable +// ^ @variable + foo; +// ^ @function + foo(); +// ^ @function + foo(bar(xyz)); +// ^ @function +// ^ @function +// ^ @variable + xx + yy; +// ^ @variable +// ^ @variable + xx := y + z + func(a, b, c); +// ^ @variable +// ^ @variable +// ^ @variable +// ^ @function +// ^ @variable +// ^ @variable +// ^ @variable +end. +// <- @keyword diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/php/keywords.php b/pack/ant/start/nvim-treesitter/tests/query/highlights/php/keywords.php new file mode 100644 index 0000000..6b938c4 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/php/keywords.php @@ -0,0 +1,97 @@ +foo(); +// ^^^^ @variable.builtin +// ^^^ @function.method.call + self::foo(); +// ^^^^ @variable.builtin +// ^^^ @function.call + static::foo(); +// ^^^^^^ @variable.builtin + parent::foo(); +// ^^^^^^ @variable.builtin + $this->foo; +// ^^^ @variable.member + $this->foo(a: 5); +// ^ @variable.parameter + A::$foo::$bar; +// ^^^ @variable.member +// ^^^ @variable.member + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/prisma/test.prisma b/pack/ant/start/nvim-treesitter/tests/query/highlights/prisma/test.prisma new file mode 100644 index 0000000..5517e9e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/prisma/test.prisma @@ -0,0 +1,63 @@ +generator client { +// ^ keyword + provider = "go run github.com/prisma/prisma-client-go" + // ^ variable +} + +datasource db { + provider = "postgresql" + // ^ string + url = env("DATABASE_URL") + // ^ function +} + +model User { + email String + // ^ type + username String @id + // ^ operator + password String + fullName String @map("full_name") + // ^ function + avatarUrl String @map("avatar_url") + about String? + // ^ type + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") + + @@map("user") +} + +model Reaction { + // ^ punctuation.bracket + id Int @id @default(autoincrement()) + // ^ punctuation.bracket + postId Int @map("post_id") + userId String @map("user_id") + type ReactionType + createdAt DateTime @default(now()) @map("created_at") + updatedAt DateTime @updatedAt @map("updated_at") + + post Post @relation(fields: [postId], references: [id]) + // ^ property + user User @relation(fields: [userId], references: [username]) + // ^ punctuation.bracket + + @@map("reaction") +} + +enum ReactionType { +// ^ keyword.type + LIKE + HAHA + SAD + ANGRY + // ^ constant +} + +view ReactionView { +// ^ keyword + id Int @unique + postId Int + userId String +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/python/fields.py b/pack/ant/start/nvim-treesitter/tests/query/highlights/python/fields.py new file mode 100644 index 0000000..deb2806 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/python/fields.py @@ -0,0 +1,12 @@ +class Fields: + def __init__(self, fields: list[int]) -> None: +# ^^^ @type.builtin +# ^^^^ @constant.builtin + self.fields = fields +# ^^^^^^ @variable.member + self.__dunderfield__ = None +# ^^^^^^^^^^^^^^^ @variable.member + self._FunKyFielD = 0 +# ^^^^^^^^^^^ @variable.member + self.NOT_A_FIELD = "IM NOT A FIELD" +# ^^^^^^^^^^^ @constant diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/python/future_import.py b/pack/ant/start/nvim-treesitter/tests/query/highlights/python/future_import.py new file mode 100644 index 0000000..6790b9b --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/python/future_import.py @@ -0,0 +1,4 @@ +from __future__ import print_function +# ^ @keyword.import +# ^ @constant.builtin +# ^ @keyword.import diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/python/pattern_matching.py b/pack/ant/start/nvim-treesitter/tests/query/highlights/python/pattern_matching.py new file mode 100644 index 0000000..2762781 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/python/pattern_matching.py @@ -0,0 +1,51 @@ +match command.split(): +# ^ @keyword.conditional + case ["quit"]: + # ^ @keyword.conditional + print("Goodbye!") + quit_game() + case ["look"]: + # ^ @keyword.conditional + current_room.describe() + case ["get", obj]: + # ^ @keyword.conditional + character.get(obj, current_room) + case ["go", direction]: + # ^ @keyword.conditional + current_room = current_room.neighbor(direction) + # The rest of your commands go here + +match command.split(): +# ^ @keyword.conditional + case ["drop", *objects]: + # ^ @keyword.conditional + for obj in objects: + character.drop(obj, current_room) + +match command.split(): +# ^ @keyword.conditional + case ["quit"]: ... # Code omitted for brevity + case ["go", direction]: pass + case ["drop", *objects]: pass + case _: + print(f"Sorry, I couldn't understand {command!r}") + # ^^ @@function.macro + +match command.split(): +# ^ @keyword.conditional + case ["north"] | ["go", "north"]: + # ^ @keyword.conditional + current_room = current_room.neighbor("north") + case ["get", obj] | ["pick", "up", obj] | ["pick", obj, "up"]: + # ^ @keyword.conditional + pass + +match = 2 +# ^ @variable +match, a = 2, 3 +# ^ @variable +match: int = secret +# ^ @variable +x, match: str = 2, "hey, what's up?" +# <- @variable +# ^ @variable diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/python/raise_from.py b/pack/ant/start/nvim-treesitter/tests/query/highlights/python/raise_from.py new file mode 100644 index 0000000..fb30f42 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/python/raise_from.py @@ -0,0 +1,6 @@ +try: + print(1 / 0) +except Exception: + raise RuntimeError from None + # ^ @keyword.exception + # ^ @keyword.exception diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/python/yield_from.py b/pack/ant/start/nvim-treesitter/tests/query/highlights/python/yield_from.py new file mode 100644 index 0000000..6ada002 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/python/yield_from.py @@ -0,0 +1,7 @@ +from foo import bar +# ^ @keyword.import +# ^ @keyword.import +def generator(): + yield from bar(42) + # ^ @keyword.return + # ^ @keyword.return diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/r/test.r b/pack/ant/start/nvim-treesitter/tests/query/highlights/r/test.r new file mode 100644 index 0000000..5fa36cc --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/r/test.r @@ -0,0 +1,47 @@ +init <- 1 +# ^ @variable +# ^ @operator +# ^ @number.float + +r"{(\1\2)}" -> `%r%` +# ^ @string +# ^ @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) +# ^ @variable.parameter +# ^ @string +# ^ @operator +# ^ @variable.member + +Lang$new(name = "r")$print() +# ^ @function.method.call + +for(i in 1:10) { +# <- @keyword.repeat +# ^ @keyword.repeat +} + +add <- function(a, b = 1, ...) { +# ^ @keyword.function +# ^ @variable.parameter +# ^ @variable.parameter +# ^ @constant.builtin + return(a + b) +# ^ @keyword.return +} + +base::letters +# ^ @module +# ^ @variable diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/rust/for.rs b/pack/ant/start/nvim-treesitter/tests/query/highlights/rust/for.rs new file mode 100644 index 0000000..e8c085f --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/rust/for.rs @@ -0,0 +1,15 @@ +struct Foo; + +// Issue https://github.com/nvim-treesitter/nvim-treesitter/issues/3641 +// Distinguish between for in loop or impl_item +impl Drop for Foo { + // ^ @keyword + fn drop(&mut self) {} +} + +fn main() { + for i in 0..128 { + // <- @keyword.repeat + println!("{i}"); + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/rust/super-crate-imports.rs b/pack/ant/start/nvim-treesitter/tests/query/highlights/rust/super-crate-imports.rs new file mode 100644 index 0000000..9326309 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/rust/super-crate-imports.rs @@ -0,0 +1,12 @@ +use crate::a; +// ^ @module +// ^ !keyword +use crate::{b, c}; +// ^ @module +// ^ !keyword +use super::a; +// ^ @module +// ^ !keyword +use super::{b, c}; +// ^ @module +// ^ !keyword diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/smali/baksmali_test_class.smali b/pack/ant/start/nvim-treesitter/tests/query/highlights/smali/baksmali_test_class.smali new file mode 100644 index 0000000..1d2a4cb --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/smali/baksmali_test_class.smali @@ -0,0 +1,261 @@ +.class public Lbaksmali/test/class; +# <- @keyword +# ^^^^^^ @keyword.modifier +.super Ljava/lang/Object; +# ^ @character.special +# ^^^^ @type.builtin +# ^ @punctuation.delimiter + +.source "baksmali_test_class.smali" +# <- @keyword.import + +.implements Lsome/interface; +.implements Lsome/other/interface; + + +.annotation build Lsome/annotation; +# ^^^^^ @keyword.modifier +# ^^^^ @type +# ^ @punctuation.delimiter + value1 = "test" +# ^^^^^^ @variable.member +# ^ @operator +# ^^^^^^ @string + value2 = .subannotation Lsome/annotation; + value1 = "test2" + value2 = Lsome/enum; + .end subannotation +.end annotation + +.annotation system Lsome/annotation; +.end annotation + + + +.field public static aStaticFieldWithoutAnInitializer:I +# ^ @punctuation.delimiter +# ^ @type.builtin + +.field public static longStaticField:J = 0x300000000L +# ^^^^^^^^^^^^ @number +.field public static longNegStaticField:J = -0x300000000L + +.field public static intStaticField:I = 0x70000000 +.field public static intNegStaticField:I = -500 + +.field public static shortStaticField:S = 500s +.field public static shortNegStaticField:S = -500s + +.field public static byteStaticField:B = 123t +.field public static byteNegStaticField:B = 0xAAt + +.field public static floatStaticField:F = 3.1415926f +# ^^^^^^^^^^ @number.float + +.field public static doubleStaticField:D = 3.141592653589793 + +.field public static charStaticField:C = 'a' +# ^^^ @character +.field public static charEscapedStaticField:C = '\n' +# ^^ @string.escape + +.field public static boolTrueStaticField:Z = true +# ^^^^ @boolean +.field public static boolFalseStaticField:Z = false + +.field public static typeStaticField:Ljava/lang/Class; = Lbaksmali/test/class; + +.field public static stringStaticField:Ljava/lang/String; = "test" +.field public static stringEscapedStaticField:Ljava/lang/String; = "test\ntest" + + +.field public static fieldStaticField:Ljava/lang/reflect/Field; = Lbaksmali/test/class;->fieldStaticField:Ljava/lang/reflect/Field; + +.field public static methodStaticField:Ljava/lang/reflect/Method; = Lbaksmali/test/class;->testMethod(ILjava/lang/String;)Ljava/lang/String; +# ^^ @punctuation.delimiter +# ^^^^^^^^^^ @function.method.call + +.field public static arrayStaticField:[I = {1, 2, 3, {1, 2, 3, 4}} +# ^ @punctuation.special +# ^ @punctuation.bracket +# ^ @punctuation.delimiter + +.field public static enumStaticField:Lsome/enum; = .enum Lsome/enum;->someEnumValue:Lsome/enum; +# ^^^^^^^^^^^^^ @variable.member + +.field public static annotationStaticField:Lsome/annotation; = .subannotation Lsome/annotation; + value1 = "test" + value2 = .subannotation Lsome/annotation; + value1 = "test2" + value2 = Lsome/enum; + .end subannotation +.end subannotation + +.field public static staticFieldWithAnnotation:I + .annotation runtime La/field/annotation; +# ^^^^^^^ @keyword.modifier + this = "is" + a = "test" + .end annotation + .annotation runtime Lorg/junit/Test; + .end annotation +.end field + +.field public instanceField:Ljava/lang/String; + + + +.method public constructor ()V +# <- @keyword.function +# ^^^^^^^^^^^ @constructor +# ^^^^^^ @constructor + .registers 1 + invoke-direct {p0}, Ljava/lang/Object;->()V +# ^^^^^^^^^^^^^ @keyword.operator +# ^^ @variable.parameter.builtin + return-void +# ^^^^^^^^^^^ @keyword.return +.end method + +.method public testMethod(ILjava/lang/String;)Ljava/lang/String; +# ^^^^^^^^^^ @function.method + .registers 3 + .annotation runtime Lorg/junit/Test; + .end annotation + .annotation system Lyet/another/annotation; + somevalue = 1234 + anothervalue = 3.14159 + .end annotation + + const-string v0, "testing\n123" +# ^^ @variable.builtin + + goto switch: +# ^^^^^^^ @label + + sget v0, Lbaksmali/test/class;->staticField:I + + switch: + packed-switch v0, pswitch: + + try_start: + const/4 v0, 7 + const v0, 10 + nop + try_end: + .catch Ljava/lang/Exception; {try_start: .. try_end:} handler: +# ^^^^^^ @keyword.exception + .catchall {try_start: .. try_end:} handler2: +# ^^^^^^^^^ @keyword.exception +# ^^ @operator + + handler: + + Label10: + Label11: + Label12: + Label13: + return-object v0 + + + + .array-data 4 + 1 2 3 4 5 6 200 + .end array-data + + pswitch: + .packed-switch 10 + Label10: + Label11: + Label12: + Label13: + .end packed-switch + + handler2: + + return-void + +.end method + +.method public abstract testMethod2()V + .annotation runtime Lsome/annotation; + subannotation = .subannotation Lsome/other/annotation; + value = "value" + .end subannotation + .end annotation + .annotation runtime Lorg/junit/Test; + .end annotation +.end method + + +.method public tryTest()V + .registers 1 + + handler: + nop + + + try_start: + const/4 v0, 7 + const v0, 10 + nop + try_end: + .catch Ljava/lang/Exception; {try_start: .. try_end:} handler: +.end method + + +.method public debugTest(IIIII)V + .registers 10 + + .parameter "Blah" + .parameter + .parameter "BlahWithAnnotations" + .annotation runtime Lsome/annotation; + something = "some value" + somethingelse = 1234 + .end annotation + .annotation runtime La/second/annotation; + .end annotation + .end parameter + .parameter + .annotation runtime Lsome/annotation; + something = "some value" + somethingelse = 1234 + .end annotation + .end parameter + .parameter "LastParam" + + .prologue +# ^^^^^^^^^ @keyword + + nop + nop + + .source "somefile.java" +# ^^^^^^^ @keyword.import + .line 101 +# ^^^ @string.special + + nop + + + .line 50 + + .local v0, aNumber:I +# ^^^^^^^ @variable + const v0, 1234 + .end local v0 + + .source "someotherfile.java" + .line 900 + + const-string v0, "1234" + + .restart local v0 + const v0, 6789 + .end local v0 + + .epilogue +# ^^^^^^^^^ @keyword + +.end method diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/solidity/test.sol b/pack/ant/start/nvim-treesitter/tests/query/highlights/solidity/test.sol new file mode 100644 index 0000000..52334bd --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/solidity/test.sol @@ -0,0 +1,186 @@ +// Example contract from official documentation at https://github.com/ethereum/solidity/blob/v0.8.12/docs/examples/voting.rst + +// SPDX-License-Identifier: GPL-3.0 +// ^ @comment +pragma solidity >=0.7.0 <0.9.0; +// ^ @keyword.directive +// ^ @keyword.directive + +import * as something from "anotherFile"; +// ^ ^ ^ @keyword.import + +/// @title Voting with delegation. +// <- @comment +contract Ballot { +// ^keyword.type +// ^ @type + // This declares a new complex type which will + // be used for variables later. + // It will represent a single voter. + struct Voter { +// ^ @type + uint weight; // weight is accumulated by delegation +// ^ @type.builtin +// ^ @variable.member + bool voted; // if true, that person already voted + address delegate; // person delegated to + uint vote; // index of the voted proposal + } + + // This is a type for a single proposal. + struct Proposal { + bytes32 name; // short name (up to 32 bytes) + uint voteCount; // number of accumulated votes + } + + address public chairperson; +// ^ @type.builtin + + // This declares a state variable that + // stores a `Voter` struct for each possible address. + mapping(address => Voter) public voters; +// ^ ^ @punctuation.bracket +// ^ @punctuation.delimiter + + // A dynamically-sized array of `Proposal` structs. + Proposal[] public proposals; + + enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill } +// ^ @constant + + /// Create a new ballot to choose one of `proposalNames`. + constructor(bytes32[] memory proposalNames) { +// ^ @constructor + chairperson = msg.sender; + voters[chairperson].weight = 1; + + // For each of the provided proposal names, + // create a new proposal object and add it + // to the end of the array. + for (uint i = 0; i < proposalNames.length; i++) { + // `Proposal({...})` creates a temporary + // Proposal object and `proposals.push(...)` + // appends it to the end of `proposals`. + proposals.push(Proposal({ + name: proposalNames[i], +// ^ @variable.member + voteCount: 0 + })); + } + } + + // Give `voter` the right to vote on this ballot. + // May only be called by `chairperson`. + function giveRightToVote(address voter) external { +// ^ @keyword.function +// ^ @function +// ^ @variable.parameter + // If the first argument of `require` evaluates + // to `false`, execution terminates and all + // changes to the state and to Ether balances + // are reverted. + // This used to consume all gas in old EVM versions, but + // not anymore. + // It is often a good idea to use `require` to check if + // functions are called correctly. + // As a second argument, you can also provide an + // explanation about what went wrong. + require( + msg.sender == chairperson, + "Only chairperson can give right to vote." + ); + require( + !voters[voter].voted, + "The voter already voted." + ); + require(voters[voter].weight == 0); + voters[voter].weight = 1; + } + + /// Delegate your vote to the voter `to`. + function delegate(address to) external { + // assigns reference + Voter storage sender = voters[msg.sender]; + require(!sender.voted, "You already voted."); + + require(to != msg.sender, "Self-delegation is disallowed."); + + // Forward the delegation as long as + // `to` also delegated. + // In general, such loops are very dangerous, + // because if they run too long, they might + // need more gas than is available in a block. + // In this case, the delegation will not be executed, + // but in other situations, such loops might + // cause a contract to get "stuck" completely. + while (voters[to].delegate != address(0)) { + to = voters[to].delegate; + + // We found a loop in the delegation, not allowed. + require(to != msg.sender, "Found loop in delegation."); + } + + // Since `sender` is a reference, this + // modifies `voters[msg.sender].voted` + Voter storage delegate_ = voters[to]; + + // Voters cannot delegate to wallets that cannot vote. + require(delegate_.weight >= 1); + sender.voted = true; + sender.delegate = to; + if (delegate_.voted) { + // If the delegate already voted, + // directly add to the number of votes + proposals[delegate_.vote].voteCount += sender.weight; + } else { + // If the delegate did not vote yet, + // add to her weight. + delegate_.weight += sender.weight; + } + } + + /// Give your vote (including votes delegated to you) + /// to proposal `proposals[proposal].name`. + function vote(uint proposal) external { + Voter storage sender = voters[msg.sender]; + require(sender.weight != 0, "Has no right to vote"); + require(!sender.voted, "Already voted."); + sender.voted = true; + sender.vote = proposal; + + // If `proposal` is out of the range of the array, + // this will throw automatically and revert all + // changes. + proposals[proposal].voteCount += sender.weight; + } + + /// @dev Computes the winning proposal taking all + /// previous votes into account. + function winningProposal() public view + returns (uint winningProposal_) + { + uint winningVoteCount = 0; + for (uint p = 0; p < proposals.length; p++) { + if (proposals[p].voteCount > winningVoteCount) { + winningVoteCount = proposals[p].voteCount; + winningProposal_ = p; + } + } + } + + // Calls winningProposal() function to get the index + // of the winner contained in the proposals array and then + // returns the name of the winner + function winnerName() external view + returns (bytes32 winnerName_) + { + winnerName_ = proposals[winningProposal()].name; + } +} + +contract Another { + Ballot b = new Ballot(new bytes32[](1)); +// ^ @keyword.operator +} + +// vim:ft=solidity diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/t32/comments.cmm b/pack/ant/start/nvim-treesitter/tests/query/highlights/t32/comments.cmm new file mode 100644 index 0000000..e36f7e6 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/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/pack/ant/start/nvim-treesitter/tests/query/highlights/t32/keywords.cmm b/pack/ant/start/nvim-treesitter/tests/query/highlights/t32/keywords.cmm new file mode 100644 index 0000000..d1516eb --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/t32/keywords.cmm @@ -0,0 +1,125 @@ +PRIVATE &password +; <- @keyword +; ^ @variable.builtin +ENTRY &password +; <- @keyword +; ^ @variable.parameter + +ENTRY %LINE &salt +; <- @keyword +; ^ @constant.builtin +; ^ @variable.parameter + +IF "&password"=="" +; <- @keyword.conditional +; ^ @string +; ^ @variable.builtin +; ^ @operator +( + ECHO "Failed to provide password." + ENDDO +; ^ @keyword.return +) +ELSE +; <- @keyword.conditional +( + PRIVATE &pass + + &pass=FALSE() +; ^ @function.builtin + WHILE !&pass +; ^ @operator + ( + GOSUB verify_password "&password" +; ^ @function.call + RETURNVALUES &pass +; ^ @variable.parameter + WAIT 10.ms +; ^ @number.float + ) + + IF !&pass + GOTO fail +; ^ @label + ELSE IF &debug +; ^ @keyword.conditional +; ^ @keyword.conditional + ( + 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.builtin +WinPOS 0% 50% 100% 35% +; ^ @number.float +COVerage.ListFunc + +ENDDO + + +fail: +; <- @label + PRINT %ERROR "Password verification failed." + END +; ^ @keyword.return + + +verify_password: +; <- @function +( + PARAMETERS &password +; ^ @variable.parameter + + SYStem.Option.KEYCODE "&password" + SYStem.JtagClock 1kHz +; ^ @number.float + SYStem.Mode.Attach + + Data.Set N: EAXI:0x34000000 %Long 0x34000100 0x34000021 /verify +; ^ @constant.builtin +; ^ @constant.builtin +; ^ @number +; ^ @constant.builtin +; ^ @number +; ^ @constant.builtin + + RETURN TRUE() +; ^ @keyword.return +) + + +SUBROUTINE start_debug +; <- @keyword.function +; ^ @function +( + COVerage.ListModule %MULTI.OBC \sieve +; ^ @keyword +; ^ @constant.builtin +; ^ @string.special.symbol + + Var.DRAW flags[0..16] /Alternate 3 +; ^ @keyword +; ^ @variable +; ^ @constant.builtin +; ^ @number + + Go main + RETURN +; ^ @keyword.return +) + +// vim: set ft=t32: diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/t32/literals.cmm b/pack/ant/start/nvim-treesitter/tests/query/highlights/t32/literals.cmm new file mode 100644 index 0000000..a9d72e4 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/t32/literals.cmm @@ -0,0 +1,39 @@ +WinPOS ,,1000.,,,,myWatchWindow +; ^ @number + +PRinTer.OPEN "~~~/varwatch.txt" ASCIIE +; ^ @string + +sYmbol.NEW _InitialSP 0x34000100 +; ^ @number + +DO ~~~~/test.cmm +; ^ @string.special.path + +WAIT 1.ns +; ^ @number.float + +SYStem.JtagClock 100.GHZ +; ^ @number.float + +DATA.SET P:&HEAD+0x4 %LONG DATA.LONG(EA:&HEAD+0x4)&0xFFFFFF +; ^ @constant.builtin + +List `main` +; ^ @string.special.symbol + +&range = 'a'--'z'||'0'--'9' +; ^ @character +; ^ @operator +; ^ @character + +Data.Set N: 0xffff800000 0y0011xx01xx&&a +; ^ @constant.builtin +; ^ @number +; ^ @number +; ^ @operator + +WinPOS 0% 85% 100% 15% +; ^ @number.float + +// vim: set ft=t32: diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/t32/var.cmm b/pack/ant/start/nvim-treesitter/tests/query/highlights/t32/var.cmm new file mode 100644 index 0000000..0deed99 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/t32/var.cmm @@ -0,0 +1,75 @@ +Var.NEWGLOBAL char[4][32] \myarr +; <- @keyword +; ^ @type.builtin +; ^ @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 +; ^ @operator + &i=&i+1. +) + +Var.NEWLOCAL \x +; <- @keyword +; ^ @variable.builtin +Var.set \x=func3(5,3) +; ^ @variable.builtin +; ^ @function.call +; ^ @number +PRINT Var.VALUE(\x) +; ^ @variable.builtin +PRINT Var.VALUE('a') +; ^ @character +Var.Assign (*ap)[2..4] = &a +; ^ @variable +; ^ @variable +Var.Assign sp = &s.n+offset +; ^ @variable +; ^ @variable +; ^ @variable.member +; ^ @variable +Var.Assign padd = (CAddition const * volatile)&d +; ^ @variable +; ^ @type +; ^ @keyword.modifier +; ^ @keyword.modifier +; ^ @variable +Var.Assign e1 = (enum e2)&e +; ^ @variable +; ^ @keyword.type +; ^ @type +; ^ @variable +Var.Assign *vector = (struct Vector3d*)&acceleration +; ^ @variable +; ^ @keyword.type +; ^ @type +; ^ @variable +Var.Assign z = (union foo)x +; ^ @variable +; ^ @keyword.type +; ^ @type +; ^ @variable +Var.Assign b = -a +; ^ @variable +; ^ @variable +Var.Assign c = i++ +; ^ @variable +; ^ @variable +Var.Assign d = sizeof(int) +; ^ @variable +; ^ @keyword.operator +; ^ @type.builtin +Var.call strcmp(key,buffer) +; ^ @function.call +; ^ @variable +; ^ @variable + +// vim: set ft=t32: diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/built-ins.tig b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/built-ins.tig new file mode 100644 index 0000000..9aa6494 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/built-ins.tig @@ -0,0 +1,44 @@ +let + var a := exit(0) + /* ^ @function.builtin */ + + primitive exit(ret: int) /* Shadowing the prelude-included built-in */ + /* ^ @type.builtin */ + + var b := exit(0) + /* ^ @function.builtin */ + + type int = string /* Shadowing the built-in type */ + /* ^ @type.builtin */ + + var c : int := "This is an \"int\"" + /* ^ @type.builtin (not sure why it isn't 'type')*/ + + var d : Object := nil + /* ^ @type.builtin */ + + type Object = int + + var self := "self" +in + let + var c : int := "This is an int" + /* ^ @type.builtin (not sure why it isn't 'type')*/ + var d : Object := "This is an object" + /* ^ @type.builtin (not sure why it isn't 'type')*/ + in + end; + + exit(1); + /* <- @function.builtin */ + + print("shadowing is fun"); + /* <- @function.builtin */ + + self; + /* <- @variable.builtin */ + + b := print + /* ^ @variable */ +end +/* vim: set ft=tiger: */ diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/comment.tig b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/comment.tig new file mode 100644 index 0000000..9323dba --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/comment.tig @@ -0,0 +1,6 @@ +/* This is /* a nested */ comment */ +/* <- @comment + ^ @comment + ^ @comment + */ +/* vim: set ft=tiger: */ diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/functions.tig b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/functions.tig new file mode 100644 index 0000000..706f199 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/functions.tig @@ -0,0 +1,9 @@ +primitive print(s: string) +/* ^ @function */ +/* ^ @variable.parameter */ + +function func(a: int) : int = (print("Hello World!"); a) +/* ^ @function */ +/* ^ @variable.parameter */ +/* ^ @function.builtin */ +/* vim: set ft=tiger: */ diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/identifiers.tig b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/identifiers.tig new file mode 100644 index 0000000..8d2207d --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/identifiers.tig @@ -0,0 +1,30 @@ +type int = int +/* ^ @variable */ +/* ^ @type.builtin */ + +type int_array = array of int +/* ^ @type.builtin */ + +type record = {a: int, b: string} +/* ^ @variable.member */ +/* ^ @type.builtin */ +/* ^ @variable.member */ +/* ^ @type.builtin */ + +var record := record {a = 12, b = "27"} +/* ^ @variable */ +/* ^ @type */ +/* ^ @variable.member */ +/* ^ @variable.member */ + +var array := int_array[12] of 27; +/* ^ @variable */ +/* ^ @type */ + +primitive func(a: int, b: string) : array +/* ^ @variable.parameter */ +/* ^ @type.builtin */ +/* ^ @variable.parameter */ +/* ^ @type.builtin */ +/* ^ @type */ +/* vim: set ft=tiger: */ diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/imports.tig b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/imports.tig new file mode 100644 index 0000000..1c7ce30 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/imports.tig @@ -0,0 +1,4 @@ +import "lib.tih" +/* <- @keyword.import */ +/* ^ @string.special.path */ +/* vim: set ft=tiger: */ diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/keywords.tig b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/keywords.tig new file mode 100644 index 0000000..c92cd92 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/keywords.tig @@ -0,0 +1,42 @@ +let +/* <- @keyword */ + + var a := 12 + /* <- @keyword */ + + function f() : int = a + /* <- @keyword.function */ + primitive g() + /* <- @keyword.function */ + + import "lib.tih" + /* <- @keyword.import */ + + type array_of_int = array of int + /* <- @keyword */ + /* ^ @keyword */ + /* ^ @keyword */ + +in +/* <- @keyword */ + + 12; + + if 12 then 27 else 42; + /* <- @keyword */ + /* ^ @keyword */ + /* ^ @keyword */ + + for i := 12 to 27 do 42; + /* <- @keyword.repeat */ + /* ^ @keyword.repeat */ + /* ^ @keyword.repeat */ + + while 12 do break + /* <- @keyword.repeat */ + /* ^ @keyword.repeat */ + /* ^ @keyword */ + +end +/* <- @keyword */ +/* vim: set ft=tiger: */ diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/literals.tig b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/literals.tig new file mode 100644 index 0000000..46f3c86 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/literals.tig @@ -0,0 +1,9 @@ +nil +/* <- @constant.builtin */ +42 +/* <- @number */ +"Hello World!\n" +/* <- @string + ^ @string.escape +*/ +/* vim: set ft=tiger: */ diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/meta-variables.tig b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/meta-variables.tig new file mode 100644 index 0000000..1b2c6c9 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/meta-variables.tig @@ -0,0 +1,14 @@ +let + _chunks(42) + /* <- @keyword */ + +in + _lvalue(12) : _namety(42) := _cast("I'm So Meta Even This Acronym", string); + /* <- @keyword */ + /* ^ @keyword */ + /* ^ @keyword */ + + _exp(42) + /* <- @keyword */ +end +/* vim: set ft=tiger: */ diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/object-oriented.tig b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/object-oriented.tig new file mode 100644 index 0000000..5c48c54 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/object-oriented.tig @@ -0,0 +1,29 @@ +let + class A extends Object {} + /* <- @keyword.type */ + /* ^ @keyword */ + /* ^ @type.builtin */ + + type B = class extends A { + /* ^ @keyword.type */ + /* ^ @keyword */ + /* ^ @type */ + + var a := 12 + + method meth() : int = self.a + /* <- @keyword.function */ + /* ^ @function.method */ + /* ^ @variable.builtin */ + } + + var object := new B + /* ^ @keyword.operator */ +in + object.a := 27; + /* ^ @variable.member */ + + object.meth() + /* ^ @function.method */ +end +/* vim: set ft=tiger: */ diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/operators.tig b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/operators.tig new file mode 100644 index 0000000..d803af7 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/tiger/operators.tig @@ -0,0 +1,49 @@ +let + var a : int := 42 + /* ^ @punctuation.delimiter */ + /* ^ @operator */ +in + ( + /* <- @punctuation.bracket */ + + -1 | 2 & 3 + 4 * 5; + /* <- @operator */ + /* ^ @operator */ + /* ^ @operator */ + /* ^ @operator */ + /* ^ @operator */ + /* ^ @punctuation.delimiter */ + + 12 >= 27; + /* ^ @operator */ + 12 <= 27; + /* ^ @operator */ + 12 = 27; + /* ^ @operator */ + 12 <> 27; + /* ^ @operator */ + 12 < 27; + /* ^ @operator */ + 12 > 27; + /* ^ @operator */ + + record.field; + /* ^ @punctuation.delimiter */ + + func(a, b); + /* ^ @punctuation.bracket */ + /* ^ @punctuation.bracket */ + /* ^ @punctuation.delimiter */ + + record_type { }; + /* ^ @punctuation.bracket */ + /* ^ @punctuation.bracket */ + + array[42] + /* ^ @punctuation.bracket */ + /* ^ @punctuation.bracket */ + + ) + /* <- @punctuation.bracket */ +end +/* vim: set ft=tiger: */ diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/typescript/as.ts b/pack/ant/start/nvim-treesitter/tests/query/highlights/typescript/as.ts new file mode 100644 index 0000000..30be1ff --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/typescript/as.ts @@ -0,0 +1,8 @@ +import * as foo from 'foo'; +// ^ @keyword.import + +export { foo as bar }; +// ^ @keyword.import + +const n = 5 as number; +// ^ @keyword.operator diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/usd/prims.usda b/pack/ant/start/nvim-treesitter/tests/query/highlights/usd/prims.usda new file mode 100644 index 0000000..da9a5d6 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/usd/prims.usda @@ -0,0 +1,118 @@ +def Xform "cube" ( + assetInfo = { + # <- @keyword + asset[] payloadAssetDependencies = [@fizz.usd@, @buzz.usd@] + # <- @type + # ^ @keyword + # ^ @string.special.url + # ^ @string.special.url + } +) +{ +} + +def "root" ( + add references = @foo.usda@ (offset = 1; scale = 2.0) + # <- @string.special.url + # ^ @string.special + # ^ @keyword + # ^ @number + # ^ @punctuation.delimiter + # ^ @keyword + # ^ @number.float +) +{ +} + +def "World" +{ + over "points" ( + clips = { + # <- @keyword + dictionary default = { + # <- @type + # ^ @variable + double2[] times = [(101, 101), (102, 102)] + # <- @type + # ^ @keyword + # ^ @number + } + } + ) + { + } +} + +def Xform "torch_2" ( + payload = @./torch.usda@ + kind = "model" +) +{ + // Pre-published light list + # <- @comment + rel lightList = [ ] # inline comment + # ^ @comment + token lightList:cacheBehavior = "consumeAndContinue" + + double3 xformOp:translate = (1, 0, 0.5) + uniform token[] xformOpOrder = ["xformOp:translate"] +} + +def "foo" ( + "some comment" + # <- @comment.documentation +) +{ +} + +def "foo" ( + # inline comment + "actual in-description comment" + # <- @comment.documentation +) +{ +} + +def "foo" ( + add references = @foo.usda@ + # <- @function.call + append references = @foo.usda@ + # <- @function.call + delete references = @foo.usda@ + # <- @function.call + reorder references = [@foo.usda@] + # <- @function.call + + references = [@foo.usda@] # explicit +) +{ +} + +over "Parent" ( + prepend references = [, @./ref.usda@] + # <- @function.call + # ^ @keyword + # ^ @string.special + # ^ @string.special.url + # ^ @string.special +) +{ +} + +def "foo" +{ + float value.timeSamples = { + # <- @type + # ^ @variable + # ^ @property + -414: 14.4 + # <- @number + # ^ @number.float + 10: 201.0, + # <- @number + # ^ @number.float + 10.123: 201.0123, + # <- @number.float + # ^ @number.float + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/usd/properties.usda b/pack/ant/start/nvim-treesitter/tests/query/highlights/usd/properties.usda new file mode 100644 index 0000000..790ccfa --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/usd/properties.usda @@ -0,0 +1,21 @@ +dictionary foo = {} +# <- @type +half[] foo = [2, 1, 2] +# <- @type +string foo = "something" +# <- @type +timecode time = 1.0 +# <- @type +token[] purpose = ["default", "render"] +# <- @type + +rel material:binding:collection:Erasers = None +# <- @type +# ^ @module +# ^ @punctuation.delimiter +# ^ @module +# ^ @punctuation.delimiter +# ^ @module +# ^ @punctuation.delimiter +# ^ @variable +# ^ @constant.builtin diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/usd/subLayers.usda b/pack/ant/start/nvim-treesitter/tests/query/highlights/usd/subLayers.usda new file mode 100644 index 0000000..ddd1dd7 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/usd/subLayers.usda @@ -0,0 +1,9 @@ +#usda 1.0 +( + subLayers = [ + # <- @keyword + @./model_sub.usda@ (offset = 1) + # <- @string.special.url + # ^ @keyword + ] +) diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/wing/class.w b/pack/ant/start/nvim-treesitter/tests/query/highlights/wing/class.w new file mode 100644 index 0000000..1507d75 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/wing/class.w @@ -0,0 +1,21 @@ +bring cloud; +// <- @keyword.import +// ^ @module + +class Foo { +// <- @keyword.type +// ^ @type +// ^ @punctuation.bracket + name: str; +//^ @property +// ^ @type.builtin +// ^ @punctuation.delimiter + new(name: str) { +//^ @keyword +// ^ @variable + this.name = name; +// ^ @punctuation.delimiter +// ^ @variable.member +// ^ @operator + } +} diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/wing/nested_method.w b/pack/ant/start/nvim-treesitter/tests/query/highlights/wing/nested_method.w new file mode 100644 index 0000000..080d297 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/wing/nested_method.w @@ -0,0 +1,4 @@ +test1.test2.test3(); +// <- @variable +// ^ @variable.member +// ^ @function.method.call diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights/xhp-intro.hack b/pack/ant/start/nvim-treesitter/tests/query/highlights/xhp-intro.hack new file mode 100644 index 0000000..0f8cffe --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights/xhp-intro.hack @@ -0,0 +1,46 @@ +// From https://docs.hhvm.com/hack/XHP/introduction (MIT licensed) + +use namespace Facebook\XHP\Core as x; +use type Facebook\XHP\HTML\{XHPHTMLHelpers, a, form}; + + +final xhp class a_post extends x\element { +// ^ @keyword.modifier +// ^ @keyword.modifier +// ^ @keyword + use XHPHTMLHelpers; + + attribute string href @required; + // ^ @attribute + attribute string target; + // ^ @keyword + + <<__Override>> + protected async function renderAsync(): Awaitable { + $id = $this->getID(); + + $anchor = {$this->getChildren()}; + // ^ @tag.delimiter + // ^ @tag + $form = ( +
:href} + target={$this->:target} + class="postLink"> + {$anchor} + + ); + + $anchor->setAttribute( + 'onclick', + 'document.getElementById("'.$id.'").submit(); return false;', + ); + $anchor->setAttribute('href', '#'); + // ^ @function.method.call + + return $form; + } +} + diff --git a/pack/ant/start/nvim-treesitter/tests/query/highlights_spec.lua b/pack/ant/start/nvim-treesitter/tests/query/highlights_spec.lua new file mode 100644 index 0000000..3bb03d4 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/highlights_spec.lua @@ -0,0 +1,125 @@ +local highlighter = require "vim.treesitter.highlighter" +local parsers = require "nvim-treesitter.parsers" +local ts = vim.treesitter + +local COMMENT_NODES = { + markdown = "html_block", + haskell = "haddock", +} + +local function check_assertions(file) + local buf = vim.fn.bufadd(file) + vim.fn.bufload(file) + local lang = parsers.get_buf_lang(buf) + assert.same( + 1, + vim.fn.executable "highlight-assertions", + '"highlight-assertions" not executable!' + .. ' Get it via "cargo install --git https://github.com/theHamsta/highlight-assertions"' + ) + local comment_node = COMMENT_NODES[lang] or "comment" + local assertions = vim.fn.json_decode( + vim.fn.system( + "highlight-assertions -p '" + .. vim.api.nvim_get_runtime_file("parser/" .. lang .. ".so", false)[1] + .. "' -s '" + .. file + .. "' -c " + .. comment_node + ) + ) + local parser = parsers.get_parser(buf, lang) + parser:parse(true) + + local self = highlighter.new(parser, {}) + + assert.True(#assertions > 0, "No assertions detected!") + for _, assertion in ipairs(assertions) do + local row = assertion.position.row + local col = assertion.position.column + + local captures = {} + local highlights = {} + self:prepare_highlight_states(row, row + 1) + self:for_each_highlight_state(function(state) + if not state.tstree then + return + end + + local root = state.tstree:root() + local root_start_row, _, root_end_row, _ = root:range() + + -- Only worry about trees within the line range + if root_start_row > row or root_end_row < row then + return + end + + local query = state.highlighter_query + + -- Some injected languages may not have highlight queries. + if not query:query() then + return + end + + local iter = query:query():iter_captures(root, self.bufnr, row, row + 1) + + for capture, node, _ in iter do + local hl = query:get_hl_from_capture(capture) + assert.is.truthy(hl) + + assert.Truthy(node) + assert.is.number(row) + assert.is.number(col) + if hl and ts.is_in_node_range(node, row, col) then + local c = query._query.captures[capture] -- name of the capture in the query + if c ~= nil and c ~= "spell" and c ~= "conceal" then + captures[c] = true + highlights[c] = true + end + end + end + end, true) + 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 + +describe("highlight queries", function() + local files = vim.fn.split(vim.fn.glob "tests/query/highlights/**/*.*") + for _, file in ipairs(files) do + it(file, function() + check_assertions(file) + end) + end +end) diff --git a/pack/ant/start/nvim-treesitter/tests/query/injection_spec.lua b/pack/ant/start/nvim-treesitter/tests/query/injection_spec.lua new file mode 100644 index 0000000..95ad12e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/injection_spec.lua @@ -0,0 +1,85 @@ +require "nvim-treesitter.highlight" -- yes, this is necessary to set the hlmap +local configs = require "nvim-treesitter.configs" +local parsers = require "nvim-treesitter.parsers" +local ts = vim.treesitter + +local function check_assertions(file) + local buf = vim.fn.bufadd(file) + vim.fn.bufload(file) + local lang = parsers.get_buf_lang(buf) + assert.same( + 1, + vim.fn.executable "highlight-assertions", + '"highlight-assertions" not executable!' + .. ' Get it via "cargo install --git https://github.com/theHamsta/highlight-assertions"' + ) + local assertions = vim.fn.json_decode( + vim.fn.system( + "highlight-assertions -p '" .. configs.get_parser_install_dir() .. "/" .. lang .. ".so'" .. " -s '" .. file .. "'" + ) + ) + local parser = parsers.get_parser(buf, lang) + + local self = parser + local top_level_root = parser:parse(true)[1]:root() + + for _, assertion in ipairs(assertions) do + local row = assertion.position.row + local col = assertion.position.column + + local neg_assert = assertion.expected_capture_name:match "^!" + assertion.expected_capture_name = neg_assert and assertion.expected_capture_name:sub(2) + or assertion.expected_capture_name + local found = false + self:for_each_tree(function(tstree, tree) + if not tstree then + return + end + local root = tstree:root() + --- If there are multiple tree with the smallest range possible + --- Check all of them to see if they fit or not + if not ts.is_in_node_range(root, row, col) or root == top_level_root then + return + end + if assertion.expected_capture_name == tree:lang() then + found = true + end + end, true) + if neg_assert then + assert.False( + found, + "Error in at " + .. file + .. ":" + .. (row + 1) + .. ":" + .. (col + 1) + .. ': expected "' + .. assertion.expected_capture_name + .. '" not to be injected here!' + ) + else + assert.True( + found, + "Error in at " + .. file + .. ":" + .. (row + 1) + .. ":" + .. (col + 1) + .. ': expected "' + .. assertion.expected_capture_name + .. '" to be injected here!' + ) + end + end +end + +describe("injections", function() + local files = vim.fn.split(vim.fn.glob "tests/query/injections/**/*.*") + for _, file in ipairs(files) do + it(file, function() + check_assertions(file) + end) + end +end) diff --git a/pack/ant/start/nvim-treesitter/tests/query/injections/cuda/macro-self-injection.cu b/pack/ant/start/nvim-treesitter/tests/query/injections/cuda/macro-self-injection.cu new file mode 100644 index 0000000..a911842 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/injections/cuda/macro-self-injection.cu @@ -0,0 +1,2 @@ +#define FOO(X,Y) X + Y +// ^ @cuda diff --git a/pack/ant/start/nvim-treesitter/tests/query/injections/dockerfile/bash-on-run-instructions.dockerfile b/pack/ant/start/nvim-treesitter/tests/query/injections/dockerfile/bash-on-run-instructions.dockerfile new file mode 100644 index 0000000..00621f1 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/injections/dockerfile/bash-on-run-instructions.dockerfile @@ -0,0 +1,6 @@ +FROM foo +RUN bar +# ^ @bash +RUN \ + baz +# ^ @bash diff --git a/pack/ant/start/nvim-treesitter/tests/query/injections/ecma/ecma-test-injections.js b/pack/ant/start/nvim-treesitter/tests/query/injections/ecma/ecma-test-injections.js new file mode 100644 index 0000000..16ddd3c --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/injections/ecma/ecma-test-injections.js @@ -0,0 +1,9 @@ +html`

`; + // ^ @html +html(`

`); + // ^ @html +svg`

`; + // ^ @html +svg(`

`); + // ^ @html + diff --git a/pack/ant/start/nvim-treesitter/tests/query/injections/html/test-html-injections.html b/pack/ant/start/nvim-treesitter/tests/query/injections/html/test-html-injections.html new file mode 100644 index 0000000..0df3bd4 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/injections/html/test-html-injections.html @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + Test div to test css injections for style attributes +
+ + + + + + + + diff --git a/pack/ant/start/nvim-treesitter/tests/query/injections/query/test-query-injections.scm b/pack/ant/start/nvim-treesitter/tests/query/injections/query/test-query-injections.scm new file mode 100644 index 0000000..f382edd --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/injections/query/test-query-injections.scm @@ -0,0 +1,27 @@ +; vim: ft=query +; format-ignore +(((symbol) @constant + (#not-lua-match? @constant "^_*[A-Z][A-Z0-9_]*$")) +; ^ @luap +) + +; format-ignore +(((tag + (attributes + (attribute + (attribute_name) @keyword))) + (#match? @keyword "^(:|v-bind|v-|\\@)")) +; ^ @regex +) + +((comment) @injection.language + . + [ + (string_expression + (string_fragment) @injection.content) + (indented_string_expression + (string_fragment) @injection.content) + ] + (#gsub! @injection.language "#%s*([%w%p]+)%s*" "%1") + ; ^ @luap + (#set! injection.combined)) diff --git a/pack/ant/start/nvim-treesitter/tests/query/injections/svelte/test-svelte-injections.svelte b/pack/ant/start/nvim-treesitter/tests/query/injections/svelte/test-svelte-injections.svelte new file mode 100644 index 0000000..ea88aa6 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/injections/svelte/test-svelte-injections.svelte @@ -0,0 +1,22 @@ + + + + + + + + + + + + +
+

Test file

+ {#each someItems as someItem} + +
{someItem}
+ + {/each} + +
diff --git a/pack/ant/start/nvim-treesitter/tests/query/injections/vue/negative-assertions.vue b/pack/ant/start/nvim-treesitter/tests/query/injections/vue/negative-assertions.vue new file mode 100644 index 0000000..000702a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/injections/vue/negative-assertions.vue @@ -0,0 +1,4 @@ + + + + diff --git a/pack/ant/start/nvim-treesitter/tests/query/injections/vue/test-vue-injections.vue b/pack/ant/start/nvim-treesitter/tests/query/injections/vue/test-vue-injections.vue new file mode 100644 index 0000000..4966e6a --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/injections/vue/test-vue-injections.vue @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + // const file = files[0]; diff --git a/pack/ant/start/nvim-treesitter/tests/query/injections/yaml/bash-on-github-actions.yml b/pack/ant/start/nvim-treesitter/tests/query/injections/yaml/bash-on-github-actions.yml new file mode 100644 index 0000000..5c732b0 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/injections/yaml/bash-on-github-actions.yml @@ -0,0 +1,32 @@ +name: CI +on: + push: + branches: [master] + pull_request: + branches: [master] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '16' + - name: Install dependencies + run: npm ci + # ^ @bash + - name: Run tests + run: npm test + # ^ @bash + - name: Parse Petalisp + run: | + git submodule init + git submodule update + if (( $(node_modules/tree-sitter-cli/tree-sitter parse test/Petalisp/**/*.lisp -q | wc -l) > 2 )); then # There are 2 known failures (strings that are not format strings but use ~X syntax) + exit 1 + else + echo "Successfully parsed Petalisp" + fi + # ^ @bash + - name: Run tests + run: npm test diff --git a/pack/ant/start/nvim-treesitter/tests/query/injections/yaml/promql-on-prometheus-rules.yaml b/pack/ant/start/nvim-treesitter/tests/query/injections/yaml/promql-on-prometheus-rules.yaml new file mode 100644 index 0000000..f064da3 --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/query/injections/yaml/promql-on-prometheus-rules.yaml @@ -0,0 +1,19 @@ +groups: +- name: Hardware alerts + rules: + - alert: Node down + expr: up{job="node_exporter"} == 0 + # ^ @promql + for: 3m + labels: + severity: warning + annotations: + title: Node {{ $labels.instance }} is down + description: Failed to scrape {{ $labels.job }} on {{ $labels.instance }} for more than 3 minutes. Node seems down. + - alert: Node down + expr: | + up{job="node_exporter"} == 0 + # ^ @promql + for: 3m + labels: + severity: warning diff --git a/pack/ant/start/nvim-treesitter/tests/unit/ts_utils_spec.lua b/pack/ant/start/nvim-treesitter/tests/unit/ts_utils_spec.lua new file mode 100644 index 0000000..397fa7e --- /dev/null +++ b/pack/ant/start/nvim-treesitter/tests/unit/ts_utils_spec.lua @@ -0,0 +1,114 @@ +local tsutils = require "nvim-treesitter.ts_utils" + +describe("update_selection", function() + local function get_updated_selection(case) + vim.api.nvim_buf_set_lines(0, 0, -1, false, case.lines) + tsutils.update_selection(0, case.node, case.selection_mode) + vim.cmd "normal! y" + return vim.fn.getreg '"' + end + + it("charwise1", function() + assert.equal( + get_updated_selection { + lines = { "foo", "", "bar" }, + node = { 0, 0, 2, 1 }, + selection_mode = "v", + }, + "foo\n\nb" + ) + it("charwise2", function() end) + assert.equal( + get_updated_selection { + lines = { "foo", "", "bar" }, + node = { 0, 1, 2, 1 }, + selection_mode = "v", + }, + "oo\n\nb" + ) + it("charwise3", function() end) + assert.equal( + get_updated_selection { + lines = { "foo", "", "bar" }, + node = { 0, 2, 2, 1 }, + selection_mode = "v", + }, + "o\n\nb" + ) + it("charwise4", function() end) + assert.equal( + get_updated_selection { + lines = { "foo", "", "bar" }, + node = { 0, 3, 2, 1 }, + selection_mode = "v", + }, + "\n\nb" + ) + end) + it("linewise", function() + assert.equal( + get_updated_selection { + lines = { "foo", "", "bar" }, + node = { 0, 3, 2, 1 }, + selection_mode = "V", + }, + "foo\n\nbar\n" + ) + end) + it("blockwise", function() + assert.equal( + get_updated_selection { + lines = { "foo", "", "bar" }, + node = { 0, 3, 2, 1 }, + selection_mode = "", + }, + "foo\n\nbar" + ) + end) +end) + +describe("swap_nodes", function() + local function swap(case) + vim.api.nvim_buf_set_lines(0, 0, -1, false, case.lines) + vim.opt.filetype = case.filetype + local a = vim.treesitter.get_node { + bufnr = 0, + pos = { case.a[1], case.a[2] }, + } + local b = vim.treesitter.get_node { + bufnr = 0, + pos = { case.b[1], case.b[2] }, + } + tsutils.swap_nodes(a, b, 0, true) + end + + it("works on adjacent nodes", function() + swap { + filetype = "python", + lines = { "print(1)" }, + a = { 0, 0 }, + b = { 0, 5 }, + } + + it("swaps text", function() end) + assert.same(vim.api.nvim_buf_get_lines(0, 0, -1, false), { "(1)print" }) + + it("moves the cursor", function() end) + assert.same(vim.api.nvim_win_get_cursor(0), { 1, 3 }) + end) + + it("works with multiline nodes", function() + swap { + filetype = "lua", + lines = { "x = { [[", "]], [[", ".....]]}" }, + a = { 0, 6 }, + b = { 1, 4 }, + } + + it("swaps text", function() end) + assert.same(vim.api.nvim_buf_get_lines(0, 0, -1, false), { "x = { [[", ".....]], [[", "]]}" }) + + it("moves the cursor", function() end) + assert.same(vim.api.nvim_win_get_cursor(0), { 2, 9 }) + end) +end) diff --git a/plugins.md b/plugins.md index 51b0469..2cef232 100644 --- a/plugins.md +++ b/plugins.md @@ -10,6 +10,7 @@ Git submodules are slow, so handle this manually. * [coc.nvim](https://github.com/neoclide/coc.nvim) * [limelight.vim](https://github.com/junegunn/limelight.vim) * [mom.vim](http://git.savannah.gnu.org/cgit/groff.git/plain/contrib/mom/examples/mom.vim) +* [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) * [tempus-themes-vim](https://gitlab.com/protesilaos/tempus-themes-vim) * [vim-actodo](https://github.com/acperkins/vim-actodo) * [vim-asciidoctor](https://github.com/habamax/vim-asciidoctor)