lsp-bridge-enable-log 选项打开, 发一下完整的日志给我看一下可以吗?
我重装系统, 估计是代理没配置好, volar 安装了半天还没有装好。
lsp-bridge-enable-log 选项打开, 发一下完整的日志给我看一下可以吗?
我重装系统, 估计是代理没配置好, volar 安装了半天还没有装好。
Eval in Emacs: (lsp-bridge--first-start '52705)
Eval in Emacs: (message '"[LSP-Bridge] found language server: /Users/liuyinz/.local/share/mise/installs/node/22.9.0/bin/vue-language-server")
Start lsp server (volar) for /Users/liuyinz/.config/emacs
Eval in Emacs: (message '"[LSP-Bridge] Active project 'emacs', enjoy hacking!")
Handlers: [<class 'core.handler.completion.Completion'>,
<class 'core.handler.completion_item.CompletionItem'>,
<class 'core.handler.find_define.FindDefine'>,
<class 'core.handler.find_type_define.FindTypeDefine'>,
<class 'core.handler.find_implementation.FindImplementation'>,
<class 'core.handler.find_references.FindReferences'>,
<class 'core.handler.peek.PeekFindDefine'>,
<class 'core.handler.peek.PeekFindReferences'>,
<class 'core.handler.hover.Hover'>,
<class 'core.handler.signature_help.SignatureHelp'>,
<class 'core.handler.prepare_rename.PrepareRename'>,
<class 'core.handler.rename.Rename'>,
<class 'core.handler.jdt_uri_resolver.JDTUriResolver'>,
<class 'core.handler.deno_uri_resolver.DenoUriResolver'>,
<class 'core.handler.csharp_uri_resolver.CSharpUriResolver'>,
<class 'core.handler.code_action.CodeAction'>,
<class 'core.handler.formatting.Formatting'>,
<class 'core.handler.range_formatting.RangeFormatting'>,
<class 'core.handler.execute_command.ExecuteCommand'>,
<class 'core.handler.workspace_symbol.WorkspaceSymbol'>,
<class 'core.handler.completion_workspace_symbol.CompletionWorkspaceSymbol'>,
<class 'core.handler.call_hierarchy.PrepareCallHierarchy'>,
<class 'core.handler.call_hierarchy.CallHierarchy'>,
<class 'core.handler.call_hierarchy.PrepareCallHierarchyIncomingCalls'>,
<class 'core.handler.call_hierarchy.PrepareCallHierarchyOutgoingCalls'>,
<class 'core.handler.call_hierarchy.CallHierarchyIncomingCalls'>,
<class 'core.handler.call_hierarchy.CallHierarchyOutgoingCalls'>,
<class 'core.handler.document_symbol.DocumentSymbol'>,
<class 'core.handler.imenu.IMenu'>,
<class 'core.handler.jdtls.jdtls_list_overridable_methods.JdtlsListOverridableMethods'>,
<class 'core.handler.jdtls.jdtls_add_overridable_methods.JdtlsAddOverridableMethods'>,
<class 'core.handler.inlay_hint.InlayHint'>,
<class 'core.handler.semantic_tokens.SemanticTokens'>,
<class 'core.handler.rust_expand_macro.RustExpandMacro'>,
<class 'core.handler.rust_reload_workspace.RustReloadWorkspace'>,
<class 'core.handler.workspace_diagnostics.WorkspaceDiagnostics'>]
--- [20:43:47.853507] Send initialize request (49512) to 'volar' for project emacs
{
"id": 49512,
"method": "initialize",
"params": {
"processId": 13822,
"rootPath": "/Users/liuyinz/.config/emacs",
"clientInfo": {
"name": "emacs",
"version": "lsp-bridge"
},
"rootUri": "file:///Users/liuyinz/.config/emacs",
"capabilities": {
"workspace": {
"configuration": true,
"symbol": {
"resolveSupport": {
"properties": []
}
},
"didChangeWatchedFiles": {
"dynamicRegistration": true,
"relativePatternSupport": true
}
},
"textDocument": {
"completion": {
"completionItem": {
"snippetSupport": true,
"deprecatedSupport": true,
"tagSupport": {
"valueSet": [
1
]
},
"resolveSupport": {
"properties": [
"documentation",
"detail",
"additionalTextEdits"
]
}
}
},
"codeAction": {
"dynamicRegistration": false,
"codeActionLiteralSupport": {
"codeActionKind": {
"valueSet": [
"quickfix",
"refactor",
"refactor.extract",
"refactor.inline",
"refactor.rewrite",
"source",
"source.organizeImports"
]
}
},
"isPreferredSupport": true
},
"inlayHint": {
"dynamicRegistration": false
},
"hover": {
"contentFormat": [
"markdown",
"plaintext"
],
"dynamicRegistration": true
},
"formatting": {
"dynamicRegistration": true
},
"rangeFormatting": {
"dynamicRegistration": true
},
"onTypeFormatting": {
"dynamicRegistration": true
},
"publishDiagnostics": {
"relatedInformation": true,
"tagSupport": {
"valueSet": [
1,
2
]
},
"versionSupport": true,
"codeDescriptionSupport": true,
"dataSupport": true
}
},
"window": {
"workDoneProgress": true
}
},
"initializationOptions": {
"typescript": {
"tsdk": "%TSDK_PATH%"
},
"vue": {
"hybridMode": false
},
"languageFeatures": {
"references": true,
"implementation": true,
"definition": true,
"typeDefinition": true,
"callHierarchy": true,
"hover": true,
"rename": true,
"renameFileRefactoring": true,
"signatureHelp": true,
"codeAction": true,
"workspaceSymbol": true,
"completion": {
"defaultTagNameCase": "",
"defaultAttrNameCase": "",
"getDocumentNameCasesRequest": false,
"getDocumentSelectionRequest": false
},
"schemaRequestService": {
"getDocumentContentRequest": false
}
},
"documentFeatures": {
"selectionRange": true,
"foldingRange": true,
"linkedEditingRange": true,
"documentSymbol": true,
"documentColor": true,
"documentFormatting": {
"defaultPrintWidth": 100,
"getDocumentPrintWidthRequest": false
}
}
}
},
"jsonrpc": "2.0"
}
Eval in Emacs: (lsp-bridge-set-prefix-style '"ascii")
Eval in Emacs: (lsp-bridge-set-server-names '"/Users/liuyinz/.config/emacs/.cache/test/test.vue" '"" '("volar"))
Recv message (error):
{
"jsonrpc": "2.0",
"id": 49512,
"error": {
"code": -32603,
"message": "Request initialize failed with message: Can't find typescript.js or tsserverlibrary.js in \"%TSDK_PATH%\""
}
}
Eval in Emacs: (message '"[LSP-Bridge] Request initialize failed with message: Can't find typescript.js or tsserverlibrary.js in \"%TSDK_PATH%\"")
ERROR:epc:ReturnError([Symbol('error'), 'Not enough arguments for format string'])
是没有替换啊, 我看看源码
而且好像所有在initilizationOptions的变量都没有替换, 我也试过其他的¥FILEHASH¥
我猜应该是 lsp-bridge/lsp_bridge.py at d46260fcddbb39bf4762acbba6db18434892dfd8 · manateelazycat/lsp-bridge · GitHub 这一行类型的判断
def read_lang_server_info(lang_server_path):
lang_server_info = json.load(lang_server_path)
# Replace template in command options.
command_args = lang_server_info["command"]
for i, arg in enumerate(command_args):
command_args[i] = replace_template(arg)
lang_server_info["command"] = command_args
# Replace template in initializationOptions.
if "initializationOptions" in lang_server_info:
initialization_options_args = lang_server_info["initializationOptions"]
for i, arg in enumerate(initialization_options_args):
initialization_options_args[i] = replace_template(arg)
lang_server_info["initializationOptions"] = initialization_options_args
return lang_server_info
这个函数替换试一下? 我的volar还没装好, 我目测修的。
我待会回去试一下
不用了, 我volar装好了, 我一会就修了。
这个补丁修复了, 原来只支持 str 类型, 现在任意深度的数据结构都支持了。
已经ok了!
我看了一下好像, volar_window 和 volar_darwin 只有两个区别, 一个是启动命令, “vue-language-server” vs “vue-language-server.cmd”, 一个就是tsdk路径替换了, 也许将来可以只用一个 volar.json 就解决了.
不用将来, 就现在吧
谁在 windows 下使用 volar 的话, 可以检测类似的命令所在的位置, 比如
(executable-find "tsc")
和对应的 tsserver对应的路径, 这样的话我参考一下可以把windows下的tsdk_path也设置为自动检测
你这个名称不好, 还是精确点, 比如 %VUE_EXE%, 万一以后还有别的lsp server command 要替换呢
有冲突再改名字呗。
我这边自动检测函数没有考虑 windows 情况, 你要不也重写一下
(defun lsp-bridge--user-tsdk-path-func ()
"Get tsserver lib*.d.ts directory path."
(when-let* (((null lsp-bridge-tsdk-path))
(bin (executable-find "tsc"))
(tsdk (expand-file-name "../../lib" (file-truename bin)))
((file-exists-p tsdk)))
(setq lsp-bridge-tsdk-path tsdk))
(or lsp-bridge-tsdk-path ""))
还是改回来吧, 虽然重复了, 但是最起码清晰了, 也方便用户自定义 json 文件。
还是留着好, 将来只要用TSDK_PATH替换掉Windows那个就圆满了
不行哇, TSDK模板留在 json 这样用户可以自定义哇, 如果你直接在 lsp-bridge 重探测了,就相当于 lsp-bridge 硬编码了哇。
lsp-bridge 应该是兼容各种 lsp server 非标准配置最多的 lsp client 了
现在就很好, 首先让用户自定义, 不然的话就自动检测, 如果检测不到那就留空报错就行了.