;;; Code: ;; Backup files (setq backup-directory-alist `((".*" . ,temporary-file-directory))) (setq auto-save-file-name-transforms `((".*" ,temporary-file-directory t))) (setq backup-by-copying t) (setq delete-old-versions t kept-new-versions 6 kept-old-versions 2 version-control t) ;; menu bars (menu-bar-mode -1) (toggle-scroll-bar -1) (tool-bar-mode -1) (setq mac-shift-modifier 'meta) ;; 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 (set-face-attribute 'default nil :font "Source Code Pro-10") (set-fontset-font t '(?😊 . ?😎) "Segoe UI Emoji") ;;(set-face-attribute 'default nil :height 110 :family "Consolas") (set-language-environment "UTF-8") (set-default-coding-systems 'utf-8) ;; Cursor (setq-default cursor-type 'bar) (blink-cursor-mode 1) ;; Line numbers (global-linum-mode 1) ;; Minimap (require 'minimap) (minimap-mode 1) (setq-default minimap-window-location "right") (setq-default minimap-highlight-line 1) (setq-default minimap-update-delay 0.5) (setq-default minimap-hide-fringes 1) (setq-default minimap-width-fraction 0.05) (setq-default minimap-dedicated-window 1) ;; Fringe (setq-default left-fringe-width 20) (setq-default right-fringe-width 20) ;; Initialization screen (setq inhibit-splash-screen t) (setq initial-scratch-message "") (setq initial-major-mode 'text-mode) ;; Better undo functionality ;; TODO: Evil mode is disabled for now ;; (require 'evil) ;; (setq evil-want-fine-undo t) ;; Highlight todos (require 'hl-todo) (global-hl-todo-mode 1) ;; Delete highlighted selection (delete-selection-mode 1) ;; Projectile for project navigation (require 'projectile) (projectile-mode +1) (define-key projectile-mode-map (kbd "s-F") 'projectile-grep) (define-key projectile-mode-map [?\s-o] 'projectile-switch-project) (define-key projectile-mode-map [?\s-p] 'projectile-find-file) (add-to-list 'projectile-globally-ignored-directories "*node_modules") ;; Ido mode text matching (require 'ivy) (ivy-mode 1) ;; Don't ask to kill when we have an open line number (setq-default confirm-kill-processes nil) ;; Tree (require 'neotree) (setq neo-smart-open t) (setq projectile-switch-project-action 'neotree-projectile-action) (setq neo-theme (if (display-graphic-p) 'icons 'arrow)) ;; (evil-define-key 'normal neotree-mode-map (kbd "TAB") 'neotree-enter) ;; (evil-define-key 'normal neotree-mode-map (kbd "SPC") 'neotree-quick-look) ;; (evil-define-key 'normal neotree-mode-map (kbd "q") 'neotree-hide) ;; (evil-define-key 'normal neotree-mode-map (kbd "RET") 'neotree-enter) ;; (evil-define-key 'normal neotree-mode-map (kbd "g") 'neotree-refresh) ;; (evil-define-key 'normal neotree-mode-map (kbd "n") 'neotree-next-line) ;; (evil-define-key 'normal neotree-mode-map (kbd "p") 'neotree-previous-line) ;; (evil-define-key 'normal neotree-mode-map (kbd "A") 'neotree-stretch-toggle) ;; (evil-define-key 'normal neotree-mode-map (kbd "H") 'neotree-hidden-file-toggle) (defun my-neotree-mode-hook() "Set the colors of neotree to match my personal taste." (setq left-fringe-width 0) (setq right-fringe-width 0) ) (add-hook 'neotree-mode-hook 'my-neotree-mode-hook) (setq neo-window-width 36) ;; Smooth scroll (setq scroll-margin 7) ;; Line highlighting (global-hl-line-mode 1) (set-face-background 'hl-line "unspecified") (set-face-attribute 'hl-line nil :box '(:line-width -1 :color "gray35" :style nil)) ;; Git (use-package git-gutter :ensure t :hook (prog-mode . git-gutter-mode) :config (setq git-gutter:update-interval 0.02) (setq git-gutter:window-width 1) (set-face-background 'git-gutter:modified "dark magenta") (set-face-background 'git-gutter:deleted "tomato") (set-face-background 'git-gutter:added "forest green")) (custom-set-variables '(git-gutter:modified-sign " ") '(git-gutter:added-sign "++") '(git-gutter:deleted-sign "--")) (use-package git-gutter-fringe :ensure t) ;; Show flycheck always and after save (use-package flycheck :ensure t) (global-flycheck-mode) (add-hook 'after-init-hook #'global-flycheck-mode) ;; Emojis (use-package emojify :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 ;; Global key binds (require 'eglot) (bind-key* (kbd "") #'eglot-rename) (bind-key* (kbd "C-x C-f") 'counsel-find-file) (bind-key* (kbd "M-x") 'counsel-M-x) (bind-key* (kbd "C-;") 'neotree-toggle) (bind-key* (kbd "M-.") 'xref-find-definitions) (bind-key* (kbd "C-x k") 'kill-this-buffer) (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) (neotree-show) (neotree-refresh) (other-window -1)) (bind-key* (kbd "M-n") 'my-create-file) (defun my-create-directory () "Create a directory and refresh neotree." (interactive) (call-interactively #'make-directory) (neotree-show) (neotree-refresh) (other-window -1)) (bind-key* (kbd "M-N") 'my-create-directory) (defun my-delete-file () "Delete a file and refresh neotree." (interactive) (call-interactively #'delete-file) (neotree-show) (neotree-refresh) (other-window -1)) (bind-key* (kbd "M-d") 'my-delete-file) (defun my-delete-directory () "Delete a file and refresh neotree." (interactive) (call-interactively #'delete-directory) (neotree-show) (neotree-refresh) (other-window -1)) (bind-key* (kbd "M-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 "M-r") 'my-rename-file) ;; Company mode for code completion (use-package company :ensure t :defer t :init (add-hook 'after-init-hook 'global-company-mode) :config ;; (use-package company-irony :ensure t :defer t) TODO: Do I need irony? (setq company-idle-delay 0 company-minimum-prefix-length 2 company-show-quick-access t company-tooltip-limit 20 company-dabbrev-downcase nil company-backends '((company-capf company-gtags company-elisp)) ; TODO: do i need company-irony here company-vscode-light-icons-margin 1 ) ) ;; Eglot (use-package eglot :custom (eglot-autoshutdown t) :ensure t :defer 3) ;(set-face-background 'eglot-highlight-symbol-face "lemon chiffon") ;; Vterm (require 'vterm) (require 'vterm-toggle) (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))) (bind-key* (kbd "M-t") 'vterm-toggle) (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) (linum-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")) ) (add-hook 'vterm-mode-hook 'my-vterm-mode-set-colors) ;; Line movement (require 'drag-stuff) (drag-stuff-global-mode) (drag-stuff-define-keys) (provide 'general) ;;; general.el ends here