Skip to content

Instantly share code, notes, and snippets.

@epetousis
Last active October 17, 2022 03:39
Show Gist options
  • Save epetousis/f9e8129b4c13c033cd12546e93b41bf1 to your computer and use it in GitHub Desktop.
Save epetousis/f9e8129b4c13c033cd12546e93b41bf1 to your computer and use it in GitHub Desktop.
Minimum code needed to get Volar working with eglot
(use-package eglot
:config (add-to-list 'eglot-server-programs
'(web-mode . (eglot-volar "vue-language-server" "--stdio"))))
(defclass eglot-volar (eglot-lsp-server) ()
:documentation "A custom class for Volar's langserver.")
;; Volar requires a path to a TypeScript SDK. It normally uses VSCode's preinstalled SDK.
;; tsdk is the correct variable as of https://github.com/johnsoncodehk/volar/pull/1916 being merged, but it may change at any time.
(cl-defmethod eglot-initialization-options ((server eglot-volar))
"Passes through required Volar initialization options"
(let* ((tsdk (concat (projectile-project-root) "node_modules/typescript/lib")))
(list :typescript (list :tsdk (file-name-as-directory tsdk)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment