@knip/language-server
v0.0.3
Published
Find unused files, dependencies, and exports in your JavaScript/TypeScript projects.
Downloads
163
Readme
Knip Language Server
Knip
Find unused files, dependencies, and exports in your JavaScript/TypeScript projects.
- Website: knip.dev
- GitHub repo: webpro-nl/knip
- Follow @webpro.nl on Bluesky for updates
- Blogpost: Knip for Editors & Agents
- Sponsor Knip
Contents
Configuration
Latest version of available settings: types.d.ts
Diagnostics
Diagnostics should work out of the box.
Most Knip issue types are translated to Diagnostic items with a
DiagnosticSeverity and emitted using this.connection.sendDiagnostics(). Also
see diagnostics.js for details.
Code Actions
Code actions should work out of the box.
Some issues/diagnostics have code actions available. Also see code-actions.js for details.
File Descriptor
Clients request the file descriptor to get available data for a document by
sending the REQUEST_FILE_NODE request, in short:
const file = await this.#client.sendRequest(REQUEST_FILE_NODE, {
uri: editor.document.uri.toString(),
});Type definition for File: session/types.ts
The file descriptor can be used to implement features like Annotations,
Export Hover, Imports and Exports.
Annotations
Annotations (aka "Code Lens" or "Inlay Hint") for exported identifiers can be
implemented using data from the file descriptor.
Example:
Export Hover
On hover of an export identifier, the file descriptor can be used to render
import locations for the exported identifier.
Optionally, code snippets can be searched for using the provided locations and mixed into the rendered list.
Example:
Imports
The file desciptor can be used to display an overview of imports of a document
with direct links to their definition location.
Optionally, the client can implement:
- Follow cursor between open document and highlight import in view
- Show cyclic dependencies
Example:
Exports
The file desciptor can be used to display an overview of exports of a document
with direct links to their usage locations.
Optionally, the client can implement:
- Follow cursor between open document and highlight export in view
- Show contention: naming conflicts through re-exports
- Show contention: branched/diamond-shaped re-export structures
Example:
