Skip to content

Commit

Permalink
reworked lsp arch
Browse files Browse the repository at this point in the history
  • Loading branch information
Redhawk18 committed Jan 21, 2025
1 parent e50a924 commit 32602ce
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 5 deletions.
8 changes: 6 additions & 2 deletions gui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use widgets::{menu_bar, pane_grid};

use kuiper_lsp::{
client::LSPClient,
commands::{initialize, shutdown, synchronize},
commands::{did_open::did_open, initialize, shutdown},
};

use iced::{
Expand Down Expand Up @@ -86,7 +86,11 @@ impl Kuiper {
self.lsp_client = Some(LSPClient::new(server));
}
LanguageServer::Shutdown() => todo!(),
LanguageServer::Syncronize(server) => log::warn!("{:#?}", server),
LanguageServer::Syncronize(sync) => match sync {
messages::Syncronize::DidClose => todo!(),
messages::Syncronize::DidChange => todo!(),
messages::Syncronize::DidOpen => did_open(path, server),
},
},
Message::Widgets(widget) => match widget {
Widgets::Button(button) => match button {
Expand Down
9 changes: 8 additions & 1 deletion gui/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ pub enum Message {
pub enum LanguageServer {
Initalize(Result<ServerSocket, kuiper_lsp::Error>),
Shutdown(),
Syncronize(Result<ServerSocket, kuiper_lsp::Error>),
Syncronize(Syncronize),
}

#[derive(Debug)]
pub enum Syncronize {
DidClose,
DidChange,
DidOpen(PathBuf, ServerSocket),
}

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion lsp/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ mod synchronize;

pub use initialize::initialize;
pub use shutdown::shutdown;
pub use synchronize::synchronize;
pub use synchronize::*;
12 changes: 12 additions & 0 deletions lsp/src/commands/synchronize/did_change.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use crate::LspSnafu;

use async_lsp::{
lsp_types::{DidOpenTextDocumentParams, TextDocumentItem, Url},
LanguageServer, ServerSocket,
};
use snafu::ResultExt;
use std::path::PathBuf;

pub async fn did_change() -> Result<ServerSocket, crate::Error> {
todo!()
}
12 changes: 12 additions & 0 deletions lsp/src/commands/synchronize/did_close.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use crate::LspSnafu;

use async_lsp::{
lsp_types::{DidOpenTextDocumentParams, TextDocumentItem, Url},
LanguageServer, ServerSocket,
};
use snafu::ResultExt;
use std::path::PathBuf;

pub async fn did_close() -> Result<ServerSocket, crate::Error> {
todo!()
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use async_lsp::{
use snafu::ResultExt;
use std::path::PathBuf;

pub async fn synchronize(
pub async fn did_open(
path: PathBuf,
mut server: ServerSocket,
) -> Result<ServerSocket, crate::Error> {
Expand Down
3 changes: 3 additions & 0 deletions lsp/src/commands/synchronize/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod did_change;
pub mod did_close;
pub mod did_open;

0 comments on commit 32602ce

Please sign in to comment.