;;; user-interface.el --- user interface config -*- lexical-binding: t -*-
;;; Commentary:

;; don't show startup message
(setq inhibit-startup-screen t)

;; improve user interface
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(defalias 'yes-or-no-p 'y-or-n-p) ; for portability
(setopt use-short-answers t)

;; enable copy-pasting outside of emacs
(setq x-select-enable-clipboard t)

;; disable ring bell sound
(setq ring-bell-function 'ignore)

;; prefer vertical splits
(setq split-width-threshold nil)

;; automatically wrap lines
(global-visual-line-mode 1)

;; set default font
(set-face-attribute 'default nil
                    :family "Hack"
                    :height 140
                    :weight 'normal
                    :width 'normal)
(set-fontset-font t 'unicode (font-spec :family "Hack Nerd Font Mono" :height 200) nil)
(set-fontset-font t 'symbol (font-spec :family "Font Awesome 7 Free" :height 200) nil)

;; color scheme
(use-package catppuccin-theme
  :custom (catppuccin-flavor 'mocha)
  :config
  (set-frame-parameter nil 'alpha-background 80)
  (add-to-list 'default-frame-alist '(alpha-background . 80))
  (if (daemonp)
      (add-hook 'after-make-frame-functions (lambda (frame)
                                              (select-frame frame)
                                              (catppuccin-set-color 'base "unspecified-bg" 'mocha)
                                              (load-theme 'catppuccin t)))
    (progn (catppuccin-set-color 'base "#000000" 'mocha)
           (load-theme 'catppuccin :no-confirm))))

;; set transparency when running emacs in terminal
(defun on-after-init ()
  (unless (display-graphic-p (selected-frame))
    (set-face-background 'default "unspecified-bg" (selected-frame))))
(add-hook 'window-setup-hook 'on-after-init)

;; mode line
(use-package doom-modeline
  :hook (after-init . doom-modeline-mode))

;; set cursor type and disable cursor blinking
(blink-cursor-mode -1)
(setq-default cursor-type '(hbar . 1))

;; display line numbers
(setq display-line-numbers-width-start t)
(dolist (mode '(prog-mode-hook
                yaml-mode-hook
		        TeX-mode-hook
		        markdown-mode-hook
                org-mode-hook
		        conf-mode-hook))
  (add-hook mode #'display-line-numbers-mode))

;; enable commands hinting when pressing keys
(which-key-mode 1)

;; better help
(use-package helpful
  :bind
  (("C-h f" . helpful-callable)
   ("C-h v" . helpful-variable)
   ("C-h k" . helpful-key)
   ("C-h x" . helpful-command)))

;; better switching between windows
(use-package ace-window
  :bind ("M-o" . ace-window))

(provide 'user-interface)
;;; user-interface.el ends here
