Skip to content

Instantly share code, notes, and snippets.

@surajitbasak109
Created March 3, 2020 21:57
Show Gist options
  • Save surajitbasak109/e98bb9400fcf1f2ebd615e56f50168e7 to your computer and use it in GitHub Desktop.
Save surajitbasak109/e98bb9400fcf1f2ebd615e56f50168e7 to your computer and use it in GitHub Desktop.
;;; .emacs --- Surajit Basak
;;; Commentary:
;; This file contains my Emacs configation
;;
;;; Code:
(require 'package)
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
;; Evil Mode
(require 'evil)
(evil-mode 1)
;;Exit insert mode by pressing j and then j quickly
(setq key-chord-two-keys-delay 0.5)
(key-chord-define evil-insert-state-map "jk" 'evil-normal-state)
(key-chord-mode 1)
(with-eval-after-load 'evil-maps
(define-key evil-normal-state-map (kbd "o") 'evil-end-of-line))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-faces-vector
[default default default italic underline success warning error])
'(display-battery-mode t)
'(global-display-line-numbers-mode t)
'(package-selected-packages
(quote
(evil company-ycmd company-tern tide company emmet-mode add-node-modules-path flycheck ##))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:family "Fira Code" :foundry "CTDB" :slant normal :weight normal :height 98 :width normal)))))
(add-to-list 'load-path "~/.emacs.d/lisp/")
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.jsx?$" . web-mode)) ;; auto-enable for .js/.jsx files
(setq web-mode-content-types-alist '(("jsx" . "\\.js[x]?\\'")))
(defun web-mode-init-hook ()
"Hooks for Web mode. Adjust indent."
(setq web-mode-markup-indent-offset 4))
(add-hook 'web-mode-hook 'web-mode-init-hook)
(add-hook 'flycheck-mode-hook 'add-node-modules-path)
(add-hook 'web-mode-hook 'emmet-mode)
(add-hook 'after-init-hook 'global-company-mode)
(add-hook 'js-mode-hook 'prettier-js-mode)
(setq prettier-js-args '(
"--trailing-comma" "none"
"--bracket-spacing" "true"
"--single-quote" "true"
"--no-semi" "true"
"--jsx-single-quote" "true"
"--jsx-bracket-same-line" "true"
"--print-width" "100"))
(defun setup-tide-mode ()
(interactive)
(tide-setup)
(flycheck-mode +1)
(setq flycheck-check-syntax-automatically '(save mode-enabled))
(eldoc-mode +1)
(tide-hl-identifier-mode +1)
;; company is an optional dependency. You have to
;; install it separately via package-install
;; `M-x package-install [ret] company`
(company-mode +1))
;; aligns annotation to the right hand side
(setq company-tooltip-align-annotations t)
;; formats the buffer before saving
(add-hook 'before-save-hook 'tide-format-before-save)
(add-hook 'typescript-mode-hook #'setup-tide-mode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment