Documentation
¶
Overview ¶
Package servers is a catalog of language servers: for each one, the command that starts it, the vim filetypes it serves, the files that mark a project root, its default initialization options and settings, and how to install it. Lookup picks the candidates for a file by its name.
The catalog only describes. It never runs a server and never runs an install: an Install is a recipe a caller may follow, with its own tools.
The data is converted from nvim-lspconfig's lsp/*.lua configs and from mason-registry's registry.json, both Apache-2.0, at the versions named in catalog_generated.go; LICENSE.apache and NOTICE carry their terms, and LICENSE.vim the terms of the filetype tables, from Vim by way of Neovim. Where an lspconfig config computes a field in Lua, the catalog cannot carry it: the field's name goes into Server.Dynamic and its value is lost. That is every field that is or holds a function (cmd, root_dir, on_attach, before_init, handlers and the like), and every field whose value depends on the machine the config was evaluated on (a path under $HOME, a pid, nvim's version). A Server whose cmd is computed has no Command, but for ts_ls and jdtls, which carry the command lspconfig starts by default; its Install's Bins usually still name the executable. Fields lspconfig sets as plain data but this package has no place for (capabilities, workspace_required and others) are dropped.
Filetypes are vim's: a file's name maps to one through nvim's own extension and filename tables, as nvim decides for a new, empty file of that name (so a .h file is cpp, and a .ts file typescript).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileType ¶
FileType is the vim filetype of the file at path, by its name or extension, as Lookup reads it: "" when its name maps to no filetype a server in the catalog claims.
func LanguageID ¶
LanguageID is the LSP languageId of a vim filetype, as lsp.Options takes it: the filetype's own name for most, LSP's where the two differ ("sh" is "shellscript", "cs" "csharp", "objc" "objective-c"); "" for "".
Types ¶
type Asset ¶
type Asset struct {
// Target is mason's platform name: linux_x64, linux_x64_gnu,
// linux_arm64_musl, darwin_arm64, win_x64, or a family (linux, unix).
Target string
// Files are release asset names, downloadable at
// https://github.com/<Package>/releases/download/<Version>/<file>. A
// name may end in ":dir/", mason's syntax for where it unpacks.
Files []string
// Bins maps each executable to its path among the unpacked files. A
// path may carry mason's launcher prefix (exec:, java-jar:, node:,
// python:, dotnet:) naming what runs it.
Bins map[string]string
}
Asset is one platform's GitHub release download.
type Install ¶
type Install struct {
// Mason is the package's mason-registry name.
Mason string
Kind Kind
// Package is what the package manager installs: an npm or pypi name, a
// Go package path (go install Package@Version), a crate, a gem, or a
// GitHub owner/repo for KindGithub.
Package string
// Version is the exact version, or the GitHub release tag.
Version string
// Qualifiers are the purl's, verbatim: repository_url, rev, features,
// extra and the like.
Qualifiers map[string]string
// ExtraPackages are installed next to Package, as name@version
// (typescript for typescript-language-server).
ExtraPackages []string
// Bins are the executables the package provides.
Bins []string
// Assets are KindGithub's, one per target.
Assets []Asset
}
Install is mason-registry's recipe for a server's package, its latest version only.
type Server ¶
type Server struct {
Name string
// Command is the argv that starts the server on stdio, nil when
// lspconfig computes it (then "cmd" is in Dynamic). ts_ls and jdtls,
// whose lspconfig cmd is a function, carry the command it starts by
// default, and keep "cmd" in Dynamic.
Command []string
FileTypes []string
// RootMarkers are file names that mark a project root, nearest first.
// Each inner slice is one priority level whose names weigh the same;
// lspconfig's flat list becomes one name per level.
RootMarkers [][]string
// InitOptions and Settings are lspconfig's defaults as JSON, nil when
// it sets none: initializationOptions, and workspace/configuration's
// answer.
InitOptions json.RawMessage
Settings json.RawMessage
// Dynamic names, sorted, the lspconfig fields computed in Lua, whose
// values the catalog cannot carry.
Dynamic []string
// Install is nil when mason-registry has no recipe this package reads.
Install *Install
}
Server is one language server, named as nvim-lspconfig names it.
func Lookup ¶
Lookup returns the servers for the file at path, nil when its name maps to no filetype a server claims. The common server for the language comes first (gopls for Go, ts_ls for TypeScript and JavaScript, basedpyright then pyright for Python, rust_analyzer, clangd for C and C++, lua_ls, jdtls), then the servers with a Command, then those whose command lspconfig computes; each group by name.