emacsconfig/settings.org

500 lines
13 KiB
Org Mode
Raw Normal View History

2023-03-24 21:06:41 +00:00
* Looks
** Font
#+begin_src emacs-lisp
2023-03-25 20:51:06 +00:00
(set-frame-font "MonoLisa 18" nil t)
2023-03-24 21:06:41 +00:00
(set-fontset-font t '(#x1f000 . #x1faff) (font-spec :family "Myne Noto Color Emoji"))
#+end_src
** Themes
#+begin_src emacs-lisp
2023-03-25 12:20:51 +00:00
(use-package afternoon-theme
:ensure t
:config
2023-03-25 23:25:38 +00:00
(load-theme 'afternoon t)
2023-03-25 12:20:51 +00:00
)
(use-package modus-themes
:ensure t
:config
2023-03-25 23:25:38 +00:00
;;(load-theme 'modus-operandi t)
2023-03-25 12:20:51 +00:00
)
2023-03-24 21:06:41 +00:00
#+end_src
** UI
*** Split vertical defaul
#+begin_src emacs-lisp
(setq split-width-threshold nil)
#+end_src
*** Lines Numbers
#+begin_src emacs-lisp
(global-display-line-numbers-mode)
2023-03-25 12:50:47 +00:00
(setq display-line-numbers-type 'relative)
2023-03-24 21:06:41 +00:00
#+end_src
*** Dashboard
Set up some config functions
Configure layout
#+begin_src emacs-lisp
(defun setup-dashboard-looks ()
"Config ideas https://github.com/emacs-dashboard/emacs-dashboard"
2023-03-25 12:20:51 +00:00
(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)
2023-03-24 21:06:41 +00:00
(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"))
)
#+end_src
2023-03-25 20:51:06 +00:00
Try to make dashboard appear when opening a file as well
2023-03-24 21:06:41 +00:00
#+begin_src emacs-lisp
2023-03-25 20:51:06 +00:00
;; (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"
2023-03-24 21:06:41 +00:00
(interactive)
2023-03-25 20:51:06 +00:00
(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))
2023-03-24 21:06:41 +00:00
2023-03-25 20:51:06 +00:00
(defun setup-dashboard-on-multiple ()
"Setups the dashboard when args are provided"
(interactive)
(if (>= (length command-line-args) 2)
(open-dashboard-on-split)))
#+end_src
Setup stuff
#+begin_src emacs-lisp
2023-03-24 21:06:41 +00:00
(defun evil-dashboard-setup ()
2023-03-25 20:51:06 +00:00
(setup-dashboard-looks)
(setup-dashboard-on-multiple))
2023-03-24 21:06:41 +00:00
#+end_src
#+begin_src emacs-lisp
(use-package dashboard
:ensure t
:after (evil)
:config
(evil-dashboard-setup)
(dashboard-setup-startup-hook))
#+end_src
2023-03-25 12:20:51 +00:00
*** Ivy
#+begin_src emacs-lisp
(use-package ivy
:ensure t
:config
(ivy-mode))
#+end_src
Consel
#+begin_src emacs-lisp
(use-package counsel
:ensure t
:config
(counsel-mode))
#+end_src
*** Which key
#+begin_src emacs-lisp
(use-package which-key
:ensure t
:config
(which-key-mode))
#+end_src
2023-03-25 12:50:47 +00:00
*** Disable Window Top bar
#+begin_src emacs-lisp
(menu-bar-mode -1)
(tool-bar-mode -1)
#+end_src
2023-03-24 21:06:41 +00:00
2023-03-25 20:51:06 +00:00
** Langs
Set up tree sitter
#+begin_src emacs-lisp
(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)
#+end_src
*** ts
Setup typescript mode
#+begin_src emacs-lisp
(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))
)
#+end_src
Setup tree sitter based indentation
#+begin_src emacs-lisp
;; 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))))
#+end_src
*** tsx
#+begin_src emacs-lisp
2023-03-25 23:25:38 +00:00
;; (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)))
2023-03-25 20:51:06 +00:00
#+end_src
*** webmode
#+begin_src emacs-lisp
(use-package web-mode
:ensure t
:config
;;(add-to-list 'auto-mode-alist '("\\.tsx?\\'" . web-mode))
)
#+end_src
2023-03-24 21:06:41 +00:00
* Settings
2023-03-25 12:20:51 +00:00
** Backup files
#+begin_src emacs-lisp
(setq
2023-03-25 20:51:06 +00:00
make-backup-files nil
2023-03-25 12:20:51 +00:00
backup-directory-alist '(("." . "/tmp/"))
auto-save-file-name-transforms '((".*" "/tmp/" t)))
#+end_src
2023-03-25 20:51:06 +00:00
** Startup screen
#+begin_src emacs-lisp
(setq inhibit-splash-screen t)
#+end_src
2023-03-25 12:50:47 +00:00
2023-03-25 20:51:06 +00:00
** Tabs
#+begin_src emacs-lisp
(setq-default tab-width 4)
#+end_src
2023-03-24 21:06:41 +00:00
* Evil
** Base Functions
#+begin_src emacs-lisp
(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)
#+end_src
** Base
2023-03-25 12:20:51 +00:00
*** Configure
#+begin_src emacs-lisp
(defun setup-evil-mode ()
2023-03-25 20:51:06 +00:00
(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)
)
2023-03-25 12:20:51 +00:00
#+end_src
*** Install
2023-03-24 21:06:41 +00:00
#+begin_src emacs-lisp
(use-package evil
:ensure
:after (evil-leader)
:config
2023-03-25 12:20:51 +00:00
(setup-evil-mode)
2023-03-24 21:06:41 +00:00
(evil-mode 1))
#+end_src
** Leader
#+begin_src emacs-lisp
(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
2023-03-25 20:51:06 +00:00
"SPC" 'projectile-find-file
2023-03-25 12:20:51 +00:00
"d" 'dired
2023-03-25 20:51:06 +00:00
"b" 'ivy-switch-buffer
2023-03-25 12:20:51 +00:00
"c" '("config" . (keymap))
2023-03-25 20:51:06 +00:00
"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)
2023-03-24 21:06:41 +00:00
)
#+end_src
** Org Mode
#+begin_src emacs-lisp
(use-package evil-org
:ensure t
:after (org evil)
:hook (org-mode . evil-org-mode))
#+end_src
* Projects
** Projectile
#+begin_src emacs-lisp
(use-package projectile
:ensure t
:config
2023-03-25 20:51:06 +00:00
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
;;(setq projectile-git-command "git-ls-all-files")
(projectile-mode +1))
2023-03-24 21:06:41 +00:00
#+end_src
** Magit
#+begin_src emacs-lisp
(use-package magit
:ensure t)
#+end_src
2023-03-25 12:20:51 +00:00
Auto complete
2023-03-25 20:51:06 +00:00
* LSP
2023-03-25 12:20:51 +00:00
** Company
#+begin_src emacs-lisp
(use-package company
:ensure t
:config
(global-company-mode))
#+end_src
2023-03-25 20:51:06 +00:00
*** Comapny box
#+begin_src emacs-lisp
(use-package company-box
:ensure t
:hook (company-mode . company-box-mode))
#+end_src
2023-03-25 12:20:51 +00:00
** LSP
2023-03-25 20:51:06 +00:00
Set up lsp
#+begin_src emacs-lisp
2023-03-25 23:25:38 +00:00
(use-package lsp-mode
:init
(setq lsp-keymap-prefix "C-c l")
:ensure t
:hook (
;;(XXX-mode . lsp-mode)
2023-03-25 20:51:06 +00:00
2023-03-25 23:25:38 +00:00
;;(typescriptreact-mode . lsp-mode)
;;(tsx-mode . lsp-mode)
;;(tsx-ts-mode . lsp-mode)
(typescript-mode . lsp-mode)
(web-mode . lsp-mode)
2023-03-25 20:51:06 +00:00
2023-03-25 23:25:38 +00:00
(lsp-mode . lsp-enable-which-key-integration))
:commands lsp
:config
;;(add-hook 'tsx-mode-hook 'lsp-mode)
)
2023-03-25 20:51:06 +00:00
#+end_src
Set up lsp ui
#+begin_src emacs-lisp
(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)
)
#+end_src
Set up ivy
#+begin_src emacs-lisp
(use-package lsp-ivy
:ensure t
:commands lsp-ivy-workspace-symbol)
#+end_src
2023-03-26 22:43:43 +01:00
*** Flycheck custom checkers
#+begin_src emacs-lisp
(defvar-local my/flycheck-local-cache nil)
(defun my/flycheck-checker-get (fn checker property)
(or (alist-get property (alist-get checker my/flycheck-local-cache))
(funcall fn checker property)))
(advice-add 'flycheck-checker-get :around 'my/flycheck-checker-get)
(add-hook 'lsp-managed-mode-hook
(lambda ()
(when (derived-mode-p 'typescript-mode)
(setq my/flycheck-local-cache '((lsp . ((next-checkers . (javascript-eslint)))))))))
#+end_src
2023-03-25 20:51:06 +00:00
** Flycheck
2023-03-25 23:25:38 +00:00
*** Helper function
#+begin_src emacs-lisp
(defun define-level-info (name severity compilation-level margin-str)
(flycheck-define-error-level name
:severity severity
:compilation-level compilation-level
:overlay-category 'flycheck-info-overlay
:margin-spec (flycheck-make-margin-spec margin-str 'flycheck-fringe-info)
:fringe-bitmap'flycheck-fringe-bitmap-double-arrow
:fringe-face 'flycheck-fringe-info
:error-list-face 'flycheck-error-list-info))
#+end_src
*** Flycheck
2023-03-25 20:51:06 +00:00
#+begin_src emacs-lisp
(use-package flycheck
2023-03-25 23:25:38 +00:00
: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)
(define-level-info 'info -10 0 "🅰")
(define-level-info 'lsp-flycheck-info-unnecessary -10 0 "🅰")
(define-level-info 'hint -20 -1 "🆓")
;; …every time Flycheck is activated in a new buffer
(add-hook 'flycheck-mode-hook #'my/set-flycheck-margins)
)
2023-03-25 20:51:06 +00:00
#+end_src
Fly check post tip
#+begin_src emacs-lisp
;; (use-package flycheck-pos-tip
;; :ensure t
;; :hook (flycheck-mode . flycheck-pos-tip-mode))
#+end_src
2023-03-25 23:25:38 +00:00
Fly check inline (disabled because was getting annoyed)
#+begin_src emacs-lisp
;; (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 1)
;; (setq flycheck-posframe-position 'point-top-left-corner)
;;
;; (set-face-attribute 'flycheck-posframe-border-face
;; nil
;; :foreground "#dc752f")
;; (add-to-list 'flycheck-posframe-inhibit-functions #'(lambda () company-backend)))
#+end_src
** TIDE
#+begin_src emacs-lisp
(use-package tide
:ensure t
:after (typescript-mode company flycheck)
:hook ((typescript-mode . tide-setup)
2023-03-26 22:43:43 +01:00
(typescript-mode . tide-hl-identifier-mode))
;;(before-save . tide-format-before-save))
)
2023-03-25 20:51:06 +00:00
2023-03-25 23:25:38 +00:00
(add-to-list 'auto-mode-alist '("\\.tsx?\\'" . typescript-mode))
2023-03-26 22:43:43 +01:00
(eval-after-load "tsx"
'(progn
(message "setups eslint tide")
(flycheck-select-checker 'javascript-eslint)))
2023-03-25 20:51:06 +00:00
#+end_src