update template

This commit is contained in:
panekj 2022-10-25 17:40:20 +02:00
parent 438bc1b8a0
commit 129e9c2d07
3 changed files with 35 additions and 7 deletions

View file

@ -5,15 +5,23 @@ version = "0.0.0"
resolver = "2"
[target.'cfg(target_os = "wasi")'.dependencies]
# plugin deps
# for unpacking zip
# zip = { version = "0.6", default-features = false, features = ["deflate"] }
# for unpacking tar/gz
# flate2 = { version = "1.0" }
# default deps for all lapce plugins
anyhow = "1.0"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
# lapce-plugin = { git = "https://github.com/lapce/lapce-plugin-rust.git", branch = "volt" }
lapce-plugin = { git = "https://github.com/panekj/lapce-plugin-rust.git", branch = "volt" }
lapce-plugin = { git = "https://github.com/lapce/lapce-plugin-rust.git" }
# lapce-plugin = { git = "https://github.com/panekj/lapce-plugin-rust.git", branch = "volt" }
[profile.release]
opt-level = 3
lto = true
codegen-units = 1
strip = true

View file

@ -1,7 +1,7 @@
use anyhow::Result;
use lapce_plugin::{
psp_types::{
lsp_types::{request::Initialize, DocumentFilter, DocumentSelector, InitializeParams, Url},
lsp_types::{request::Initialize, DocumentFilter, DocumentSelector, InitializeParams, Url, MessageType},
Request,
},
register_plugin, LapcePlugin, VoltEnvironment, PLUGIN_RPC,
@ -91,15 +91,15 @@ fn initialize(params: InitializeParams) -> Result<()> {
// Plugin working directory
let volt_uri = VoltEnvironment::uri()?;
let server_path = Url::parse(&volt_uri)?.join("[filename]")?;
let server_uri = Url::parse(&volt_uri)?.join("[filename]")?;
// if you want to use server from PATH
// let server_path = Url::parse(&format!("urn:{filename}"))?;
// let server_uri = Url::parse(&format!("urn:{filename}"))?;
// Available language IDs
// https://github.com/lapce/lapce/blob/HEAD/lapce-proxy/src/buffer.rs#L173
PLUGIN_RPC.start_lsp(
server_path,
server_uri,
server_args,
document_selector,
params.initialization_options,
@ -115,7 +115,7 @@ fn handle_request(&mut self, _id: u64, method: String, params: Value) {
Initialize::METHOD => {
let params: InitializeParams = serde_json::from_value(params).unwrap();
if let Err(e) = initialize(params) {
PLUGIN_RPC.stderr(&format!("plugin returned with error: {e}"))
PLUGIN_RPC.window_show_message(MessageType::ERROR, format!("plugin returned with error: {e}"))
}
}
_ => {}

View file

@ -8,3 +8,23 @@ wasm = "bin/<plugin-name>.wasm"
[activation]
language = []
workspace-contains = []
[config."volt.serverPath"]
default = ""
description = "Path to custom LSP executable"
# [config."volt.serverArgs"]
# default = []
# description = ""
# [config."lspSettingArray"]
# default = []
# description = ""
# [config."lspSettingString"]
# default = ""
# description = ""
# [config."lspSettingBool"]
# default = false
# description = ""