277 lines
7.9 KiB
EmacsLisp
Executable file
277 lines
7.9 KiB
EmacsLisp
Executable file
;;; ===================== ;;;
|
|
;;; Author: Muha Aliss ;;;
|
|
;;; Mail: muhaaliss@pm.me ;;;
|
|
;;; Edit: 14/04/2024 ;;;
|
|
;;; ===================== ;;;
|
|
|
|
|
|
|
|
;;; ===================== ;;;
|
|
;;; Package ;;;
|
|
;;; ===================== ;;;
|
|
|
|
;; Package signature check disable
|
|
(setq package-check-signature nil)
|
|
|
|
;; Edit package sources
|
|
(require 'package)
|
|
(add-to-list 'package-archives '("MELPA" . "https://melpa.org/packages/") t)
|
|
|
|
;; Initializes the package infrastructure
|
|
(package-initialize)
|
|
|
|
;; Define the package-selected-packages variable and assign the packages i want to it.
|
|
(setq package-selected-packages
|
|
'(gnu-elpa
|
|
gnu-elpa-keyring-update
|
|
use-package
|
|
which-key
|
|
counsel
|
|
all-the-icons
|
|
all-the-icons-dired
|
|
dap-mode
|
|
exec-path-from-shell
|
|
perspective
|
|
))
|
|
|
|
;; Search packages in installed packages,
|
|
(when (cl-find-if-not #'package-installed-p package-selected-packages)
|
|
;; refresh packages list,
|
|
(package-refresh-contents)
|
|
;; install the packages.
|
|
(mapc #'package-install package-selected-packages))
|
|
|
|
|
|
|
|
;;; ===================== ;;;
|
|
;;; Interface ;;;
|
|
;;; ===================== ;;;
|
|
|
|
;; Hide welcome screen
|
|
(setq inhibit-splash-screen t)
|
|
|
|
;; Open bookmark window by default
|
|
(list-bookmarks)
|
|
(switch-to-buffer "*Bookmark List*")
|
|
|
|
;; Display line numbers
|
|
(global-display-line-numbers-mode)
|
|
|
|
;; Set cursor to i-beam
|
|
(setq-default cursor-type 'bar)
|
|
|
|
;; Highlight Current Line
|
|
(global-hl-line-mode 1)
|
|
|
|
;; Up/Down arrow move based on logical lines (newline char) or visual line
|
|
(setq line-move-visual nil)
|
|
|
|
;; Show cursor position within line
|
|
(column-number-mode 1)
|
|
|
|
;; org mode syntax color embeded source code
|
|
(setq org-src-fontify-natively t)
|
|
|
|
;; ivy rich icons
|
|
(use-package all-the-icons-ivy-rich
|
|
:ensure t
|
|
:init (all-the-icons-ivy-rich-mode 1))
|
|
(use-package ivy-rich
|
|
:ensure t
|
|
:init (ivy-rich-mode 1)
|
|
:config
|
|
(setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line))
|
|
|
|
;; Set a theme
|
|
(use-package doom-themes
|
|
:ensure t
|
|
:config
|
|
;; Global settings (defaults)
|
|
(setq doom-themes-enable-bold t ;; if nil, bold is universally disabled
|
|
doom-themes-enable-italic t) ;; if nil, italics is universally disabled
|
|
(load-theme 'doom-one t)
|
|
;; Enable flashing mode-line on errors
|
|
(doom-themes-visual-bell-config)
|
|
;; Enable custom neotree theme (all-the-icons must be installed!)
|
|
(doom-themes-neotree-config)
|
|
;; or for treemacs users
|
|
(setq doom-themes-treemacs-theme "doom-atom") ;; use "doom-colors" for less minimal icon theme
|
|
(doom-themes-treemacs-config)
|
|
;; Corrects (and improves) org-mode's native fontification.
|
|
(doom-themes-org-config))
|
|
|
|
;; Set default window size
|
|
(if (display-graphic-p)
|
|
(progn
|
|
(setq initial-frame-alist
|
|
'(
|
|
(tool-bar-lines . 0)
|
|
(width . 110) ;; chars
|
|
(height . 40) ;; lines
|
|
(left . 787)
|
|
(top . 0)))
|
|
(setq default-frame-alist
|
|
'(
|
|
(tool-bar-lines . 0)
|
|
(width . 110)
|
|
(height . 40)
|
|
(left . 787)
|
|
(top . 0))))
|
|
(progn
|
|
(setq initial-frame-alist '( (tool-bar-lines . 0)))
|
|
(setq default-frame-alist '( (tool-bar-lines . 0)))))
|
|
|
|
;; Set default font
|
|
(cond
|
|
((string-equal system-type "windows-nt") ;; Microsoft Windows
|
|
(when (member "Consolas" (font-family-list))
|
|
(set-frame-font "Consolas-12" t t)))
|
|
((string-equal system-type "darwin") ;; macOS
|
|
(when (member "Menlo" (font-family-list))
|
|
(set-frame-font "Menlo-12" t t)))
|
|
((string-equal system-type "gnu/linux") ;; linux
|
|
(when (member "Source Code Pro" (font-family-list))
|
|
(set-frame-font "Source Code Pro-12" t t))))
|
|
|
|
|
|
|
|
;;; ===================== ;;;
|
|
;;; Editing ;;;
|
|
;;; ===================== ;;;
|
|
|
|
;; Turn on/off line wrap for current buffer.
|
|
(global-visual-line-mode 1)
|
|
|
|
;; Make typing delete/overwrites selected text
|
|
(delete-selection-mode 1)
|
|
|
|
;; Set default tab char's display width to 4 spaces
|
|
(setq-default tab-width 4)
|
|
|
|
;; Make indent commands use space only (never tab character)
|
|
(setq-default indent-tabs-mode nil)
|
|
|
|
;; Make tab key do indent first then completion.
|
|
(setq-default tab-always-indent nil)
|
|
|
|
;; Set highlighting brackets
|
|
(show-paren-mode 1)
|
|
(setq show-paren-style 'mixed)
|
|
|
|
;; Add support for pretty symbols mode
|
|
(global-prettify-symbols-mode 1)
|
|
(defun my-add-pretty-symbol ()
|
|
"make some word display as Unicode symbols"
|
|
(setq prettify-symbols-alist
|
|
'(
|
|
("->" . 8594) ;; → 8594
|
|
("lambda" . 955) ;; λ 955
|
|
("--->" . 10230) ;; ⟶ 10230
|
|
("=>" . 8658) ;; ⇒ 8658
|
|
("map" . 8614) ;; ↦ 8614
|
|
)))
|
|
|
|
;; Hippie expand to words only
|
|
(setq hippie-expand-try-functions-list
|
|
'(
|
|
try-expand-dabbrev
|
|
try-expand-dabbrev-all-buffers
|
|
try-complete-lisp-symbol-partially
|
|
try-complete-lisp-symbol
|
|
try-complete-file-name-partially
|
|
try-complete-file-name))
|
|
|
|
|
|
|
|
;;; ===================== ;;;
|
|
;;; Buffer ;;;
|
|
;;; ===================== ;;;
|
|
|
|
;; ivy config
|
|
(use-package ivy
|
|
:ensure t
|
|
:config
|
|
(ivy-mode)
|
|
(setq ivy-use-virtual-buffers t)
|
|
(setq enable-recursive-minibuffers t)
|
|
;; enable this if you want `swiper' to use it
|
|
;; (setq search-default-mode #'char-fold-to-regexp)
|
|
(define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history))
|
|
|
|
;; Shows key assignments in a mini window.
|
|
(which-key-mode)
|
|
|
|
;; Use short answer
|
|
(if (version< emacs-version "28.1")
|
|
(defalias 'yes-or-no-p 'y-or-n-p)
|
|
(setq use-short-answers t))
|
|
|
|
|
|
|
|
;;; ===================== ;;;
|
|
;;; Hooks ;;;
|
|
;;; ===================== ;;;
|
|
|
|
(add-hook 'tex-mode-hook 'my-add-pretty-symbol)
|
|
(add-hook 'emacs-lisp-mode-hook 'my-add-pretty-symbol)
|
|
(add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
|
|
|
|
|
|
|
|
;;; ===================== ;;;
|
|
;;; Key bindings ;;;
|
|
;;; ===================== ;;;
|
|
|
|
;; Hippie expand keybindings
|
|
(global-set-key (kbd "C-t") 'hippie-expand)
|
|
|
|
;; Move line keybindings.
|
|
(global-set-key (kbd "M-<up>") 'move-line-up)
|
|
(global-set-key (kbd "M-<down>") 'move-line-down)
|
|
|
|
;; Copy or cut current line if no selection keybindings
|
|
(global-set-key (kbd "<f2>") 'xah-cut-line-or-region) ;; cut
|
|
(global-set-key (kbd "<f3>") 'xah-copy-line-or-region) ;; copy
|
|
(global-set-key (kbd "<f4>") 'yank) ;; paste
|
|
|
|
;; Select current line keybinding
|
|
(global-set-key (kbd "M-7") 'xah-select-line)
|
|
|
|
;; Delete batching bracket keybindings
|
|
(global-set-key (kbd "M-<delete>") 'xah-delete-forward-bracket-pairs)
|
|
(global-set-key (kbd "M-S-<delete>") 'xah-delete-backward-bracket-text)
|
|
|
|
;; Goto matching bracket keybindings
|
|
(global-set-key (kbd "M-<left>") 'xah-goto-matching-bracket)
|
|
(global-set-key (kbd "M-<right>") 'xah-goto-matching-bracket)
|
|
|
|
;; ivy
|
|
(global-set-key "\C-s" 'swiper)
|
|
(global-set-key (kbd "M-x") 'counsel-M-x)
|
|
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
|
|
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
|
|
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
|
|
(global-set-key (kbd "<f1> o") 'counsel-describe-symbol)
|
|
(global-set-key (kbd "<f1> l") 'counsel-find-library)
|
|
(global-set-key (kbd "<f5>") 'ivy-resume)
|
|
|
|
|
|
;;; ===================== ;;;
|
|
;;; Load other .el files ;;;
|
|
;;; ===================== ;;;
|
|
|
|
(load "~/.emacs.d/xah")
|
|
(load "~/.emacs.d/rust")
|
|
(custom-set-variables
|
|
;; custom-set-variables was added by Custom.
|
|
;; If you edit it by hand, you could mess it up, so be careful.
|
|
;; Your init file should contain only one such instance.
|
|
;; If there is more than one, they won't work right.
|
|
'(package-selected-packages
|
|
'(rustic flycheck company doom-themes all-the-icons-ivy-rich gnu-elpa gnu-elpa-keyring-update use-package which-key counsel all-the-icons all-the-icons-dired dap-mode)))
|
|
(custom-set-faces
|
|
;; custom-set-faces was added by Custom.
|
|
;; If you edit it by hand, you could mess it up, so be careful.
|
|
;; Your init file should contain only one such instance.
|
|
;; If there is more than one, they won't work right.
|
|
)
|