Advertisement
Guest User

Untitled

a guest
May 2nd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 11.75 KB | None | 0 0
  1. ;;; .emacs.el -- Emacs configuration file.
  2.  
  3. ;;; Commentary:
  4.  
  5. ;;; Code:
  6. (require 'package)
  7. (let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
  8.                     (not (gnutls-available-p))))
  9.        (proto (if no-ssl "http" "https")))
  10.   ;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired
  11.   (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t)
  12.   ;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t)
  13.   (when (< emacs-major-version 24)
  14.     ;; For important compatibility libraries like cl-lib
  15.     (add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/")))))
  16. (package-initialize)
  17.  
  18. ;; TODO add the rest of the packages to this list
  19. (defvar my-packages '(better-defaults
  20.                       projectile
  21.                       clojure-mode
  22.                       cider))
  23.  
  24. (dolist (p my-packages)
  25.   (unless (package-installed-p p)
  26.     (package-install p)))
  27.  
  28. (custom-set-variables
  29.  ;; custom-set-variables was added by Custom.
  30.  ;; If you edit it by hand, you could mess it up, so be careful.
  31.  ;; Your init file should contain only one such instance.
  32.  ;; If there is more than one, they won't work right.
  33.  '(company-quickhelp-color-background "#4F4F4F")
  34.  '(company-quickhelp-color-foreground "#DCDCCC")
  35.  '(custom-enabled-themes (quote (spacemacs-dark)))
  36.  '(custom-safe-themes
  37.    (quote
  38.     ("ec5f697561eaf87b1d3b087dd28e61a2fc9860e4c862ea8e6b0b77bd4967d0ba" "f71859eae71f7f795e734e6e7d178728525008a28c325913f564a42f74042c31" "bffa9739ce0752a37d9b1eee78fc00ba159748f50dc328af4be661484848e476" default)))
  39.  '(fci-rule-color "#383838")
  40.  '(nrepl-message-colors
  41.    (quote
  42.     ("#CC9393" "#DFAF8F" "#F0DFAF" "#7F9F7F" "#BFEBBF" "#93E0E3" "#94BFF3" "#DC8CC3")))
  43.  '(package-selected-packages
  44.    (quote
  45.     (jedi-direx jedi python-mode js-comint paredit parinfer use-package htmlize org-link-minor-mode elcord telephone-line smart-tabs-mode cider projectile better-defaults clojure-mode zenburn-theme challenger-deep-theme haskell-mode neotree web-mode json-mode flycheck js2-mode spaceline spacemacs-theme)))
  46.  '(vc-annotate-background "#2B2B2B")
  47.  '(vc-annotate-color-map
  48.    (quote
  49.     ((20 . "#BC8383")
  50.      (40 . "#CC9393")
  51.      (60 . "#DFAF8F")
  52.      (80 . "#D0BF8F")
  53.      (100 . "#E0CF9F")
  54.      (120 . "#F0DFAF")
  55.      (140 . "#5F7F5F")
  56.      (160 . "#7F9F7F")
  57.      (180 . "#8FB28F")
  58.      (200 . "#9FC59F")
  59.      (220 . "#AFD8AF")
  60.      (240 . "#BFEBBF")
  61.      (260 . "#93E0E3")
  62.      (280 . "#6CA0A3")
  63.      (300 . "#7CB8BB")
  64.      (320 . "#8CD0D3")
  65.      (340 . "#94BFF3")
  66.      (360 . "#DC8CC3"))))
  67.  '(vc-annotate-very-old-color "#DC8CC3"))
  68. (custom-set-faces
  69.  ;; custom-set-faces was added by Custom.
  70.  ;; If you edit it by hand, you could mess it up, so be careful.
  71.  ;; Your init file should contain only one such instance.
  72.  ;; If there is more than one, they won't work right.
  73.  )
  74.  ;; custom-set-faces was added by Custom.
  75.  ;; If you edit it by hand, you could mess it up, so be careful.
  76.  ;; Your init file should contain only one such instance.
  77.  ;; If there is more than one, they won't work right.
  78.  
  79.  
  80. (setq inhibit-startup-screen t)
  81. (menu-bar-mode 0)
  82. (tool-bar-mode 0)
  83. (scroll-bar-mode 0)
  84. (setq-default tab-width 2)
  85. (when (version<= "26.0.50" emacs-version)
  86.   (global-display-line-numbers-mode))
  87. (setq ring-bell-function 'ignore)
  88. (require 'ido)
  89. (ido-mode t)
  90.  
  91. (setq backup-directory-alist `(("." . "~/.saves")))
  92. (setq backup-by-copying t)
  93.  
  94. ;;(require 'spaceline-config)
  95. ;; (spaceline-spacemacs-theme)
  96.  
  97. (require 'telephone-line)
  98. (setq telephone-line-primary-left-separator 'telephone-line-cubed-left
  99.       telephone-line-secondary-left-separator 'telephone-line-cubed-hollow-left
  100.       telephone-line-primary-right-separator 'telephone-line-cubed-right
  101.       telephone-line-secondary-right-separator 'telephone-line-cubed-hollow-right)
  102. (setq telephone-line-height 24
  103.       telephone-line-evil-use-short-tag t)
  104. (telephone-line-mode 1)
  105.  
  106. ;;(require 'smart-tabs-mode)
  107. ;; (smart-tabs-insinuate 'javascript)
  108. (setq-default indent-tabs-mode nil)
  109.  
  110. (require 'js2-mode)
  111. (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
  112. (add-to-list 'interpreter-mode-alist '("node" . js2-mode))
  113.  
  114. ;; use web-mode for .js and .jsx files
  115. (add-to-list 'auto-mode-alist '("\\.jsx$" . web-mode))
  116. ;;(add-to-list 'auto-mode-alist '("\\.js$" . web-mode))
  117.  
  118. ;; http://www.flycheck.org/manual/latest/index.html
  119. (require 'flycheck)
  120.  
  121. ;; turn on flychecking globally
  122. (add-hook 'after-init-hook #'global-flycheck-mode)
  123. (global-flycheck-mode)
  124.  
  125. ;; disable jshint since we prefer eslint checking
  126. (setq-default flycheck-disabled-checkers
  127.               (append flycheck-disabled-checkers
  128.                       '(javascript-jshint)))
  129.  
  130. ;; use eslint with web-mode for js and jsx files
  131. (flycheck-add-mode 'javascript-eslint 'web-mode)
  132.  
  133. ;; customize flycheck temp file prefix
  134. (setq-default flycheck-temp-prefix ".flycheck")
  135.  
  136. ;; disable json-jsonlist checking for json files
  137. (setq-default flycheck-disabled-checkers
  138.   (append flycheck-disabled-checkers
  139.     '(json-jsonlist)))
  140.  
  141. ;; use local eslint from node_modules before global
  142. ;; http://emacs.stackexchange.com/questions/21205/flycheck-with-file-relative-eslint-executable
  143. (defun my/use-eslint-from-node-modules ()
  144.   (let* ((root (locate-dominating-file
  145.                 (or (buffer-file-name) default-directory)
  146.                 "node_modules"))
  147.          (eslint (and root
  148.                       (expand-file-name "node_modules/eslint/bin/eslint.js"
  149.                                         root))))
  150.     (when (and eslint (file-executable-p eslint))
  151.       (setq-local flycheck-javascript-eslint-executable eslint))))
  152. (add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)
  153.  
  154. ;; adjust indents for web-mode to 2 spaces
  155. (defun my-web-mode-hook ()
  156.   "Hooks for Web mode.  Adjust indent."
  157.   ;;; http://web-mode.org/
  158.   (setq web-mode-markup-indent-offset 2)
  159.   (setq web-mode-css-indent-offset 2)
  160.   (setq web-mode-code-indent-offset 2))
  161. (add-hook 'web-mode-hook  'my-web-mode-hook)
  162.  
  163. ;; for better jsx syntax-highlighting in web-mode
  164. ;; - courtesy of Patrick @halbtuerke
  165. (defadvice web-mode-highlight-part (around tweak-jsx activate)
  166.   (if (or (equal web-mode-content-type "jsx") (equal web-mode-content-type "js"))
  167.     (let ((web-mode-enable-part-face nil))
  168.       ad-do-it)
  169.     ad-do-it))
  170.  
  171. ;;; runs eslint --fix on the current file after save
  172. ;;; alpha quality -- use at your own risk
  173.  
  174. (defun eslint-fix-file ()
  175.   (interactive)
  176.   (message "eslint --fixing the file" (buffer-file-name))
  177.   (shell-command (concat "eslint --fix " (buffer-file-name))))
  178.  
  179. (defun eslint-fix-file-and-revert ()
  180.   (interactive)
  181.   (eslint-fix-file)
  182.   (revert-buffer t t))
  183.  
  184. (add-hook 'js2-mode-hook
  185.           (lambda ()
  186.             (add-hook 'after-save-hook #'eslint-fix-file-and-revert)))
  187.  
  188. (require 'neotree)
  189. (global-set-key [f8] 'neotree-toggle)
  190.  
  191. ;; Haskell setup
  192. (require 'haskell-mode)
  193. (require 'haskell-interactive-mode)
  194. (require 'haskell-process)
  195. (add-hook 'haskell-mode-hook 'interactive-haskell-mode)
  196.  
  197. ;; Keybindings for Haskell
  198. (define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-or-reload)
  199. (define-key haskell-mode-map (kbd "C-`") 'haskell-interactive-bring)
  200. (define-key haskell-mode-map (kbd "C-c C-t") 'haskell-process-do-type)
  201. (define-key haskell-mode-map (kbd "C-c C-i") 'haskell-process-do-info)
  202. (define-key haskell-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build)
  203. (define-key haskell-mode-map (kbd "C-c C-k") 'haskell-interactive-mode-clear)
  204. (define-key haskell-mode-map (kbd "C-c c") 'haskell-process-cabal)
  205.  
  206. ;; elcord
  207. (require 'elcord)
  208. (elcord-mode)
  209.  
  210. ;; Org-mode
  211.  
  212. (require 'org)
  213.  
  214. ;; The following lines are always needed.  Choose your own keys.
  215. (global-set-key "\C-cl" 'org-store-link)
  216. (global-set-key "\C-ca" 'org-agenda)
  217. (global-set-key "\C-cc" 'org-capture)
  218. (global-set-key "\C-cb" 'org-switchb)
  219.  
  220. ;; HTML export stuff
  221. (setq browse-url-browser-function 'browse-url-generic
  222.       browse-url-generic-program "firefox")
  223.  
  224. (setenv "BROWSER" "firefox")
  225.  
  226.  
  227. ;; Latex export stuff
  228.  
  229. (setq org-latex-listings '('minted 'hyperref))
  230.  
  231. (require 'ox-latex)
  232. (add-to-list 'org-latex-packages-alist '("" "minted" "" "hyperref"))
  233.  
  234. (unless (boundp 'org-latex-classes)
  235.   (setq org-latex-classes nil))
  236. (add-to-list 'org-latex-classes
  237.              '("article"
  238.                "\\documentclass{article}"
  239.                ("\\section{%s}" . "\\section*{%s}")))
  240.  
  241. ;; prolog
  242. (add-to-list 'auto-mode-alist '("\\.pl\\'" . prolog-mode))
  243.  
  244. ;; use-package
  245. (require 'use-package)
  246.  
  247. ;; parinfer
  248.  
  249. (use-package parinfer
  250.   :ensure t
  251.   :bind
  252.   (("C-," . parinfer-toggle-mode))
  253.   :init
  254.   (progn
  255.     (setq parinfer-extensions
  256.           '(defaults       ; should be included.
  257.              pretty-parens  ; different paren styles for different modes.
  258.                                         ; evil           ; If you use Evil.
  259.                                         ; lispy          ; If you use Lispy. With this extension, you should install Lispy and do not enable lispy-mode directly.
  260.              paredit        ; Introduce some paredit commands.
  261.              smart-tab      ; C-b & C-f jump positions and smart shift with tab & S-tab.
  262.              smart-yank))   ; Yank behavior depend on mode.
  263.     (add-hook 'clojure-mode-hook #'parinfer-mode)
  264.     (add-hook 'emacs-lisp-mode-hook #'parinfer-mode)
  265.     (add-hook 'common-lisp-mode-hook #'parinfer-mode)
  266.     (add-hook 'scheme-mode-hook #'parinfer-mode)
  267.     (add-hook 'lisp-mode-hook #'parinfer-mode)))
  268.  
  269. (require 'js-comint)
  270. (setq inferior-js-program-command "/usr/bin/java org.mozilla.javascript.tools.shell.Main")
  271. (add-hook 'js2-mode-hook '(lambda ()
  272.                             (local-set-key (kbd "C-x C-e") 'js-send-last-sexp)
  273.                             (local-set-key "\C-\M-x" 'js-send-last-sexp-and-go)
  274.                             (local-set-key (kbd "C-c b") 'js-send-buffer)
  275.                             (local-set-key "\C-c\C-b" 'js-send-buffer-and-go)
  276.                             (local-set-key "\C-cl" 'js-load-file-and-go)))
  277.  
  278. (defun inferior-js-mode-hook-setup ()
  279.   "Cleaner node.js output."
  280.   (add-hook 'comint-output-filter-functions 'js-comint-process-output))
  281. (add-hook 'inferior-js-mode-hook 'inferior-js-mode-hook-setup t)
  282.  
  283. (global-set-key (kbd "<S-tab>") 'un-indent-by-removing-4-spaces)
  284. (defun un-indent-by-removing-4-spaces ()
  285.   "Remove 4 spaces from beginning of of line."
  286.   (interactive)
  287.   (save-excursion
  288.     (save-match-data
  289.       (beginning-of-line)
  290.       ;; get rid of tabs at beginning of line
  291.       (when (looking-at "^\\s-+")
  292.         (untabify (match-beginning 0) (match-end 0)))
  293.       (when (looking-at "^    ")
  294.         (replace-match "")))))
  295.  
  296. ;; Flycheck clojure
  297. ;;(require 'flycheck-clojure)
  298. ;;(eval-after-load 'flycheck '(flycheck-clojure-setup))
  299. ;;(add-hook 'after-init-hook #'global-flycheck-mode)
  300.  
  301. ;; Flycheck pos tip
  302. ;; (require 'flycheck-pos-tip)
  303. ;; (eval-after-load 'flycheck
  304. ;;  '(setq flycheck-display-errors-function #'flycheck-pos-tip-error-messages))
  305.  
  306. (require 'python-mode)
  307. (setq py-install-directory "/usr/bin/python3")
  308. (add-to-list 'load-path py-install-directory)
  309. (defun MY-LOCAL-SHELL ()
  310.   "Start interactive shell."
  311.   (interactive)
  312.   (py-shell nil py-install-directory))
  313.  
  314. (defun load-into-py-shell ()
  315.   "Start interactive shell with file loaded."
  316.   (interactive)
  317.   (py-shell-send-file buffer-file-name))
  318.  
  319. (define-key python-mode-map (kbd "C-c C-l") 'load-into-py-shell)
  320.  
  321. ;; Load jedi auto-complete for python
  322. (require 'jedi)
  323. (add-hook 'python-mode-hook 'jedi:setup)
  324. (setq jedi:environment-virtualenv nil)
  325. (setq jedi:complete-on-dot t)
  326.  
  327. (setq-local flycheck-python-pylint-executable "python3")
  328.  
  329. (global-eldoc-mode t)
  330.  
  331. (setq create-lockfiles nil)
  332.  
  333. (provide '.emacs)
  334. ;;; .emacs ends here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement