<commit_before>;;; init-js.el ---                                -*- lexical-binding: t; -*-
;; Copyright (C) 2017  <NAME>
;; Author: <NAME>;;; init-js.el --- base file <<EMAIL>>
;; Keywords: 
;;; Commentary:
;; Javascript 
;;; Code:

(require 'web-mode)
(require 'js2-mode)
(require 'ac-js2)
(require 'indium)
(require 'js2-refactor)
(require 'tide)

;; Mac系统中需要用 exec-path-from-shell-initialize 加载环境变量, 否则找不到 indium server
;; (when (featurep 'cocoa)
;;   ;; Initialize environment from user's shell to make eshell know every PATH by other shell.
;;   (require 'exec-path-from-shell)
;;   (exec-path-from-shell-initialize))

(add-hook 'js2-mode-hook #'js2-refactor-mode)
(add-hook 'js-mode-hook #'indium-interaction-mode)
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))

(add-hook 'js2-mode-hook 'prettier-js-mode)
(add-hook 'web-mode-hook 'prettier-js-mode)

(add-hook 'web-mode-hook
          (lambda ()
            (when (string-equal "tsx" (file-name-extension buffer-file-name))
              )))
;; enable typescript-tslint checker
(flycheck-add-mode 'typescript-tslint 'web-mode)

(add-hook 'js2-mode-hook (lambda()
			   ;;(setq indium-debugger-mode 1)
			   ;;(setq indium-nodejs-inspect-brk t)
			   ;;(setq indium-script-enable-sourcemaps t)
			   ;;(setup-tide-mode t)
			   (tern-mode)
			   (hs-minor-mode t)
			   (company-mode)
			   (set (make-local-variable 'company-backends) '((company-tern company-etags company-dabbrev-code) company-dabbrev))
			   ))


(defun setup-tide-mode ()
  "Typescript develop configure."
  (interactive)
  (setq tide-tsserver-process-environment '("TSS_LOG=-level verbose -file /tmp/tss.log"))
  (tide-setup)
  (flycheck-mode +1)
  (setq flycheck-check-syntax-automatically '(save mode-enabled))
  (add-hook 'before-save-hook 'save-format-file)
  ;;(eldoc-mode +1)
  (hs-minor-mode t)
  (tide-hl-identifier-mode +1)
  (global-set-key (kbd "C-c .") 'tide-references)
  ;;(company-mode +1)
  )
(setq company-tooltip-align-annotations t)
;;
(defun save-format-file()
  "Use shell command format code."
  (interactive)
  (tide-format-before-save)
  ;; (shell-command (concat "prettier --write " (buffer-file-name)))
  ;; (auto-revert-buffers)
  ;; (do-auto-save)
<commit_msg>update agenda key<commit_after>;;; init-js.el ---                                -*- lexical-binding: t; -*-
;; Copyright (C) 2017  <NAME>
;; Author: Yuanfei He;;; init-js.el --- base file <<EMAIL>>
;; Keywords: 
;;; Commentary:
;; Javascript 
;;; Code:

(require 'web-mode)
(require 'js2-mode)
(require 'ac-js2)
(require 'indium)
(require 'js2-refactor)
(require 'tide)

;; Mac系统中需要用 exec-path-from-shell-initialize 加载环境变量, 否则找不到 indium server
;; (when (featurep 'cocoa)
;;   ;; Initialize environment from user's shell to make eshell know every PATH by other shell.
;;   (require 'exec-path-from-shell)
;;   (exec-path-from-shell-initialize))

(add-hook 'js2-mode-hook #'js2-refactor-mode)
(add-hook 'js-mode-hook #'indium-interaction-mode)
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))

(add-hook 'js2-mode-hook 'prettier-js-mode)
(add-hook 'web-mode-hook 'prettier-js-mode)

(add-hook 'web-mode-hook
          (lambda ()
            (when (string-equal "tsx" (file-name-extension buffer-file-name))
              )))
;; enable typescript-tslint checker
(flycheck-add-mode 'typescript-tslint 'web-mode)

(add-hook 'js2-mode-hook (lambda()
			   ;;(setq indium-debugger-mode 1)
			   ;;(setq indium-nodejs-inspect-brk t)
			   ;;(setq indium-script-enable-sourcemaps t)
			   ;;(setup-tide-mode t)
			   (tern-mode)
			   (hs-minor-mode t)
			   (company-mode)
			   (set (make-local-variable 'company-backends) '((company-tern company-etags company-dabbrev-code) company-dabbrev))
			   ))


(defun setup-tide-mode ()
  "Typescript develop configure."
  (interactive)
  (setq tide-tsserver-process-environment '("TSS_LOG=-level verbose -file /tmp/tss.log"))
  (tide-setup)
  (flycheck-mode +1)
  (setq flycheck-check-syntax-automatically '(save mode-enabled))
  (add-hook 'before-save-hook 'save-format-file)
  (eldoc-mode +1)
  (hs-minor-mode t)
  (tide-hl-identifier-mode +1)
  (global-set-key (kbd "C-c .") 'tide-references)
  (setq tide-always-show-documentation t)
  (setq tide-imenu-flatten t)
  ;;(company-mode +1)
  )
(setq company-tooltip-align-annotations t)
;;
(defun save-format-file()
  "Use shell command format code."
  (interactive)
  (tide-format-before-save)
  ;; (shell-command (concat "prettier --write " (buffer-file-name)))
  ;; (auto-revert-buffers)
  ;; (do-auto-save)

{'fraction_non_alphanumeric': 0.18395008605851979, 'fraction_numerical': 0.007314974182444062, 'mean_word_length': 3.253430924062214, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1495717', 'n_tokens_mistral': 1883, 'n_tokens_neox': 1782, 'n_words': 345}