 (define-key evil-visual-state-map ",x" 'execute-extended-command)
 (define-key evil-normal-state-map ",z" 'recenter-top-bottom)
 
-(define-key yas-minor-mode-map (kbd "<tab>") nil)
-(define-key yas-minor-mode-map (kbd "TAB") nil)
-(evil-define-key 'insert yas-minor-mode-map (kbd "C-s") 'yas-expand)
-(evil-define-key 'insert yas-minor-mode-map (kbd "C-f") 'yas-next-field)
-
-(eval-after-load 'auto-complete
+(evil-define-key 'insert yas-minor-mode-map (kbd "<tab>") nil)
+(evil-define-key 'insert yas-minor-mode-map (kbd "TAB") nil)
+
+;; (eval-after-load 'auto-complete
+;;   '(progn
+;;      (define-key evil-insert-state-map (kbd "S-<iso-lefttab>") 'ac-previous)))
+
+;; (defun my-company-yas-expand ()
+;;   "Yasnippet expand even if there is a company mode popup."
+;;   (interactive)
+;;   (evil-normal-state)
+;;   (evil-append)
+;;   (yas-expand))
+
+(eval-after-load 'company
   '(progn
-     (define-key evil-insert-state-map (kbd "S-<iso-lefttab>") 'ac-previous)))
+     (define-key evil-insert-state-map [tab] 'company-select-next)
+     (define-key evil-insert-state-map (kbd "TAB") 'company-select-next)
+     (define-key evil-insert-state-map (kbd "S-<iso-lefttab>") 'company-select-previous)
+     ;; (evil-define-key 'insert yas-minor-mode-map (kbd "C-s") 'my-company-yas-expand)
+     (evil-define-key 'insert yas-minor-mode-map (kbd "C-f") 'yas-next-field)
+     (evil-define-key 'insert company-capf-minor-mode-map (kbd "C-w") 'evil-delete-backward-word)))
 
 (add-to-list 'load-path "~/etsi/emacs/.emacs.d/kb")
 (require 'ibuffer-kb)
+
+(evil-set-initial-state 'magit-mode 'normal)
+(evil-set-initial-state 'magit-status-mode 'normal)
+(evil-set-initial-state 'magit-diff-mode 'normal)
+(evil-set-initial-state 'magit-log-mode 'normal)
+
+(evil-define-key 'normal magit-mode-map
+  "j" 'magit-goto-next-section
+  "k" 'magit-goto-previous-section)
+
+(evil-define-key 'normal magit-log-mode-map
+  "j" 'magit-goto-next-section
+  "k" 'magit-goto-previous-section)
+
+(evil-define-key 'normal magit-diff-mode-map
+  "j" 'magit-goto-next-section
+  "k" 'magit-goto-previous-section)
 
 ;;; Leftover mode activation.
 (evil-mode t)

   :fetcher github
   :repo "alpaker/Fill-Column-Indicator"))

(quelpa
 '(auto-complete
   :fetcher github
   :repo "auto-complete/auto-complete"
   :files ("*.el" "dict")))

(quelpa
 '(yasnippet
   :fetcher github
   :repo "capitaomorte/yasnippet"
   :files ("yasnippet.el")))

(quelpa
 '(pdf-tools


;; Associate .pdf files with pdf-view-mode.
(add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode))

;; Magit.
(custom-set-faces
 `(magit-section-heading
   ((t (:weight, 'normal))))
 `(magit-section-highlight
   ((t (:weight, 'normal))))
 `(magit-diff-file-heading
   ((t (:weight, 'normal)))))

;;; Theme.
(load-theme 'firebelly t)
