 (unless noninteractive
   (message "Loading %s..." load-file-name))
 
-;; UTF-8
 (setq locale-coding-system 'utf-8)
 (set-terminal-coding-system 'utf-8)
 (prefer-coding-system 'utf-8)
 
-;; Packages
-(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/") ("melpa" . "https://melpa.org/packages/")))
-(package-initialize)
-
-(when (not (package-installed-p 'use-package))
-    (package-refresh-contents)
-    (package-install 'use-package))
-
 (when (not (window-system))
   (send-string-to-terminal "\033]12;black\007"))
 
-;; use-package organizes package configuration
 (eval-when-compile
+  (require 'package)
+  (package-initialize)
   (defvar use-package-verbose t)
   (require 'use-package))
 


;;; Post initialization

(when (display-graphic-p)
  (let ((elapsed (float-time (time-subtract (current-time)
                                            emacs-start-time))))
    (message "Loading %s...done (%.3fs)" load-file-name elapsed))


(use-package helm
  :ensure t
  :bind (("M-x" . helm-M-x)
         ("C-x C-f" . helm-find-files)
         ("C-x b" . helm-buffers-list)
         ("C-x f" . helm-recentf)
         ("M-y" . helm-show-kill-ring))
  :diminish (helm-mode)
  :config
  (setq helm-buffers-fuzzy-matching t)
  (helm-mode 1))

(use-package inf-ruby
  :ensure t
  :hook (ruby-mode . inf-ruby-minor-mode))

(use-package ruby-mode
  :ensure t
  :mode "\\.rb\\'"
  :interpreter "ruby"
  :config
  (setq ruby-deep-indent-paren-style nil)
  :init (defun ruby-send-whole-buffer ()
          (interactive)
          (save-buffer)
          (ruby-load-file (buffer-file-name (current-buffer)))))
;; :bind (("C-M-l" . ruby-forward-sexp)
;;        ("C-M-j" . ruby-backward-sexp)
;;        ("C-x e" . ruby-send-whole-buffer)
;;        ("C-x C-e" . ruby-send-whole-buffer)))

(use-package zeal-at-point
  :ensure t
