diff --git a/mlir/utils/coc.nvim/.github/workflows/auto_publish.yml b/mlir/utils/coc.nvim/.github/workflows/auto_publish.yml new file mode 100644 index 0000000000000..3b053cb14c629 --- /dev/null +++ b/mlir/utils/coc.nvim/.github/workflows/auto_publish.yml @@ -0,0 +1,31 @@ +# This workflow publishes the extension to the Coc marketplace when the version changes. +name: Publish to Coc Marketplace +on: + # Run whenever a new commit is pushed to the main branch. + push: + branches: [ main ] + paths: [ 'package.json' ] + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: detect version + uses: EndBug/version-check@v2.0.1 + id: check + if: github.event_name != 'workflow_dispatch' + with: + # Search the diff content for version changes. + diff-search: true + + - name: publish + # if: steps.check.outputs.changed == 'true' + # The token will be expired in on 08/03/2022. + run: | + npm install + npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}} diff --git a/mlir/utils/coc.nvim/.gitignore b/mlir/utils/coc.nvim/.gitignore new file mode 100644 index 0000000000000..ec25628b950a1 --- /dev/null +++ b/mlir/utils/coc.nvim/.gitignore @@ -0,0 +1,7 @@ +out +node_modules +.vscode-test +*.vsix +*.tgz + +!.vscode diff --git a/mlir/utils/coc.nvim/.npmignore b/mlir/utils/coc.nvim/.npmignore new file mode 100644 index 0000000000000..2f8b41a7adc23 --- /dev/null +++ b/mlir/utils/coc.nvim/.npmignore @@ -0,0 +1,26 @@ +src/ +*.map +*.tgz + +# tool +.github +.eslintrc.js +.prettierrc + +# package manager +yarn.lock +yarn-error.log + +# bundler +tsconfig.json +webpack.config.js +esbuild.mjs +esbuild.js + +# vscode +.vscodeignore +.vscode/ +grammar.json +*-grammar.json +language-configuration.json +*-language-configuration.json diff --git a/mlir/utils/coc.nvim/.vscode/launch.json b/mlir/utils/coc.nvim/.vscode/launch.json new file mode 100644 index 0000000000000..dfe1753e6a663 --- /dev/null +++ b/mlir/utils/coc.nvim/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "extensionHost", + "request": "launch", + "name": "Run Extension", + "runtimeExecutable": "${execPath}", + "args": [ + "--extensionDevelopmentPath=${workspaceRoot}" + ], + "outFiles": [ + "${workspaceRoot}/out/**/*.js" + ], + "preLaunchTask": { + "type": "npm", + "script": "watch" + } + } + ] +} \ No newline at end of file diff --git a/mlir/utils/coc.nvim/.vscode/tasks.json b/mlir/utils/coc.nvim/.vscode/tasks.json new file mode 100644 index 0000000000000..5efd8048880a1 --- /dev/null +++ b/mlir/utils/coc.nvim/.vscode/tasks.json @@ -0,0 +1,33 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "compile", + "group": "build", + "presentation": { + "panel": "dedicated", + "reveal": "never" + }, + "problemMatcher": [ + "$tsc" + ] + }, + { + "type": "npm", + "script": "watch", + "isBackground": true, + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "panel": "dedicated", + "reveal": "never" + }, + "problemMatcher": [ + "$tsc-watch" + ] + } + ] +} \ No newline at end of file diff --git a/mlir/utils/coc.nvim/.vscodeignore b/mlir/utils/coc.nvim/.vscodeignore new file mode 100644 index 0000000000000..f369b5e55b684 --- /dev/null +++ b/mlir/utils/coc.nvim/.vscodeignore @@ -0,0 +1,4 @@ +.vscode/** +.vscode-test/** +.gitignore +vsc-extension-quickstart.md diff --git a/mlir/utils/coc.nvim/LICENSE b/mlir/utils/coc.nvim/LICENSE new file mode 100644 index 0000000000000..53bb2e7fbc764 --- /dev/null +++ b/mlir/utils/coc.nvim/LICENSE @@ -0,0 +1,234 @@ +============================================================================== +The LLVM Project is under the Apache License v2.0 with LLVM Exceptions: +============================================================================== + + 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. + + +---- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + +============================================================================== +Software from third parties included in the LLVM Project: +============================================================================== +The LLVM Project contains third party software which is under different license +terms. All such code will be identified clearly using at least one of two +mechanisms: +1) It will be in a separate directory tree with its own `LICENSE.txt` or + `LICENSE` file at the top containing the specific license and restrictions + which apply to that software, or +2) It will contain specific license and restriction terms at the top of every + file. diff --git a/mlir/utils/coc.nvim/README.md b/mlir/utils/coc.nvim/README.md new file mode 100644 index 0000000000000..70773cf3877db --- /dev/null +++ b/mlir/utils/coc.nvim/README.md @@ -0,0 +1,343 @@ +# MLIR + +Ported from [vscode-mlir](https://github.com/llvm/vscode-mlir). + +Because some APIs of [vscode](github.com/microsoft/vscode) are missing in +[coc.nvim](https://github.com/neoclide/coc.nvim), disable some features +temporarily: + +- command `mlir.viewPDLLOutput`: miss + `vscode.workspace.openTextDocument({language, content})` +- custom editor `mlir.bytecode`: miss + `vscode.window.registerCustomEditorProvider()` +- filesystem `mlir.bytecode-mlir`: miss `vscode.workspace.registerFileSystemProvider()` +- use `chokidar.watch()` to detect the changes of the paths of language + servers: miss `vscode.Disposable.constructor()` + +## Install + +- [coc-marketplace](https://github.com/fannheyward/coc-marketplace) +- [npm](https://www.npmjs.com/package/coc-mlir) +- vim: + +```vim +" command line +CocInstall coc-mlir +" or add the following code to your vimrc +let g:coc_global_extensions = ['coc-mlir', 'other coc-plugins'] +``` + +--- + +Provides language IDE features for [MLIR](https://mlir.llvm.org/) related +languages: [MLIR](#mlir---mlir-textual-assembly-format), +[PDLL](#pdll---mlir-pdll-pattern-files), and [TableGen](#td---tablegen-files) + +## `.mlir` - MLIR textual assembly format: + +The MLIR extension adds language support for the +[MLIR textual assembly format](https://mlir.llvm.org/docs/LangRef/): + +### Features + +- Syntax highlighting for `.mlir` files and `mlir` markdown blocks +- go-to-definition and cross references +- Detailed information when hovering over IR entities +- Outline and navigation of symbols and symbol tables +- Code completion +- Live parser and verifier diagnostics + +#### Diagnostics + +The language server actively runs verification on the IR as you type, showing +any generated diagnostics in-place. + +![IMG](https://mlir.llvm.org/mlir-lsp-server/diagnostics.png) + +##### Automatically insert `expected-` diagnostic checks + +MLIR provides +[infrastructure](https://mlir.llvm.org/docs/Diagnostics/#sourcemgr-diagnostic-verifier-handler) +for checking expected diagnostics, which is heavily utilized when defining IR +parsing and verification. The language server provides code actions for +automatically inserting the checks for diagnostics it knows about. + +![IMG](https://mlir.llvm.org/mlir-lsp-server/diagnostics_action.gif) + +#### Code completion + +The language server provides suggestions as you type, offering completions for +dialect constructs (such as attributes, operations, and types), block names, SSA +value names, keywords, and more. + +![IMG](https://mlir.llvm.org/mlir-lsp-server/code_complete.gif) + +#### Cross-references + +Cross references allow for navigating the use/def chains of SSA values (i.e. +operation results and block arguments), [Symbols](../SymbolsAndSymbolTables.md), +and Blocks. + +##### Find definition + +Jump to the definition of the IR entity under the cursor. A few examples are +shown below: + +- SSA Values + +![SSA](https://mlir.llvm.org/mlir-lsp-server/goto_def_ssa.gif) + +- Symbol References + +![Symbols](https://mlir.llvm.org/mlir-lsp-server/goto_def_symbol.gif) + +The definition of an operation will also take into account the source location +attached, allowing for navigating into the source file that generated the +operation. + +![External Locations](https://mlir.llvm.org/mlir-lsp-server/goto_def_external.gif) + +##### Find references + +Show all references of the IR entity under the cursor. + +![IMG](https://mlir.llvm.org/mlir-lsp-server/find_references.gif) + +#### Hover + +Hover over an IR entity to see more information about it. The exact information +displayed is dependent on the type of IR entity under the cursor. For example, +hovering over an `Operation` may show its generic format. + +![IMG](https://mlir.llvm.org/mlir-lsp-server/hover.png) + +#### Navigation + +The language server will also inform the editor about the structure of symbol +tables within the IR. This allows for jumping directly to the definition of a +symbol, such as a `func.func`, within the file. + +![IMG](https://mlir.llvm.org/mlir-lsp-server/navigation.gif) + +#### Bytecode Editing and Inspection + +The language server provides support for interacting with MLIR bytecode files, +enabling IDEs to transparently view and edit bytecode files in the same way +as textual `.mlir` files. + +![IMG](https://mlir.llvm.org/mlir-lsp-server/bytecode_edit.gif) + +### Setup + +#### `mlir-lsp-server` + +The various `.mlir` language features require the +[`mlir-lsp-server` language server](https://mlir.llvm.org/docs/Tools/MLIRLSP/#mlir-lsp-language-server--mlir-lsp-server). +If `mlir-lsp-server` is not found within your workspace path, you must specify +the path of the server via the `mlir.server_path` setting. The path of the +server may be absolute or relative within your workspace. + +## `.pdll` - MLIR PDLL pattern files: + +The MLIR extension adds language support for the +[PDLL pattern language](https://mlir.llvm.org/docs/PDLL/). + +### Features + +- Syntax highlighting for `.pdll` files and `pdll` markdown blocks +- go-to-definition and cross references +- Types and documentation on hover +- Code completion and signature help +- View intermediate AST, MLIR, or C++ output + +#### Diagnostics + +The language server actively runs verification as you type, showing any +generated diagnostics in-place. + +![IMG](https://mlir.llvm.org/mlir-pdll-lsp-server/diagnostics.png) + +#### Code completion and signature help + +The language server provides suggestions as you type based on what constraints, +rewrites, dialects, operations, etc are available in this context. The server +also provides information about the structure of constraint and rewrite calls, +operations, and more as you fill them in. + +![IMG](https://mlir.llvm.org/mlir-pdll-lsp-server/code_complete.gif) + +#### Cross-references + +Cross references allow for navigating the code base. + +##### Find definition + +Jump to the definition of a symbol under the cursor: + +![IMG](https://mlir.llvm.org/mlir-pdll-lsp-server/goto_def.gif) + +If ODS information is available, we can also jump to the definition of operation +names and more: + +![IMG](https://mlir.llvm.org/mlir-pdll-lsp-server/goto_def_ods.gif) + +##### Find references + +Show all references of the symbol under the cursor. + +![IMG](https://mlir.llvm.org/mlir-pdll-lsp-server/find_references.gif) + +#### Hover + +Hover over a symbol to see more information about it, such as its type, +documentation, and more. + +![IMG](https://mlir.llvm.org/mlir-pdll-lsp-server/hover.png) + +If ODS information is available, we can also show information directly from the +operation definitions: + +![IMG](https://mlir.llvm.org/mlir-pdll-lsp-server/hover_ods.png) + +#### Navigation + +The language server will also inform the editor about the structure of symbols +within the IR. + +![IMG](https://mlir.llvm.org/mlir-pdll-lsp-server/navigation.gif) + +#### View intermediate output + +The language server provides support for introspecting various intermediate +stages of compilation, such as the AST, the `.mlir` containing the generated +PDL, and the generated C++ glue. This is a custom LSP extension, and is not +necessarily provided by all IDE clients. + +![IMG](https://mlir.llvm.org/mlir-pdll-lsp-server/view_output.gif) + +#### Inlay hints + +The language server provides additional information inline with the source code. +Editors usually render this using read-only virtual text snippets interspersed +with code. Hints may be shown for: + +- types of local variables +- names of operand and result groups +- constraint and rewrite arguments + +![IMG](https://mlir.llvm.org/mlir-pdll-lsp-server/inlay_hints.png) + +### Setup + +#### `mlir-pdll-lsp-server` + +The various `.pdll` language features require the +[`mlir-pdll-lsp-server` language server](https://mlir.llvm.org/docs/Tools/MLIRLSP/#pdll-lsp-language-server--mlir-pdll-lsp-server). +If `mlir-pdll-lsp-server` is not found within your workspace path, you must +specify the path of the server via the `mlir.pdll_server_path` setting. The path +of the server may be absolute or relative within your workspace. + +#### Project setup + +To properly understand and interact with `.pdll` files, the language server must +understand how the project is built (compile flags). +[`pdll_compile_commands.yml` files](https://mlir.llvm.org/docs/Tools/MLIRLSP/#compilation-database) +related to your project should be provided to ensure files are properly +processed. These files can usually be generated by the build system, and the +server will attempt to find them within your `build/` directory. If not +available in or a unique location, additional `pdll_compile_commands.yml` files +may be specified via the `mlir.pdll_compilation_databases` setting. The paths of +these databases may be absolute or relative within your workspace. + +## `.td` - TableGen files: + +The MLIR extension adds language support for the +[TableGen language](https://llvm.org/docs/TableGen/ProgRef.html). + +### Features + +- Syntax highlighting for `.td` files and `tablegen` markdown blocks +- go-to-definition and cross references +- Types and documentation on hover + +#### Diagnostics + +The language server actively runs verification as you type, showing any +generated diagnostics in-place. + +![IMG](https://mlir.llvm.org/tblgen-lsp-server/diagnostics.png) + +#### Cross-references + +Cross references allow for navigating the code base. + +##### Find definition + +Jump to the definition of a symbol under the cursor: + +![IMG](https://mlir.llvm.org/tblgen-lsp-server/goto_def.gif) + +##### Find references + +Show all references of the symbol under the cursor. + +![IMG](https://mlir.llvm.org/tblgen-lsp-server/find_references.gif) + +#### Hover + +Hover over a symbol to see more information about it, such as its type, +documentation, and more. + +![IMG](https://mlir.llvm.org/tblgen-lsp-server/hover_def.png) + +Hovering over an overridden field will also show you information such as +documentation from the base value: + +![IMG](https://mlir.llvm.org/tblgen-lsp-server/hover_field.png) + +### Setup + +#### `tblgen-lsp-server` + +The various `.td` language features require the +[`tblgen-lsp-server` language server](https://mlir.llvm.org/docs/Tools/MLIRLSP/#tablegen-lsp-language-server--tblgen-lsp-server). +If `tblgen-lsp-server` is not found within your workspace path, you must specify +the path of the server via the `mlir.tablegen_server_path` setting. The path of +the server may be absolute or relative within your workspace. + +#### Project setup + +To properly understand and interact with `.td` files, the language server must +understand how the project is built (compile flags). +[`tablegen_compile_commands.yml` files](https://mlir.llvm.org/docs/Tools/MLIRLSP/#compilation-database-1) +related to your project should be provided to ensure files are properly +processed. These files can usually be generated by the build system, and the +server will attempt to find them within your `build/` directory. If not +available in or a unique location, additional `tablegen_compile_commands.yml` +files may be specified via the `mlir.tablegen_compilation_databases` setting. +The paths of these databases may be absolute or relative within your workspace. + +## Contributing + +This extension is actively developed within the +[LLVM monorepo](https://github.com/llvm/llvm-project), at +[`mlir/utils/vscode`](https://github.com/llvm/llvm-project/tree/main/mlir/utils/vscode). +As such, contributions should follow the +[normal LLVM guidelines](https://llvm.org/docs/Contributing.html), with code +reviews sent to +[phabricator](https://llvm.org/docs/Contributing.html#how-to-submit-a-patch). + +When developing or deploying this extension within the LLVM monorepo, a few +extra setup steps are required: + +- Copy `mlir/utils/textmate/mlir.json` to the extension directory and rename to + `grammar.json`. +- Copy `llvm/utils/textmate/tablegen.json` to the extension directory and rename + to `tablegen-grammar.json`. +- Copy + `https://mlir.llvm.org//LogoAssets/logo/PNG/full_color/mlir-identity-03.png` + to the extension directory and rename to `icon.png`. + +Please follow the existing code style when contributing to the extension, we +recommend to run `npm run format` before sending a patch. + diff --git a/mlir/utils/coc.nvim/cpp-grammar.json b/mlir/utils/coc.nvim/cpp-grammar.json new file mode 100644 index 0000000000000..36063c6a5210b --- /dev/null +++ b/mlir/utils/coc.nvim/cpp-grammar.json @@ -0,0 +1,44 @@ +{ + "scopeName": "source.cpp.mlir", + "injectionSelector": "L:source.cpp -string.quoted.double.cpp -string.quoted.double.raw", + "patterns": [ + { + "include": "#mlir-raw-string" + } + ], + "repository": { + "mlir-raw-string": { + "begin": "R\"(?i:mlir)(\\()", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.cpp" + }, + "1": { + "name": "mlir.delimeter.raw.string.cpp" + } + }, + "end": "\\)(?i:mlir)\"", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.cpp" + }, + "1": { + "name": "mlir.delimeter.raw.string.cpp" + } + }, + "name": "mlir.raw.string.cpp", + "patterns": [ + { + "contentName": "source.mlir", + "begin": "(?!\\G)", + "end": "(?i)(?=\\)mlir\")", + "patterns": [ + { + "include": "source.mlir" + } + ] + } + ] + } + } +} diff --git a/mlir/utils/coc.nvim/grammar.json b/mlir/utils/coc.nvim/grammar.json new file mode 100644 index 0000000000000..820f8921cf237 --- /dev/null +++ b/mlir/utils/coc.nvim/grammar.json @@ -0,0 +1,398 @@ +{ + "name": "MLIR", + "fileTypes": [ + "mlir" + ], + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#string" + }, + { + "include": "#top_level_entity" + } + ], + "repository": { + "comment": { + "match": "\/\/.*$", + "name": "comment.line.double-slash.mlir" + }, + "number": { + "patterns": [ + { + "match": "(\\W)?([0-9]+\\.[0-9]*)([eE][+-]?[0-9]+)?", + "name": "constant.numeric.mlir" + }, + { + "match": "([\\W])?(0x[0-9a-zA-Z]+)", + "captures": { + "2": { + "name": "constant.numeric.mlir" + } + } + }, + { + "match": "([\\Wx])?([0-9]+)", + "captures": { + "2": { + "name": "constant.numeric.mlir" + } + } + } + ] + }, + "string": { + "begin": "\"", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.mlir" + } + }, + "patterns": [ + { + "match": "\\\\[nt\"]", + "name": "constant.character.escape.mlir" + } + ], + "end": "\"", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.mlir" + } + }, + "name": "string.quoted.double.mlir" + }, + "top_level_entity": { + "patterns": [ + { + "include": "#attribute_alias_def" + }, + { + "include": "#type_alias_def" + }, + { + "include": "#operation_body" + } + ] + }, + "attribute_alias_def": { + "match": "^\\s*(\\#\\w+)\\b\\s+\\=", + "captures": { + "1": { + "name": "constant.language.mlir" + } + } + }, + "type_alias_def": { + "match": "^\\s*(\\!\\w+)\\b\\s+\\=", + "captures": { + "1": { + "name": "entity.name.type.mlir" + } + } + }, + "operation": { + "patterns": [ + { + "match": "^\\s*(\\%[\\%\\w\\:\\,\\s]+)\\s+\\=\\s+([\\w\\.\\$\\-]+)\\b", + "captures": { + "1": { + "patterns": [ + { + "include": "#ssa_value" + } + ] + }, + "2": { + "name": "variable.other.enummember.mlir" + } + } + }, + { + "match": "^\\s*([\\w\\.\\$\\-]+)\\b(?=[^\\<\\:])", + "name": "variable.other.enummember.mlir" + } + ] + }, + "operation_body": { + "patterns": [ + { + "include": "#operation" + }, + { + "include": "#region_body_or_attr_dict" + }, + { + "include": "#comment" + }, + { + "include": "#ssa_value" + }, + { + "include": "#block" + }, + { + "include": "#attribute_value" + }, + { + "include": "#bare_identifier" + } + ] + }, + "region_body_or_attr_dict": { + "patterns": [ + { + "begin": "\\{\\s*(?=\\%|\\/|\\^)", + "patterns": [ + { + "include": "#operation_body" + } + ], + "end": "\\}" + }, + { + "begin": "\\{\\s*(?=[^\\}]*$)", + "patterns": [ + { + "include": "#operation_body" + } + ], + "end": "\\}" + }, + { + "begin": "\\{\\s*(?=\\%)", + "patterns": [ + { + "include": "#operation_body" + } + ], + "end": "\\}" + }, + { + "begin": "\\{\\s*(?=.*$)", + "patterns": [ + { + "include": "#attribute_dictionary_body" + } + ], + "end": "\\}" + } + ] + }, + "attribute_value": { + "patterns": [ + { + "include": "#string" + }, + { + "include": "#comment" + }, + { + "include": "#number" + }, + { + "match": "\\b(false|true|unit)\\b", + "name": "constant.language.mlir" + }, + { + "begin": "\\b(affine_map|affine_set)\\s*\\<", + "beginCaptures": { + "1": { + "name": "constant.language.mlir" + } + }, + "patterns": [ + { + "match": "\\b(ceildiv|floordiv|mod|symbol)\\b", + "name": "entity.name.function.mlir" + }, + { + "match": "\\b([\\w\\.\\$\\-]+)\\b", + "name": "variable.mlir" + }, + { + "include": "#number" + } + ], + "end": "\\)\\>" + }, + { + "begin": "\\b(dense|opaque|sparse)\\s*\\<", + "beginCaptures": { + "1": { + "name": "constant.language.mlir" + } + }, + "patterns": [ + { + "include": "#attribute_value" + } + ], + "end": "\\>" + }, + { + "begin": "\\[", + "patterns": [ + { + "include": "#attribute_value" + }, + { + "include": "#operation_body" + } + ], + "end": "\\]" + }, + { + "begin": "\\{", + "patterns": [ + { + "include": "#attribute_dictionary_body" + } + ], + "end": "\\}" + }, + { + "match": "(\\@[\\w+\\$\\-\\.]*)", + "name": "entity.name.function.mlir" + }, + { + "begin": "(\\#[\\w\\$\\-\\.]+)\\<", + "beginCaptures": { + "1": { + "name": "constant.language.mlir" + } + }, + "patterns": [ + { + "include": "#attribute_value" + }, + { + "match": "\\-\\>|\\>\\=" + }, + { + "include": "#bare_identifier" + } + ], + "end": "\\>" + }, + { + "match": "\\#[\\w\\$\\-\\.]+\\b", + "name": "constant.language.mlir" + }, + { + "include": "#type_value" + }, + { + "begin": "\\<", + "patterns": [ + { + "include": "#attribute_value" + }, + { + "include": "#bare_identifier" + } + ], + "end": "\\>" + } + ] + }, + "attribute_dictionary_body": { + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#string" + }, + { + "include": "#attribute_value" + }, + { + "match": "(\\%)?\\b([\\w\\.\\-\\$\\:0-9]+)\\b\\s*(?=\\=|\\,|\\})", + "name": "variable.other.mlir" + } + ] + }, + "type_value": { + "patterns": [ + { + "begin": "(\\![\\w\\$\\-\\.]+)\\<", + "beginCaptures": { + "1": { + "name": "entity.name.type.mlir" + } + }, + "patterns": [ + { + "include": "#attribute_value" + }, + { + "match": "\\-\\>|\\>\\=", + "name": "punctuation.other.mlir" + }, + { + "include": "#bare_identifier" + } + ], + "end": "\\>" + }, + { + "match": "\\![\\w\\$\\-\\.]+\\b", + "name": "entity.name.type.mlir" + }, + { + "begin": "(complex|memref|tensor|tuple|vector)\\<", + "beginCaptures": { + "1": { + "name": "entity.name.type.mlir" + } + }, + "patterns": [ + { + "match": "[\\?x0-9\\[\\]]+", + "captures": { + "0": { + "patterns": [ + { + "include": "#number" + } + ] + } + } + }, + { + "include": "#attribute_value" + }, + { + "match": "\\-\\>|\\>\\=", + "name": "punctuation.other.mlir" + }, + { + "include": "#bare_identifier" + } + ], + "end": "\\>" + }, + { + "match": "bf16|f16|f32|f64|f80|f128|index|none|(u|s)?i[0-9]+", + "name": "entity.name.type.mlir" + } + ] + }, + "bare_identifier": { + "match": "\\b([\\w\\.\\$\\-]+)\\b", + "name": "keyword.other.mlir" + }, + "ssa_value": { + "match": "\\%[\\w\\.\\$\\:\\#]+", + "name": "variable.other.mlir" + }, + "block": { + "match": "\\^[\\w\\d_$\\.-]+", + "name": "keyword.control.mlir" + } + }, + "scopeName": "source.mlir" +} \ No newline at end of file diff --git a/mlir/utils/coc.nvim/icon.png b/mlir/utils/coc.nvim/icon.png new file mode 100644 index 0000000000000..2daa335d02995 Binary files /dev/null and b/mlir/utils/coc.nvim/icon.png differ diff --git a/mlir/utils/coc.nvim/language-configuration.json b/mlir/utils/coc.nvim/language-configuration.json new file mode 100644 index 0000000000000..8a34cc83a53cb --- /dev/null +++ b/mlir/utils/coc.nvim/language-configuration.json @@ -0,0 +1,22 @@ +{ + "comments": { + "lineComment": "//" + }, + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + "autoClosingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""] + ], + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""] + ] +} diff --git a/mlir/utils/coc.nvim/markdown-grammar.json b/mlir/utils/coc.nvim/markdown-grammar.json new file mode 100644 index 0000000000000..2a285a0705bcb --- /dev/null +++ b/mlir/utils/coc.nvim/markdown-grammar.json @@ -0,0 +1,117 @@ +{ + "fileTypes": [], + "injectionSelector": "L:text.html.markdown", + "patterns": [ + { + "include": "#mlir-code-block" + }, + { + "include": "#pdll-code-block" + }, + { + "include": "#tablegen-code-block" + } + ], + "repository": { + "mlir-code-block": { + "begin": "(^|\\G)(\\s*)(\\`{3,}|~{3,})\\s*(?i:(mlir)(\\s+[^`~]*)?$)", + "name": "markup.fenced_code.block.markdown", + "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", + "beginCaptures": { + "3": { + "name": "punctuation.definition.markdown" + }, + "4": { + "name": "fenced_code.block.language.markdown" + }, + "5": { + "name": "fenced_code.block.language.attributes.markdown" + } + }, + "endCaptures": { + "3": { + "name": "punctuation.definition.markdown" + } + }, + "patterns": [ + { + "begin": "(^|\\G)(\\s*)(.*)", + "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)", + "contentName": "meta.embedded.block.mlir", + "patterns": [ + { + "include": "source.mlir" + } + ] + } + ] + }, + "pdll-code-block": { + "begin": "(^|\\G)(\\s*)(\\`{3,}|~{3,})\\s*(?i:(pdll)(\\s+[^`~]*)?$)", + "name": "markup.fenced_code.block.markdown", + "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", + "beginCaptures": { + "3": { + "name": "punctuation.definition.markdown" + }, + "4": { + "name": "fenced_code.block.language.markdown" + }, + "5": { + "name": "fenced_code.block.language.attributes.markdown" + } + }, + "endCaptures": { + "3": { + "name": "punctuation.definition.markdown" + } + }, + "patterns": [ + { + "begin": "(^|\\G)(\\s*)(.*)", + "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)", + "contentName": "meta.embedded.block.pdll", + "patterns": [ + { + "include": "source.pdll" + } + ] + } + ] + }, + "tablegen-code-block": { + "begin": "(^|\\G)(\\s*)(\\`{3,}|~{3,})\\s*(?i:(tablegen)(\\s+[^`~]*)?$)", + "name": "markup.fenced_code.block.markdown", + "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", + "beginCaptures": { + "3": { + "name": "punctuation.definition.markdown" + }, + "4": { + "name": "fenced_code.block.language.markdown" + }, + "5": { + "name": "fenced_code.block.language.attributes.markdown" + } + }, + "endCaptures": { + "3": { + "name": "punctuation.definition.markdown" + } + }, + "patterns": [ + { + "begin": "(^|\\G)(\\s*)(.*)", + "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)", + "contentName": "meta.embedded.block.tablegen", + "patterns": [ + { + "include": "source.tablegen" + } + ] + } + ] + } + }, + "scopeName": "markdown.mlir.codeblock" +} \ No newline at end of file diff --git a/mlir/utils/coc.nvim/package-lock.json b/mlir/utils/coc.nvim/package-lock.json new file mode 100644 index 0000000000000..d9d307a1f26cb --- /dev/null +++ b/mlir/utils/coc.nvim/package-lock.json @@ -0,0 +1,710 @@ +{ + "name": "vscode-mlir", + "version": "0.0.11", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "vscode-mlir", + "version": "0.0.11", + "dependencies": { + "base64-js": "^1.5.1", + "chokidar": "3.5.2" + }, + "devDependencies": { + "@types/mocha": "^7.0.2", + "@types/node": "^14.17.0", + "clang-format": "^1.8.0", + "coc.nvim": "^0.0.83-next.9", + "typescript": "^4.6.4" + }, + "engines": { + "coc": "^0.0.80" + } + }, + "node_modules/@types/mocha": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-7.0.2.tgz", + "integrity": "sha512-ZvO2tAcjmMi8V/5Z3JsyofMe3hasRcaw88cto5etSVMwVQfeivGAlEYmaQgceUSVYFofVjT+ioHsATjdWcFt1w==", + "dev": true + }, + "node_modules/@types/node": { + "version": "14.18.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.18.tgz", + "integrity": "sha512-B9EoJFjhqcQ9OmQrNorItO+OwEOORNn3S31WuiHvZY/dm9ajkB7AKD/8toessEtHHNL+58jofbq7hMMY9v4yig==", + "dev": true + }, + "node_modules/anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/async": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz", + "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==", + "dev": true + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/chokidar": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", + "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/clang-format": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/clang-format/-/clang-format-1.8.0.tgz", + "integrity": "sha512-pK8gzfu55/lHzIpQ1givIbWfn3eXnU7SfxqIwVgnn5jEM6j4ZJYjpFqFs4iSBPNedzRMmfjYjuQhu657WAXHXw==", + "dev": true, + "dependencies": { + "async": "^3.2.3", + "glob": "^7.0.0", + "resolve": "^1.1.6" + }, + "bin": { + "check-clang-format": "bin/check-clang-format.js", + "clang-format": "index.js", + "git-clang-format": "bin/git-clang-format" + } + }, + "node_modules/coc.nvim": { + "version": "0.0.83-next.9", + "resolved": "https://registry.npmjs.org/coc.nvim/-/coc.nvim-0.0.83-next.9.tgz", + "integrity": "sha512-ek5+EgA9N92/6Wt07TAYpavmBgXZto4Dmwmm56oyBl/w4wy3Tod7LfpCp4k9M4xCxhxPtrflIcxvhdDUPIeMuw==", + "dev": true, + "engines": { + "node": ">=14.14.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/cocnvim" + }, + "peerDependencies": { + "@types/node": "^14.14.0" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "node_modules/glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-core-module": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.5.0.tgz", + "integrity": "sha512-TXCMSDsEHMEEZ6eCA8rwRDbLu55MRGmrctljsBX/2v1d9/GzqHOxW5c5oPSgrUt2vBFXebu9rGqckXGPWOlYpg==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/picomatch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "dependencies": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/typescript": { + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + }, + "dependencies": { + "@types/mocha": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-7.0.2.tgz", + "integrity": "sha512-ZvO2tAcjmMi8V/5Z3JsyofMe3hasRcaw88cto5etSVMwVQfeivGAlEYmaQgceUSVYFofVjT+ioHsATjdWcFt1w==", + "dev": true + }, + "@types/node": { + "version": "14.18.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.18.18.tgz", + "integrity": "sha512-B9EoJFjhqcQ9OmQrNorItO+OwEOORNn3S31WuiHvZY/dm9ajkB7AKD/8toessEtHHNL+58jofbq7hMMY9v4yig==", + "dev": true + }, + "anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "async": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.3.tgz", + "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==", + "dev": true + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "requires": { + "fill-range": "^7.0.1" + } + }, + "chokidar": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", + "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + } + }, + "clang-format": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/clang-format/-/clang-format-1.8.0.tgz", + "integrity": "sha512-pK8gzfu55/lHzIpQ1givIbWfn3eXnU7SfxqIwVgnn5jEM6j4ZJYjpFqFs4iSBPNedzRMmfjYjuQhu657WAXHXw==", + "dev": true, + "requires": { + "async": "^3.2.3", + "glob": "^7.0.0", + "resolve": "^1.1.6" + } + }, + "coc.nvim": { + "version": "0.0.83-next.9", + "resolved": "https://registry.npmjs.org/coc.nvim/-/coc.nvim-0.0.83-next.9.tgz", + "integrity": "sha512-ek5+EgA9N92/6Wt07TAYpavmBgXZto4Dmwmm56oyBl/w4wy3Tod7LfpCp4k9M4xCxhxPtrflIcxvhdDUPIeMuw==", + "dev": true, + "requires": {} + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "optional": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "requires": { + "is-glob": "^4.0.1" + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-core-module": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.5.0.tgz", + "integrity": "sha512-TXCMSDsEHMEEZ6eCA8rwRDbLu55MRGmrctljsBX/2v1d9/GzqHOxW5c5oPSgrUt2vBFXebu9rGqckXGPWOlYpg==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" + }, + "is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "picomatch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==" + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "requires": { + "picomatch": "^2.2.1" + } + }, + "resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "requires": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "requires": { + "is-number": "^7.0.0" + } + }, + "typescript": { + "version": "4.6.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", + "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + } +} diff --git a/mlir/utils/coc.nvim/package.json b/mlir/utils/coc.nvim/package.json new file mode 100644 index 0000000000000..5b6c76efa4c55 --- /dev/null +++ b/mlir/utils/coc.nvim/package.json @@ -0,0 +1,213 @@ +{ + "name": "coc-mlir", + "displayName": "MLIR", + "description": "MLIR Language Extension", + "version": "0.0.11", + "publisher": "llvm-vs-code-extensions", + "homepage": "https://mlir.llvm.org/", + "icon": "icon.png", + "engines": { + "coc": "^0.0.82" + }, + "categories": [ + "Programming Languages" + ], + "keywords": [ + "coc.nvim", + "LLVM", + "MLIR", + "PDLL", + "TableGen", + "tblgen", + "tablegen" + ], + "activationEvents": [ + "onFileSystem:mlir.bytecode-mlir", + "onCustomEditor:mlir.bytecode", + "onLanguage:mlir", + "onLanguage:pdll", + "onLanguage:tablegen" + ], + "main": "./out/extension.js", + "scripts": { + "prepare": "tsc -p ./", + "compile": "tsc -watch -p ./", + "format": "clang-format -i --glob=\"{src,test}/*.ts\"", + "package": "vsce package", + "git-clang-format": "git-clang-format" + }, + "dependencies": { + "base64-js": "^1.5.1", + "chokidar": "3.5.2" + }, + "devDependencies": { + "@types/mocha": "^7.0.2", + "@types/node": "^14.17.0", + "clang-format": "^1.8.0", + "coc.nvim": "^0.0.83-next.18", + "typescript": "^4.6.4", + "which": "^4.0.0" + }, + "repository": { + "type": "git", + "url": "https://github.com/Freed-Wu/coc-mlir" + }, + "contributes": { + "customEditors": [ + { + "viewType": "mlir.bytecode", + "displayName": "MLIR Bytecode", + "priority": "default", + "selector": [ + { + "filenamePattern": "*.mlirbc" + } + ] + } + ], + "languages": [ + { + "id": "mlir", + "aliases": [ + "MLIR", + "mlir" + ], + "extensions": [ + ".mlir", + ".mlirbc" + ], + "configuration": "./language-configuration.json" + }, + { + "id": "mlir-injection" + }, + { + "id": "pdll", + "aliases": [ + "PDLL", + "pdll" + ], + "extensions": [ + ".pdll" + ], + "configuration": "./pdll-language-configuration.json" + }, + { + "id": "tablegen", + "aliases": [ + "TableGen", + "tblgen" + ], + "extensions": [ + ".td" + ], + "configuration": "./tablegen-language-configuration.json" + } + ], + "grammars": [ + { + "language": "mlir", + "scopeName": "source.mlir", + "path": "./grammar.json" + }, + { + "language": "mlir-injection", + "scopeName": "markdown.mlir.codeblock", + "path": "markdown-grammar.json", + "injectTo": [ + "text.html.markdown" + ], + "embeddedLanguages": { + "meta.embedded.block.mlir": "mlir", + "meta.embedded.block.pdll": "pdll", + "meta.embedded.block.tablegen": "tablegen" + } + }, + { + "scopeName": "source.cpp.mlir", + "path": "./cpp-grammar.json", + "injectTo": [ + "source.cpp" + ], + "embeddedLanguages": { + "source.mlir": "mlir" + } + }, + { + "language": "pdll", + "scopeName": "source.pdll", + "path": "./pdll-grammar.json" + }, + { + "language": "tablegen", + "scopeName": "source.tablegen", + "path": "./tablegen-grammar.json" + } + ], + "configuration": { + "type": "object", + "title": "MLIR", + "properties": { + "mlir.server_path": { + "scope": "resource", + "type": "string", + "description": "The file path of the mlir-lsp-server executable." + }, + "mlir.pdll_server_path": { + "scope": "resource", + "type": "string", + "description": "The file path of the mlir-pdll-lsp-server executable." + }, + "mlir.pdll_compilation_databases": { + "scope": "resource", + "type": "array", + "description": "A list of `pdll_compile_commands.yml` database files containing information about .pdll files processed by the server." + }, + "mlir.tablegen_server_path": { + "scope": "resource", + "type": "string", + "description": "The file path of the tblgen-lsp-server executable." + }, + "mlir.tablegen_compilation_databases": { + "scope": "resource", + "type": "array", + "description": "A list of `tablegen_compile_commands.yml` database files containing information about .td files processed by the server." + }, + "mlir.onSettingsChanged": { + "type": "string", + "default": "prompt", + "description": "Action taken when a setting change requires a server restart to take effect.", + "enum": [ + "prompt", + "restart", + "ignore" + ], + "enumDescriptions": [ + "Prompt the user for restarting the server", + "Automatically restart the server", + "Do nothing" + ] + } + } + }, + "commands": [ + { + "command": "mlir.restart", + "title": "mlir: Restart language server" + }, + { + "command": "mlir.viewPDLLOutput", + "title": "mlir-pdll: View PDLL output" + } + ], + "menus": { + "editor/context": [ + { + "command": "mlir.viewPDLLOutput", + "group": "z_commands", + "when": "editorLangId == pdll" + } + ] + } + } +} diff --git a/mlir/utils/coc.nvim/pdll-grammar.json b/mlir/utils/coc.nvim/pdll-grammar.json new file mode 100644 index 0000000000000..47c8968c3ac0c --- /dev/null +++ b/mlir/utils/coc.nvim/pdll-grammar.json @@ -0,0 +1,524 @@ +{ + "name": "PDLL", + "fileTypes": [ + "pdll" + ], + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#string" + }, + { + "include": "#string_block" + }, + { + "include": "#integer" + }, + { + "include": "#include" + }, + { + "include": "#user_constraint" + }, + { + "include": "#user_rewrite" + }, + { + "include": "#pattern" + }, + { + "include": "#inside_pattern" + } + ], + "repository": { + "comment": { + "match": "\/\/.*$", + "name": "comment.line.double-slash.pdll" + }, + "string": { + "name": "string.quoted.double.pdll", + "begin": "\"", + "end": "\"", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.pdll" + } + }, + "patterns": [ + { + "match": "\\\\[nt\"]", + "name": "constant.character.escape.pdll" + }, + { + "match": "\\\\.", + "name": "invalid.illegal.pdll" + } + ], + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.pdll" + } + } + }, + "string_block": { + "name": "string.quoted.triple.pdll", + "begin": "\\[{", + "end": "}]", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.pdll" + } + }, + "patterns": [ + { + "match": "\\\\[nt\"]", + "name": "constant.character.escape.pdll" + }, + { + "match": "\\\\.", + "name": "invalid.illegal.pdll" + } + ], + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.pdll" + } + } + }, + "integer": { + "match": "[0-9]+", + "name": "constant.numeric.pdll" + }, + "include": { + "patterns": [ + { + "match": "(#include)", + "name": "keyword.control.pdll" + } + ] + }, + "argument_or_result_list": { + "patterns": [ + { + "match": "\\b([aA-zZ_0-9]*)\\b\\s*:\\s*([aA-zZ_0-9]+)\\b(\\<([^\\>]+)\\>)?", + "captures": { + "1": { + "name": "variable.parameter.pdll" + }, + "2": { + "name": "entity.name.type.pdll" + }, + "4": { + "name": "variable.other.enummember.pdll" + } + } + }, + { + "match": "(\\(|\\>|,)\\s*([aA-zZ_0-9]+)\\b(\\<([^\\>]+)\\>)?\\s*(?=[^:])", + "captures": { + "2": { + "name": "entity.name.type.pdll" + }, + "4": { + "name": "variable.other.enummember.pdll" + } + } + } + ] + }, + "user_constraint": { + "patterns": [ + { + "begin": "\\b(Constraint)\\b\\s*(\\b[aA-zZ_0-9]*\\b)?", + "beginCaptures": { + "1": { + "name": "keyword.other.pdll" + }, + "2": { + "name": "entity.name.type.pdll" + } + }, + "patterns": [ + { + "begin": "(\\[{)", + "patterns": [ + { + "include": "source.cpp" + } + ], + "end": "(}])" + }, + { + "begin": "(?=\\()", + "patterns": [ + { + "include": "#argument_or_result_list" + } + ], + "end": "\\)" + }, + { + "include": "#argument_or_result_list" + }, + { + "begin": "{", + "patterns": [ + { + "include": "#inside_pattern" + } + ], + "end": "(?=})" + }, + { + "begin": "=>", + "patterns": [ + { + "include": "#inside_pattern" + } + ], + "end": "(?=;|,|\\))" + } + ], + "end": "(}|;|,)|(?=\\))" + } + ] + }, + "user_rewrite": { + "patterns": [ + { + "begin": "\\b(Rewrite)\\b\\s*(\\b[aA-zZ_0-9]*\\b)?", + "beginCaptures": { + "1": { + "name": "keyword.other.pdll" + }, + "2": { + "name": "entity.name.function.pdll" + } + }, + "patterns": [ + { + "begin": "(\\[{)", + "patterns": [ + { + "include": "source.cpp" + } + ], + "end": "(}])" + }, + { + "begin": "(?=\\()", + "patterns": [ + { + "include": "#argument_or_result_list" + } + ], + "end": "\\)" + }, + { + "include": "#argument_or_result_list" + }, + { + "begin": "{", + "patterns": [ + { + "include": "#inside_pattern" + } + ], + "end": "(?=})" + }, + { + "begin": "=>", + "patterns": [ + { + "include": "#inside_pattern" + } + ], + "end": "(?=;|,|\\))" + } + ], + "end": "(}|;|,)|(?=\\))" + } + ] + }, + "pattern_metadata": { + "patterns": [ + { + "match": "\\b(with)\\b", + "name": "keyword.other.pdll" + }, + { + "match": "\\b(benefit)\\b\\(([0-9]+)\\)", + "captures": { + "1": { + "name": "entity.name.variable.pdll" + }, + "2": { + "name": "constant.numeric.pdll" + } + } + }, + { + "match": "\\b(recursion)\\b", + "name": "entity.name.variable.pdll" + } + ] + }, + "pattern": { + "patterns": [ + { + "begin": "\\b(Pattern)\\b\\s*(\\b[aA-zZ_0-9]*\\b)?\\s*(\\bwith\\b\\s*[^\\{]*)?\\s*({)", + "beginCaptures": { + "1": { + "name": "keyword.other.pdll" + }, + "2": { + "name": "entity.name.function.pdll" + }, + "3": { + "patterns": [ + { + "include": "#pattern_metadata" + } + ] + } + }, + "patterns": [ + { + "include": "#inside_pattern" + } + ], + "end": "(})" + }, + { + "begin": "\\b(Pattern)\\b\\s*(\\b[aA-zZ_0-9]*\\b)?\\s*(\\bwith\\b\\s*[^\\=]*)?\\s*(=>)", + "beginCaptures": { + "1": { + "name": "keyword.other.pdll" + }, + "2": { + "name": "entity.name.function.pdll" + }, + "3": { + "patterns": [ + { + "include": "#pattern_metadata" + } + ] + } + }, + "patterns": [ + { + "include": "#inside_pattern" + } + ], + "end": ";" + } + ] + }, + "inside_pattern": { + "patterns": [ + { + "match": "\\b(erase|let|replace|return|rewrite|with)\\b", + "captures": { + "1": { + "name": "keyword.control.pdll" + } + } + }, + { + "include": "#expressions" + } + ] + }, + "variable_constraint": { + "patterns": [ + { + "match": "\\b(Op)<([a-zA-Z0-9_\\.$-]*)>", + "captures": { + "1": { + "name": "entity.name.type.pdll" + }, + "2": { + "name": "variable.other.enummember.pdll" + } + } + }, + { + "begin": "<", + "patterns": [ + { + "include": "#expressions" + } + ], + "end": ">" + }, + { + "match": "[a-zA-Z_0-9]+", + "name": "entity.name.type.pdll" + } + ] + }, + "variable_definition": { + "patterns": [ + { + "begin": "\\b([aA-zZ_0-9]*)\\b\\s*:\\s*\\[", + "beginCaptures": { + "1": { + "name": "entity.name.variable.pdll" + } + }, + "patterns": [ + { + "include": "#variable_constraint" + } + ], + "end": "\\]" + }, + { + "match": "\\b([aA-zZ_0-9]*)\\b\\s*:\\s*([aA-zZ_0-9]+(\\<([^\\>]+)\\>)?)", + "captures": { + "1": { + "name": "entity.name.variable.pdll" + }, + "2": { + "patterns": [ + { + "include": "#variable_constraint" + } + ] + } + } + } + ] + }, + "expressions": { + "patterns": [ + { + "include": "#user_constraint" + }, + { + "include": "#user_rewrite" + }, + { + "include": "#attr_expr" + }, + { + "include": "#op_expr" + }, + { + "include": "#type_expr" + }, + { + "include": "#call_expr" + }, + { + "include": "#variable_definition" + }, + { + "include": "#identifier_expr" + }, + { + "include": "#string" + }, + { + "include": "#string_block" + }, + { + "include": "#comment" + }, + { + "begin": "{", + "patterns": [ + { + "include": "#inside_pattern" + } + ], + "end": "}" + }, + { + "begin": "\\(", + "patterns": [ + { + "include": "#expressions" + } + ], + "end": "\\)" + } + ] + }, + "attr_expr": { + "patterns": [ + { + "begin": "(attr)<", + "beginCaptures": { + "1": { + "name": "keyword.other.pdll" + } + }, + "patterns": [ + { + "include": "#string" + }, + { + "include": "#string_block" + } + ], + "end": ">" + } + ] + }, + "call_expr": { + "begin": "\\b([a-zA-Z0-9_]+)\\(", + "beginCaptures": { + "1": { + "name": "entity.name.variable.pdll" + } + }, + "patterns": [ + { + "include": "#expressions" + } + ], + "end": "\\)" + }, + "identifier_expr": { + "match": "\\b([a-zA-Z0-9_]+)\\b", + "name": "entity.name.variable.pdll" + }, + "op_expr": { + "match": "\\b(op)<([0-9a-zA-Z_\\.]*)>", + "captures": { + "1": { + "name": "keyword.other.pdll" + }, + "2": { + "name": "variable.other.enummember.pdll" + } + } + }, + "type_expr": { + "patterns": [ + { + "begin": "\\b(type)<", + "beginCaptures": { + "1": { + "name": "keyword.other.pdll" + } + }, + "patterns": [ + { + "include": "#string" + }, + { + "include": "#string_block" + } + ], + "end": ">" + } + ] + } + }, + "scopeName": "source.pdll" +} \ No newline at end of file diff --git a/mlir/utils/coc.nvim/pdll-language-configuration.json b/mlir/utils/coc.nvim/pdll-language-configuration.json new file mode 100644 index 0000000000000..1357db8a9d4db --- /dev/null +++ b/mlir/utils/coc.nvim/pdll-language-configuration.json @@ -0,0 +1,67 @@ +{ + "comments": { + "lineComment": "//" + }, + "brackets": [ + [ + "{", + "}" + ], + [ + "[", + "]" + ], + [ + "(", + ")" + ], + [ + "<", + ">" + ] + ], + "autoClosingPairs": [ + [ + "{", + "}" + ], + [ + "[", + "]" + ], + [ + "(", + ")" + ], + [ + "<", + ">" + ], + [ + "\"", + "\"" + ] + ], + "surroundingPairs": [ + [ + "{", + "}" + ], + [ + "[", + "]" + ], + [ + "(", + ")" + ], + [ + "<", + ">" + ], + [ + "\"", + "\"" + ] + ] +} \ No newline at end of file diff --git a/mlir/utils/coc.nvim/src/config.ts b/mlir/utils/coc.nvim/src/config.ts new file mode 100644 index 0000000000000..9e5e287ce4ed1 --- /dev/null +++ b/mlir/utils/coc.nvim/src/config.ts @@ -0,0 +1,19 @@ +import * as vscode from 'coc.nvim'; + +/** + * Gets the config value `mlir.`, with an optional workspace folder. + */ +export function get(key: string, + workspaceFolder: vscode.WorkspaceFolder = null, + defaultValue: T = undefined): T { + return vscode.workspace.getConfiguration('mlir', workspaceFolder) + .get(key, defaultValue); +} + +/** + * Sets the config value `mlir.`. + */ +export function update(key: string, value: T, + target?: vscode.ConfigurationTarget) { + return vscode.workspace.getConfiguration('mlir').update(key, value, target); +} diff --git a/mlir/utils/coc.nvim/src/configWatcher.ts b/mlir/utils/coc.nvim/src/configWatcher.ts new file mode 100644 index 0000000000000..ffb94ef4c558d --- /dev/null +++ b/mlir/utils/coc.nvim/src/configWatcher.ts @@ -0,0 +1,86 @@ +import * as chokidar from 'chokidar'; +import * as vscode from 'coc.nvim'; + +import * as config from './config'; +import {MLIRContext} from './mlirContext'; + +/** + * Prompt the user to see if we should restart the server. + */ +async function promptRestart(settingName: string, promptMessage: string) { + switch (config.get(settingName)) { + case 'restart': + vscode.commands.executeCommand('mlir.restart'); + break; + case 'ignore': + break; + case 'prompt': + default: + switch (await vscode.window.showInformationMessage( + promptMessage, 'Yes', 'Yes, always', 'No, never')) { + case 'Yes': + vscode.commands.executeCommand('mlir.restart'); + break; + case 'Yes, always': + vscode.commands.executeCommand('mlir.restart'); + config.update(settingName, 'restart', + vscode.ConfigurationTarget.Global); + break; + case 'No, never': + config.update(settingName, 'ignore', + vscode.ConfigurationTarget.Global); + break; + default: + break; + } + break; + } +} + +/** + * Activate watchers that track configuration changes for the given workspace + * folder, or null if the workspace is top-level. + */ +export async function activate( + mlirContext: MLIRContext, workspaceFolder: vscode.WorkspaceFolder, + serverSettings: string[], serverPaths: string[]) { + // When a configuration change happens, check to see if we should restart the + // server. + mlirContext.subscriptions.push(vscode.workspace.onDidChangeConfiguration(event => { + for (const serverSetting of serverSettings) { + const expandedSetting = `mlir.${serverSetting}`; + if (event.affectsConfiguration(expandedSetting, workspaceFolder)) { + promptRestart( + 'onSettingsChanged', + `setting '${ + expandedSetting}' has changed. Do you want to reload the server?`); + } + } + })); + + // Setup watchers for the provided server paths. + const fileWatcherConfig = { + disableGlobbing : true, + followSymlinks : true, + ignoreInitial : true, + awaitWriteFinish : true, + }; + for (const serverPath of serverPaths) { + if (serverPath === '') { + return; + } + + // If the server path actually exists, track it in case it changes. + // TODO: coc.nvim doesn't have this API + // const fileWatcher = chokidar.watch(serverPath, fileWatcherConfig); + // fileWatcher.on('all', (event, _filename, _details) => { + // if (event != 'unlink') { + // promptRestart( + // 'onSettingsChanged', + // 'MLIR language server file has changed. Do you want to reload the server?'); + // } + // }); + // mlirContext.subscriptions.push( + // new vscode.Disposable(() => { fileWatcher.close(); })); + } +} diff --git a/mlir/utils/coc.nvim/src/extension.ts b/mlir/utils/coc.nvim/src/extension.ts new file mode 100644 index 0000000000000..363b8a21a5a40 --- /dev/null +++ b/mlir/utils/coc.nvim/src/extension.ts @@ -0,0 +1,30 @@ +import * as vscode from 'coc.nvim'; + +// import {registerMLIRExtensions} from './MLIR/mlir'; +import {MLIRContext} from './mlirContext'; +// TODO: https://github.com/neoclide/coc.nvim/discussions/4918 +// import {registerPDLLExtensions} from './PDLL/pdll'; + +/** + * This method is called when the extension is activated. The extension is + * activated the very first time a command is executed. + */ +export function activate(context: vscode.ExtensionContext) { + const outputChannel = vscode.window.createOutputChannel('MLIR'); + context.subscriptions.push(outputChannel); + + const mlirContext = new MLIRContext(); + context.subscriptions.push(mlirContext); + + // Initialize the commands of the extension. + context.subscriptions.push( + vscode.commands.registerCommand('mlir.restart', async () => { + // Dispose and reactivate the context. + mlirContext.dispose(); + await mlirContext.activate(outputChannel); + })); + // registerMLIRExtensions(context, mlirContext); + // registerPDLLExtensions(context, mlirContext); + + mlirContext.activate(outputChannel); +} diff --git a/mlir/utils/coc.nvim/src/mlirContext.ts b/mlir/utils/coc.nvim/src/mlirContext.ts new file mode 100644 index 0000000000000..136ce7e33a79d --- /dev/null +++ b/mlir/utils/coc.nvim/src/mlirContext.ts @@ -0,0 +1,392 @@ +import * as fs from 'fs'; +import * as path from 'path'; +import * as vscode from 'coc.nvim'; +import * as vscodelc from 'coc.nvim'; +import * as which from 'which'; + +import * as config from './config'; +import * as configWatcher from './configWatcher'; + +/** + * This class represents the context of a specific workspace folder. + */ +class WorkspaceFolderContext implements vscode.Disposable { + dispose() { + this.clients.forEach(async client => await client.stop()); + this.clients.clear(); + } + + clients: Map = new Map(); +} + +/** + * This class manages all of the MLIR extension state, + * including the language client. + */ +export class MLIRContext implements vscode.Disposable { + subscriptions: vscode.Disposable[] = []; + workspaceFolders: Map = new Map(); + outputChannel: vscode.OutputChannel; + + /** + * Activate the MLIR context, and start the language clients. + */ + async activate(outputChannel: vscode.OutputChannel) { + this.outputChannel = outputChannel; + + // This lambda is used to lazily start language clients for the given + // document. It removes the need to pro-actively start language clients for + // every folder within the workspace and every language type we provide. + const startClientOnOpenDocument = async (document: vscode.TextDocument) => { + await this.getOrActivateLanguageClient(vscode.Uri.parse(document.uri), document.languageId); + }; + // Process any existing documents. + for (const textDoc of vscode.workspace.textDocuments) { + await startClientOnOpenDocument(textDoc); + } + + // Watch any new documents to spawn servers when necessary. + this.subscriptions.push( + vscode.workspace.onDidOpenTextDocument(startClientOnOpenDocument)); + this.subscriptions.push( + vscode.workspace.onDidChangeWorkspaceFolders((event) => { + for (const folder of event.removed) { + const client = this.workspaceFolders.get(folder.uri.toString()); + if (client) { + client.dispose(); + this.workspaceFolders.delete(folder.uri.toString()); + } + } + })); + } + + /** + * Open or return a language server for the given uri and language. + */ + async getOrActivateLanguageClient(uri: vscode.Uri, languageId: string): + Promise { + let serverSettingName: string; + if (languageId === 'mlir') { + serverSettingName = 'server_path'; + } else if (languageId === 'pdll') { + serverSettingName = 'pdll_server_path'; + } else if (languageId === 'tablegen') { + serverSettingName = 'tablegen_server_path'; + } else { + return null; + } + + // Check the scheme of the uri. + let validSchemes = [ 'file', 'mlir.bytecode-mlir' ]; + if (!validSchemes.includes(uri.scheme)) { + return null; + } + + // Resolve the workspace folder if this document is in one. We use the + // workspace folder when determining if a server needs to be started. + let workspaceFolder = vscode.workspace.getWorkspaceFolder(uri); + let workspaceFolderStr = + workspaceFolder ? workspaceFolder.uri.toString() : ""; + + // Get or create a client context for this folder. + let folderContext = this.workspaceFolders.get(workspaceFolderStr); + if (!folderContext) { + folderContext = new WorkspaceFolderContext(); + this.workspaceFolders.set(workspaceFolderStr, folderContext); + } + // Start the client for this language if necessary. + let client = folderContext.clients.get(languageId); + if (!client) { + client = await this.activateWorkspaceFolder( + workspaceFolder, serverSettingName, languageId, this.outputChannel); + folderContext.clients.set(languageId, client); + } + return client; + } + + /** + * Prepare a compilation database option for a server. + */ + async prepareCompilationDatabaseServerOptions( + languageName: string, workspaceFolder: vscode.WorkspaceFolder, + configsToWatch: string[], pathsToWatch: string[], + additionalServerArgs: string[]) { + // Process the compilation databases attached for the workspace folder. + let databases = config.get( + `${languageName}_compilation_databases`, workspaceFolder, []); + + // If no databases were explicitly specified, default to a database in the + // 'build' directory within the current workspace. + if (databases.length === 0) { + if (workspaceFolder) { + databases.push(vscode.Uri.parse(workspaceFolder.uri).fsPath + + `/build/${languageName}_compile_commands.yml`); + } + + // Otherwise, try to resolve each of the paths. + } else { + for await (let database of databases) { + database = await this.resolvePath(database, '', workspaceFolder); + } + } + + configsToWatch.push(`${languageName}_compilation_databases`); + pathsToWatch.push(...databases); + + // Setup the compilation databases as additional arguments to pass to the + // server. + databases.filter(database => database !== ''); + additionalServerArgs.push(...databases.map( + (database) => `--${languageName}-compilation-database=${database}`)); + } + + /** + * Prepare the server options for a PDLL server, e.g. populating any + * accessible compilation databases. + */ + async preparePDLLServerOptions(workspaceFolder: vscode.WorkspaceFolder, + configsToWatch: string[], + pathsToWatch: string[], + additionalServerArgs: string[]) { + await this.prepareCompilationDatabaseServerOptions( + 'pdll', workspaceFolder, configsToWatch, pathsToWatch, + additionalServerArgs); + } + + /** + * Prepare the server options for a TableGen server, e.g. populating any + * accessible compilation databases. + */ + async prepareTableGenServerOptions(workspaceFolder: vscode.WorkspaceFolder, + configsToWatch: string[], + pathsToWatch: string[], + additionalServerArgs: string[]) { + await this.prepareCompilationDatabaseServerOptions( + 'tablegen', workspaceFolder, configsToWatch, pathsToWatch, + additionalServerArgs); + } + + /** + * Activate the language client for the given language in the given workspace + * folder. + */ + async activateWorkspaceFolder(workspaceFolder: vscode.WorkspaceFolder, + serverSettingName: string, languageName: string, + outputChannel: vscode.OutputChannel): + Promise { + let configsToWatch: string[] = []; + let filepathsToWatch: string[] = []; + let additionalServerArgs: string[] = []; + + // Initialize additional configurations for this server. + if (languageName === 'pdll') { + await this.preparePDLLServerOptions(workspaceFolder, configsToWatch, + filepathsToWatch, + additionalServerArgs); + } else if (languageName == 'tablegen') { + await this.prepareTableGenServerOptions(workspaceFolder, configsToWatch, + filepathsToWatch, + additionalServerArgs); + } + + // Try to activate the language client. + const [server, serverPath] = await this.startLanguageClient( + workspaceFolder, outputChannel, serverSettingName, languageName, + additionalServerArgs); + configsToWatch.push(serverSettingName); + filepathsToWatch.push(serverPath); + + // Watch for configuration changes on this folder. + await configWatcher.activate(this, workspaceFolder, configsToWatch, + filepathsToWatch); + return server; + } + + /** + * Start a new language client for the given language. Returns an array + * containing the opened server, or null if the server could not be started, + * and the resolved server path. + */ + async startLanguageClient(workspaceFolder: vscode.WorkspaceFolder, + outputChannel: vscode.OutputChannel, + serverSettingName: string, languageName: string, + additionalServerArgs: string[]): + Promise<[ vscodelc.LanguageClient, string ]> { + const clientTitle = languageName.toUpperCase() + ' Language Client'; + + // Get the path of the lsp-server that is used to provide language + // functionality. + var serverPath = + await this.resolveServerPath(serverSettingName, workspaceFolder); + + // If the server path is empty, bail. We don't emit errors if the user + // hasn't explicitly configured the server. + if (serverPath === '') { + return [ null, serverPath ]; + } + + // Check that the file actually exists. + if (!fs.existsSync(serverPath)) { + vscode.window + .showErrorMessage( + `${clientTitle}: Unable to resolve path for '${ + serverSettingName}', please ensure the path is correct`, + "Open Setting") + .then((value) => { + if (value === "Open Setting") { + vscode.commands.executeCommand( + 'workbench.action.openWorkspaceSettings', + {openToSide : false, query : `mlir.${serverSettingName}`}); + } + }); + return [ null, serverPath ]; + } + + // Configure the server options. + const serverOptions: vscodelc.ServerOptions = { + command : serverPath, + args : additionalServerArgs + }; + + // Configure file patterns relative to the workspace folder. + let filePattern: vscode.GlobPattern = '**/*.' + languageName; + let selectorPattern: string = null; + if (workspaceFolder) { + filePattern = new vscode.RelativePattern(workspaceFolder, filePattern); + selectorPattern = `${vscode.Uri.parse(workspaceFolder.uri).fsPath}/**/*`; + } + + // Configure the middleware of the client. This is sort of abused to allow + // for defining a "fallback" language server that operates on non-workspace + // folders. Workspace folder language servers can properly filter out + // documents not within the folder, but we can't effectively filter for + // documents outside of the workspace. To support this, and avoid having two + // servers targeting the same set of files, we use middleware to inject the + // dynamic logic for checking if a document is in the workspace. + let middleware = {}; + if (!workspaceFolder) { + middleware = { + didOpen : (document, next) : Promise => { + if (!vscode.workspace.getWorkspaceFolder(document.uri)) { + return next(document); + } + return Promise.resolve(); + } + }; + } + + // Configure the client options. + const clientOptions: vscodelc.LanguageClientOptions = { + documentSelector : [ + {language : languageName, pattern : selectorPattern}, + ], + synchronize : { + // Notify the server about file changes to language files contained in + // the workspace. + fileEvents : vscode.workspace.createFileSystemWatcher(filePattern) + }, + outputChannel : outputChannel, + workspaceFolder : workspaceFolder, + middleware : middleware, + + // Don't switch to output window when the server returns output. + revealOutputChannelOn : vscodelc.RevealOutputChannelOn.Never, + }; + + // Create the language client and start the client. + let languageClient = new vscodelc.LanguageClient( + languageName + '-lsp', clientTitle, serverOptions, clientOptions); + languageClient.start(); + return [ languageClient, serverPath ]; + } + + /** + * Given a server setting, return the default server path. + */ + static getDefaultServerFilename(serverSettingName: string): string { + if (serverSettingName === 'pdll_server_path') { + return 'mlir-pdll-lsp-server'; + } + if (serverSettingName === 'server_path') { + return 'mlir-lsp-server'; + } + if (serverSettingName === 'tablegen_server_path') { + return 'tblgen-lsp-server'; + } + return ''; + } + + /** + * Try to resolve the given path, or the default path, with an optional + * workspace folder. If a path could not be resolved, just returns the + * input filePath. + */ + async resolvePath(filePath: string, defaultPath: string, + workspaceFolder: vscode.WorkspaceFolder): Promise { + const configPath = filePath; + + // If the path is already fully resolved, there is nothing to do. + if (path.isAbsolute(filePath)) { + return filePath; + } + + // If a path hasn't been set, try to use the default path. + if (filePath === '') { + if (defaultPath === '') { + return filePath; + } + return await which(defaultPath); + + // Fallthrough to try resolving the default path. + } + + // Try to resolve the path relative to the workspace. + let filePattern: vscode.GlobPattern = '**/' + filePath; + if (workspaceFolder) { + filePattern = new vscode.RelativePattern(workspaceFolder, filePattern); + } + let foundUris = await vscode.workspace.findFiles(filePattern, null, 1); + if (foundUris.length === 0) { + // If we couldn't resolve it, just return the original path anyways. The + // file might not exist yet. + return configPath; + } + // Otherwise, return the resolved path. + return foundUris[0].fsPath; + } + + /** + * Try to resolve the path for the given server setting, with an optional + * workspace folder. + */ + async resolveServerPath(serverSettingName: string, + workspaceFolder: vscode.WorkspaceFolder): + Promise { + const serverPath = config.get(serverSettingName, workspaceFolder); + const defaultPath = MLIRContext.getDefaultServerFilename(serverSettingName); + return this.resolvePath(serverPath, defaultPath, workspaceFolder); + } + + /** + * Return the language client for the given language and uri, or null if no + * client is active. + */ + getLanguageClient(uri: vscode.Uri, + languageName: string): vscodelc.LanguageClient { + let workspaceFolder = vscode.workspace.getWorkspaceFolder(uri); + let workspaceFolderStr = + workspaceFolder ? workspaceFolder.uri.toString() : ""; + let folderContext = this.workspaceFolders.get(workspaceFolderStr); + if (!folderContext) { + return null; + } + return folderContext.clients.get(languageName); + } + + dispose() { + this.subscriptions.forEach((d) => { d.dispose(); }); + this.subscriptions = []; + this.workspaceFolders.forEach((d) => { d.dispose(); }); + this.workspaceFolders.clear(); + } +} diff --git a/mlir/utils/coc.nvim/tablegen-grammar.json b/mlir/utils/coc.nvim/tablegen-grammar.json new file mode 100644 index 0000000000000..8da8aaed19336 --- /dev/null +++ b/mlir/utils/coc.nvim/tablegen-grammar.json @@ -0,0 +1,452 @@ +{ + "name": "TableGen", + "fileTypes": [ + "td" + ], + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#preprocessor" + }, + { + "include": "#strings" + }, + { + "include": "#integer" + }, + { + "include": "#builtin_types" + }, + { + "include": "#keywords" + }, + { + "include": "#classes" + }, + { + "include": "#defs" + }, + { + "include": "#values" + } + ], + "repository": { + "comments": { + "patterns": [ + { + "match": "\/\/.*$", + "name": "comment.line.double-slash.tablegen" + }, + { + "begin": "/\\*", + "end": "\\*/", + "captures": { + "0": { + "name": "comment.block.tablegen" + } + }, + "patterns": [ + { + "include": "#comments" + } + ], + "name": "comment.block.tablegen" + } + ] + }, + "preprocessor": { + "patterns": [ + { + "match": "^#ifdef\\s+(\\w+)", + "name": "keyword.control.ifdef.tablegen", + "captures": { + "1": { + "name": "entity.name.function.preprocessor.tablegen" + } + } + }, + { + "match": "^#ifndef\\s+(\\w+)", + "name": "keyword.control.ifndef.tablegen", + "captures": { + "1": { + "name": "entity.name.function.preprocessor.tablegen" + } + } + }, + { + "match": "^#else", + "name": "keyword.control.else.tablegen" + }, + { + "match": "#endif", + "name": "keyword.control.endif.tablegen" + }, + { + "match": "#define\\s+(\\w+)", + "name": "keyword.control.ifndef.tablegen", + "captures": { + "1": { + "name": "entity.name.function.preprocessor.tablegen" + } + } + }, + { + "match": "^include\\s+", + "name": "keyword.control.include.tablegen" + } + ] + }, + "strings": { + "patterns": [ + { + "name": "string.quoted.double.tablegen", + "begin": "\"", + "end": "\"", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.tablegen" + } + }, + "patterns": [ + { + "match": "\\\\['nt\"]", + "name": "constant.character.escape.tablegen" + } + ], + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.tablegen" + } + } + }, + { + "name": "string.quoted.triple.tablegen", + "begin": "\\[{", + "end": "}]", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.tablegen" + } + }, + "patterns": [ + { + "match": "\\\\[nt\"]", + "name": "constant.character.escape.tablegen" + } + ], + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.tablegen" + } + } + } + ] + }, + "integer": { + "patterns": [ + { + "match": "\\b\\d+\\b", + "name": "constant.numeric.tablegen" + }, + { + "match": "\\b0[xX][a-fA-F0-9]+\\b", + "name": "constant.numeric.hex.tablegen" + }, + { + "match": "\\b0b[01]+\\b", + "name": "constant.numeric.binary.tablegen" + } + ] + }, + "builtin_types": { + "patterns": [ + { + "match": "\\b(?:bit|code|dag|int|string)\\b", + "name": "entity.name.type.tablegen" + }, + { + "begin": "\\b(bits)\\<", + "beginCaptures": { + "1": { + "name": "entity.name.type.tablegen" + } + }, + "patterns": [ + { + "include": "#integer" + } + ], + "end": "\\>" + }, + { + "begin": "\\b(list)\\<", + "beginCaptures": { + "1": { + "name": "entity.name.type.tablegen" + } + }, + "patterns": [ + { + "include": "#types" + } + ], + "end": "\\>" + } + ] + }, + "types": { + "patterns": [ + { + "include": "#builtin_types" + }, + { + "match": "\\b(\\w+)\\b", + "name": "entity.name.type.tablegen" + } + ] + }, + "bang_operators": { + "patterns": [ + { + "begin": "(\\!cast|\\!getdagop|\\!isa)\\<", + "beginCaptures": { + "1": { + "name": "entity.name.function" + } + }, + "patterns": [ + { + "include": "#types" + } + ], + "end": "\\>" + }, + { + "match": "(\\!\\w+)\\b", + "name": "entity.name.function" + } + ] + }, + "keywords": { + "patterns": [ + { + "match": "\\b(assert|else|foreach|defset|defvar|field|if|in|let|then)\\b", + "name": "keyword.other.tablegen" + } + ] + }, + "record_body": { + "patterns": [ + { + "begin": "\\:", + "patterns": [ + { + "match": "\\b(\\w+)\\b", + "name": "entity.name.type.tablegen" + }, + { + "begin": "\\<", + "patterns": [ + { + "include": "#values" + } + ], + "end": "\\>" + } + ], + "end": "(?=\\;|\\{)" + }, + { + "begin": "\\{", + "patterns": [ + { + "include": "#keywords" + }, + { + "include": "#builtin_types" + }, + { + "match": "\\b(\\w+\\s+)?\\b(\\w+)\\b\\s+\\=", + "captures": { + "1": { + "name": "entity.name.type.tablegen" + }, + "2": { + "name": "variable.other.tablegen" + } + } + }, + { + "include": "#values" + } + ], + "end": "(?=\\})" + } + ] + }, + "classes": { + "begin": "\\b(multiclass|class)\\b\\s+(\\w+)\\b", + "beginCaptures": { + "1": { + "name": "keyword.other.class.tablegen" + }, + "2": { + "name": "entity.name.type.tablegen" + } + }, + "patterns": [ + { + "begin": "\\<", + "patterns": [ + { + "include": "#builtin_types" + }, + { + "match": "\\b(\\w+\\s+)?\\b(\\w+)\\b", + "captures": { + "1": { + "name": "entity.name.type.tablegen" + }, + "2": { + "name": "variable.other.tablegen" + } + } + }, + { + "begin": "=", + "patterns": [ + { + "include": "#values" + } + ], + "end": "(?=\\>|\\,)" + } + ], + "end": "\\>" + }, + { + "include": "#record_body" + } + ], + "end": "(\\;|\\})" + }, + "defs": { + "begin": "\\b(defm|def)\\b", + "beginCaptures": { + "1": { + "name": "keyword.other.def.tablegen" + } + }, + "patterns": [ + { + "include": "#record_body" + }, + { + "include": "#values" + } + ], + "end": "(\\;|\\})" + }, + "values": { + "patterns": [ + { + "include": "#builtin_types" + }, + { + "include": "#bang_operators" + }, + { + "include": "#classes" + }, + { + "include": "#defs" + }, + { + "include": "#comments" + }, + { + "include": "#integer" + }, + { + "include": "#strings" + }, + { + "match": "\\b(?:false|true)\\b", + "name": "keyword.other.tablegen" + }, + { + "match": "(\\?)", + "name": "keyword.other.tablegen" + }, + { + "begin": "\\{", + "patterns": [ + { + "include": "#values" + } + ], + "end": "\\}" + }, + { + "begin": "\\[", + "patterns": [ + { + "include": "#values" + } + ], + "end": "(?=\\])" + }, + { + "begin": "\\]\\s*\\<", + "patterns": [ + { + "include": "#types" + } + ], + "end": "\\>" + }, + { + "begin": "\\(", + "patterns": [ + { + "include": "#values" + } + ], + "end": "\\)" + }, + { + "include": "#keywords" + }, + { + "begin": "\\b(\\w+)\\<", + "beginCaptures": { + "1": { + "name": "entity.name.type.tablegen" + } + }, + "patterns": [ + { + "include": "#values" + } + ], + "end": "\\>" + }, + { + "match": "(\\$\\w+)\\b", + "name": "variable.other.enummember.tablegen" + }, + { + "match": "\\b(\\w+)\\b", + "name": "variable.other.tablegen" + }, + { + "include": "#preprocessor" + } + ] + } + }, + "scopeName": "source.tablegen" +} \ No newline at end of file diff --git a/mlir/utils/coc.nvim/tablegen-language-configuration.json b/mlir/utils/coc.nvim/tablegen-language-configuration.json new file mode 100644 index 0000000000000..6a1455bf8ca7f --- /dev/null +++ b/mlir/utils/coc.nvim/tablegen-language-configuration.json @@ -0,0 +1,89 @@ +{ + "comments": { + "lineComment": "//", + "blockComment": [ + "/*", + "*/" + ] + }, + "colorizedBracketPairs": [ + [ + "{", + "}" + ], + [ + "[", + "]" + ], + [ + "(", + ")" + ], + [ + "<", + ">" + ] + ], + "brackets": [ + [ + "{", + "}" + ], + [ + "[", + "]" + ], + [ + "(", + ")" + ], + [ + "<", + ">" + ] + ], + "autoClosingPairs": [ + [ + "{", + "}" + ], + [ + "[", + "]" + ], + [ + "(", + ")" + ], + [ + "<", + ">" + ], + [ + "\"", + "\"" + ] + ], + "surroundingPairs": [ + [ + "{", + "}" + ], + [ + "[", + "]" + ], + [ + "(", + ")" + ], + [ + "<", + ">" + ], + [ + "\"", + "\"" + ] + ] +} \ No newline at end of file diff --git a/mlir/utils/coc.nvim/tsconfig.json b/mlir/utils/coc.nvim/tsconfig.json new file mode 100644 index 0000000000000..6e4d493ddfe02 --- /dev/null +++ b/mlir/utils/coc.nvim/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "outDir": "out", + "rootDir": "src", + "allowSyntheticDefaultImports": true, + "sourceMap": true + }, + "include": [ + "src" + ], + "exclude": [ + "node_modules", + ".vscode-test" + ] +}