;;; Code: (set-language-environment "UTF-8") (set-default-coding-systems 'utf-8) ;; Initialization screen (setq fancy-splash-image "~/.emacs.d/images/true.png") (setq inhibit-startup-screen t initial-scratch-message nil sentence-end-double-space nil ring-bell-function 'ignore frame-resize-pixelwise t) ;; Backup files (setq make-backup-files nil auto-save-default nil create-lockfiles nil) (setq delete-old-versions t kept-new-versions 6 kept-old-versions 2 version-control t) (set-face-attribute 'default nil :family "JetBrains Mono" :height 100 :weight 'normal :width 'normal) ;; Don't ask to kill when we have an open line number (setq-default confirm-kill-processes nil) ;; Line highlighting (global-hl-line-mode 1) ;; Initial major mode (setq initial-major-mode 'text-mode) ;; Auto revert mode to reload disk (global-auto-revert-mode 1) ;; menu bars (menu-bar-mode -1) (toggle-scroll-bar -1) (tool-bar-mode -1) (setq mac-shift-modifier 'meta) ;; Modeline (use-package mood-line ;; Enable mood-line :config (mood-line-mode)) ;; Disable major modes on long lines (global-so-long-mode 1) ;; Ability to fold regions (add-hook 'javascript-mode-hook (lambda () (hs-minor-mode 1))) (add-hook 'typescript-mode-hook (lambda () (hs-minor-mode 1))) (add-hook 'c-mode-hook (lambda () (hs-minor-mode 1))) (add-hook 'python-mode-hook (lambda () (hs-minor-mode 1))) (add-hook 'emacs-lisp-mode-hook (lambda () (hs-minor-mode 1))) ;; Default Values (setq-default indent-tabs-mode nil) ; use spaces only if nil (setq-default tab-width 2) ; Assuming you want your tabs to be four spaces wide ;; Cursor (setq-default cursor-type 'bar) (blink-cursor-mode 1) ;; Line numbers (global-display-line-numbers-mode 1) ;; Show number of matches (setq isearch-lazy-highlight t) (setq isearch-lazy-count t) ;; Fringe (setq-default left-fringe-width 20) (setq-default right-fringe-width 20) ;; Highlight todos (use-package hl-todo :ensure t :config (global-hl-todo-mode 1) ) ;; Delete highlighted selection (delete-selection-mode 1) (use-package vertico :ensure t :init (vertico-mode) ;; Different scroll margin ;; (setq vertico-scroll-margin 0) ;; Show more candidates ;; (setq vertico-count 20) ;; Grow and shrink the Vertico minibuffer ;; (setq vertico-resize t) ;; Optionally enable cycling for `vertico-next' and `vertico-previous'. ;; (setq vertico-cycle t) ) (use-package orderless :ensure t :init ;; Configure a custom style dispatcher (see the Consult wiki) ;; (setq orderless-style-dispatchers '(+orderless-consult-dispatch orderless-affix-dispatch) ;; orderless-component-separator #'orderless-escapable-split-on-space) (setq completion-styles '(orderless basic) completion-category-defaults nil completion-category-overrides '((file (styles partial-completion))))) ;; Enable rich annotations using the Marginalia package (use-package marginalia :ensure t ;; Bind `marginalia-cycle' locally in the minibuffer. To make the binding ;; available in the *Completions* buffer, add it to the ;; `completion-list-mode-map'. :bind (:map minibuffer-local-map ("M-A" . marginalia-cycle)) ;; The :init section is always executed. :init ;; Marginalia must be actived in the :init section of use-package such that ;; the mode gets enabled right away. Note that this forces loading the ;; package. (marginalia-mode)) (use-package rg :ensure t) ;; Projectile for project navigation (use-package projectile :ensure t :config (projectile-mode +1) (setq projectile-switch-project-action 'treemacs-add-and-display-current-project-exclusively) (setq projectile-indexing-method 'native) (setq projectile-enable-caching t) (setq projectile-use-git-grep t) (add-to-list 'projectile-globally-ignored-directories "node_modules") (add-to-list 'projectile-globally-ignored-directories "elpa") (add-to-list 'projectile-globally-ignored-directories "build") (add-to-list 'projectile-globally-ignored-directories "dist") (add-to-list 'projectile-project-root-files "package.json") (add-to-list 'projectile-globally-ignored-files "package-lock.json") (define-key projectile-mode-map (kbd "C-c p f") 'projectile-ripgrep) (define-key projectile-mode-map (kbd "C-c p o") 'projectile-switch-project) (define-key projectile-mode-map (kbd "C-c p p") 'projectile-find-file) ) ;; Tree (use-package treemacs :ensure t :config (add-hook 'treemacs-mode-hook treemacs-filewatch-mode) (add-hook 'treemacs-mode-hook treemacs-git-mode) ) (use-package treemacs-projectile :ensure t :after (treemacs projectile)) ;; Git (use-package git-gutter :ensure t :hook (prog-mode . git-gutter-mode) :config (setq git-gutter:update-interval 1) (setq git-gutter:window-width 1)) (use-package git-gutter-fringe :ensure t :config (define-fringe-bitmap 'git-gutter-fr:added [224] nil nil '(center repeated)) (define-fringe-bitmap 'git-gutter-fr:modified [224] nil nil '(center repeated)) (define-fringe-bitmap 'git-gutter-fr:deleted [128 192 224 240] nil nil 'bottom)) (use-package magit :ensure t) ;; Emojis ;; (use-package emojify ;; :ensure t ;; :config ;; (when (member "Segoe UI Emoji" (font-family-list)) ;; (set-fontset-font ;; t 'symbol (font-spec :family "Segoe UI Emoji") nil 'prepend)) ;; (setq emojify-display-style 'unicode) ;; (setq emojify-emoji-styles '(unicode)) ;; (bind-key* (kbd "C-c e") #'emojify-insert-emoji)) ; override binding in any mode ;; icons (use-package all-the-icons :ensure t :if (display-graphic-p)) ;; Global key binds (bind-key* (kbd "M-.") 'xref-find-definitions) (bind-key* (kbd "C-x k") 'kill-this-buffer) (bind-key* (kbd "C-C ;") 'treemacs) (defun my-create-file (filename) "Create a file and refresh neotree. FILENAME File to create." (interactive (list (read-file-name "Enter your file name: " nil nil nil (file-name-nondirectory "")))) (make-empty-file filename) (find-file filename)) (bind-key* (kbd "C-c f n") 'my-create-file) (defun my-create-directory () "Create a directory and refresh neotree." (interactive) (call-interactively #'make-directory) (other-window -1)) (bind-key* (kbd "C-c d n") 'my-create-directory) (defun my-delete-file () "Delete a file and refresh neotree." (interactive) (call-interactively #'delete-file)) (bind-key* (kbd "C-c f d") 'my-delete-file) (defun my-delete-directory () "Delete a file and refresh neotree." (interactive) (call-interactively #'delete-directory)) (bind-key* (kbd "C-c d d") 'my-delete-directory) ;; source: http://steve.yegge.googlepages.com/my-dot-emacs-file (defun my-rename-file (new-name) "Renames both current buffer and file it's visiting to NEW-NAME." (interactive "sNew name: ") (let ((name (buffer-name)) (filename (buffer-file-name))) (if (not filename) (message "Buffer '%s' is not visiting a file!" name) (if (get-buffer new-name) (message "A buffer named '%s' already exists!" new-name) (progn (rename-file filename new-name 1) (rename-buffer new-name) (set-visited-file-name new-name) (set-buffer-modified-p nil) ;(neotree-show) ;(neotree-refresh) (other-window -1)))))) (bind-key* (kbd "C-c f r") 'my-rename-file) (use-package company :ensure t :defer t :init (add-hook 'after-init-hook 'global-company-mode) :config (setq company-idle-delay 0.1 company-minimum-prefix-length 2 company-tooltip-limit 10 company-backends '((company-capf company-gtags company-elisp company-css company-dabbrev company-nxml)) ) ) (use-package company-quickhelp :ensure t :defer t :init (company-quickhelp-mode 1) :config (setq company-quickhelp-delay 0.1) (setq company-quickhelp-color-background (face-attribute 'default :background)) ) ;; Eglot (use-package eglot :custom (eglot-autoshutdown t) :ensure t :bind ("" . #'eglot-rename)) (set-face-underline 'eglot-highlight-symbol-face t) ;; Vterm (defun my-vterm-mode-set-colors() "Set the colors of vterm to match my personal taste." (setq-local global-hl-line-mode nil) ;(turn-off-evil-mode) (display-line-numbers-mode -1) (setq left-fringe-width 0) (setq right-fringe-width 0) (set-window-fringes (selected-window) 0 0 nil) (face-remap-add-relative 'default '(:background "#232627")) (face-remap-add-relative 'default '(:foreground"#fcfcfc")) ) (use-package vterm :ensure t :defer t ) (add-hook 'vterm-mode-hook 'my-vterm-mode-set-colors) (use-package vterm-toggle :ensure t :config (setq vterm-toggle-fullscreen-p nil) (add-to-list 'display-buffer-alist '((lambda (buffer-or-name _) (let ((buffer (get-buffer buffer-or-name))) (with-current-buffer buffer (or (equal major-mode 'vterm-mode) (string-prefix-p vterm-buffer-name (buffer-name buffer)))))) (display-buffer-reuse-window display-buffer-at-bottom) ;;(display-buffer-reuse-window display-buffer-in-direction) ;;display-buffer-in-direction/direction/dedicated is added in emacs27 ;;(direction . bottom) ;;(dedicated . t) ;dedicated is supported in emacs27 (reusable-frames . visible) (window-height . 0.2))) :after (vterm)) (bind-key* (kbd "M-t") 'vterm-toggle) ;; Line movement (use-package drag-stuff :config (drag-stuff-global-mode) ;; Note: I do NOT use (drag-stuff-define-keys) because I want M- to work in org mode (define-key drag-stuff-mode-map (drag-stuff--kbd 'up) 'drag-stuff-up) (define-key drag-stuff-mode-map (drag-stuff--kbd 'down) 'drag-stuff-down) ) ;; Copy the entire buffer. (defun my-copy-all () "Copy entire buffer to clipboard." (interactive) (clipboard-kill-ring-save (point-min) (point-max))) (use-package flycheck :ensure t :config (setq flycheck-check-syntax-automatically '(save mode-enable)) '(flycheck-idle-change-delay 1)) ;; Snippets (use-package yasnippet :ensure t :config ;(setq yas-snippet-dirs ; '("~/.emacs.d/snippets" ;; personal snippets ; )) (yas-global-mode 1) (bind-key* (kbd "C-c y i") 'yas/insert-snippet) ) (use-package yasnippet-snippets :ensure t) (provide 'general) ;;; general.el ends here