emacsconfig/settings.org

13 KiB

Looks

Font

  (set-frame-font "MonoLisa 18" nil t)
  (set-fontset-font t '(#x1f000 . #x1faff) (font-spec :family "Myne Noto Color Emoji"))

Themes

  (use-package afternoon-theme
    :ensure t
    :config
    ;;(load-theme 'afternoon t)
    )
  (use-package modus-themes
    :ensure t
    :config
    (load-theme 'modus-operandi t)
    )

UI

Split vertical defaul

  (setq split-width-threshold nil)

Lines Numbers

  (global-display-line-numbers-mode)
  (setq display-line-numbers-type 'relative)

Dashboard

Set up some config functions

Configure layout

  (defun setup-dashboard-looks ()
    "Config ideas https://github.com/emacs-dashboard/emacs-dashboard"
    (evil-define-key 'normal dashboard-mode-map (kbd "r") 'dashboard-section-1)
    (evil-define-key 'normal dashboard-mode-map (kbd "J") 'dashboard-next-section)
    (evil-define-key 'normal dashboard-mode-map (kbd "K") 'dashboard-previous-section)
    (setq dashboard-startup-banner "~/.emacs.d/OnePiece.gif")
    (setq dashboard-banner-logo-title "Lets get coddiinnngggg")
    (setq dashboard-show-shortcuts t)
    (setq dashboard-items '((recents . 5)
			    (projects . 5)))
    (setq dashboard-item-names '(("Recent Files:" . "💫 Recent Files, probably not decent:")
				 ("Projects:" . "Projects 🆓, probably also not decent:")))
    ;; Curently broken ☣️ 
    (setq dashboard-center-content nil)
    ;;(setq dashboard-set-heading-icons t)
    ;;(setq dashboard-set-file-icons t)
    (setq dashboard-footer-messages '("Sleepyyyyy 🥱"
				      "Uhhhh I am lost"
				      "🆓 Just go watch anime 🆓"
				      "Compiler Error ☣️ Upssss!"
				      "❤️ Its Coddiinnnng timee"))
    )

Try to make dashboard appear when opening a file as well

  ;;  (defun setup-dashboard-on-multiple ()
  ;;    (interactive)
  ;;    (if (> (length command-line-args) 2)
  ;;	(progn
  ;;	  (split-window-below)
  ;;	  (balance-windows)
  ;;	  (other-window 1)
  ;;	  )
  ;;	(message (concat "Got" (number-to-string (length command-line-args)))))

  (defun open-dashboard-on-split ()
    "Opens the dashboard on a new split window"
    (interactive)
    (split-window-below)
    (balance-windows)
    (other-window 1)
    (generate-new-buffer "*dashboard*")
    (switch-to-buffer "*dashboard*")
    (dashboard-insert-startupify-lists)
    (window-resize (get-buffer-window) (- (floor (* (window-total-height (get-buffer-window)) 0.4))))
    (other-window 1))

  (defun setup-dashboard-on-multiple ()
    "Setups the dashboard when args are provided"
    (interactive)
    (if (>= (length command-line-args) 2)
	(open-dashboard-on-split)))

Setup stuff

  (defun evil-dashboard-setup ()
    (setup-dashboard-looks) 
    (setup-dashboard-on-multiple))
  (use-package dashboard
    :ensure t
    :after (evil)
    :config
    (evil-dashboard-setup)
    (dashboard-setup-startup-hook))

Ivy

  (use-package ivy
    :ensure t
    :config
    (ivy-mode))

Consel

  (use-package counsel
    :ensure t
    :config
    (counsel-mode))

Which key

  (use-package which-key
    :ensure t
    :config
    (which-key-mode))

Disable Window Top bar

  (menu-bar-mode -1)
  (tool-bar-mode -1)

Langs

Set up tree sitter

  (use-package tree-sitter
    :ensure t
    :hook (tree-sitter-after-on . tree-sitter-hl-mode)
    :config
    (global-tree-sitter-mode))
  (use-package tree-sitter-langs
    :ensure t)

ts

Setup typescript mode

  (use-package typescript-mode
    :ensure t
    :after (tree-sitter)
    :config
    ;;(define-derived-mode typescriptreact-mode typescript-mode
    ;;  "TypeScript TSX")
    ;;(add-to-list 'auto-mode-alist '("\\.tsx?\\'" . typescriptreact-mode))
    ;;(add-to-list 'tree-sitter-major-mode-language-alist '(typescriptreact-mode . tsx))
    )

Setup tree sitter based indentation

  ;; great tree-sitter-based indentation for typescript/tsx, css, json
;;  (use-package tsi
;
;;    :quelpa (tsi :fetcher github :repo "orzechowskid/tsi.el")
;;    ;; define autoload definitions which when actually invoked will cause package to be loaded
;;    :commands (tsi-typescript-mode tsi-json-mode tsi-css-mode)
;;    :init
;;    (add-hook 'typescript-mode-hook (lambda () (tsi-typescript-mode 1)))
;;    (add-hook 'json-mode-hook (lambda () (tsi-json-mode 1)))
;;    (add-hook 'css-mode-hook (lambda () (tsi-css-mode 1)))
;;    (add-hook 'scss-mode-hook (lambda () (tsi-scss-mode 1))))

tsx

  (use-package coverlay
	:ensure t)

  (use-package origami
	:ensure t)

  (use-package css-in-js-mode
	:straight '(css-in-js-mode
		:type git
		:host github
		:repo "orzechowskid/tree-sitter-css-in-js"))

  (use-package corfu
	:ensure t)
  
  (setq eglot-server-programs '())
  (use-package tsx-mode
	:straight '(tsx-mode
		:type git
		:host github
		:repo "orzechowskid/tsx-mode.el"
		:branch "emacs29")
	:config
	(add-to-list 'auto-mode-alist '("\\.tsx?\\'" . tsx-mode)))

webmode

  (use-package web-mode
    :ensure t
    :config
    ;;(add-to-list 'auto-mode-alist '("\\.tsx?\\'" . web-mode))
    )

Settings

Backup files

  (setq
   make-backup-files nil
   backup-directory-alist '(("." . "/tmp/"))
   auto-save-file-name-transforms '((".*" "/tmp/" t)))

Startup screen

  (setq inhibit-splash-screen t)

Tabs

  (setq-default tab-width 4)

Evil

Base Functions

  (defun my-evil-quit (old-fun &rest args)
    (if (eq major-mode 'org-src-mode)
      (org-edit-src-exit)
      (apply old-fun args)))

  (defun my-evil-save (old-fun &rest args)
    (if (eq major-mode 'org-src-mode)
      (org-edit-src-save)
      (apply old-fun args)))

  (advice-add #'evil-save :around #'my-evil-save)
  (advice-add #'evil-quit :around #'my-evil-quit)

Base

Configure

  (defun setup-evil-mode ()
	(evil-define-key 'insert global-map (kbd "C-SPC") 'company-complete)
	(evil-define-key 'normal global-map
	  (kbd "]e") 'flycheck-next-error
	  (kbd "[e") 'flycheck-previous-error
	  (kbd "gd") 'lsp-find-definition
	  (kbd "K") 'lsp-ui-doc-show
	  (kbd "gr") 'lsp-find-references)
	)

Install

  (use-package evil
    :ensure
    :after (evil-leader)
    :config
    (setup-evil-mode)
    (evil-mode 1))

Leader

  (use-package evil-leader
    :ensure t
    :config
    (global-evil-leader-mode)
    ; Set leader
    (evil-leader/set-leader "<SPC>")
    (evil-leader/set-key
      "f" 'find-file
      "SPC" 'projectile-find-file
      "d" 'dired
      "b" 'ivy-switch-buffer

      "c" '("config" . (keymap))
      "cf" '("config file" . (lambda ()(interactive) (find-file (expand-file-name "~/.emacs.d/settings.org"))))
      "c+" '("config file" . (lambda ()(interactive) (text-scale-increase)))
      "c-" '("config file" . (lambda ()(interactive) (text-scale-decrease)))

      "p" '("project" . (keymap))
      "pf" '("file" . (lambda () (interactive)(projectile-find-file)))

      "g" '("goto" . (keymap))
      "gg" 'magit
      "gd" '("Goto Definition" . (lambda () (interactive)(evil-goto-definition)))

      )
    (evil-leader/set-key-for-mode 'org-mode
      "is" 'org-insert-structure-template
      "e" 'org-edit-src-code)
    )

Org Mode

  (use-package evil-org
    :ensure t
    :after (org evil)
    :hook (org-mode . evil-org-mode))

Projects

Projectile

  (use-package projectile
    :ensure t
    :config
    (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
    ;;(setq projectile-git-command "git-ls-all-files")
    (projectile-mode +1))

Magit

  (use-package magit
    :ensure t)

Auto complete

LSP

Company

  (use-package company
    :ensure t
    :config
    (global-company-mode))

Comapny box

  (use-package company-box
	:ensure t
	:hook (company-mode . company-box-mode))

LSP

Set up lsp

	(use-package lsp-mode
	  :init
	  (setq lsp-keymap-prefix "C-c l")
	  :ensure t
	  :hook (
		 ;;(XXX-mode . lsp-mode)

		 ;;(typescriptreact-mode . lsp-mode)
		 (typescript-mode . lsp-mode)
		 (tsx-mode		. lsp-mode)
		 (tsx-ts-mode		. lsp-mode)
		 (web-mode		. lsp-mode)

		 (lsp-mode . lsp-enable-which-key-integration))
	  :commands  lsp
	  :config
	  (add-hook 'tsx-mode-hook 'lsp-mode))

Set up lsp ui

  (use-package lsp-ui
	:ensure t
	:commands lsp-ui-mode
	:config
	;; sideline
	(setq lsp-ui-sideline-show-diagnostics nil)
	(setq lsp-ui-sideline-show-code-actions nil)
	(setq lsp-ui-sideline-show-hover t)
	(setq lsp-ui-sideline-delay 0)
	;; ui-doc
	(setq lsp-ui-doc-enable t)
	(setq lsp-ui-doc-delay 1)
	(setq lsp-ui-doc-show-with-cursor t)
	(setq lsp-ui-doc-show-with-mouse nil)
	(setq lsp-ui-doc-position 'at-point)
	)

Set up ivy

  (use-package lsp-ivy
    :ensure t
    :commands lsp-ivy-workspace-symbol)

Flycheck

  (use-package flycheck
    :ensure t
    :init(global-flycheck-mode)
    :config
    ;; Show indicators in the left margin
    (setq flycheck-indication-mode 'left-margin)

    ;; Adjust margins and fringe widths…
    (defun my/set-flycheck-margins ()
      (setq left-fringe-width 0 right-fringe-width 0
	    left-margin-width 2 right-margin-width 0)
      (setq flycheck-default-margin-str "🆓")
      (flycheck-refresh-fringes-and-margins))

    (flycheck-define-error-level 'error
      :severity 100
      :compilation-level 2
      :overlay-category 'flycheck-error-overlay
      :margin-spec (flycheck-make-margin-spec "❤️" 'flycheck-fringe-error)
      :fringe-bitmap 'flycheck-fringe-bitmap-double-arrow
      :fringe-face 'flycheck-fringe-error
      :error-list-face 'flycheck-error-list-error)

    (flycheck-define-error-level 'warning
      :severity 10
      :compilation-level 1
      :overlay-category 'flycheck-warning-overlay
      :margin-spec (flycheck-make-margin-spec "😞" 'flycheck-fringe-warning)
      :fringe-bitmap'flycheck-fringe-bitmap-double-arrow
      :fringe-face 'flycheck-fringe-warning
      :error-list-face 'flycheck-error-list-warning)

    (flycheck-define-error-level 'info
      :severity -10
      :compilation-level 0
      :overlay-category 'flycheck-info-overlay
      :margin-spec (flycheck-make-margin-spec "🅰" 'flycheck-fringe-info)
      :fringe-bitmap'flycheck-fringe-bitmap-double-arrow
      :fringe-face 'flycheck-fringe-info
      :error-list-face 'flycheck-error-list-info)

    (flycheck-define-error-level 'lsp-flycheck-info-unnecessary
      :severity -10
      :compilation-level 0
      :overlay-category 'flycheck-info-overlay
      :margin-spec (flycheck-make-margin-spec "🅰" 'flycheck-fringe-info)
      :fringe-bitmap'flycheck-fringe-bitmap-double-arrow
      :fringe-face 'flycheck-fringe-info
      :error-list-face 'flycheck-error-list-info)

    (flycheck-define-error-level 'hint
      :severity -20
      :compilation-level -1
      :overlay-category 'flycheck-info-overlay
      :margin-spec (flycheck-make-margin-spec "🆓" 'flycheck-fringe-info)
      :fringe-bitmap'flycheck-fringe-bitmap-double-arrow
      :fringe-face 'flycheck-fringe-info
      :error-list-face 'flycheck-error-list-info)

    ;; …every time Flycheck is activated in a new buffer
    (add-hook 'flycheck-mode-hook #'my/set-flycheck-margins)
    )

Fly check post tip

;;  (use-package flycheck-pos-tip
;;    :ensure t
;;    :hook (flycheck-mode . flycheck-pos-tip-mode))

Fly check inline

  (use-package flycheck-posframe
    :ensure t
    :after flycheck
    :hook (flycheck-mode . flycheck-posframe-mode)
    :config
    (flycheck-posframe-configure-pretty-defaults)
    (setq flycheck-posframe-error-prefix "☣️❤️")
    (setq flycheck-posframe-warning-prefix "🅰😞")
    (setq flycheck-posframe-info-prefix "🅰🆓")
    (set-face-attribute 'flycheck-posframe-error-face
			nil
			:inherit nil
			:foreground "#b72c01")
    (set-face-attribute 'flycheck-posframe-warning-face
			nil
			:foreground "#b77401")

    (set-face-attribute 'flycheck-posframe-info-face
			nil
			:foreground "#0156b7")

    (setq flycheck-posframe-border-width 3)
    (set-face-attribute 'flycheck-posframe-border-face
			nil
			:foreground "#dc752f")
    (add-to-list 'flycheck-posframe-inhibit-functions #'(lambda () company-backend)))