diff --git a/emacs/init.el b/emacs/init.el index 59ca625..afcb543 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -1,148 +1,10 @@ -(require 'package) -(setq package-enable-at-startup nil) -(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/")) -(add-to-list 'package-archives '("marmalade" . "https://marmalade-repo.org/packages/")) -(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")) -(package-initialize) +;Record startup timestamp +(defvar super-emacs/invokation-time + (current-time)) -(unless (package-installed-p 'use-package) - (package-refresh-contents) - (package-install 'use-package)) - -(use-package async - :ensure t) -(use-package dired-async - :after async - :config - (dired-async-mode 1) - (async-bytecomp-package-mode 1) - ) - - -(if (display-graphic-p) - - (if (string-equal system-type "darwin") - (setenv "PATH" (concat (getenv "PATH") ":/usr/local/bin")) - (load-theme 'ubuntu t) - ) -) -(setq inhibit-startup-screen t) - -;;add ternjs to emacs -(add-to-list 'load-path "~/DevelopmentUtils/tern/emacs/") -(autoload 'tern-mode "tern.el" nil t) - -;;auto load tern with .js files -(add-hook 'js-mode-hook (lambda () (tern-mode t))) -(global-linum-mode t) - -;;highlight brackets -(show-paren-mode 1) -(setq show-paren-delay 0) - -;;window management -(global-set-key (kbd "C-x -") 'shrink-window) -(global-set-key (kbd "C-x +") 'enlarge-window) - -(global-set-key (kbd "C-x p") 'previous-multiframe-window) -(put 'downcase-region 'disabled nil) - -;;undo -(global-set-key (kbd "C--") 'undo) - -(global-set-key (kbd "s--") 'text-scale-decrease) -(global-set-key (kbd "s-=") 'text-scale-increase) - -;;neotree -(use-package neotree - :ensure t - :bind("" . neotree-toggle) -) - - -;;Rust -(setq racer-cmd "/usr/local/bin/racer") -(setq racer-rust-src-path "/Users/grant/.rust/src/") - -(add-hook 'rust-mode-hook #'racer-mode) -(add-hook 'racer-mode-hook #'eldoc-mode) - -(add-hook 'racer-mode-hook #'company-mode) -(add-hook 'rust-mode-hook #'rust-enable-format-on-save) - -(add-hook 'rust-mode-hook 'cargo-minor-mode) - -(add-hook 'rust-mode-hook - (lambda () - (local-set-key (kbd "C-c ") #'rust-format-buffer))) - -(add-hook 'flycheck-mode-hook #'flycheck-rust-setup) - -;;Python - -;;autocomplete -(use-package company - :ensure t ) -(setq company-tooltip-align-annotations t) - -(add-hook 'after-init-hook 'global-company-mode) -(eval-after-load "company" - '(add-to-list 'company-backends 'company-anaconda)) - - -(setq company-dabbrev-downcase 0) -(setq company-idle-delay 0) -(setq company-minimum-prefix-length 2) - -(use-package py-autopep8 - :ensure t) - - -;;white space -(require 'whitespace) - (autoload 'whitespace-mode "whitespace" "Toggle whitespace visualization." t) - -(setq-default indent-tabs-mode nil) - - -(use-package magit - :ensure t) -(use-package helm - :ensure t - :diminish helm-mode - :init (progn - (require 'helm-config) - (helm-mode) - ) - :bind(("C-c h" . helm-mini) - ("C-h a" . helm-apropos) - ("C-x C-b" . helm-buffers-list) - ("C-x b" . helm-buffers-list) - ("M-y" . helm-show-kill-ring) - ("M-x" . helm-M-x) - ("C-x c o" . helm-occur) - ("C-x c s" . helm-swoop) - ("C-x c y" . helm-yas-complete) - ("C-x c Y" . helm-yas-create-snippet-on-region) - ("C-x c b" . my/helm-do-grep-book-notes) - ("C-x c SPC" . helm-all-mark-rings)) - ) - - -(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. - '(custom-safe-themes - (quote - ("3d5307e5d6eb221ce17b0c952aa4cf65dbb3fa4a360e12a71e03aab78e0176c5" default))) - '(package-selected-packages - (quote - (ubuntu-theme py-autopep8 hide-comnt terraform-mode helm-projectile 0blayout jinja2-mode company-anaconda yaml-mode markdown-mode markdown-mode+ markdownfmt swift-mode swift3-mode go-mode jq-mode web-beautify use-package tern-auto-complete rustfmt racer neotree magit json-reformat js2-highlight-vars jedi helm flymake-rust flycheck-rust csharp-mode company-jedi cargo)))) -(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. - '(font-lock-string-face ((t (:foreground "magenta"))))) +;Load configuration files +(load-file "~/.emacs.d/super-emacs/repositories.el") +(load-file "~/.emacs.d/super-emacs/packages.el") +(load-file "~/.emacs.d/super-emacs/interface.el") +(load-file "~/.emacs.d/super-emacs/misc.el") +(load-file "~/.emacs.d/super-emacs/key-bindings.el") diff --git a/emacs/super-emacs/interface.el b/emacs/super-emacs/interface.el new file mode 100644 index 0000000..71bf208 --- /dev/null +++ b/emacs/super-emacs/interface.el @@ -0,0 +1,20 @@ +;Change title-bar text +(setq frame-title-format + "super-emacs") + +;Disable menu-bar +(menu-bar-mode -1) + +;Disable tool-bar +(tool-bar-mode -1) + +;Disable scroll-bar +(scroll-bar-mode -1) + +;Activate material theme +(load-theme 'material + t) + +;Set font +(custom-set-faces + '(default ((t (:height 120))))) diff --git a/emacs/super-emacs/key-bindings.el b/emacs/super-emacs/key-bindings.el new file mode 100644 index 0000000..343154f --- /dev/null +++ b/emacs/super-emacs/key-bindings.el @@ -0,0 +1,36 @@ +(defvar super-emacs--my-keyboard-bindings + '(("C-}" . mc/mark-next-like-this) + ("C-{" . mc/mark-previous-like-this) + ("C-|" . mc/mark-all-like-this) + ("C->" . ace-jump-mode) + ("C-<" . ace-jump-mode-pop-mark) + ("M-/" . undo-tree-visualize) + ("C-\," . neotree-toggle) + ("C-\"" . theme-looper-enable-next-theme) + ("C-M-'" . myterminal-controls-open-controls) + ("C-c M-x" . execute-extended-command) + ("M-x" . helm-M-x) + ("C-x b" . helm-mini) + ("C-x C-b" . helm-buffers-list) + ("C-x C-f" . helm-find-files) + ("C-x C-r" . helm-recentf) + ("M-y" . helm-show-kill-ring) + ("C-;" . ace-window) + ("C-S-" . buf-move-up) + ("C-S-" . buf-move-down) + ("C-S-" . buf-move-left) + ("C-S-" . buf-move-right) + ("" . super-emacs-reload-current-file) + ("C--" . undo) + ("C-x p" . previous-multiframe-window) + ("s--" . text-scale-decrease) + ("s-=" . text-scale-increase) + )) + +(defun super-emacs-apply-keyboard-bindings (pair) + "Apply keyboard-bindings for supplied list of key-pair values" + (global-set-key (kbd (car pair)) + (cdr pair))) + +(mapc 'super-emacs-apply-keyboard-bindings + super-emacs--my-keyboard-bindings) diff --git a/emacs/super-emacs/misc.el b/emacs/super-emacs/misc.el new file mode 100644 index 0000000..02f7986 --- /dev/null +++ b/emacs/super-emacs/misc.el @@ -0,0 +1,25 @@ +(defun super-emacs-reload-current-file () + "Reload the file loaded in current buffer from the disk" + (interactive) + (cond (buffer-file-name (progn (find-alternate-file buffer-file-name) + (message "File reloaded"))) + (t (message "You're not editing a file!")))) + +;Disable splash message, start *scratch* buffer by default +(setq initial-buffer-choice + t) +(setq initial-scratch-message + "") + +;Enforce spaces for indentation, instead of tabs +(setq-default indent-tabs-mode + nil) + +;Enable show-paren-mode +(show-paren-mode) + +;Enable winner-mode +(winner-mode t) + +;Enable windmove +(windmove-default-keybindings) diff --git a/emacs/super-emacs/packages.el b/emacs/super-emacs/packages.el new file mode 100644 index 0000000..fd76b70 --- /dev/null +++ b/emacs/super-emacs/packages.el @@ -0,0 +1,86 @@ +;Create repositories cache, if required +(when (not package-archive-contents) + (package-refresh-contents)) + +;Declare a list of required packages +(defvar super-emacs--required-packages + '(helm + multiple-cursors + ace-jump-mode + ace-window + powerline + buffer-move + ztree + undo-tree + neotree + material-theme + dired-launch + which-key + meta-presenter + myterminal-controls + theme-looper + magit + rust-mode + racer + company + )) + +;Install required packages +(mapc (lambda (p) + (package-install p)) + super-emacs--required-packages) + + +;Start undo-tree +(global-undo-tree-mode) + +;Set hooks for dired-launch-mode +(add-hook 'dired-mode-hook + 'dired-launch-mode) + +;Start which-key-mode +(which-key-mode) + +;Setup company-mode +(setq company-dabbrev-downcase 0) +(setq company-idle-delay 0) +(setq company-minimum-prefix-length 2) + + +;Set up ace-jump-mode +(autoload 'ace-jump-mode + "ace-jump-mode" + "Emacs quick move minor mode" + t) +(autoload 'ace-jump-mode-pop-mark + "ace-jump-mode" + "Ace jump back:-" + t) + +;Enable powerline +(powerline-center-theme) +(setq powerline-default-separator + 'slant) + +;Configure theme-looper +(theme-looper-set-theme-set '(deeper-blue + wheatgrass + wombat + material)) +(theme-looper-set-customizations 'powerline-reset) + +;Configure myterminal-controls +(myterminal-controls-set-controls-data + '(("t" "Change color theme" theme-looper-enable-next-theme) + ("r" "Reload file" super-emacs-reload-current-file))) + +;Set up helm-mode +(helm-mode 1) +(helm-autoresize-mode 1) +(setq helm-split-window-in-side-p + t) + +;Set up racer for rust-mode +(add-hook 'rust-mode-hook #'racer-mode) +(add-hook 'rust-mode-hook #'eldoc-mode) +(add-hook 'racer-mode-hook #'company-mode) diff --git a/emacs/super-emacs/repositories.el b/emacs/super-emacs/repositories.el new file mode 100644 index 0000000..98e9c11 --- /dev/null +++ b/emacs/super-emacs/repositories.el @@ -0,0 +1,10 @@ +;Load package.el +(require 'package) + +;Add melpa to list of repositories +(add-to-list 'package-archives + '("melpa" . "http://melpa.milkbox.net/packages/") + t) + +;Initialize package.el +(package-initialize)