1
0
mirror of https://github.com/sameer1612/.dotfiles.git synced 2025-02-19 19:10:07 +02:00
2024-10-11 09:30:57 +05:30

419 lines
18 KiB
EmacsLisp

(setq gc-cons-threshold #x40000000)
(setq read-process-output-max (* 1024 1024 4))
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(defcustom ek-use-nerd-fonts t
"Configuration for using Nerd Fonts Symbols."
:type 'boolean
:group 'appearance)
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
(load (locate-user-emacs-file "packages/emacs.el"))
(load (locate-user-emacs-file "packages/window.el"))
(use-package dired
:ensure nil ;; This is built-in, no need to fetch it.
:custom
(dired-listing-switches "-lah --group-directories-first") ;; Display files in a human-readable format and group directories first.
(dired-dwim-target t) ;; Enable "do what I mean" for target directories.
(dired-guess-shell-alist-user
'(("\\.\\(png\\|jpe?g\\|tiff\\)" "feh" "xdg-open" "open") ;; Open image files with `feh' or the default viewer.
("\\.\\(mp[34]\\|m4a\\|ogg\\|flac\\|webm\\|mkv\\)" "mpv" "xdg-open" "open") ;; Open audio and video files with `mpv'.
(".*" "open" "xdg-open"))) ;; Default opening command for other files.
(dired-kill-when-opening-new-dired-buffer t) ;; Close the previous buffer when opening a new `dired' instance.
:config
(when (eq system-type 'darwin)
(let ((gls (executable-find "gls"))) ;; Use GNU ls on macOS if available.
(when gls
(setq insert-directory-program gls)))))
(use-package isearch
:ensure nil ;; This is built-in, no need to fetch it.
:config
(setq isearch-lazy-count t) ;; Enable lazy counting to show current match information.
(setq lazy-count-prefix-format "(%s/%s) ") ;; Format for displaying current match count.
(setq lazy-count-suffix-format nil) ;; Disable suffix formatting for match count.
(setq search-whitespace-regexp ".*?") ;; Allow searching across whitespace.
:bind (("C-s" . isearch-forward) ;; Bind C-s to forward isearch.
("C-r" . isearch-backward))) ;; Bind C-r to backward isearch.
(use-package vc
:ensure nil ;; This is built-in, no need to fetch it.
:defer t
:bind
(("C-x v d" . vc-dir) ;; Open VC directory for version control status.
("C-x v =" . vc-diff) ;; Show differences for the current file.
("C-x v D" . vc-root-diff) ;; Show differences for the entire repository.
("C-x v v" . vc-next-action)) ;; Perform the next version control action.
:config
(setq vc-annotate-color-map
'((20 . "#f5e0dc")
(40 . "#f2cdcd")
(60 . "#f5c2e7")
(80 . "#cba6f7")
(100 . "#f38ba8")
(120 . "#eba0ac")
(140 . "#fab387")
(160 . "#f9e2af")
(180 . "#a6e3a1")
(200 . "#94e2d5")
(220 . "#89dceb")
(240 . "#74c7ec")
(260 . "#89b4fa")
(280 . "#b4befe"))))
(use-package eldoc
:ensure nil ;; This is built-in, no need to fetch it.
:init
(global-eldoc-mode))
(use-package flymake
:ensure nil ;; This is built-in, no need to fetch it.
:defer t
:hook (prog-mode . flymake-mode)
:custom
(flymake-margin-indicators-string
'((error "" compilation-error) (warning "»" compilation-warning)
(note "»" compilation-info))))
(use-package which-key
:ensure nil ;; This is built-in, no need to fetch it.
:defer t ;; Defer loading Which-Key until after init.
:hook
(after-init . which-key-mode)) ;; Enable which-key mode after initialization.
(use-package vertico
:ensure t
:hook
(after-init . vertico-mode) ;; Enable vertico after Emacs has initialized.
:custom
(vertico-count 10) ;; Number of candidates to display in the completion list.
(vertico-resize nil) ;; Disable resizing of the vertico minibuffer.
(vertico-cycle nil) ;; Do not cycle through candidates when reaching the end of the list.
:config
(advice-add #'vertico--format-candidate :around
(lambda (orig cand prefix suffix index _start)
(setq cand (funcall orig cand prefix suffix index _start))
(concat
(if (= vertico--index index)
(propertize "» " 'face '(:foreground "#80adf0" :weight bold))
" ")
cand))))
(use-package orderless
:ensure t
:defer t ;; Load Orderless on demand.
:after vertico ;; Ensure Vertico is loaded before Orderless.
:init
(setq completion-styles '(orderless basic) ;; Set the completion styles.
completion-category-defaults nil ;; Clear default category settings.
completion-category-overrides '((file (styles partial-completion))))) ;; Customize file completion styles.
(use-package marginalia
:ensure t
:hook
(after-init . marginalia-mode))
(use-package consult
:ensure t
:defer t
:init
(advice-add #'register-preview :override #'consult-register-window)
(setq xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref))
(use-package embark
:ensure t
:defer t)
(use-package embark-consult
:ensure t
:hook
(embark-collect-mode . consult-preview-at-point-mode)) ;; Enable preview in Embark collect mode.
(use-package treesit-auto
:ensure t
:after emacs
:custom
(treesit-auto-install 'prompt)
:config
(treesit-auto-add-to-auto-mode-alist 'all)
(global-treesit-auto-mode t))
(use-package markdown-mode
:defer t
:ensure t
:mode ("README\\.md\\'" . gfm-mode) ;; Use gfm-mode for README.md files.
:init (setq markdown-command "multimarkdown")) ;; Set the Markdown processing command.
(use-package company
:defer t
:ensure t
:custom
(company-tooltip-align-annotations t) ;; Align annotations with completions.
(company-minimum-prefix-length 1) ;; Trigger completion after typing 1 character
(company-idle-delay 0.2) ;; Delay before showing completion (adjust as needed)
(company-tooltip-maximum-width 50)
:config
(define-key company-active-map (kbd "C-y")
(lambda ()
(interactive)
(company-show-doc-buffer)))
(define-key company-active-map [tab] 'company-complete-selection)
(define-key company-active-map (kbd "TAB") 'company-complete-selection)
(define-key company-active-map [ret] 'company-complete-selection)
(define-key company-active-map (kbd "RET") 'company-complete-selection)
:hook
(after-init . global-company-mode)) ;; Enable Company Mode globally after initialization.
(use-package lsp-mode
:ensure t
:defer t
:hook (;; Replace XXX-mode with concrete major mode (e.g. python-mode)
(bash-ts-mode . lsp) ;; Enable LSP for Bash
(typescript-ts-mode . lsp) ;; Enable LSP for TypeScript
(tsx-ts-mode . lsp) ;; Enable LSP for TSX
(js-mode . lsp) ;; Enable LSP for JavaScript
(js-ts-mode . lsp) ;; Enable LSP for JavaScript (TS mode)
(lsp-mode . lsp-enable-which-key-integration)) ;; Integrate with Which Key
:commands lsp
:custom
(lsp-keymap-prefix "C-c l") ;; Set the prefix for LSP commands.
(lsp-inlay-hint-enable t) ;; Enable inlay hints.
(lsp-completion-provider :none) ;; Disable the default completion provider.
(lsp-session-file (locate-user-emacs-file ".lsp-session")) ;; Specify session file location.
(lsp-log-io nil) ;; Disable IO logging for speed.
(lsp-idle-delay 0) ;; Set the delay for LSP to 0 (debouncing).
(lsp-keep-workspace-alive nil) ;; Disable keeping the workspace alive.
;; Core settings
(lsp-enable-xref t) ;; Enable cross-references.
(lsp-auto-configure t) ;; Automatically configure LSP.
(lsp-enable-links nil) ;; Disable links.
(lsp-eldoc-enable-hover t) ;; Enable ElDoc hover.
(lsp-enable-file-watchers nil) ;; Disable file watchers.
(lsp-enable-folding nil) ;; Disable folding.
(lsp-enable-imenu t) ;; Enable Imenu support.
(lsp-enable-indentation nil) ;; Disable indentation.
(lsp-enable-on-type-formatting nil) ;; Disable on-type formatting.
(lsp-enable-suggest-server-download t) ;; Enable server download suggestion.
(lsp-enable-symbol-highlighting t) ;; Enable symbol highlighting.
(lsp-enable-text-document-color nil) ;; Disable text document color.
;; Modeline settings
(lsp-modeline-code-actions-enable nil) ;; Keep modeline clean.
(lsp-modeline-diagnostics-enable nil) ;; Use `flymake' instead.
(lsp-modeline-workspace-status-enable t) ;; Display "LSP" in the modeline when enabled.
(lsp-signature-doc-lines 1) ;; Limit echo area to one line.
(lsp-eldoc-render-all nil) ;; Render all ElDoc messages.
;; Completion settings
(lsp-completion-enable t) ;; Enable completion.
(lsp-completion-enable-additional-text-edit t) ;; Enable additional text edits for completions.
(lsp-enable-snippet nil) ;; Disable snippets
(lsp-completion-show-kind t) ;; Show kind in completions.
;; Lens settings
(lsp-lens-enable t) ;; Enable lens support.
;; Headerline settings
(lsp-headerline-breadcrumb-enable-symbol-numbers t) ;; Enable symbol numbers in the headerline.
(lsp-headerline-arrow "") ;; Set arrow for headerline.
(lsp-headerline-breadcrumb-enable-diagnostics nil) ;; Disable diagnostics in headerline.
(lsp-headerline-breadcrumb-icons-enable nil) ;; Disable icons in breadcrumb.
;; Semantic settings
(lsp-semantic-tokens-enable nil)) ;; Disable semantic tokens.
(use-package lsp-tailwindcss
:ensure t
:defer t
:config
(add-to-list 'lsp-language-id-configuration '(".*\\.erb$" . "html")) ;; Associate ERB files with HTML.
:init
(setq lsp-tailwindcss-add-on-mode t))
(use-package diff-hl
:defer t
:ensure t
:hook
(find-file . (lambda ()
(global-diff-hl-mode) ;; Enable Diff-HL mode for all files.
(diff-hl-flydiff-mode) ;; Automatically refresh diffs.
(diff-hl-margin-mode))) ;; Show diff indicators in the margin.
:custom
(diff-hl-side 'left) ;; Set the side for diff indicators.
(diff-hl-margin-symbols-alist '((insert . "") ;; Customize symbols for each change type.
(delete . "-")
(change . "")
(unknown . "?")
(ignored . "i"))))
(use-package xclip
:ensure t
:defer t
:hook
(after-init . xclip-mode)) ;; Enable xclip mode after initialization.
(use-package indent-guide
:defer t
:ensure t
:hook
(prog-mode . indent-guide-mode) ;; Activate indent-guide in programming modes.
:config
(setq indent-guide-char "")) ;; Set the character used for the indent guide.
(use-package add-node-modules-path
:ensure t
:defer t
:custom
;; Makes sure you are using the local bin for your
;; node project. Local eslint, typescript server...
(eval-after-load 'typescript-ts-mode
'(add-hook 'typescript-ts-mode-hook #'add-node-modules-path))
(eval-after-load 'tsx-ts-mode
'(add-hook 'tsx-ts-mode-hook #'add-node-modules-path))
(eval-after-load 'typescriptreact-mode
'(add-hook 'typescriptreact-mode-hook #'add-node-modules-path))
(eval-after-load 'js-mode
'(add-hook 'js-mode-hook #'add-node-modules-path)))
(load (locate-user-emacs-file "packages/evil.el"))
(use-package rainbow-delimiters
:defer t
:ensure t
:hook
(prog-mode . rainbow-delimiters-mode))
(use-package dotenv-mode
:defer t
:ensure t
:config)
(use-package pulsar
:defer t
:ensure t
:hook
(after-init . pulsar-global-mode)
:config
(setq pulsar-pulse t)
(setq pulsar-delay 0.025)
(setq pulsar-iterations 10)
(setq pulsar-face 'evil-ex-lazy-highlight)
(add-to-list 'pulsar-pulse-functions 'evil-scroll-down)
(add-to-list 'pulsar-pulse-functions 'flymake-goto-next-error)
(add-to-list 'pulsar-pulse-functions 'flymake-goto-prev-error)
(add-to-list 'pulsar-pulse-functions 'evil-yank)
(add-to-list 'pulsar-pulse-functions 'evil-yank-line)
(add-to-list 'pulsar-pulse-functions 'evil-delete)
(add-to-list 'pulsar-pulse-functions 'evil-delete-line)
(add-to-list 'pulsar-pulse-functions 'evil-jump-item)
(add-to-list 'pulsar-pulse-functions 'diff-hl-next-hunk)
(add-to-list 'pulsar-pulse-functions 'diff-hl-previous-hunk))
(use-package doom-themes
:ensure t
:config
(load-theme 'doom-gruvbox t))
(use-package doom-modeline
:ensure t
:defer t
:custom
(doom-modeline-buffer-file-name-style 'buffer-name) ;; Set the buffer file name style to just the buffer name (without path).
(doom-modeline-project-detection 'project) ;; Enable project detection for displaying the project name.
(doom-modeline-buffer-name t) ;; Show the buffer name in the mode line.
(doom-modeline-vcs-max-length 25) ;; Limit the version control system (VCS) branch name length to 25 characters.
:config
(if ek-use-nerd-fonts ;; Check if nerd fonts are being used.
(setq doom-modeline-icon t) ;; Enable icons in the mode line if nerd fonts are used.
(setq doom-modeline-icon nil)) ;; Disable icons if nerd fonts are not being used.
:hook
(after-init . doom-modeline-mode))
(use-package neotree
:ensure t
:custom
(neo-show-hidden-files t) ;; By default shows hidden files (toggle with H)
(neo-theme 'nerd) ;; Set the default theme for Neotree to 'nerd' for a visually appealing look.
(neo-vc-integration '(face char)) ;; Enable VC integration to display file states with faces (color coding) and characters (icons).
:defer t ;; Load the package only when needed to improve startup time.
:config
(if ek-use-nerd-fonts ;; Check if nerd fonts are being used.
(setq neo-theme 'nerd-icons) ;; Set the theme to 'nerd-icons' if nerd fonts are available.
(setq neo-theme 'nerd))) ;; Otherwise, fall back to the 'nerd' theme.
(use-package nerd-icons
:if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts.
:ensure t ;; Ensure the package is installed.
:defer t) ;; Load the package only when needed to improve startup time.
(use-package nerd-icons-dired
:if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts.
:ensure t ;; Ensure the package is installed.
:defer t ;; Load the package only when needed to improve startup time.
:hook
(dired-mode . nerd-icons-dired-mode))
(use-package nerd-icons-completion
:if ek-use-nerd-fonts ;; Load the package only if the user has configured to use nerd fonts.
:ensure t ;; Ensure the package is installed.
:after (:all nerd-icons marginalia) ;; Load after `nerd-icons' and `marginalia' to ensure proper integration.
:config
(nerd-icons-completion-mode) ;; Activate nerd icons for completion interfaces.
(add-hook 'marginalia-mode-hook #'nerd-icons-completion-marginalia-setup)) ;; Setup icons in the marginalia mode for enhanced completion display.
(defun ek/first-install ()
(interactive) ;; Allow this function to be called interactively.
(switch-to-buffer "*Messages*") ;; Switch to the *Messages* buffer to display installation messages.
(message ">>> All required packages installed.")
(message ">>> Configuring Emacs-Kick...")
(message ">>> Configuring Tree Sitter parsers...")
(require 'treesit-auto)
(treesit-auto-install-all) ;; Install all available Tree Sitter grammars.
(message ">>> Configuring Nerd Fonts...")
(require 'nerd-icons)
(nerd-icons-install-fonts) ;; Install all available nerd-fonts
(message ">>> Native compile 3rd-party packages...\n")
(require 'comp)
(native-compile-prune-cache) ;; Prune the native compilation cache to free up resources.
(dolist (dir (directory-files package-user-dir t "^[^.]" t))
(when (file-directory-p dir) ;; Check if the current entry is a directory.
(byte-recompile-directory dir 0 t) ;; Byte compile all files in the directory.
(native-compile-async dir 'recursively))) ;; Asynchronously compile the directory and its subdirectories.
(message ">>> Emacs-Kick installed!!! Press any key to close the installer and open Emacs normally.") ;; Notify the user that the installation is complete.
(read-key) ;; Wait for the user to press any key.
(kill-emacs)) ;; Close Emacs after installation is complete.
(provide 'init)