mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-09-12 05:16:46 +00:00
add djls-python crate (#1)
* add djls-pyenv crate * add implementation * remove newline * rename field * rename crate
This commit is contained in:
parent
17b7974b7d
commit
931c0bc9fb
7 changed files with 359 additions and 1 deletions
|
@ -3,9 +3,12 @@ use tower_lsp::jsonrpc::Result as LspResult;
|
|||
use tower_lsp::lsp_types::*;
|
||||
use tower_lsp::{Client, LanguageServer, LspService, Server};
|
||||
|
||||
use djls_python::PythonEnvironment;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Backend {
|
||||
client: Client,
|
||||
python: PythonEnvironment,
|
||||
}
|
||||
|
||||
#[tower_lsp::async_trait]
|
||||
|
@ -30,6 +33,10 @@ impl LanguageServer for Backend {
|
|||
self.client
|
||||
.log_message(MessageType::INFO, "server initialized!")
|
||||
.await;
|
||||
|
||||
self.client
|
||||
.log_message(MessageType::INFO, format!("\n{}", self.python))
|
||||
.await;
|
||||
}
|
||||
|
||||
async fn shutdown(&self) -> LspResult<()> {
|
||||
|
@ -39,10 +46,12 @@ impl LanguageServer for Backend {
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let python = PythonEnvironment::initialize()?;
|
||||
|
||||
let stdin = tokio::io::stdin();
|
||||
let stdout = tokio::io::stdout();
|
||||
|
||||
let (service, socket) = LspService::build(|client| Backend { client }).finish();
|
||||
let (service, socket) = LspService::build(|client| Backend { client, python }).finish();
|
||||
|
||||
Server::new(stdin, stdout, socket).serve(service).await;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue