[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:
@ -11,25 +13,57 @@
;; Themes
(setq custom-theme-directory "~/.emacs.d/themes/")
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
;; Packages
(require 'package) ;; You might already have this line
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/"))
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(setq package-enable-at-startup nil)
(package-initialize) ;; You might already have this line
(setq package-user-dir (expand-file-name "elpa" user-emacs-directory)
package-archives
'(("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")
("cselpa" . "http://elpa.thecybershadow.net/packages/")))
(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 '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)
(tool-bar-mode -1)
(when (display-graphic-p)
@ -53,9 +87,34 @@
;; M-> (end-of-buffer) : Déplacement à la fin 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
(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
(set-language-environment "UTF-8")
@ -78,32 +137,31 @@
;; Retrieve PATH from fish shell
(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))
;; Auto complete + Yasnippet
(use-package sr-speedbar
(use-package projectile
:config
(setq speedbar-show-unknown-files t)
(setq speedbar-use-images t))
(projectile-mode 1)
(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
:config
;; (semantic-mode)
(global-set-key (kbd "C-c C-k C-l") 'sr-speedbar-toggle))
(use-package helm-config
(use-package helm
:config
(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 C-f") 'helm-find-files)
(global-set-key (kbd "C-x C-b") 'helm-buffers-list)
(helm-mode 1)
(projectile-global-mode)
(setq projectile-completion-system 'helm)
(add-to-list 'helm-boring-buffer-regexp-list "\\*.*")
(helm-projectile-on))
(add-to-list 'helm-boring-buffer-regexp-list "\\*.*"))
(use-package helm-projectile
:after (helm projectile)
:config
(setq projectile-completion-system 'helm)
(helm-projectile-on))
(use-package yasnippet
:config
@ -111,30 +169,43 @@
(use-package flycheck
: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)
(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"))
(add-hook 'c++-mode-hook
(lambda ()
(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
: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
(add-hook 'after-init-hook 'global-company-mode)
(global-set-key (kbd "M-/") 'company-complete)
(add-hook 'c++-mode-hook
(lambda ()
(setq-local company-clang-arguments '("-std=c++14")))))
(global-set-key (kbd "M-/") 'company-complete))
(use-package company-c-headers
: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
(require 'doc-mode)
@ -142,7 +213,8 @@
(add-hook 'c++-mode-common-hook 'doc-mode)
;; Latex
(use-package tex-mik
(use-package auctex
:defer t
:config
(setq TeX-auto-save t)
(setq TeX-parse-self t)
@ -201,6 +273,18 @@
(require 'tex)
(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
(use-package magit
@ -243,8 +327,6 @@
(setq c-default-style "k&r")
(setq c-basic-offset 4)
(use-package c++1x-minor-mode)
(defun ac-cc-mode-setup ()
"Initialization hook for CC-mode runs before any other hooks."
(hide-ifdef-mode)
@ -314,11 +396,10 @@
(add-hook 'LaTeX-mode-hook 'key-latex-mode-setup)
;; python
(use-package flycheck-mypy)
(use-package elpy
:ensure t
:config
(when (load "flycheck" t t)
(require 'flycheck-mypy)
(flycheck-add-next-checker 'python-flake8 'python-mypy)
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
(add-hook 'elpy-mode-hook 'flycheck-mode))

3
.gitignore vendored
View File

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