Skip to content

Commit e37202f

Browse files
remove dep
1 parent 7d9f8e2 commit e37202f

File tree

7 files changed

+38
-40
lines changed

7 files changed

+38
-40
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pg_completions/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ tree-sitter.workspace = true
1212
tree_sitter_sql.workspace = true
1313
pg_schema_cache.workspace = true
1414
pg_test_utils.workspace = true
15-
tower-lsp.workspace = true
1615

1716
sqlx.workspace = true
1817

crates/pg_completions/src/item.rs

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,3 @@ pub struct CompletionItem {
1111
pub preselected: Option<bool>,
1212
pub kind: CompletionItemKind,
1313
}
14-
15-
impl From<CompletionItem> for tower_lsp::lsp_types::CompletionItem {
16-
fn from(i: CompletionItem) -> Self {
17-
tower_lsp::lsp_types::CompletionItem {
18-
label: i.label,
19-
label_details: Some(tower_lsp::lsp_types::CompletionItemLabelDetails {
20-
description: Some(i.description),
21-
detail: None,
22-
}),
23-
kind: Some(i.kind.into()),
24-
detail: None,
25-
documentation: None,
26-
deprecated: None,
27-
preselect: None,
28-
sort_text: None,
29-
filter_text: None,
30-
insert_text: None,
31-
insert_text_format: None,
32-
insert_text_mode: None,
33-
text_edit: None,
34-
additional_text_edits: None,
35-
commit_characters: None,
36-
data: None,
37-
tags: None,
38-
command: None,
39-
}
40-
}
41-
}
42-
43-
impl From<CompletionItemKind> for tower_lsp::lsp_types::CompletionItemKind {
44-
fn from(value: CompletionItemKind) -> Self {
45-
match value {
46-
CompletionItemKind::Table => tower_lsp::lsp_types::CompletionItemKind::CLASS,
47-
}
48-
}
49-
}

crates/pg_completions/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ mod providers;
66
mod relevance;
77

88
pub use complete::*;
9+
pub use item::*;

crates/pg_lsp/src/session.rs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ use tower_lsp::lsp_types::{
1414
InlayHintKind, InlayHintLabel, MarkedString, Position, Range,
1515
};
1616

17-
use crate::{db_connection::DbConnection, utils::line_index_ext::LineIndexExt};
17+
use crate::{
18+
db_connection::DbConnection,
19+
utils::{line_index_ext::LineIndexExt, to_lsp_types::to_completion_kind},
20+
};
1821

1922
pub struct Session {
2023
db: RwLock<Option<DbConnection>>,
@@ -246,7 +249,29 @@ impl Session {
246249
schema: &schema_cache,
247250
})
248251
.into_iter()
249-
.map(|i| i.into())
252+
.map(|item| CompletionItem {
253+
label: item.label,
254+
label_details: Some(tower_lsp::lsp_types::CompletionItemLabelDetails {
255+
description: Some(item.description),
256+
detail: None,
257+
}),
258+
kind: Some(to_completion_kind(item.kind)),
259+
detail: None,
260+
documentation: None,
261+
deprecated: None,
262+
preselect: None,
263+
sort_text: None,
264+
filter_text: None,
265+
insert_text: None,
266+
insert_text_format: None,
267+
insert_text_mode: None,
268+
text_edit: None,
269+
additional_text_edits: None,
270+
commit_characters: None,
271+
data: None,
272+
tags: None,
273+
command: None,
274+
})
250275
.collect();
251276

252277
Some(CompletionList {

crates/pg_lsp/src/utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pub mod line_index_ext;
2+
pub mod to_lsp_types;
23
pub mod to_proto;
34

45
use std::path::PathBuf;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use tower_lsp::lsp_types;
2+
3+
pub fn to_completion_kind(
4+
kind: pg_completions::CompletionItemKind,
5+
) -> lsp_types::CompletionItemKind {
6+
match kind {
7+
pg_completions::CompletionItemKind::Table => lsp_types::CompletionItemKind::CLASS,
8+
}
9+
}

0 commit comments

Comments
 (0)