更新结构

This commit is contained in:
锦恢 2024-09-07 19:37:26 +08:00
parent 2b455a838d
commit 00ec7abc6c
4 changed files with 42 additions and 45 deletions

View File

@ -1,20 +1,10 @@
use crate::server::ProjectConfig; use crate::server::ProjectConfig;
#[cfg(feature = "slang")]
use path_clean::PathClean;
use regex::Regex; use regex::Regex;
use ropey::Rope; use ropey::Rope;
#[cfg(feature = "slang")]
use std::env::current_dir;
#[cfg(feature = "slang")]
use std::path::Path;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use tower_lsp::lsp_types::*; use tower_lsp::lsp_types::*;
#[cfg(feature = "slang")]
use veridian_slang::slang_compile;
use walkdir::DirEntry; use walkdir::DirEntry;
#[cfg(feature = "slang")]
use walkdir::WalkDir;
#[cfg(feature = "slang")] #[cfg(feature = "slang")]
pub fn get_diagnostics( pub fn get_diagnostics(

View File

@ -16,7 +16,7 @@ mod support;
use server::Backend; use server::Backend;
#[derive(StructOpt, Debug)] #[derive(StructOpt, Debug)]
#[structopt(name = "veridian", about = "A SystemVerilog/Verilog Language Server")] #[structopt(name = "Digtal LSP", about = "LSP for Digital IDE")]
struct Opt {} struct Opt {}
#[tokio::main] #[tokio::main]
@ -25,7 +25,8 @@ async fn main() {
let log_handle = flexi_logger::Logger::with(flexi_logger::LogSpecification::info()) let log_handle = flexi_logger::Logger::with(flexi_logger::LogSpecification::info())
.start() .start()
.unwrap(); .unwrap();
info!("starting veridian...");
info!("launch Digital LSP");
let stdin = tokio::io::stdin(); let stdin = tokio::io::stdin();
let stdout = tokio::io::stdout(); let stdout = tokio::io::stdout();

View File

@ -296,7 +296,7 @@ impl LanguageServer for Backend {
} }
async fn initialized(&self, _: InitializedParams) { async fn initialized(&self, _: InitializedParams) {
self.client self.client
.log_message(MessageType::INFO, "veridian initialized!") .log_message(MessageType::INFO, "digital lsp initialized!")
.await; .await;
} }
async fn shutdown(&self) -> Result<()> { async fn shutdown(&self) -> Result<()> {

View File

@ -4,12 +4,13 @@
* ------------------------------------------------------------------------------------------ */ * ------------------------------------------------------------------------------------------ */
import { workspace, ExtensionContext } from "vscode"; import { workspace, ExtensionContext } from "vscode";
import * as path from 'path';
import { import {
LanguageClient, LanguageClient,
LanguageClientOptions, LanguageClientOptions,
ServerOptions, ServerOptions,
Executable, Executable,
} from "vscode-languageclient/node"; } from "vscode-languageclient/node";
let client: LanguageClient; let client: LanguageClient;
@ -17,39 +18,44 @@ const workSpaceFolder = workspace.workspaceFolders?.[0];
let cwd: string = workSpaceFolder.uri.fsPath; let cwd: string = workSpaceFolder.uri.fsPath;
export function activate(context: ExtensionContext) { export function activate(context: ExtensionContext) {
const run: Executable = { const lspServerPath = path.resolve(
command: context.asAbsolutePath('target/debug/digital-lsp.exe'), context.extensionPath, '..', '..', 'target', 'debug', 'digital-lsp.exe'
// options: { cwd }, );
};
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 // If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used // Otherwise the run options are used
let serverOptions: ServerOptions = { let serverOptions: ServerOptions = {
run, run,
debug: run, debug: run,
}; };
// Options to control the language client // Options to control the language client
let clientOptions: LanguageClientOptions = { let clientOptions: LanguageClientOptions = {
// Register the server for plain text documents // Register the server for plain text documents
documentSelector: [{ scheme: "file", language: "systemverilog" }], documentSelector: [{ scheme: "file", language: "systemverilog" }],
}; };
// Create the language client and start the client. // Create the language client and start the client.
client = new LanguageClient( client = new LanguageClient(
"Digital LSP", "Digital LSP",
"Digital LSP", "Digital LSP",
serverOptions, serverOptions,
clientOptions clientOptions
); );
// Start the client. This will also launch the server // Start the client. This will also launch the server
client.start(); client.start();
} }
export function deactivate(): Thenable<void> | undefined { export function deactivate(): Thenable<void> | undefined {
if (!client) { if (!client) {
return undefined; return undefined;
} }
return client.stop(); return client.stop();
} }