Skip to content

Latest commit

 

History

History
137 lines (118 loc) · 5.24 KB

Emacs.org

File metadata and controls

137 lines (118 loc) · 5.24 KB

EMACS

EARLY-INIT.EL

Setting straight.el

;; Setting straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

;; straight integrate with use-package
(straight-use-package 'use-package)
;; always invoke straight when using use-package
(setq straight-use-package-by-default t)

Setting use-package

;; straight integrate with use-package
(straight-use-package 'use-package)
;; always invoke straight when using use-package
(setq straight-use-package-by-default t)

Functions

;; Custom Variables and Functions
;; set font size based on system-type
(defun ethan-font-size-func ()
  (interactive)
  (setq ethan-font-size (cond ((string= system-type "gnu/linux") 120)
				  ((string= system-type "darwin") 130))))

;; set ls command based on system-type
(defun ethan/set-ls-command ()
  (interactive)
  (cond ((string= system-type "gnu/linux") (setq ethan/set-ls-variable "ls"))
	((string= system-type "darwin") (setq ethan/set-ls-variable "gls"))))
(eval (ethan/set-ls-command))

;; set compile-command based on file extension
(defun ethan/file-set-compile-command ()
  (interactive)
  (let* ((file-name-full buffer-file-name)
         (file-ext (file-name-extension buffer-file-name))
         (file-name-without-extension (file-name-sans-extension buffer-file-name))
         (file-name-without-extension-and-path (file-name-base buffer-file-name)))
    
    (cond ((string= file-ext "c") (setq compile-command (format "gcc -o %s %s && ./%s"
							      file-name-without-extension
							      file-name-full
							      file-name-without-extension-and-path)))
	  ((string= file-ext "cpp") (setq compile-command (format "g++ -o %s %s && ./%s"
							     file-name-without-extension
							     file-name-full
							     file-name-without-extension-and-path))) 
	  ((string= file-ext "java") (setq compile-command (format "javac %s && java %s"
						             file-name-full
						             file-name-without-extension)))
	  ((string= file-ext "kt") (setq compile-command (format "kotlinc %s -include-runtime -d %s.jar && java -jar %s.jar"
							     file-name-full
							     file-name-without-extension
							     file-name-without-extension)))
	  ((string= file-ext "py") (setq compile-command (format "python3 %s"
								 file-name-full))))))

;; To compile and recompile with universal argument
(defun ethan/universal-compile-command ()
  (interactive)
  (setq current-prefix-arg '(4))
   (call-interactively 'compile))

(defun ethan/universal-recompile-command ()
  (interactive)
  (setq current-prefix-arg '(4))
   (call-interactively 'recompile))

INIT.EL

Basic Configuration

;; Basic Configurations

(setq inhibit-startup-message t) ;; stops showing startup screen when we start emacs
(setq pixel-scroll-mode 1)       ;; pixel scrolling
(scroll-bar-mode -1)             ;; disable scroll scrool
(tool-bar-mode -1)               ;; disable toolbar
(tooltip-mode -1)                ;; disable tooltios
(set-fringe-mode 10)             ;; gives some breathing room
(electric-pair-mode 1)           ;; Pair Parentheses
;; (menu-bar-mode -1)              ;; disable menubar
(set-face-attribute 'default nil :font "JetBrainsMono Nerd Font Mono" :height (eval (ethan-font-size-func))) ;; set font and font-size
(setq ring-bell-function 'ignore)
(setq persp-suppress-no-prefix-key-warning t)
(recentf-mode 1)                 ;; Maintains a list of recent files
(setq history-length 25)         ;; saves history of minibuffer upto 25 length
(savehist-mode 1)                ;; initiate above mode
(save-place-mode 1)              ;; saves cursor location in files
(global-auto-revert-mode 1)      ;; Sync files if the file is edited outside emacs
(setq global-auto-revert-non-file-buffers t) ;; Revert Dired and other buffers (same as above for dired and non file buffers)
(column-number-mode 1)           ;; Make column number visible in modeline
(global-display-line-numbers-mode t)         ;; Display line numbers
(setq display-line-numbers-type 'relative)   ;; Line numbers type relative
(setq debug-on-error t)

Backup Directory

;; Write backups to ~/.emacs.d/backup/
(setq backup-directory-alist '(("." . "~/.emacs.d/backup"))
      backup-by-copying      t  ; Don't de-link hard links
      version-control        t  ; Use version numbers on backups
      delete-old-versions    t  ; Automatically delete excess backups:
      kept-new-versions      20 ; how many of the newest versions to keep
      kept-old-versions      5) ; and how many of the old

PACKAGES.EL

BINDINGS.EL

CUSTOM-VARS.EL

LSP.EL