Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript with flycheck #2874

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions contrib/!lang/typescript/packages.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
;;; packages.el --- typescript Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Chris Bowdon & Contributors
;;
;; Author: Chris Bowdon <c.bowdon@bath.edu>
;; Author: Hamish Hutchings <hamhut1066@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(setq typescript-packages '(
tss
flycheck))

(setq test-layer-excluded-packages '())

(defun typescript/post-init-flycheck ()
"Add hook for flycheck"
(use-package flycheck
:defer t
:config
(progn
;; ;;; remove hook for flymake, as it seems to conflict.
;; (add-hook 'typescript-mode-hook 'flycheck-mode (flymake-mode nil))
;; (add-hook 'typescript-mode-hook (lambda flymake-mode nil))
;;; This Code Snippet was from [Here](https://github.com/caisah/flycheck-typescript) and is licensed under the GPL
(flycheck-define-checker typescript
"A TypeScript syntax checker using tsc command."
:command ("tsc" "--out" "/dev/null" source-inplace)
:error-patterns
((error line-start (file-name) "(" line "," column "): error " (message) line-end))
:modes (typescript-mode))

(add-to-list 'flycheck-checkers 'typescript))))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its better to keep trailing parentheses together, don't leave them on their own line

(defun typescript/init-tss ()
"Initialize tss"
(use-package tss
:defer t
:mode ("\\.ts\\'" . typescript-mode)
:init (evil-leader/set-key-for-mode 'flycheck-mode
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want to use evil-leader/set-key-for-mode 'typescript-mode to keep this from being bound in other filetypes

"mgg" 'tss-jump-to-definition
"mhh" 'tss-popup-help)
:config
(progn
;; Remove Flymake mode from hook.
(advice-add 'tss-setup-current-buffer :before (lambda flymake-mode nil))

(add-hook 'typescript-mode-hook 'tss-setup-current-buffer t)
(add-hook 'kill-buffer-hook 'tss--delete-process t))))
58 changes: 50 additions & 8 deletions layers/!lang/typescript/packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,62 @@
;; Copyright (c) 2014-2015 Chris Bowdon & Contributors
;;
;; Author: Chris Bowdon <c.bowdon@bath.edu>
;; Author: Hamish Hutchings <hamhut1066@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3

(setq typescript-packages '(tss))
(setq typescript-private-packages '(
tss
flycheck))

(defun typescript/init-tss ()
"Initialize my package"
(setq test-layer-excluded-packages '(flymake))

(defun typescript-private/post-init-flycheck ()
"Add hook for flycheck"
(use-package flycheck
:defer t
:config (progn
;; ;;; remove hook for flymake, as it seems to conflict.
;; (add-hook 'typescript-mode-hook 'flycheck-mode (flymake-mode nil))
;; (add-hook 'typescript-mode-hook (lambda flymake-mode nil))
;;; This Code Snippet was from [Here](https://github.com/caisah/flycheck-typescript) and is licensed under the GPL
(flycheck-define-checker typescript
"A TypeScript syntax checker using tsc command."
:command ("tsc" "--out" "/dev/null" source-inplace)
:error-patterns
((error line-start (file-name) "(" line "," column "): error " (message) line-end))
:modes (typescript-mode))

(add-to-list 'flycheck-checkers 'typescript)
)
)
)


(defun typescript-private/init-tss ()
"Initialize tss"
(use-package tss
:defer t
:mode ("\\.ts\\'" . typescript-mode)
:init (evil-leader/set-key-for-mode 'typescript-mode
"mgg" 'tss-jump-to-definition
"mhh" 'tss-popup-help)
:config (tss-config-default)))
:mode (
("\\.ts\\'" . typescript-mode)
))
:init (evil-leader/set-key-for-mode 'flycheck-mode
"mgg" 'tss-jump-to-definition
"mhh" 'tss-popup-help)

)

(defun typescript-private/post-init-tss ()
"Initialize tss"
(use-package tss
:defer t
:config (progn
;; Remove Flymake mode from hook.
(advice-add 'tss-setup-current-buffer :before (lambda flymake-mode nil))

(add-hook 'typescript-mode-hook 'tss-setup-current-buffer t)
(add-hook 'kill-buffer-hook 'tss--delete-process t)
)))