diff --git a/client/src/extension.ts b/client/src/extension.ts index 82748fe..7fa6b60 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -1,12 +1,21 @@ import * as path from 'path' +//# #if HAVE_VSCODE import { ExtensionContext, languages, SemanticTokensLegend } from 'vscode' +//# #elif HAVE_COC_NVIM +//# import { ExtensionContext, languages, SemanticTokensLegend } from 'coc.nvim' +//# #define Thenable Promise +//# #endif import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind, +//# #if HAVE_VSCODE } from 'vscode-languageclient/node' +//# #elif HAVE_COC_NVIM +//# } from 'coc.nvim' +//# #endif import { SemanticTokensProvider, tokenTypesLegend } from './semanticTokens' let client: LanguageClient @@ -46,9 +55,13 @@ export function activate(context: ExtensionContext) { client.onReady().then(() => { context.subscriptions.push( languages.registerDocumentSemanticTokensProvider( - { language: 'awk' }, + [{ language: 'awk' }], new SemanticTokensProvider(client), + //# #if HAVE_VSCODE new SemanticTokensLegend(tokenTypesLegend, []), + //# #elif HAVE_COC_NVIM + //# {tokenTypes: tokenTypesLegend, tokenModifiers: []}, + //# #endif ), ) }) diff --git a/client/src/semanticTokens.ts b/client/src/semanticTokens.ts index e11bf89..fc327d0 100644 --- a/client/src/semanticTokens.ts +++ b/client/src/semanticTokens.ts @@ -4,8 +4,13 @@ import { SemanticTokens, SemanticTokensBuilder, TextDocument, + //# #if HAVE_VSCODE } from 'vscode' import { LanguageClient } from 'vscode-languageclient/node' +//# #elif HAVE_COC_NVIM +//# } from 'coc.nvim' +//# import { LanguageClient } from 'coc.nvim' +//# #endif const tokenTypes = new Map() diff --git a/coc-awk/.npmignore b/coc-awk/.npmignore new file mode 100644 index 0000000..6875b6f --- /dev/null +++ b/coc-awk/.npmignore @@ -0,0 +1,3 @@ +/* +!/out/ +*.map diff --git a/coc-awk/README.md b/coc-awk/README.md new file mode 100644 index 0000000..5ac7ca8 --- /dev/null +++ b/coc-awk/README.md @@ -0,0 +1,20 @@ +# AWK IDE + +Ported from [awk-ide-vscode](https://github.com/Beaglefoot/awk-language-server). + +## Install + +- [coc-marketplace](https://github.com/fannheyward/coc-marketplace) +- [npm](https://www.npmjs.com/package/coc-awk) +- vim: + +```vim +" command line +CocInstall coc-awk +" or add the following code to your vimrc +let g:coc_global_extensions = ['coc-awk', 'other coc-plugins'] +``` + +## Usage + +Refer [awk-language-server](https://github.com/Beaglefoot/awk-language-server). diff --git a/coc-awk/package.json b/coc-awk/package.json new file mode 100644 index 0000000..c19071a --- /dev/null +++ b/coc-awk/package.json @@ -0,0 +1,99 @@ +{ + "name": "coc-awk", + "displayName": "AWK IDE", + "description": "coc.nvim client for AWK Language Server", + "author": "Stanislav Chernov ", + "license": "MIT", + "version": "0.0.1", + "publisher": "beaglefoot", + "repository": { + "type": "git", + "url": "https://github.com/Beaglefoot/awk-language-server" + }, + "icon": "icon/awk_ide_logo.png", + "engines": { + "coc": "^0.0.82" + }, + "categories": [ + "Programming Languages", + "Formatters" + ], + "keywords": [ + "coc.nvim", + "awk", + "gawk", + "ide", + "lsp" + ], + "activationEvents": [ + "onLanguage:awk" + ], + "main": "./out/extension.js", + "contributes": { + "configuration": { + "type": "object", + "title": "AWK IDE", + "properties": { + "awk-ide-vscode.trace.server": { + "scope": "window", + "type": "string", + "enum": [ + "off", + "messages", + "verbose" + ], + "default": "off", + "description": "Traces the communication between VS Code and the language server." + }, + "awk-ide-vscode.indexing": { + "scope": "window", + "type": "boolean", + "default": true, + "description": "Turns on/off source files indexing. Requires restart." + } + } + }, + "languages": [ + { + "id": "awk", + "extensions": [ + ".awk", + ".gawk" + ], + "aliases": [ + "AWK", + "awk", + "GAWK", + "gawk" + ], + "firstLine": "^#!/.*\\bawk*\\b", + "configuration": "./language-configuration.json" + } + ], + "configurationDefaults": { + "[awk]": { + "editor.semanticHighlighting.enabled": true + } + }, + "grammars": [ + { + "language": "awk", + "scopeName": "source.awk", + "path": "./syntaxes/awk.tmGrammar.json" + } + ] + }, + "scripts": { + "vscode:prepublish": "cd .. && yarn build:client:force", + "patch": "scripts/patch.sh ../client/src/*.ts", + "prepack": "npm run patch && tsc -b tsconfig.json" + }, + "dependencies": { + "awk-language-server": "0.10.6" + }, + "devDependencies": { + "@types/node": "^22.5.2", + "coc.nvim": "^0.0.83-next.18", + "typescript": "^4.3.2" + } +} diff --git a/coc-awk/scripts/patch.pl b/coc-awk/scripts/patch.pl new file mode 100755 index 0000000..5363953 --- /dev/null +++ b/coc-awk/scripts/patch.pl @@ -0,0 +1,2 @@ +#!/usr/bin/env -S perl -p +s=//#==; diff --git a/coc-awk/scripts/patch.sh b/coc-awk/scripts/patch.sh new file mode 100755 index 0000000..0cb95af --- /dev/null +++ b/coc-awk/scripts/patch.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -e +cd "$(dirname "$(dirname "$(readlink -f "$0")")")" + +for file; do + scripts/patch.pl "$file" | cpp -DHAVE_COC_NVIM -xassembler-with-cpp -nostdinc -P -C -o"${file#*/*/}" +done diff --git a/coc-awk/src/.gitignore b/coc-awk/src/.gitignore new file mode 100644 index 0000000..a68d087 --- /dev/null +++ b/coc-awk/src/.gitignore @@ -0,0 +1,2 @@ +/* +!/.gitignore diff --git a/coc-awk/tsconfig.json b/coc-awk/tsconfig.json new file mode 100644 index 0000000..e8ba1c7 --- /dev/null +++ b/coc-awk/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "out", + "rootDir": "src", + "allowSyntheticDefaultImports": true, + "noImplicitAny": false + }, + "include": ["src"], + "exclude": ["node_modules"] +}