Created
October 22, 2014 13:54
-
-
Save ashishnegi/10ea139b0468c631b856 to your computer and use it in GitHub Desktop.
Emacs where javascript works great :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setq inhibit-startup-message t) | |
(switch-to-buffer "*scratch*") | |
;(global-linum-mode) | |
(global-set-key (kbd "\C-x c") 'clipboard-kill-ring-save) | |
(global-set-key (kbd "\C-x p") 'clipboard-yank) | |
(setq make-backup-files t) | |
(setq version-control t) | |
(setq backup-directory-alist (quote ((".*" . "~/.emacs.d/.emacs_backups/")))) | |
(savehist-mode 1) | |
(setq savehist-additional-variables '(kill-ring search-ring regexp-search-ring)) | |
(setq save-place-file "~/.emacs.d/saveplace") | |
(setq-default save-place t) | |
(setq desktop-save-mode t) | |
(cua-selection-mode t) | |
(require 'package) | |
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t) | |
;; (require 'package) | |
(add-to-list 'package-archives | |
'("marmalade" . "http://marmalade-repo.org/packages/")) | |
(package-initialize) | |
(add-to-list 'package-archives | |
'("melpa" . "http://melpa.milkbox.net/packages/") t) | |
(when (not package-archive-contents) | |
(package-refresh-contents)) | |
;; make list of clojure must-have packages. | |
(defvar my-packages '(pkg-info | |
clojure-mode | |
nrepl | |
nrepl-ritz | |
cider)) | |
(dolist (p my-packages) | |
(when (not (package-installed-p p)) | |
(package-install p))) | |
(autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t) | |
(add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode) | |
(add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode) | |
(add-hook 'ielm-mode-hook #'enable-paredit-mode) | |
(add-hook 'lisp-mode-hook #'enable-paredit-mode) | |
(add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode) | |
(add-hook 'scheme-mode-hook #'enable-paredit-mode) | |
;; Useful global settings as Emacs is used predominantely for Clojure development | |
;; Launch the Clojure repl via Leiningen - M-x clojure-jack-in | |
;; Global shortcut definition to fire up clojure repl and connect to it | |
(global-set-key (kbd "C-c C-j") 'cider-jack-in) | |
;; hook the nrepl with the ritz or vice-versa | |
(add-hook 'nrepl-interaction-mode-hook 'my-nrepl-mode-setup) | |
(defun my-nrepl-mode-setup () | |
(require 'nrepl-ritz)) | |
(add-to-list 'load-path "~/.emacs.d/") | |
(require 'dirtree) | |
;// save the desktop restart at last close state | |
(desktop-save-mode 1) | |
;// save history of the termincal | |
(savehist-mode 1) | |
;// load the solarized light or dark theme | |
;; (load-theme 'solarized-dark t) | |
;// set font size | |
(set-face-attribute 'default nil :height 130) | |
(global-linum-mode t) | |
;// auto complete feature | |
(require 'auto-complete-config) | |
(ac-config-default) | |
(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict") | |
;; added for javascript ------- | |
; Use dictionaries by default | |
(setq-default ac-sources (add-to-list 'ac-sources 'ac-source-dictionary)) | |
(global-auto-complete-mode t) | |
; Start auto-completion after 2 characters of a word | |
(setq ac-auto-start 2) | |
; case sensitivity is important when finding matches | |
(setq ac-ignore-case nil) | |
(require 'yasnippet) | |
;; set the snippets directory | |
(setq yas-snippet-dirs | |
'( "~/.emacs.d/plugins_old/yasnippet/yasmate/snippets" ;; the yasmate collection | |
"~/.emacs.d/plugins_old/yasnippet/snippets" ;; the snippet collection | |
"~/.emacs.d/elpa/yasnippet/snippets" ;; the default collection | |
)) | |
;; Load the snippet files themselves | |
;; (yas-load-directory "~/.emacs.d/plugins_old/yasnippet/snippets/js-mode/") | |
;; now enable the yasnippet for snippets | |
(yas-global-mode 1) | |
;; no need to do this now. :) | |
;;(yas-reload-all) | |
;;(ac-set-trigger-key "TAB") | |
;;(ac-set-trigger-key "<tab>") | |
;; (define-key yas-minor-mode-map (kbd "TAB") 'yas-expand) | |
;; (define-key yas-minor-mode-map (kbd "<tab>") 'yas-expand) | |
;; (setq yas-trigger-key "") | |
;; (setq yas-next-field-key "") | |
;; (setq yas-prev-field-key "") | |
;; Let's have snippets in the auto-complete dropdown | |
(add-to-list 'ac-sources 'ac-source-yasnippet) | |
;; adding lint node | |
;; (add-to-list 'load-path "~/.emacs.d/plugins_old/lintnode") | |
;; finally followed this : http://www.emacswiki.org/emacs/FlymakeJavaScript to install jslint in emacs | |
;; ;; TRYING Flycheck jshint | |
;; (require 'flymake-jslint) | |
;; (add-hook 'js-mode-hook 'flymake-jslint-load) | |
;; Make sure we can find the lintnode executable | |
;; (setq lintnode-location "~/.emacs.d/plugins_old/lintnode") | |
;; JSLint can be... opinionated | |
;; (setq lintnode-jslint-excludes (list 'nomen 'undef 'plusplus 'onevar 'white)) | |
;; Start the server when we first open a js file and start checking | |
;; (add-hook 'js-mode-hook | |
;; (lambda () | |
;; (lintnode-hook))) | |
;; added red cursor for wrong lint node errors | |
;; (require 'flymake-cursor) | |
;; ;; fold the functions | |
;; ( add-hook 'js-mode-hook | |
;; (lambda () | |
;; ;; Scan the file for nested code blocks | |
;; (imenu-add-menubar-index) | |
;; ;; Activate the folding mode | |
;; (hs-minor-mode t))) | |
(require 'flycheck) | |
(add-hook 'js-mode-hook | |
(lambda () (flycheck-mode t))) | |
;; Show-hide | |
;;(global-set-key (kbd "") 'hs-show-block) | |
;;(global-set-key (kbd "") 'hs-show-all) | |
;;(global-set-key (kbd "") 'hs-hide-block) | |
;;(global-set-key (kbd "") 'hs-hide-all) | |
;; repl for javascript | |
(require 'js-comint) | |
;; Use node as our repl | |
(setq inferior-js-program-command "node --interactive") | |
(setq inferior-js-mode-hook | |
(lambda () | |
;; We like nice colors | |
(ansi-color-for-comint-mode-on) | |
;; Deal with some prompt nonsense | |
(add-to-list 'comint-preoutput-filter-functions | |
(lambda (output) | |
(replace-regexp-in-string ".*1G\.\.\..*5G" "..." | |
(replace-regexp-in-string "\033\\[[0-9]+[GK]" "" | |
(replace-regexp-in-string "[>>]" "> " (replace-regexp-in-string ".*1G.*3G" ">" output)))))))) | |
;; ----------------------------- | |
;// repl history | |
(setq cider-repl-wrap-history t) | |
;// show the port no | |
(setq nrepl-buffer-name-show-port t) | |
;// store the repl history | |
(setq cider-repl-history-file "~/.repl-history") | |
;// org mode | |
(require 'org) | |
(global-set-key "\C-cl" 'org-store-link) | |
(global-set-key "\C-cc" 'org-capture) | |
(global-set-key "\C-ca" 'org-agenda) | |
(global-set-key "\C-cb" 'org-iswitchb) | |
(setq org-log-done t) | |
;// rainbow of parenthesis in clojure | |
(require 'rainbow-delimiters) | |
;// add hook for all programming | |
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode) | |
(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 '("\\.[gj]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 '("\\.html?\\'" . web-mode)) | |
;; set the auto-complete mode in web-mode too. | |
(add-to-list 'ac-modes 'web-mode) | |
(add-to-list 'auto-mode-alist '("\\.js\\'" . js-mode)) | |
;; set up tern.js for code completion of javascript | |
;; (add-to-list 'load-path "~/gitrepos/tern/emacs/") | |
;; (autoload 'tern-mode "tern.el" nil t) | |
(add-hook 'js-mode-hook (lambda () (tern-mode t))) | |
;; TODO: also try without it | |
;; for auto complete with tern | |
(eval-after-load 'tern | |
'(progn | |
(require 'tern-auto-complete) | |
(setq tern-ac-on-dot 1) | |
(tern-ac-setup))) | |
;; delte the tern process when it becomes non-responsive | |
(defun delete-tern-process () | |
(interactive) | |
(delete-process "Tern")) | |
;; rainbow for clojure.. | |
;; taken from solarized-definitions | |
(let ( (yellow "#ffe44c") | |
(red "#ff2121") | |
(orange "#FF7F0F") | |
(green "#197C38") | |
(cyan "#93e0e3") | |
(blue "#32DDFF") | |
(navy "#7944FF") | |
(magneta "#dc8cc3") | |
(pink "#FF92BE") | |
) | |
(custom-theme-set-faces | |
'user | |
`(rainbow-delimiters-depth-1-face ((t (:foreground , red)))) | |
`(rainbow-delimiters-depth-2-face ((t (:foreground , green)))) | |
`(rainbow-delimiters-depth-3-face ((t (:foreground , blue)))) | |
`(rainbow-delimiters-depth-4-face ((t (:foreground , orange)))) | |
`(rainbow-delimiters-depth-5-face ((t (:foreground , navy)))) | |
`(rainbow-delimiters-depth-6-face ((t (:foreground , pink)))) | |
`(rainbow-delimiters-depth-7-face ((t (:foreground , red)))) | |
`(rainbow-delimiters-depth-8-face ((t (:foreground , cyan)))) | |
`(rainbow-delimiters-depth-9-face ((t (:foreground , magneta)))) | |
)) | |
(semantic-mode t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment