use-package configuration is better

This commit is contained in:
Vladan Popovic 2020-01-05 23:51:24 +01:00
parent 5b50bfea88
commit bd5e9a2b46
16 changed files with 185 additions and 174 deletions

15
custom.el Normal file
View file

@ -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.
)

24
init.el
View file

@ -4,7 +4,8 @@
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize) (package-initialize)
(setq dotfiles-dir (file-name-directory (setq dotfiles-dir
(file-name-directory
(or (buffer-file-name) (file-chase-links load-file-name)))) (or (buffer-file-name) (file-chase-links load-file-name))))
(add-to-list 'load-path (concat dotfiles-dir "modules")) (add-to-list 'load-path (concat dotfiles-dir "modules"))
@ -16,24 +17,13 @@
(require 'jenga-helm) (require 'jenga-helm)
(require 'jenga-magit) (require 'jenga-magit)
(require 'jenga-org) (require 'jenga-org)
(require 'jenga-python) (require 'jenga-ui)
(require 'jenga-theme)
;; Custom languages and highlighting ;; Custom languages and highlighting
(require 'jenga-elm) (require 'jenga-elm)
(require 'jenga-rust) (require 'jenga-rust)
(require 'jenga-systemd) (require 'jenga-systemd)
(custom-set-variables (require 'jenga-python)
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. (setq custom-file "~/.emacs.d/custom.el")
;; Your init file should contain only one such instance. (load custom-file)
;; 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.
)

View file

@ -1,12 +1,15 @@
;;;; Company configuration. ;;;; Company configuration.
(require 'jenga-functions) (use-package company
(instl 'company) :ensure t
:defer t
;; Allign annotations in company auto-complete list. :init (global-company-mode)
(setq company-tooltip-align-annotations t) :config
(add-hook 'after-init-hook 'global-company-mode) (progn
(setq tab-always-indent 'complete)
(add-to-list 'completion-styles 'initials t) (add-to-list 'completion-styles 'initials t)
(bind-key "M-<tab>" #'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) (provide 'jenga-company)

View file

@ -1,26 +1,25 @@
;;;; Elm mode configuration. ;;;; Elm mode configuration.
(require 'jenga-functions) (use-package elm-mode
(instl 'elm-mode) :ensure t
(instl 'lsp-mode) :bind
(instl 'lsp-ui) ("M-<tab>" . company-indent-or-complete-common)
(instl 'yasnippet) :config
(use-package lsp-mode)
(add-hook 'elm-mode-hook #'company-mode) (use-package lsp-ui)
(add-hook 'elm-mode-hook #'lsp) (use-package yasnippet)
(add-hook 'elm-mode-hook (lambda () (setq evil-auto-indent nil))) (use-package company)
(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-<tab>") #'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 (setq elm-format-on-save t
elm-tags-on-save t elm-tags-on-save t
elm-tags-exclude-elm-stuff nil) 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))))
(with-eval-after-load 'flycheck
'(add-hook 'flycheck-mode-hook #'flycheck-elm-setup))
(provide 'jenga-elm) (provide 'jenga-elm)

View file

@ -1,16 +1,8 @@
;; Persist command history ;; Persist command history
(savehist-mode 1) (savehist-mode 1)
;; Disable the splash screen (to enable it agin, replace the t with 0). ;; Enable C-r in evil
(setq inhibit-splash-screen t) (undo-tree-mode 1)
;; 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. ;;;; TAGS configuration.
;; Goto tag with M-. ;; Goto tag with M-.
@ -21,21 +13,10 @@
(message "Loading tags file: %s" my-tags-file) (message "Loading tags file: %s" my-tags-file)
(visit-tags-table my-tags-file))) (visit-tags-table my-tags-file)))
;;(setq split-height-threshold nil) ;; Resize windows
;;(setq split-width-threshold 0)
(global-set-key (kbd "S-C-h") 'shrink-window-horizontally) (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-l") 'enlarge-window-horizontally)
(global-set-key (kbd "S-C-j") 'shrink-window) (global-set-key (kbd "S-C-j") 'shrink-window)
(global-set-key (kbd "S-C-k") 'enlarge-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) (provide 'jenga-emacs)

View file

@ -2,15 +2,20 @@
;;(unless (package-installed-p 'evil) ;;(unless (package-installed-p 'evil)
;; (package-refresh-contents) ;; (package-refresh-contents)
;; (package-install 'evil)) ;; (package-install 'evil))
(add-to-list 'load-path "~/.emacs.d/evil") (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) (setq evil-want-C-u-scroll t)
;; Enable Evil mode.
(require 'evil)
(evil-mode 1)
(eval-after-load "evil-maps" (eval-after-load "evil-maps"
;; Unset Evil's "M-." keymap so that TAGS definitions can be followed. ;; Unset Evil's "M-." keymap so that TAGS definitions can be followed.
(define-key evil-normal-state-map "\M-." nil)) (define-key evil-normal-state-map "\M-." nil)))
(provide 'jenga-evil) (provide 'jenga-evil)

View file

@ -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)

View file

@ -1,13 +1,22 @@
;;;; Heml mode configuration. ;;;; Heml mode configuration.
(require 'jenga-functions) (use-package helm
(instl 'helm) :requires helm-config
:init
(require 'helm-config)
(helm-mode 1) (helm-mode 1)
(setq helm-autoresize-max-height 0)
(setq helm-autoresize-min-height 20)
(helm-autoresize-mode 1) (helm-autoresize-mode 1)
:bind
("<tab>" . 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-<next>/M-<prior>
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. ;; 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 ;; 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-set-key (kbd "C-c h") 'helm-command-prefix)
(global-unset-key (kbd "C-x c")) (global-unset-key (kbd "C-x c"))
(define-key helm-map (kbd "<tab>") '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") (when (executable-find "firefox")
(setq helm-google-suggest-use-curl-p t)) (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-<next>/M-<prior>
helm-ff-file-name-history-use-recentf t
helm-echo-input-in-header-line t)
(provide 'jenga-helm) (provide 'jenga-helm)

View file

@ -1,7 +1,5 @@
;;;; Magit configuration. ;;;; Magit configuration.
(require 'jenga-functions) (use-package magit
(instl 'magit) :init (setq magit-auto-revert-mode nil))
(setq magit-auto-revert-mode nil)
(provide 'jenga-magit) (provide 'jenga-magit)

View file

@ -1,9 +1,7 @@
;;;; Org mode configuration. ;;;; Org mode configuration.
;; Enable Org mode. ;; Enable Org mode.
(require 'jenga-functions) (use-package org
(instl 'org) :ensure t
:init (add-to-list 'auto-mode-alist '("\\.org$" . org-mode)))
;; Turn on Org mode on .org files.
(add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
(provide 'jenga-org) (provide 'jenga-org)

View file

@ -1,26 +1,33 @@
;;;; Python configuration. ;;;; Python configuration.
(require 'jenga-functions) (use-package jupyter
(instl 'elpy) :ensure t)
(instl 'jupyter) (use-package ein
(instl 'ein) :ensure t)
(instl 'py-autopep8) (use-package py-autopep8
(instl 'yasnippet) :ensure t)
(use-package yasnippet
:ensure t)
(use-package jedi
:ensure t)
(use-package elpy
:ensure t
:init
(elpy-enable) (elpy-enable)
:bind
(add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save) ("M-." . jedi:goto-definition)
("M-," . jedi:goto-definition-pop-marker)
;; Enable Flycheck :config
(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" (setq python-shell-interpreter "jupyter"
python-indent-offset 4
python-shell-interpreter-args "console --simple-prompt" python-shell-interpreter-args "console --simple-prompt"
python-shell-prompt-detect-failure-warning nil) python-shell-prompt-detect-failure-warning nil)
;; Use IPython for REPL
(add-to-list 'python-shell-completion-native-disabled-interpreters (add-to-list 'python-shell-completion-native-disabled-interpreters
"jupyter") "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) (provide 'jenga-python)

0
modules/jenga-rst.el Normal file
View file

View file

@ -1,27 +1,26 @@
;;;; Rust mode configuration. ;;;; Rust mode configuration.
;; Add rust load hooks. ;; Add rust load hooks.
(require 'jenga-functions) (use-package cargo)
(instl 'rust-mode) (use-package flycheck-rust)
(instl 'racer)
(instl 'cargo)
(instl 'flycheck-rust)
(add-hook 'rust-mode-hook #'racer-mode) (use-package rust-mode
(add-hook 'racer-mode-hook #'eldoc-mode) :init (add-to-list 'auto-mode-alist '("\\.rs\\'" . rust-mode))
(add-hook 'racer-mode-hook #'company-mode) :bind
(add-hook 'rust-mode-hook #'cargo-minor-mode) ("M-." . racer-find-definition)
("M-h" . racer-describe)
("M-<tab>" . 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) (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-<tab>") #'company-indent-or-complete-common)
(provide 'jenga-rust) (provide 'jenga-rust)

View file

@ -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)

31
modules/jenga-ui.el Normal file
View file

@ -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)