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

Better js support

parent 064e9117
......@@ -38,6 +38,10 @@
;; Enable pretty symbols globally
(global-prettify-symbols-mode t)
;; Load path from shell
(use-package exec-path-from-shell
:config (exec-path-from-shell-initialize))
;; Open emacs config
(defun pr/visit-emacs-config ()
"Opens file with Emacs configurations."
......@@ -116,7 +120,9 @@
(use-package cyberpunk-theme)
(use-package cyberpunk-theme
(load-theme 'cyberpunk))
;; Font settings
(defvar pr/default-font "Hack")
......@@ -209,10 +215,13 @@ other, future frames."
;; Dumb-jump
(use-package dumb-jump
("M-." . 'xref-find-definitions)
(setq dumb-jump-force-searcher 'rg)
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate))
(setq xref-backend-functions (remq 'etags--xref-backend xref-backend-functions))
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate)
(setq dumb-jump-force-searcher 'rg
dumb-jump-selector 'ivy))
;; Company-mode
(use-package company
......@@ -246,6 +255,7 @@ other, future frames."
;; Language servers
(use-package lsp-mode
(setq lsp-enable-xref nil)
(setq gc-cons-threshold 100000000) ;; Why? Visit:
(setq lsp-completion-provider :capf)
:hook ((js-mode . lsp))
......@@ -292,6 +302,20 @@ other, future frames."
;; Better M-x
(use-package smex)
(use-package highlight-symbol
:hook (prog-mode . highlight-symbol-mode)
(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-mode t)
......@@ -308,7 +332,14 @@ other, future frames."
;; Flycheck
(use-package flycheck
:ensure t
:init (global-flycheck-mode))
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
(flycheck-add-mode 'javascript-eslint 'web-mode)
(flycheck-add-mode 'javascript-eslint 'js-mode)
(use-package flycheck-color-mode-line
......@@ -345,6 +376,31 @@ other, future frames."
(tide-hl-identifier-mode +1)
(company-mode +1)))
;; Javascript
(setq js-indent-level 2)
(use-package tern
(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)
(eslint (and root
(expand-file-name "node_modules/eslint/bin/eslint.js"
(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
(use-package auctex
: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