 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Behavior
 ;;
-(require 'popwin)
-(popwin-mode 1)
+(use-package popwin
+  :ensure t
+  :config
+  (popwin-mode 1)
+)
+
 ;; custom shortcuts
 (global-set-key (kbd "C-c -") 'split-window-vertically)
 (global-set-key (kbd "C-c |") 'split-window-horizontally)

              vc-ignore-dir-regexp
              tramp-file-name-regexp))

;; work setup
(if (file-exists-p "~/.emacs.suse.d/init.el")
    (load-file "~/.emacs.suse.d/init.el"))

(require 'org)
(setq org-src-fontify-natively t)
(setq org-fontify-whole-heading-line t)
(setq org-pretty-entities t)

;; Org mode
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
(define-key org-mode-map (kbd "M-RET") nil)

;; org-trello major mode for all .trello files
(add-to-list 'auto-mode-alist '("\\.trello$" . org-mode))

;; add a hook function to check if this is trello file, then activate the org-trello minor mode.
(add-hook 'org-mode-hook
          (lambda ()
            (let ((filename (buffer-file-name (current-buffer))))
              (when (and filename (string= "trello" (file-name-extension filename)))
              (org-trello-mode)))))

(provide 'init)
;;; init.el ends here


(advice-add 'xclip-selection-value :around #'xclip-tramp-fix)
(advice-add 'xclip-select-text :around #'xclip-tramp-fix)
(use-package xclip
  :ensure t
  :config
  (progn (xclip-mode 1) (turn-on-xclip))
)

;;;; scrolling
(setq scroll-step 1)
(setq scroll-conservatively 10000)
(setq auto-window-vscroll nil)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Common programming and tools
;;
(use-package multi-term :ensure t)

(use-package projectile
  :ensure t
  :config (projectile-global-mode t)
  :diminish projectile-mode
)

(use-package company
  :ensure t
  :config (add-hook 'prog-mode-hook 'company-mode))

(use-package magit :ensure t)

(use-package flycheck
  :ensure t
  :defer t
  :init
  (defun my-flycheck-prog-mode-hook ()
    (flycheck-mode t))
  (add-hook 'prog-mode-hook 'my-flycheck-prog-mode-hook))

(use-package flycheck-pos-tip
  :ensure t
  :after (flycheck)
  :config
  (with-eval-after-load 'flycheck (flycheck-pos-tip-mode)))

;; Auto refresh buffers
(global-auto-revert-mode 1)
