Skip to content

Instantly share code, notes, and snippets.

@shakdwipeea
Created March 17, 2019 09:41
Show Gist options
  • Select an option

  • Save shakdwipeea/17bd7921391855a4f7933331826b3c53 to your computer and use it in GitHub Desktop.

Select an option

Save shakdwipeea/17bd7921391855a4f7933331826b3c53 to your computer and use it in GitHub Desktop.
my emacs init file
;;; init.el -- Config
;;; Commentary:
;;; custom Emacs config
;;; Code:
(let ((bootstrap-file (concat user-emacs-directory "straight/repos/straight.el/bootstrap.el"))
(bootstrap-version 3))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(defun install-packages (packages)
"Install PACKAGES from melpa."
(mapcar (lambda (x) (straight-use-package x)) packages))
(straight-use-package
'(slime-repl-ansi-color :type git :host github :repo "enriquefernandez/slime-repl-ansi-color"))
(straight-use-package
'(spot4e :type git :host github :repo "chiply/spot4e"))
(install-packages '(magit smartparens smart-mode-line
ivy projectile counsel-projectile clojars
rainbow-delimiters pretty-mode aggressive-indent color-theme
color-theme-solarized multiple-cursors highlight-symbol doom-themes company
projectile py-autopep8 company-jedi flycheck flycheck-color-mode-line geiser
haskell-mode intero rust-mode flycheck flycheck-rust flycheck-inline cargo
racer company emojify unicode-fonts emoticons cider sesman
auto-complete restclient js2-mode json-mode web-mode scheme-complete
spotify spot4e sly))
;; spotify
(require 'spotify)
;; Settings
(setq spotify-oauth2-client-secret "")
(setq spotify-oauth2-client-id "")
;; Updates the mode line every second (set to 0 to disable this feature)
(setq spotify-mode-line-refresh-interval 1)
(require 'emoticons)
;; autocomplete everywhere
(require 'ivy)
;; enable ivy everywhere
(ivy-mode 1)
;; multi cursorp
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
;; magit-status
(global-set-key (kbd "C-h") 'magit-status)
;; some default configruation
(setq ivy-use-virtual-buffers t)
(setq ivy-count-format "(%d/%d) ")
(projectile-mode +1)
(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
;; projectile-mode with ivy
(counsel-projectile-mode)
;; smart parens
(require 'smartparens-config)
(global-set-key (kbd "<C-right>") 'sp-forward-slurp-sexp)
(global-set-key (kbd "<C-left>") 'sp-forward-barf-sexp)
(require 'pretty-mode)
(global-pretty-mode t);; clojure mode hooks
(add-hook 'clojure-mode-hook #'smartparens-strict-mode)
(add-hook 'clojure-mode-hook #'rainbow-delimiters-mode)
(add-hook 'clojure-mode-hook #'prettify-symbols-mode)
(add-hook 'clojure-mode-hook #'aggressive-indent-mode)
(add-hook 'clojure-mode-hook #'highlight-symbol-mode)
(add-hook 'after-init-hook 'global-company-mode)
(add-hook 'cider-repl-mode-hook #'cider-company-enable-fuzzy-completion)
(add-hook 'cider-mode-hook #'cider-company-enable-fuzzy-completion)
(show-smartparens-global-mode t)
(smartparens-global-strict-mode t)
(setq package-enable-at-startup nil)
(package-initialize)
(require 'doom-themes)
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
;; Load the theme (doom-one, doom-molokai, etc); keep in mind that each theme
;; may have their own settings.
(load-theme 'doom-one t)
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
;; Enable custom neotree theme (all-the-icons must be installed!)
(doom-themes-neotree-config)
;; or for treemacs users
(doom-themes-treemacs-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config)
(tool-bar-mode -1)
(menu-bar-mode -1)
;; python
(defun company-jedi-setup ()
(add-to-list 'company-backends 'company-jedi))
(add-hook 'python-mode-hook 'company-jedi-setup)
(setq jedi:setup-keys t)
(setq jedi:complete-on-dot t)
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi-custom-file (expand-file-name "jedi-custom.el" user-emacs-directory))
(when (file-exists-p jedi-custom-file)
(load jedi-custom-file))
(setq
python-shell-interpreter "ipython"
python-shell-interpreter-args "-i")
(add-hook 'after-init-hook 'global-flycheck-mode)
(setq flycheck-display-errors-function #'flycheck-display-error-messages-unless-error-list)
(require 'flycheck-color-mode-line)
(eval-after-load "flycheck"
'(add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode))
(require 'py-autopep8)
(add-hook 'python-mode-hook 'py-autopep8-enable-on-save)
(add-hook 'haskell-mode-hook 'intero-mode)
(require 'ansi-color)
(defun display-ansi-colors ()
(interactive)
(ansi-color-apply-on-region (point-min) (point-max)))
(defun colorize-compilation-buffer ()
(toggle-read-only)
(ansi-color-apply-on-region (point-min) (point-max))
(toggle-read-only))
(add-hook 'compilation-filter-hook 'colorize-compilation-buffer)
;;;;;;;;;;;;;;;;;;;;;;;
;; Common lisp setup ;;
;;;;;;;;;;;;;;;;;;;;;;;
(add-to-list 'exec-path "/usr/bin")
;; (load (expand-file-name "~/quicklisp/slime-helper.el"))
(setq inferior-lisp-program "/usr/bin/sbcl")
;; (setq inferior-lisp-program "/usr/local/bin/ecl")
;; (setq slime-contribs '(slime-fancy))
;; (require 'ac-slime)
;; (add-hook 'slime-mode-hook 'set-up-slime-ac)
;; (add-hook 'slime-repl-mode-hook 'set-up-slime-ac)
;; (eval-after-load "auto-complete"
;; '(add-to-list 'ac-modes 'slime-repl-mode))
;; (add-hook 'slime-mode-hook #'smartparens-strict-mode)
;; (add-hook 'slime-mode-hook #'rainbow-delimiters-mode)
;; (add-hook 'slime-mode-hook #'prettify-symbols-mode)
;; (add-hook 'slime-mode-hook #'aggressive-indent-mode)
;; (add-hook 'slime-mode-hook #'highlight-symbol-mode)
;; rust
(setq rust-format-on-save t)
(with-eval-after-load 'rust-mode
(add-hook 'flycheck-mode-hook #'flycheck-rust-setup))
(add-hook 'rust-mode-hook 'cargo-minor-mode)
(add-hook 'rust-mode-hook #'racer-mode)
(add-hook 'racer-mode-hook #'eldoc-mode)
;; autocompletions
(add-hook 'racer-mode-hook #'company-mode)
(require 'rust-mode)
(define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common)
(setq company-tooltip-align-annotations t)
(with-eval-after-load 'flycheck
(flycheck-inline-mode))
(add-hook 'after-init-hook #'global-emojify-mode)
(eval-after-load 'scheme
'(define-key scheme-mode-map "\t" 'scheme-complete-or-indent))
(autoload 'scheme-get-current-symbol-info "scheme-complete" nil t)
(add-hook 'scheme-mode-hook
(lambda ()
(make-local-variable 'eldoc-documentation-function)
(setq eldoc-documentation-function 'scheme-get-current-symbol-info)
(eldoc-mode)))
(defun racket-doc ()
"Searches docs.racket-lang.org for SYMBOL, which is by default
the symbol currently under the cursor."
(interactive)
(let* ((word-at-point (word-at-point))
(symbol-at-point (symbol-at-point))
(default (symbol-name symbol-at-point))
(inp (read-from-minibuffer
(if (or word-at-point symbol-at-point)
(concat "Symbol (default " default "): ")
"Symbol (no default): "))))
(if (and (string= inp "")
(not word-at-point)
(not symbol-at-point))
(message "you didn't enter a symbol!")
(browse-url
(concat "http://docs.racket-lang.org/search/index.html?q="
(if (string= inp "")
default
inp))))))
;; (setq lisp-indent-function 'scheme-smart-indent-function)
(global-set-key (kbd "C-k") 'insert-parentheses)
(prefer-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
;; (set-terminal-coding-system 'utf-8)
;; (set-keyboard-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)
(unicode-fonts-setup)
;; toolbar
(tool-bar-mode -1)
(setq frame-title-format "")
;; transparency
(defun toggle-transparency ()
(interactive)
(let ((alpha (frame-parameter nil 'alpha)))
(set-frame-parameter
nil 'alpha
(if (eql (cond ((numberp alpha) alpha)
((numberp (cdr alpha)) (cdr alpha))
;; Also handle undocumented (<active> <inactive>) form.
((numberp (cadr alpha)) (cadr alpha)))
100)
'(75 . 50) '(100 . 100)))))
(global-set-key (kbd "C-c t") 'toggle-transparency)
;; javascript
;; use web-mode for .jsx files
(add-to-list 'auto-mode-alist '("\\.jsx$" . web-mode))
;; http://www.flycheck.org/manual/latest/index.html
(require 'flycheck)
;; turn on flychecking globally
(add-hook 'after-init-hook #'global-flycheck-mode)
;; disable jshint since we prefer eslint checking
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
'(javascript-jshint)))
;; use eslint with web-mode for jsx files
(flycheck-add-mode 'javascript-eslint 'web-mode)
;; customize flycheck temp file prefix
(setq-default flycheck-temp-prefix ".flycheck")
;; disable json-jsonlist checking for json files
(setq-default flycheck-disabled-checkers
(append flycheck-disabled-checkers
'(json-jsonlist)))
;; use local eslint from node_modules before global
;; http://emacs.stackexchange.com/questions/21205/flycheck-with-file-relative-eslint-executable
(defun my/use-eslint-from-node-modules ()
(let* ((root (locate-dominating-file
(or (buffer-file-name) default-directory)
"node_modules"))
(eslint (and root
(expand-file-name "node_modules/eslint/bin/eslint.js"
root))))
(when (and eslint (file-executable-p eslint))
(setq-local flycheck-javascript-eslint-executable eslint))))
(add-hook 'flycheck-mode-hook #'my/use-eslint-from-node-modules)
;; tmp files
;; store all backup and autosave files in the tmp dir
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
(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 (:height 132 :family "Roboto Mono for Powerline" :foundry "simp" :slant normal :weight normal :width normal)))))
(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.
'(cider-jack-in-auto-inject-clojure (quote (quote latest)))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment