#[cfg(feature = "dhat-heap")]
#[global_allocator]
static ALLOC: dhat::Alloc = dhat::Alloc;
use clap::Parser;
use eyre::Result;
use solidity_language_server::lsp::ForgeLsp;
use tower_lsp::{LspService, Server};
#[derive(Clone, Debug, clap::ValueEnum)]
pub enum CompletionMode {
Full,
Fast,
}
#[derive(Clone, Debug, Parser)]
#[command(
version = env!("LONG_VERSION"),
about = "solidity-language-server, a Solidity LSP powered by foundry"
)]
pub struct LspArgs {
#[arg(long)]
pub stdio: bool,
#[arg(long)]
pub use_solar: bool,
#[arg(long)]
pub use_forge: bool,
#[arg(long, value_enum, hide = true)]
pub completion_mode: Option<CompletionMode>,
}
impl LspArgs {
pub async fn run(self) -> Result<()> {
let stdin = tokio::io::stdin();
let stdout = tokio::io::stdout();
let use_solc = !self.use_forge;
let (service, socket) =
LspService::new(|client| ForgeLsp::new(client, self.use_solar, use_solc));
Server::new(stdin, stdout, socket).serve(service).await;
Ok(())
}
}
#[tokio::main]
async fn main() -> eyre::Result<()> {
#[cfg(feature = "dhat-heap")]
let _profiler = dhat::Profiler::new_heap();
let args = LspArgs::parse();
args.run().await
}