Skip to content

Commit bd13fd4

Browse files
committed
feat: add launchj
1 parent 7562a1d commit bd13fd4

File tree

4 files changed

+75
-154
lines changed

4 files changed

+75
-154
lines changed

.DS_Store

0 Bytes
Binary file not shown.

launch.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
cargo wasi build
4+
5+
cp -f "/Users/skymac/workplace/lapce-vue/target/wasm32-wasi/debug/lapce-vue.rustc.wasm" "/Users/skymac/Library/Application Support/dev.lapce.Lapce-Stable/plugins/Lapce.lapce-vue/bin/"
6+
7+
cd /Users/skymac/workplace/fork/lapce/target/release/ && ./lapce

src/config.rs

Lines changed: 65 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ pub struct LanguageFeatures {
103103
#[serde(skip_serializing_if = "Option::is_none")]
104104
signatureHelp: Option<bool>,
105105
#[serde(skip_serializing_if = "Option::is_none")]
106-
completion: Option<Completion>,
106+
// completion: Option<Completion>,
107+
completion: Option<bool>,
107108
#[serde(skip_serializing_if = "Option::is_none")]
108109
documentHighlight: Option<bool>,
109110
#[serde(skip_serializing_if = "Option::is_none")]
@@ -112,23 +113,24 @@ pub struct LanguageFeatures {
112113
workspaceSymbol: Option<bool>,
113114
#[serde(skip_serializing_if = "Option::is_none")]
114115
codeLens: Option<CodeLens>,
116+
// codeLens: Option<bool>,
115117
#[serde(skip_serializing_if = "Option::is_none")]
116118
semanticTokens: Option<bool>,
117119
#[serde(skip_serializing_if = "Option::is_none")]
118120
codeAction: Option<bool>,
119121
#[serde(skip_serializing_if = "Option::is_none")]
120122
inlayHints: Option<bool>,
123+
/// 诊断
121124
#[serde(skip_serializing_if = "Option::is_none")]
122125
diagnostics: Option<bool>,
123126
#[serde(skip_serializing_if = "Option::is_none")]
124-
schemaRequestService: Option<SchemaRequestService>,
127+
// schemaRequestService: Option<SchemaRequestService>,
128+
schemaRequestService: Option<bool>,
125129
}
126130

127131
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
128132
#[serde(rename_all = "camelCase")]
129133
pub struct DocumentFeatures {
130-
#[serde(skip_serializing_if = "Option::is_none")]
131-
allowedLanguageIds: Option<Vec<String>>,
132134
#[serde(skip_serializing_if = "Option::is_none")]
133135
selectionRange: Option<bool>,
134136
#[serde(skip_serializing_if = "Option::is_none")]
@@ -143,36 +145,6 @@ pub struct DocumentFeatures {
143145
documentFormatting: Option<bool>,
144146
}
145147

146-
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
147-
#[serde(rename_all = "camelCase")]
148-
pub struct MainLanguageFeature {
149-
pub references: Option<bool>,
150-
pub implementation: Option<bool>,
151-
pub definition: Option<bool>,
152-
pub typeDefinition: Option<bool>,
153-
pub callHierarchy: Option<bool>,
154-
pub hover: Option<bool>,
155-
pub rename: Option<bool>,
156-
pub renameFileRefactoring: Option<bool>,
157-
pub signatureHelp: Option<bool>,
158-
pub codeAction: Option<bool>,
159-
pub workspaceSymbol: Option<bool>,
160-
pub completion: Completion,
161-
pub schemaRequestService: Option<SchemaRequestService>,
162-
}
163-
164-
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
165-
#[serde(rename_all = "camelCase")]
166-
struct SecondLanguageFeature {
167-
documentHighlight: Option<bool>,
168-
documentLink: Option<bool>,
169-
codeLens: Option<CodeLens>,
170-
semanticTokens: Option<bool>,
171-
inlayHints: Option<bool>,
172-
diagnostics: Option<bool>,
173-
schemaRequestService: Option<SchemaRequestService>,
174-
}
175-
176148
#[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
177149
#[serde(rename_all = "camelCase")]
178150
struct ServerInitializationOptions {
@@ -185,44 +157,50 @@ struct ServerInitializationOptions {
185157
}
186158
pub fn get_main_language_feature() -> LanguageFeatures {
187159
LanguageFeatures {
188-
references: None,
160+
references: Some(true),
189161
// 不存在
190-
implementation: None,
191-
definition: None,
192-
typeDefinition: None,
193-
callHierarchy: None,
162+
implementation: Some(true),
163+
definition: Some(true),
164+
typeDefinition: Some(true),
165+
callHierarchy: Some(true),
194166
hover: None,
195-
rename: None,
196-
renameFileRefactoring: None,
197-
signatureHelp: None,
198-
codeAction: None,
199-
workspaceSymbol: None,
200-
completion: Some(Completion {
201-
defaultTagNameCase: DefaultTagNameCase::both,
202-
defaultAttrNameCase: DefaultAttrNameCase::kebabCase,
203-
getDocumentNameCasesRequest: Some(false),
204-
getDocumentSelectionRequest: Some(false),
205-
ignoreTriggerCharacters: None,
167+
rename: Some(true),
168+
renameFileRefactoring: Some(true),
169+
signatureHelp: Some(true),
170+
codeAction: Some(true),
171+
workspaceSymbol: Some(true),
172+
// completion: Some(Completion {
173+
// defaultTagNameCase: DefaultTagNameCase::both,
174+
// defaultAttrNameCase: DefaultAttrNameCase::kebabCase,
175+
// getDocumentNameCasesRequest: Some(true),
176+
// getDocumentSelectionRequest: Some(true),
177+
// ignoreTriggerCharacters: None,
178+
// }),
179+
completion: Some(true),
180+
schemaRequestService: Some(true),
181+
documentHighlight: Some(true),
182+
documentLink: Some(true),
183+
codeLens: Some(CodeLens {
184+
showReferencesNotification: Some(true),
206185
}),
207-
schemaRequestService: None,
208-
documentHighlight: None,
209-
documentLink: None,
210-
codeLens: None,
211-
semanticTokens: None,
212-
inlayHints: None,
213-
diagnostics: None,
186+
// 语义标记
187+
semanticTokens: Some(false),
188+
inlayHints: Some(true),
189+
diagnostics: Some(true),
214190
}
215191
}
216192

217193
pub fn get_second_language_feature() -> LanguageFeatures {
218194
LanguageFeatures {
219-
documentHighlight: None,
220-
documentLink: None,
221-
codeLens: None,
222-
semanticTokens: None,
195+
documentHighlight: Some(true),
196+
documentLink: Some(true),
197+
codeLens: Some(CodeLens {
198+
showReferencesNotification: Some(true),
199+
}),
200+
semanticTokens: Some(true),
223201
// 不存在
224-
inlayHints: None,
225-
diagnostics: None,
202+
inlayHints: Some(true),
203+
diagnostics: Some(true),
226204
schemaRequestService: None,
227205
references: None,
228206
implementation: None,
@@ -241,21 +219,27 @@ pub fn get_second_language_feature() -> LanguageFeatures {
241219

242220
pub fn get_doc_feature() -> DocumentFeatures {
243221
DocumentFeatures {
244-
// allowedLanguageIds: vec![
222+
// allowedLanguageIds: Some(vec![
245223
// "vue".to_owned(),
246224
// "javascript".to_owned(),
247225
// "typescript".to_owned(),
248226
// "javascriptreact".to_owned(),
249227
// "typescriptreact".to_owned(),
250-
// ],
251-
allowedLanguageIds: None,
252-
selectionRange: None,
253-
foldingRange: None,
254-
linkedEditingRange: None,
255-
documentSymbol: None,
256-
documentColor: None,
257-
// 没有格式胡
258-
documentFormatting: None,
228+
// ]),
229+
// allowedLanguageIds: Some(),
230+
// selectionRange: Some(true),
231+
// foldingRange: Some(true),
232+
// linkedEditingRange: Some(true),
233+
// documentSymbol: Some(true),
234+
// documentColor: Some(true),
235+
// // 没有格式胡
236+
// documentFormatting: Some(true),
237+
selectionRange: Some(true),
238+
foldingRange: Some(true),
239+
linkedEditingRange: Some(true),
240+
documentSymbol: Some(true),
241+
documentColor: Some(true),
242+
documentFormatting: Some(true),
259243
}
260244
}
261245

@@ -280,15 +264,19 @@ pub fn get_initialization_options(name: LanguageOptionEnum) -> Option<Value> {
280264
let initialization_options = ServerInitializationOptions {
281265
// textDocumentSync: TextDocumentSyncKind::Incremental,
282266
typescript: TypescriptPath {
283-
// serverPath: "/Users/skymac/node_modules/typescript/lib/tsserverlibrary.js".to_owned(),
284-
serverPath: "/Users/xiaoxin/Library/pnpm/global/5/.pnpm/typescript@4.7.4/node_modules/typescript/lib/tsserverlibrary.js".to_owned(),
267+
serverPath:
268+
"/Users/skymac/Library/pnpm/global/5/.pnpm/typescript@4.8.4/node_modules/typescript/lib/tsserverlibrary.js"
269+
.to_owned(),
270+
// serverPath: "/Users/xiaoxin/Library/pnpm/global/5/.pnpm/typescript@4.7.4/node_modules/typescript/lib/tsserverlibrary.js".to_owned(),
285271
localizedPath: None, // localizedPath: Some(
286272
// "/Users/skymac/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json"
287273
// .to_owned(),
288274
// ),
289275
},
290-
languageFeatures: language_features,
291-
documentFeatures: document_features,
276+
languageFeatures: Some(get_main_language_feature()),
277+
documentFeatures: Some(get_doc_feature()),
292278
};
293279
serde_json::to_value(&initialization_options).ok()
294280
}
281+
282+
fn find_volar_path(root_path: Option<String>) {}

src/main.rs

Lines changed: 3 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,6 @@ fn initialize(params: InitializeParams) -> Result<()> {
2424
// let doc_language_feature_option =
2525
// config::get_initialization_options(LanguageOptionEnum::document_feature);
2626

27-
// PLUGIN_RPC.stderr(&format!(
28-
// "lapce_params:{:#?}",
29-
// params.initialization_options
30-
// ));
31-
// PLUGIN_RPC.stderr(&format!(
32-
// "main_language_feature_option:{:#?}",
33-
// main_language_feature_option
34-
// ));
35-
// PLUGIN_RPC.stderr(&format!(
36-
// "second_language_feature_option:{:#?}",
37-
// second_language_feature_option
38-
// ));
39-
// PLUGIN_RPC.stderr(&format!(
40-
// "doc_language_feature_option:{:#?}",
41-
// doc_language_feature_option
42-
// ));
43-
4427
let document_selector: DocumentSelector = vec![DocumentFilter {
4528
// lsp language id
4629
language: Some(String::from("vue")),
@@ -56,73 +39,16 @@ fn initialize(params: InitializeParams) -> Result<()> {
5639
"--inspect".to_string(),
5740
];
5841

59-
// Check for user specified LSP server path
60-
// ```
61-
// [lapce-plugin-name.lsp]
62-
// serverPath = "[path or filename]"
63-
// serverArgs = ["--arg1", "--arg2"]
64-
// ```
65-
if let Some(options) = params.initialization_options.as_ref() {
66-
if let Some(lsp) = options.get("lsp") {
67-
if let Some(args) = lsp.get("serverArgs") {
68-
if let Some(args) = args.as_array() {
69-
if !args.is_empty() {
70-
server_args = vec![];
71-
}
72-
for arg in args {
73-
if let Some(arg) = arg.as_str() {
74-
server_args.push(arg.to_string());
75-
}
76-
}
77-
}
78-
}
79-
80-
if let Some(server_path) = lsp.get("serverPath") {
81-
if let Some(server_path) = server_path.as_str() {
82-
if !server_path.is_empty() {
83-
let server_uri = Url::parse(&format!("urn:{}", server_path))?;
84-
PLUGIN_RPC.start_lsp(
85-
server_uri,
86-
server_args,
87-
document_selector,
88-
params.initialization_options,
89-
);
90-
return Ok(());
91-
}
92-
}
93-
}
94-
}
95-
}
96-
97-
// Download URL
98-
// let _ = format!("https://github.com/<name>/<project>/releases/download/<version>/{filename}");
99-
100-
// see lapce_plugin::Http for available API to download files
101-
102-
// let _ = match VoltEnvironment::operating_system().as_deref() {
103-
// Ok("windows") => {
104-
// format!("{}.exe", "[filename]")
105-
// }
106-
// _ => "[filename]".to_string(),
107-
// };
42+
let server_path =
43+
Url::parse("file:///Users/skymac/workplace/volar/packages/vue-language-server/bin/run.sh")?;
10844

109-
// Plugin working directory
110-
// let volt_uri = VoltEnvironment::uri()?;
111-
let server_path = Url::parse(
112-
"file:///Users/xiaoxin/workspace/volar/packages/vue-language-server/bin/run.sh",
113-
)?;
114-
115-
// if you want to use server from PATH
116-
// let server_path = Url::parse(&format!("urn:{filename}"))?;
117-
118-
// Available language IDs
119-
// https://github.com/lapce/lapce/blob/HEAD/lapce-proxy/src/buffer.rs#L173
12045
PLUGIN_RPC.start_lsp(
12146
server_path.clone(),
12247
server_args.clone(),
12348
document_selector.clone(),
12449
main_language_feature_option,
12550
);
51+
12652
// PLUGIN_RPC.start_lsp(
12753
// server_path.clone(),
12854
// server_args.clone(),

0 commit comments

Comments
 (0)