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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ lspbridge/*
projectile-bookmarks.eld
tramp
.mc-lists*
eln-cache
projects
18 changes: 15 additions & 3 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,18 @@

(package-initialize)

;; Ensure use-package is installed (required for Emacs 30+)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))

;; Configure use-package
(eval-when-compile
(require 'use-package))
(setq use-package-always-ensure t) ; Make :ensure t default

;; load config
(add-to-list 'load-path "~/.emacs.d/rc")
(add-to-list 'load-path (expand-file-name "rc" user-emacs-directory))
(require 'basic)
(require 'rc-basic)
(require 'rc-c)
Expand All @@ -38,5 +48,7 @@
(require 'rc-wc)
(require 'rc-python)

(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)
;; Set custom file and load it if it exists
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
(load custom-file t))
22 changes: 8 additions & 14 deletions rc/basic.el
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
; Linum and auto pair
(display-line-numbers-mode)
; Auto pair
(electric-pair-mode t)

(require 'use-package)
Expand All @@ -25,18 +24,14 @@
(add-hook 'prog-mode-hook #'whitespace-mode)
(electric-indent-mode -1)

;; autocomplete
;; auto complete
(use-package auto-complete
:ensure t)
(setq ac-ignore-case nil)
(add-hook 'emacs-lisp-mode-hook (lambda ()
(auto-complete-mode t)
(setq ac-sources (append ac-sources '(ac-source-functions)))))
;; Company for auto-completion (modern replacement for auto-complete)
(use-package company
:ensure t
:init (add-hook 'after-init-hook 'global-company-mode))
(ac-config-default)
:init
(add-hook 'after-init-hook 'global-company-mode)
:config
(setq company-idle-delay 0.5
company-minimum-prefix-length 2))


(set-language-environment "UTF-8")
Expand Down Expand Up @@ -80,8 +75,7 @@
:ensure t)
(xclip-mode 1)

;; trim space
(add-hook 'write-file-hooks 'delete-trailing-whitespace nil t)
;; trim space (already handled by before-save-hook above, but keep for compatibility)

;; rss
(use-package elfeed
Expand Down
4 changes: 2 additions & 2 deletions rc/rc-basic.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
'(fullscreen . maximized))

(when window-system
(set-frame-font (font-spec :family "Noto Sans Mono" :size 12))
(set-frame-font (font-spec :family "Noto Sans Mono" :size 18))
(dolist (script '(han cjk-misc bopomofo))
(set-fontset-font
(frame-parameter nil 'font)
script
(font-spec :name "Noto Sans CJK SC" :size 12))))
(font-spec :name "Noto Sans CJK SC" :size 18))))

(setq-default line-spacing 4)

Expand Down
27 changes: 26 additions & 1 deletion rc/rc-file-management.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
;;; rc-file-management.el ---
;;; rc-file-management.el --- File and project management

(require 'use-package)

;; Projectile - Project management (used by treemacs)
(use-package projectile
:ensure t
:config
(projectile-mode +1)
;; Use ripgrep if available (faster than default grep)
;; Projectile will automatically detect and use rg if installed
(when (executable-find "rg")
(setq projectile-grep-command "rg --color=never --files-with-matches"))
:bind
(:map global-map
("C-c p s" . projectile-grep) ; Search keyword in project
("C-c p f" . projectile-find-file) ; Find file in project
("C-c p r" . projectile-replace) ; Replace in project
("C-c p p" . projectile-switch-project) ; Switch project
("C-c p d" . projectile-find-dir))) ; Find directory in project

;; Treemacs - File tree explorer
(use-package treemacs
:ensure t
:defer t
Expand All @@ -10,10 +31,14 @@
("C-x t C-p" . treemacs-previous-project)
("C-x t C-f" . treemacs-create-file)))

;; Treemacs integration with projectile
(use-package treemacs-projectile
:after (treemacs projectile)
:ensure t)

;; Note: If ripgrep (rg) is installed, projectile will use it automatically
;; Install: brew install ripgrep (macOS) or apt-get install ripgrep (Linux)

(provide 'rc-file-management)
;;;

4 changes: 2 additions & 2 deletions rc/rc-lsp.el
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
(use-package lsp-mode
:ensure t
:init
;; Set the prefix key for LSP commands
(setq lsp-keymap-prefix "C-c l")
;; Set the prefix key for LSP commands (C-c L to avoid conflict with org-store-link)
(setq lsp-keymap-prefix "C-c L")
;; Performance optimizations
(setq lsp-idle-delay 0.5)
(setq lsp-log-io nil)
Expand Down
6 changes: 5 additions & 1 deletion rc/rc-org.el
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@
(let ((done (or (not org-state) ;; nil when no TODO list
(member org-state org-done-keywords)))
(file (buffer-file-name))
(agenda (funcall (ad-get-orig-definition 'org-agenda-files)) ))
;; Get original org-agenda-files without advice
(agenda (progn
(advice-remove 'org-agenda-files 'dynamic-agenda-files-advice)
(prog1 (org-agenda-files)
(advice-add 'org-agenda-files :filter-return #'dynamic-agenda-files-advice)))))
(unless (member file agenda)
(if done
(save-excursion
Expand Down
72 changes: 13 additions & 59 deletions rc/rc-python.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
;; C-c C-f - Toggle code folding at point
;; C-c C-s - Show all folded code
;; C-c C-h - Hide all foldable code
;; C-c p s - Search (grep) in project
;; Note: Project search is available globally (see rc-file-management.el):
;; C-c p s - Search keyword in project (uses ripgrep if available)
;; C-c p f - Find file in project
;; C-c p r - Replace in project
;; C-c s - Search with ripgrep (if installed)
;;
;; Dependencies to install:
;; 1. LSP server (choose one):
Expand All @@ -28,56 +28,29 @@
;; Python mode (built-in, no :ensure needed)
(use-package python
:mode (("\\.py\\'" . python-mode))
:init
;; Ensure global font-lock is enabled
(global-font-lock-mode 1)
:config
(setq python-indent-offset 4)
(setq python-indent-guess-indent-offset t)
;; Ensure font-lock is enabled for Python
(setq font-lock-maximum-decoration t)
;; Code navigation: M-. (forward) and M-, (backward)
;; xref is built-in and works with LSP
:custom
(python-indent-offset 4)
(python-indent-guess-indent-offset t)
:bind
(:map python-mode-map
("M-." . xref-find-definitions)
("M-," . xref-pop-marker-stack)
("C-c M-." . xref-find-references))
:hook
;; Ensure syntax highlighting is enabled
(python-mode . (lambda ()
;; Enable font-lock (syntax highlighting)
(font-lock-mode 1)
(jit-lock-mode 1)
;; Force fontification of the entire buffer
(font-lock-ensure)
;; Set font-lock level to maximum for better highlighting
(setq font-lock-maximum-decoration t)
;; Ensure syntax table is set
(syntax-ppss-flush-cache 0))))
("C-c M-." . xref-find-references)))

;; LSP for Python
;; Add Python hook to lsp-mode (configured in rc-lsp.el)
(use-package lsp-mode
:ensure t
:after (python rc-lsp)
:hook (python-mode . (lambda ()
;; Start LSP
(lsp-deferred)
;; Ensure xref uses LSP backend (lsp-mode should add this automatically,
;; but we ensure it's there)
(when (boundp 'xref-backend-functions)
(add-to-list 'xref-backend-functions 'lsp-xref-backend t))))
:config
:hook (python-mode . lsp-deferred)
:custom
;; Configure LSP server (pylsp is recommended)
;; Install: pip install python-lsp-server[all]
(setq lsp-pylsp-server-command '("pylsp"))
(lsp-pylsp-server-command '("pylsp"))
;; Alternative: pyright
;; Install: npm install -g pyright
;; (setq lsp-python-ms-executable "pyright-langserver")
;; (setq lsp-python-ms-extra-paths '())
;; Ensure xref backend is registered globally
(add-to-list 'xref-backend-functions 'lsp-xref-backend t)
;; (lsp-python-ms-executable "pyright-langserver")
;; (lsp-python-ms-extra-paths '())
)

;; Code folding using hideshow (built-in, no :ensure needed)
Expand Down Expand Up @@ -112,27 +85,8 @@
;; (setq flycheck-python-pylint-use-symbolic-id nil)
)

;; Project-wide search using projectile
;; Projectile is already referenced in rc-file-management.el
(use-package projectile
:ensure t
:after python
:config
(projectile-mode +1)
:bind
(:map python-mode-map
("C-c p s" . projectile-grep)
("C-c p f" . projectile-find-file)
("C-c p r" . projectile-replace)))

;; Alternative: ripgrep for faster search
;; Install: brew install ripgrep (macOS) or apt-get install ripgrep (Linux)
(use-package ripgrep
:ensure t
:after python
:bind
(:map python-mode-map
("C-c s" . ripgrep-regexp)))
;; Note: Project-wide search is configured globally in rc-file-management.el
;; Use C-c p s for projectile-grep or C-c s for ripgrep-regexp

;; Company for auto-completion (already installed, but configure for Python)
(use-package company
Expand Down