Skip to content

Instantly share code, notes, and snippets.

@deviantfero
Created September 6, 2019 05:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deviantfero/09c374666b52ed0f462f318e042b001b to your computer and use it in GitHub Desktop.
Save deviantfero/09c374666b52ed0f462f318e042b001b to your computer and use it in GitHub Desktop.
(defun my/activate-tide-mode ()
"Use hl-identifier-mode only on js or ts buffers."
(when (and (stringp buffer-file-name)
(string-match "\\.[tj]sx?\\'" buffer-file-name))
(tide-setup)
(tide-hl-identifier-mode)))
(defun my/set-local-eslint ()
"Use local node_modules."
(add-node-modules-path)
(setq-local flycheck-javascript-eslint-executable (executable-find "eslint")))
(use-package tide
:ensure t
:config
(flycheck-add-next-checker 'tsx-tide 'javascript-eslint)
:hook (web-mode . my/activate-tide-mode))
(use-package flycheck
:ensure t
:hook (web-mode . my/set-local-eslint)
:init
(setq flycheck-python-flake8-executable (executable-find "flake8"))
(setq flycheck-python-pycompile-executable (executable-find "python3"))
:config
(flycheck-add-mode 'javascript-eslint 'web-mode)
(setq flycheck-check-syntax-automatically '(mode-enabled save))
(global-flycheck-mode 1))
(use-package web-mode
:ensure t
:mode
("\\.ejs\\'" "\\.hbs\\'" "\\.html\\'" "\\.php\\'" "\\.[jt]sx?\\'")
:config
(setq web-mode-content-types-alist '(("jsx" . "\\.[jt]sx?\\'")))
(setq web-mode-markup-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(setq web-mode-script-padding 2)
(setq web-mode-block-padding 2)
(setq web-mode-style-padding 2)
(setq web-mode-enable-auto-pairing t)
(setq web-mode-enable-auto-closing t)
(setq web-mode-enable-current-element-highlight t))
(use-package add-node-modules-path
:ensure t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment