使eglot补全vue文件时发现能提示补全项,但是回车选择提示项时错误。
查了下原因发现是,volar没有按照lsp协议正确的返回completionItem
导致eglot拿不到textEdit
中的range
字段,前天给volar报了bug volar#1373 今天已经发布了新版本修复了volar/CHANGELOG.md。
关闭了eglot的日志打印,体验还行。
以下是我的配置:
;;; 调整到100M
(add-hook 'emacs-startup-hook
(lambda () (setq gc-cons-threshold (* 100 1024 1024))))
(setq read-process-output-max (* 1024 1024))
;; 关闭日志打印,不卡emacs
(setq-default eglot-events-buffer-size 0)
;; 自己继承web-mode定义vue-mode
(define-derived-mode vue-mode web-mode "Vue")
(add-to-list 'auto-mode-alist '("\\.vue\\'" . vue-mode))
(add-hook 'vue-mode-hook 'eglot-ensure)
;;; 配置volar
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs '(vue-mode . (eglot-volar "vue-language-server" "--stdio")))
(defclass eglot-volar (eglot-lsp-server) ()
:documentation "volar")
(cl-defmethod eglot-initialization-options ((server eglot-volar))
"Passes through required cquery initialization options"
`(
:typescript (:serverPath ,(expand-file-name "~/.nvm/versions/node/v16.14.2/lib/node_modules/typescript/lib/tsserverlibrary.js"))
:languageFeatures (
:references t
:implementation t
:definition t
:typeDefinition t
:rename t
:renameFileRefactoring t
:signatureHelp t
:codeAction t
:workspaceSymbol t
:completion (
:defaultTagNameCase ""
:defaultAttrNameCase ""
:getDocumentNameCasesRequest :json-false
:getDocumentSelectionRequest :json-false)
:schemaRequestService (:getDocumentContentRequest :json-false))
:documentFeatures (
:selectionRange t,
:foldingRange :json-false,
:linkedEditingRange t,
:documentSymbol t,
:documentColor t,
:documentFormatting (
:defaultPrintWidth 100
:getDocumentPrintWidthRequest :json-false)
:defaultPrintWidth 100
:getDocumentPrintWidthRequest :json-false))))
当前使用的版本:
@volar/[email protected]