Skip to main content

gen_lsp_types/generated/
enumerations.rs

1use serde::{Deserialize, Serialize};
2use std::{borrow::Cow, fmt};
3
4/// A set of predefined token types. This set is not fixed
5/// an clients can specify additional token types via the
6/// corresponding client capabilities.
7///
8/// @since 3.16.0
9#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize)]
10#[serde(into = "String", from = "String")]
11pub enum SemanticTokenTypes {
12    Namespace,
13    /// Represents a generic type. Acts as a fallback for types which can't be mapped to
14    /// a specific type like class or enum.
15    Type,
16    Class,
17    Enum,
18    Interface,
19    Struct,
20    TypeParameter,
21    Parameter,
22    Variable,
23    Property,
24    EnumMember,
25    Event,
26    Function,
27    Method,
28    Macro,
29    Keyword,
30    Modifier,
31    Comment,
32    String,
33    Number,
34    Regexp,
35    Operator,
36    /// @since 3.17.0
37    Decorator,
38    /// @since 3.18.0
39    Label,
40    /// A custom value.
41    #[serde(untagged)]
42    Custom(Cow<'static, str>),
43}
44impl From<SemanticTokenTypes> for String {
45    fn from(e: SemanticTokenTypes) -> Self {
46        match e {
47            SemanticTokenTypes::Namespace => "namespace".to_string(),
48            SemanticTokenTypes::Type => "type".to_string(),
49            SemanticTokenTypes::Class => "class".to_string(),
50            SemanticTokenTypes::Enum => "enum".to_string(),
51            SemanticTokenTypes::Interface => "interface".to_string(),
52            SemanticTokenTypes::Struct => "struct".to_string(),
53            SemanticTokenTypes::TypeParameter => "typeParameter".to_string(),
54            SemanticTokenTypes::Parameter => "parameter".to_string(),
55            SemanticTokenTypes::Variable => "variable".to_string(),
56            SemanticTokenTypes::Property => "property".to_string(),
57            SemanticTokenTypes::EnumMember => "enumMember".to_string(),
58            SemanticTokenTypes::Event => "event".to_string(),
59            SemanticTokenTypes::Function => "function".to_string(),
60            SemanticTokenTypes::Method => "method".to_string(),
61            SemanticTokenTypes::Macro => "macro".to_string(),
62            SemanticTokenTypes::Keyword => "keyword".to_string(),
63            SemanticTokenTypes::Modifier => "modifier".to_string(),
64            SemanticTokenTypes::Comment => "comment".to_string(),
65            SemanticTokenTypes::String => "string".to_string(),
66            SemanticTokenTypes::Number => "number".to_string(),
67            SemanticTokenTypes::Regexp => "regexp".to_string(),
68            SemanticTokenTypes::Operator => "operator".to_string(),
69            SemanticTokenTypes::Decorator => "decorator".to_string(),
70            SemanticTokenTypes::Label => "label".to_string(),
71            SemanticTokenTypes::Custom(any) => any.into_owned(),
72        }
73    }
74}
75impl From<String> for SemanticTokenTypes {
76    fn from(v: String) -> Self {
77        match v.as_str() {
78            "namespace" => Self::Namespace,
79            "type" => Self::Type,
80            "class" => Self::Class,
81            "enum" => Self::Enum,
82            "interface" => Self::Interface,
83            "struct" => Self::Struct,
84            "typeParameter" => Self::TypeParameter,
85            "parameter" => Self::Parameter,
86            "variable" => Self::Variable,
87            "property" => Self::Property,
88            "enumMember" => Self::EnumMember,
89            "event" => Self::Event,
90            "function" => Self::Function,
91            "method" => Self::Method,
92            "macro" => Self::Macro,
93            "keyword" => Self::Keyword,
94            "modifier" => Self::Modifier,
95            "comment" => Self::Comment,
96            "string" => Self::String,
97            "number" => Self::Number,
98            "regexp" => Self::Regexp,
99            "operator" => Self::Operator,
100            "decorator" => Self::Decorator,
101            "label" => Self::Label,
102            _ => Self::Custom(Cow::Owned(v)),
103        }
104    }
105}
106impl SemanticTokenTypes {
107    /// Create a custom `SemanticTokenTypes` from a string literal.
108    #[must_use]
109    pub const fn new(s: &'static str) -> Self {
110        Self::Custom(Cow::Borrowed(s))
111    }
112}
113impl From<&'static str> for SemanticTokenTypes {
114    fn from(s: &'static str) -> Self {
115        match s {
116            "namespace" => Self::Namespace,
117            "type" => Self::Type,
118            "class" => Self::Class,
119            "enum" => Self::Enum,
120            "interface" => Self::Interface,
121            "struct" => Self::Struct,
122            "typeParameter" => Self::TypeParameter,
123            "parameter" => Self::Parameter,
124            "variable" => Self::Variable,
125            "property" => Self::Property,
126            "enumMember" => Self::EnumMember,
127            "event" => Self::Event,
128            "function" => Self::Function,
129            "method" => Self::Method,
130            "macro" => Self::Macro,
131            "keyword" => Self::Keyword,
132            "modifier" => Self::Modifier,
133            "comment" => Self::Comment,
134            "string" => Self::String,
135            "number" => Self::Number,
136            "regexp" => Self::Regexp,
137            "operator" => Self::Operator,
138            "decorator" => Self::Decorator,
139            "label" => Self::Label,
140            _ => Self::Custom(Cow::Borrowed(s)),
141        }
142    }
143}
144impl fmt::Display for SemanticTokenTypes {
145    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
146        let s: String = self.clone().into();
147        write!(f, "{s}")
148    }
149}
150impl SemanticTokenTypes {
151    #[must_use]
152    pub fn as_str(&self) -> &str {
153        match self {
154            Self::Namespace => "namespace",
155            Self::Type => "type",
156            Self::Class => "class",
157            Self::Enum => "enum",
158            Self::Interface => "interface",
159            Self::Struct => "struct",
160            Self::TypeParameter => "typeParameter",
161            Self::Parameter => "parameter",
162            Self::Variable => "variable",
163            Self::Property => "property",
164            Self::EnumMember => "enumMember",
165            Self::Event => "event",
166            Self::Function => "function",
167            Self::Method => "method",
168            Self::Macro => "macro",
169            Self::Keyword => "keyword",
170            Self::Modifier => "modifier",
171            Self::Comment => "comment",
172            Self::String => "string",
173            Self::Number => "number",
174            Self::Regexp => "regexp",
175            Self::Operator => "operator",
176            Self::Decorator => "decorator",
177            Self::Label => "label",
178            Self::Custom(any) => any,
179        }
180    }
181}
182
183/// A set of predefined token modifiers. This set is not fixed
184/// an clients can specify additional token types via the
185/// corresponding client capabilities.
186///
187/// @since 3.16.0
188#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize)]
189#[serde(into = "String", from = "String")]
190pub enum SemanticTokenModifiers {
191    Declaration,
192    Definition,
193    Readonly,
194    Static,
195    Deprecated,
196    Abstract,
197    Async,
198    Modification,
199    Documentation,
200    DefaultLibrary,
201    /// A custom value.
202    #[serde(untagged)]
203    Custom(Cow<'static, str>),
204}
205impl From<SemanticTokenModifiers> for String {
206    fn from(e: SemanticTokenModifiers) -> Self {
207        match e {
208            SemanticTokenModifiers::Declaration => "declaration".to_string(),
209            SemanticTokenModifiers::Definition => "definition".to_string(),
210            SemanticTokenModifiers::Readonly => "readonly".to_string(),
211            SemanticTokenModifiers::Static => "static".to_string(),
212            SemanticTokenModifiers::Deprecated => "deprecated".to_string(),
213            SemanticTokenModifiers::Abstract => "abstract".to_string(),
214            SemanticTokenModifiers::Async => "async".to_string(),
215            SemanticTokenModifiers::Modification => "modification".to_string(),
216            SemanticTokenModifiers::Documentation => "documentation".to_string(),
217            SemanticTokenModifiers::DefaultLibrary => "defaultLibrary".to_string(),
218            SemanticTokenModifiers::Custom(any) => any.into_owned(),
219        }
220    }
221}
222impl From<String> for SemanticTokenModifiers {
223    fn from(v: String) -> Self {
224        match v.as_str() {
225            "declaration" => Self::Declaration,
226            "definition" => Self::Definition,
227            "readonly" => Self::Readonly,
228            "static" => Self::Static,
229            "deprecated" => Self::Deprecated,
230            "abstract" => Self::Abstract,
231            "async" => Self::Async,
232            "modification" => Self::Modification,
233            "documentation" => Self::Documentation,
234            "defaultLibrary" => Self::DefaultLibrary,
235            _ => Self::Custom(Cow::Owned(v)),
236        }
237    }
238}
239impl SemanticTokenModifiers {
240    /// Create a custom `SemanticTokenModifiers` from a string literal.
241    #[must_use]
242    pub const fn new(s: &'static str) -> Self {
243        Self::Custom(Cow::Borrowed(s))
244    }
245}
246impl From<&'static str> for SemanticTokenModifiers {
247    fn from(s: &'static str) -> Self {
248        match s {
249            "declaration" => Self::Declaration,
250            "definition" => Self::Definition,
251            "readonly" => Self::Readonly,
252            "static" => Self::Static,
253            "deprecated" => Self::Deprecated,
254            "abstract" => Self::Abstract,
255            "async" => Self::Async,
256            "modification" => Self::Modification,
257            "documentation" => Self::Documentation,
258            "defaultLibrary" => Self::DefaultLibrary,
259            _ => Self::Custom(Cow::Borrowed(s)),
260        }
261    }
262}
263impl fmt::Display for SemanticTokenModifiers {
264    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
265        let s: String = self.clone().into();
266        write!(f, "{s}")
267    }
268}
269impl SemanticTokenModifiers {
270    #[must_use]
271    pub fn as_str(&self) -> &str {
272        match self {
273            Self::Declaration => "declaration",
274            Self::Definition => "definition",
275            Self::Readonly => "readonly",
276            Self::Static => "static",
277            Self::Deprecated => "deprecated",
278            Self::Abstract => "abstract",
279            Self::Async => "async",
280            Self::Modification => "modification",
281            Self::Documentation => "documentation",
282            Self::DefaultLibrary => "defaultLibrary",
283            Self::Custom(any) => any,
284        }
285    }
286}
287
288/// The document diagnostic report kinds.
289///
290/// @since 3.17.0
291#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
292#[serde(into = "String", try_from = "String")]
293pub enum DocumentDiagnosticReportKind {
294    /// A diagnostic report with a full
295    /// set of problems.
296    Full,
297    /// A report indicating that the last
298    /// returned report is still accurate.
299    Unchanged,
300}
301impl From<DocumentDiagnosticReportKind> for String {
302    fn from(e: DocumentDiagnosticReportKind) -> Self {
303        match e {
304            DocumentDiagnosticReportKind::Full => "full".to_string(),
305            DocumentDiagnosticReportKind::Unchanged => "unchanged".to_string(),
306        }
307    }
308}
309impl TryFrom<String> for DocumentDiagnosticReportKind {
310    type Error = String;
311    fn try_from(v: String) -> Result<Self, <Self as TryFrom<String>>::Error> {
312        match v.as_str() {
313            "full" => Ok(Self::Full),
314            "unchanged" => Ok(Self::Unchanged),
315            _ => Err(format!("Invalid DocumentDiagnosticReportKind: {v}")),
316        }
317    }
318}
319impl fmt::Display for DocumentDiagnosticReportKind {
320    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
321        let s: String = (*self).into();
322        write!(f, "{s}")
323    }
324}
325impl DocumentDiagnosticReportKind {
326    #[must_use]
327    pub fn as_str(&self) -> &str {
328        match self {
329            Self::Full => "full",
330            Self::Unchanged => "unchanged",
331        }
332    }
333}
334
335/// Predefined error codes.
336#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
337#[serde(into = "i32", from = "i32")]
338pub enum ErrorCodes {
339    ParseError,
340    InvalidRequest,
341    MethodNotFound,
342    InvalidParams,
343    InternalError,
344    /// Error code indicating that a server received a notification or
345    /// request before the server has received the `initialize` request.
346    ServerNotInitialized,
347    UnknownErrorCode,
348    /// A custom value.
349    #[serde(untagged)]
350    Custom(i32),
351}
352impl From<ErrorCodes> for i32 {
353    fn from(e: ErrorCodes) -> Self {
354        match e {
355            ErrorCodes::ParseError => -32700i32,
356            ErrorCodes::InvalidRequest => -32600i32,
357            ErrorCodes::MethodNotFound => -32601i32,
358            ErrorCodes::InvalidParams => -32602i32,
359            ErrorCodes::InternalError => -32603i32,
360            ErrorCodes::ServerNotInitialized => -32002i32,
361            ErrorCodes::UnknownErrorCode => -32001i32,
362            ErrorCodes::Custom(any) => any,
363        }
364    }
365}
366impl From<i32> for ErrorCodes {
367    fn from(v: i32) -> Self {
368        match v {
369            -32700i32 => Self::ParseError,
370            -32600i32 => Self::InvalidRequest,
371            -32601i32 => Self::MethodNotFound,
372            -32602i32 => Self::InvalidParams,
373            -32603i32 => Self::InternalError,
374            -32002i32 => Self::ServerNotInitialized,
375            -32001i32 => Self::UnknownErrorCode,
376            _ => Self::Custom(v),
377        }
378    }
379}
380
381#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
382#[serde(into = "i32", from = "i32")]
383pub enum LspErrorCodes {
384    /// A request failed but it was syntactically correct, e.g the
385    /// method name was known and the parameters were valid. The error
386    /// message should contain human readable information about why
387    /// the request failed.
388    ///
389    /// @since 3.17.0
390    RequestFailed,
391    /// The server cancelled the request. This error code should
392    /// only be used for requests that explicitly support being
393    /// server cancellable.
394    ///
395    /// @since 3.17.0
396    ServerCancelled,
397    /// The server detected that the content of a document got
398    /// modified outside normal conditions. A server should
399    /// NOT send this error code if it detects a content change
400    /// in it unprocessed messages. The result even computed
401    /// on an older state might still be useful for the client.
402    ///
403    /// If a client decides that a result is not of any use anymore
404    /// the client should cancel the request.
405    ContentModified,
406    /// The client has canceled a request and a server has detected
407    /// the cancel.
408    RequestCancelled,
409    /// A custom value.
410    #[serde(untagged)]
411    Custom(i32),
412}
413impl From<LspErrorCodes> for i32 {
414    fn from(e: LspErrorCodes) -> Self {
415        match e {
416            LspErrorCodes::RequestFailed => -32803i32,
417            LspErrorCodes::ServerCancelled => -32802i32,
418            LspErrorCodes::ContentModified => -32801i32,
419            LspErrorCodes::RequestCancelled => -32800i32,
420            LspErrorCodes::Custom(any) => any,
421        }
422    }
423}
424impl From<i32> for LspErrorCodes {
425    fn from(v: i32) -> Self {
426        match v {
427            -32803i32 => Self::RequestFailed,
428            -32802i32 => Self::ServerCancelled,
429            -32801i32 => Self::ContentModified,
430            -32800i32 => Self::RequestCancelled,
431            _ => Self::Custom(v),
432        }
433    }
434}
435
436/// A set of predefined range kinds.
437#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize)]
438#[serde(into = "String", from = "String")]
439pub enum FoldingRangeKind {
440    /// Folding range for a comment
441    Comment,
442    /// Folding range for an import or include
443    Imports,
444    /// Folding range for a region (e.g. `#region`)
445    Region,
446    /// A custom value.
447    #[serde(untagged)]
448    Custom(Cow<'static, str>),
449}
450impl From<FoldingRangeKind> for String {
451    fn from(e: FoldingRangeKind) -> Self {
452        match e {
453            FoldingRangeKind::Comment => "comment".to_string(),
454            FoldingRangeKind::Imports => "imports".to_string(),
455            FoldingRangeKind::Region => "region".to_string(),
456            FoldingRangeKind::Custom(any) => any.into_owned(),
457        }
458    }
459}
460impl From<String> for FoldingRangeKind {
461    fn from(v: String) -> Self {
462        match v.as_str() {
463            "comment" => Self::Comment,
464            "imports" => Self::Imports,
465            "region" => Self::Region,
466            _ => Self::Custom(Cow::Owned(v)),
467        }
468    }
469}
470impl FoldingRangeKind {
471    /// Create a custom `FoldingRangeKind` from a string literal.
472    #[must_use]
473    pub const fn new(s: &'static str) -> Self {
474        Self::Custom(Cow::Borrowed(s))
475    }
476}
477impl From<&'static str> for FoldingRangeKind {
478    fn from(s: &'static str) -> Self {
479        match s {
480            "comment" => Self::Comment,
481            "imports" => Self::Imports,
482            "region" => Self::Region,
483            _ => Self::Custom(Cow::Borrowed(s)),
484        }
485    }
486}
487impl fmt::Display for FoldingRangeKind {
488    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
489        let s: String = self.clone().into();
490        write!(f, "{s}")
491    }
492}
493impl FoldingRangeKind {
494    #[must_use]
495    pub fn as_str(&self) -> &str {
496        match self {
497            Self::Comment => "comment",
498            Self::Imports => "imports",
499            Self::Region => "region",
500            Self::Custom(any) => any,
501        }
502    }
503}
504
505/// A symbol kind.
506#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
507#[serde(into = "u32", try_from = "u32")]
508pub enum SymbolKind {
509    File,
510    Module,
511    Namespace,
512    Package,
513    Class,
514    Method,
515    Property,
516    Field,
517    Constructor,
518    Enum,
519    Interface,
520    Function,
521    Variable,
522    Constant,
523    String,
524    Number,
525    Boolean,
526    Array,
527    Object,
528    Key,
529    Null,
530    EnumMember,
531    Struct,
532    Event,
533    Operator,
534    TypeParameter,
535}
536impl From<SymbolKind> for u32 {
537    fn from(e: SymbolKind) -> Self {
538        match e {
539            SymbolKind::File => 1u32,
540            SymbolKind::Module => 2u32,
541            SymbolKind::Namespace => 3u32,
542            SymbolKind::Package => 4u32,
543            SymbolKind::Class => 5u32,
544            SymbolKind::Method => 6u32,
545            SymbolKind::Property => 7u32,
546            SymbolKind::Field => 8u32,
547            SymbolKind::Constructor => 9u32,
548            SymbolKind::Enum => 10u32,
549            SymbolKind::Interface => 11u32,
550            SymbolKind::Function => 12u32,
551            SymbolKind::Variable => 13u32,
552            SymbolKind::Constant => 14u32,
553            SymbolKind::String => 15u32,
554            SymbolKind::Number => 16u32,
555            SymbolKind::Boolean => 17u32,
556            SymbolKind::Array => 18u32,
557            SymbolKind::Object => 19u32,
558            SymbolKind::Key => 20u32,
559            SymbolKind::Null => 21u32,
560            SymbolKind::EnumMember => 22u32,
561            SymbolKind::Struct => 23u32,
562            SymbolKind::Event => 24u32,
563            SymbolKind::Operator => 25u32,
564            SymbolKind::TypeParameter => 26u32,
565        }
566    }
567}
568impl TryFrom<u32> for SymbolKind {
569    type Error = String;
570    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
571        match v {
572            1u32 => Ok(Self::File),
573            2u32 => Ok(Self::Module),
574            3u32 => Ok(Self::Namespace),
575            4u32 => Ok(Self::Package),
576            5u32 => Ok(Self::Class),
577            6u32 => Ok(Self::Method),
578            7u32 => Ok(Self::Property),
579            8u32 => Ok(Self::Field),
580            9u32 => Ok(Self::Constructor),
581            10u32 => Ok(Self::Enum),
582            11u32 => Ok(Self::Interface),
583            12u32 => Ok(Self::Function),
584            13u32 => Ok(Self::Variable),
585            14u32 => Ok(Self::Constant),
586            15u32 => Ok(Self::String),
587            16u32 => Ok(Self::Number),
588            17u32 => Ok(Self::Boolean),
589            18u32 => Ok(Self::Array),
590            19u32 => Ok(Self::Object),
591            20u32 => Ok(Self::Key),
592            21u32 => Ok(Self::Null),
593            22u32 => Ok(Self::EnumMember),
594            23u32 => Ok(Self::Struct),
595            24u32 => Ok(Self::Event),
596            25u32 => Ok(Self::Operator),
597            26u32 => Ok(Self::TypeParameter),
598            _ => Err(format!("Invalid SymbolKind: {v}")),
599        }
600    }
601}
602
603/// Symbol tags are extra annotations that tweak the rendering of a symbol.
604///
605/// @since 3.16
606#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
607#[serde(into = "u32", try_from = "u32")]
608pub enum SymbolTag {
609    /// Render a symbol as obsolete, usually using a strike-out.
610    Deprecated,
611}
612impl From<SymbolTag> for u32 {
613    fn from(e: SymbolTag) -> Self {
614        match e {
615            SymbolTag::Deprecated => 1u32,
616        }
617    }
618}
619impl TryFrom<u32> for SymbolTag {
620    type Error = String;
621    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
622        match v {
623            1u32 => Ok(Self::Deprecated),
624            _ => Err(format!("Invalid SymbolTag: {v}")),
625        }
626    }
627}
628
629/// Moniker uniqueness level to define scope of the moniker.
630///
631/// @since 3.16.0
632#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
633#[serde(into = "String", try_from = "String")]
634pub enum UniquenessLevel {
635    /// The moniker is only unique inside a document
636    Document,
637    /// The moniker is unique inside a project for which a dump got created
638    Project,
639    /// The moniker is unique inside the group to which a project belongs
640    Group,
641    /// The moniker is unique inside the moniker scheme.
642    Scheme,
643    /// The moniker is globally unique
644    Global,
645}
646impl From<UniquenessLevel> for String {
647    fn from(e: UniquenessLevel) -> Self {
648        match e {
649            UniquenessLevel::Document => "document".to_string(),
650            UniquenessLevel::Project => "project".to_string(),
651            UniquenessLevel::Group => "group".to_string(),
652            UniquenessLevel::Scheme => "scheme".to_string(),
653            UniquenessLevel::Global => "global".to_string(),
654        }
655    }
656}
657impl TryFrom<String> for UniquenessLevel {
658    type Error = String;
659    fn try_from(v: String) -> Result<Self, <Self as TryFrom<String>>::Error> {
660        match v.as_str() {
661            "document" => Ok(Self::Document),
662            "project" => Ok(Self::Project),
663            "group" => Ok(Self::Group),
664            "scheme" => Ok(Self::Scheme),
665            "global" => Ok(Self::Global),
666            _ => Err(format!("Invalid UniquenessLevel: {v}")),
667        }
668    }
669}
670impl fmt::Display for UniquenessLevel {
671    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
672        let s: String = (*self).into();
673        write!(f, "{s}")
674    }
675}
676impl UniquenessLevel {
677    #[must_use]
678    pub fn as_str(&self) -> &str {
679        match self {
680            Self::Document => "document",
681            Self::Project => "project",
682            Self::Group => "group",
683            Self::Scheme => "scheme",
684            Self::Global => "global",
685        }
686    }
687}
688
689/// The moniker kind.
690///
691/// @since 3.16.0
692#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
693#[serde(into = "String", try_from = "String")]
694pub enum MonikerKind {
695    /// The moniker represent a symbol that is imported into a project
696    Import,
697    /// The moniker represents a symbol that is exported from a project
698    Export,
699    /// The moniker represents a symbol that is local to a project (e.g. a local
700    /// variable of a function, a class not visible outside the project, ...)
701    Local,
702}
703impl From<MonikerKind> for String {
704    fn from(e: MonikerKind) -> Self {
705        match e {
706            MonikerKind::Import => "import".to_string(),
707            MonikerKind::Export => "export".to_string(),
708            MonikerKind::Local => "local".to_string(),
709        }
710    }
711}
712impl TryFrom<String> for MonikerKind {
713    type Error = String;
714    fn try_from(v: String) -> Result<Self, <Self as TryFrom<String>>::Error> {
715        match v.as_str() {
716            "import" => Ok(Self::Import),
717            "export" => Ok(Self::Export),
718            "local" => Ok(Self::Local),
719            _ => Err(format!("Invalid MonikerKind: {v}")),
720        }
721    }
722}
723impl fmt::Display for MonikerKind {
724    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
725        let s: String = (*self).into();
726        write!(f, "{s}")
727    }
728}
729impl MonikerKind {
730    #[must_use]
731    pub fn as_str(&self) -> &str {
732        match self {
733            Self::Import => "import",
734            Self::Export => "export",
735            Self::Local => "local",
736        }
737    }
738}
739
740/// Inlay hint kinds.
741///
742/// @since 3.17.0
743#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
744#[serde(into = "u32", try_from = "u32")]
745pub enum InlayHintKind {
746    /// An inlay hint that for a type annotation.
747    Type,
748    /// An inlay hint that is for a parameter.
749    Parameter,
750}
751impl From<InlayHintKind> for u32 {
752    fn from(e: InlayHintKind) -> Self {
753        match e {
754            InlayHintKind::Type => 1u32,
755            InlayHintKind::Parameter => 2u32,
756        }
757    }
758}
759impl TryFrom<u32> for InlayHintKind {
760    type Error = String;
761    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
762        match v {
763            1u32 => Ok(Self::Type),
764            2u32 => Ok(Self::Parameter),
765            _ => Err(format!("Invalid InlayHintKind: {v}")),
766        }
767    }
768}
769
770/// The message type
771#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
772#[serde(into = "u32", try_from = "u32")]
773pub enum MessageType {
774    /// An error message.
775    Error,
776    /// A warning message.
777    Warning,
778    /// An information message.
779    Info,
780    /// A log message.
781    Log,
782    /// A debug message.
783    ///
784    /// @since 3.18.0
785    /// @proposed
786    Debug,
787}
788impl From<MessageType> for u32 {
789    fn from(e: MessageType) -> Self {
790        match e {
791            MessageType::Error => 1u32,
792            MessageType::Warning => 2u32,
793            MessageType::Info => 3u32,
794            MessageType::Log => 4u32,
795            MessageType::Debug => 5u32,
796        }
797    }
798}
799impl TryFrom<u32> for MessageType {
800    type Error = String;
801    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
802        match v {
803            1u32 => Ok(Self::Error),
804            2u32 => Ok(Self::Warning),
805            3u32 => Ok(Self::Info),
806            4u32 => Ok(Self::Log),
807            5u32 => Ok(Self::Debug),
808            _ => Err(format!("Invalid MessageType: {v}")),
809        }
810    }
811}
812
813/// Defines how the host (editor) should sync
814/// document changes to the language server.
815#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
816#[serde(into = "u32", try_from = "u32")]
817pub enum TextDocumentSyncKind {
818    /// Documents should not be synced at all.
819    None,
820    /// Documents are synced by always sending the full content
821    /// of the document.
822    Full,
823    /// Documents are synced by sending the full content on open.
824    /// After that only incremental updates to the document are
825    /// send.
826    Incremental,
827}
828impl From<TextDocumentSyncKind> for u32 {
829    fn from(e: TextDocumentSyncKind) -> Self {
830        match e {
831            TextDocumentSyncKind::None => 0u32,
832            TextDocumentSyncKind::Full => 1u32,
833            TextDocumentSyncKind::Incremental => 2u32,
834        }
835    }
836}
837impl TryFrom<u32> for TextDocumentSyncKind {
838    type Error = String;
839    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
840        match v {
841            0u32 => Ok(Self::None),
842            1u32 => Ok(Self::Full),
843            2u32 => Ok(Self::Incremental),
844            _ => Err(format!("Invalid TextDocumentSyncKind: {v}")),
845        }
846    }
847}
848
849/// Represents reasons why a text document is saved.
850#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
851#[serde(into = "u32", try_from = "u32")]
852pub enum TextDocumentSaveReason {
853    /// Manually triggered, e.g. by the user pressing save, by starting debugging,
854    /// or by an API call.
855    Manual,
856    /// Automatic after a delay.
857    AfterDelay,
858    /// When the editor lost focus.
859    FocusOut,
860}
861impl From<TextDocumentSaveReason> for u32 {
862    fn from(e: TextDocumentSaveReason) -> Self {
863        match e {
864            TextDocumentSaveReason::Manual => 1u32,
865            TextDocumentSaveReason::AfterDelay => 2u32,
866            TextDocumentSaveReason::FocusOut => 3u32,
867        }
868    }
869}
870impl TryFrom<u32> for TextDocumentSaveReason {
871    type Error = String;
872    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
873        match v {
874            1u32 => Ok(Self::Manual),
875            2u32 => Ok(Self::AfterDelay),
876            3u32 => Ok(Self::FocusOut),
877            _ => Err(format!("Invalid TextDocumentSaveReason: {v}")),
878        }
879    }
880}
881
882/// The kind of a completion entry.
883#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
884#[serde(into = "u32", try_from = "u32")]
885pub enum CompletionItemKind {
886    Text,
887    Method,
888    Function,
889    Constructor,
890    Field,
891    Variable,
892    Class,
893    Interface,
894    Module,
895    Property,
896    Unit,
897    Value,
898    Enum,
899    Keyword,
900    Snippet,
901    Color,
902    File,
903    Reference,
904    Folder,
905    EnumMember,
906    Constant,
907    Struct,
908    Event,
909    Operator,
910    TypeParameter,
911}
912impl From<CompletionItemKind> for u32 {
913    fn from(e: CompletionItemKind) -> Self {
914        match e {
915            CompletionItemKind::Text => 1u32,
916            CompletionItemKind::Method => 2u32,
917            CompletionItemKind::Function => 3u32,
918            CompletionItemKind::Constructor => 4u32,
919            CompletionItemKind::Field => 5u32,
920            CompletionItemKind::Variable => 6u32,
921            CompletionItemKind::Class => 7u32,
922            CompletionItemKind::Interface => 8u32,
923            CompletionItemKind::Module => 9u32,
924            CompletionItemKind::Property => 10u32,
925            CompletionItemKind::Unit => 11u32,
926            CompletionItemKind::Value => 12u32,
927            CompletionItemKind::Enum => 13u32,
928            CompletionItemKind::Keyword => 14u32,
929            CompletionItemKind::Snippet => 15u32,
930            CompletionItemKind::Color => 16u32,
931            CompletionItemKind::File => 17u32,
932            CompletionItemKind::Reference => 18u32,
933            CompletionItemKind::Folder => 19u32,
934            CompletionItemKind::EnumMember => 20u32,
935            CompletionItemKind::Constant => 21u32,
936            CompletionItemKind::Struct => 22u32,
937            CompletionItemKind::Event => 23u32,
938            CompletionItemKind::Operator => 24u32,
939            CompletionItemKind::TypeParameter => 25u32,
940        }
941    }
942}
943impl TryFrom<u32> for CompletionItemKind {
944    type Error = String;
945    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
946        match v {
947            1u32 => Ok(Self::Text),
948            2u32 => Ok(Self::Method),
949            3u32 => Ok(Self::Function),
950            4u32 => Ok(Self::Constructor),
951            5u32 => Ok(Self::Field),
952            6u32 => Ok(Self::Variable),
953            7u32 => Ok(Self::Class),
954            8u32 => Ok(Self::Interface),
955            9u32 => Ok(Self::Module),
956            10u32 => Ok(Self::Property),
957            11u32 => Ok(Self::Unit),
958            12u32 => Ok(Self::Value),
959            13u32 => Ok(Self::Enum),
960            14u32 => Ok(Self::Keyword),
961            15u32 => Ok(Self::Snippet),
962            16u32 => Ok(Self::Color),
963            17u32 => Ok(Self::File),
964            18u32 => Ok(Self::Reference),
965            19u32 => Ok(Self::Folder),
966            20u32 => Ok(Self::EnumMember),
967            21u32 => Ok(Self::Constant),
968            22u32 => Ok(Self::Struct),
969            23u32 => Ok(Self::Event),
970            24u32 => Ok(Self::Operator),
971            25u32 => Ok(Self::TypeParameter),
972            _ => Err(format!("Invalid CompletionItemKind: {v}")),
973        }
974    }
975}
976
977/// Completion item tags are extra annotations that tweak the rendering of a completion
978/// item.
979///
980/// @since 3.15.0
981#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
982#[serde(into = "u32", try_from = "u32")]
983pub enum CompletionItemTag {
984    /// Render a completion as obsolete, usually using a strike-out.
985    Deprecated,
986}
987impl From<CompletionItemTag> for u32 {
988    fn from(e: CompletionItemTag) -> Self {
989        match e {
990            CompletionItemTag::Deprecated => 1u32,
991        }
992    }
993}
994impl TryFrom<u32> for CompletionItemTag {
995    type Error = String;
996    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
997        match v {
998            1u32 => Ok(Self::Deprecated),
999            _ => Err(format!("Invalid CompletionItemTag: {v}")),
1000        }
1001    }
1002}
1003
1004/// Defines whether the insert text in a completion item should be interpreted as
1005/// plain text or a snippet.
1006#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
1007#[serde(into = "u32", try_from = "u32")]
1008pub enum InsertTextFormat {
1009    /// The primary text to be inserted is treated as a plain string.
1010    PlainText,
1011    /// The primary text to be inserted is treated as a snippet.
1012    ///
1013    /// A snippet can define tab stops and placeholders with `$1`, `$2`
1014    /// and `${3:foo}`. `$0` defines the final tab stop, it defaults to
1015    /// the end of the snippet. Placeholders with equal identifiers are linked,
1016    /// that is typing in one will update others too.
1017    ///
1018    /// See also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax
1019    Snippet,
1020}
1021impl From<InsertTextFormat> for u32 {
1022    fn from(e: InsertTextFormat) -> Self {
1023        match e {
1024            InsertTextFormat::PlainText => 1u32,
1025            InsertTextFormat::Snippet => 2u32,
1026        }
1027    }
1028}
1029impl TryFrom<u32> for InsertTextFormat {
1030    type Error = String;
1031    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
1032        match v {
1033            1u32 => Ok(Self::PlainText),
1034            2u32 => Ok(Self::Snippet),
1035            _ => Err(format!("Invalid InsertTextFormat: {v}")),
1036        }
1037    }
1038}
1039
1040/// How whitespace and indentation is handled during completion
1041/// item insertion.
1042///
1043/// @since 3.16.0
1044#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
1045#[serde(into = "u32", try_from = "u32")]
1046pub enum InsertTextMode {
1047    /// The insertion or replace strings is taken as it is. If the
1048    /// value is multi line the lines below the cursor will be
1049    /// inserted using the indentation defined in the string value.
1050    /// The client will not apply any kind of adjustments to the
1051    /// string.
1052    AsIs,
1053    /// The editor adjusts leading whitespace of new lines so that
1054    /// they match the indentation up to the cursor of the line for
1055    /// which the item is accepted.
1056    ///
1057    /// Consider a line like this: <2tabs><cursor><3tabs>foo. Accepting a
1058    /// multi line completion item is indented using 2 tabs and all
1059    /// following lines inserted will be indented using 2 tabs as well.
1060    AdjustIndentation,
1061}
1062impl From<InsertTextMode> for u32 {
1063    fn from(e: InsertTextMode) -> Self {
1064        match e {
1065            InsertTextMode::AsIs => 1u32,
1066            InsertTextMode::AdjustIndentation => 2u32,
1067        }
1068    }
1069}
1070impl TryFrom<u32> for InsertTextMode {
1071    type Error = String;
1072    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
1073        match v {
1074            1u32 => Ok(Self::AsIs),
1075            2u32 => Ok(Self::AdjustIndentation),
1076            _ => Err(format!("Invalid InsertTextMode: {v}")),
1077        }
1078    }
1079}
1080
1081/// A document highlight kind.
1082#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
1083#[serde(into = "u32", try_from = "u32")]
1084pub enum DocumentHighlightKind {
1085    /// A textual occurrence.
1086    Text,
1087    /// Read-access of a symbol, like reading a variable.
1088    Read,
1089    /// Write-access of a symbol, like writing to a variable.
1090    Write,
1091}
1092impl From<DocumentHighlightKind> for u32 {
1093    fn from(e: DocumentHighlightKind) -> Self {
1094        match e {
1095            DocumentHighlightKind::Text => 1u32,
1096            DocumentHighlightKind::Read => 2u32,
1097            DocumentHighlightKind::Write => 3u32,
1098        }
1099    }
1100}
1101impl TryFrom<u32> for DocumentHighlightKind {
1102    type Error = String;
1103    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
1104        match v {
1105            1u32 => Ok(Self::Text),
1106            2u32 => Ok(Self::Read),
1107            3u32 => Ok(Self::Write),
1108            _ => Err(format!("Invalid DocumentHighlightKind: {v}")),
1109        }
1110    }
1111}
1112
1113/// A set of predefined code action kinds
1114#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize)]
1115#[serde(into = "String", from = "String")]
1116pub enum CodeActionKind {
1117    /// Empty kind.
1118    Empty,
1119    /// Base kind for quickfix actions: 'quickfix'
1120    QuickFix,
1121    /// Base kind for refactoring actions: 'refactor'
1122    Refactor,
1123    /// Base kind for refactoring extraction actions: 'refactor.extract'
1124    ///
1125    /// Example extract actions:
1126    ///
1127    /// - Extract method
1128    /// - Extract function
1129    /// - Extract variable
1130    /// - Extract interface from class
1131    /// - ...
1132    RefactorExtract,
1133    /// Base kind for refactoring inline actions: 'refactor.inline'
1134    ///
1135    /// Example inline actions:
1136    ///
1137    /// - Inline function
1138    /// - Inline variable
1139    /// - Inline constant
1140    /// - ...
1141    RefactorInline,
1142    /// Base kind for refactoring move actions: `refactor.move`
1143    ///
1144    /// Example move actions:
1145    ///
1146    /// - Move a function to a new file
1147    /// - Move a property between classes
1148    /// - Move method to base class
1149    /// - ...
1150    ///
1151    /// @since 3.18.0
1152    /// @proposed
1153    RefactorMove,
1154    /// Base kind for refactoring rewrite actions: 'refactor.rewrite'
1155    ///
1156    /// Example rewrite actions:
1157    ///
1158    /// - Convert JavaScript function to class
1159    /// - Add or remove parameter
1160    /// - Encapsulate field
1161    /// - Make method static
1162    /// - Move method to base class
1163    /// - ...
1164    RefactorRewrite,
1165    /// Base kind for source actions: `source`
1166    ///
1167    /// Source code actions apply to the entire file.
1168    Source,
1169    /// Base kind for an organize imports source action: `source.organizeImports`
1170    SourceOrganizeImports,
1171    /// Base kind for auto-fix source actions: `source.fixAll`.
1172    ///
1173    /// Fix all actions automatically fix errors that have a clear fix that do not require user input.
1174    /// They should not suppress errors or perform unsafe fixes such as generating new types or classes.
1175    ///
1176    /// @since 3.15.0
1177    SourceFixAll,
1178    /// Base kind for all code actions applying to the entire notebook's scope. CodeActionKinds using
1179    /// this should always begin with `notebook.`
1180    ///
1181    /// @since 3.18.0
1182    Notebook,
1183    /// A custom value.
1184    #[serde(untagged)]
1185    Custom(Cow<'static, str>),
1186}
1187impl From<CodeActionKind> for String {
1188    fn from(e: CodeActionKind) -> Self {
1189        match e {
1190            CodeActionKind::Empty => "".to_string(),
1191            CodeActionKind::QuickFix => "quickfix".to_string(),
1192            CodeActionKind::Refactor => "refactor".to_string(),
1193            CodeActionKind::RefactorExtract => "refactor.extract".to_string(),
1194            CodeActionKind::RefactorInline => "refactor.inline".to_string(),
1195            CodeActionKind::RefactorMove => "refactor.move".to_string(),
1196            CodeActionKind::RefactorRewrite => "refactor.rewrite".to_string(),
1197            CodeActionKind::Source => "source".to_string(),
1198            CodeActionKind::SourceOrganizeImports => "source.organizeImports".to_string(),
1199            CodeActionKind::SourceFixAll => "source.fixAll".to_string(),
1200            CodeActionKind::Notebook => "notebook".to_string(),
1201            CodeActionKind::Custom(any) => any.into_owned(),
1202        }
1203    }
1204}
1205impl From<String> for CodeActionKind {
1206    fn from(v: String) -> Self {
1207        match v.as_str() {
1208            "" => Self::Empty,
1209            "quickfix" => Self::QuickFix,
1210            "refactor" => Self::Refactor,
1211            "refactor.extract" => Self::RefactorExtract,
1212            "refactor.inline" => Self::RefactorInline,
1213            "refactor.move" => Self::RefactorMove,
1214            "refactor.rewrite" => Self::RefactorRewrite,
1215            "source" => Self::Source,
1216            "source.organizeImports" => Self::SourceOrganizeImports,
1217            "source.fixAll" => Self::SourceFixAll,
1218            "notebook" => Self::Notebook,
1219            _ => Self::Custom(Cow::Owned(v)),
1220        }
1221    }
1222}
1223impl CodeActionKind {
1224    /// Create a custom `CodeActionKind` from a string literal.
1225    #[must_use]
1226    pub const fn new(s: &'static str) -> Self {
1227        Self::Custom(Cow::Borrowed(s))
1228    }
1229}
1230impl From<&'static str> for CodeActionKind {
1231    fn from(s: &'static str) -> Self {
1232        match s {
1233            "" => Self::Empty,
1234            "quickfix" => Self::QuickFix,
1235            "refactor" => Self::Refactor,
1236            "refactor.extract" => Self::RefactorExtract,
1237            "refactor.inline" => Self::RefactorInline,
1238            "refactor.move" => Self::RefactorMove,
1239            "refactor.rewrite" => Self::RefactorRewrite,
1240            "source" => Self::Source,
1241            "source.organizeImports" => Self::SourceOrganizeImports,
1242            "source.fixAll" => Self::SourceFixAll,
1243            "notebook" => Self::Notebook,
1244            _ => Self::Custom(Cow::Borrowed(s)),
1245        }
1246    }
1247}
1248impl fmt::Display for CodeActionKind {
1249    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1250        let s: String = self.clone().into();
1251        write!(f, "{s}")
1252    }
1253}
1254impl CodeActionKind {
1255    #[must_use]
1256    pub fn as_str(&self) -> &str {
1257        match self {
1258            Self::Empty => "",
1259            Self::QuickFix => "quickfix",
1260            Self::Refactor => "refactor",
1261            Self::RefactorExtract => "refactor.extract",
1262            Self::RefactorInline => "refactor.inline",
1263            Self::RefactorMove => "refactor.move",
1264            Self::RefactorRewrite => "refactor.rewrite",
1265            Self::Source => "source",
1266            Self::SourceOrganizeImports => "source.organizeImports",
1267            Self::SourceFixAll => "source.fixAll",
1268            Self::Notebook => "notebook",
1269            Self::Custom(any) => any,
1270        }
1271    }
1272}
1273
1274/// Code action tags are extra annotations that tweak the behavior of a code action.
1275///
1276/// @since 3.18.0 - proposed
1277#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
1278#[serde(into = "u32", try_from = "u32")]
1279pub enum CodeActionTag {
1280    /// Marks the code action as LLM-generated.
1281    LLMGenerated,
1282}
1283impl From<CodeActionTag> for u32 {
1284    fn from(e: CodeActionTag) -> Self {
1285        match e {
1286            CodeActionTag::LLMGenerated => 1u32,
1287        }
1288    }
1289}
1290impl TryFrom<u32> for CodeActionTag {
1291    type Error = String;
1292    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
1293        match v {
1294            1u32 => Ok(Self::LLMGenerated),
1295            _ => Err(format!("Invalid CodeActionTag: {v}")),
1296        }
1297    }
1298}
1299
1300#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
1301#[serde(into = "String", try_from = "String")]
1302pub enum TraceValue {
1303    /// Turn tracing off.
1304    Off,
1305    /// Trace messages only.
1306    Messages,
1307    /// Verbose message tracing.
1308    Verbose,
1309}
1310impl From<TraceValue> for String {
1311    fn from(e: TraceValue) -> Self {
1312        match e {
1313            TraceValue::Off => "off".to_string(),
1314            TraceValue::Messages => "messages".to_string(),
1315            TraceValue::Verbose => "verbose".to_string(),
1316        }
1317    }
1318}
1319impl TryFrom<String> for TraceValue {
1320    type Error = String;
1321    fn try_from(v: String) -> Result<Self, <Self as TryFrom<String>>::Error> {
1322        match v.as_str() {
1323            "off" => Ok(Self::Off),
1324            "messages" => Ok(Self::Messages),
1325            "verbose" => Ok(Self::Verbose),
1326            _ => Err(format!("Invalid TraceValue: {v}")),
1327        }
1328    }
1329}
1330impl fmt::Display for TraceValue {
1331    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1332        let s: String = (*self).into();
1333        write!(f, "{s}")
1334    }
1335}
1336impl TraceValue {
1337    #[must_use]
1338    pub fn as_str(&self) -> &str {
1339        match self {
1340            Self::Off => "off",
1341            Self::Messages => "messages",
1342            Self::Verbose => "verbose",
1343        }
1344    }
1345}
1346
1347/// Describes the content type that a client supports in various
1348/// result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
1349///
1350/// Please note that `MarkupKinds` must not start with a `$`. This kinds
1351/// are reserved for internal usage.
1352#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
1353#[serde(into = "String", try_from = "String")]
1354pub enum MarkupKind {
1355    /// Plain text is supported as a content format
1356    PlainText,
1357    /// Markdown is supported as a content format
1358    Markdown,
1359}
1360impl From<MarkupKind> for String {
1361    fn from(e: MarkupKind) -> Self {
1362        match e {
1363            MarkupKind::PlainText => "plaintext".to_string(),
1364            MarkupKind::Markdown => "markdown".to_string(),
1365        }
1366    }
1367}
1368impl TryFrom<String> for MarkupKind {
1369    type Error = String;
1370    fn try_from(v: String) -> Result<Self, <Self as TryFrom<String>>::Error> {
1371        match v.as_str() {
1372            "plaintext" => Ok(Self::PlainText),
1373            "markdown" => Ok(Self::Markdown),
1374            _ => Err(format!("Invalid MarkupKind: {v}")),
1375        }
1376    }
1377}
1378impl fmt::Display for MarkupKind {
1379    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1380        let s: String = (*self).into();
1381        write!(f, "{s}")
1382    }
1383}
1384impl MarkupKind {
1385    #[must_use]
1386    pub fn as_str(&self) -> &str {
1387        match self {
1388            Self::PlainText => "plaintext",
1389            Self::Markdown => "markdown",
1390        }
1391    }
1392}
1393
1394/// Predefined Language kinds
1395/// @since 3.18.0
1396#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize)]
1397#[serde(into = "String", from = "String")]
1398pub enum LanguageKind {
1399    ABAP,
1400    WindowsBat,
1401    BibTeX,
1402    Clojure,
1403    Coffeescript,
1404    C,
1405    CPP,
1406    CSharp,
1407    CSS,
1408    /// @since 3.18.0
1409    /// @proposed
1410    D,
1411    /// @since 3.18.0
1412    /// @proposed
1413    Delphi,
1414    Diff,
1415    Dart,
1416    Dockerfile,
1417    Elixir,
1418    Erlang,
1419    FSharp,
1420    GitCommit,
1421    GitRebase,
1422    Go,
1423    Groovy,
1424    Handlebars,
1425    Haskell,
1426    HTML,
1427    Ini,
1428    Java,
1429    JavaScript,
1430    JavaScriptReact,
1431    JSON,
1432    LaTeX,
1433    Less,
1434    Lua,
1435    Makefile,
1436    Markdown,
1437    ObjectiveC,
1438    ObjectiveCPP,
1439    /// @since 3.18.0
1440    /// @proposed
1441    Pascal,
1442    Perl,
1443    Perl6,
1444    PHP,
1445    Powershell,
1446    Pug,
1447    Python,
1448    R,
1449    Razor,
1450    Ruby,
1451    Rust,
1452    SCSS,
1453    SASS,
1454    Scala,
1455    ShaderLab,
1456    ShellScript,
1457    SQL,
1458    Swift,
1459    TypeScript,
1460    TypeScriptReact,
1461    TeX,
1462    VisualBasic,
1463    XML,
1464    XSL,
1465    YAML,
1466    /// A custom value.
1467    #[serde(untagged)]
1468    Custom(Cow<'static, str>),
1469}
1470impl From<LanguageKind> for String {
1471    fn from(e: LanguageKind) -> Self {
1472        match e {
1473            LanguageKind::ABAP => "abap".to_string(),
1474            LanguageKind::WindowsBat => "bat".to_string(),
1475            LanguageKind::BibTeX => "bibtex".to_string(),
1476            LanguageKind::Clojure => "clojure".to_string(),
1477            LanguageKind::Coffeescript => "coffeescript".to_string(),
1478            LanguageKind::C => "c".to_string(),
1479            LanguageKind::CPP => "cpp".to_string(),
1480            LanguageKind::CSharp => "csharp".to_string(),
1481            LanguageKind::CSS => "css".to_string(),
1482            LanguageKind::D => "d".to_string(),
1483            LanguageKind::Delphi => "pascal".to_string(),
1484            LanguageKind::Diff => "diff".to_string(),
1485            LanguageKind::Dart => "dart".to_string(),
1486            LanguageKind::Dockerfile => "dockerfile".to_string(),
1487            LanguageKind::Elixir => "elixir".to_string(),
1488            LanguageKind::Erlang => "erlang".to_string(),
1489            LanguageKind::FSharp => "fsharp".to_string(),
1490            LanguageKind::GitCommit => "git-commit".to_string(),
1491            LanguageKind::GitRebase => "rebase".to_string(),
1492            LanguageKind::Go => "go".to_string(),
1493            LanguageKind::Groovy => "groovy".to_string(),
1494            LanguageKind::Handlebars => "handlebars".to_string(),
1495            LanguageKind::Haskell => "haskell".to_string(),
1496            LanguageKind::HTML => "html".to_string(),
1497            LanguageKind::Ini => "ini".to_string(),
1498            LanguageKind::Java => "java".to_string(),
1499            LanguageKind::JavaScript => "javascript".to_string(),
1500            LanguageKind::JavaScriptReact => "javascriptreact".to_string(),
1501            LanguageKind::JSON => "json".to_string(),
1502            LanguageKind::LaTeX => "latex".to_string(),
1503            LanguageKind::Less => "less".to_string(),
1504            LanguageKind::Lua => "lua".to_string(),
1505            LanguageKind::Makefile => "makefile".to_string(),
1506            LanguageKind::Markdown => "markdown".to_string(),
1507            LanguageKind::ObjectiveC => "objective-c".to_string(),
1508            LanguageKind::ObjectiveCPP => "objective-cpp".to_string(),
1509            LanguageKind::Pascal => "pascal".to_string(),
1510            LanguageKind::Perl => "perl".to_string(),
1511            LanguageKind::Perl6 => "perl6".to_string(),
1512            LanguageKind::PHP => "php".to_string(),
1513            LanguageKind::Powershell => "powershell".to_string(),
1514            LanguageKind::Pug => "jade".to_string(),
1515            LanguageKind::Python => "python".to_string(),
1516            LanguageKind::R => "r".to_string(),
1517            LanguageKind::Razor => "razor".to_string(),
1518            LanguageKind::Ruby => "ruby".to_string(),
1519            LanguageKind::Rust => "rust".to_string(),
1520            LanguageKind::SCSS => "scss".to_string(),
1521            LanguageKind::SASS => "sass".to_string(),
1522            LanguageKind::Scala => "scala".to_string(),
1523            LanguageKind::ShaderLab => "shaderlab".to_string(),
1524            LanguageKind::ShellScript => "shellscript".to_string(),
1525            LanguageKind::SQL => "sql".to_string(),
1526            LanguageKind::Swift => "swift".to_string(),
1527            LanguageKind::TypeScript => "typescript".to_string(),
1528            LanguageKind::TypeScriptReact => "typescriptreact".to_string(),
1529            LanguageKind::TeX => "tex".to_string(),
1530            LanguageKind::VisualBasic => "vb".to_string(),
1531            LanguageKind::XML => "xml".to_string(),
1532            LanguageKind::XSL => "xsl".to_string(),
1533            LanguageKind::YAML => "yaml".to_string(),
1534            LanguageKind::Custom(any) => any.into_owned(),
1535        }
1536    }
1537}
1538impl From<String> for LanguageKind {
1539    fn from(v: String) -> Self {
1540        match v.as_str() {
1541            "abap" => Self::ABAP,
1542            "bat" => Self::WindowsBat,
1543            "bibtex" => Self::BibTeX,
1544            "clojure" => Self::Clojure,
1545            "coffeescript" => Self::Coffeescript,
1546            "c" => Self::C,
1547            "cpp" => Self::CPP,
1548            "csharp" => Self::CSharp,
1549            "css" => Self::CSS,
1550            "d" => Self::D,
1551            "pascal" => Self::Delphi,
1552            "diff" => Self::Diff,
1553            "dart" => Self::Dart,
1554            "dockerfile" => Self::Dockerfile,
1555            "elixir" => Self::Elixir,
1556            "erlang" => Self::Erlang,
1557            "fsharp" => Self::FSharp,
1558            "git-commit" => Self::GitCommit,
1559            "rebase" => Self::GitRebase,
1560            "go" => Self::Go,
1561            "groovy" => Self::Groovy,
1562            "handlebars" => Self::Handlebars,
1563            "haskell" => Self::Haskell,
1564            "html" => Self::HTML,
1565            "ini" => Self::Ini,
1566            "java" => Self::Java,
1567            "javascript" => Self::JavaScript,
1568            "javascriptreact" => Self::JavaScriptReact,
1569            "json" => Self::JSON,
1570            "latex" => Self::LaTeX,
1571            "less" => Self::Less,
1572            "lua" => Self::Lua,
1573            "makefile" => Self::Makefile,
1574            "markdown" => Self::Markdown,
1575            "objective-c" => Self::ObjectiveC,
1576            "objective-cpp" => Self::ObjectiveCPP,
1577            "pascal" => Self::Pascal,
1578            "perl" => Self::Perl,
1579            "perl6" => Self::Perl6,
1580            "php" => Self::PHP,
1581            "powershell" => Self::Powershell,
1582            "jade" => Self::Pug,
1583            "python" => Self::Python,
1584            "r" => Self::R,
1585            "razor" => Self::Razor,
1586            "ruby" => Self::Ruby,
1587            "rust" => Self::Rust,
1588            "scss" => Self::SCSS,
1589            "sass" => Self::SASS,
1590            "scala" => Self::Scala,
1591            "shaderlab" => Self::ShaderLab,
1592            "shellscript" => Self::ShellScript,
1593            "sql" => Self::SQL,
1594            "swift" => Self::Swift,
1595            "typescript" => Self::TypeScript,
1596            "typescriptreact" => Self::TypeScriptReact,
1597            "tex" => Self::TeX,
1598            "vb" => Self::VisualBasic,
1599            "xml" => Self::XML,
1600            "xsl" => Self::XSL,
1601            "yaml" => Self::YAML,
1602            _ => Self::Custom(Cow::Owned(v)),
1603        }
1604    }
1605}
1606impl LanguageKind {
1607    /// Create a custom `LanguageKind` from a string literal.
1608    #[must_use]
1609    pub const fn new(s: &'static str) -> Self {
1610        Self::Custom(Cow::Borrowed(s))
1611    }
1612}
1613impl From<&'static str> for LanguageKind {
1614    fn from(s: &'static str) -> Self {
1615        match s {
1616            "abap" => Self::ABAP,
1617            "bat" => Self::WindowsBat,
1618            "bibtex" => Self::BibTeX,
1619            "clojure" => Self::Clojure,
1620            "coffeescript" => Self::Coffeescript,
1621            "c" => Self::C,
1622            "cpp" => Self::CPP,
1623            "csharp" => Self::CSharp,
1624            "css" => Self::CSS,
1625            "d" => Self::D,
1626            "pascal" => Self::Delphi,
1627            "diff" => Self::Diff,
1628            "dart" => Self::Dart,
1629            "dockerfile" => Self::Dockerfile,
1630            "elixir" => Self::Elixir,
1631            "erlang" => Self::Erlang,
1632            "fsharp" => Self::FSharp,
1633            "git-commit" => Self::GitCommit,
1634            "rebase" => Self::GitRebase,
1635            "go" => Self::Go,
1636            "groovy" => Self::Groovy,
1637            "handlebars" => Self::Handlebars,
1638            "haskell" => Self::Haskell,
1639            "html" => Self::HTML,
1640            "ini" => Self::Ini,
1641            "java" => Self::Java,
1642            "javascript" => Self::JavaScript,
1643            "javascriptreact" => Self::JavaScriptReact,
1644            "json" => Self::JSON,
1645            "latex" => Self::LaTeX,
1646            "less" => Self::Less,
1647            "lua" => Self::Lua,
1648            "makefile" => Self::Makefile,
1649            "markdown" => Self::Markdown,
1650            "objective-c" => Self::ObjectiveC,
1651            "objective-cpp" => Self::ObjectiveCPP,
1652            "pascal" => Self::Pascal,
1653            "perl" => Self::Perl,
1654            "perl6" => Self::Perl6,
1655            "php" => Self::PHP,
1656            "powershell" => Self::Powershell,
1657            "jade" => Self::Pug,
1658            "python" => Self::Python,
1659            "r" => Self::R,
1660            "razor" => Self::Razor,
1661            "ruby" => Self::Ruby,
1662            "rust" => Self::Rust,
1663            "scss" => Self::SCSS,
1664            "sass" => Self::SASS,
1665            "scala" => Self::Scala,
1666            "shaderlab" => Self::ShaderLab,
1667            "shellscript" => Self::ShellScript,
1668            "sql" => Self::SQL,
1669            "swift" => Self::Swift,
1670            "typescript" => Self::TypeScript,
1671            "typescriptreact" => Self::TypeScriptReact,
1672            "tex" => Self::TeX,
1673            "vb" => Self::VisualBasic,
1674            "xml" => Self::XML,
1675            "xsl" => Self::XSL,
1676            "yaml" => Self::YAML,
1677            _ => Self::Custom(Cow::Borrowed(s)),
1678        }
1679    }
1680}
1681impl fmt::Display for LanguageKind {
1682    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1683        let s: String = self.clone().into();
1684        write!(f, "{s}")
1685    }
1686}
1687impl LanguageKind {
1688    #[must_use]
1689    pub fn as_str(&self) -> &str {
1690        match self {
1691            Self::ABAP => "abap",
1692            Self::WindowsBat => "bat",
1693            Self::BibTeX => "bibtex",
1694            Self::Clojure => "clojure",
1695            Self::Coffeescript => "coffeescript",
1696            Self::C => "c",
1697            Self::CPP => "cpp",
1698            Self::CSharp => "csharp",
1699            Self::CSS => "css",
1700            Self::D => "d",
1701            Self::Delphi => "pascal",
1702            Self::Diff => "diff",
1703            Self::Dart => "dart",
1704            Self::Dockerfile => "dockerfile",
1705            Self::Elixir => "elixir",
1706            Self::Erlang => "erlang",
1707            Self::FSharp => "fsharp",
1708            Self::GitCommit => "git-commit",
1709            Self::GitRebase => "rebase",
1710            Self::Go => "go",
1711            Self::Groovy => "groovy",
1712            Self::Handlebars => "handlebars",
1713            Self::Haskell => "haskell",
1714            Self::HTML => "html",
1715            Self::Ini => "ini",
1716            Self::Java => "java",
1717            Self::JavaScript => "javascript",
1718            Self::JavaScriptReact => "javascriptreact",
1719            Self::JSON => "json",
1720            Self::LaTeX => "latex",
1721            Self::Less => "less",
1722            Self::Lua => "lua",
1723            Self::Makefile => "makefile",
1724            Self::Markdown => "markdown",
1725            Self::ObjectiveC => "objective-c",
1726            Self::ObjectiveCPP => "objective-cpp",
1727            Self::Pascal => "pascal",
1728            Self::Perl => "perl",
1729            Self::Perl6 => "perl6",
1730            Self::PHP => "php",
1731            Self::Powershell => "powershell",
1732            Self::Pug => "jade",
1733            Self::Python => "python",
1734            Self::R => "r",
1735            Self::Razor => "razor",
1736            Self::Ruby => "ruby",
1737            Self::Rust => "rust",
1738            Self::SCSS => "scss",
1739            Self::SASS => "sass",
1740            Self::Scala => "scala",
1741            Self::ShaderLab => "shaderlab",
1742            Self::ShellScript => "shellscript",
1743            Self::SQL => "sql",
1744            Self::Swift => "swift",
1745            Self::TypeScript => "typescript",
1746            Self::TypeScriptReact => "typescriptreact",
1747            Self::TeX => "tex",
1748            Self::VisualBasic => "vb",
1749            Self::XML => "xml",
1750            Self::XSL => "xsl",
1751            Self::YAML => "yaml",
1752            Self::Custom(any) => any,
1753        }
1754    }
1755}
1756
1757/// Describes how an [inline completion provider][InlineCompletionItemProvider] was triggered.
1758///
1759/// @since 3.18.0
1760/// @proposed
1761#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
1762#[serde(into = "u32", try_from = "u32")]
1763pub enum InlineCompletionTriggerKind {
1764    /// Completion was triggered explicitly by a user gesture.
1765    Invoked,
1766    /// Completion was triggered automatically while editing.
1767    Automatic,
1768}
1769impl From<InlineCompletionTriggerKind> for u32 {
1770    fn from(e: InlineCompletionTriggerKind) -> Self {
1771        match e {
1772            InlineCompletionTriggerKind::Invoked => 1u32,
1773            InlineCompletionTriggerKind::Automatic => 2u32,
1774        }
1775    }
1776}
1777impl TryFrom<u32> for InlineCompletionTriggerKind {
1778    type Error = String;
1779    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
1780        match v {
1781            1u32 => Ok(Self::Invoked),
1782            2u32 => Ok(Self::Automatic),
1783            _ => Err(format!("Invalid InlineCompletionTriggerKind: {v}")),
1784        }
1785    }
1786}
1787
1788/// A set of predefined position encoding kinds.
1789///
1790/// @since 3.17.0
1791#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize)]
1792#[serde(into = "String", from = "String")]
1793pub enum PositionEncodingKind {
1794    /// Character offsets count UTF-8 code units (e.g. bytes).
1795    UTF8,
1796    /// Character offsets count UTF-16 code units.
1797    ///
1798    /// This is the default and must always be supported
1799    /// by servers
1800    UTF16,
1801    /// Character offsets count UTF-32 code units.
1802    ///
1803    /// Implementation note: these are the same as Unicode codepoints,
1804    /// so this `PositionEncodingKind` may also be used for an
1805    /// encoding-agnostic representation of character offsets.
1806    UTF32,
1807    /// A custom value.
1808    #[serde(untagged)]
1809    Custom(Cow<'static, str>),
1810}
1811impl From<PositionEncodingKind> for String {
1812    fn from(e: PositionEncodingKind) -> Self {
1813        match e {
1814            PositionEncodingKind::UTF8 => "utf-8".to_string(),
1815            PositionEncodingKind::UTF16 => "utf-16".to_string(),
1816            PositionEncodingKind::UTF32 => "utf-32".to_string(),
1817            PositionEncodingKind::Custom(any) => any.into_owned(),
1818        }
1819    }
1820}
1821impl From<String> for PositionEncodingKind {
1822    fn from(v: String) -> Self {
1823        match v.as_str() {
1824            "utf-8" => Self::UTF8,
1825            "utf-16" => Self::UTF16,
1826            "utf-32" => Self::UTF32,
1827            _ => Self::Custom(Cow::Owned(v)),
1828        }
1829    }
1830}
1831impl PositionEncodingKind {
1832    /// Create a custom `PositionEncodingKind` from a string literal.
1833    #[must_use]
1834    pub const fn new(s: &'static str) -> Self {
1835        Self::Custom(Cow::Borrowed(s))
1836    }
1837}
1838impl From<&'static str> for PositionEncodingKind {
1839    fn from(s: &'static str) -> Self {
1840        match s {
1841            "utf-8" => Self::UTF8,
1842            "utf-16" => Self::UTF16,
1843            "utf-32" => Self::UTF32,
1844            _ => Self::Custom(Cow::Borrowed(s)),
1845        }
1846    }
1847}
1848impl fmt::Display for PositionEncodingKind {
1849    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1850        let s: String = self.clone().into();
1851        write!(f, "{s}")
1852    }
1853}
1854impl PositionEncodingKind {
1855    #[must_use]
1856    pub fn as_str(&self) -> &str {
1857        match self {
1858            Self::UTF8 => "utf-8",
1859            Self::UTF16 => "utf-16",
1860            Self::UTF32 => "utf-32",
1861            Self::Custom(any) => any,
1862        }
1863    }
1864}
1865
1866/// The file event type
1867#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
1868#[serde(into = "u32", try_from = "u32")]
1869pub enum FileChangeType {
1870    /// The file got created.
1871    Created,
1872    /// The file got changed.
1873    Changed,
1874    /// The file got deleted.
1875    Deleted,
1876}
1877impl From<FileChangeType> for u32 {
1878    fn from(e: FileChangeType) -> Self {
1879        match e {
1880            FileChangeType::Created => 1u32,
1881            FileChangeType::Changed => 2u32,
1882            FileChangeType::Deleted => 3u32,
1883        }
1884    }
1885}
1886impl TryFrom<u32> for FileChangeType {
1887    type Error = String;
1888    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
1889        match v {
1890            1u32 => Ok(Self::Created),
1891            2u32 => Ok(Self::Changed),
1892            3u32 => Ok(Self::Deleted),
1893            _ => Err(format!("Invalid FileChangeType: {v}")),
1894        }
1895    }
1896}
1897
1898#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
1899#[serde(into = "u32", from = "u32")]
1900pub enum WatchKind {
1901    /// Interested in create events.
1902    Create,
1903    /// Interested in change events
1904    Change,
1905    /// Interested in delete events
1906    Delete,
1907    /// A custom value.
1908    #[serde(untagged)]
1909    Custom(u32),
1910}
1911impl From<WatchKind> for u32 {
1912    fn from(e: WatchKind) -> Self {
1913        match e {
1914            WatchKind::Create => 1u32,
1915            WatchKind::Change => 2u32,
1916            WatchKind::Delete => 4u32,
1917            WatchKind::Custom(any) => any,
1918        }
1919    }
1920}
1921impl From<u32> for WatchKind {
1922    fn from(v: u32) -> Self {
1923        match v {
1924            1u32 => Self::Create,
1925            2u32 => Self::Change,
1926            4u32 => Self::Delete,
1927            _ => Self::Custom(v),
1928        }
1929    }
1930}
1931
1932/// The diagnostic's severity.
1933#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
1934#[serde(into = "u32", try_from = "u32")]
1935pub enum DiagnosticSeverity {
1936    /// Reports an error.
1937    Error,
1938    /// Reports a warning.
1939    Warning,
1940    /// Reports an information.
1941    Information,
1942    /// Reports a hint.
1943    Hint,
1944}
1945impl From<DiagnosticSeverity> for u32 {
1946    fn from(e: DiagnosticSeverity) -> Self {
1947        match e {
1948            DiagnosticSeverity::Error => 1u32,
1949            DiagnosticSeverity::Warning => 2u32,
1950            DiagnosticSeverity::Information => 3u32,
1951            DiagnosticSeverity::Hint => 4u32,
1952        }
1953    }
1954}
1955impl TryFrom<u32> for DiagnosticSeverity {
1956    type Error = String;
1957    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
1958        match v {
1959            1u32 => Ok(Self::Error),
1960            2u32 => Ok(Self::Warning),
1961            3u32 => Ok(Self::Information),
1962            4u32 => Ok(Self::Hint),
1963            _ => Err(format!("Invalid DiagnosticSeverity: {v}")),
1964        }
1965    }
1966}
1967
1968/// The diagnostic tags.
1969///
1970/// @since 3.15.0
1971#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
1972#[serde(into = "u32", try_from = "u32")]
1973pub enum DiagnosticTag {
1974    /// Unused or unnecessary code.
1975    ///
1976    /// Clients are allowed to render diagnostics with this tag faded out instead of having
1977    /// an error squiggle.
1978    Unnecessary,
1979    /// Deprecated or obsolete code.
1980    ///
1981    /// Clients are allowed to rendered diagnostics with this tag strike through.
1982    Deprecated,
1983}
1984impl From<DiagnosticTag> for u32 {
1985    fn from(e: DiagnosticTag) -> Self {
1986        match e {
1987            DiagnosticTag::Unnecessary => 1u32,
1988            DiagnosticTag::Deprecated => 2u32,
1989        }
1990    }
1991}
1992impl TryFrom<u32> for DiagnosticTag {
1993    type Error = String;
1994    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
1995        match v {
1996            1u32 => Ok(Self::Unnecessary),
1997            2u32 => Ok(Self::Deprecated),
1998            _ => Err(format!("Invalid DiagnosticTag: {v}")),
1999        }
2000    }
2001}
2002
2003/// How a completion was triggered
2004#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
2005#[serde(into = "u32", try_from = "u32")]
2006pub enum CompletionTriggerKind {
2007    /// Completion was triggered by typing an identifier (24x7 code
2008    /// complete), manual invocation (e.g Ctrl+Space) or via API.
2009    Invoked,
2010    /// Completion was triggered by a trigger character specified by
2011    /// the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
2012    TriggerCharacter,
2013    /// Completion was re-triggered as current completion list is incomplete
2014    TriggerForIncompleteCompletions,
2015}
2016impl From<CompletionTriggerKind> for u32 {
2017    fn from(e: CompletionTriggerKind) -> Self {
2018        match e {
2019            CompletionTriggerKind::Invoked => 1u32,
2020            CompletionTriggerKind::TriggerCharacter => 2u32,
2021            CompletionTriggerKind::TriggerForIncompleteCompletions => 3u32,
2022        }
2023    }
2024}
2025impl TryFrom<u32> for CompletionTriggerKind {
2026    type Error = String;
2027    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
2028        match v {
2029            1u32 => Ok(Self::Invoked),
2030            2u32 => Ok(Self::TriggerCharacter),
2031            3u32 => Ok(Self::TriggerForIncompleteCompletions),
2032            _ => Err(format!("Invalid CompletionTriggerKind: {v}")),
2033        }
2034    }
2035}
2036
2037/// Defines how values from a set of defaults and an individual item will be
2038/// merged.
2039///
2040/// @since 3.18.0
2041#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
2042#[serde(into = "u32", try_from = "u32")]
2043pub enum ApplyKind {
2044    /// The value from the individual item (if provided and not `null`) will be
2045    /// used instead of the default.
2046    Replace,
2047    /// The value from the item will be merged with the default.
2048    ///
2049    /// The specific rules for mergeing values are defined against each field
2050    /// that supports merging.
2051    Merge,
2052}
2053impl From<ApplyKind> for u32 {
2054    fn from(e: ApplyKind) -> Self {
2055        match e {
2056            ApplyKind::Replace => 1u32,
2057            ApplyKind::Merge => 2u32,
2058        }
2059    }
2060}
2061impl TryFrom<u32> for ApplyKind {
2062    type Error = String;
2063    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
2064        match v {
2065            1u32 => Ok(Self::Replace),
2066            2u32 => Ok(Self::Merge),
2067            _ => Err(format!("Invalid ApplyKind: {v}")),
2068        }
2069    }
2070}
2071
2072/// How a signature help was triggered.
2073///
2074/// @since 3.15.0
2075#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
2076#[serde(into = "u32", try_from = "u32")]
2077pub enum SignatureHelpTriggerKind {
2078    /// Signature help was invoked manually by the user or by a command.
2079    Invoked,
2080    /// Signature help was triggered by a trigger character.
2081    TriggerCharacter,
2082    /// Signature help was triggered by the cursor moving or by the document content changing.
2083    ContentChange,
2084}
2085impl From<SignatureHelpTriggerKind> for u32 {
2086    fn from(e: SignatureHelpTriggerKind) -> Self {
2087        match e {
2088            SignatureHelpTriggerKind::Invoked => 1u32,
2089            SignatureHelpTriggerKind::TriggerCharacter => 2u32,
2090            SignatureHelpTriggerKind::ContentChange => 3u32,
2091        }
2092    }
2093}
2094impl TryFrom<u32> for SignatureHelpTriggerKind {
2095    type Error = String;
2096    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
2097        match v {
2098            1u32 => Ok(Self::Invoked),
2099            2u32 => Ok(Self::TriggerCharacter),
2100            3u32 => Ok(Self::ContentChange),
2101            _ => Err(format!("Invalid SignatureHelpTriggerKind: {v}")),
2102        }
2103    }
2104}
2105
2106/// The reason why code actions were requested.
2107///
2108/// @since 3.17.0
2109#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
2110#[serde(into = "u32", try_from = "u32")]
2111pub enum CodeActionTriggerKind {
2112    /// Code actions were explicitly requested by the user or by an extension.
2113    Invoked,
2114    /// Code actions were requested automatically.
2115    ///
2116    /// This typically happens when current selection in a file changes, but can
2117    /// also be triggered when file content changes.
2118    Automatic,
2119}
2120impl From<CodeActionTriggerKind> for u32 {
2121    fn from(e: CodeActionTriggerKind) -> Self {
2122        match e {
2123            CodeActionTriggerKind::Invoked => 1u32,
2124            CodeActionTriggerKind::Automatic => 2u32,
2125        }
2126    }
2127}
2128impl TryFrom<u32> for CodeActionTriggerKind {
2129    type Error = String;
2130    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
2131        match v {
2132            1u32 => Ok(Self::Invoked),
2133            2u32 => Ok(Self::Automatic),
2134            _ => Err(format!("Invalid CodeActionTriggerKind: {v}")),
2135        }
2136    }
2137}
2138
2139/// A pattern kind describing if a glob pattern matches a file a folder or
2140/// both.
2141///
2142/// @since 3.16.0
2143#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
2144#[serde(into = "String", try_from = "String")]
2145pub enum FileOperationPatternKind {
2146    /// The pattern matches a file only.
2147    File,
2148    /// The pattern matches a folder only.
2149    Folder,
2150}
2151impl From<FileOperationPatternKind> for String {
2152    fn from(e: FileOperationPatternKind) -> Self {
2153        match e {
2154            FileOperationPatternKind::File => "file".to_string(),
2155            FileOperationPatternKind::Folder => "folder".to_string(),
2156        }
2157    }
2158}
2159impl TryFrom<String> for FileOperationPatternKind {
2160    type Error = String;
2161    fn try_from(v: String) -> Result<Self, <Self as TryFrom<String>>::Error> {
2162        match v.as_str() {
2163            "file" => Ok(Self::File),
2164            "folder" => Ok(Self::Folder),
2165            _ => Err(format!("Invalid FileOperationPatternKind: {v}")),
2166        }
2167    }
2168}
2169impl fmt::Display for FileOperationPatternKind {
2170    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2171        let s: String = (*self).into();
2172        write!(f, "{s}")
2173    }
2174}
2175impl FileOperationPatternKind {
2176    #[must_use]
2177    pub fn as_str(&self) -> &str {
2178        match self {
2179            Self::File => "file",
2180            Self::Folder => "folder",
2181        }
2182    }
2183}
2184
2185/// A notebook cell kind.
2186///
2187/// @since 3.17.0
2188#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
2189#[serde(into = "u32", try_from = "u32")]
2190pub enum NotebookCellKind {
2191    /// A markup-cell is formatted source that is used for display.
2192    Markup,
2193    /// A code-cell is source code.
2194    Code,
2195}
2196impl From<NotebookCellKind> for u32 {
2197    fn from(e: NotebookCellKind) -> Self {
2198        match e {
2199            NotebookCellKind::Markup => 1u32,
2200            NotebookCellKind::Code => 2u32,
2201        }
2202    }
2203}
2204impl TryFrom<u32> for NotebookCellKind {
2205    type Error = String;
2206    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
2207        match v {
2208            1u32 => Ok(Self::Markup),
2209            2u32 => Ok(Self::Code),
2210            _ => Err(format!("Invalid NotebookCellKind: {v}")),
2211        }
2212    }
2213}
2214
2215#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
2216#[serde(into = "String", try_from = "String")]
2217pub enum ResourceOperationKind {
2218    /// Supports creating new files and folders.
2219    Create,
2220    /// Supports renaming existing files and folders.
2221    Rename,
2222    /// Supports deleting existing files and folders.
2223    Delete,
2224}
2225impl From<ResourceOperationKind> for String {
2226    fn from(e: ResourceOperationKind) -> Self {
2227        match e {
2228            ResourceOperationKind::Create => "create".to_string(),
2229            ResourceOperationKind::Rename => "rename".to_string(),
2230            ResourceOperationKind::Delete => "delete".to_string(),
2231        }
2232    }
2233}
2234impl TryFrom<String> for ResourceOperationKind {
2235    type Error = String;
2236    fn try_from(v: String) -> Result<Self, <Self as TryFrom<String>>::Error> {
2237        match v.as_str() {
2238            "create" => Ok(Self::Create),
2239            "rename" => Ok(Self::Rename),
2240            "delete" => Ok(Self::Delete),
2241            _ => Err(format!("Invalid ResourceOperationKind: {v}")),
2242        }
2243    }
2244}
2245impl fmt::Display for ResourceOperationKind {
2246    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2247        let s: String = (*self).into();
2248        write!(f, "{s}")
2249    }
2250}
2251impl ResourceOperationKind {
2252    #[must_use]
2253    pub fn as_str(&self) -> &str {
2254        match self {
2255            Self::Create => "create",
2256            Self::Rename => "rename",
2257            Self::Delete => "delete",
2258        }
2259    }
2260}
2261
2262#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
2263#[serde(into = "String", try_from = "String")]
2264pub enum FailureHandlingKind {
2265    /// Applying the workspace change is simply aborted if one of the changes provided
2266    /// fails. All operations executed before the failing operation stay executed.
2267    Abort,
2268    /// All operations are executed transactional. That means they either all
2269    /// succeed or no changes at all are applied to the workspace.
2270    Transactional,
2271    /// If the workspace edit contains only textual file changes they are executed transactional.
2272    /// If resource changes (create, rename or delete file) are part of the change the failure
2273    /// handling strategy is abort.
2274    TextOnlyTransactional,
2275    /// The client tries to undo the operations already executed. But there is no
2276    /// guarantee that this is succeeding.
2277    Undo,
2278}
2279impl From<FailureHandlingKind> for String {
2280    fn from(e: FailureHandlingKind) -> Self {
2281        match e {
2282            FailureHandlingKind::Abort => "abort".to_string(),
2283            FailureHandlingKind::Transactional => "transactional".to_string(),
2284            FailureHandlingKind::TextOnlyTransactional => {
2285                "textOnlyTransactional".to_string()
2286            }
2287            FailureHandlingKind::Undo => "undo".to_string(),
2288        }
2289    }
2290}
2291impl TryFrom<String> for FailureHandlingKind {
2292    type Error = String;
2293    fn try_from(v: String) -> Result<Self, <Self as TryFrom<String>>::Error> {
2294        match v.as_str() {
2295            "abort" => Ok(Self::Abort),
2296            "transactional" => Ok(Self::Transactional),
2297            "textOnlyTransactional" => Ok(Self::TextOnlyTransactional),
2298            "undo" => Ok(Self::Undo),
2299            _ => Err(format!("Invalid FailureHandlingKind: {v}")),
2300        }
2301    }
2302}
2303impl fmt::Display for FailureHandlingKind {
2304    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2305        let s: String = (*self).into();
2306        write!(f, "{s}")
2307    }
2308}
2309impl FailureHandlingKind {
2310    #[must_use]
2311    pub fn as_str(&self) -> &str {
2312        match self {
2313            Self::Abort => "abort",
2314            Self::Transactional => "transactional",
2315            Self::TextOnlyTransactional => "textOnlyTransactional",
2316            Self::Undo => "undo",
2317        }
2318    }
2319}
2320
2321#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
2322#[serde(into = "u32", try_from = "u32")]
2323pub enum PrepareSupportDefaultBehavior {
2324    /// The client's default behavior is to select the identifier
2325    /// according the to language's syntax rule.
2326    Identifier,
2327}
2328impl From<PrepareSupportDefaultBehavior> for u32 {
2329    fn from(e: PrepareSupportDefaultBehavior) -> Self {
2330        match e {
2331            PrepareSupportDefaultBehavior::Identifier => 1u32,
2332        }
2333    }
2334}
2335impl TryFrom<u32> for PrepareSupportDefaultBehavior {
2336    type Error = String;
2337    fn try_from(v: u32) -> Result<Self, <Self as TryFrom<u32>>::Error> {
2338        match v {
2339            1u32 => Ok(Self::Identifier),
2340            _ => Err(format!("Invalid PrepareSupportDefaultBehavior: {v}")),
2341        }
2342    }
2343}
2344
2345#[derive(PartialEq, Eq, Hash, Debug, Clone, Serialize, Deserialize, Copy)]
2346#[serde(into = "String", try_from = "String")]
2347pub enum TokenFormat {
2348    Relative,
2349}
2350impl From<TokenFormat> for String {
2351    fn from(e: TokenFormat) -> Self {
2352        match e {
2353            TokenFormat::Relative => "relative".to_string(),
2354        }
2355    }
2356}
2357impl TryFrom<String> for TokenFormat {
2358    type Error = String;
2359    fn try_from(v: String) -> Result<Self, <Self as TryFrom<String>>::Error> {
2360        match v.as_str() {
2361            "relative" => Ok(Self::Relative),
2362            _ => Err(format!("Invalid TokenFormat: {v}")),
2363        }
2364    }
2365}
2366impl fmt::Display for TokenFormat {
2367    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2368        let s: String = (*self).into();
2369        write!(f, "{s}")
2370    }
2371}
2372impl TokenFormat {
2373    #[must_use]
2374    pub fn as_str(&self) -> &str {
2375        match self {
2376            Self::Relative => "relative",
2377        }
2378    }
2379}
2380
2381impl std::ops::BitOr for WatchKind {
2382    type Output = Self;
2383    fn bitor(self, rhs: Self) -> Self {
2384        (Into::<u32>::into(self) | Into::<u32>::into(rhs)).into()
2385    }
2386}
2387impl std::ops::BitOrAssign for WatchKind {
2388    fn bitor_assign(&mut self, rhs: Self) {
2389        *self = (Into::<u32>::into(*self) | Into::<u32>::into(rhs)).into();
2390    }
2391}
2392impl std::ops::BitAnd for WatchKind {
2393    type Output = Self;
2394    fn bitand(self, rhs: Self) -> Self {
2395        (Into::<u32>::into(self) & Into::<u32>::into(rhs)).into()
2396    }
2397}
2398impl std::ops::BitAndAssign for WatchKind {
2399    fn bitand_assign(&mut self, rhs: Self) {
2400        *self = (Into::<u32>::into(*self) & Into::<u32>::into(rhs)).into();
2401    }
2402}
2403impl std::ops::BitXor for WatchKind {
2404    type Output = Self;
2405    fn bitxor(self, rhs: Self) -> Self {
2406        (Into::<u32>::into(self) ^ Into::<u32>::into(rhs)).into()
2407    }
2408}
2409impl std::ops::BitXorAssign for WatchKind {
2410    fn bitxor_assign(&mut self, rhs: Self) {
2411        *self = (Into::<u32>::into(*self) ^ Into::<u32>::into(rhs)).into();
2412    }
2413}