lsp-bridge 的补全只有 Snippet 和 SearchWord

打开 vue 文件的日志, 没有报错或警告:

Eval in Emacs: (lsp-bridge--first-start '64755)
Eval in Emacs: (message '"[LSP-Bridge] found language server: /Users/mzy/.nvm/versions/node/v18.19.0/bin/vue-language-server")
Eval in Emacs: (message '"[LSP-Bridge] found language server: /Users/mzy/.nvm/versions/node/v18.19.0/bin/vue-language-server")
Start lsp server (volar) for /Users/mzy/work/traffic
Eval in Emacs: (message '"[LSP-Bridge] Active project 'traffic', 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.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.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.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'>]

--- [11:15:19.176719] Send initialize request (61352) to 'volar' for project traffic
{
   "id": 61352,
   "method": "initialize",
   "params": {
      "processId": 76189,
      "rootPath": "/Users/mzy/work/traffic",
      "clientInfo": {
         "name": "emacs",
         "version": "lsp-bridge"
      },
      "rootUri": "file:///Users/mzy/work/traffic",
      "capabilities": {
         "workspace": {
            "configuration": true,
            "symbol": {
               "resolveSupport": {
                  "properties": []
               }
            }
         },
         "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
            },
            "publishDiagnostics": {
               "relatedInformation": true,
               "tagSupport": {
                  "valueSet": [
                     1,
                     2
                  ]
               },
               "versionSupport": true,
               "codeDescriptionSupport": true,
               "dataSupport": true
            }
         }
      },
      "initializationOptions": {
         "typescript": {
            "tsdk": "/usr/local/lib/node_modules/typescript/lib"
         },
         "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
            }
         }
      }
   },
   "message_type": "request",
   "jsonrpc": "2.0"
}
Eval in Emacs: (lsp-bridge-set-server-names '"/Users/mzy/work/traffic/src/components/Cross/index.vue" '"" '("volar"))

--- [11:15:19.518633] Recv response (61352) from 'volar' for project traffic
{
   "jsonrpc": "2.0",
   "id": 61352,
   "result": {
      "capabilities": {
         "textDocumentSync": 2,
         "workspace": {
            "fileOperations": {
               "willRename": {
                  "filters": [
                     {
                        "pattern": {
                           "glob": "**/*.{js,cjs,mjs,ts,cts,mts,jsx,tsx,json,vue}"
                        }
                     }
                  ]
               }
            }
         },
         "selectionRangeProvider": true,
         "foldingRangeProvider": true,
         "linkedEditingRangeProvider": true,
         "colorProvider": true,
         "documentSymbolProvider": true,
         "documentFormattingProvider": true,
         "documentRangeFormattingProvider": true,
         "referencesProvider": true,
         "implementationProvider": true,
         "definitionProvider": true,
         "typeDefinitionProvider": true,
         "callHierarchyProvider": true,
         "hoverProvider": true,
         "renameProvider": {
            "prepareProvider": true
         },
         "signatureHelpProvider": {
            "triggerCharacters": [],
            "retriggerCharacters": []
         },
         "completionProvider": {
            "triggerCharacters": [
               "*",
               "/",
               "-",
               ":",
               "\"",
               ".",
               "<",
               "=",
               "@",
               ">",
               "+",
               "^",
               "(",
               ")",
               "#",
               "[",
               "]",
               "$",
               "{",
               "}"
            ],
            "resolveProvider": true
         },
         "documentHighlightProvider": true,
         "documentLinkProvider": {
            "resolveProvider": true
         },
         "codeLensProvider": {
            "resolveProvider": true
         },
         "codeActionProvider": {
            "codeActionKinds": [
               "",
               "quickfix",
               "refactor",
               "refactor.extract",
               "refactor.inline",
               "refactor.rewrite",
               "source",
               "source.fixAll",
               "source.organizeImports"
            ],
            "resolveProvider": true
         },
         "inlayHintProvider": {
            "resolveProvider": true
         },
         "workspaceSymbolProvider": true,
         "documentOnTypeFormattingProvider": {
            "firstTriggerCharacter": ";",
            "moreTriggerCharacter": [
               "}",
               "\n"
            ]
         }
      }
   }
}

--- [11:15:19.518839] Send initialized notification to 'volar' for project traffic

--- [11:15:19.589872] Recv workspace/configuration request (0) from 'volar' for project traffic
{
   "method": "initialized",
   "params": {},
   "message_type": "notification",
   "jsonrpc": "2.0"
}
{
   "jsonrpc": "2.0",
   "id": 0,
   "method": "workspace/configuration",
   "params": {
      "items": [
         {
            "section": "http"
         }
      ]
   }
}

--- [11:15:19.590058] Send workspace/didChangeConfiguration notification to 'volar' for project traffic
{
   "method": "workspace/didChangeConfiguration",
   "params": {
      "settings": {}
   },
   "message_type": "notification",
   "jsonrpc": "2.0"
}

--- [11:15:19.670035] Send textDocument/didOpen notification to 'volar' for project traffic
{
   "method": "textDocument/didOpen",
   "params": {
      "textDocument": {
         "uri": "file:///Users/mzy/work/traffic/src/components/Cross/index.vue",
         "languageId": "vue",
         "version": 0,
         "text": "<template>\n  <div class=\"cross\">\n    <canvas ref=\"canvasRef\" id=\"canvas\"> Your browser is not suppot canvas </canvas>\n  </div>\n</template>\n\n<script setup lang=\"ts\" name=\"Cross\">\nimport { ref, reactive, onMounted, onBeforeUnmount } from \"vue\";\nimport { calculateNewPoint, pointBetween, findPointsOnLine } from \"@/utils/calc\";\nimport { Coor, InLink, Lane } from \"@/utils/interface\";\nimport Cdraw from \"@/utils/cdraw\";\nimport testData from \"@/views/network/lanes/testData\";\n\nconst canvasRef: Ref<HTMLCanvasElement | null> = ref(null);\nlet ctx: CanvasRenderingContext2D | null = null;\nlet cdraw: Cdraw;\n\nconst center: Coor = {\n  x: 0,\n  y: 0\n};\n\nonMounted(() => {\n  initCanvas();\n  drawCross();\n});\n\nfunction initCanvas() {\n  const canvas = document.querySelector(\"#canvas\") as HTMLCanvasElement;\n  cdraw = new Cdraw(canvas);\n  canvas.width = (canvasRef.value as HTMLCanvasElement).offsetWidth;\n  canvas.height = (canvasRef.value as HTMLCanvasElement).offsetHeight;\n  ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D;\n  center.x = canvas.width / 2;\n  center.y = canvas.height / 2;\n  cdraw.drawCircle(center, 22, \"red\");\n}\n\nfunction drawCross() {\n  let angle = 0;\n  while (angle < 360) {\n    if (angle === 315) {\n      const p = calculateNewPoint(center, angle, 150);\n      const p2 = pointBetween(center, p, 3);\n      cdraw.drawCircle(p, 10, \"red\", angle);\n      cdraw.drawCircle(p2, 10, \"yellow\");\n      cdraw.drawLine(p, p2, \"red\");\n      const listA1 = findPointsOnLine(p, p2, 20);\n      listA1.forEach((item, i) => {\n        const color = i === 0 ? \"cyan\" : \"blue\";\n        cdraw.drawCircle(item, 10, color);\n      });\n\n      const listA2 = findPointsOnLine(p, p2, 40);\n      listA2.forEach((item, i) => {\n        const color = i === 0 ? \"cyan\" : \"blue\";\n        cdraw.drawCircle(item, 10, color);\n      });\n\n      const listB1 = findPointsOnLine(center, p, 20);\n      listB1.forEach((item, i) => {\n        const color = i === 0 ? \"cyan\" : \"blue\";\n        cdraw.drawCircle(item, 10, color);\n      });\n    }\n    angle += 45;\n  }\n}\n</script>\n\n<style scoped lang=\"scss\">\n.cross {\n  width: 100%;\n  height: 100%;\n}\n#canvas {\n  width: 100%;\n  height: 100%;\n  border: 1px solid #235773;\n}\n</style>\n"
      }
   },
   "message_type": "notification",
   "jsonrpc": "2.0"
}

--- [11:15:19.889580] Send textDocument/signatureHelp request (3730) to 'volar' for project traffic
{
   "id": 3730,
   "method": "textDocument/signatureHelp",
   "params": {
      "position": {
         "line": 35,
         "character": 0
      },
      "textDocument": {
         "uri": "file:///Users/mzy/work/traffic/src/components/Cross/index.vue"
      }
   },
   "message_type": "request",
   "jsonrpc": "2.0"
}

--- [11:15:19.889795] Send response to server request 0 to 'volar' for project traffic
{
   "id": 0,
   "result": [
      null
   ],
   "message_type": "response",
   "jsonrpc": "2.0"
}

--- [11:15:19.935429] Recv textDocument/signatureHelp response (3730) from 'volar' for project traffic
{
   "jsonrpc": "2.0",
   "id": 3730,
   "result": null
}

--- [11:15:19.944395] Recv workspace/configuration request (1) from 'volar' for project traffic
{
   "jsonrpc": "2.0",
   "id": 1,
   "method": "workspace/configuration",
   "params": {
      "items": [
         {
            "section": "css.customData"
         }
      ]
   }
}

--- [11:15:19.944484] Send response to server request 1 to 'volar' for project traffic

--- [11:15:19.973821] Recv workspace/configuration request (2) from 'volar' for project traffic
{
   "id": 1,
   "result": [
      null
   ],
   "message_type": "response",
   "jsonrpc": "2.0"
}
{
   "jsonrpc": "2.0",
   "id": 2,
   "method": "workspace/configuration",
   "params": {
      "items": [
         {
            "section": "scss"
         }
      ]
   }
}

--- [11:15:19.973931] Send response to server request 2 to 'volar' for project traffic
{
   "id": 2,
   "result": [
      null
   ],
   "message_type": "response",
   "jsonrpc": "2.0"
}

--- [11:15:19.982546] Recv textDocument/publishDiagnostics notification from 'volar' for project traffic

--- [11:15:19.982633] Record diagnostics from 'volar' for file index.vue
{
   "jsonrpc": "2.0",
   "method": "textDocument/publishDiagnostics",
   "params": {
      "uri": "file:///Users/mzy/work/traffic/src/components/Cross/index.vue",
      "diagnostics": [],
      "version": 0
   }
}

--- [11:15:20.047131] Recv textDocument/publishDiagnostics notification from 'volar' for project traffic

输入内容后 :

--- [11:17:39.401276] Send textDocument/didChange notification to 'volar' for project traffic
{
   "method": "textDocument/didChange",
   "params": {
      "textDocument": {
         "uri": "file:///Users/mzy/work/traffic/src/components/Cross/index.vue",
         "version": 3
      },
      "contentChanges": [
         {
            "range": {
               "start": {
                  "line": 36,
                  "character": 2
               },
               "end": {
                  "line": 36,
                  "character": 2
               }
            },
            "rangeLength": 0,
            "text": "c"
         }
      ]
   },
   "message_type": "notification",
   "jsonrpc": "2.0"
}
Eval in Emacs: (lsp-bridge-search-backend--record-items '"search-file-words" '((:key "coor" :icon "search" :label "coor" :displayLabel "coor" :annotation "Search Word" :backend "search-file-words") (:key "calc" :icon "search" :label "calc" :displayLabel "calc" :annotation "Search Word" :backend "search-file-words") (:key "cyan" :icon "search" :label "cyan" :displayLabel "cyan" :annotation "Search Word" :backend "search-file-words") (:key "class" :icon "search" :label "class" :displayLabel "class" :annotation "Search Word" :backend "search-file-words") (:key "cdraw" :icon "search" :label "cdraw" :displayLabel "cdraw" :annotation "Search Word" :backend "search-file-words") (:key "cdraw" :icon "search" :label "cdraw" :displayLabel "cdraw" :annotation "Search Word" :backend "search-file-words") (:key "const" :icon "search" :label "const" :displayLabel "const" :annotation "Search Word" :backend "search-file-words") (:key "cross" :icon "search" :label "cross" :displayLabel "cross" :annotation "Search Word" :backend "search-file-words") (:key "cross" :icon "search" :label "cross" :displayLabel "cross" :annotation "Search Word" :backend "search-file-words") (:key "color" :icon "search" :label "color" :displayLabel "color" :annotation "Search Word" :backend "search-file-words")))

--- [11:17:39.505909] Send textDocument/completion request (6396) to 'volar' for project traffic
{
   "id": 6396,
   "method": "textDocument/completion",
   "params": {
      "position": {
         "line": 36,
         "character": 3
      },
      "context": {
         "triggerKind": 1
      },
      "textDocument": {
         "uri": "file:///Users/mzy/work/traffic/src/components/Cross/index.vue"
      }
   },
   "message_type": "request",
   "jsonrpc": "2.0"
}

--- [11:17:39.511351] Recv textDocument/completion response (6396) from 'volar' for project traffic

--- [11:17:39.511404] Got completion candidates (0) from 'volar' for file index.vue

--- [11:17:39.511420] Record completion candidates (0) from 'volar' for file index.vue
Eval in Emacs: (lsp-bridge-completion--record-items '"/Users/mzy/work/traffic/src/components/Cross/index.vue" '"" '() '(:line 36 :character 3) '"volar" '("*" "/" "-" ":" "\"" "." "<" "=" "@" ">" "+" "^" "(" ")" "#" "[" "]" "$" "{" "}") '("volar"))
{
   "jsonrpc": "2.0",
   "id": 6396,
   "result": {
      "isIncomplete": false,
      "items": []
   }
}

--- [11:17:39.660439] Recv textDocument/publishDiagnostics notification from 'volar' for project traffic

--- [11:17:39.660553] Record diagnostics from 'volar' for file index.vue
{
   "jsonrpc": "2.0",
   "method": "textDocument/publishDiagnostics",
   "params": {
      "uri": "file:///Users/mzy/work/traffic/src/components/Cross/index.vue",
      "diagnostics": [],
      "version": 3
   }
}

--- [11:17:39.660775] Recv textDocument/publishDiagnostics notification from 'volar' for project traffic

--- [11:17:39.660808] Record diagnostics from 'volar' for file index.vue
{
   "jsonrpc": "2.0",
   "method": "textDocument/publishDiagnostics",
   "params": {
      "uri": "file:///Users/mzy/work/traffic/src/components/Cross/index.vue",
      "diagnostics": [],
      "version": 3
   }
}

--- [11:17:39.950207] Send textDocument/signatureHelp request (30162) to 'volar' for project traffic
{
   "id": 30162,
   "method": "textDocument/signatureHelp",
   "params": {
      "position": {
         "line": 36,
         "character": 3
      },
      "textDocument": {
         "uri": "file:///Users/mzy/work/traffic/src/components/Cross/index.vue"
      }
   },
   "message_type": "request",
   "jsonrpc": "2.0"
}

--- [11:17:39.952317] Recv textDocument/signatureHelp response (30162) from 'volar' for project traffic
{
   "jsonrpc": "2.0",
   "id": 30162,
   "result": null
}
Eval in Emacs: (lsp-bridge-diagnostic--render '"/Users/mzy/work/traffic/src/components/Cross/index.vue" '"" '() '0)

*** lsp-bridge-try-completion execute predicate 'lsp-bridge-not-only-blank-before-cursor' failed with result: 'nil'

语法检查也没有了

image

lsp-bridge 的全部配置

(if (file-exists-p "~/AppData/Roaming/lsp-bridge")
    (add-to-list 'load-path "~/AppData/Roaming/lsp-bridge")
  (add-to-list 'load-path "~/emacs-packages/lsp-bridge"))
(require 'lsp-bridge)
(global-lsp-bridge-mode)
;; 当光标悬停在诊断位置时显示诊断工具提示,默认禁用
(setq lsp-bridge-enable-hover-diagnostic t)
(setq acm-enable-tabnine nil)
(setq acm-enable-yas nil)
(setq acm-backend-search-file-words-candidate-min-length 3)
;; (setq acm-backend-lsp-block-kind-list '("Snippet" "Enum"))

(setq lsp-bridge-enable-log t)

python 的那一堆包也是正常的

如何继续排错呢?

还有这个症状:每次保存文件都像是重启了一下 lsp-bridge

[LSP-Bridge] Active project ’traffic’, enjoy hacking!
Saving file /Users/mzy/work/traffic/src/components/Cross/index.vue...
Wrote /Users/mzy/work/traffic/src/components/Cross/index.vue
[LSP-Bridge] found language server: /Users/mzy/.nvm/versions/node/v18.19.0/bin/vue-language-server [2 times]
[LSP-Bridge] Active project ’traffic’, enjoy hacking!
Mark set
Saving file /Users/mzy/work/traffic/src/components/Cross/index.vue...
Wrote /Users/mzy/work/traffic/src/components/Cross/index.vue
[LSP-Bridge] found language server: /Users/mzy/.nvm/versions/node/v18.19.0/bin/vue-language-server [2 times]
[LSP-Bridge] Active project ’traffic’, enjoy hacking!
Mark activated
Saving file /Users/mzy/work/traffic/src/components/Cross/index.vue...
Wrote /Users/mzy/work/traffic/src/components/Cross/index.vue
[LSP-Bridge] found language server: /Users/mzy/.nvm/versions/node/v18.19.0/bin/vue-language-server [2 times]
[LSP-Bridge] Active project ’traffic’, enjoy hacking!
Saving file /Users/mzy/work/traffic/src/components/Cross/index.vue...
Wrote /Users/mzy/work/traffic/src/components/Cross/index.vue
[LSP-Bridge] found language server: /Users/mzy/.nvm/versions/node/v18.19.0/bin/vue-language-server [2 times]
[LSP-Bridge] Active project ’traffic’, enjoy hacking!
Mark set
next-line: End of buffer

我有个 eslint-fix 的包,会在保存的时候执行 eslint-fix,不过测试过了,跟它没关系

(use-package eslint-fix
  :ensure t
  :config
  (add-hook 'js-mode-hook (lambda () (add-hook 'after-save-hook 'eslint-fix nil t)))
  ;; (add-hook 'js2-mode-hook (lambda () (add-hook 'after-save-hook 'eslint-fix nil t)))
  (add-hook 'web-mode-hook (lambda () (add-hook 'after-save-hook 'eslint-fix nil t)))
  (add-hook 'typescript-mode-hook (lambda () (add-hook 'after-save-hook 'eslint-fix nil t))))