initial commit

This commit is contained in:
Josh Thomas 2024-12-04 23:04:43 -06:00
commit 08fd1f27b9
6 changed files with 108 additions and 0 deletions

50
crates/djls/src/main.rs Normal file
View file

@ -0,0 +1,50 @@
use anyhow::Result;
use tower_lsp::jsonrpc::Result as LspResult;
use tower_lsp::lsp_types::*;
use tower_lsp::{Client, LanguageServer, LspService, Server};
#[derive(Debug)]
struct Backend {
client: Client,
}
#[tower_lsp::async_trait]
impl LanguageServer for Backend {
async fn initialize(&self, _params: InitializeParams) -> LspResult<InitializeResult> {
Ok(InitializeResult {
capabilities: ServerCapabilities {
text_document_sync: Some(TextDocumentSyncCapability::Kind(
TextDocumentSyncKind::INCREMENTAL,
)),
..Default::default()
},
offset_encoding: None,
server_info: Some(ServerInfo {
name: String::from("Django Language Server"),
version: Some(String::from("0.1.0")),
}),
})
}
async fn initialized(&self, _: InitializedParams) {
self.client
.log_message(MessageType::INFO, "server initialized!")
.await;
}
async fn shutdown(&self) -> LspResult<()> {
Ok(())
}
}
#[tokio::main]
async fn main() -> Result<()> {
let stdin = tokio::io::stdin();
let stdout = tokio::io::stdout();
let (service, socket) = LspService::build(|client| Backend { client }).finish();
Server::new(stdin, stdout, socket).serve(service).await;
Ok(())
}