@yaegassy/coc-ty 0.2.2 → 0.3.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/.serena/project.yml +84 -0
- package/CLAUDE.md +42 -0
- package/lib/index.js +39 -1
- package/package.json +17 -3
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# list of languages for which language servers are started; choose from:
|
|
2
|
+
# al bash clojure cpp csharp csharp_omnisharp
|
|
3
|
+
# dart elixir elm erlang fortran go
|
|
4
|
+
# haskell java julia kotlin lua markdown
|
|
5
|
+
# nix perl php python python_jedi r
|
|
6
|
+
# rego ruby ruby_solargraph rust scala swift
|
|
7
|
+
# terraform typescript typescript_vts yaml zig
|
|
8
|
+
# Note:
|
|
9
|
+
# - For C, use cpp
|
|
10
|
+
# - For JavaScript, use typescript
|
|
11
|
+
# Special requirements:
|
|
12
|
+
# - csharp: Requires the presence of a .sln file in the project folder.
|
|
13
|
+
# When using multiple languages, the first language server that supports a given file will be used for that file.
|
|
14
|
+
# The first language is the default language and the respective language server will be used as a fallback.
|
|
15
|
+
# Note that when using the JetBrains backend, language servers are not used and this list is correspondingly ignored.
|
|
16
|
+
languages:
|
|
17
|
+
- typescript
|
|
18
|
+
|
|
19
|
+
# the encoding used by text files in the project
|
|
20
|
+
# For a list of possible encodings, see https://docs.python.org/3.11/library/codecs.html#standard-encodings
|
|
21
|
+
encoding: "utf-8"
|
|
22
|
+
|
|
23
|
+
# whether to use the project's gitignore file to ignore files
|
|
24
|
+
# Added on 2025-04-07
|
|
25
|
+
ignore_all_files_in_gitignore: true
|
|
26
|
+
|
|
27
|
+
# list of additional paths to ignore
|
|
28
|
+
# same syntax as gitignore, so you can use * and **
|
|
29
|
+
# Was previously called `ignored_dirs`, please update your config if you are using that.
|
|
30
|
+
# Added (renamed) on 2025-04-07
|
|
31
|
+
ignored_paths: []
|
|
32
|
+
|
|
33
|
+
# whether the project is in read-only mode
|
|
34
|
+
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
|
|
35
|
+
# Added on 2025-04-18
|
|
36
|
+
read_only: false
|
|
37
|
+
|
|
38
|
+
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
|
|
39
|
+
# Below is the complete list of tools for convenience.
|
|
40
|
+
# To make sure you have the latest list of tools, and to view their descriptions,
|
|
41
|
+
# execute `uv run scripts/print_tool_overview.py`.
|
|
42
|
+
#
|
|
43
|
+
# * `activate_project`: Activates a project by name.
|
|
44
|
+
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
|
|
45
|
+
# * `create_text_file`: Creates/overwrites a file in the project directory.
|
|
46
|
+
# * `delete_lines`: Deletes a range of lines within a file.
|
|
47
|
+
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
|
|
48
|
+
# * `execute_shell_command`: Executes a shell command.
|
|
49
|
+
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
|
|
50
|
+
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
|
|
51
|
+
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
|
|
52
|
+
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
|
|
53
|
+
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
|
|
54
|
+
# * `initial_instructions`: Gets the initial instructions for the current project.
|
|
55
|
+
# Should only be used in settings where the system prompt cannot be set,
|
|
56
|
+
# e.g. in clients you have no control over, like Claude Desktop.
|
|
57
|
+
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
|
|
58
|
+
# * `insert_at_line`: Inserts content at a given line in a file.
|
|
59
|
+
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
|
|
60
|
+
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
|
|
61
|
+
# * `list_memories`: Lists memories in Serena's project-specific memory store.
|
|
62
|
+
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
|
|
63
|
+
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
|
|
64
|
+
# * `read_file`: Reads a file within the project directory.
|
|
65
|
+
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
|
|
66
|
+
# * `remove_project`: Removes a project from the Serena configuration.
|
|
67
|
+
# * `replace_lines`: Replaces a range of lines within a file with new content.
|
|
68
|
+
# * `replace_symbol_body`: Replaces the full definition of a symbol.
|
|
69
|
+
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
|
|
70
|
+
# * `search_for_pattern`: Performs a search for a pattern in the project.
|
|
71
|
+
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
|
|
72
|
+
# * `switch_modes`: Activates modes by providing a list of their names
|
|
73
|
+
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
|
|
74
|
+
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
|
|
75
|
+
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
|
|
76
|
+
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
|
|
77
|
+
excluded_tools: []
|
|
78
|
+
|
|
79
|
+
# initial prompt for the project. It will always be given to the LLM upon activating the project
|
|
80
|
+
# (contrary to the memories, which are loaded on demand).
|
|
81
|
+
initial_prompt: ""
|
|
82
|
+
|
|
83
|
+
project_name: "coc-ty"
|
|
84
|
+
included_optional_tools: []
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
coc-ty is a coc.nvim extension that provides LSP support for the `ty` Python type checker (by Astral). It bridges the ty language server with Vim/Neovim through the coc.nvim framework.
|
|
8
|
+
|
|
9
|
+
## Build Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
yarn install # Install dependencies
|
|
13
|
+
yarn build # Build using esbuild (src/index.ts -> lib/index.js)
|
|
14
|
+
yarn watch # Build with file watching for development
|
|
15
|
+
yarn lint # Run ESLint on src/ directory
|
|
16
|
+
yarn clean # Remove lib/ directory
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
No test framework is configured.
|
|
20
|
+
|
|
21
|
+
## Architecture
|
|
22
|
+
|
|
23
|
+
The extension follows a simple structure with ~150 lines of TypeScript:
|
|
24
|
+
|
|
25
|
+
- **src/index.ts** - Extension entry point; exports `activate()` called by coc.nvim on `onLanguage:python`
|
|
26
|
+
- **src/client.ts** - Creates and configures the LanguageClient with ServerOptions (ty binary + 'server' subcommand) and ClientOptions (document selector, initialization options, feature toggles)
|
|
27
|
+
- **src/tool.ts** - Binary detection: checks `ty.path` setting first, then falls back to system PATH via `which`
|
|
28
|
+
- **src/commands/** - Command handlers for `ty.restart` and `ty.showLogs`
|
|
29
|
+
|
|
30
|
+
All user-facing configuration options are defined in `package.json` under `contributes.configuration`. The extension converts these settings into initialization options passed to the ty language server.
|
|
31
|
+
|
|
32
|
+
## Key Integration Points
|
|
33
|
+
|
|
34
|
+
- The ty binary is invoked with `server` subcommand to start LSP mode
|
|
35
|
+
- Feature toggles (completion, diagnostics, hover, inlayHints, typeDefinition) are passed via ClientCapabilities disabled features
|
|
36
|
+
- Root patterns for Python project detection: pyproject.toml, ty.toml, setup.py, setup.cfg, tox.ini, Pipfile, requirements.txt
|
|
37
|
+
|
|
38
|
+
## Related Projects
|
|
39
|
+
|
|
40
|
+
- [astral-sh/ty](https://github.com/astral-sh/ty) - The Python type checker
|
|
41
|
+
- [ty-vscode](https://github.com/astral-sh/ty/tree/main/crates/ty_vscode) - VSCode extension this mirrors
|
|
42
|
+
- [coc.nvim](https://github.com/neoclide/coc.nvim) - The Vim/Neovim LSP framework
|
package/lib/index.js
CHANGED
|
@@ -261,6 +261,41 @@ var import_coc = require("coc.nvim");
|
|
|
261
261
|
var SERVER_SUBCOMMAND = "server";
|
|
262
262
|
|
|
263
263
|
// src/client.ts
|
|
264
|
+
var EXTENSION_ONLY_KEYS = {
|
|
265
|
+
// InitializationOptions
|
|
266
|
+
logLevel: true,
|
|
267
|
+
logFile: true,
|
|
268
|
+
// ExtensionSettings by coc-ty
|
|
269
|
+
enable: true,
|
|
270
|
+
disableCompletion: true,
|
|
271
|
+
disableDiagnostics: true,
|
|
272
|
+
disableHover: true,
|
|
273
|
+
disableInlayHint: true,
|
|
274
|
+
disableTypeDefinition: true,
|
|
275
|
+
path: true,
|
|
276
|
+
interpreter: true,
|
|
277
|
+
importStrategy: true,
|
|
278
|
+
trace: true
|
|
279
|
+
};
|
|
280
|
+
function isExtensionOnlyKey(key) {
|
|
281
|
+
return key in EXTENSION_ONLY_KEYS;
|
|
282
|
+
}
|
|
283
|
+
var configurationWorkspaceMiddleware = {
|
|
284
|
+
configuration: async (params, token, next) => {
|
|
285
|
+
const response = await next(params, token);
|
|
286
|
+
if (!Array.isArray(response)) {
|
|
287
|
+
return response;
|
|
288
|
+
}
|
|
289
|
+
return params.items.map((param, index) => {
|
|
290
|
+
const result = response[index];
|
|
291
|
+
if (param.section === "ty" && result && typeof result === "object") {
|
|
292
|
+
const serverSettings = Object.fromEntries(Object.entries(result).filter(([key]) => !isExtensionOnlyKey(key)));
|
|
293
|
+
return serverSettings;
|
|
294
|
+
}
|
|
295
|
+
return result;
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
};
|
|
264
299
|
function createServerClient(command) {
|
|
265
300
|
const newEnv = { ...process.env };
|
|
266
301
|
const args = [SERVER_SUBCOMMAND];
|
|
@@ -272,7 +307,10 @@ function createServerClient(command) {
|
|
|
272
307
|
const clientOptions = {
|
|
273
308
|
documentSelector: ["python"],
|
|
274
309
|
initializationOptions: getInitializationOptions(),
|
|
275
|
-
disabledFeatures: getLanguageClientDisabledFeatures()
|
|
310
|
+
disabledFeatures: getLanguageClientDisabledFeatures(),
|
|
311
|
+
middleware: {
|
|
312
|
+
workspace: configurationWorkspaceMiddleware
|
|
313
|
+
}
|
|
276
314
|
};
|
|
277
315
|
const client2 = new import_coc.LanguageClient("ty", "ty server", serverOptions, clientOptions);
|
|
278
316
|
return client2;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yaegassy/coc-ty",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "coc.nvim extension with support for the ty type checker and language server.",
|
|
5
5
|
"author": "yaegassy <yosstools@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -110,16 +110,30 @@
|
|
|
110
110
|
"default": "",
|
|
111
111
|
"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."
|
|
112
112
|
},
|
|
113
|
+
"ty.configuration": {
|
|
114
|
+
"default": null,
|
|
115
|
+
"markdownDescription": "Inline JSON configuration for ty settings. Overrides settings in a configuration file. For example\n\n```json\n{\n \"rules\": {\n \"unresolved-reference\": \"ignore\"\n }\n}\n``` ",
|
|
116
|
+
"scope": "window",
|
|
117
|
+
"type": "object"
|
|
118
|
+
},
|
|
119
|
+
"ty.configurationFile": {
|
|
120
|
+
"default": null,
|
|
121
|
+
"markdownDescription": "Path to a `ty.toml` configuration file.",
|
|
122
|
+
"scope": "window",
|
|
123
|
+
"type": "string"
|
|
124
|
+
},
|
|
113
125
|
"ty.diagnosticMode": {
|
|
114
126
|
"default": "openFilesOnly",
|
|
115
127
|
"markdownDescription": "Analysis scope for showing diagnostics.",
|
|
116
128
|
"enum": [
|
|
117
129
|
"openFilesOnly",
|
|
118
|
-
"workspace"
|
|
130
|
+
"workspace",
|
|
131
|
+
"off"
|
|
119
132
|
],
|
|
120
133
|
"enumDescriptions": [
|
|
121
134
|
"Analyzes and reports errors on only open files.",
|
|
122
|
-
"Analyzes and reports errors on all files in the workspace."
|
|
135
|
+
"Analyzes and reports errors on all files in the workspace.",
|
|
136
|
+
"Turn all diagnostics off. Use ty as a language server only."
|
|
123
137
|
],
|
|
124
138
|
"scope": "resource",
|
|
125
139
|
"type": "string"
|