;; load package manager, add the Melpa package registry
(require 'package)
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
(package-initialize)
;; bootstrap use-package
(unless (package-installed-p '(use-package))
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
;; ui
(tool-bar-mode -1) ;; disable toolbar
(menu-bar-mode -1) ;; disable menubar
(scroll-bar-mode -1) ;; disable scrollbar
(fringe-mode 1) ;; shrink fringes
(show-paren-mode 1) ;; show parent parentheses
(global-hl-line-mode t) ;; highlight current line
(setq inhibit-startup-message t) ;; disable startup screen
(setq x-select-enable-clipboard t) ;; enable clipboard outside emacs
(setq ring-bell-function 'ignore) ;; disable ring-bell
(defalias 'yes-or-no-p 'y-or-n-p) ;; transform yes-or-no to y-or-n
(setq scroll-conservatively 100) ;; conservative scrolling
(global-prettify-symbols-mode t) ;; prettify symbols mode
(load-theme 'manoj-dark t)
;; code related
(display-line-numbers-mode 1) ;; show line numbers
(setq-default display-line-numbers 'relative) ;; set them to be relative
(setq electric-pair-pairs '((?\{ . ?\})
(?\( . ?\))
(?\[ . ?\])
(?\" . ?\"))) ;; enable bracket pair-matching
(electric-pair-mode t) ;; enable bracket pair-matching
(setq-default indent-tabs-mode nil) ;; no tab indent
;; backups
(setq make-backup-files nil) ;; disable backup
(setq auto-save-default nil) ;; disable backup
(setq c-default-style "linux"
c-basic-offset 4)
(use-package async
:ensure t
:init
(dired-async-mode 1))
(use-package diminish
:ensure t)
;; (use-package company
;; :ensure t
;; :custom
;; (global-company-mode 1)
;; (company-begin-commands '(self-insert-command))
;; (company-idle-delay .1)
;; (company-minimum-prefix-length 2)
;; (company-show-numbers t)
;; (company-tooltip-align-annotations 't)
;; (global-company-mode t))
(use-package eshell
:config
(setq eshell-prompt-regexp "^[^αλ\n]*[αλ] ")
(setq eshell-prompt-function
(lambda nil
(concat
(if (string= (eshell/pwd) (getenv "HOME"))
(propertize "~" 'face `(:foreground "#99CCFF"))
(replace-regexp-in-string
(getenv "HOME")
(propertize "~" 'face `(:foreground "#99CCFF"))
(propertize (eshell/pwd) 'face `(:foreground "#99CCFF"))))
(if (= (user-uid) 0)
(propertize " α " 'face `(:foreground "#FF6666"))
(propertize " λ " 'face `(:foreground "#FF1493"))))))
(setq eshell-highlight-prompt nil)
(defalias 'open 'find-file-other-window)
(defalias 'clean 'eshell/clear-scrollback)
(defun eshell/sudo-open (filename)
"Open a file as root in Eshell."
(let ((qual-filename (if (string-match "^/" filename)
filename
(concat (expand-file-name (eshell/pwd)) "/" filename))))
(switch-to-buffer
(find-file-noselect
(concat "/sudo::" qual-filename)))))
(defun eshell-other-window ()
"Create or visit an eshell buffer."
(interactive)
(if (not (get-buffer "*eshell*"))
(progn
(split-window-sensibly (selected-window))
(other-window 1)
(eshell))
(switch-to-buffer-other-window "*eshell*")))
(global-set-key (kbd "<s-C-return>") 'eshell-other-window))
;; (use-package evil
;; :ensure t
;; :defer nil
;; :init
;; (setq evil-want-keybinding nil)
;; (setq evil-want-C-u-scroll t)
;; :config
;; (evil-mode 1))
(use-package exec-path-from-shell
:ensure t
:config
(exec-path-from-shell-initialize))
(use-package geiser
:ensure t
:config
(setq geiser-active-implementations '(guile)))
(use-package ido
:init (ido-mode 1)
:config
(use-package ido-vertical-mode
:ensure t
:init
(ido-vertical-mode 1)
:config
(setq ido-vertical-define-keys 'C-n-C-p-up-and-down))
(setq ido-enable-flex-matching t)
(setq ido-create-new-buffer 'always)
(setq ido-everywhere t))
(use-package magit :ensure t) ;; it's git magic
(use-package neotree
:ensure t
:bind ([f8] . 'neotree-toggle))
(use-package uniquify
:config
(setq uniquify-buffer-name-style 'forward))
(use-package swiper
:ensure t
:bind ("C-s" . 'swiper))
(use-package switch-window :ensure t
:config
(setq switch-window-input-style 'minibuffer)
(setq switch-window-increase 4)
(setq switch-window-threshold 2)
(setq switch-window-shortcut-style 'qwerty)
(setq switch-window-qwerty-shortcuts
'("a" "s" "d" "f" "j" "k" "l"))
:bind
([remap other-window] . switch-window))
(use-package which-key
:ensure t
:diminish which-key-mode
:config
(which-key-mode)
(which-key-setup-side-window-right-bottom))
(global-set-key (kbd "C-x C-b") 'ibuffer)
;; programming modes
(use-package go-mode
:ensure t
:config
(setq gofmt-command "goimports")
(add-hook 'before-save-hook 'gofmt-before-save))
(use-package nix-mode
:mode "\\.nix\\'")