From cc1c1af46eb2a0d5e093ca3cc67c202f1b9606fe Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Sat, 7 Dec 2019 23:09:25 +0100 Subject: [PATCH] Initial working version --- .gitmodules | 3 +++ LICENCE | 12 ++++++++++++ README.rst | 17 +++++++++++++++++ custom.el | 23 ++++++++++++++++++++++ evil | 1 + init.el | 29 ++++++++++++++++++++++++++++ modules/jenga-company.el | 12 ++++++++++++ modules/jenga-elm.el | 17 +++++++++++++++++ modules/jenga-emacs.el | 39 ++++++++++++++++++++++++++++++++++++++ modules/jenga-evil.el | 16 ++++++++++++++++ modules/jenga-functions.el | 7 +++++++ modules/jenga-helm.el | 32 +++++++++++++++++++++++++++++++ modules/jenga-magit.el | 5 +++++ modules/jenga-ocaml.el | 16 ++++++++++++++++ modules/jenga-org.el | 9 +++++++++ modules/jenga-rust.el | 30 +++++++++++++++++++++++++++++ modules/jenga-systemd.el | 13 +++++++++++++ modules/jenga-theme.el | 7 +++++++ 18 files changed, 288 insertions(+) create mode 100644 .gitmodules create mode 100644 LICENCE create mode 100644 README.rst create mode 100644 custom.el create mode 160000 evil create mode 100644 init.el create mode 100644 modules/jenga-company.el create mode 100644 modules/jenga-elm.el create mode 100644 modules/jenga-emacs.el create mode 100644 modules/jenga-evil.el create mode 100644 modules/jenga-functions.el create mode 100644 modules/jenga-helm.el create mode 100644 modules/jenga-magit.el create mode 100644 modules/jenga-ocaml.el create mode 100644 modules/jenga-org.el create mode 100644 modules/jenga-rust.el create mode 100644 modules/jenga-systemd.el create mode 100644 modules/jenga-theme.el diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..87b62a2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "evil"] + path = evil + url = https://github.com/emacs-evil/evil.git diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..9fe9322 --- /dev/null +++ b/LICENCE @@ -0,0 +1,12 @@ +Copyright (c) 2019 by Vladan Popovic + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..1bfdcf2 --- /dev/null +++ b/README.rst @@ -0,0 +1,17 @@ +My custom emacs configuration +============================= + +**IT'S EVIL!!!** + +Tested on: + +* Rust +* Elm +* Systemd + +Installation +============ + +Clone the repository as ~/.emacs.d/ (not inside it), e.g.:: + + git clone https://path-to-this-repo.git ~/.emacs.d diff --git a/custom.el b/custom.el new file mode 100644 index 0000000..462bc57 --- /dev/null +++ b/custom.el @@ -0,0 +1,23 @@ +(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. + '(elm-compile-arguments '("--output=elm-couchapp/_attachments/index.html")) + '(elm-compile-command '("elm make")) + '(elm-format-on-save t) + '(elm-interactive-command '("elm" "repl")) + '(elm-package-command '("elm" "package")) + '(elm-package-json "elm.json") + '(elm-reactor-command '("elm" "reactor")) + '(elm-tags-exclude-elm-stuff nil) + '(elm-tags-on-save 1) + '(package-selected-packages + '(material-theme racer evil-mode helm rust-mode highlight-parentheses-mode merlin forge magit yaml-mode neotree lsp-rust hindent hi2 flycheck-haskell ac-haskell-process lsp-haskell haste haskell-snippets haskell-mode rainbow-identifiers elm-test-runner flycheck-elm elm-mode company ztree ac-etags sqlformat cargo evil))) +;; +(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. + ) diff --git a/evil b/evil new file mode 160000 index 0000000..c861d2f --- /dev/null +++ b/evil @@ -0,0 +1 @@ +Subproject commit c861d2f6be8207a8919675ce76db583df071b4d5 diff --git a/init.el b/init.el new file mode 100644 index 0000000..a598938 --- /dev/null +++ b/init.el @@ -0,0 +1,29 @@ +;; Load emacs customizations. +;; The customization file shouldn't should be only +(setq custom-file "~/.emacs.d/custom.el") +(load custom-file) + +;; Configure emacs packages. +(setq should-install-packages t) ;; Define this before everything to speed up startup. +(require 'package) +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) +(package-initialize) + +(setq dotfiles-dir (file-name-directory + (or (buffer-file-name) (file-chase-links load-file-name)))) + +(add-to-list 'load-path (concat dotfiles-dir "modules")) + +;; Emacs customization / global plugin configuration +(require 'jenga-company) +(require 'jenga-emacs) +(require 'jenga-evil) +(require 'jenga-helm) +(require 'jenga-magit) +(require 'jenga-org) +(require 'jenga-theme) + +;; Custom languages and highlighting +(require 'jenga-elm) +(require 'jenga-rust) +(require 'jenga-systemd) diff --git a/modules/jenga-company.el b/modules/jenga-company.el new file mode 100644 index 0000000..834fa50 --- /dev/null +++ b/modules/jenga-company.el @@ -0,0 +1,12 @@ +;;;; Company configuration. +(require 'jenga-functions) +(instl 'company) + +;; Allign annotations in company auto-complete list. +(setq company-tooltip-align-annotations t) +(add-hook 'after-init-hook 'global-company-mode) + +(setq tab-always-indent 'complete) +(add-to-list 'completion-styles 'initials t) + +(provide 'jenga-company) diff --git a/modules/jenga-elm.el b/modules/jenga-elm.el new file mode 100644 index 0000000..f866e43 --- /dev/null +++ b/modules/jenga-elm.el @@ -0,0 +1,17 @@ +;;;; Elm mode configuration. +(require 'jenga-functions) +(instl 'elm-mode) + +(add-hook 'elm-mode-hook #'company-mode) +(add-hook 'elm-mode-hook #'rainbow-delimiters-mode) +(add-hook 'elm-mode-hook (lambda () (setq evil-auto-indent nil))) + +;; Turn on Elm mode with *.elm files. +(add-to-list 'auto-mode-alist '("\\.elm\\'" . elm-mode)) +(add-to-list 'company-backends 'company-elm) + +(setq elm-format-on-save t + elm-tags-on-save t + elm-tags-exclude-elm-stuff nil) + +(provide 'jenga-elm) diff --git a/modules/jenga-emacs.el b/modules/jenga-emacs.el new file mode 100644 index 0000000..4b2f113 --- /dev/null +++ b/modules/jenga-emacs.el @@ -0,0 +1,39 @@ +;; Persist command history +(savehist-mode 1) + +;; Disable the splash screen (to enable it agin, replace the t with 0). +(setq inhibit-splash-screen t) + +;; Disable the menu. +(tool-bar-mode -1) +;; Enable transient mark mode. +(transient-mark-mode 1) + +;; Highlight paired parentheses when cursor is over one. +(show-paren-mode 1) + +;;;; TAGS configuration. +;; Goto tag with M-. +(global-set-key "\M-." 'etags-select-find-tag) +;; Automatically load TAGS file (if exists) when opening emacs. +(let ((my-tags-file (locate-dominating-file default-directory "TAGS"))) + (when my-tags-file + (message "Loading tags file: %s" my-tags-file) + (visit-tags-table my-tags-file))) + +;;(setq split-height-threshold nil) +;;(setq split-width-threshold 0) +(global-set-key (kbd "S-C-h") 'shrink-window-horizontally) +(global-set-key (kbd "S-C-l") 'enlarge-window-horizontally) +(global-set-key (kbd "S-C-j") 'shrink-window) +(global-set-key (kbd "S-C-k") 'enlarge-window) + +(setq-default display-line-numbers-type 'absolute + display-line-numbers-current-absolute t + display-line-numbers-width 4 + display-line-numbers-widen t) + +(add-hook 'text-mode-hook #'display-line-numbers-mode) +(add-hook 'prog-mode-hook #'display-line-numbers-mode) + +(provide 'jenga-emacs) diff --git a/modules/jenga-evil.el b/modules/jenga-evil.el new file mode 100644 index 0000000..f8f727d --- /dev/null +++ b/modules/jenga-evil.el @@ -0,0 +1,16 @@ +;;;; Evil mode configuration. +;;(unless (package-installed-p 'evil) +;; (package-refresh-contents) +;; (package-install 'evil)) +(add-to-list 'load-path "~/.emacs.d/evil") +(setq evil-want-C-u-scroll t) + +;; Enable Evil mode. +(require 'evil) +(evil-mode 1) + +(eval-after-load "evil-maps" + ;; Unset Evil's "M-." keymap so that TAGS definitions can be followed. + (define-key evil-normal-state-map "\M-." nil)) + +(provide 'jenga-evil) diff --git a/modules/jenga-functions.el b/modules/jenga-functions.el new file mode 100644 index 0000000..2d2d49e --- /dev/null +++ b/modules/jenga-functions.el @@ -0,0 +1,7 @@ +(defun instl (pckg) + (unless (and should-install-packages (package-installed-p pckg)) + (package-refresh-contents) + (package-install pckg)) + (require pckg)) + +(provide 'jenga-functions) diff --git a/modules/jenga-helm.el b/modules/jenga-helm.el new file mode 100644 index 0000000..bc0cae2 --- /dev/null +++ b/modules/jenga-helm.el @@ -0,0 +1,32 @@ +;;;; Heml mode configuration. +(require 'jenga-functions) +(instl 'helm) + +(require 'helm-config) + +(helm-mode 1) +(setq helm-autoresize-max-height 0) +(setq helm-autoresize-min-height 20) +(helm-autoresize-mode 1) + +;; The default "C-x c" is quite close to "C-x C-c", which quits Emacs. +;; Changed to "C-c h". Note: We must set "C-c h" globally, because we +;; cannot change `helm-command-prefix-key' once `helm-config' is loaded. +(global-set-key (kbd "C-c h") 'helm-command-prefix) +(global-unset-key (kbd "C-x c")) + +(define-key helm-map (kbd "") 'helm-execute-persistent-action) ; rebind tab to run persistent action +(define-key helm-map (kbd "C-i") 'helm-execute-persistent-action) ; make TAB work in terminal +(define-key helm-map (kbd "C-z") 'helm-select-action) ; list actions using C-z + +(when (executable-find "firefox") + (setq helm-google-suggest-use-curl-p t)) + +(setq helm-split-window-in-side-p t ; Open helm buffer inside current window, not occupy whole other window + helm-move-to-line-cycle-in-source t ; Move to end or beginning of source when reaching top or bottom of source. + helm-ff-search-library-in-sexp t ; Search for library in `require' and `declare-function' sexp. + helm-scroll-amount 8 ; Scroll 8 lines other window using M-/M- + helm-ff-file-name-history-use-recentf t + helm-echo-input-in-header-line t) + +(provide 'jenga-helm) diff --git a/modules/jenga-magit.el b/modules/jenga-magit.el new file mode 100644 index 0000000..1809e4a --- /dev/null +++ b/modules/jenga-magit.el @@ -0,0 +1,5 @@ +;;;; Magit configuration. +(require 'jenga-functions) +(instl 'magit) + +(provide 'jenga-magit) diff --git a/modules/jenga-ocaml.el b/modules/jenga-ocaml.el new file mode 100644 index 0000000..f93fb8f --- /dev/null +++ b/modules/jenga-ocaml.el @@ -0,0 +1,16 @@ +;; OCaml +(let ((opam-share (ignore-errors (car (process-lines "opam" "config" "var" "share"))))) + (when (and opam-share (file-directory-p opam-share)) + (add-to-list 'load-path (expand-file-name "emacs/site-lisp" opam-share)) + (autoload 'merlin-mode "merlin" nil t nil) + (add-hook 'tuareg-mode-hook 'merlin-mode t) + (add-hook 'caml-mode-hook 'merlin-mode t))) + +; Make company aware of merlin +(with-eval-after-load 'company + (add-to-list 'company-backends 'merlin-company-backend)) + +; Enable company on merlin managed buffers +(add-hook 'merlin-mode-hook 'company-mode) + +(provide 'jenga-ocaml) diff --git a/modules/jenga-org.el b/modules/jenga-org.el new file mode 100644 index 0000000..685a571 --- /dev/null +++ b/modules/jenga-org.el @@ -0,0 +1,9 @@ +;;;; Org mode configuration. +;; Enable Org mode. +(require 'jenga-functions) +(instl 'org) + +;; Turn on Org mode on .org files. +(add-to-list 'auto-mode-alist '("\\.org$" . org-mode)) + +(provide 'jenga-org) diff --git a/modules/jenga-rust.el b/modules/jenga-rust.el new file mode 100644 index 0000000..3476e5c --- /dev/null +++ b/modules/jenga-rust.el @@ -0,0 +1,30 @@ +;;;; Rust mode configuration. +;; Add rust load hooks. +(require 'jenga-functions) +(instl 'rust-mode) +(instl 'racer) + +(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 'cargo-minor-mode) + +;; Turn on Rust mode with *.rs files. +(add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode)) +;; Auto-format with rustfmt on save. +(setq rust-format-on-save t) + +;; Show company auto-complete list on *.rs files by pressing TAB. +(define-key rust-mode-map (kbd "TAB") #'company-indent-or-complete-common) +;; Use M-. keybinding to follow tag. +(define-key rust-mode-map (kbd "M-.") 'racer-find-definition) +;; Use M-h keybinding to open symbol documentation. +(define-key rust-mode-map (kbd "M-h") 'racer-describe) +;; Use C-c C-c keybinding to compile with `cargo build`. +(define-key rust-mode-map (kbd "C-c C-b") 'cargo-process-build) +;; Use C-c C-r keybinding to run with `cargo run`. +(define-key rust-mode-map (kbd "C-c C-r") 'cargo-process-run) +;; Use C-c C-t keybinding to test with `cargo test`. +(define-key rust-mode-map (kbd "C-c C-t") 'cargo-process-test) + +(provide 'jenga-rust) diff --git a/modules/jenga-systemd.el b/modules/jenga-systemd.el new file mode 100644 index 0000000..383a447 --- /dev/null +++ b/modules/jenga-systemd.el @@ -0,0 +1,13 @@ +(add-to-list 'auto-mode-alist '("\\.service\\'" . conf-unix-mode)) +(add-to-list 'auto-mode-alist '("\\.timer\\'" . conf-unix-mode)) +(add-to-list 'auto-mode-alist '("\\.target\\'" . conf-unix-mode)) +(add-to-list 'auto-mode-alist '("\\.mount\\'" . conf-unix-mode)) +(add-to-list 'auto-mode-alist '("\\.automount\\'" . conf-unix-mode)) +(add-to-list 'auto-mode-alist '("\\.slice\\'" . conf-unix-mode)) +(add-to-list 'auto-mode-alist '("\\.socket\\'" . conf-unix-mode)) +(add-to-list 'auto-mode-alist '("\\.path\\'" . conf-unix-mode)) +(add-to-list 'auto-mode-alist '("\\.netdev\\'" . conf-unix-mode)) +(add-to-list 'auto-mode-alist '("\\.network\\'" . conf-unix-mode)) +(add-to-list 'auto-mode-alist '("\\.link\\'" . conf-unix-mode)) + +(provide 'jenga-systemd) diff --git a/modules/jenga-theme.el b/modules/jenga-theme.el new file mode 100644 index 0000000..2a048fb --- /dev/null +++ b/modules/jenga-theme.el @@ -0,0 +1,7 @@ +;; Use material theme on black background. +(unless (package-installed-p 'material-theme) + (package-refresh-contents) + (package-install 'material-theme)) +(require 'material-theme) + +(provide 'jenga-theme)