-
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
Showing
10 changed files
with
216 additions
and
26 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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<div align="center"> | ||
|
||
# Blaze | ||
# Kuiper | ||
|
||
[![Builds](https://img.shields.io/github/actions/workflow/status/Redhawk18/code-editor/build.yml)](https:/Redhawk18/code-editor/actions/workflows/build.yml) | ||
[![License](https://img.shields.io/github/license/Redhawk18/code-editor)](https:/Redhawk18/code-editor/blob/main/LICENSE) | ||
[![Builds](https://img.shields.io/github/actions/workflow/status/Redhawk18/kuiper/build.yml)](https:/Redhawk18/kuiper/actions/workflows/build.yml) | ||
[![License](https://img.shields.io/github/license/Redhawk18/kuiper)](https:/Redhawk18/kuiper/blob/main/LICENSE) | ||
|
||
A blazing fast [Integrated Development Environment](https://en.wikipedia.org/wiki/Integrated_development_environment), meant to give power back to developers. | ||
|
||
|
@@ -21,13 +21,13 @@ Currently to install | |
1. Clone the repository | ||
|
||
``` | ||
git clone [email protected]:Redhawk18/blaze.git | ||
git clone [email protected]:Redhawk18/kuiper.git | ||
``` | ||
|
||
2. Compile and install the program | ||
|
||
``` | ||
cargo install --path blaze | ||
cargo install --path kuiper | ||
``` | ||
|
||
3. Add given path to your `$PATH` | ||
|
@@ -40,20 +40,20 @@ If youre operating system needs additional packages please create a pull request | |
<summary>OpenSuse</summary> | ||
|
||
``` | ||
sudo zypper install atkmm-devel gdk-pixbuf-devel gdk-pixbuf-xlib-devel glib2-devel gtk3-devel harfbuzz-devel pkg-config rustup | ||
sudo zypper install atkmm-devel pkg-config rustup | ||
``` | ||
</details> | ||
|
||
1. Clone the repository | ||
|
||
``` | ||
git clone [email protected]:Redhawk18/blaze.git | ||
git clone [email protected]:Redhawk18/kuiper.git | ||
``` | ||
|
||
2. Go into the repository | ||
|
||
``` | ||
cd blaze | ||
cd kuiper | ||
``` | ||
|
||
3. Compiling | ||
|
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
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,16 @@ | ||
[package] | ||
name = "kuiper_lsp" | ||
version.workspace = true | ||
edition.workspace = true | ||
authors.workspace = true | ||
license.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
async-lsp.workspace = true | ||
iced.workspace = true | ||
log.workspace = true | ||
lsp-types.workspace = true | ||
snafu.workspace = true | ||
tokio.workspace = true |
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,156 @@ | ||
use async_lsp::{ | ||
concurrency::ConcurrencyLayer, panic::CatchUnwindLayer, router::Router, tracing::TracingLayer, | ||
LanguageClient, ResponseError, | ||
}; | ||
use log::{info, trace, Level}; | ||
use lsp_types::{ | ||
notification::{Progress, PublishDiagnostics, ShowMessage}, | ||
ClientCapabilities, HoverContents, HoverParams, InitializeParams, MarkupContent, | ||
NumberOrString, Position, ProgressParamsValue, TextDocumentIdentifier, | ||
TextDocumentPositionParams, Url, WindowClientCapabilities, WorkDoneProgress, | ||
WorkDoneProgressParams, | ||
}; | ||
use std::{ops::ControlFlow, path::Path, process::Stdio}; | ||
use tokio::sync::oneshot; | ||
|
||
const TEST_ROOT: &str = "."; | ||
|
||
struct ClientState { | ||
indexed_tx: Option<oneshot::Sender<()>>, | ||
} | ||
|
||
struct Stop; | ||
|
||
impl LanguageClient for ClientState { | ||
type Error = ResponseError; | ||
type NotifyResult = ControlFlow<async_lsp::Result<()>>; | ||
} | ||
|
||
pub async fn start_lsp() { | ||
let root_dir = Path::new(TEST_ROOT) | ||
.canonicalize() | ||
.expect("test root should be valid"); | ||
|
||
let (indexed_tx, indexed_rx) = oneshot::channel(); | ||
|
||
let (mainloop, mut server) = async_lsp::MainLoop::new_client(|_server| { | ||
let mut router = Router::new(ClientState { | ||
indexed_tx: Some(indexed_tx), | ||
}); | ||
router | ||
.notification::<Progress>(|this, prog| { | ||
trace!("{:#?} {:#?}", prog.token, prog.value); | ||
if matches!(prog.token, NumberOrString::String(s) if s == "rustAnalyzer/Indexing") | ||
&& matches!( | ||
prog.value, | ||
ProgressParamsValue::WorkDone(WorkDoneProgress::End(_)) | ||
) | ||
{ | ||
// Sometimes rust-analyzer auto-index multiple times? | ||
if let Some(tx) = this.indexed_tx.take() { | ||
let _: Result<_, _> = tx.send(()); | ||
} | ||
} | ||
ControlFlow::Continue(()) | ||
}) | ||
.notification::<PublishDiagnostics>(|_, _| ControlFlow::Continue(())) | ||
.notification::<ShowMessage>(|_, params| { | ||
trace!("Message {:?}: {}", params.typ, params.message); | ||
ControlFlow::Continue(()) | ||
}) | ||
.event(|_, _: Stop| ControlFlow::Break(Ok(()))); | ||
|
||
ServiceBuilder::new() | ||
.layer(TracingLayer::default()) | ||
.layer(CatchUnwindLayer::default()) | ||
.layer(ConcurrencyLayer::default()) | ||
.service(router) | ||
}); | ||
|
||
tracing_subscriber::fmt() | ||
.with_max_level(Level::Info) | ||
.with_ansi(false) | ||
.with_writer(std::io::stdout) | ||
.init(); | ||
|
||
let child = async_process::Command::new("rust-analyzer") | ||
.current_dir(&root_dir) | ||
.stdin(Stdio::piped()) | ||
.stdout(Stdio::piped()) | ||
.stderr(Stdio::inherit()) | ||
.kill_on_drop(true) | ||
.spawn() | ||
.expect("Failed run rust-analyzer"); | ||
let stdout = child.stdout.unwrap(); | ||
let stdin = child.stdin.unwrap(); | ||
|
||
let mainloop_fut = tokio::spawn(async move { | ||
mainloop.run_buffered(stdout, stdin).await.unwrap(); | ||
}); | ||
|
||
// Initialize. | ||
let root_uri = Url::from_file_path(&root_dir).unwrap(); | ||
let init_ret = server | ||
.initialize(InitializeParams { | ||
root_uri: Some(root_uri), | ||
capabilities: ClientCapabilities { | ||
window: Some(WindowClientCapabilities { | ||
work_done_progress: Some(true), | ||
..WindowClientCapabilities::default() | ||
}), | ||
..ClientCapabilities::default() | ||
}, | ||
..InitializeParams::default() | ||
}) | ||
.await | ||
.unwrap(); | ||
info!("Initialized: {init_ret:?}"); | ||
server.initialized(InitializedParams {}).unwrap(); | ||
|
||
// Synchronize documents. | ||
let file_uri = Url::from_file_path(root_dir.join("src/lib.rs")).unwrap(); | ||
let text = "fn func() { let var = 1; }"; | ||
server | ||
.did_open(DidOpenTextDocumentParams { | ||
text_document: TextDocumentItem { | ||
uri: file_uri.clone(), | ||
language_id: "rust".into(), | ||
version: 0, | ||
text: text.into(), | ||
}, | ||
}) | ||
.unwrap(); | ||
|
||
// Wait until indexed. | ||
indexed_rx.await.unwrap(); | ||
|
||
// Query. | ||
let var_pos = text.find("var").unwrap(); | ||
let hover = server | ||
.hover(HoverParams { | ||
text_document_position_params: TextDocumentPositionParams { | ||
text_document: TextDocumentIdentifier { uri: file_uri }, | ||
position: Position::new(0, var_pos as _), | ||
}, | ||
work_done_progress_params: WorkDoneProgressParams::default(), | ||
}) | ||
.await | ||
.unwrap() | ||
.unwrap(); | ||
info!("Hover result: {hover:?}"); | ||
assert!( | ||
matches!( | ||
hover.contents, | ||
HoverContents::Markup(MarkupContent { value, .. }) | ||
if value.contains("let var: i32") | ||
), | ||
"should show the type of `var`", | ||
); | ||
|
||
// Shutdown. | ||
server.shutdown(()).await.unwrap(); | ||
server.exit(()).unwrap(); | ||
|
||
server.emit(Stop).unwrap(); | ||
mainloop_fut.await.unwrap(); | ||
} |
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,2 @@ | ||
mod client; | ||
mod subscription; |
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,7 @@ | ||
use iced::{subscription, Subscription}; | ||
|
||
pub enum Event {} | ||
|
||
pub fn connect() -> Subscription<Event> { | ||
todo!() | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use blaze_gui::start_gui; | ||
use kuiper_gui::start_gui; | ||
|
||
fn main() { | ||
pretty_env_logger::init(); | ||
|