@yaegassy/coc-ty 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +45 -0
- package/lib/index.js +383 -0
- package/package.json +192 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 yaegassy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# coc-ty
|
|
2
|
+
|
|
3
|
+
[ty](https://github.com/astral-sh/ty) language server extension for [coc.nvim](https://github.com/neoclide/coc.nvim).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
**CocInstall**:
|
|
8
|
+
|
|
9
|
+
> ...TODO
|
|
10
|
+
|
|
11
|
+
**e.g. vim-plug**:
|
|
12
|
+
|
|
13
|
+
```vim
|
|
14
|
+
Plug 'yaegassy/coc-ty', {'do': 'yarn install --frozen-lockfile'}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Configuration options
|
|
18
|
+
|
|
19
|
+
- `ty.enable`: Enable coc-ty extension, default: `true`
|
|
20
|
+
- `ty.disableHover`: Disable hover only, default: `false`
|
|
21
|
+
- `ty.disableInlayHint`: Disable inlayHint only, default: `false`
|
|
22
|
+
- `ty.disableTypeDefinition`: Disable typeDefinition only, default: `false`
|
|
23
|
+
- `ty.useDetectTyCommand`: Automatically detects the ty command in the execution environment and sets `tf.path`, default: `true`
|
|
24
|
+
- `ty.binaryPath`: Custom path for the `ty` binary. If no value is set, the `ty` command will be detected from the runtime environment, , default: `""`
|
|
25
|
+
- `ty.trace.server`: Traces the communication between coc.nvim and the ty language server, default: `"off"`
|
|
26
|
+
|
|
27
|
+
Other settings have the same configuration as [ty-vscode](https://github.com/astral-sh/ty-vscode).
|
|
28
|
+
|
|
29
|
+
## Commands
|
|
30
|
+
|
|
31
|
+
- `ty.showLogs`: Show logs
|
|
32
|
+
- `ty.restart`: Restart Server
|
|
33
|
+
|
|
34
|
+
## Thanks
|
|
35
|
+
|
|
36
|
+
- [astral-sh/ty](https://github.com/astral-sh/ty)
|
|
37
|
+
- [astral-sh/ty-vscode](https://github.com/astral-sh/ty-vscode)
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
MIT
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
> This extension is built with [create-coc-extension](https://github.com/fannheyward/create-coc-extension)
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// node_modules/isexe/windows.js
|
|
34
|
+
var require_windows = __commonJS({
|
|
35
|
+
"node_modules/isexe/windows.js"(exports, module2) {
|
|
36
|
+
module2.exports = isexe;
|
|
37
|
+
isexe.sync = sync;
|
|
38
|
+
var fs = require("fs");
|
|
39
|
+
function checkPathExt(path, options) {
|
|
40
|
+
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
41
|
+
if (!pathext) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
pathext = pathext.split(";");
|
|
45
|
+
if (pathext.indexOf("") !== -1) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
for (var i = 0; i < pathext.length; i++) {
|
|
49
|
+
var p = pathext[i].toLowerCase();
|
|
50
|
+
if (p && path.substr(-p.length).toLowerCase() === p) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
function checkStat(stat, path, options) {
|
|
57
|
+
if (!stat.isSymbolicLink() && !stat.isFile()) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return checkPathExt(path, options);
|
|
61
|
+
}
|
|
62
|
+
function isexe(path, options, cb) {
|
|
63
|
+
fs.stat(path, function(er, stat) {
|
|
64
|
+
cb(er, er ? false : checkStat(stat, path, options));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function sync(path, options) {
|
|
68
|
+
return checkStat(fs.statSync(path), path, options);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// node_modules/isexe/mode.js
|
|
74
|
+
var require_mode = __commonJS({
|
|
75
|
+
"node_modules/isexe/mode.js"(exports, module2) {
|
|
76
|
+
module2.exports = isexe;
|
|
77
|
+
isexe.sync = sync;
|
|
78
|
+
var fs = require("fs");
|
|
79
|
+
function isexe(path, options, cb) {
|
|
80
|
+
fs.stat(path, function(er, stat) {
|
|
81
|
+
cb(er, er ? false : checkStat(stat, options));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function sync(path, options) {
|
|
85
|
+
return checkStat(fs.statSync(path), options);
|
|
86
|
+
}
|
|
87
|
+
function checkStat(stat, options) {
|
|
88
|
+
return stat.isFile() && checkMode(stat, options);
|
|
89
|
+
}
|
|
90
|
+
function checkMode(stat, options) {
|
|
91
|
+
var mod = stat.mode;
|
|
92
|
+
var uid = stat.uid;
|
|
93
|
+
var gid = stat.gid;
|
|
94
|
+
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
|
|
95
|
+
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
|
|
96
|
+
var u = parseInt("100", 8);
|
|
97
|
+
var g = parseInt("010", 8);
|
|
98
|
+
var o = parseInt("001", 8);
|
|
99
|
+
var ug = u | g;
|
|
100
|
+
var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
|
|
101
|
+
return ret;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// node_modules/isexe/index.js
|
|
107
|
+
var require_isexe = __commonJS({
|
|
108
|
+
"node_modules/isexe/index.js"(exports, module2) {
|
|
109
|
+
var fs = require("fs");
|
|
110
|
+
var core;
|
|
111
|
+
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
112
|
+
core = require_windows();
|
|
113
|
+
} else {
|
|
114
|
+
core = require_mode();
|
|
115
|
+
}
|
|
116
|
+
module2.exports = isexe;
|
|
117
|
+
isexe.sync = sync;
|
|
118
|
+
function isexe(path, options, cb) {
|
|
119
|
+
if (typeof options === "function") {
|
|
120
|
+
cb = options;
|
|
121
|
+
options = {};
|
|
122
|
+
}
|
|
123
|
+
if (!cb) {
|
|
124
|
+
if (typeof Promise !== "function") {
|
|
125
|
+
throw new TypeError("callback not provided");
|
|
126
|
+
}
|
|
127
|
+
return new Promise(function(resolve, reject) {
|
|
128
|
+
isexe(path, options || {}, function(er, is) {
|
|
129
|
+
if (er) {
|
|
130
|
+
reject(er);
|
|
131
|
+
} else {
|
|
132
|
+
resolve(is);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
core(path, options || {}, function(er, is) {
|
|
138
|
+
if (er) {
|
|
139
|
+
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
140
|
+
er = null;
|
|
141
|
+
is = false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
cb(er, is);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function sync(path, options) {
|
|
148
|
+
try {
|
|
149
|
+
return core.sync(path, options || {});
|
|
150
|
+
} catch (er) {
|
|
151
|
+
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
152
|
+
return false;
|
|
153
|
+
} else {
|
|
154
|
+
throw er;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// node_modules/which/lib/index.js
|
|
162
|
+
var require_lib = __commonJS({
|
|
163
|
+
"node_modules/which/lib/index.js"(exports, module2) {
|
|
164
|
+
var isexe = require_isexe();
|
|
165
|
+
var { join, delimiter, sep, posix } = require("path");
|
|
166
|
+
var isWindows = process.platform === "win32";
|
|
167
|
+
var rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? "" : sep}]`.replace(/(\\)/g, "\\$1"));
|
|
168
|
+
var rRel = new RegExp(`^\\.${rSlash.source}`);
|
|
169
|
+
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
170
|
+
var getPathInfo = (cmd, {
|
|
171
|
+
path: optPath = process.env.PATH,
|
|
172
|
+
pathExt: optPathExt = process.env.PATHEXT,
|
|
173
|
+
delimiter: optDelimiter = delimiter
|
|
174
|
+
}) => {
|
|
175
|
+
const pathEnv = cmd.match(rSlash) ? [""] : [
|
|
176
|
+
// windows always checks the cwd first
|
|
177
|
+
...isWindows ? [process.cwd()] : [],
|
|
178
|
+
...(optPath || /* istanbul ignore next: very unusual */
|
|
179
|
+
"").split(optDelimiter)
|
|
180
|
+
];
|
|
181
|
+
if (isWindows) {
|
|
182
|
+
const pathExtExe = optPathExt || [".EXE", ".CMD", ".BAT", ".COM"].join(optDelimiter);
|
|
183
|
+
const pathExt = pathExtExe.split(optDelimiter);
|
|
184
|
+
if (cmd.includes(".") && pathExt[0] !== "") {
|
|
185
|
+
pathExt.unshift("");
|
|
186
|
+
}
|
|
187
|
+
return { pathEnv, pathExt, pathExtExe };
|
|
188
|
+
}
|
|
189
|
+
return { pathEnv, pathExt: [""] };
|
|
190
|
+
};
|
|
191
|
+
var getPathPart = (raw, cmd) => {
|
|
192
|
+
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
193
|
+
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
|
|
194
|
+
return prefix + join(pathPart, cmd);
|
|
195
|
+
};
|
|
196
|
+
var which3 = async (cmd, opt = {}) => {
|
|
197
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
198
|
+
const found = [];
|
|
199
|
+
for (const envPart of pathEnv) {
|
|
200
|
+
const p = getPathPart(envPart, cmd);
|
|
201
|
+
for (const ext of pathExt) {
|
|
202
|
+
const withExt = p + ext;
|
|
203
|
+
const is = await isexe(withExt, { pathExt: pathExtExe, ignoreErrors: true });
|
|
204
|
+
if (is) {
|
|
205
|
+
if (!opt.all) {
|
|
206
|
+
return withExt;
|
|
207
|
+
}
|
|
208
|
+
found.push(withExt);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (opt.all && found.length) {
|
|
213
|
+
return found;
|
|
214
|
+
}
|
|
215
|
+
if (opt.nothrow) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
throw getNotFoundError(cmd);
|
|
219
|
+
};
|
|
220
|
+
var whichSync = (cmd, opt = {}) => {
|
|
221
|
+
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
222
|
+
const found = [];
|
|
223
|
+
for (const pathEnvPart of pathEnv) {
|
|
224
|
+
const p = getPathPart(pathEnvPart, cmd);
|
|
225
|
+
for (const ext of pathExt) {
|
|
226
|
+
const withExt = p + ext;
|
|
227
|
+
const is = isexe.sync(withExt, { pathExt: pathExtExe, ignoreErrors: true });
|
|
228
|
+
if (is) {
|
|
229
|
+
if (!opt.all) {
|
|
230
|
+
return withExt;
|
|
231
|
+
}
|
|
232
|
+
found.push(withExt);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (opt.all && found.length) {
|
|
237
|
+
return found;
|
|
238
|
+
}
|
|
239
|
+
if (opt.nothrow) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
throw getNotFoundError(cmd);
|
|
243
|
+
};
|
|
244
|
+
module2.exports = which3;
|
|
245
|
+
which3.sync = whichSync;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
// src/index.ts
|
|
250
|
+
var src_exports = {};
|
|
251
|
+
__export(src_exports, {
|
|
252
|
+
activate: () => activate
|
|
253
|
+
});
|
|
254
|
+
module.exports = __toCommonJS(src_exports);
|
|
255
|
+
var import_coc5 = require("coc.nvim");
|
|
256
|
+
|
|
257
|
+
// src/client.ts
|
|
258
|
+
var import_coc = require("coc.nvim");
|
|
259
|
+
|
|
260
|
+
// src/constant.ts
|
|
261
|
+
var SERVER_SUBCOMMAND = "server";
|
|
262
|
+
|
|
263
|
+
// src/client.ts
|
|
264
|
+
var import_which = __toESM(require_lib());
|
|
265
|
+
function createServerClient(command) {
|
|
266
|
+
const newEnv = { ...process.env };
|
|
267
|
+
const args = [SERVER_SUBCOMMAND];
|
|
268
|
+
const serverOptions = {
|
|
269
|
+
command,
|
|
270
|
+
args,
|
|
271
|
+
options: { env: newEnv }
|
|
272
|
+
};
|
|
273
|
+
const clientOptions = {
|
|
274
|
+
documentSelector: ["python"],
|
|
275
|
+
initializationOptions: getInitializationOptions(),
|
|
276
|
+
disabledFeatures: getLanguageClientDisabledFeatures()
|
|
277
|
+
};
|
|
278
|
+
const client2 = new import_coc.LanguageClient("ty", "ty server", serverOptions, clientOptions);
|
|
279
|
+
return client2;
|
|
280
|
+
}
|
|
281
|
+
function convertFromWorkspaceConfigToInitializationOptions() {
|
|
282
|
+
const settings = import_coc.workspace.getConfiguration("ty");
|
|
283
|
+
const initializationOptions = {
|
|
284
|
+
settings: {
|
|
285
|
+
path: settings.get("path"),
|
|
286
|
+
interpreter: settings.get("interpreter"),
|
|
287
|
+
importStrategy: settings.get(`importStrategy`) ?? "fromEnvironment",
|
|
288
|
+
logLevel: settings.get("logLevel"),
|
|
289
|
+
logFile: settings.get("logFile"),
|
|
290
|
+
experimental: settings.get("experimental")
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
return initializationOptions;
|
|
294
|
+
}
|
|
295
|
+
function getInitializationOptions() {
|
|
296
|
+
const initializationOptions = convertFromWorkspaceConfigToInitializationOptions();
|
|
297
|
+
if (import_coc.workspace.getConfiguration("ty").get("useDetectTyCommand", true)) {
|
|
298
|
+
const envTyCommandPath = import_which.default.sync("ty", { nothrow: true });
|
|
299
|
+
if (envTyCommandPath) {
|
|
300
|
+
initializationOptions.settings.path = [envTyCommandPath];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return initializationOptions;
|
|
304
|
+
}
|
|
305
|
+
function getLanguageClientDisabledFeatures() {
|
|
306
|
+
const r = [];
|
|
307
|
+
if (getConfigDisableHover())
|
|
308
|
+
r.push("hover");
|
|
309
|
+
if (getConfigDisableInlayHintHover())
|
|
310
|
+
r.push("inlayHint");
|
|
311
|
+
if (getConfigDisableTypeDefinitionHover())
|
|
312
|
+
r.push("typeDefinition");
|
|
313
|
+
return r;
|
|
314
|
+
}
|
|
315
|
+
function getConfigDisableHover() {
|
|
316
|
+
return import_coc.workspace.getConfiguration("ty").get("disableHover", false);
|
|
317
|
+
}
|
|
318
|
+
function getConfigDisableInlayHintHover() {
|
|
319
|
+
return import_coc.workspace.getConfiguration("ty").get("disableInlayHint", false);
|
|
320
|
+
}
|
|
321
|
+
function getConfigDisableTypeDefinitionHover() {
|
|
322
|
+
return import_coc.workspace.getConfiguration("ty").get("disableTypeDefinition", false);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// src/commands/restart.ts
|
|
326
|
+
var import_coc2 = require("coc.nvim");
|
|
327
|
+
function register(context, client2) {
|
|
328
|
+
context.subscriptions.push(
|
|
329
|
+
import_coc2.commands.registerCommand("ty.restart", async () => {
|
|
330
|
+
if (client2) {
|
|
331
|
+
if (client2.serviceState !== import_coc2.ServiceStat.Stopped) {
|
|
332
|
+
await client2.stop();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
client2.start();
|
|
336
|
+
})
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// src/commands/showLogs.ts
|
|
341
|
+
var import_coc3 = require("coc.nvim");
|
|
342
|
+
async function register2(context, client2) {
|
|
343
|
+
await client2.onReady();
|
|
344
|
+
context.subscriptions.push(
|
|
345
|
+
import_coc3.commands.registerCommand("ty.showLogs", () => {
|
|
346
|
+
if (client2.outputChannel) {
|
|
347
|
+
client2.outputChannel.show();
|
|
348
|
+
}
|
|
349
|
+
})
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// src/tool.ts
|
|
354
|
+
var import_coc4 = require("coc.nvim");
|
|
355
|
+
var import_which2 = __toESM(require_lib());
|
|
356
|
+
async function getTyBinaryPath() {
|
|
357
|
+
let tyBinaryPath = import_coc4.workspace.getConfiguration("ty").get("binaryPath", "");
|
|
358
|
+
if (!tyBinaryPath) {
|
|
359
|
+
tyBinaryPath = import_which2.default.sync("ty", { nothrow: true }) || "";
|
|
360
|
+
}
|
|
361
|
+
return tyBinaryPath;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// src/index.ts
|
|
365
|
+
var client;
|
|
366
|
+
async function activate(context) {
|
|
367
|
+
if (!import_coc5.workspace.getConfiguration("ty").get("enable"))
|
|
368
|
+
return;
|
|
369
|
+
const command = await getTyBinaryPath();
|
|
370
|
+
if (command) {
|
|
371
|
+
client = createServerClient(command);
|
|
372
|
+
} else {
|
|
373
|
+
import_coc5.window.showWarningMessage('coc-ty | "ty" binary does not exist.`');
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
context.subscriptions.push(import_coc5.services.registLanguageClient(client));
|
|
377
|
+
register2(context, client);
|
|
378
|
+
register(context, client);
|
|
379
|
+
}
|
|
380
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
381
|
+
0 && (module.exports = {
|
|
382
|
+
activate
|
|
383
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yaegassy/coc-ty",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "coc.nvim extension with support for the ty type checker and language server.",
|
|
5
|
+
"author": "yaegassy <yosstools@gmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "lib/index.js",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"coc.nvim",
|
|
10
|
+
"python",
|
|
11
|
+
"python3",
|
|
12
|
+
"ty",
|
|
13
|
+
"type checker",
|
|
14
|
+
"coc-ty",
|
|
15
|
+
"vim",
|
|
16
|
+
"neovim"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"coc": "^0.0.80"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/yaegassy/coc-ty"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"lint": "eslint src --ext ts",
|
|
30
|
+
"clean": "rimraf lib",
|
|
31
|
+
"watch": "node esbuild.js --watch",
|
|
32
|
+
"build": "node esbuild.js",
|
|
33
|
+
"prepare": "node esbuild.js"
|
|
34
|
+
},
|
|
35
|
+
"prettier": {
|
|
36
|
+
"singleQuote": true,
|
|
37
|
+
"printWidth": 120,
|
|
38
|
+
"semi": true
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^20.11.17",
|
|
42
|
+
"@types/semver": "^7.5.8",
|
|
43
|
+
"@types/which": "^2.0.1",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
45
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
46
|
+
"coc.nvim": "^0.0.82",
|
|
47
|
+
"esbuild": "^0.16.17",
|
|
48
|
+
"eslint": "^8.56.0",
|
|
49
|
+
"eslint-config-prettier": "^9.1.0",
|
|
50
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
51
|
+
"prettier": "^3.2.5",
|
|
52
|
+
"rimraf": "^5.0.1",
|
|
53
|
+
"typescript": "^5.3.3",
|
|
54
|
+
"which": "^3.0.0"
|
|
55
|
+
},
|
|
56
|
+
"activationEvents": [
|
|
57
|
+
"onLanguage:python"
|
|
58
|
+
],
|
|
59
|
+
"contributes": {
|
|
60
|
+
"rootPatterns": [
|
|
61
|
+
{
|
|
62
|
+
"filetype": "python",
|
|
63
|
+
"patterns": [
|
|
64
|
+
"pyproject.toml",
|
|
65
|
+
"ty.toml",
|
|
66
|
+
"setup.py",
|
|
67
|
+
"setup.cfg",
|
|
68
|
+
"tox.ini",
|
|
69
|
+
"Pipfile",
|
|
70
|
+
"requirements.txt"
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"configuration": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"title": "coc-ty configuration",
|
|
77
|
+
"properties": {
|
|
78
|
+
"ty.enable": {
|
|
79
|
+
"type": "boolean",
|
|
80
|
+
"default": true,
|
|
81
|
+
"description": "Enable coc-ty extension"
|
|
82
|
+
},
|
|
83
|
+
"ty.disableHover": {
|
|
84
|
+
"type": "boolean",
|
|
85
|
+
"default": false,
|
|
86
|
+
"description": "Disable hover only."
|
|
87
|
+
},
|
|
88
|
+
"ty.disableInlayHint": {
|
|
89
|
+
"type": "boolean",
|
|
90
|
+
"default": false,
|
|
91
|
+
"description": "Disable inlayHint only."
|
|
92
|
+
},
|
|
93
|
+
"ty.disableTypeDefinition": {
|
|
94
|
+
"type": "boolean",
|
|
95
|
+
"default": false,
|
|
96
|
+
"description": "Disable typeDefinition only."
|
|
97
|
+
},
|
|
98
|
+
"ty.useDetectTyCommand": {
|
|
99
|
+
"type": "boolean",
|
|
100
|
+
"default": true,
|
|
101
|
+
"description": "Automatically detects the ty command in the execution environment and sets `ty.path`."
|
|
102
|
+
},
|
|
103
|
+
"ty.binaryPath": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"default": "",
|
|
106
|
+
"description": "Custom path for the `ty` binary when using the native server. If no value is set, the `ty` command will be detected from the runtime environment."
|
|
107
|
+
},
|
|
108
|
+
"ty.path": {
|
|
109
|
+
"default": [],
|
|
110
|
+
"markdownDescription": "Path to a custom `ty` executable, e.g., `[\"/path/to/ty\"]`.",
|
|
111
|
+
"scope": "resource",
|
|
112
|
+
"items": {
|
|
113
|
+
"type": "string"
|
|
114
|
+
},
|
|
115
|
+
"type": "array"
|
|
116
|
+
},
|
|
117
|
+
"ty.experimental.completions.enable": {
|
|
118
|
+
"default": false,
|
|
119
|
+
"markdownDescription": "Whether to enable completions.",
|
|
120
|
+
"scope": "window",
|
|
121
|
+
"type": "boolean"
|
|
122
|
+
},
|
|
123
|
+
"ty.importStrategy": {
|
|
124
|
+
"default": "fromEnvironment",
|
|
125
|
+
"markdownDescription": "Strategy for loading the `ty` executable. `fromEnvironment` picks up ty from the environment, falling back to the bundled version if needed. `useBundled` uses the version bundled with the extension.",
|
|
126
|
+
"enum": [
|
|
127
|
+
"fromEnvironment",
|
|
128
|
+
"useBundled"
|
|
129
|
+
],
|
|
130
|
+
"enumDescriptions": [
|
|
131
|
+
"Use `ty` from environment, fallback to bundled version only if `ty` not available in the environment.",
|
|
132
|
+
"Always use the bundled version of `ty`."
|
|
133
|
+
],
|
|
134
|
+
"scope": "window",
|
|
135
|
+
"type": "string"
|
|
136
|
+
},
|
|
137
|
+
"ty.interpreter": {
|
|
138
|
+
"default": [],
|
|
139
|
+
"markdownDescription": "Path to a Python interpreter to use to find the `ty` executable.",
|
|
140
|
+
"scope": "resource",
|
|
141
|
+
"items": {
|
|
142
|
+
"type": "string"
|
|
143
|
+
},
|
|
144
|
+
"type": "array"
|
|
145
|
+
},
|
|
146
|
+
"ty.logLevel": {
|
|
147
|
+
"default": null,
|
|
148
|
+
"markdownDescription": "Controls the log level of the language server.",
|
|
149
|
+
"enum": [
|
|
150
|
+
"error",
|
|
151
|
+
"warning",
|
|
152
|
+
"info",
|
|
153
|
+
"debug",
|
|
154
|
+
"trace"
|
|
155
|
+
],
|
|
156
|
+
"scope": "application",
|
|
157
|
+
"type": "string"
|
|
158
|
+
},
|
|
159
|
+
"ty.logFile": {
|
|
160
|
+
"default": null,
|
|
161
|
+
"markdownDescription": "Path to the log file for the language server.",
|
|
162
|
+
"type": "string"
|
|
163
|
+
},
|
|
164
|
+
"ty.trace.server": {
|
|
165
|
+
"type": "string",
|
|
166
|
+
"enum": [
|
|
167
|
+
"off",
|
|
168
|
+
"messages",
|
|
169
|
+
"verbose"
|
|
170
|
+
],
|
|
171
|
+
"default": "off",
|
|
172
|
+
"description": "Traces the communication between coc.nvim and the ty server."
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"commands": [
|
|
177
|
+
{
|
|
178
|
+
"command": "ty.showLogs",
|
|
179
|
+
"title": "Show logs"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"command": "ty.restart",
|
|
183
|
+
"title": "Restart Server"
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
},
|
|
187
|
+
"dependencies": {
|
|
188
|
+
"semver": "^7.6.2",
|
|
189
|
+
"toml": "^3.0.0"
|
|
190
|
+
},
|
|
191
|
+
"packageManager": "yarn@1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
|
|
192
|
+
}
|