-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21ba624
commit 5204f01
Showing
5 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct CompletionList { | ||
pub is_incomplete: bool, | ||
pub items: Vec<CompletionItem>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct CompletionItem { | ||
pub label: String, | ||
|
||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub kind: Option<i32>, | ||
|
||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub insert_text: Option<String>, | ||
|
||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub insert_text_format: Option<i32>, | ||
} | ||
|
||
#[derive(Clone, Copy, Debug)] | ||
#[allow(dead_code)] | ||
pub enum CompletionItemKind { | ||
Text = 1, | ||
Method = 2, | ||
Function = 3, | ||
Constructor = 4, | ||
Field = 5, | ||
Variable = 6, | ||
Class = 7, | ||
Interface = 8, | ||
Module = 9, | ||
Property = 10, | ||
Unit = 11, | ||
Value = 12, | ||
Enum = 13, | ||
Keyword = 14, | ||
Snippet = 15, | ||
Color = 16, | ||
File = 17, | ||
Reference = 18, | ||
Folder = 19, | ||
EnumMember = 20, | ||
Constant = 21, | ||
Struct = 22, | ||
Event = 23, | ||
Operator = 24, | ||
TypeParameter = 25, | ||
} | ||
|
||
#[derive(Clone, Copy, Debug)] | ||
#[allow(dead_code)] | ||
pub enum InsertTextFormat { | ||
PlainText = 1, | ||
Snippet = 2, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use crate::completion::{CompletionItem, CompletionItemKind, InsertTextFormat}; | ||
|
||
pub fn extend_completions(completions: &mut Vec<CompletionItem>) { | ||
completions.push(CompletionItem { | ||
label: "for".to_string(), | ||
kind: Some(CompletionItemKind::Snippet as i32), | ||
insert_text: Some("for ($1; $2; $3) {\n $4\n}$0".to_string()), | ||
insert_text_format: Some(InsertTextFormat::Snippet as i32), | ||
}); | ||
|
||
completions.push(CompletionItem { | ||
label: "if".to_string(), | ||
kind: Some(CompletionItemKind::Snippet as i32), | ||
insert_text: Some("if ($1) {\n $2\n}$0".to_string()), | ||
insert_text_format: Some(InsertTextFormat::Snippet as i32), | ||
}); | ||
|
||
completions.push(CompletionItem { | ||
label: "ifelse".to_string(), | ||
kind: Some(CompletionItemKind::Snippet as i32), | ||
insert_text: Some("if ($1) {\n $2\n} else {\n $3\n}$0".to_string()), | ||
insert_text_format: Some(InsertTextFormat::Snippet as i32), | ||
}); | ||
|
||
completions.push(CompletionItem { | ||
label: "while".to_string(), | ||
kind: Some(CompletionItemKind::Snippet as i32), | ||
insert_text: Some("while ($1) {\n $2\n}$0".to_string()), | ||
insert_text_format: Some(InsertTextFormat::Snippet as i32), | ||
}); | ||
} |