From 00ec7abc6cca09f5b7668c8f9c4a798dffbb68ae Mon Sep 17 00:00:00 2001 From: Kirigaya <1193466151@qq.com> Date: Sat, 7 Sep 2024 19:37:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/diagnostics.rs | 10 ------ src/main.rs | 5 +-- src/server.rs | 2 +- test/client/src/extension.ts | 70 +++++++++++++++++++----------------- 4 files changed, 42 insertions(+), 45 deletions(-) diff --git a/src/diagnostics.rs b/src/diagnostics.rs index dc1d870..73a32de 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -1,20 +1,10 @@ use crate::server::ProjectConfig; -#[cfg(feature = "slang")] -use path_clean::PathClean; use regex::Regex; use ropey::Rope; -#[cfg(feature = "slang")] -use std::env::current_dir; -#[cfg(feature = "slang")] -use std::path::Path; use std::path::PathBuf; use std::process::{Command, Stdio}; use tower_lsp::lsp_types::*; -#[cfg(feature = "slang")] -use veridian_slang::slang_compile; use walkdir::DirEntry; -#[cfg(feature = "slang")] -use walkdir::WalkDir; #[cfg(feature = "slang")] pub fn get_diagnostics( diff --git a/src/main.rs b/src/main.rs index 7a2a8e2..dc2676b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,7 @@ mod support; use server::Backend; #[derive(StructOpt, Debug)] -#[structopt(name = "veridian", about = "A SystemVerilog/Verilog Language Server")] +#[structopt(name = "Digtal LSP", about = "LSP for Digital IDE")] struct Opt {} #[tokio::main] @@ -25,7 +25,8 @@ async fn main() { let log_handle = flexi_logger::Logger::with(flexi_logger::LogSpecification::info()) .start() .unwrap(); - info!("starting veridian..."); + + info!("launch Digital LSP"); let stdin = tokio::io::stdin(); let stdout = tokio::io::stdout(); diff --git a/src/server.rs b/src/server.rs index e67d577..baf0f1c 100644 --- a/src/server.rs +++ b/src/server.rs @@ -296,7 +296,7 @@ impl LanguageServer for Backend { } async fn initialized(&self, _: InitializedParams) { self.client - .log_message(MessageType::INFO, "veridian initialized!") + .log_message(MessageType::INFO, "digital lsp initialized!") .await; } async fn shutdown(&self) -> Result<()> { diff --git a/test/client/src/extension.ts b/test/client/src/extension.ts index a51fff3..cd62e2b 100644 --- a/test/client/src/extension.ts +++ b/test/client/src/extension.ts @@ -4,12 +4,13 @@ * ------------------------------------------------------------------------------------------ */ import { workspace, ExtensionContext } from "vscode"; +import * as path from 'path'; import { - LanguageClient, - LanguageClientOptions, - ServerOptions, - Executable, + LanguageClient, + LanguageClientOptions, + ServerOptions, + Executable, } from "vscode-languageclient/node"; let client: LanguageClient; @@ -17,39 +18,44 @@ const workSpaceFolder = workspace.workspaceFolders?.[0]; let cwd: string = workSpaceFolder.uri.fsPath; export function activate(context: ExtensionContext) { - const run: Executable = { - command: context.asAbsolutePath('target/debug/digital-lsp.exe'), - // options: { cwd }, - }; + const lspServerPath = path.resolve( + context.extensionPath, '..', '..', 'target', 'debug', 'digital-lsp.exe' + ); + + console.log('launch lsp in ', lspServerPath); + const run: Executable = { + command: lspServerPath, + // options: { cwd }, + }; - // If the extension is launched in debug mode then the debug server options are used - // Otherwise the run options are used - let serverOptions: ServerOptions = { - run, - debug: run, - }; + // If the extension is launched in debug mode then the debug server options are used + // Otherwise the run options are used + let serverOptions: ServerOptions = { + run, + debug: run, + }; - // Options to control the language client - let clientOptions: LanguageClientOptions = { - // Register the server for plain text documents - documentSelector: [{ scheme: "file", language: "systemverilog" }], - }; + // Options to control the language client + let clientOptions: LanguageClientOptions = { + // Register the server for plain text documents + documentSelector: [{ scheme: "file", language: "systemverilog" }], + }; - // Create the language client and start the client. - client = new LanguageClient( - "Digital LSP", - "Digital LSP", - serverOptions, - clientOptions - ); + // Create the language client and start the client. + client = new LanguageClient( + "Digital LSP", + "Digital LSP", + serverOptions, + clientOptions + ); - // Start the client. This will also launch the server - client.start(); + // Start the client. This will also launch the server + client.start(); } export function deactivate(): Thenable | undefined { - if (!client) { - return undefined; - } - return client.stop(); + if (!client) { + return undefined; + } + return client.stop(); }