BIG GINORMOUS HUGE COMMIT THAT SHOULD CATCH THINGS UP WITH A BIG REFACTOR

This commit is contained in:
Mike 'Fuzzy' Partin 2024-07-10 01:34:45 -07:00
parent 0fdff262b7
commit 107c25c8ae
25 changed files with 452 additions and 541 deletions

View File

@ -3,7 +3,7 @@
;;
;; Add the lib directory to the load path
(add-to-list 'load-path (expand-file-name "lib" user-emacs-directory))
(add-to-list 'load-path (expand-file-name "thwap" user-emacs-directory))
;; Add the thwap.d directory to the load path
(add-to-list 'load-path (expand-file-name "thwap.d" user-emacs-directory))

44
init.el
View File

@ -4,14 +4,14 @@
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(xterm-mouse-mode t)
'(mouse-autoselect-window t)
'(mouse-drag-and-drop-region t)
'(mouse-drag-and-drop-region-cross-program t)
'(terraform-format-on-save t)
'(terraform-indent-level 2)
'(tool-bar-mode nil)
'(visible-bell 1))
'(visible-bell 1)
'(xterm-mouse-mode t))
(custom-set-faces
;; custom-set-faces was added by Custom.
@ -20,39 +20,21 @@
;; If there is more than one, they won't work right.
'(default ((t (:family "Noto Sans Mono" :foundry "GOOG" :slant normal :weight regular :height 90 :width normal)))))
;; thwap helpers
(require 'thwap-helpers)
;; thwap config
(require 'thwap-config)
(require 'thwap-configuration)
;; thwap defaults
(require 'thwap-defaults)
;; theme configuration
(require 'thwap-theme)
;; icon configuration
(require 'thwap-icons)
;; nerdtree configuration
(require 'thwap-nerdtree)
(require 'thwap-interface)
;; file browser configuration
(require 'thwap-file-browser)
;; company configuration
(require 'thwap-comp)
;; LSP configuration
(require 'thwap-lsp)
;; Eglot configuration
(require 'thwap-eglot)
;; projectile configuration
(require 'thwap-projectile)
;; magit configuration
(require 'thwap-magit)
;; CoPilot configuration
(require 'thwap-copilot)
(require 'thwap-completion)
;; development configuration
(require 'thwap-development)
;; org configuration
(require 'thwap-org)
;; golang configuration
(require 'thwap-go)
;; terraform configuration
(require 'thwap-tf)
;; python configuration
(require 'thwap-py)
;; yaml configuration
(require 'thwap-yaml)
;; yasnippet configuration
(require 'thwap-yas)
(require 'thwap-orgmode)
;; dashboard
(require 'thwap-dash)
(require 'thwap-dashboard)

View File

@ -1,18 +0,0 @@
;; Company and auto-complete configuration
(when (and thwap-comp-enable-company (not thwap-comp-enable-auto-complete))
(straight-use-package 'company)
(add-hook 'after-init-hook 'global-company-mode))
;; If auto-complete is enabled, enable it
(when (and thwap-comp-enable-auto-complete (not thwap-comp-enable-company))
(straight-use-package 'auto-complete)
(ac-config-default))
;; If both are enabled, disable auto-complete
(when (and thwap-comp-enable-auto-complete thwap-comp-enable-company)
(message "Both company and auto-complete are enabled. These are mutually exclusive. Disabling auto-complete.")
(straight-use-package 'company)
(add-hook 'after-init-hook 'global-company-mode))
(provide 'thwap-comp)

View File

@ -1,222 +0,0 @@
;;
;; Define the custom variables for the T.H.W.A.P. Emacs configuration.
;;
;; define the group
(defgroup thwap-config nil
"T.H.W.A.P. Emacs configuration group."
:group 'convenience
:prefix "thwap-")
;;
;; Theme and appearance settings
;;
;; modus themes toggle
(defcustom thwap-ui-enable-modus-themes nil
"Whether or not to install the modus themes."
:type 'boolean
:group 'thwap-config)
;; doom themes toggle
(defcustom thwap-ui-enable-doom-themes nil
"Whether or not to install the doom themes."
:type 'boolean
:group 'thwap-config)
;; sublime themes toggle
(defcustom thwap-ui-enable-sublime-themes nil
"Whether or not to install the sublime themes."
:type 'boolean
:group 'thwap-config)
;; kaolin themes toggle
(defcustom thwap-ui-enable-kaolin-themes nil
"Whether or not to install the kaolin themes."
:type 'boolean
:group 'thwap-config)
;; alect themes toggle
(defcustom thwap-ui-enable-alect-themes nil
"Whether or not to install the alect themes."
:type 'boolean
:group 'thwap-config)
;; theme to load
(defcustom thwap-ui-theme 'wombat ;; 'modus-vivendi-tinted
"Name of the theme to load."
:type 'string
:group 'thwap-config)
;; all-the-icons toggle
(defcustom thwap-ui-enable-all-the-icons nil
"Whether or not to enable all-the-icons."
:type 'boolean
:group 'thwap-config)
;; nerd-icons toggle
(defcustom thwap-ui-enable-nerd-icons nil
"Whether or not to enable nerd-icons."
:type 'boolean
:group 'thwap-config)
;;
;; Tree browser packages
;;
;; treemacs toggle
(defcustom thwap-fm-enable-treemacs nil
"Whether or not to enable treemacs."
:type 'boolean
:group 'thwap-config)
;; neotree toggle
(defcustom thwap-fm-enable-neotree nil
"Whether or not to enable neotree."
:type 'boolean'
:group 'thwap-config)
;;
;; Completion packages
;;
;; company toggle
(defcustom thwap-comp-enable-company nil
"Whether or not to enable company."
:type 'boolean
:group 'thwap-config)
;; auto-complete toggle
(defcustom thwap-comp-enable-auto-complete nil
"Whether or not to enable auto-complete."
:type 'boolean
:group 'thwap-config)
;;
;; development assistance packages
;;
;; lsp toggle
(defcustom thwap-dev-enable-lsp nil
"Whether or not to enable lsp."
:type 'boolean
:group 'thwap-config)
;; projectile toggle
(defcustom thwap-dev-enable-projectile nil
"Whether or not to enable projectile."
:type 'boolean
:group 'thwap-config)
;; magit toggle
(defcustom thwap-dev-enable-magit nil
"Whether or not to enable magit."
:type 'boolean
:group 'thwap-config)
;; Copilot toggle
(defcustom thwap-dev-enable-copilot nil
"Whether or not to enable copilot."
:type 'boolean
:group 'thwap-config)
;; Eglot toggle
(defcustom thwap-dev-enable-eglot nil
"Whether or not to setup Eglot."
:type 'boolean
:group 'thwap-config)
;; Go toggle
(defcustom thwap-dev-enable-go nil
"Whether or not to setup Go development modes."
:type 'boolean
:group 'thwap-config)
;; Python toggle
(defcustom thwap-dev-enable-python nil
"Whether or not to setup Python development modes."
:type 'boolean
:group 'thwap-config)
;; Terraform toggle
(defcustom thwap-dev-enable-terraform nil
"Whether or not to setup Terraform development modes."
:type 'boolean
:group 'thwap-config)
;; Yaml toggle
(defcustom thwap-dev-enable-yaml nil
"Whether or not to setup Yaml modes."
:type 'boolean
:group 'thwap-config)
;;
;; Org mode settings
;;
(defcustom thwap-org-enable-org nil
"Whether or not to enable org-mode."
:type 'boolean
:group 'thwap-config)
(defcustom thwap-org-enable-org-bullets nil
"Whether or not to enable org-bullets."
:type 'boolean
:group 'thwap-config)
(defcustom thwap-org-enable-org-super-agenda nil
"Whether or not to enable org-super-agenda."
:type 'boolean
:group 'thwap-config)
(defcustom thwap-org-enable-org-modern nil
"Whether or not to enable org-modern."
:type 'boolean
:group 'thwap-config)
(defcustom thwap-org-enable-org-timeblock nil
"Whether or not to enable org-timeblock."
:type 'boolean
:group 'thwap-config)
(defcustom thwap-org-enable-org-download nil
"Whether or not to enable org-download."
:type 'boolean
:group 'thwap-config)
(defcustom thwap-org-enable-org-roam nil
"Whether or not to enable org-roam."
:type 'boolean
:group 'thwap-config)
(defcustom thwap-org-enable-org-roam-ui nil
"Whether or not to enable org-roam-ui."
:type 'boolean
:group 'thwap-config)
(defcustom thwap-org-enable-ob-mermaid nil
"Whether or not to enable ob-mermaid."
:type 'boolean
:group 'thwap-config)
(defcustom thwap-org-enable-org-transclusion nil
"Whether or not to enable org-transclusion."
:type 'boolean
:group 'thwap-config)
(defcustom thwap-org-enable-org-ai nil
"Whether or not to enable org-ai."
:type 'boolean
:group 'thwap-config)
(defcustom thwap-org-openai-api-token nil
"OpenAI API Token for use in org-ai."
:type 'string
:group 'thwap-config)
;; our provide statement
(provide 'thwap-config)

View File

@ -1,13 +0,0 @@
(when thwap-dev-enable-copilot
(straight-use-package 'dash)
(straight-use-package 'editorconfig)
(use-package copilot
:straight (:host github :repo "zerolfx/copilot.el" :files ("dist" "*.el"))
:ensure t)
;; you can utilize :map :hook and :config to customize copilot
(add-hook 'prog-mode-hook 'copilot-mode)
(define-key copilot-completion-map (kbd "<tab>") 'copilot-accept-completion)
(define-key copilot-completion-map (kbd "TAB") 'copilot-accept-completion))
(provide 'thwap-copilot)

View File

@ -1,5 +0,0 @@
(when (or thwap-dev-enable-eglot thwap-dev-enable-lsp)
(straight-use-package 'eglot)
(require 'eglot))
(provide 'thwap-eglot)

View File

@ -1,14 +0,0 @@
(when thwap-dev-enable-go
(straight-use-package 'go-mode)
(setq lsp-go-analyses '((shadow . t)
(simplifycompositelit . :json-false)))
(when (executable-find "gopls")
(add-hook 'go-mode-hook #'lsp-deferred)
(add-hook 'go-mode-hook 'eglot-ensure))
(when (executable-find "goimports")
(setq gofmt-command "goimports"))
(add-hook 'before-save-hook 'gofmt-before-save))
(provide 'thwap-go)

View File

@ -1,41 +0,0 @@
(when (and thwap-ui-enable-all-the-icons (not thwap-ui-enable-nerd-icons))
(use-package all-the-icons
:ensure t
:straight t
:hook (dired-mode . all-the-icons-dired-mode))
(use-package all-the-icons-completion
:ensure t
:straight t
:defer
:init
(all-the-icons-completion-mode 1)))
(when (and thwap-ui-enable-nerd-icons (not thwap-ui-enable-all-the-icons))
(use-package nerd-icons
:straight (nerd-icons
:type git
:host github
:repo "rainstormstudio/nerd-icons.el"
:files (:defaults "data"))
:custom
;; The Nerd Font you want to use in GUI
;; "Symbols Nerd Font Mono" is the default and is recommended
;; but you can use any other Nerd Font if you want
(nerd-icons-font-family "Symbols Nerd Font Mono")
))
(when (and thwap-ui-enable-nerd-icons thwap-ui-enable-all-the-icons)
(message "Both all-the-icons and nerd-icons are enabled. Disabling nerd-icons.")
(use-package all-the-icons-dired
:ensure t
:straight t
:hook (dired-mode . all-the-icons-dired-mode))
(use-package all-the-icons-completion
:ensure t
:straight t
:defer
:init
(all-the-icons-completion-mode 1)))
(provide 'thwap-icons)

View File

@ -1,10 +0,0 @@
(when thwap-dev-enable-lsp
(straight-use-package 'lsp-mode)
(straight-use-package 'lsp-ui)
(straight-use-package 'lsp-treemacs)
(setq gc-cons-threshold 100000000)
(setq read-process-output-max (* 1024 1024))
(thwap/add-key-binding "l" 'lsp-keymap-prefix "lsp-keymap-prefix"))
(provide 'thwap-lsp)

View File

@ -1,8 +0,0 @@
(when thwap-dev-enable-magit
(straight-use-package 'magit)
(straight-use-package 'forge)
(straight-use-package 'magit-todos)
(thwap/add-key-binding "g s" 'magit-status "Git status (magit entrypoint)"))
(provide 'thwap-magit)

View File

@ -1,6 +0,0 @@
(when thwap-dev-enable-projectile
(straight-use-package 'projectile)
(thwap/add-key-binding "p" 'projectile-command-map "Projectile commands"))
(provide 'thwap-projectile)

View File

@ -1,13 +0,0 @@
(when thwap-dev-enable-python
(add-hook 'python-mode-hook (lambda ()
(setq-local tab-width 2)))
(add-hook 'python-mode-hook #'lsp-deferred)
(when (executable-find "pylsp")
(add-hook 'python-mode-hook 'eglot-ensure))
(use-package python-black
:demand t
:straight t
:after python
:hook (python-mode . python-black-on-save-mode)))
(provide 'thwap-py)

View File

@ -1,17 +0,0 @@
(when thwap-dev-enable-terraform
(use-package terraform-mode
:straight t
:demand t
:init
(custom-set-variables
'(terraform-indent-level 2)
'(terraform-format-on-save t))
:config
(add-to-list 'eglot-server-programs
`(terraform-mode . ("terraform-ls" "serve"))))
(when thwap-dev-enable-lsp
(when (executable-find "terraform-ls")
(add-hook 'terraform-mode-hook 'eglot-ensure))
(add-hook 'terraform-mode-hook #'lsp-deferred)))
(provide 'thwap-tf)

View File

@ -1,29 +0,0 @@
;; theme bits
(when thwap-ui-enable-modus-themes
(straight-use-package 'modus-themes)
(require 'modus-themes))
(when thwap-ui-enable-doom-themes
(straight-use-package 'doom-themes)
(require 'doom-themes))
(when thwap-ui-enable-sublime-themes
(straight-use-package 'sublime-themes)
(require 'sublime-themes))
(when thwap-ui-enable-kaolin-themes
(straight-use-package 'kaolin-themes)
(require 'kaolin-themes))
(when thwap-ui-enable-alect-themes
(straight-use-package 'alect-themes)
(require 'alect-themes))
;; load the theme specified in the config
;; if things look wonky, you probably either need to install the
;; theme or you need to check your spelling.
(load-theme thwap-ui-theme :no-confirm)
(provide 'thwap-theme)

View File

@ -1,6 +0,0 @@
(when thwap-dev-enable-yaml
(use-package yaml-mode
:ensure t
:straight t))
(provide 'thwap-yaml)

View File

@ -1,19 +0,0 @@
(use-package yasnippet
:ensure t
:straight t
:config
(setq yas-snippet-dirs '("~/.emacs.d/snippets")))
;; (yas-global-mode 1))
(use-package yasnippet-snippets
:ensure t
:straight t
:after yasnippet
:config
(yas-reload-all)
(yas-global-mode 1))
;; yasnippet stuff
(thwap/add-key-binding "y n" 'yas-new-snippet "Create a new yasnippet")
(provide 'thwap-yas)

51
thwap/thwap-completion.el Normal file
View File

@ -0,0 +1,51 @@
;;
;; Completion packages
;;
;; company toggle
(defcustom thwap-completion nil
"Choose the completion framework to use."
:type '(choice (const :tag "None" nil)
(const :tag "company" companycomp)
(const :tag "helm" helmcomp)
(const :tag "ivy" ivycomp))
:group 'thwap-config)
;; Company and auto-complete configuration
(when (and (eq 'companycomp thwap-completion) (not (eq 'helmcomp thwap-completion)) (not (eq 'ivycomp thwap-completion)))
(straight-use-package 'company)
(add-hook 'after-init-hook 'global-company-mode))
;; If ivy is enabled, install and configure it
(when (and (eq 'ivycomp thwap-completion) (not (eq 'companycomp thwap-completion)) (not (eq 'helmcomp thwap-completion)))
(straight-use-package 'ivy)
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t))
;; If helm is enabled, install and configure it
(when (and (eq 'helmcomp thwap-completion) (not (eq 'companycomp thwap-completion)) (not (eq 'ivycomp thwap-completion)))
(straight-use-package 'helm)
(helm-mode 1))
;; If all are enabled, choose company
(when (or (and (eq 'companycomp thwap-completion) (eq 'helmcomp thwap-completion) (eq 'ivycomp thwap-completion))
(and (eq 'companycomp thwap-completion) (eq 'helmcomp thwap-completion) (not (eq 'ivycomp thwap-completion)))
(and (eq 'companycomp thwap-completion) (eq 'ivycomp thwap-completion) (not (eq 'helmcomp thwap-completion))))
(message "All completion frameworks are enabled. Choosing company.")
(straight-use-package 'company)
(add-hook 'after-init-hook 'global-company-mode))
;; if helm and ivy are enabled, choose ivy
(when (and (eq 'helmcomp thwap-completion) (eq 'ivycomp thwap-completion) (not (eq 'companycomp thwap-completion)))
(message "Both helm and ivy are enabled. Choosing ivy.")
(straight-use-package 'ivy)
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq enable-recursive-minibuffers t))
(provide 'thwap-completion)

View File

@ -0,0 +1,11 @@
;;
;; Define the custom variables for the T.H.W.A.P. Emacs configuration.
;;
;; define the group
(defgroup thwap-config nil
"T.H.W.A.P. Emacs configuration group."
:group 'convenience
:prefix "thwap-")
(provide 'thwap-configuration)

View File

@ -1,26 +1,3 @@
;;
;; Helper functions for the dashboard
;;
(defun thwap/dashboard-insert-logo-title (banner)
"Insert BANNER into the dashboard buffer."
(insert "\n")
;; if banner is a single string, display it in the center
;; else if it is a list of strings, display them with line breaks
(if (stringp banner)
(insert (propertize banner 'face 'dashboard-banner-logo-title))
(dolist (line banner)
(insert (propertize line 'face 'dashboard-banner-logo-title))
(insert "\n"))))
(defun thwap/dashboard-build-logo-title (lst)
"Build a list of strings from LST to display as the banner."
(mapconcat 'identity (reverse lst) "\n"))
(defun thwap/random-string-from-list (strings)
(let ((index (random (length strings))))
(nth index strings)))
(straight-use-package 'dashboard)
(dashboard-setup-startup-hook)
@ -31,7 +8,8 @@
(setq dashboard-center-content t)
(setq dashboard-vertically-center-content t)
(setq dashboard-show-shortcuts t)
(setq dashboard-items '((recents . 10)))
(setq dashboard-items '((recents . 5)
(agenda . 5)))
(setq dashboard-startupify-list '(dashboard-insert-banner
dashboard-insert-newline
dashboard-insert-banner-title
@ -43,4 +21,5 @@
dashboard-insert-newline
dashboard-insert-footer))
(provide 'thwap-dash)
(provide 'thwap-dashboard)
;;; thwap-dashboard.el ends here

View File

@ -51,6 +51,17 @@
;; eval buffer is also very useful
(thwap/add-key-binding "e b" 'eval-buffer "Eval buffer")
(straight-use-package 'yasnippet)
(require 'yasnippet)
(setq yas-snippet-dirs '("~/.emacs.d/snippets"))
(straight-use-package 'yasnippet-snippets)
(require 'yasnippet-snippets)
(yas-reload-all)
(yas-global-mode 1)
;; yasnippet stuff
(thwap/add-key-binding "y n" 'yas-new-snippet "Create a new yasnippet")
;; our provide statement

125
thwap/thwap-development.el Normal file
View File

@ -0,0 +1,125 @@
;;
;; development assistance packages
;;
;; dev layer toggles
(defcustom thwap-development nil
"Whether or not to enable development assistance packages."
:type '(set (const :tag "None" nil)
(const :tag "lsp" lspmode) ;; generally required for other modes
(const :tag "magit" magitmode) ;; git integration
(const :tag "projectile" projectilemode) ;; project management
(const :tag "copilot" copilotmode) ;; code completion
(const :tag "go" gomode) ;; go language support
(const :tag "python" pythonmode) ;; python language support
(const :tag "elpy" elpymode) ;; python language support (elpy)
(const :tag "terraform" terraformmode) ;; terraform language support
(const :tag "yaml" yamlmode)) ;; yaml language support
:group 'thwap-config)
;; lsp-mode
(when (memq 'lspmode thwap-development)
(straight-use-package 'lsp-mode)
(straight-use-package 'lsp-ui)
(when (eq 'treemacs thwap-dirbrowser)
(straight-use-package 'lsp-treemacs))
(setq gc-cons-threshold 100000000)
(setq read-process-output-max (* 1024 1024))
(thwap/add-key-binding "l" 'lsp-keymap-prefix "lsp-keymap-prefix")
(straight-use-package 'eglot)
(require 'eglot)
(message "lsp-mode loaded"))
;; magit
(when (memq 'magitmode thwap-development)
(straight-use-package 'magit)
(straight-use-package 'forge)
(straight-use-package 'magit-todos)
(thwap/add-key-binding "g s" 'magit-status "Git status (magit entrypoint)")
(thwap/add-key-binding "g l" 'magit-log "Git log (magit entrypoint")
(thwap/add-key-binding "g b" 'magit-blame "Git blame (magit entrypoint")
(thwap/add-key-binding "g f" 'magit-find-file "Git find file (magit entrypoint")
(message "magit loaded"))
;; projectile
(when (memq 'projectilemode thwap-development)
(straight-use-package 'projectile)
(thwap/add-key-binding "p" 'projectile-command-map "Projectile commands")
(message "projectile loaded"))
;; co-pilot
(when (memq 'copilotmode thwap-development)
(straight-use-package 'dash)
(straight-use-package 'editorconfig)
(use-package copilot
:straight (:host github :repo "zerolfx/copilot.el" :files ("dist" "*.el"))
:ensure t)
;; you can utilize :map :hook and :config to customize copilot
(add-hook 'prog-mode-hook 'copilot-mode)
(define-key copilot-completion-map (kbd "<tab>") 'copilot-accept-completion)
(define-key copilot-completion-map (kbd "TAB") 'copilot-accept-completion)
(message "copilot loaded"))
;; go-mode
(when (memq 'gomode thwap-development)
(straight-use-package 'go-mode)
(straight-use-package 'go-eldoc)
(straight-use-package 'go-projectile)
(straight-use-package 'go-snippets)
(setq lsp-go-analyses '((shadow . t)
(simplifycompositelit . :json-false)))
(when (executable-find "gopls")
(add-hook 'go-mode-hook #'lsp-deferred)
(add-hook 'go-mode-hook 'eglot-ensure))
(when (executable-find "goimports")
(setq gofmt-command "goimports"))
(add-hook 'before-save-hook 'gofmt-before-save)
(message "go-mode loaded"))
;; python-mode
(when (memq 'pythonmode thwap-development)
(when (memq 'elpymode thwap-development)
(straight-use-package 'elpy)
(elpy-enable))
(when (not (memq 'elpymode thwap-development))
(add-hook 'python-mode-hook (lambda ()
(setq-local tab-width 2)))
(add-hook 'python-mode-hook #'lsp-deferred))
(when (executable-find "pylsp")
(add-hook 'python-mode-hook 'eglot-ensure))
(use-package python-black
:demand t
:straight t
:after python
:hook (python-mode . python-black-on-save-mode))
(message "python-mode loaded"))
;; terraform-mode
(when (memq 'terraformmode thwap-development)
(straight-use-package 'terraform-mode)
(when (eq 'company thwap-completion)
(straight-use-package 'company-terraform)
(add-hook 'terraform-mode-hook #'company-terraform-init))
(add-hook 'terraform-mode-hook #'terraform-format-on-save-mode)
(add-hook 'terraform-mode-hook #'terraform-format-on-save-mode)
(message "terraform-mode loaded"))
;; yaml-mode
(when (memq 'yamlmode thwap-development)
(straight-use-package 'yaml-mode)
(add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
(add-to-list 'auto-mode-alist '("\\.yaml\\'" . yaml-mode))
;; yaml-mode is a bit too aggressive with its indentation
;; so we'll disable it and use the default
(add-hook 'yaml-mode-hook
(lambda ()
(setq-local electric-indent-inhibit t)
(setq-local electric-layout-rules nil)))
(message "yaml-mode loaded"))
(message "T.H.W.A.P. development assistance packages loaded")
(provide 'thwap-development)
;; thwap-development.el ends here

View File

@ -1,5 +1,21 @@
(when (and thwap-fm-enable-neotree (not thwap-fm-enable-treemacs))
;;
;; Tree browser packages
;;
(defcustom thwap-dirbrowser nil
"Whether or not to enable treemacs."
:type '(choice (const :tag "None" nil)
(const :tag "neotree" neotree)
(const :tag "treemacs" treemacs))
:group 'thwap-config)
;;
;; File Tree Browser
;;
(when (eq 'neotree thwap-dirbrowser)
(use-package neotree
:straight t
:config
@ -7,7 +23,7 @@
(thwap/add-key-binding "C-n" 'neotree-toggle "Toggle Neotree")))
(when (and thwap-fm-enable-treemacs (not thwap-fm-enable-neotree))
(when (eq 'treemacs thwap-dirbrowser)
(use-package treemacs
:straight t
:ensure t
@ -27,9 +43,8 @@
treemacs-never-persist nil
treemacs-is-never-other-window t
treemacs-goto-tag-strategy 'refetch-index)))
(thwap/add-key-binding "C-n" 'treemacs "Toggle Treemacs"))
(thwap/add-key-binding "C-t" 'treemacs "Toggle Treemacs")
(when (memq 'kaolinthemes thwap-ui-themes)
(kaolin-treemacs-theme)))
(when (and thwap-fm-enable-treemacs thwap-ui-enable-kaolin-themes (not thwap-fm-enable-neotree))
(kaolin-treemacs-theme))
(provide 'thwap-nerdtree)
(provide 'thwap-file-browser)

56
thwap/thwap-helpers.el Normal file
View File

@ -0,0 +1,56 @@
;;
;; Helper functions for the dashboard
;;
(defun thwap/dashboard-insert-logo-title (banner)
"Insert BANNER into the dashboard buffer."
(insert "\n")
;; if banner is a single string, display it in the center
;; else if it is a list of strings, display them with line breaks
(if (stringp banner)
(insert (propertize banner 'face 'dashboard-banner-logo-title))
(dolist (line banner)
(insert (propertize line 'face 'dashboard-banner-logo-title))
(insert "\n"))))
(defun thwap/dashboard-build-logo-title (lst)
"Build a list of strings from LST to display as the banner."
(mapconcat 'identity (reverse lst) "\n"))
(defun thwap/random-string-from-list (strings)
(let ((index (random (length strings))))
(nth index strings)))
;;
;; Helper functions for general use
;;
;; Function to list all files in a directory with a given extension
(defun thwap/list-files-with-extension (dir extension)
"Recursively list all files in DIR with the given EXTENSION, suitable for org-agenda-files."
(let ((files '()))
(dolist (file (directory-files-recursively dir (concat "\\." extension "\\'")))
(push file files))
(nreverse files)))
;;
;; Helper functions for org mode
;;
;; Function to get a unique filename for Org-capture
(defun thwap/org-capture-get-unique-filename ()
"Generate a unique filename for Org-capture."
(let ((filename (format "~/.org-agenda/syncup__issue__%s.org" (format-time-string "%Y%m%d%H%M%S"))))
(message "Inside function: Generated filename: %s" filename)
filename))
;; Function to update org-agenda-files
(defun thwap/org-agenda-files-update ()
"Update the org-agenda-files variable."
(setq org-agenda-files (thwap/list-files-with-extension "~/.org-agenda" "org"))
(setq org-timeblock-files (thwap/list-files-with-extension "~/.org-agenda" "org"))
(setq org-timeblock-inbox-file "~/.org-agenda/tasks.org"))
(provide 'thwap-helpers)
;;; thwap-helpers.el ends here

100
thwap/thwap-interface.el Normal file
View File

@ -0,0 +1,100 @@
;;
;; Theme and appearance settings
;;
;; modus themes toggle
(defcustom thwap-ui-themes nil
"Choose the themes to install."
:type '(set (const :tag "Modus themes" modusthemes)
(const :tag "Doom themes" doomthemes)
(const :tag "Sublime themes" sublimethemes)
(const :tag "Kaolin themes" kaolinthemes)
(const :tag "Alect themes" alectthemes))
:group 'thwap-config)
;; theme to load
(defcustom thwap-ui-theme 'wombat ;; 'modus-vivendi-tinted
"Name of the theme to load."
:type 'string
:group 'thwap-config)
;; all-the-icons toggle
(defcustom thwap-ui-icons nil
"Choose the icon sets to install."
:type '(choice (const :tag "None" nil)
(const :tag "All-the-icons" alltheicons)
(const :tag "Nerd-icons" nerdicons))
:group 'thwap-config)
;; theme bits
(when (memq 'modusthemes thwap-ui-themes)
(straight-use-package 'modus-themes)
(require 'modus-themes))
(when (memq 'doomthemes thwap-ui-themes)
(straight-use-package 'doom-themes)
(require 'doom-themes))
(when (memq 'sublimethemes thwap-ui-themes)
(straight-use-package 'sublime-themes)
(require 'sublime-themes))
(when (memq 'kaolinthemes thwap-ui-themes)
(straight-use-package 'kaolin-themes)
(require 'kaolin-themes))
(when (memq 'alectthems thwap-ui-themes)
(straight-use-package 'alect-themes)
(require 'alect-themes))
;; load the theme specified in the config
;; if things look wonky, you probably either need to install the
;; theme or you need to check your spelling.
(load-theme thwap-ui-theme :no-confirm)
;; icon bits
(when (and (eq 'alltheicons thwap-ui-icons) (not (eq 'nerdicons thwap-ui-icons)))
(use-package all-the-icons
:ensure t
:straight t
:hook (dired-mode . all-the-icons-dired-mode))
(use-package all-the-icons-completion
:ensure t
:straight t
:defer
:init
(all-the-icons-completion-mode 1)))
(when (and (eq 'nerdicons thwap-ui-icons) (not (eq 'alltheicons thwap-ui-icons)))
(use-package nerd-icons
:straight (nerd-icons
:type git
:host github
:repo "rainstormstudio/nerd-icons.el"
:files (:defaults "data"))
:custom
;; The Nerd Font you want to use in GUI
;; "Symbols Nerd Font Mono" is the default and is recommended
;; but you can use any other Nerd Font if you want
(nerd-icons-font-family "Symbols Nerd Font Mono")
))
(when (and (eq 'nerdicons thwap-ui-icons) (eq 'alltheicons thwap-ui-icons))
(message "Both all-the-icons and nerd-icons are enabled. Disabling nerd-icons.")
(use-package all-the-icons-dired
:ensure t
:straight t
:hook (dired-mode . all-the-icons-dired-mode))
(use-package all-the-icons-completion
:ensure t
:straight t
:defer
:init
(all-the-icons-completion-mode 1)))
(provide 'thwap-interface)

View File

@ -1,34 +1,39 @@
;;
;; Helper functions
;; Org mode settings
;;
;; Function to get a unique filename for Org-capture
(defun thwap/org-capture-get-unique-filename ()
"Generate a unique filename for Org-capture."
(let ((filename (format "~/.org-agenda/syncup__issue__%s.org" (format-time-string "%Y%m%d%H%M%S"))))
(message "Inside function: Generated filename: %s" filename)
filename))
;; org layer toggles
(defcustom thwap-orgmode nil
"Choose from the available org-mode packages"
:type '(set (const :tag "None" nil)
(const :tag "Org" orgmode)
(const :tag "Org-Bullets" orgbullets)
(const :tag "Org-SuperAgenda" orgsuperagenda)
(const :tag "Org-Modern" orgmodern)
(const :tag "Org-TimeBlock" orgtimeblock)
(const :tag "Org-Download" orgdownload)
(const :tag "Org-Transclusion" orgtransclusion))
:group 'thwap-config)
(defun thwap/list-files-with-extension (dir extension)
"Recursively list all files in DIR with the given EXTENSION, suitable for org-agenda-files."
(let ((files '()))
(dolist (file (directory-files-recursively dir (concat "\\." extension "\\'")))
(push file files))
(nreverse files)))
(defun thwap/org-agenda-files-update ()
"Update the org-agenda-files variable."
(setq org-agenda-files (thwap/list-files-with-extension "~/.org-agenda" "org"))
(setq org-timeblock-files (thwap/list-files-with-extension "~/.org-agenda" "org"))
(setq org-timeblock-inbox-file "~/.org-agenda/tasks.org"))
;; org-babel extras
(defcustom thwap-orgbabel nil
"Choose extra packages for org-babel"
:type '(set (const :tag "None" nil)
(const :tag "ob-mermaid" obmermaid)
(const :tag "ob-napkin" obnapkin))
:group 'thwap-config)
(defcustom thwap-org-openai-api-token nil
"OpenAI API Token for use in org-ai. (Setting this enables the org-ai support.)"
:type 'string
:group 'thwap-config)
;;
;; Ensure Org mode is installed and loaded
;;
;; base
(when thwap-org-enable-org
(when (memq 'orgmode thwap-orgmode)
(straight-use-package 'org)
(setq browse-url-browser-function 'browse-url-generic
browse-url-generic-program "firefox-esr"
@ -82,59 +87,59 @@
(thwap/add-key-binding "o e" 'org-export-dispatch "Export the current buffer."))
;; org-bullets
(when (and thwap-org-enable-org thwap-org-enable-org-bullets)
(when (and (memq 'orgmode thwap-orgmode) (memq 'orgbullets thwap-orgmode))
(straight-use-package 'org-bullets)
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1))))
;; org-super-agenda
(when (and thwap-org-enable-org thwap-org-enable-org-super-agenda)
(when (and (memq 'orgmode thwap-orgmode) (memq 'orgsuperagenda thwap-orgmode))
(straight-use-package 'org-super-agenda)
(add-hook 'org-agenda-mode-hook 'org-super-agenda-mode))
;; org-modern
(when (and thwap-org-enable-org thwap-org-enable-org-modern)
(when (and (memq 'orgmode thwap-orgmode) (memq 'orgmodern thwap-orgmode))
(straight-use-package 'org-modern))
;; org-timeblock
(when (and thwap-org-enable-org thwap-org-enable-org-timeblock)
(when (and (memq 'orgmode thwap-orgmode) (memq 'orgtimeblock thwap-orgmode))
(straight-use-package 'org-timeblock))
;; org-download
(when (and thwap-org-enable-org thwap-org-enable-org-download)
(when (and (memq 'orgmode thwap-orgmode) (memq 'orgdownload thwap-orgmode))
(add-hook 'dired-mode-hook 'org-download-enable))
;; org-roam
;; (when (and thwap-org-enable-org thwap-org-enable-org-roam)
;; (setq org-roam-directory "~/.org-agenda")
;; (setq org-roam-db-location "~/.org-agenda/org-roam.db")
;; (setq org-roam-completion-everywhere t)
;; (setq org-roam-capture-templates
;; '(("d" "default" plain "%?"
;; :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
;; :unnarrowed t)))
;; (add-hook 'after-init-hook 'org-roam-mode)
;; (add-hook 'org-mode-hook 'org-roam-mode)
;; (add-hook 'org-mode-hook 'org-roam-ui-mode))
;; ;; org-roam-ui
;; (when (and thwap-org-enable-org thwap-org-enable-org-roam thwap-org-enable-org-roam-ui)
;; (straight-use-package 'org-roam-ui)
;; (setq org-roam-ui-sync-theme t)
;; (setq org-roam-ui-follow t)
;; (setq org-roam-ui-update-on-save t))
;; org-transclusion
(when (and (memq 'orgmode thwap-orgmode) (memq 'orgtransclusion thwap-orgmode))
(straight-use-package 'org-transclusion))
;; ob-mermaid
(when (and thwap-org-enable-org thwap-org-enable-ob-mermaid)
(when (and (memq 'orgmode thwap-orgmode) (memq 'obmermaid thwap-orgbabel))
(straight-use-package 'ob-mermaid)
(add-to-list 'org-src-lang-modes '("mermaid" . mermaid))
(add-to-list 'org-babel-load-languages '(mermaid . t)))
;; org-roam
(when (and thwap-org-enable-org thwap-org-enable-org-roam)
(setq org-roam-directory "~/.org-agenda")
(setq org-roam-db-location "~/.org-agenda/org-roam.db")
(setq org-roam-completion-everywhere t)
(setq org-roam-capture-templates
'(("d" "default" plain "%?"
:if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
:unnarrowed t)))
(add-hook 'after-init-hook 'org-roam-mode)
(add-hook 'org-mode-hook 'org-roam-mode)
(add-hook 'org-mode-hook 'org-roam-ui-mode))
;; org-roam-ui
(when (and thwap-org-enable-org thwap-org-enable-org-roam thwap-org-enable-org-roam-ui)
(straight-use-package 'org-roam-ui)
(setq org-roam-ui-sync-theme t)
(setq org-roam-ui-follow t)
(setq org-roam-ui-update-on-save t))
;; org-transclusion
(when (and thwap-org-enable-org thwap-org-enable-org-transclusion)
(straight-use-package 'org-transclusion))
;; org-ai
(when (and thwap-org-enable-org thwap-org-enable-org-ai)
(when (and (memq 'orgmode thwap-orgmode) thwap-org-openai-api-token)
(straight-use-package
'(org-ai :type git :host github :repo "rksm/org-ai"
:local-repo "org-ai"
@ -144,9 +149,6 @@
(org-ai-global-mode)
(org-ai-install-yasnippets))
;;
;; Org mode configuration
;;
(provide 'thwap-org)
(provide 'thwap-orgmode)
;; thwap-orgmode.el ends here