mirror of
https://github.com/slint-ui/slint.git
synced 2025-12-11 20:09:37 +00:00
lsp: Use InitializeResult from lsp-types
Make the previous patch typesafe by enabling the "proposed" feature in the `lsp-types` crate, so that the `InitializeResult` has the `offsetEncoding` field. Fix the fallout of this change.
This commit is contained in:
parent
051cf83482
commit
ad33c257cf
3 changed files with 16 additions and 12 deletions
|
|
@ -57,7 +57,7 @@ i-slint-compiler = { version = "=0.2.6", path = "../../internal/compiler"}
|
||||||
clap = { version = "3.2", features = ["derive", "wrap_help"] }
|
clap = { version = "3.2", features = ["derive", "wrap_help"] }
|
||||||
dunce = "1.0.1"
|
dunce = "1.0.1"
|
||||||
euclid = "0.22"
|
euclid = "0.22"
|
||||||
lsp-types = "0.93.0"
|
lsp-types = { version = "0.93.0", features = ["proposed"] }
|
||||||
serde = "1.0.118"
|
serde = "1.0.118"
|
||||||
serde_json = "1.0.60"
|
serde_json = "1.0.60"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,10 @@ mod util;
|
||||||
|
|
||||||
use i_slint_compiler::CompilerConfiguration;
|
use i_slint_compiler::CompilerConfiguration;
|
||||||
use lsp_types::notification::{DidChangeTextDocument, DidOpenTextDocument, Notification};
|
use lsp_types::notification::{DidChangeTextDocument, DidOpenTextDocument, Notification};
|
||||||
use lsp_types::{DidChangeTextDocumentParams, DidOpenTextDocumentParams, InitializeParams};
|
use lsp_types::{
|
||||||
|
DidChangeTextDocumentParams, DidOpenTextDocumentParams, InitializeParams, InitializeResult,
|
||||||
|
ServerInfo,
|
||||||
|
};
|
||||||
use server_loop::*;
|
use server_loop::*;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
@ -128,18 +131,18 @@ fn main() {
|
||||||
pub fn run_lsp_server() -> Result<(), Error> {
|
pub fn run_lsp_server() -> Result<(), Error> {
|
||||||
let (connection, io_threads) = Connection::stdio();
|
let (connection, io_threads) = Connection::stdio();
|
||||||
let (id, params) = connection.initialize_start()?;
|
let (id, params) = connection.initialize_start()?;
|
||||||
let server_capabilities = server_loop::server_capabilities();
|
|
||||||
|
|
||||||
let initialize_data = serde_json::json!({
|
let initialization_reply = InitializeResult {
|
||||||
"capabilities": server_capabilities,
|
capabilities: server_loop::server_capabilities(),
|
||||||
"offsetEncoding": "utf-8", // We support utf-8 *only*
|
|
||||||
"serverInfo": {
|
|
||||||
"name": "slint-ls",
|
|
||||||
"version": String::from(env!("CARGO_PKG_VERSION")),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
connection.initialize_finish(id, initialize_data)?;
|
server_info: Some(ServerInfo {
|
||||||
|
name: "slint-ls".into(),
|
||||||
|
version: Some(env!("CARGO_PKG_VERSION").to_string()),
|
||||||
|
}),
|
||||||
|
offset_encoding: Some("utf-8".to_string()),
|
||||||
|
};
|
||||||
|
|
||||||
|
connection.initialize_finish(id, serde_json::to_value(initialization_reply)?)?;
|
||||||
|
|
||||||
main_loop(&connection, params)?;
|
main_loop(&connection, params)?;
|
||||||
io_threads.join()?;
|
io_threads.join()?;
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,7 @@ pub fn server_capabilities() -> ServerCapabilities {
|
||||||
trigger_characters: Some(vec![".".to_owned()]),
|
trigger_characters: Some(vec![".".to_owned()]),
|
||||||
work_done_progress_options: WorkDoneProgressOptions::default(),
|
work_done_progress_options: WorkDoneProgressOptions::default(),
|
||||||
all_commit_characters: None,
|
all_commit_characters: None,
|
||||||
|
completion_item: None,
|
||||||
}),
|
}),
|
||||||
definition_provider: Some(OneOf::Left(true)),
|
definition_provider: Some(OneOf::Left(true)),
|
||||||
text_document_sync: Some(TextDocumentSyncCapability::Kind(
|
text_document_sync: Some(TextDocumentSyncCapability::Kind(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue