[emacs] Switch to use-package everywhere.

This commit is contained in:
Mikaël Capelle 2019-12-27 16:45:28 +01:00
parent 2e133f8e04
commit f193b6f096
2 changed files with 130 additions and 46 deletions

View File

@ -1,4 +1,6 @@
;;; init.el --- Init file for emacs ;;; init.el --- -*- lexical-binding: t -*-
;;; Init file for emacs
;;; Commentary: ;;; Commentary:
@ -11,25 +13,57 @@
;; Themes ;; Themes
(setq custom-theme-directory "~/.emacs.d/themes/") (setq custom-theme-directory "~/.emacs.d/themes/")
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
;; Packages ;; Packages
(require 'package) ;; You might already have this line (require 'package) ;; You might already have this line
(add-to-list 'package-archives (setq package-user-dir (expand-file-name "elpa" user-emacs-directory)
'("melpa" . "http://melpa.org/packages/")) package-archives
(when (< emacs-major-version 24) '(("gnu" . "http://elpa.gnu.org/packages/")
;; For important compatibility libraries like cl-lib ("melpa" . "http://melpa.org/packages/")
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))) ("cselpa" . "http://elpa.thecybershadow.net/packages/")))
(setq package-enable-at-startup nil)
(package-initialize) ;; You might already have this line
(load-theme 'material t) (unless (bound-and-true-p package--initialized)
(setq package-enable-at-startup nil) ; To prevent initializing twice
(package-initialize))
;; set use-package-verbose to t for interpreted .emacs,
;; and to nil for byte-compiled .emacs.elc.
(eval-and-compile
(setq use-package-verbose (not (bound-and-true-p byte-compile-current-file))))
;; Install use-package if not installed
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-and-compile
(setq use-package-always-ensure t)
(setq use-package-expand-minimally t)
(setq use-package-compute-statistics t)
(setq use-package-enable-imenu-support t))
(eval-when-compile
(require 'use-package)
(require 'bind-key))
(use-package auto-package-update
:if (not (daemonp))
:custom
(auto-package-update-interval 7) ;; in days
(auto-package-update-prompt-before-update t)
(auto-package-update-delete-old-versions t)
(auto-package-update-hide-results t)
:config
(auto-package-update-maybe))
(use-package diminish)
(require 'iso-transl) (require 'iso-transl)
(require 'use-package)
(setq use-package-verbose t) (global-display-line-numbers-mode)
;; No menu, scrollbar, display line and column ;; No menu, scrollbar, displayline and column
(menu-bar-mode -1) (menu-bar-mode -1)
(tool-bar-mode -1) (tool-bar-mode -1)
(when (display-graphic-p) (when (display-graphic-p)
@ -53,9 +87,34 @@
;; M-> (end-of-buffer) : Déplacement à la fin du buffer. ;; M-> (end-of-buffer) : Déplacement à la fin du buffer.
;; M-< (beginning-of-buffer) : Déplacement au début du buffer. ;; M-< (beginning-of-buffer) : Déplacement au début du buffer.
(use-package material-theme
:config
(load-theme 'material t))
;; No split screen at startup ;; No split screen at startup
(setq inhibit-startup-screen t) (setq inhibit-startup-screen t)
;; Or if you use use-package
(setq dashboard-items '((recents . 5)
;; (bookmarks . 5)
(projects . 5)
(agenda . 5)
(registers . 5)))
(setq dashboard-set-heading-icons t)
(setq dashboard-set-file-icons t)
(setq dashboard-set-navigator t)
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook))
(add-hook 'dashboard-mode-hook (lambda () (display-line-numbers-mode -1)))
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
(use-package doom-modeline
:ensure t
:hook (after-init . doom-modeline-mode))
(use-package ace-window
:bind ("C-x C-o" . ace-window))
;; Encoding ;; Encoding
(set-language-environment "UTF-8") (set-language-environment "UTF-8")
@ -78,32 +137,31 @@
;; Retrieve PATH from fish shell ;; Retrieve PATH from fish shell
(when (memq window-system '(mac ns x)) (when (memq window-system '(mac ns x))
(setq exec-path-from-shell-shell-name "/usr/bin/fish") (setq exec-path-from-shell-shell-name "/usr/local/bin/fish")
(exec-path-from-shell-initialize)) (exec-path-from-shell-initialize))
;; Auto complete + Yasnippet ;; Auto complete + Yasnippet
(use-package projectile
(use-package sr-speedbar
:config :config
(setq speedbar-show-unknown-files t) (projectile-mode 1)
(setq speedbar-use-images t)) (define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
(setq projectile-enable-caching t))
(use-package semantic/sb (use-package helm
:config
;; (semantic-mode)
(global-set-key (kbd "C-c C-k C-l") 'sr-speedbar-toggle))
(use-package helm-config
:config :config
(global-set-key (kbd "M-x") 'helm-M-x) (global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x r b") 'helm-filtered-bookmarks) (global-set-key (kbd "C-x r b") 'helm-filtered-bookmarks)
(global-set-key (kbd "C-x C-f") 'helm-find-files) (global-set-key (kbd "C-x C-f") 'helm-find-files)
(global-set-key (kbd "C-x C-b") 'helm-buffers-list) (global-set-key (kbd "C-x C-b") 'helm-buffers-list)
(helm-mode 1) (helm-mode 1)
(projectile-global-mode) (add-to-list 'helm-boring-buffer-regexp-list "\\*.*"))
(setq projectile-completion-system 'helm)
(add-to-list 'helm-boring-buffer-regexp-list "\\*.*") (use-package helm-projectile
(helm-projectile-on)) :after (helm projectile)
:config
(setq projectile-completion-system 'helm)
(helm-projectile-on))
(use-package yasnippet (use-package yasnippet
:config :config
@ -111,30 +169,43 @@
(use-package flycheck (use-package flycheck
:config :config
(require 'flycheck-color-mode-line)
(add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode)
(add-hook 'flycheck-mode-hook 'flycheck-pos-tip-mode)
(add-hook 'flycheck-after-syntax-check-hook 'flycheck-autolist-hook) (add-hook 'flycheck-after-syntax-check-hook 'flycheck-autolist-hook)
(global-flycheck-mode) (global-flycheck-mode)
(setq flycheck-emacs-lisp-load-path "inherit") (setq flycheck-emacs-lisp-load-path "inherict")
(setq flycheck-clang-args '("-stdlib=libc++" "-W" "-Wall")) (setq flycheck-clang-args '("-stdlib=libc++" "-W" "-Wall"))
(add-hook 'c++-mode-hook (add-hook 'c++-mode-hook
(lambda () (lambda ()
(setq-local flycheck-clang-language-standard "c++14")))) (setq-local flycheck-clang-language-standard "c++14"))))
(use-package flycheck-pos-tip
:after (flycheck)
:config
(add-hook 'flycheck-mode-hook 'flycheck-pos-tip-mode))
(use-package flycheck-color-mode-line
:after (flycheck)
:config
(add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode))
(use-package company (use-package company
:init
(require 'company-auctex)
(setq company-backends (append company-backends '(company-c-headers
company-jedi
company-web-html)))
(add-hook 'LaTeX-mode-hook 'company-auctex-init)
:config :config
(add-hook 'after-init-hook 'global-company-mode) (add-hook 'after-init-hook 'global-company-mode)
(global-set-key (kbd "M-/") 'company-complete) (global-set-key (kbd "M-/") 'company-complete))
(add-hook 'c++-mode-hook
(lambda () (use-package company-c-headers
(setq-local company-clang-arguments '("-std=c++14"))))) :config
(add-to-list 'company-backends 'company-c-headers))
(use-package company-jedi
:config
(add-to-list 'company-backends 'company-jedi))
(use-package company-web
:config
(add-to-list 'company-backends 'company-web-html))
; C++
(use-package modern-cpp-font-lock
:ensure t)
(add-hook 'c++-mode-hook #'modern-c++-font-lock-mode)
;; Doc mode ;; Doc mode
(require 'doc-mode) (require 'doc-mode)
@ -142,7 +213,8 @@
(add-hook 'c++-mode-common-hook 'doc-mode) (add-hook 'c++-mode-common-hook 'doc-mode)
;; Latex ;; Latex
(use-package tex-mik (use-package auctex
:defer t
:config :config
(setq TeX-auto-save t) (setq TeX-auto-save t)
(setq TeX-parse-self t) (setq TeX-parse-self t)
@ -201,6 +273,18 @@
(require 'tex) (require 'tex)
(TeX-global-PDF-mode t) (TeX-global-PDF-mode t)
) )
(use-package company-auctex
:after (auctex company)
:config (company-auctex-init))
;; (add-to-list 'ispell-local-dictionary-alist '("francais-hunspell"
;; "[[:alpha:]]"
;; "[^[:alpha]]"
;; "[']"
;; t
;; ("-d" "fr_FR")
;; nil
;; iso-8859-1))
;; magit ;; magit
(use-package magit (use-package magit
@ -243,8 +327,6 @@
(setq c-default-style "k&r") (setq c-default-style "k&r")
(setq c-basic-offset 4) (setq c-basic-offset 4)
(use-package c++1x-minor-mode)
(defun ac-cc-mode-setup () (defun ac-cc-mode-setup ()
"Initialization hook for CC-mode runs before any other hooks." "Initialization hook for CC-mode runs before any other hooks."
(hide-ifdef-mode) (hide-ifdef-mode)
@ -314,11 +396,10 @@
(add-hook 'LaTeX-mode-hook 'key-latex-mode-setup) (add-hook 'LaTeX-mode-hook 'key-latex-mode-setup)
;; python ;; python
(use-package flycheck-mypy)
(use-package elpy (use-package elpy
:ensure t
:config :config
(when (load "flycheck" t t) (when (load "flycheck" t t)
(require 'flycheck-mypy)
(flycheck-add-next-checker 'python-flake8 'python-mypy) (flycheck-add-next-checker 'python-flake8 'python-mypy)
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules)) (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
(add-hook 'elpy-mode-hook 'flycheck-mode)) (add-hook 'elpy-mode-hook 'flycheck-mode))

3
.gitignore vendored
View File

@ -4,10 +4,13 @@
.emacs.d/.python-environments .emacs.d/.python-environments
.emacs.d/auto-save-list .emacs.d/auto-save-list
.emacs.d/elpa .emacs.d/elpa
.emacs.d/.last-package-update-day
.emacs.d/projectile.cache
.emacs.d/projectile-bookmarks.eld .emacs.d/projectile-bookmarks.eld
.emacs.d/eshell/ .emacs.d/eshell/
.emacs.d/transient/ .emacs.d/transient/
.emacs.d/elpy/ .emacs.d/elpy/
.emacs.d/recentf
# Mac file # Mac file
**/.DS_Store **/.DS_Store