Skip to content

Instantly share code, notes, and snippets.

@svapreddy
Created January 28, 2018 09:17
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 svapreddy/4897e897fe8e3a1314142cf45b627e3f to your computer and use it in GitHub Desktop.
Save svapreddy/4897e897fe8e3a1314142cf45b627e3f to your computer and use it in GitHub Desktop.
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(proto (if no-ssl "http" "http")))
;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
;;(add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . (concat proto "://elpa.gnu.org/packages/")))))
(package-initialize)
(unless (package-installed-p 'js2-mode)
(package-install 'js2-mode))
(require 'js2-mode)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
;; Better imenu
(add-hook 'js2-mode-hook #'js2-imenu-extras-mode)
(unless (package-installed-p 'js2-refactor)
(package-install 'js2-refactor))
(unless (package-installed-p 'xref-js2)
(package-install 'xref-js2))
(require 'js2-refactor)
(require 'xref-js2)
(add-hook 'js2-mode-hook #'js2-refactor-mode)
(js2r-add-keybindings-with-prefix "C-c C-r")
(define-key js2-mode-map (kbd "C-k") #'js2r-kill)
;; js-mode (which js2 is based on) binds "M-." which conflicts with xref, so
;; unbind it.
(define-key js-mode-map (kbd "M-.") nil)
(add-hook 'js2-mode-hook (lambda ()
(add-hook 'xref-backend-functions #'xref-js2-xref-backend nil t)))
(define-key js2-mode-map (kbd "C-k") #'js2r-kill)
(require 'company)
(require 'company-tern)
(unless (package-installed-p 'company)
(package-install 'company))
(unless (package-installed-p 'company-tern)
(package-install 'indium-tern))
(add-to-list 'company-backends 'company-tern)
(add-hook 'js2-mode-hook (lambda ()
(tern-mode)
(company-mode)))
;; Disable completion keybindings, as we use xref-js2 instead
(define-key tern-mode-keymap (kbd "M-.") nil)
(define-key tern-mode-keymap (kbd "M-,") nil)
(unless (package-installed-p 'indium)
(package-install 'indium))
(require 'indium)
(unless (package-installed-p 'web-mode)
(package-install 'web-mode))
(require 'web-mode)
(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.cacho\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.css\\'" . web-mode))
(add-to-list 'auto-mode-alist '("\\.scss\\'" . web-mode))
(setq web-mode-engines-alist
'(("css" . "\\.css\\'")
("underscorejs" . "\\.cacho\\.")
("html" . "\\.html\\."))
)
(add-hook 'before-save-hook 'web-mode-buffer-indent)
(setq web-mode-enable-auto-pairing t)
(setq web-mode-enable-css-colorization t)
(local-set-key (kbd "RET") 'newline-and-indent)
(require 'vimish-fold)
(global-set-key (kbd "C->") #'vimish-fold)
(global-set-key (kbd "C-<") #'vimish-fold-delete)
(vimish-fold-global-mode 1)
;; Setup Fuzzy
(unless (package-installed-p 'find-file-in-repository)
(package-install 'find-file-in-repository))
(require 'find-file-in-repository)
(unless (package-installed-p 'ido)
(package-install 'ido))
(require 'ido)
(unless (package-installed-p 'ido-completing-read+)
(package-install 'ido-completing-read+))
(require 'ido-completing-read+)
(unless (package-installed-p 'ido-vertical-mode)
(package-install 'ido-vertical-mode))
(require 'ido-vertical-mode)
(global-set-key (kbd "C-x f") 'find-file-in-repository)
(ido-mode 1)
(ido-everywhere 1)
(ido-ubiquitous-mode 1)
(ido-vertical-mode)
(setq ido-vertical-define-keys 'C-n-C-p-up-down-left-right)
;; Recent files
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)
(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.
'(package-selected-packages
(quote
(ido-vertical-mode ido-ubiquitous find-file-in-repository web-mode-edit-element indium company-tern xref-js2 js2-refactor js2-mode))))
(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.
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment