Emacs config utilizing prelude as a base
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.

60 lines
1.8 KiB

  1. ;;; prelude-ts.el --- Emacs Prelude: Typescript programming support.
  2. ;;
  3. ;; Copyright © 2011-2022 LEE Dongjun
  4. ;;
  5. ;; Author: LEE Dongjun <redongjun@gmail.com>
  6. ;; This file is not part of GNU Emacs.
  7. ;;; Commentary:
  8. ;; Some basic configuration for Typescript development.
  9. ;;; License:
  10. ;; This program is free software; you can redistribute it and/or
  11. ;; modify it under the terms of the GNU General Public License
  12. ;; as published by the Free Software Foundation; either version 3
  13. ;; of the License, or (at your option) any later version.
  14. ;;
  15. ;; This program is distributed in the hope that it will be useful,
  16. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;; GNU General Public License for more details.
  19. ;;
  20. ;; You should have received a copy of the GNU General Public License
  21. ;; along with GNU Emacs; see the file COPYING. If not, write to the
  22. ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  23. ;; Boston, MA 02110-1301, USA.
  24. ;;; Code:
  25. (require 'prelude-programming)
  26. (prelude-require-packages '(tide))
  27. (require 'typescript-mode)
  28. (add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-mode))
  29. (with-eval-after-load 'typescript-mode
  30. (defun prelude-ts-mode-defaults ()
  31. (interactive)
  32. (tide-setup)
  33. (flycheck-mode +1)
  34. (setq flycheck-check-syntax-automatically '(save mode-enabled))
  35. (eldoc-mode +1)
  36. (tide-hl-identifier-mode +1))
  37. ;; formats the buffer before saving
  38. (add-hook 'before-save-hook
  39. (lambda ()
  40. (when prelude-format-on-save
  41. (tide-format-before-save))))
  42. (setq prelude-ts-mode-hook 'prelude-ts-mode-defaults)
  43. (add-hook 'typescript-mode-hook (lambda () (run-hooks 'prelude-ts-mode-hook))))
  44. (provide 'prelude-ts)
  45. ;;; prelude-ts.el ends here