mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-25 10:56:19 +04:00
71551d395b
Language Servers are now configured in a separate table in `languages.toml`: ```toml [langauge-server.mylang-lsp] command = "mylang-lsp" args = ["--stdio"] config = { provideFormatter = true } [language-server.efm-lsp-prettier] command = "efm-langserver" [language-server.efm-lsp-prettier.config] documentFormatting = true languages = { typescript = [ { formatCommand ="prettier --stdin-filepath ${INPUT}", formatStdin = true } ] } ``` The language server for a language is configured like this (`typescript-language-server` is configured by default): ```toml [[language]] name = "typescript" language-servers = [ { name = "efm-lsp-prettier", only-features = [ "format" ] }, "typescript-language-server" ] ``` or equivalent: ```toml [[language]] name = "typescript" language-servers = [ { name = "typescript-language-server", except-features = [ "format" ] }, "efm-lsp-prettier" ] ``` Each requested LSP feature is priorized in the order of the `language-servers` array. For example the first `goto-definition` supported language server (in this case `typescript-language-server`) will be taken for the relevant LSP request (command `goto_definition`). If no `except-features` or `only-features` is given all features for the language server are enabled, as long as the language server supports these. If it doesn't the next language server which supports the feature is tried. The list of supported features are: - `format` - `goto-definition` - `goto-declaration` - `goto-type-definition` - `goto-reference` - `goto-implementation` - `signature-help` - `hover` - `document-highlight` - `completion` - `code-action` - `workspace-command` - `document-symbols` - `workspace-symbols` - `diagnostics` - `rename-symbol` - `inlay-hints` Another side-effect/difference that comes with this PR, is that only one language server instance is started if different languages use the same language server.
51 lines
1.2 KiB
Rust
51 lines
1.2 KiB
Rust
//! LSP diagnostic utility types.
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// Describes the severity level of a [`Diagnostic`].
|
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Deserialize, Serialize)]
|
|
pub enum Severity {
|
|
Hint,
|
|
Info,
|
|
Warning,
|
|
Error,
|
|
}
|
|
|
|
impl Default for Severity {
|
|
fn default() -> Self {
|
|
Self::Hint
|
|
}
|
|
}
|
|
|
|
/// A range of `char`s within the text.
|
|
#[derive(Debug, Clone, Copy, PartialOrd, Ord, PartialEq, Eq)]
|
|
pub struct Range {
|
|
pub start: usize,
|
|
pub end: usize,
|
|
}
|
|
|
|
#[derive(Debug, Eq, Hash, PartialEq, Clone, Deserialize, Serialize)]
|
|
pub enum NumberOrString {
|
|
Number(i32),
|
|
String(String),
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub enum DiagnosticTag {
|
|
Unnecessary,
|
|
Deprecated,
|
|
}
|
|
|
|
/// Corresponds to [`lsp_types::Diagnostic`](https://docs.rs/lsp-types/0.94.0/lsp_types/struct.Diagnostic.html)
|
|
#[derive(Debug, Clone)]
|
|
pub struct Diagnostic {
|
|
pub range: Range,
|
|
pub line: usize,
|
|
pub message: String,
|
|
pub severity: Option<Severity>,
|
|
pub code: Option<NumberOrString>,
|
|
pub language_server_id: usize,
|
|
pub tags: Vec<DiagnosticTag>,
|
|
pub source: Option<String>,
|
|
pub data: Option<serde_json::Value>,
|
|
}
|