Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions core/core-packages.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,15 @@
use-package-always-demand nil
use-package-expand-minimally t)

(defvar core-modules '(smartparens idle-highlight-mode find-file-in-project smex scpaste helm flycheck undo-tree dired-hacks-utils flycheck eshell-prompt-extras fuzzy deferred auto-async-byte-compile markdown-mode async))

(defvar package-refreshed-this-session nil)

(defun maybe-refresh-package-contents (package)
"Refresh package contents if PACKAGE is not installed and if contents have not been refreshed this session."
(unless (or package-refreshed-this-session (package-installed-p package))
(package-refresh-contents)
(setq package-refreshed-this-session t)))


(defun require-package (package)
"Ensure PACKAGE is installed."
"Ensure PACKAGE is installed, with error handling."
(unless (package-installed-p package)
(maybe-refresh-package-contents package)
(condition-case err
(eval `(use-package ,package
:ensure t))
(progn
(package-refresh-contents)
(package-install package))
(error (message "Failed to install %s: %S" package err)))))
Comment on lines 29 to 36

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a comment to explain what the condition-case block is doing, specifically what errors it is catching and why. This will improve the readability of the code.

    (condition-case err
        (progn
          (package-refresh-contents)
          (package-install package))
      (error (message "Failed to install %s: %S" package err))) ; Handle errors during package installation



(defun module-list-install (modules-list)
"Install missing modules from MODULES-LIST."
(dolist (module modules-list)
(require-package module)))

(module-list-install core-modules)

(defun add-subfolders-to-load-path (parent-dir)
"Add subfolders of PARENT-DIR to load path."
(let ((default-directory parent-dir))
Expand Down
10 changes: 0 additions & 10 deletions early-init.el
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@


(global-display-line-numbers-mode 1)
(require 'linum)
(global-linum-mode 0)
(global-linum-mode -1)

;; BUG
(setq outline-minor-mode-prefix "\C-c \C-o")

;; Optimizations for faster startup
(setq file-name-handler-alist-original file-name-handler-alist)
Expand All @@ -46,9 +40,6 @@
(push '(vertical-scroll-bars) default-frame-alist)


(setq package-enable-at-startup nil)


(defconst main-savefile-dir (expand-file-name "savefile" user-emacs-directory))
;; Ensure savefile directory exists
(unless (file-exists-p main-savefile-dir)
Expand All @@ -61,7 +52,6 @@
(require 'core-packages)
(require 'core-feel)
(require 'core-util)
(require 'core-native-comp)
(require 'core-look)

(package-initialize)
68 changes: 1 addition & 67 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,71 +5,11 @@
(add-to-list 'load-path packages-dir)

;; Load core and package configurations
;; (require 'pkg-elpaca)
(require 'pkg-ido)
(require 'pkg-corfu2)
(require 'pkg-org)
(require 'pkg-discover)
(require 'pkg-git)
;; (require 'pkg-company)
(require 'pkg-flycheck)
(require 'pkg-ssh)
(require 'pkg-docker)
(require 'pkg-feel)
(require 'pkg-lsp)
(require 'pkg-latex)
(require 'pkg-yaml)
(require 'pkg-php)
(require 'pkg-projectile)
(require 'pkg-bash)
(require 'pkg-search)
(require 'pkg-eshell)
(require 'pkg-rust)
(require 'pkg-emms)
(require 'pkg-web)
(require 'pkg-systemd)
(require 'pkg-multipleCursor)
(require 'pkg-mouvement)
;; (require 'pkg-dhall)
;; (require 'pkg-terraform-lsp)
;; (require 'pkg-go)
(require 'pkg-irc)
;; (require 'pkg-straight)
(require 'pkg-loader)


(require 'pkg-flutter)
(require 'pkg-terraform)
;; (require 'pkg-corfu)

;; (require 'pkg-combobulate)
(add-to-list 'custom-theme-load-path theme-dir)
;; (require 'pkg-theme)
(load-theme 'my-solarized-dark t)


;; (use-package 'gptel)

;; Llama.cpp offers an OpenAI compatible API
;; (gptel-make-openai "llama-cpp" ;Any name
;; :stream t ;Stream responses
;; :protocol "http"
;; :host "localhost:8000" ;Llama.cpp server location
;; :models '("test")) ;Any names, doesn't matter for Llama

;; ;; Execute the following only if emacs is compiled with treesit
;; (when (featurep 'treesit)
;; (use-package combobulate
;; :ensure t))


;; Execute the following only if emacs is compiled with treesit
;; (if (featurep 'treesit)
;; (require 'pkg-combobulate))

;; (native-compile-async "/home/michael/.emacs.d" 'recursively)

;; Remove .elc files on save

(use-package emacs
:config
(winner-mode 1)
Expand All @@ -82,9 +22,3 @@
(delete-file (concat buffer-file-name "c"))))
nil t)))
(add-to-list 'auto-mode-alist '("\\.log\\'" . auto-revert-mode)))

(use-package no-littering
:ensure t
:config
(setq auto-save-file-name-transforms
`((".*" ,(no-littering-expand-var-file-name "auto-save/") t))))
63 changes: 35 additions & 28 deletions packages/pkg-bash.el
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
;; Bash settings
;;; pkg-bash.el --- Bash completion -*- lexical-binding: t -*-

(require-package 'bash-completion)
;;; Commentary:
;; This package configures bash completion.

;;; Code:

;; Function to turn off indent-tabs-mode
(defun turn-off-indent-tabs-mode ()
"Turn off the use of tabs for indentation."
(setq indent-tabs-mode nil)
(setq tab-width 8))
(require-package 'bash-completion)
(use-package bash-completion
:defer t
:config
;; Function to turn off indent-tabs-mode.
(defun turn-off-indent-tabs-mode ()
"Turn off the use of tabs for indentation."
(setq indent-tabs-mode nil)
(setq tab-width 8))

;; Add hook for shell script mode
(add-hook 'sh-mode-hook 'turn-off-indent-tabs-mode)
;; Add hook for shell script mode.
(add-hook 'sh-mode-hook 'turn-off-indent-tabs-mode)

;; Function to generate auto-complete candidates for bash
(defun ac-bash-candidates ()
"Generate a list of potential completions for the current bash command.
;; Function to generate auto-complete candidates for bash.
(defun ac-bash-candidates ()
"Generate a list of potential completions for the current bash command.
This function is a modified version of `bash-completion-dynamic-complete'
from bash-completion.el."
(when bash-completion-enabled
(let* ((start (comint-line-beginning-position))
(pos (point))
(tokens (bash-completion-tokenize start pos))
(open-quote (bash-completion-tokenize-open-quote tokens))
(parsed (bash-completion-process-tokens tokens pos))
(line (cdr (assq 'line parsed)))
(point (cdr (assq 'point parsed)))
(cword (cdr (assq 'cword parsed)))
(words (cdr (assq 'words parsed)))
(stub (nth cword words))
(completions (bash-completion-comm line point words cword open-quote))
;; Override configuration for comint-dynamic-simple-complete.
;; Bash adds a space suffix automatically.
(comint-completion-addsuffix nil))
completions)))
(when bash-completion-enabled
(let* ((start (comint-line-beginning-position))
(pos (point))
(tokens (bash-completion-tokenize start pos))
(open-quote (bash-completion-tokenize-open-quote tokens))
(parsed (bash-completion-process-tokens tokens pos))
(line (cdr (assq 'line parsed)))
(point (cdr (assq 'point parsed)))
(cword (cdr (assq 'cword parsed)))
(words (cdr (assq 'words parsed)))
(stub (nth cword words))
(completions (bash-completion-comm line point words cword open-quote))
;; Override configuration for comint-dynamic-simple-complete.
;; Bash adds a space suffix automatically.
(comint-completion-addsuffix nil))
completions))))
Comment on lines +9 to +41

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The use-package macro should be used to configure bash-completion and define the turn-off-indent-tabs-mode and ac-bash-candidates functions within its :config block. This ensures that these functions are only defined when bash-completion is loaded, improving modularity and lazy loading.

(use-package bash-completion
  :defer t
  :config
    ;; Function to turn off indent-tabs-mode.
    (defun turn-off-indent-tabs-mode ()
      "Turn off the use of tabs for indentation."
      (setq indent-tabs-mode nil)
      (setq tab-width 8))

    ;; Add hook for shell script mode.
    (add-hook 'sh-mode-hook 'turn-off-indent-tabs-mode)

    ;; Function to generate auto-complete candidates for bash.
    (defun ac-bash-candidates ()
      "Generate a list of potential completions for the current bash command.
 This function is a modified version of `bash-completion-dynamic-complete'
 from bash-completion.el."
      (when bash-completion-enabled
        (let* ((start (comint-line-beginning-position))
               (pos (point))
               (tokens (bash-completion-tokenize start pos))
               (open-quote (bash-completion-tokenize-open-quote tokens))
               (parsed (bash-completion-process-tokens tokens pos))
               (line (cdr (assq 'line parsed)))
               (point (cdr (assq 'point parsed)))
               (cword (cdr (assq 'cword parsed)))
               (words (cdr (assq 'words parsed)))
               (stub (nth cword words))
               (completions (bash-completion-comm line point words cword open-quote))
               ;; Override configuration for comint-dynamic-simple-complete.
               ;; Bash adds a space suffix automatically.
               (comint-completion-addsuffix nil))
          completions))))


(provide 'pkg-bash)
Loading