forked from muhaaliss/mydotfiles
Cleaning and beautification done
This commit is contained in:
parent
ef0e1885c6
commit
3c1ae6948f
1 changed files with 138 additions and 203 deletions
341
init.el
341
init.el
|
@ -1,70 +1,90 @@
|
|||
;;; Author: Muha Aliss
|
||||
;;; Mail: muhaaliss@pm.me
|
||||
;;; Create: 07/09/2023
|
||||
;;; Edit: 09/09/2023
|
||||
;;; ==================================================
|
||||
;;; -------------> Author: Muha Aliss <---------------
|
||||
;;; -------------> Mail: muhaaliss@pm.me <------------
|
||||
;;; -------------> Create: 07/09/2023 <---------------
|
||||
;;; -------------> Edit: 21/09/2023 <-----------------
|
||||
;;; ==================================================
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;;; ---> Package
|
||||
;;; ==================================================
|
||||
;;; -------------------> Package <--------------------
|
||||
;;; ==================================================
|
||||
|
||||
;; Package signature check disable
|
||||
(when (version<= "25" emacs-version)
|
||||
(when (version<= "26.1" emacs-version)
|
||||
(setq package-check-signature nil))
|
||||
|
||||
;; Edit package sources
|
||||
(require 'package)
|
||||
(add-to-list 'package-archives '("MELPA" . "https://melpa.org/packages/") t)
|
||||
|
||||
|
||||
;; List the packages you want
|
||||
(setq package-list '(gnu-elpa gnu-elpa-keyring-update atom-one-dark-theme))
|
||||
|
||||
|
||||
|
||||
;; List the repositories containing them
|
||||
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
|
||||
("melpa" . "https://melpa.org/packages/")))
|
||||
|
||||
|
||||
|
||||
;; Activate all the packages (in particular autoloads)
|
||||
;; 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 doom-themes bookmark lsp-mode all-the-icons yasnippet lsp-treemacs helm-lsp projectile hydra flycheck company avy which-key helm-xref dap-mode elpy))
|
||||
|
||||
|
||||
;; Fetch the list of packages available
|
||||
(unless package-archive-contents
|
||||
(package-refresh-contents))
|
||||
|
||||
|
||||
|
||||
;; İnstall the missing packages
|
||||
(dolist (package package-list)
|
||||
(unless (package-installed-p package)
|
||||
(package-install package)))
|
||||
;; 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
|
||||
;;; ==================================================
|
||||
;;; ------------------> Interface <-------------------
|
||||
;;; ==================================================
|
||||
|
||||
;; Hide welcome screen and open bookmark
|
||||
;; Hide welcome screen
|
||||
(setq inhibit-splash-screen t)
|
||||
(require 'bookmark)
|
||||
|
||||
;; Open bookmark window by default
|
||||
(list-bookmarks)
|
||||
(switch-to-buffer "*Bookmark List*")
|
||||
|
||||
|
||||
;; Display line numbers
|
||||
(when (version<= "26.1" emacs-version)
|
||||
(global-display-line-numbers-mode))
|
||||
|
||||
;; Set cursor to i-beam
|
||||
(modify-all-frames-parameters (list (cons 'cursor-type 'bar)))
|
||||
(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)
|
||||
|
||||
;; Set a theme
|
||||
(load-theme 'atom-one-dark t)
|
||||
|
||||
|
||||
(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)
|
||||
|
@ -74,7 +94,6 @@
|
|||
(tool-bar-lines . 0)
|
||||
(width . 110) ; chars
|
||||
(height . 40) ; lines
|
||||
;(background-color . "honeydew")
|
||||
(left . 50)
|
||||
(top . 50)))
|
||||
(setq default-frame-alist
|
||||
|
@ -82,35 +101,12 @@
|
|||
(tool-bar-lines . 0)
|
||||
(width . 110)
|
||||
(height . 40)
|
||||
;(background-color . "honeydew")
|
||||
(left . 50)
|
||||
(top . 50))))
|
||||
(progn
|
||||
(setq initial-frame-alist '( (tool-bar-lines . 0)))
|
||||
(setq default-frame-alist '( (tool-bar-lines . 0)))))
|
||||
|
||||
|
||||
|
||||
;; Show line number global
|
||||
(when (version<= "26.1" emacs-version)
|
||||
(global-display-line-numbers-mode))
|
||||
|
||||
|
||||
;; 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)
|
||||
|
||||
|
||||
|
||||
;; Set default font
|
||||
(cond
|
||||
((string-equal system-type "windows-nt") ; Microsoft Windows
|
||||
|
@ -125,54 +121,31 @@
|
|||
|
||||
|
||||
|
||||
;; org mode syntax color embeded source code
|
||||
(setq org-src-fontify-natively t)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;;; ---> Editing
|
||||
|
||||
;; Stop auto save and backup
|
||||
(setq auto-save-default nil)
|
||||
(setq make-backup-files nil)
|
||||
(setq backup-by-copying 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)
|
||||
(progn
|
||||
(setq-default indent-tabs-mode nil))
|
||||
|
||||
|
||||
(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 ()
|
||||
|
@ -186,18 +159,6 @@
|
|||
("map" . 8614) ; ↦ 8614
|
||||
)))
|
||||
|
||||
;; Pretty symbols hook for some major modes
|
||||
(add-hook 'clojure-mode-hook 'my-add-pretty-symbol)
|
||||
(add-hook 'haskell-mode-hook 'my-add-pretty-symbol)
|
||||
(add-hook 'tex-mode-hook 'my-add-pretty-symbol)
|
||||
(add-hook 'emacs-lisp-mode-hook 'my-add-pretty-symbol)
|
||||
(add-hook 'python-mode-hook 'my-add-pretty-symbol)
|
||||
|
||||
|
||||
|
||||
;; Hippie expand keybindings
|
||||
(global-set-key (kbd "C-t") 'hippie-expand)
|
||||
|
||||
;; Hippie expand to words only
|
||||
(setq hippie-expand-try-functions-list
|
||||
'(
|
||||
|
@ -213,11 +174,6 @@
|
|||
;; try-expand-line
|
||||
))
|
||||
|
||||
|
||||
|
||||
;; Select current line keybinding
|
||||
(global-set-key (kbd "M-7") 'xah-select-line)
|
||||
|
||||
(defun xah-select-line ()
|
||||
"Select current line. If region is active, extend selection downward by line.
|
||||
If `visual-line-mode' is on, consider line as visual line.
|
||||
|
@ -242,13 +198,6 @@ Version: 2017-11-01 2021-03-19 2023-07-16"
|
|||
(push-mark (line-beginning-position) t t)
|
||||
(end-of-line)))))
|
||||
|
||||
;; 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
|
||||
|
||||
|
||||
|
||||
;; Copy current line if no selection
|
||||
(defun xah-copy-line-or-region ()
|
||||
"Copy current line or selection.
|
||||
|
@ -287,8 +236,6 @@ Version: 2010-05-21 2022-10-03"
|
|||
(end-of-line)
|
||||
(forward-char))))))))
|
||||
|
||||
|
||||
|
||||
;; Cut current line if no selection
|
||||
(defun xah-cut-line-or-region ()
|
||||
"Cut current line or selection.
|
||||
|
@ -305,12 +252,6 @@ Version: 2010-05-21 2015-06-10"
|
|||
(kill-region (region-beginning) (region-end) t)
|
||||
(kill-region (line-beginning-position) (line-beginning-position 2))))))
|
||||
|
||||
|
||||
|
||||
;; Move line keybindings.
|
||||
(global-set-key (kbd "M-<up>") 'move-line-up)
|
||||
(global-set-key (kbd "M-<down>") 'move-line-down)
|
||||
|
||||
;; Move the current line up or down by N lines.
|
||||
(defun move-line (n)
|
||||
(interactive "p")
|
||||
|
@ -344,8 +285,6 @@ Version: 2010-05-21 2015-06-10"
|
|||
(transpose-lines 1)
|
||||
(forward-line -1)))
|
||||
|
||||
|
||||
|
||||
;; Delete the matching brackets
|
||||
(defun xah-delete-forward-bracket-pairs (&optional DeleteInnerTextQ)
|
||||
"Delete the matching brackets to the right of cursor including the inner text.
|
||||
|
@ -463,11 +402,6 @@ Version: 2017-07-02 2023-07-22 2023-07-30"
|
|||
(t
|
||||
(delete-char -1)))))
|
||||
|
||||
;; 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)
|
||||
|
||||
|
||||
(defvar xah-brackets '("“”" "()" "[]" "{}" "<>" "<>" "()" "[]" "{}" "⦅⦆" "〚〛" "⦃⦄" "‹›" "«»" "「」" "〈〉" "《》" "【】" "〔〕" "⦗⦘" "『』" "〖〗" "〘〙" "「」" "⟦⟧" "⟨⟩" "⟪⟫" "⟮⟯" "⟬⟭" "⌈⌉" "⌊⌋" "⦇⦈" "⦉⦊" "❛❜" "❝❞" "❨❩" "❪❫" "❴❵" "❬❭" "❮❯" "❰❱" "❲❳" "〈〉" "⦑⦒" "⧼⧽" "﹙﹚" "﹛﹜" "﹝﹞" "⁽⁾" "₍₎" "⦋⦌" "⦍⦎" "⦏⦐" "⁅⁆" "⸢⸣" "⸤⸥" "⟅⟆" "⦓⦔" "⦕⦖" "⸦⸧" "⸨⸩" "⦅⦆")
|
||||
"A list of strings, each element is a string of 2 chars, the left bracket and a matching right bracket.
|
||||
Used by `xah-select-text-in-quote' and others.")
|
||||
|
@ -499,58 +433,38 @@ Version: 2016-11-22 2023-07-22"
|
|||
(backward-sexp))
|
||||
(t (backward-up-list 1 'ESCAPE-STRINGS 'NO-SYNTAX-CROSSING)))))
|
||||
|
||||
;; Goto matching bracket keybindings
|
||||
(global-set-key (kbd "M-<left>") 'xah-goto-matching-bracket)
|
||||
(global-set-key (kbd "M-<right>") 'xah-goto-matching-bracket)
|
||||
|
||||
|
||||
|
||||
|
||||
;;; ==================================================
|
||||
;;; --------------------> Buffer <--------------------
|
||||
;;; ==================================================
|
||||
|
||||
;;; ---> Buffer
|
||||
;; Complete file names, buffer names, or any other Emacs interactions
|
||||
(helm-mode)
|
||||
|
||||
;; Make ibuffer default
|
||||
(defalias 'list-buffers 'ibuffer)
|
||||
;; Change the functionality of some default functions.
|
||||
(define-key global-map [remap find-file] #'helm-find-files)
|
||||
(define-key global-map [remap execute-extended-command] #'helm-M-x)
|
||||
(define-key global-map [remap switch-to-buffer] #'helm-mini)
|
||||
|
||||
;; Minibuffer setup
|
||||
(progn
|
||||
(setq enable-recursive-minibuffers t)
|
||||
(savehist-mode 0)
|
||||
;; big minibuffer height, for ido to show choices vertically
|
||||
(setq max-mini-window-height 0.5)
|
||||
;; minibuffer, stop cursor going into prompt
|
||||
(customize-set-variable
|
||||
'minibuffer-prompt-properties
|
||||
(quote (read-only t cursor-intangible t face minibuffer-prompt))))
|
||||
|
||||
;; Make buffer switch command do suggestions, also for find-file command
|
||||
(if (version< emacs-version "28.1")
|
||||
(progn
|
||||
(progn
|
||||
(require 'ido)
|
||||
(ido-mode 1)
|
||||
;; show choices vertically
|
||||
(setf (nth 2 ido-decorations) "\n")
|
||||
;; show any name that has the chars you typed
|
||||
(setq ido-enable-flex-matching t)
|
||||
;; use current pane for newly opened file
|
||||
(setq ido-default-file-method 'selected-window)
|
||||
;; use current pane for newly switched buffer
|
||||
(setq ido-default-buffer-method 'selected-window)
|
||||
)
|
||||
(progn
|
||||
;; minibuffer enhanced completion icomplete
|
||||
(require 'icomplete)
|
||||
(icomplete-mode 1)
|
||||
;; show choices vertically
|
||||
(setq icomplete-separator "\n")
|
||||
(setq icomplete-hide-common-prefix nil)
|
||||
(setq icomplete-in-buffer t)
|
||||
(define-key icomplete-minibuffer-map (kbd "<right>") 'icomplete-forward-completions)
|
||||
(define-key icomplete-minibuffer-map (kbd "<left>") 'icomplete-backward-completions)))
|
||||
(fido-vertical-mode 1))
|
||||
;; Shows key assignments in a mini window.
|
||||
(which-key-mode)
|
||||
|
||||
;; Garbage collector
|
||||
(setq gc-cons-threshold (* 100 1024 1024)
|
||||
read-process-output-max (* 1024 1024)
|
||||
treemacs-space-between-root-nodes nil
|
||||
company-idle-delay 0.0
|
||||
company-minimum-prefix-length 1
|
||||
lsp-idle-delay 0.1) ;; clangd is fast
|
||||
|
||||
;; lsp-mode config
|
||||
(with-eval-after-load 'lsp-mode
|
||||
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration)
|
||||
(require 'dap-cpptools)
|
||||
(yas-global-mode))
|
||||
|
||||
;; Use short answer
|
||||
(if (version< emacs-version "28.1")
|
||||
|
@ -561,37 +475,58 @@ Version: 2016-11-22 2023-07-22"
|
|||
|
||||
|
||||
|
||||
;;; ---> Load other .el files
|
||||
;;; ==================================================
|
||||
;;; --------------------> Hooks <---------------------
|
||||
;;; ==================================================
|
||||
|
||||
(add-hook 'clojure-mode-hook 'my-add-pretty-symbol)
|
||||
(add-hook 'haskell-mode-hook 'my-add-pretty-symbol)
|
||||
(add-hook 'tex-mode-hook 'my-add-pretty-symbol)
|
||||
(add-hook 'emacs-lisp-mode-hook 'my-add-pretty-symbol)
|
||||
(add-hook 'python-mode-hook 'my-add-pretty-symbol)
|
||||
(add-hook 'c-mode-hook 'lsp)
|
||||
(add-hook 'c++-mode-hook 'lsp)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;;; ==================================================
|
||||
;;; ----------------> 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)
|
||||
|
||||
;(gloab-set-key (kbd "C-c l") lsp-keymap-prefix)
|
||||
(setq lsp-keymap-prefix "C-c l")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;;; ==================================================
|
||||
;;; ------------> Load other .el files <--------------
|
||||
;;; ==================================================
|
||||
|
||||
(load "~/.emacs.d/my-abbrev.el")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;;; ---> Get value PATH
|
||||
|
||||
;; get value of env var PATH
|
||||
(getenv "PATH")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;;; ---> Emacs auto added
|
||||
|
||||
(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.
|
||||
'(custom-enabled-themes '(atom-one-dark))
|
||||
'(custom-safe-themes
|
||||
'("0c860c4fe9df8cff6484c54d2ae263f19d935e4ff57019999edbda9c7eda50b8" default))
|
||||
'(package-selected-packages '(gnu-elpa-keyring-update gnu-elpa atom-one-dark-theme)))
|
||||
(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.
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue