├── VERSION ├── .gitattributes ├── .gitignore ├── docs ├── antora.yml ├── modules │ └── ROOT │ │ ├── assets │ │ └── images │ │ │ ├── code-folding.gif │ │ │ ├── code-snippets.gif │ │ │ └── syntax-highlighting.gif │ │ └── pages │ │ ├── changelog.adoc │ │ ├── features │ │ ├── code-folding.adoc │ │ ├── syntax-highlighting.adoc │ │ ├── lsp.adoc │ │ ├── index.adoc │ │ └── code-snippets.adoc │ │ ├── index.adoc │ │ └── installation.adoc └── nav.adoc ├── .github ├── dependabot.yml ├── workflows │ ├── main.yml │ ├── build.yml │ ├── __lockfile__.yml │ ├── prb.yml │ └── release.yml ├── PklProject ├── PklProject.deps.json └── index.pkl ├── MAINTAINERS.adoc ├── licenserc.toml ├── scripts ├── custom-header-style.toml └── license-header.txt ├── queries └── pkl │ ├── folds.scm │ ├── indents.scm │ ├── injections.scm │ ├── locals.scm │ └── highlights.scm ├── ftdetect └── pkl.vim ├── SECURITY.adoc ├── plugin └── pkl-neovim.vim ├── lua ├── pkl-neovim │ ├── internal.lua │ ├── lsp_commands.lua │ ├── config.lua │ ├── lsp_extensions.lua │ └── commands.lua └── pkl-neovim.lua ├── ftplugin └── pkl.vim ├── snippets └── pkl.snippets ├── CONTRIBUTING.adoc ├── CODE_OF_CONDUCT.adoc ├── doc └── pkl-neovim.txt ├── README.adoc └── LICENSE.txt /VERSION: -------------------------------------------------------------------------------- 1 | 0.6.0 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | .github/workflows/*.yml linguist-generated=true 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea/ 3 | .vscode/ 4 | doc/tags 5 | .pkl-lsp/ 6 | -------------------------------------------------------------------------------- /docs/antora.yml: -------------------------------------------------------------------------------- 1 | name: neovim 2 | title: Neovim Plugin 3 | version: 0.6.0 4 | nav: 5 | - nav.adoc 6 | -------------------------------------------------------------------------------- /docs/modules/ROOT/assets/images/code-folding.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apple/pkl-neovim/HEAD/docs/modules/ROOT/assets/images/code-folding.gif -------------------------------------------------------------------------------- /docs/modules/ROOT/assets/images/code-snippets.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apple/pkl-neovim/HEAD/docs/modules/ROOT/assets/images/code-snippets.gif -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/changelog.adoc: -------------------------------------------------------------------------------- 1 | = Changelog 2 | 3 | [[release-0.6.0]] 4 | == 0.6.0 (2024-02-02) 5 | 6 | Initial build for open source plugin 7 | -------------------------------------------------------------------------------- /docs/modules/ROOT/assets/images/syntax-highlighting.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apple/pkl-neovim/HEAD/docs/modules/ROOT/assets/images/syntax-highlighting.gif -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/features/code-folding.adoc: -------------------------------------------------------------------------------- 1 | = Code Folding 2 | 3 | Collapse and expand object and class definitions. 4 | 5 | image::code-folding.gif[Code folding demo] -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/features/syntax-highlighting.adoc: -------------------------------------------------------------------------------- 1 | = Syntax Highlighting 2 | 3 | Have your code highlighted as you type. 4 | 5 | image::syntax-highlighting.gif[Syntax highlighting demo] 6 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: / 5 | ignore: 6 | - dependency-name: '*' 7 | update-types: 8 | - version-update:semver-major 9 | schedule: 10 | interval: weekly 11 | -------------------------------------------------------------------------------- /docs/nav.adoc: -------------------------------------------------------------------------------- 1 | * xref:ROOT:installation.adoc[Installation] 2 | 3 | * xref:ROOT:features/index.adoc[Features] 4 | ** xref:ROOT:features/syntax-highlighting.adoc[Syntax Highlighting] 5 | ** xref:ROOT:features/code-folding.adoc[Code Folding] 6 | ** xref:ROOT:features/code-snippets.adoc[Code Snippets] 7 | * xref:ROOT:changelog.adoc[Changelog] 8 | -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/index.adoc: -------------------------------------------------------------------------------- 1 | = Neovim Plugin 2 | 3 | The Neovim plugin provides language support for authoring Pkl files in neovim. 4 | 5 | Follow the xref:installation.adoc[installation instructions] and check out the xref:features/index.adoc[feature overview]. 6 | 7 | NOTE: Standard vim is not supported because it does not support syntax highlighting via tree-sitter. 8 | -------------------------------------------------------------------------------- /MAINTAINERS.adoc: -------------------------------------------------------------------------------- 1 | = MAINTAINERS 2 | 3 | This page lists all active Maintainers of this repository. 4 | 5 | See link:CONTRIBUTING.adoc[] for general contribution guidelines. 6 | 7 | == Maintainers (in alphabetical order) 8 | 9 | * https://github.com/bioball[Daniel Chao] 10 | * https://github.com/stackoverflow[Islon Scherer] 11 | * https://github.com/HT154[Jen Basch] 12 | * https://github.com/holzensp[Philip Hölzenspies] 13 | -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/features/lsp.adoc: -------------------------------------------------------------------------------- 1 | = Pkl Language Server 2 | 3 | This plugin integrates with xref:lsp:ROOT:index.adoc[Pkl Language Server] to provide code completion, hover-over documentation, project support, and more! 4 | 5 | == Supported features 6 | 7 | * Go-to-definition 8 | * Hover-over documentation 9 | * Static code analysis 10 | * Quick fixes 11 | 12 | The feature set grows as the language server improves over time. 13 | -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/features/index.adoc: -------------------------------------------------------------------------------- 1 | = Features 2 | 3 | xref:features/syntax-highlighting.adoc[Syntax Highlighting]:: 4 | Have your code highlighted as you type. 5 | xref:features/code-folding.adoc[Code Folding]:: 6 | Collapse and expand object and class definitions. 7 | xref:features/code-snippets.adoc[Code Snippets]:: 8 | Insert a code snippet by typing its shortcut. 9 | xref:features/lsp.adoc[Pkl Language Server]:: 10 | Code completion, typechecking, quick fixes, goto definition, and more. 11 | -------------------------------------------------------------------------------- /licenserc.toml: -------------------------------------------------------------------------------- 1 | additionalHeaders = ["scripts/custom-header-style.toml"] 2 | 3 | headerPath = "scripts/license-header.txt" 4 | 5 | includes = [ 6 | "*.lua", 7 | "*.scm", 8 | "*.snippets", 9 | "*.vim", 10 | ] 11 | 12 | excludes = [ 13 | "doc", 14 | "docs", 15 | ] 16 | 17 | [git] 18 | attrs = 'auto' 19 | ignore = 'auto' 20 | 21 | [properties] 22 | copyrightOwner = "Apple Inc. and the Pkl project authors" 23 | 24 | [mapping.SCHEME_STYLE] 25 | extensions = ["scm"] 26 | 27 | [mapping.VIM_STYLE] 28 | extensions = ["vim"] 29 | 30 | [mapping.SCRIPT_STYLE] 31 | extensions = ["snippets"] 32 | -------------------------------------------------------------------------------- /scripts/custom-header-style.toml: -------------------------------------------------------------------------------- 1 | [SCHEME_STYLE] 2 | firstLine = '' 3 | endLine = "\n" 4 | beforeEachLine = '; ' 5 | afterEachLine = '' 6 | allowBlankLines = false 7 | multipleLines = false 8 | padLines = false 9 | skipLinePattern = '^;!.*$' 10 | firstLineDetectionPattern = ';.*$' 11 | lastLineDetectionPattern = ';.*$' 12 | 13 | [VIM_STYLE] 14 | firstLine = '' 15 | endLine = "\n" 16 | beforeEachLine = '" ' 17 | afterEachLine = '' 18 | allowBlankLines = false 19 | multipleLines = false 20 | padLines = false 21 | skipLinePattern = '^\"!.*$' 22 | firstLineDetectionPattern = '\".*$' 23 | lastLineDetectionPattern = '\".*$' 24 | -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/features/code-snippets.adoc: -------------------------------------------------------------------------------- 1 | = Code Snippets 2 | 3 | :uri-ultisnip: https://github.com/SirVer/ultisnips 4 | :uri-snipmate: https://github.com/garbas/vim-snipmate 5 | 6 | Pkl-neovim provides support for code snippets. To use, ensure either {uri-ultisnip}[UltiSnips] or {uri-snipmate}[snipMate] is installed by following their install instructions. 7 | 8 | image::code-snippets.gif[Code snippets demo] 9 | 10 | == Supported Snippets 11 | 12 | cla:: Class 13 | fun:: Function 14 | fn:: Function (short) 15 | ->:: Lambda 16 | ame:: amends 17 | ext:: extends 18 | imp:: import 19 | if:: if-else 20 | thr:: throw 21 | -------------------------------------------------------------------------------- /queries/pkl/folds.scm: -------------------------------------------------------------------------------- 1 | ; Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. 2 | ; 3 | ; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ; you may not use this file except in compliance with the License. 5 | ; You may obtain a copy of the License at 6 | ; 7 | ; https://www.apache.org/licenses/LICENSE-2.0 8 | ; 9 | ; Unless required by applicable law or agreed to in writing, software 10 | ; distributed under the License is distributed on an "AS IS" BASIS, 11 | ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ; See the License for the specific language governing permissions and 13 | ; limitations under the License. 14 | 15 | [ 16 | (objectBody) 17 | (classBody) 18 | ] @fold 19 | -------------------------------------------------------------------------------- /ftdetect/pkl.vim: -------------------------------------------------------------------------------- 1 | " Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. 2 | " 3 | " Licensed under the Apache License, Version 2.0 (the "License"); 4 | " you may not use this file except in compliance with the License. 5 | " You may obtain a copy of the License at 6 | " 7 | " https://www.apache.org/licenses/LICENSE-2.0 8 | " 9 | " Unless required by applicable law or agreed to in writing, software 10 | " distributed under the License is distributed on an "AS IS" BASIS, 11 | " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | " See the License for the specific language governing permissions and 13 | " limitations under the License. 14 | 15 | au BufRead,BufNewFile PklProject,*.pkl,*.pcf,pkl-lsp://* set filetype=pkl 16 | -------------------------------------------------------------------------------- /SECURITY.adoc: -------------------------------------------------------------------------------- 1 | = Security 2 | 3 | For the protection of our community, the Pkl team does not disclose, discuss, or confirm security issues until our investigation is complete and any necessary updates are generally available. 4 | 5 | == Reporting a security vulnerability 6 | 7 | If you have discovered a security vulnerability within the Pkl Pantry project, please report it to us. 8 | We welcome reports from everyone, including security researchers, developers, and users. 9 | 10 | Security vulnerabilities may be reported on the link:https://security.apple.com/submit[Report a vulnerability] form. 11 | When submitting a vulnerability, select "Apple Devices and Software" as the affected platform, and "Open Source" as the affected area. 12 | 13 | For more information, see https://pkl-lang.org/security.html. 14 | -------------------------------------------------------------------------------- /plugin/pkl-neovim.vim: -------------------------------------------------------------------------------- 1 | " Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. 2 | " 3 | " Licensed under the Apache License, Version 2.0 (the "License"); 4 | " you may not use this file except in compliance with the License. 5 | " You may obtain a copy of the License at 6 | " 7 | " https://www.apache.org/licenses/LICENSE-2.0 8 | " 9 | " Unless required by applicable law or agreed to in writing, software 10 | " distributed under the License is distributed on an "AS IS" BASIS, 11 | " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | " See the License for the specific language governing permissions and 13 | " limitations under the License. 14 | 15 | lua require "pkl-neovim".init() 16 | 17 | au BufReadCmd pkl-lsp://* lua require('pkl-neovim').open_lspfile(vim.fn.expand('')) 18 | -------------------------------------------------------------------------------- /scripts/license-header.txt: -------------------------------------------------------------------------------- 1 | Copyright ©{{ " " }}{%- if attrs.git_file_modified_year != attrs.git_file_created_year -%}{{ attrs.git_file_created_year }}-{{ attrs.git_file_modified_year }}{%- else -%}{{ attrs.git_file_created_year }}{%- endif -%}{{ " " }}{{ props["copyrightOwner"] }}. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | https://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | # Generated from Workflow.pkl. DO NOT EDIT. 2 | name: Build (main) 3 | 'on': 4 | push: 5 | branches: 6 | - main 7 | tags-ignore: 8 | - '**' 9 | concurrency: 10 | group: ${{ github.workflow }}-${{ github.ref }} 11 | cancel-in-progress: false 12 | permissions: 13 | contents: read 14 | jobs: 15 | test-format-license-headers: 16 | name: hawkeye-check 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 20 | with: 21 | persist-credentials: false 22 | fetch-depth: 0 23 | - run: hawkeye check --config licenserc.toml --fail-if-unknown 24 | container: 25 | image: ghcr.io/korandoru/hawkeye@sha256:c3ab994c0d81f3d116aabf9afc534e18648e3e90d7525d741c1e99dd8166ec85 26 | test: 27 | runs-on: ubuntu-latest 28 | steps: 29 | - run: echo hello 30 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # Generated from Workflow.pkl. DO NOT EDIT. 2 | name: Build 3 | 'on': 4 | push: 5 | branches-ignore: 6 | - main 7 | - release/* 8 | tags-ignore: 9 | - '**' 10 | concurrency: 11 | group: ${{ github.workflow }}-${{ github.ref }} 12 | cancel-in-progress: false 13 | permissions: 14 | contents: read 15 | jobs: 16 | test-format-license-headers: 17 | name: hawkeye-check 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 21 | with: 22 | persist-credentials: false 23 | fetch-depth: 0 24 | - run: hawkeye check --config licenserc.toml --fail-if-unknown 25 | container: 26 | image: ghcr.io/korandoru/hawkeye@sha256:c3ab994c0d81f3d116aabf9afc534e18648e3e90d7525d741c1e99dd8166ec85 27 | test: 28 | runs-on: ubuntu-latest 29 | steps: 30 | - run: echo hello 31 | -------------------------------------------------------------------------------- /.github/workflows/__lockfile__.yml: -------------------------------------------------------------------------------- 1 | #file: noinspection MandatoryParamsAbsent,UndefinedAction 2 | # This is a fake workflow that never runs. 3 | # It's used to pin actions to specific git SHAs when generating actual workflows. 4 | # It also gets updated by dependabot (see .github/dependabot.yml). 5 | # Generated from Workflow.pkl. DO NOT EDIT. 6 | name: __lockfile__ 7 | 'on': 8 | push: 9 | branches-ignore: 10 | - '**' 11 | tags-ignore: 12 | - '**' 13 | jobs: 14 | locks: 15 | if: 'false' 16 | runs-on: nothing 17 | steps: 18 | - name: actions/checkout@v6 19 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 20 | - name: actions/create-github-app-token@v2 21 | uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2 22 | - name: actions/upload-artifact@v5 23 | uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5 24 | -------------------------------------------------------------------------------- /lua/pkl-neovim/internal.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | 3 | Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | https://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | 17 | ]] 18 | local M = {} 19 | 20 | -- Deprecated; use require('pkl-neovim').init() instead 21 | function M.init() 22 | vim.deprecate("require('pkl-neovim.internal').init", "require('pkl-neovim').init", "1.0.0", "pkl-neovim") 23 | require("pkl-neovim").init() 24 | end 25 | 26 | return M 27 | -------------------------------------------------------------------------------- /queries/pkl/indents.scm: -------------------------------------------------------------------------------- 1 | ; Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. 2 | ; 3 | ; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ; you may not use this file except in compliance with the License. 5 | ; You may obtain a copy of the License at 6 | ; 7 | ; https://www.apache.org/licenses/LICENSE-2.0 8 | ; 9 | ; Unless required by applicable law or agreed to in writing, software 10 | ; distributed under the License is distributed on an "AS IS" BASIS, 11 | ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ; See the License for the specific language governing permissions and 13 | ; limitations under the License. 14 | 15 | [ 16 | (objectBody) 17 | (classBody) 18 | (ifExpr) 19 | (mlStringLiteralExpr) 20 | (importClause) 21 | (importGlobClause) 22 | ] @indent.begin 23 | 24 | 25 | ("\"\"\"") @indent.begin @indent.end ; fix for mlString's delimiter 26 | 27 | [ 28 | "}" 29 | "]" 30 | ")" 31 | "else" 32 | ] @indent.branch @indent.end 33 | 34 | 35 | -------------------------------------------------------------------------------- /ftplugin/pkl.vim: -------------------------------------------------------------------------------- 1 | " Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. 2 | " 3 | " Licensed under the Apache License, Version 2.0 (the "License"); 4 | " you may not use this file except in compliance with the License. 5 | " You may obtain a copy of the License at 6 | " 7 | " https://www.apache.org/licenses/LICENSE-2.0 8 | " 9 | " Unless required by applicable law or agreed to in writing, software 10 | " distributed under the License is distributed on an "AS IS" BASIS, 11 | " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | " See the License for the specific language governing permissions and 13 | " limitations under the License. 14 | 15 | " Fold using tree-sitter 16 | setlocal foldexpr=nvim_treesitter#foldexpr() 17 | 18 | " comment with two slashes 19 | setlocal commentstring=//\ %s 20 | 21 | " Need to enable treesitter highlighting if on main branch. 22 | " `vim.treesitter.start` symbol doesn't exist on master branch. 23 | lua << EOF 24 | if vim.treesitter.start then 25 | vim.treesitter.start() 26 | end 27 | EOF 28 | 29 | lua require('pkl-neovim').start_lsp() 30 | -------------------------------------------------------------------------------- /.github/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | 17 | amends "pkl:Project" 18 | 19 | dependencies { 20 | ["pkl.impl.ghactions"] { 21 | uri = "package://pkg.pkl-lang.org/pkl-project-commons/pkl.impl.ghactions@1.1.6" 22 | } 23 | ["com.github.actions"] { 24 | uri = "package://pkg.pkl-lang.org/pkl-pantry/com.github.actions@1.3.0" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /queries/pkl/injections.scm: -------------------------------------------------------------------------------- 1 | ; Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. 2 | ; 3 | ; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ; you may not use this file except in compliance with the License. 5 | ; You may obtain a copy of the License at 6 | ; 7 | ; https://www.apache.org/licenses/LICENSE-2.0 8 | ; 9 | ; Unless required by applicable law or agreed to in writing, software 10 | ; distributed under the License is distributed on an "AS IS" BASIS, 11 | ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ; See the License for the specific language governing permissions and 13 | ; limitations under the License. 14 | 15 | ( 16 | ((unqualifiedAccessExpr (identifier) @methodName (argumentList (slStringLiteralExpr (slStringLiteralPart) @injection.content))) 17 | (#set! injection.language "regex")) 18 | (#eq? @methodName "Regex")) 19 | 20 | ( 21 | ((unqualifiedAccessExpr (identifier) @methodName (argumentList (slStringLiteralExpr (escapeSequence) @injection.content))) 22 | (#set! injection.language "regex")) 23 | (#eq? @methodName "Regex")) 24 | ; TODO: inject markdown into doc comments 25 | -------------------------------------------------------------------------------- /lua/pkl-neovim/lsp_commands.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | 3 | Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | https://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | 17 | ]] 18 | -- Handlers responsible for executing commands. 19 | -- These correspond to the `workspace/executeCommand` message, which gets fired by pkl-lsp 20 | -- based on certain flows. 21 | return { 22 | ["pkl.syncProjects"] = function (_, _) 23 | require("pkl-neovim").sync_projects() 24 | end, 25 | ["pkl.downloadPackage"] = function (cmd, _) 26 | assert(#cmd.arguments == 1, "Expected one argument") 27 | require("pkl-neovim").download_package(cmd.arguments[1]) 28 | end 29 | } 30 | -------------------------------------------------------------------------------- /snippets/pkl.snippets: -------------------------------------------------------------------------------- 1 | # Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # https://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | snippet ame "Amends" 16 | amends "${1:moduleUri}" 17 | 18 | snippet cla "Class" 19 | class ${1:className} { 20 | } 21 | 22 | snippet ext "Extends" 23 | extends "${1:moduleUri}" 24 | 25 | snippet fun "Function" 26 | function ${1:functionName}(${2:parameterName}: ${3:parameterType}): ${4:returnType} = $0 27 | 28 | snippet fn "Function short" 29 | function ${1:functionName}(${2:parameters}) = $0 30 | 31 | snippet if "if-else" 32 | if (${1:condition}) $2 else $0 33 | 34 | snippet imp "import" 35 | import "${1:moduleUri}" 36 | 37 | snippet -> "lambda" 38 | (${1:parameters}) -> $0 39 | 40 | snippet thr "throw" 41 | throw \"${1:message}\" 42 | -------------------------------------------------------------------------------- /.github/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": { 4 | "package://pkg.pkl-lang.org/pkl-pantry/com.github.actions@1": { 5 | "type": "remote", 6 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/com.github.actions@1.3.0", 7 | "checksums": { 8 | "sha256": "76174cb974310b3d952280b76ed224eb4ee6fd5419bf696ad9a66fba44bd427d" 9 | } 10 | }, 11 | "package://pkg.pkl-lang.org/pkl-project-commons/pkl.impl.ghactions@1": { 12 | "type": "remote", 13 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-project-commons/pkl.impl.ghactions@1.1.6", 14 | "checksums": { 15 | "sha256": "efe36e694f45b0804c5fcc746774727c016c866478b8c1eb0ea86d00c8bd8cf2" 16 | } 17 | }, 18 | "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped@1": { 19 | "type": "remote", 20 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped@1.1.1", 21 | "checksums": { 22 | "sha256": "1e6e29b441ffdee2605d317f6543a4a604aab5af472b63f0c47d92a3b4b36f7f" 23 | } 24 | }, 25 | "package://pkg.pkl-lang.org/pkl-pantry/com.github.dependabot@1": { 26 | "type": "remote", 27 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/com.github.dependabot@1.0.0", 28 | "checksums": { 29 | "sha256": "02ef6f25bfca5b1d095db73ea15de79d2d2c6832ebcab61e6aba90554382abcb" 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /queries/pkl/locals.scm: -------------------------------------------------------------------------------- 1 | ; Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. 2 | ; 3 | ; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ; you may not use this file except in compliance with the License. 5 | ; You may obtain a copy of the License at 6 | ; 7 | ; https://www.apache.org/licenses/LICENSE-2.0 8 | ; 9 | ; Unless required by applicable law or agreed to in writing, software 10 | ; distributed under the License is distributed on an "AS IS" BASIS, 11 | ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ; See the License for the specific language governing permissions and 13 | ; limitations under the License. 14 | 15 | ; Scopes 16 | 17 | (module) @local.scope 18 | (clazz) @local.scope 19 | (classMethod) @local.scope 20 | (objectMethod) @local.scope 21 | (functionLiteralExpr) @local.scope 22 | (objectBody) @local.scope 23 | (letExpr) @local.scope 24 | (forGenerator) @local.scope 25 | 26 | ; Definitions 27 | 28 | (clazz (identifier) @local.definition) 29 | 30 | (typeAlias 31 | (identifier) @local.definition) 32 | 33 | (classMethod (methodHeader (identifier)) @local.definition) 34 | 35 | (objectMethod 36 | (methodHeader (identifier)) @local.definition) 37 | 38 | (classProperty 39 | (identifier) @local.definition) 40 | 41 | (objectProperty 42 | (identifier) @local.definition) 43 | 44 | (typedIdentifier 45 | (identifier) @local.definition) 46 | 47 | ; References 48 | 49 | (unqualifiedAccessExpr 50 | (identifier) @local.reference) 51 | -------------------------------------------------------------------------------- /CONTRIBUTING.adoc: -------------------------------------------------------------------------------- 1 | :uri-github-issue-pkl: https://github.com/apple/pkl-neovim/issues/new 2 | :uri-seven-rules: https://cbea.ms/git-commit/#seven-rules 3 | 4 | = Pkl Neovim Contributors Guide 5 | 6 | Welcome to the Pkl community, and thank you for contributing! 7 | This guide explains how to get involved. 8 | 9 | * <> 10 | * <> 11 | * <> 12 | 13 | == Licensing 14 | 15 | Pkl Neovim is released under the Apache 2.0 license. 16 | This is why we require that, by submitting a pull request, you acknowledge that you have the right to license your contribution to Apple and the community, and agree that your contribution is licensed under the Apache 2.0 license. 17 | 18 | == Issue Tracking 19 | 20 | To file a bug or feature request, use {uri-github-issue-pkl}[GitHub]. 21 | Be sure to include the following information: 22 | 23 | * Context 24 | ** What are/were you trying to achieve? 25 | ** What's the impact of this bug/feature? 26 | 27 | For bug reports, additionally include the following information: 28 | 29 | * The complete error message. 30 | * The simplest possible steps to reproduce. 31 | * Output produced from the template. 32 | * Error messages from the target system. 33 | 34 | == Pull Requests 35 | 36 | When preparing a pull request, follow this checklist: 37 | 38 | * Imitate the conventions of surrounding code. 39 | * Follow the {uri-seven-rules}[seven rules] of great Git commit messages: 40 | ** Separate subject from body with a blank line. 41 | ** Limit the subject line to 50 characters. 42 | ** Capitalize the subject line. 43 | ** Do not end the subject line with a period. 44 | ** Use the imperative mood in the subject line. 45 | ** Wrap the body at 72 characters. 46 | ** Use the body to explain what and why vs. how. 47 | 48 | == Maintainers 49 | 50 | The project’s maintainers (those with write access to the upstream repository) are listed in link:MAINTAINERS.adoc[]. 51 | -------------------------------------------------------------------------------- /lua/pkl-neovim/config.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | 3 | Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | https://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | 17 | ]] 18 | local M = {} 19 | 20 | ---@class pklneovim.Config 21 | ---@field pkl_cli_path? string 22 | ---@field pkl_formatter_grammar_version? string 23 | ---@field timeout_ms? number 24 | ---@field start_command? string[] 25 | 26 | ---@param path string The path to the field being validated 27 | ---@param tbl table The table to validate 28 | ---@see vim.validate 29 | ---@return boolean is_valid 30 | ---@return string|nil error_message 31 | local function validate_path(path, tbl) 32 | local ok, err = pcall(vim.validate, tbl) 33 | return ok, err and path .. "." .. err 34 | end 35 | 36 | local function validate(cfg) 37 | return validate_path("vim.g.pkl_neovim", { 38 | pkl_cli_path = { cfg.pkl_cli_path, {"string", "nil"} }, 39 | pkl_formatter_grammar_version = { cfg.pkl_formatter_grammar_version, { "string", "nil" } }, 40 | timeout_ms = { cfg.timeout_ms, {"number", "nil"} }, 41 | start_command = { cfg.start_command, {"table", "nil"} } 42 | }) 43 | end 44 | 45 | ---@type pklneovim.Config | nil 46 | vim.g.pkl_neovim = vim.g.pkl_neovim 47 | 48 | ---@return pklneovim.Config 49 | function M.get_config() 50 | if not M._config then 51 | local user_config = vim.g.pkl_neovim or {} 52 | local ok, err = validate(user_config) 53 | if not ok then 54 | vim.notify(err, vim.log.levels.ERROR) 55 | return {} 56 | end 57 | M._config = user_config 58 | end 59 | return M._config 60 | end 61 | 62 | return M 63 | -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/installation.adoc: -------------------------------------------------------------------------------- 1 | = Installation 2 | 3 | :uri-neovim: https://neovim.io 4 | :uri-nvim-treesitter: https://github.com/nvim-treesitter/nvim-treesitter 5 | :uri-vim-plug: https://github.com/junegunn/vim-plug 6 | :uri-homebrew: https://brew.sh 7 | 8 | This plugin requires {uri-neovim}[Neovim] version 0.11 or higher. 9 | 10 | Install {uri-nvim-treesitter}[nvim-treesitter] alongside this plugin using your favorite plugin manager. 11 | 12 | Here is a sample `+init.vim+` file using {uri-vim-plug}[vim-plug]. 13 | To complete the setup, you will need to run `+:PlugInstall+`, then restart neovim. 14 | 15 | [source,vim] 16 | ---- 17 | call plug#begin() 18 | Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} 19 | Plug 'https://github.com/apple/pkl-neovim.git' 20 | call plug#end() 21 | 22 | " The below is required for enabling the tree-sitter syntax engine, which is used by pkl-neovim. 23 | lua <> "$GITHUB_PATH" 54 | echo "pkl_exec=$PKL_EXEC" >> "$GITHUB_OUTPUT" 55 | - shell: bash 56 | run: pkl eval -m .github/ --project-dir .github/ .github/index.pkl 57 | - name: check git status 58 | shell: bash 59 | run: |- 60 | if [ -n "$(git status --porcelain)" ]; then 61 | echo "Running pkl resulted in a diff! You likely need to run 'pkl eval' and commit the changes." 62 | git diff --name-only 63 | exit 1 64 | fi 65 | -------------------------------------------------------------------------------- /.github/index.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | 17 | amends "@pkl.impl.ghactions/PklCI.pkl" 18 | 19 | import "@com.github.actions/context.pkl" 20 | import "@pkl.impl.ghactions/jobs/HawkeyeCheck.pkl" 21 | 22 | triggerDocsBuild = "release" 23 | 24 | testReports { 25 | excludeJobs { 26 | Regex("deploy-.*") 27 | Regex("test-format-.*") 28 | } 29 | } 30 | 31 | prb = main 32 | 33 | build = main 34 | 35 | main { 36 | jobs { 37 | ["test-format-license-headers"] = new HawkeyeCheck {}.job 38 | ["test"] { 39 | `runs-on` = "ubuntu-latest" 40 | steps { 41 | // We don't have any tests right now. 42 | new { run = "echo hello" } 43 | } 44 | } 45 | } 46 | } 47 | 48 | release = (main) { 49 | jobs { 50 | ["deploy-github-release"] { 51 | `runs-on` = "ubuntu-latest" 52 | needs = main.jobs.keys.toListing() 53 | permissions { 54 | contents = "write" 55 | } 56 | steps { 57 | new { 58 | env { 59 | ["GH_TOKEN"] = context.github.token 60 | ["GH_REPO"] = context.github.repository 61 | } 62 | run = 63 | #""" 64 | gh release create "\#(context.github.refName)" \ 65 | --title "\#(context.github.refName)" \ 66 | --target "\#(context.github.sha)" \ 67 | --verify-tag \ 68 | --notes "Release notes: https://pkl-lang.org/neovim/current/changelog.html#release-\#(context.github.refName)" 69 | """# 70 | } 71 | } 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # Generated from Workflow.pkl. DO NOT EDIT. 2 | name: Release 3 | 'on': 4 | push: 5 | branches-ignore: 6 | - '**' 7 | tags: 8 | - '**' 9 | concurrency: 10 | group: ${{ github.workflow }}-${{ github.ref }} 11 | cancel-in-progress: false 12 | permissions: 13 | contents: read 14 | jobs: 15 | test-format-license-headers: 16 | name: hawkeye-check 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 20 | with: 21 | persist-credentials: false 22 | fetch-depth: 0 23 | - run: hawkeye check --config licenserc.toml --fail-if-unknown 24 | container: 25 | image: ghcr.io/korandoru/hawkeye@sha256:c3ab994c0d81f3d116aabf9afc534e18648e3e90d7525d741c1e99dd8166ec85 26 | test: 27 | runs-on: ubuntu-latest 28 | steps: 29 | - run: echo hello 30 | deploy-github-release: 31 | needs: 32 | - test-format-license-headers 33 | - test 34 | permissions: 35 | contents: write 36 | runs-on: ubuntu-latest 37 | steps: 38 | - env: 39 | GH_TOKEN: ${{ github.token }} 40 | GH_REPO: ${{ github.repository }} 41 | run: |- 42 | gh release create "${{ github.ref_name }}" \ 43 | --title "${{ github.ref_name }}" \ 44 | --target "${{ github.sha }}" \ 45 | --verify-tag \ 46 | --notes "Release notes: https://pkl-lang.org/neovim/current/changelog.html#release-${{ github.ref_name }}" 47 | trigger-downstream-builds: 48 | if: github.repository_owner == 'apple' 49 | needs: 50 | - test-format-license-headers 51 | - test 52 | - deploy-github-release 53 | runs-on: ubuntu-latest 54 | steps: 55 | - name: Create app token 56 | id: app-token 57 | uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2 58 | with: 59 | app-id: ${{ secrets.PKL_CI_CLIENT_ID }} 60 | private-key: ${{ secrets.PKL_CI }} 61 | owner: ${{ github.repository_owner }} 62 | - name: Trigger pkl-lang.org build 63 | env: 64 | GH_TOKEN: ${{ steps.app-token.outputs.token }} 65 | run: |- 66 | gh workflow run \ 67 | --repo apple/pkl-lang.org \ 68 | --ref main \ 69 | --field source_run="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ 70 | main.yml 71 | -------------------------------------------------------------------------------- /lua/pkl-neovim/lsp_extensions.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | 3 | Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | https://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | 17 | ]] 18 | ---@enum MessageType 19 | local messageType = { 20 | error = 1, 21 | warning = 2, 22 | info = 3, 23 | log = 4, 24 | debug = 5, 25 | } 26 | 27 | ---@class Command 28 | ---@field title string Title of the command, like `save`. 29 | ---@field command string The identifier of the actual command handler. 30 | ---@field arguments any[] Arguments that the command handler should be invoked with. 31 | 32 | ---@class ActionableNotification 33 | ---@field type MessageType 34 | ---@field message string 35 | ---@field data any 36 | ---@field commands Command[] 37 | 38 | ---@param type MessageType 39 | local function get_prefix(type) 40 | local prefixes = { 41 | [messageType.error] = "[ERROR] ", 42 | [messageType.warning] = "[WARNING] " 43 | } 44 | return prefixes[type] or "" 45 | end 46 | 47 | ---@param notification ActionableNotification 48 | local function actionable_notification_handler(_, notification, ctx) 49 | local commands_iter = vim.iter(notification.commands) 50 | 51 | local titles = commands_iter 52 | :map(function (it) return it.title end) 53 | :to_table() 54 | 55 | local client = vim.lsp.clients.find_by_id(ctx.client_id) 56 | if not client then 57 | return 58 | end 59 | 60 | vim.ui.select( 61 | titles, 62 | { 63 | prompt = get_prefix(notification.type) .. notification.message 64 | }, 65 | function (response) 66 | if not response then 67 | return 68 | end 69 | local command = commands_iter 70 | :find(function (it) return it.title == response end) 71 | if not command then 72 | return 73 | end 74 | client:exec_cmd(command, { bufnr = ctx.bufnr }) 75 | end 76 | ) 77 | end 78 | 79 | return { 80 | ["pkl/actionableNotification"] = actionable_notification_handler 81 | } 82 | -------------------------------------------------------------------------------- /lua/pkl-neovim/commands.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | 3 | Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | https://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | 17 | ]] 18 | local api = vim.api 19 | 20 | local M = {} 21 | 22 | ---@class PklSubcommand 23 | ---@field impl fun(args: string[], opts: table) The command implementation 24 | ---@field complete? fun(subcmd_arg_lead: string): string[] Command completions callback, taking the lead of the subcommand's arguments 25 | 26 | ---@type table 27 | local subcommand_tbl = { 28 | syncProjects = { 29 | impl = function (args, opts) 30 | local plugin = require('pkl-neovim') 31 | plugin.sync_projects() 32 | end 33 | } 34 | } 35 | 36 | ---@param opts table :h lua-guide-commands-create 37 | local function pkl_command(opts) 38 | local fargs = opts.fargs 39 | local subcommand_key = fargs[1] 40 | local args = #fargs > 1 and vim.list_slice(fargs, 2, #fargs) or {} 41 | local subcommand = subcommand_tbl[subcommand_key] 42 | if not subcommand then 43 | vim.notify("Pkl: Unknown command: " .. subcommand_key, vim.log.levels.ERROR) 44 | return 45 | end 46 | subcommand.impl(args, opts) 47 | end 48 | 49 | M.register = function() 50 | api.nvim_create_user_command( 51 | "Pkl", 52 | pkl_command, 53 | { 54 | nargs = "+", 55 | desc = "Commands related to working with Pkl", 56 | complete = function(arg_lead, cmdline, _) 57 | -- Get the subcommand. 58 | local subcmd_key, subcmd_arg_lead = cmdline:match("^['<,'>]*Pkl[!]*%s(%S+)%s(.*)$") 59 | if subcmd_key 60 | and subcmd_arg_lead 61 | and subcommand_tbl[subcmd_key] 62 | and subcommand_tbl[subcmd_key].complete 63 | then 64 | -- The subcommand has completions. Return them. 65 | return subcommand_tbl[subcmd_key].complete(subcmd_arg_lead) 66 | end 67 | -- Check if cmdline is a subcommand 68 | if cmdline:match("^['<,'>]*Pkl[!]*%s+%w*$") then 69 | -- Filter subcommands that match 70 | local subcommand_keys = vim.tbl_keys(subcommand_tbl) 71 | return vim.iter(subcommand_keys) 72 | :filter(function(key) 73 | return key:find(arg_lead) ~= nil 74 | end) 75 | :totable() 76 | end 77 | end, 78 | } 79 | ) 80 | end 81 | 82 | return M 83 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.adoc: -------------------------------------------------------------------------------- 1 | == Code of Conduct 2 | 3 | === Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our 7 | project and our community a harassment-free experience for everyone, 8 | regardless of age, body size, disability, ethnicity, sex 9 | characteristics, gender identity and expression, level of experience, 10 | education, socio-economic status, nationality, personal appearance, 11 | race, religion, or sexual identity and orientation. 12 | 13 | === Our Standards 14 | 15 | Examples of behavior that contributes to creating a positive environment 16 | include: 17 | 18 | * Using welcoming and inclusive language 19 | * Being respectful of differing viewpoints and experiences 20 | * Gracefully accepting constructive criticism 21 | * Focusing on what is best for the community 22 | * Showing empathy towards other community members 23 | 24 | Examples of unacceptable behavior by participants include: 25 | 26 | * The use of sexualized language or imagery and unwelcome sexual 27 | attention or advances 28 | * Trolling, insulting/derogatory comments, and personal or political 29 | attacks 30 | * Public or private harassment 31 | * Publishing others’ private information, such as a physical or 32 | electronic address, without explicit permission 33 | * Other conduct which could reasonably be considered inappropriate in a 34 | professional setting 35 | 36 | === Our Responsibilities 37 | 38 | Project maintainers are responsible for clarifying the standards of 39 | acceptable behavior and are expected to take appropriate and fair 40 | corrective action in response to any instances of unacceptable behavior. 41 | 42 | Project maintainers have the right and responsibility to remove, edit, 43 | or reject comments, commits, code, wiki edits, issues, and other 44 | contributions that are not aligned to this Code of Conduct, or to ban 45 | temporarily or permanently any contributor for other behaviors that they 46 | deem inappropriate, threatening, offensive, or harmful. 47 | 48 | === Scope 49 | 50 | This Code of Conduct applies within all project spaces, and it also 51 | applies when an individual is representing the project or its community 52 | in public spaces. Examples of representing a project or community 53 | include using an official project e-mail address, posting via an 54 | official social media account, or acting as an appointed representative 55 | at an online or offline event. Representation of a project may be 56 | further defined and clarified by project maintainers. 57 | 58 | === Enforcement 59 | 60 | Instances of abusive, harassing, or otherwise unacceptable behavior may 61 | be reported by contacting the open source team at 62 | opensource-conduct@group.apple.com. All complaints will be reviewed and 63 | investigated and will result in a response that is deemed necessary and 64 | appropriate to the circumstances. The project team is obligated to 65 | maintain confidentiality with regard to the reporter of an incident. 66 | Further details of specific enforcement policies may be posted 67 | separately. 68 | 69 | Project maintainers who do not follow or enforce the Code of Conduct in 70 | good faith may face temporary or permanent repercussions as determined 71 | by other members of the project’s leadership. 72 | 73 | === Attribution 74 | 75 | This Code of Conduct is adapted from the 76 | https://www.contributor-covenant.org[Contributor Covenant], version 1.4, 77 | available at 78 | https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 79 | -------------------------------------------------------------------------------- /queries/pkl/highlights.scm: -------------------------------------------------------------------------------- 1 | ; Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved. 2 | ; 3 | ; Licensed under the Apache License, Version 2.0 (the "License"); 4 | ; you may not use this file except in compliance with the License. 5 | ; You may obtain a copy of the License at 6 | ; 7 | ; https://www.apache.org/licenses/LICENSE-2.0 8 | ; 9 | ; Unless required by applicable law or agreed to in writing, software 10 | ; distributed under the License is distributed on an "AS IS" BASIS, 11 | ; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | ; See the License for the specific language governing permissions and 13 | ; limitations under the License. 14 | 15 | ; List of captures supported by nvim-treesitter: 16 | ; https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md#highlights 17 | 18 | ; Types 19 | 20 | (clazz (identifier) @type) 21 | (typeAlias (identifier) @type) 22 | (declaredType (qualifiedIdentifier (identifier) @type)) 23 | 24 | (typeArgumentList 25 | "<" @punctuation.bracket 26 | ">" @punctuation.bracket) 27 | 28 | ; Access 29 | (unqualifiedAccessExpr 30 | (identifier) @property) 31 | 32 | (qualifiedAccessExpr 33 | (identifier) @variable.member) 34 | 35 | (qualifiedAccessExpr 36 | (identifier) @function.call (argumentList)) 37 | 38 | (unqualifiedAccessExpr 39 | (identifier) @function.call (argumentList)) 40 | 41 | ; Method definitions 42 | 43 | (classMethod (methodHeader (identifier)) @function.method) 44 | (objectMethod (methodHeader (identifier)) @function.method) 45 | 46 | ; Identifiers 47 | 48 | (classProperty (identifier) @variable.member) 49 | (objectProperty (identifier) @variable.member) 50 | 51 | (annotation "@" @attribute (qualifiedIdentifier (identifier) @attribute)) 52 | 53 | (typedIdentifier (identifier) @variable.parameter) 54 | (blankIdentifier) @variable.parameter.builtin 55 | (importClause (identifier) @variable) 56 | 57 | ; Literals 58 | 59 | (stringConstant) @string 60 | (slStringLiteralExpr) @string 61 | (mlStringLiteralExpr) @string 62 | 63 | (escapeSequence) @string.escape 64 | 65 | (intLiteralExpr) @number 66 | (floatLiteralExpr) @number.float 67 | 68 | (stringInterpolation 69 | "\\(" @punctuation.special 70 | ")" @punctuation.special) @none 71 | 72 | (stringInterpolation 73 | "\\#(" @punctuation.special 74 | ")" @punctuation.special) @none 75 | 76 | (stringInterpolation 77 | "\\##(" @punctuation.special 78 | ")" @punctuation.special) @none 79 | 80 | (lineComment) @comment 81 | (blockComment) @comment 82 | (docComment) @comment.documentation 83 | 84 | ; Operators 85 | 86 | "??" @operator 87 | "=" @operator 88 | "<" @operator 89 | ">" @operator 90 | "!" @operator 91 | "==" @operator 92 | "!=" @operator 93 | "<=" @operator 94 | ">=" @operator 95 | "&&" @operator 96 | "||" @operator 97 | "+" @operator 98 | "-" @operator 99 | "**" @operator 100 | "*" @operator 101 | "/" @operator 102 | "~/" @operator 103 | "%" @operator 104 | "|>" @operator 105 | 106 | "?" @operator.type 107 | "|" @operator.type 108 | "->" @operator.type 109 | 110 | "..." @punctuation 111 | "...?" @punctuation 112 | "," @punctuation.delimiter 113 | ":" @punctuation.delimiter 114 | "." @punctuation.delimiter 115 | "?." @punctuation.delimiter 116 | 117 | "(" @punctuation.bracket 118 | ")" @punctuation.bracket 119 | "[" @punctuation.bracket 120 | "]" @punctuation.bracket 121 | "{" @punctuation.bracket 122 | "}" @punctuation.bracket 123 | 124 | ; Keywords 125 | 126 | "abstract" @keyword 127 | "amends" @keyword 128 | "as" @keyword 129 | "class" @keyword 130 | "else" @keyword.conditional 131 | "extends" @keyword 132 | "external" @keyword 133 | (falseLiteralExpr) @boolean 134 | "for" @keyword.repeat 135 | "function" @keyword.function 136 | "hidden" @keyword 137 | "if" @keyword.conditional 138 | "import" @keyword.import 139 | "import*" @keyword.import 140 | "in" @keyword 141 | "is" @keyword 142 | "let" @keyword 143 | "local" @keyword 144 | "module" @keyword 145 | "new" @keyword 146 | (nullLiteralExpr) @constant.builtin 147 | "open" @keyword 148 | "out" @keyword 149 | (outerExpr) @variable.builtin 150 | "read" @function.method.builtin 151 | "read?" @function.method.builtin 152 | "read*" @function.method.builtin 153 | "super" @variable.builtin 154 | (thisExpr) @variable.builtin 155 | "throw" @function.method.builtin 156 | "trace" @function.method.builtin 157 | (trueLiteralExpr) @boolean 158 | "typealias" @keyword 159 | (nothingType) @type.builtin 160 | (unknownType) @type.builtin 161 | (moduleType) @type.builtin 162 | "when" @keyword.conditional 163 | -------------------------------------------------------------------------------- /doc/pkl-neovim.txt: -------------------------------------------------------------------------------- 1 | *pkl-neovim.txt* Last change 2025 April 15 2 | 3 | Language support for the Pkl configuration language. 4 | 5 | https://pkl-lang.org 6 | 7 | =============================================================================== 8 | CONTENTS *pkl-neovim-contents* 9 | 10 | 1. Features: |pkl-neovim-features| 11 | 2. Commands: |pkl-neovim-commands| 12 | 3. Installation: |pkl-neovim-installation| 13 | 3. Configuration: |pkl-neovim-configuration| 14 | 4. Requirements: |pkl-neovim-requirements| 15 | 5. Information: |pkl-neovim-information| 16 | 17 | =============================================================================== 18 | FEATURES *pkl-neovim-features* 19 | 20 | * Syntax Highlighting 21 | (via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)) 22 | * Indentation 23 | (via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)) 24 | * Code folding 25 | (via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)) 26 | * Snippet support (via [SnipMate](https://github.com/garbas/vim-snipmate) or 27 | [UltiSnips](https://github.com/SirVer/ultisnips)) 28 | * Code completion, typechecking, quick fixes, documentation via 29 | [Pkl Language Server](https://pkl-lang.org/lsp/current/index.html) 30 | 31 | =============================================================================== 32 | COMMANDS *pkl-neovim-commands* 33 | *:Pkl* 34 | `:Pkl {command {args?}}` 35 | 36 | :Pkl syncProjects 37 | 38 | Tell the Pkl Language Server to build an understanding of the current 39 | workspace's Pkl projects. 40 | 41 | Executing this command enables language insights of dependencies, including 42 | type-checking, go-to-definition, and more. 43 | 44 | =============================================================================== 45 | INSTALLATION *pkl-neovim-installation* 46 | 47 | 1. Install {nvim-tree-sitter/nvim-treesitter} and {pkl-neovim} using your 48 | plugin manager of choice. For example, if using vim-plug, add this to 49 | your `init.vim`, then run `:PlugInstall`: 50 | 51 | > 52 | call plug#begin() 53 | Plug 'nvim-treesitter/nvim-treesitter' 54 | Plug 'git@github.com:apple/pkl-neovim.git' 55 | call plug#end() 56 | < 57 | 2. Enable tree-sitter features for Pkl in your `init.vim`. For example: 58 | 59 | > 60 | lua < 81 | vim.g.pkl_neovim = { 82 | start_command = { "java", "-jar", "/path/to/pkl-lsp" } 83 | } 84 | < 85 | 86 | > 87 | ---@type pklneovim.Config 88 | vim.g.pkl_neovim 89 | < 90 | 91 | *vim.g.pkl_neovim* 92 | *g:pkl_neovim* 93 | PklNeovimConfig *PklNeovimConfig* 94 | 95 | Fields: ~ 96 | {pkl_cli_path?} (string) 97 | Local path in your file system where the Pkl CLI is installed. 98 | 99 | {pkl_formatter_grammar_version?} (string) 100 | Grammar version to use when formatting Pkl code. 101 | Possible values: "1" or "2". 102 | 1: Pkl 0.25 - 0.29 103 | 2: Pkl 0.30+ 104 | 105 | {timeout_ms?} (number) 106 | The number of milliseconds to wait for responses from Pkl Language 107 | Server. 108 | (Default: 5000) 109 | 110 | {start_command?} (string[]) 111 | The command to run to start the Pkl Language Server. 112 | 113 | =============================================================================== 114 | REQUIREMENTS *pkl-neovim-requirements* 115 | 116 | * Neovim version 0.11 or higher (https://neovim.io/) 117 | * nvim-treesitter (https://github.com/nvim-treesitter/nvim-treesitter) 118 | * (Optional) Java 22 or higher 119 | * (Optional) Pkl Language Server (https://github.com/apple/pkl-lsp) 120 | =============================================================================== 121 | INFORMATION *pkl-neovim-information* 122 | 123 | Author: The Pkl team 124 | Repo: https://github.com/apple/pkl-neovim 125 | 126 | =============================================================================== 127 | =============================================================================== 128 | " vim:ft=help:et:ts=2:sw=2:sts=2:norl: 129 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = pkl-neovim 2 | 3 | :uri-lazy-nvim: https://github.com/folke/lazy.nvim 4 | :uri-lazyvim: https://github.com/LazyVim/LazyVim 5 | :uri-neovim: https://neovim.io 6 | :uri-nvim-treesitter: https://github.com/nvim-treesitter/nvim-treesitter 7 | :uri-packer-nvim: https://github.com/wbthomason/packer.nvim 8 | :uri-snipmate: https://github.com/garbas/vim-snipmate 9 | :uri-ultisnips: https://github.com/SirVer/ultisnips 10 | :uri-vim-plug: https://github.com/junegunn/vim-plug 11 | :uri-homebrew: https://brew.sh 12 | :uri-pkl-lsp: https://pkl-lang.org/lsp/current/index.html 13 | 14 | This repository provides language support for Pkl for {uri-neovim}[neovim]. 15 | 16 | Supported features: 17 | 18 | - Syntax highlighting (via {uri-nvim-treesitter}[nvim-treesitter]) 19 | - Code folding (via {uri-nvim-treesitter}[nvim-treesitter]) 20 | - Code snippets (via {uri-snipmate}[SnipMate] or {uri-ultisnips}[UltiSnips]) 21 | - Go-to definition, code completion, typechecking, quick fixes, and more (via {uri-pkl-lsp}[Pkl Language Server]) 22 | 23 | == Quick Start 24 | 25 | 1. <> through your favorite plugin manager. 26 | 2. Download the latest https://github.com/apple/pkl-lsp/releases[Pkl Language Server] + 27 | Alternatively, install with homebrew with `brew install pkl-lsp` 28 | 3. Configure the LSP start command and Pkl CLI path: 29 | + 30 | [source,lua] 31 | ---- 32 | vim.g.pkl_neovim = { 33 | start_command = { "java", "-jar", "/path/to/pkl-lsp.jar" }, 34 | -- or if pkl-lsp is installed with brew: 35 | -- start_command = { "pkl-lsp" }, 36 | pkl_cli_path = "/path/to/pkl" 37 | } 38 | ---- 39 | 40 | [[installation]] 41 | == Installation 42 | 43 | === Requirements 44 | 45 | * {uri-neovim}[Neovim] version 0.11 or higher. 46 | * {uri-nvim-treesitter}[nvim-treesitter] 47 | * {uri-pkl-lsp}[Pkl Language Server] 48 | * Java 22 or higher 49 | 50 | === vim-plug setup 51 | 52 | Here is a sample `+init.vim+` file using {uri-vim-plug}[vim-plug]. 53 | To complete the setup, you will need to run `+:PlugInstall+`, then restart neovim. 54 | 55 | [source,vim] 56 | ---- 57 | call plug#begin() 58 | Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} 59 | Plug 'https://github.com/apple/pkl-neovim.git' 60 | call plug#end() 61 | 62 | " The below is required for enabling the tree-sitter syntax engine, which is used by pkl-neovim. 63 | lua <>. 166 | 167 | To do this, run the `:Pkl syncProjects` command. 168 | Alternatively, run lua function `require('pkl-neovim').sync_projects()`. 169 | 170 | [[workspace-root]] 171 | == Workspace root 172 | 173 | When starting {uri-pkl-lsp}[Pkl Language Server], pkl-neovim will look for the following files/directories to determine what the workspace root is (in descending order of priority): 174 | 175 | 1. `.pkl-lsp/` 176 | 2. `.git/` 177 | 3. `PklProject` 178 | 179 | If you are working on a non-git based project, it can be helpful to create a `.pkl-lsp` to mark where the workspace root is. 180 | This allows the language server to discover multiple Pkl projects, and analyze dependency imports in all of them. 181 | This also allows pkl-neovim to determine that the same instance of the language server can be shared between different buffers. 182 | -------------------------------------------------------------------------------- /lua/pkl-neovim.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | 3 | Copyright © 2025 Apple Inc. and the Pkl project authors. All rights reserved. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | https://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | 17 | ]] 18 | local api = vim.api 19 | 20 | local M = {} 21 | 22 | local function get_lsp_client() 23 | for _, c in ipairs(vim.lsp.get_clients()) do 24 | if c.name == "pkl" then 25 | return c 26 | end 27 | end 28 | end 29 | 30 | local function get_or_start_lsp_client() 31 | local client = get_lsp_client() 32 | if not client then 33 | M.start_lsp() 34 | end 35 | client = get_lsp_client() 36 | assert(client, "Pkl LSP client is not started") 37 | return client 38 | end 39 | 40 | function M.init() 41 | M.init_grammar() 42 | require("pkl-neovim.commands").register() 43 | end 44 | 45 | function M.init_grammar() 46 | local parsersModuleExists, parsers = pcall(require, "nvim-treesitter.parsers") 47 | local installerExists, installer = pcall(require, "nvim-treesitter.install") 48 | local pkl_parser_config = { 49 | install_info = { 50 | url = "https://github.com/apple/tree-sitter-pkl.git", 51 | revision = "v0.20.0", 52 | files = {"src/parser.c", "src/scanner.c"}, 53 | filetype = "pkl", 54 | used_by = {"pcf"} 55 | }, 56 | } 57 | if parsersModuleExists then 58 | -- Try the "master" branch API first (get_parser_configs) 59 | local parser_config = parsers.get_parser_configs and parsers.get_parser_configs() 60 | if parser_config then 61 | -- "master" branch API 62 | parser_config.pkl = pkl_parser_config 63 | 64 | if installerExists and not parsers.has_parser("pkl") then 65 | installer.update("pkl") 66 | end 67 | else 68 | -- "main" branch API - register parser info differently 69 | -- In main branch, parser configs are accessed via the list property 70 | local ok, parser_list = pcall(function() 71 | return require("nvim-treesitter.parsers").list 72 | end) 73 | 74 | if ok and parser_list then 75 | parser_list.pkl = pkl_parser_config 76 | end 77 | 78 | -- Register the language associations 79 | if vim.treesitter and vim.treesitter.language then 80 | vim.treesitter.language.register("pkl", "pkl") 81 | vim.treesitter.language.register("pkl", "pcf") 82 | end 83 | 84 | -- Install parser if needed (main branch) 85 | if installerExists then 86 | installer.update { with_sync = false, lang = "pkl" } 87 | end 88 | end 89 | else 90 | print("[pkl-neovim] Required plugin 'tree-sitter/tree-sitter' not found.") 91 | print(" Ensure that it is installed in order to receive features such as syntax highlighting and code folding.") 92 | end 93 | end 94 | 95 | ---Starts the Pkl LSP, if not already started. 96 | ---No-op if the start command is not configured. 97 | function M.start_lsp() 98 | local config = require("pkl-neovim.config").get_config() 99 | if not config.start_command then 100 | vim.notify_once("Configuration `vim.g.pkl_neovim.start_command` is not set; Pkl LSP features are not enabled.", vim.log.levels.WARN) 101 | return 102 | end 103 | vim.lsp.start({ 104 | name = 'pkl', 105 | settings = { 106 | ["pkl.cli.path"] = config.pkl_cli_path 107 | }, 108 | -- first look for a `.pkl-lsp` dir 109 | -- failing that, look for a `.git` dir 110 | -- failing that, look for a PklProject file 111 | root_dir = 112 | vim.fs.root(0, '.pkl-lsp') 113 | or vim.fs.root(0, '.git') 114 | or vim.fs.root(0, 'PklProject'), 115 | cmd = config.start_command, 116 | handlers = require("pkl-neovim.lsp_extensions"), 117 | commands = require("pkl-neovim.lsp_commands"), 118 | init_options = { 119 | extendedClientCapabilities = { 120 | actionableRuntimeNotifications = true 121 | } 122 | } 123 | }) 124 | end 125 | 126 | ---Opens the provided `pkl-lsp://` scheme file in the current buffer. 127 | --- 128 | ---@param fname string URI of the file to open 129 | function M.open_lspfile(fname) 130 | local client = get_lsp_client() 131 | local config = require("pkl-neovim.config").get_config() 132 | assert(client, "No Pkl LSP instance found attached to the current buffer") 133 | local timeout_ms = config.timeout_ms or 5000 134 | local buf = api.nvim_get_current_buf() 135 | vim.bo[buf].modifiable = true 136 | vim.bo[buf].swapfile = false 137 | vim.bo[buf].buftype = 'nofile' 138 | vim.bo[buf].filetype = 'pkl' 139 | local content 140 | local function handler(err, result) 141 | assert(not err, vim.inspect(err)) 142 | content = result 143 | local normalized = string.gsub(result, '\r\n', '\n') 144 | local source_lines = vim.split(normalized, "\n", { plain = true }) 145 | 146 | api.nvim_buf_set_lines(buf, 0, -1, false, source_lines) 147 | vim.bo[buf].modifiable = false 148 | end 149 | client:request("pkl/fileContents", { uri = fname }, handler, buf) 150 | -- Need to block. Otherwise logic could run that sets the cursor to a position 151 | -- that's still missing. 152 | vim.wait(timeout_ms, function() return content ~= nil end) 153 | end 154 | 155 | ---Tells the existing Pkl LSP to run the syncProjects action. 156 | ---Scans the workspace directories for PklProject files, and creates a graph of dependencies. 157 | function M.sync_projects() 158 | local client = get_or_start_lsp_client() 159 | assert(client, "No Pkl LSP instance found attached to the current buffer") 160 | local buf = api.nvim_get_current_buf() 161 | client:request("pkl/syncProjects", nil, function() end, buf) 162 | end 163 | 164 | ---Tells the LSP to download the specified package. 165 | ---This requires that `vim.g.pkl_neovim.pkl_cli_path` has been set to the Pkl executable. 166 | ---@param packageUri string 167 | function M.download_package(packageUri) 168 | local client = get_or_start_lsp_client() 169 | assert(client, "No Pkl LSP instance found attached to the current buffer") 170 | local buf = api.nvim_get_current_buf() 171 | client:request("pkl/downloadPackage", packageUri, function() end, buf) 172 | end 173 | 174 | return M 175 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | --------------------------------------------------------------------------------