mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-09-29 05:15:15 +00:00
add initial autocomplete for installed templatetags (#46)
This commit is contained in:
parent
5eb8a775e4
commit
c16635b1c0
8 changed files with 359 additions and 58 deletions
|
@ -6,6 +6,7 @@ mod tasks;
|
|||
use crate::notifier::TowerLspNotifier;
|
||||
use crate::server::{DjangoLanguageServer, LspNotification, LspRequest};
|
||||
use anyhow::Result;
|
||||
use server::LspResponse;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
use tower_lsp::jsonrpc::Result as LspResult;
|
||||
|
@ -19,11 +20,16 @@ struct TowerLspBackend {
|
|||
#[tower_lsp::async_trait]
|
||||
impl LanguageServer for TowerLspBackend {
|
||||
async fn initialize(&self, params: InitializeParams) -> LspResult<InitializeResult> {
|
||||
self.server
|
||||
.read()
|
||||
match self
|
||||
.server
|
||||
.write()
|
||||
.await
|
||||
.handle_request(LspRequest::Initialize(params))
|
||||
.map_err(|_| tower_lsp::jsonrpc::Error::internal_error())
|
||||
.map_err(|_| tower_lsp::jsonrpc::Error::internal_error())?
|
||||
{
|
||||
LspResponse::Initialize(result) => Ok(result),
|
||||
_ => Err(tower_lsp::jsonrpc::Error::internal_error()),
|
||||
}
|
||||
}
|
||||
|
||||
async fn initialized(&self, params: InitializedParams) {
|
||||
|
@ -77,6 +83,19 @@ impl LanguageServer for TowerLspBackend {
|
|||
eprintln!("Error handling document close: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
async fn completion(&self, params: CompletionParams) -> LspResult<Option<CompletionResponse>> {
|
||||
match self
|
||||
.server
|
||||
.write()
|
||||
.await
|
||||
.handle_request(LspRequest::Completion(params))
|
||||
.map_err(|_| tower_lsp::jsonrpc::Error::internal_error())?
|
||||
{
|
||||
LspResponse::Completion(result) => Ok(result),
|
||||
_ => Err(tower_lsp::jsonrpc::Error::internal_error()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn serve() -> Result<()> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue