Verified Commit 132aa754 authored by peacerebel's avatar peacerebel
Browse files

Better js support

parent 064e9117
...@@ -38,6 +38,10 @@ ...@@ -38,6 +38,10 @@
;; Enable pretty symbols globally ;; Enable pretty symbols globally
(global-prettify-symbols-mode t) (global-prettify-symbols-mode t)
;; Load path from shell
(use-package exec-path-from-shell
:config (exec-path-from-shell-initialize))
;; Open emacs config ;; Open emacs config
(defun pr/visit-emacs-config () (defun pr/visit-emacs-config ()
"Opens file with Emacs configurations." "Opens file with Emacs configurations."
...@@ -116,7 +120,9 @@ ...@@ -116,7 +120,9 @@
(which-key-mode)) (which-key-mode))
;; THEME ;; THEME
(use-package cyberpunk-theme) (use-package cyberpunk-theme
:init
(load-theme 'cyberpunk))
;; Font settings ;; Font settings
(defvar pr/default-font "Hack") (defvar pr/default-font "Hack")
...@@ -209,10 +215,13 @@ other, future frames." ...@@ -209,10 +215,13 @@ other, future frames."
;; Dumb-jump ;; Dumb-jump
(use-package dumb-jump (use-package dumb-jump
:bind
("M-." . 'xref-find-definitions)
:config :config
(setq dumb-jump-force-searcher 'rg) (setq xref-backend-functions (remq 'etags--xref-backend xref-backend-functions))
:init (add-hook 'xref-backend-functions #'dumb-jump-xref-activate)
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate)) (setq dumb-jump-force-searcher 'rg
dumb-jump-selector 'ivy))
;; Company-mode ;; Company-mode
(use-package company (use-package company
...@@ -246,6 +255,7 @@ other, future frames." ...@@ -246,6 +255,7 @@ other, future frames."
;; Language servers ;; Language servers
(use-package lsp-mode (use-package lsp-mode
:config :config
(setq lsp-enable-xref nil)
(setq gc-cons-threshold 100000000) ;; Why? Visit: https://emacs-lsp.github.io/lsp-mode/page/performance/ (setq gc-cons-threshold 100000000) ;; Why? Visit: https://emacs-lsp.github.io/lsp-mode/page/performance/
(setq lsp-completion-provider :capf) (setq lsp-completion-provider :capf)
:hook ((js-mode . lsp)) :hook ((js-mode . lsp))
...@@ -292,6 +302,20 @@ other, future frames." ...@@ -292,6 +302,20 @@ other, future frames."
;; Better M-x ;; Better M-x
(use-package smex) (use-package smex)
(use-package highlight-symbol
:hook (prog-mode . highlight-symbol-mode)
:custom
(highlight-symbol-idle-delay 0.3))
(use-package highlight-numbers
:hook (prog-mode . highlight-numbers-mode))
(use-package highlight-operators
:hook (prog-mode . highlight-operators-mode))
(use-package highlight-escape-sequences
:hook (prog-mode . hes-mode))
;; Electric pair ;; Electric pair
(electric-pair-mode t) (electric-pair-mode t)
...@@ -308,7 +332,14 @@ other, future frames." ...@@ -308,7 +332,14 @@ other, future frames."
;; Flycheck ;; Flycheck
(use-package flycheck (use-package flycheck
:ensure t :ensure t
:init (global-flycheck-mode)) :config
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
'(javascript-jshint)))
:init
(flycheck-add-mode 'javascript-eslint 'web-mode)
(flycheck-add-mode 'javascript-eslint 'js-mode)
(global-flycheck-mode))
(use-package flycheck-color-mode-line (use-package flycheck-color-mode-line
:hook :hook
...@@ -345,6 +376,31 @@ other, future frames." ...@@ -345,6 +376,31 @@ other, future frames."
(tide-hl-identifier-mode +1) (tide-hl-identifier-mode +1)
(company-mode +1))) (company-mode +1)))
;; Javascript
(setq js-indent-level 2)
(use-package tern
:config
(unbind-key "M-." tern-mode-keymap)
(unbind-key "M-," tern-mode-keymap)
(add-hook 'js-mode-hook (lambda () (tern-mode t))))
(eval-after-load 'js
'(define-key js-mode-map (kbd "M-.") nil))
(defun my/use-eslint-from-node-modules ()
"Find local eslisnt installation."
(let* ((root (locate-dominating-file
(or (buffer-file-name) default-directory)
"node_modules"))
(eslint (and root
(expand-file-name "node_modules/eslint/bin/eslint.js"
root))))
(when (and eslint (file-executable-p eslint))
(setq-local flycheck-javascript-eslint-executable eslint))))
(add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)
;; TeX ;; TeX
(use-package auctex (use-package auctex
:defer t :defer t
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment