From 107c25c8ae94c4a4804f27dd33e07228604fb33d Mon Sep 17 00:00:00 2001 From: Mike 'Fuzzy' Partin Date: Wed, 10 Jul 2024 01:34:45 -0700 Subject: [PATCH] BIG GINORMOUS HUGE COMMIT THAT SHOULD CATCH THINGS UP WITH A BIG REFACTOR --- early-init.el | 2 +- init.el | 44 +--- lib/thwap-comp.el | 18 -- lib/thwap-config.el | 222 ------------------ lib/thwap-copilot.el | 13 - lib/thwap-eglot.el | 5 - lib/thwap-go.el | 14 -- lib/thwap-icons.el | 41 ---- lib/thwap-lsp.el | 10 - lib/thwap-magit.el | 8 - lib/thwap-projectile.el | 6 - lib/thwap-py.el | 13 - lib/thwap-tf.el | 17 -- lib/thwap-theme.el | 29 --- lib/thwap-yaml.el | 6 - lib/thwap-yas.el | 19 -- thwap/thwap-completion.el | 51 ++++ thwap/thwap-configuration.el | 11 + lib/thwap-dash.el => thwap/thwap-dashboard.el | 29 +-- {lib => thwap}/thwap-defaults.el | 11 + thwap/thwap-development.el | 125 ++++++++++ .../thwap-file-browser.el | 29 ++- thwap/thwap-helpers.el | 56 +++++ thwap/thwap-interface.el | 100 ++++++++ lib/thwap-org.el => thwap/thwap-orgmode.el | 114 ++++----- 25 files changed, 452 insertions(+), 541 deletions(-) delete mode 100644 lib/thwap-comp.el delete mode 100644 lib/thwap-config.el delete mode 100644 lib/thwap-copilot.el delete mode 100644 lib/thwap-eglot.el delete mode 100644 lib/thwap-go.el delete mode 100644 lib/thwap-icons.el delete mode 100644 lib/thwap-lsp.el delete mode 100644 lib/thwap-magit.el delete mode 100644 lib/thwap-projectile.el delete mode 100644 lib/thwap-py.el delete mode 100644 lib/thwap-tf.el delete mode 100644 lib/thwap-theme.el delete mode 100644 lib/thwap-yaml.el delete mode 100644 lib/thwap-yas.el create mode 100644 thwap/thwap-completion.el create mode 100644 thwap/thwap-configuration.el rename lib/thwap-dash.el => thwap/thwap-dashboard.el (57%) rename {lib => thwap}/thwap-defaults.el (83%) create mode 100644 thwap/thwap-development.el rename lib/thwap-nerdtree.el => thwap/thwap-file-browser.el (57%) create mode 100644 thwap/thwap-helpers.el create mode 100644 thwap/thwap-interface.el rename lib/thwap-org.el => thwap/thwap-orgmode.el (60%) diff --git a/early-init.el b/early-init.el index 978015b..4b29f36 100644 --- a/early-init.el +++ b/early-init.el @@ -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)) diff --git a/init.el b/init.el index 701528b..c72eea9 100644 --- a/init.el +++ b/init.el @@ -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) diff --git a/lib/thwap-comp.el b/lib/thwap-comp.el deleted file mode 100644 index 9e58f86..0000000 --- a/lib/thwap-comp.el +++ /dev/null @@ -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) diff --git a/lib/thwap-config.el b/lib/thwap-config.el deleted file mode 100644 index 96990a7..0000000 --- a/lib/thwap-config.el +++ /dev/null @@ -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) diff --git a/lib/thwap-copilot.el b/lib/thwap-copilot.el deleted file mode 100644 index 8f7739b..0000000 --- a/lib/thwap-copilot.el +++ /dev/null @@ -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 "") 'copilot-accept-completion) - (define-key copilot-completion-map (kbd "TAB") 'copilot-accept-completion)) - -(provide 'thwap-copilot) diff --git a/lib/thwap-eglot.el b/lib/thwap-eglot.el deleted file mode 100644 index a007c9f..0000000 --- a/lib/thwap-eglot.el +++ /dev/null @@ -1,5 +0,0 @@ -(when (or thwap-dev-enable-eglot thwap-dev-enable-lsp) - (straight-use-package 'eglot) - (require 'eglot)) - -(provide 'thwap-eglot) diff --git a/lib/thwap-go.el b/lib/thwap-go.el deleted file mode 100644 index 095ca08..0000000 --- a/lib/thwap-go.el +++ /dev/null @@ -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) diff --git a/lib/thwap-icons.el b/lib/thwap-icons.el deleted file mode 100644 index 4dd6a63..0000000 --- a/lib/thwap-icons.el +++ /dev/null @@ -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) diff --git a/lib/thwap-lsp.el b/lib/thwap-lsp.el deleted file mode 100644 index 778fd62..0000000 --- a/lib/thwap-lsp.el +++ /dev/null @@ -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) diff --git a/lib/thwap-magit.el b/lib/thwap-magit.el deleted file mode 100644 index 409c59d..0000000 --- a/lib/thwap-magit.el +++ /dev/null @@ -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) diff --git a/lib/thwap-projectile.el b/lib/thwap-projectile.el deleted file mode 100644 index 988759f..0000000 --- a/lib/thwap-projectile.el +++ /dev/null @@ -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) diff --git a/lib/thwap-py.el b/lib/thwap-py.el deleted file mode 100644 index 7477c72..0000000 --- a/lib/thwap-py.el +++ /dev/null @@ -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) diff --git a/lib/thwap-tf.el b/lib/thwap-tf.el deleted file mode 100644 index c63b589..0000000 --- a/lib/thwap-tf.el +++ /dev/null @@ -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) diff --git a/lib/thwap-theme.el b/lib/thwap-theme.el deleted file mode 100644 index 318b8d9..0000000 --- a/lib/thwap-theme.el +++ /dev/null @@ -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) diff --git a/lib/thwap-yaml.el b/lib/thwap-yaml.el deleted file mode 100644 index 7fbdc2d..0000000 --- a/lib/thwap-yaml.el +++ /dev/null @@ -1,6 +0,0 @@ -(when thwap-dev-enable-yaml - (use-package yaml-mode - :ensure t - :straight t)) - -(provide 'thwap-yaml) diff --git a/lib/thwap-yas.el b/lib/thwap-yas.el deleted file mode 100644 index 0637e12..0000000 --- a/lib/thwap-yas.el +++ /dev/null @@ -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) diff --git a/thwap/thwap-completion.el b/thwap/thwap-completion.el new file mode 100644 index 0000000..fc021a3 --- /dev/null +++ b/thwap/thwap-completion.el @@ -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) + diff --git a/thwap/thwap-configuration.el b/thwap/thwap-configuration.el new file mode 100644 index 0000000..63d0d6b --- /dev/null +++ b/thwap/thwap-configuration.el @@ -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) diff --git a/lib/thwap-dash.el b/thwap/thwap-dashboard.el similarity index 57% rename from lib/thwap-dash.el rename to thwap/thwap-dashboard.el index 9ea130b..bc668d9 100644 --- a/lib/thwap-dash.el +++ b/thwap/thwap-dashboard.el @@ -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 diff --git a/lib/thwap-defaults.el b/thwap/thwap-defaults.el similarity index 83% rename from lib/thwap-defaults.el rename to thwap/thwap-defaults.el index 9f52f0c..c678976 100644 --- a/lib/thwap-defaults.el +++ b/thwap/thwap-defaults.el @@ -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 diff --git a/thwap/thwap-development.el b/thwap/thwap-development.el new file mode 100644 index 0000000..8457dba --- /dev/null +++ b/thwap/thwap-development.el @@ -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 "") '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 diff --git a/lib/thwap-nerdtree.el b/thwap/thwap-file-browser.el similarity index 57% rename from lib/thwap-nerdtree.el rename to thwap/thwap-file-browser.el index 7b34349..8b1eae6 100644 --- a/lib/thwap-nerdtree.el +++ b/thwap/thwap-file-browser.el @@ -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) diff --git a/thwap/thwap-helpers.el b/thwap/thwap-helpers.el new file mode 100644 index 0000000..0f70dc8 --- /dev/null +++ b/thwap/thwap-helpers.el @@ -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 diff --git a/thwap/thwap-interface.el b/thwap/thwap-interface.el new file mode 100644 index 0000000..0c4365f --- /dev/null +++ b/thwap/thwap-interface.el @@ -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) diff --git a/lib/thwap-org.el b/thwap/thwap-orgmode.el similarity index 60% rename from lib/thwap-org.el rename to thwap/thwap-orgmode.el index c29e269..4916d73 100644 --- a/lib/thwap-org.el +++ b/thwap/thwap-orgmode.el @@ -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