ts-bridge is a TypeScript language-server shim designed for seamless integration between Neovim and tsserver. Written in Rust, it transforms LSP requests into TypeScript server protocol without reinventing the wheel. With its modular architecture, it provides a clean and efficient path for Neovim users to enhance their development experience, leveraging the power of TypeScript.
ts-bridge is a robust TypeScript language-server shim developed in Rust, designed to seamlessly connect Neovim's built-in LSP client with the well-known tsserver. By acting as a bridge, it efficiently facilitates communication between the Language Server Protocol (LSP) and the TypeScript server, allowing for enhanced development capabilities within the Neovim environment.
config, provider, process, and protocol, aligning with modern JavaScript and TypeScript tooling pipelines.tsc and tsserver) for all type-checking and completion tasks.ts-bridge includes support for a variety of LSP functionalities including:
didOpen, didChange, and didClose)How daemon mode works
At a high level, the daemon accepts many LSP connections and routes each project's requests through a shared tsserver service keyed by project root.
┌─────────────────────────────────────────────────┐
│ ts-bridge daemon │
│ │
LSP client 1 ─┤ session (per client) ─┐ │
LSP client 2 ─┤ session (per client) ─┼── Project registry ─┐ │
LSP client 3 ─┤ session (per client) ─┘ │ │
│ │ │
│ project root A ── tsserver (A) │ │
│ project root B ── tsserver (B) │ │
└─────────────────────────────────────────────────┘
While ready for use out-of-the-box, ts-bridge allows for easy configuration within Neovim using lspconfig. A minimal configuration snippet is available:
local configs = require("lspconfig.configs")
local util = require("lspconfig.util")
if not configs.ts_bridge then
configs.ts_bridge = {
default_config = {
cmd = { "ts-bridge" },
filetypes = { "typescript", "typescriptreact", "javascript", "javascriptreact" },
root_dir = util.root_pattern("tsconfig.json", "jsconfig.json", "package.json", ".git"),
},
}
end
local lspconfig = require("lspconfig")
lspconfig.ts_bridge.setup({
cmd = { "ts-bridge" },
settings = {
["ts-bridge"] = {
separate_diagnostic_server = true,
publish_diagnostic_on = "insert_leave",
enable_inlay_hints = true,
},
},
})
ts-bridge supports a daemon mode that keeps a single ts-bridge process alive, which can handle multiple LSP clients. This mode enhances responsiveness by reusing warm tsserver instances across different project sessions. Users can easily configure the daemon to run directly from Neovim or manually through the command line.
For more detailed information regarding configuration options and advanced setups, refer to the GitHub Releases page as well as the available installation scripts for differing platforms.
Contributions and issue reporting are encouraged, fostering a collaborative environment for further enhancements and bug fixes.
No comments yet.
Sign in to be the first to comment.