diff --git a/custom.el b/custom.el new file mode 100644 index 0000000..972c863 --- /dev/null +++ b/custom.el @@ -0,0 +1,15 @@ +(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. + '(ffap-machine-p-known (quote reject)) + '(package-selected-packages + (quote + (undo-tree ein-mumamo yasnippet use-package racer material-theme magit lsp-ui helm flycheck-rust elm-mode company-lsp 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. + ) diff --git a/init.el b/init.el index 05a8dc9..f03b656 100644 --- a/init.el +++ b/init.el @@ -4,8 +4,9 @@ (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)))) +(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")) @@ -16,24 +17,13 @@ (require 'jenga-helm) (require 'jenga-magit) (require 'jenga-org) -(require 'jenga-python) -(require 'jenga-theme) +(require 'jenga-ui) ;; Custom languages and highlighting (require 'jenga-elm) (require 'jenga-rust) (require 'jenga-systemd) -(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. - '(package-selected-packages - (quote - (ein-mumamo yasnippet use-package racer material-theme magit lsp-ui helm flycheck-rust elm-mode company-lsp 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. - ) +(require 'jenga-python) + +(setq custom-file "~/.emacs.d/custom.el") +(load custom-file) diff --git a/modules/jenga-company.el b/modules/jenga-company.el index 834fa50..d74f527 100644 --- a/modules/jenga-company.el +++ b/modules/jenga-company.el @@ -1,12 +1,15 @@ ;;;; 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) +(use-package company + :ensure t + :defer t + :init (global-company-mode) + :config + (progn + (add-to-list 'completion-styles 'initials t) + (bind-key "M-" #'company-complete company-mode-map) + (setq company-tooltip-align-annotations t + tab-always-indent 'complete) + (setq company-dabbrev-downcase nil)) + :diminish company-mode) (provide 'jenga-company) diff --git a/modules/jenga-elm.el b/modules/jenga-elm.el index 7aaeb25..743ca21 100644 --- a/modules/jenga-elm.el +++ b/modules/jenga-elm.el @@ -1,26 +1,25 @@ ;;;; Elm mode configuration. -(require 'jenga-functions) -(instl 'elm-mode) -(instl 'lsp-mode) -(instl 'lsp-ui) -(instl 'yasnippet) +(use-package elm-mode + :ensure t + :bind + ("M-" . company-indent-or-complete-common) + :config + (use-package lsp-mode) + (use-package lsp-ui) + (use-package yasnippet) + (use-package company) + (setq elm-format-on-save t + elm-tags-on-save t + elm-tags-exclude-elm-stuff nil) + (add-to-list 'company-backends 'company-elm) + (add-to-list 'auto-mode-alist '("\\.elm\\'" . elm-mode)) + :hook + (after-init . global-flycheck-mode) + (elm-mode . company-mode) + (elm-mode . lsp) + (elm-mode . (lambda () (setq evil-auto-indent nil)))) -(add-hook 'elm-mode-hook #'company-mode) -(add-hook 'elm-mode-hook #'lsp) -(add-hook 'elm-mode-hook (lambda () (setq evil-auto-indent nil))) - -(add-hook 'after-init-hook #'global-flycheck-mode) (with-eval-after-load 'flycheck '(add-hook 'flycheck-mode-hook #'flycheck-elm-setup)) -(add-to-list 'company-backends 'company-elm) -(define-key elm-mode-map (kbd "M-") #'company-indent-or-complete-common) - -;; Turn on Elm mode with *.elm files. -(add-to-list 'auto-mode-alist '("\\.elm\\'" . elm-mode)) - -(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 index 90e7cb4..21eaf10 100644 --- a/modules/jenga-emacs.el +++ b/modules/jenga-emacs.el @@ -1,16 +1,8 @@ ;; 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) +;; Enable C-r in evil +(undo-tree-mode 1) ;;;; TAGS configuration. ;; Goto tag with M-. @@ -21,21 +13,10 @@ (message "Loading tags file: %s" my-tags-file) (visit-tags-table my-tags-file))) -;;(setq split-height-threshold nil) -;;(setq split-width-threshold 0) +;; Resize windows (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 column-number-mode t) - -(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 index f8f727d..3b1c4b1 100644 --- a/modules/jenga-evil.el +++ b/modules/jenga-evil.el @@ -2,15 +2,20 @@ ;;(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)) +(use-package evil + :ensure t + :init ;; tweak evil's configuration before loading it + (setq evil-search-module 'evil-search + evil-ex-complete-emacs-commands nil + evil-vsplit-window-right t + evil-split-window-below t + evil-shift-round nil + evil-want-C-u-scroll t) + :config ;; tweak evil after loading it + (evil-mode) + (setq evil-want-C-u-scroll t) + (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 deleted file mode 100644 index 2d2d49e..0000000 --- a/modules/jenga-functions.el +++ /dev/null @@ -1,7 +0,0 @@ -(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 index bc0cae2..a2ebac4 100644 --- a/modules/jenga-helm.el +++ b/modules/jenga-helm.el @@ -1,13 +1,22 @@ ;;;; 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) +(use-package helm + :requires helm-config + :init + (helm-mode 1) + (helm-autoresize-mode 1) + :bind + ("" . helm-execute-persistent-action) ; rebind tab to run persistent action + ("C-i" . helm-execute-persistent-action) ; make TAB work in terminal + ("C-z" . helm-select-action) ; list actions using C-z + :config + (setq helm-autoresize-max-height 0 + helm-autoresize-min-height 20 + 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)) ;; 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 @@ -15,18 +24,8 @@ (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 index ec70e98..121f490 100644 --- a/modules/jenga-magit.el +++ b/modules/jenga-magit.el @@ -1,7 +1,5 @@ ;;;; Magit configuration. -(require 'jenga-functions) -(instl 'magit) - -(setq magit-auto-revert-mode nil) +(use-package magit + :init (setq magit-auto-revert-mode nil)) (provide 'jenga-magit) diff --git a/modules/jenga-org.el b/modules/jenga-org.el index 685a571..c03f4fb 100644 --- a/modules/jenga-org.el +++ b/modules/jenga-org.el @@ -1,9 +1,7 @@ ;;;; 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)) +(use-package org + :ensure t + :init (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))) (provide 'jenga-org) diff --git a/modules/jenga-python.el b/modules/jenga-python.el index 2083da3..7ed9ff0 100644 --- a/modules/jenga-python.el +++ b/modules/jenga-python.el @@ -1,26 +1,33 @@ ;;;; Python configuration. -(require 'jenga-functions) -(instl 'elpy) -(instl 'jupyter) -(instl 'ein) -(instl 'py-autopep8) -(instl 'yasnippet) - -(elpy-enable) - -(add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save) - -;; Enable Flycheck -(when (require 'flycheck nil t) - (setq elpy-modules (delq 'elpy-module-flymake elpy-modules)) - (add-hook 'elpy-mode-hook 'flycheck-mode)) - -;; Use IPython for REPL -(setq python-shell-interpreter "jupyter" - python-shell-interpreter-args "console --simple-prompt" - python-shell-prompt-detect-failure-warning nil) - -(add-to-list 'python-shell-completion-native-disabled-interpreters - "jupyter") +(use-package jupyter + :ensure t) +(use-package ein + :ensure t) +(use-package py-autopep8 + :ensure t) +(use-package yasnippet + :ensure t) +(use-package jedi + :ensure t) +(use-package elpy + :ensure t + :init + (elpy-enable) + :bind + ("M-." . jedi:goto-definition) + ("M-," . jedi:goto-definition-pop-marker) + :config + (setq python-shell-interpreter "jupyter" + python-indent-offset 4 + python-shell-interpreter-args "console --simple-prompt" + python-shell-prompt-detect-failure-warning nil) + ;; Use IPython for REPL + (add-to-list 'python-shell-completion-native-disabled-interpreters + "jupyter") + :hook + (elpy-mode . py-autopep8-enable-on-save) + (elpy-mode . flycheck-mode) + (elpy-mode . jedi:setup) + (elpy-mode . jedi:ac-setup)) (provide 'jenga-python) diff --git a/modules/jenga-rst.el b/modules/jenga-rst.el new file mode 100644 index 0000000..e69de29 diff --git a/modules/jenga-rust.el b/modules/jenga-rust.el index d387139..c0a25dc 100644 --- a/modules/jenga-rust.el +++ b/modules/jenga-rust.el @@ -1,27 +1,26 @@ ;;;; Rust mode configuration. ;; Add rust load hooks. -(require 'jenga-functions) -(instl 'rust-mode) -(instl 'racer) -(instl 'cargo) -(instl 'flycheck-rust) +(use-package cargo) +(use-package flycheck-rust) -(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) +(use-package rust-mode + :init (add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode)) + :bind + ("M-." . racer-find-definition) + ("M-h" . racer-describe) + ("M-" . company-indent-or-complete-common) + :config + (setq rust-format-on-save t) + :hook + (after-init . global-flycheck-mode) + (rust-mode . racer-mode) + (rust-mode . cargo-minor-mode)) + +(use-package racer + :hook + (racer-mode . eldoc-mode) + (racer-mode . company-mode)) -(add-hook 'after-init-hook #'global-flycheck-mode) (add-hook 'flycheck-mode-hook #'flycheck-rust-setup) - -;; 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) - -(define-key rust-mode-map (kbd "M-.") #'racer-find-definition) -(define-key rust-mode-map (kbd "M-h") #'racer-describe) -(define-key rust-mode-map (kbd "M-") #'company-indent-or-complete-common) - (provide 'jenga-rust) diff --git a/modules/jenga-systemd.el b/modules/jenga-systemd.el index 383a447..27a9f80 100644 --- a/modules/jenga-systemd.el +++ b/modules/jenga-systemd.el @@ -1,13 +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 '("\\.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)) +(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 deleted file mode 100644 index 2a048fb..0000000 --- a/modules/jenga-theme.el +++ /dev/null @@ -1,7 +0,0 @@ -;; 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) diff --git a/modules/jenga-ui.el b/modules/jenga-ui.el new file mode 100644 index 0000000..1fd32a3 --- /dev/null +++ b/modules/jenga-ui.el @@ -0,0 +1,31 @@ +;; Use material theme on black background. +(use-package material-theme) + +;; +;; =============== +;; Other UI tweaks +;; =============== +;; +;; 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) + +(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) + +(setq column-number-mode t) +(setq ido-use-filename-at-point nil) + +(provide 'jenga-ui)