emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.8k stars 893 forks source link

Add support for vtsls typescript LSP #4335

Open fstaffa opened 9 months ago

fstaffa commented 9 months ago

https://github.com/yioneko/vtsls is a wrapper around official vscode extension and offers some additional features (e.g. ts-ls offers "Convert 'require' to 'import'", but vtsls also offers "Convert all 'require' to 'import' which does the same for all statements in file)

somallg commented 5 months ago

If you are using doom-emacs, this code snippets will register vtsls as new typescript server. Please note this is minimal configuration, and you need to install vtsls with npm install -g @vtsls/language-server

(after! lsp-mode
  (defgroup lsp-vtsls nil
    "LSP wrapper for typescript extension of vscode."
    :group 'lsp-mode
    :link '(url-link "https://github.com/yioneko/vtsls"))

  (defcustom lsp-clients-vtsls-server "vtsls"
    "The vtsls executable to use.
Leave as just the executable name to use the default behavior of
finding the executable with variable `exec-path'."
    :group 'lsp-vtsls
    :risky t
    :type 'file
    :package-version '(lsp-mode . "8.0.0"))

  (defcustom lsp-clients-vtsls-server-args '("--stdio")
    "Extra arguments for starting the vtsls language server."
    :group 'lsp-vtsls
    :risky t
    :type '(repeat string)
    :package-version '(lsp-mode . "8.0.0"))

  (lsp-register-client
   (make-lsp-client :new-connection (lsp-stdio-connection (lambda ()
                                                            (cons lsp-clients-vtsls-server
                                                                  lsp-clients-vtsls-server-args)))
                    :activation-fn #'lsp-typescript-javascript-tsx-jsx-activate-p
                    :priority -1
                    :completion-in-comments? t
                    :server-id 'vtsls)))
nvimtor commented 4 days ago

Has someone managed to make inlay type hints work with vtsls?