Created
August 27, 2014 06:26
-
-
Save ashishnegi/e1fdd7d3f5e20060de8f to your computer and use it in GitHub Desktop.
.emacs file for problem http://stackoverflow.com/questions/25520073/javascript-environment-in-emacs
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) | |
(when (not package-archive-contents) | |
(package-refresh-contents)) | |
(defvar my-packages '(pkg-info clojure-mode | |
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) | |
(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 120) | |
(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) | |
;; now enable the yasnippet for snippets | |
(yas-global-mode 1) | |
;; 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 | |
)) | |
(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 | |
(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))) | |
;; 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") | |
(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 ".*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)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment