You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

1.6 KiB

Language - JavaScript - TypeScript

Package

Define TypeScript JavaScript language package.

  (use-package emacs
    :after uno-lang-js
    :config
    (provide 'uno-lang-js-ts))

TypeScript, TSX Mode

  (use-package web-mode
    :after uno-lang-js-ts)

  (use-package typescript-mode
    :after (uno-lang-js-ts web-mode)
    :init
    (define-derived-mode typescript-tsx-mode web-mode "typescript-tsx")
    (push '("\\.tsx$" . typescript-tsx-mode) auto-mode-alist))

  (use-package emacs
    :after (uno-lang-js-ts ligature typescript-mode)
    :config
    (ligature-set-ligatures 'typescript-mode uno-lang-js-ligatures)
    (ligature-set-ligatures 'typescript-tsx-mode uno-lang-js-ligatures))

LSP Integration

  (use-package emacs
    :after (uno-lang-js-ts uno-lang-js-yarn typescript-mode)
    :hook
    (uno-lang-js-yarn . uno/lang/js/ts/yarn)
    ((typescript-mode typescript-tsx-mode) . uno/lang/js/yarn/check)
    :init
    (defun uno/lang/js/ts/yarn ()
      "Attempt to load SDKs with Yarn support."
      (when (and (member major-mode '(typescript-mode typescript-tsx-mode))
                 (uno/lang/js/yarn/add-to-local-lsp
                  'typescript-language-server
                  "typescript-language-server/lib/cli.js")
                 (uno/lang/js/yarn/add-to-local-lsp
                  'typescript
                  "typescript/bin/tsserver"))
        (push 'ts-ls lsp-enabled-clients)
        (lsp)))
    (uno/add-useless-buffer "\\*ts-ls\\*")
    (uno/add-useless-buffer "\\*ts-ls::.*\\*"))