diff options
author | admin <contact@optics-design.com> | 2025-06-16 00:10:41 +0200 |
---|---|---|
committer | admin <contact@optics-design.com> | 2025-06-16 00:10:41 +0200 |
commit | 7f1416d7c6774e10b529ec3604b5d67fbd7c583f (patch) | |
tree | 9defd05491b37505d92e29d1cfd8f21d125f96f2 /.emacs.d/init.el |
Diffstat (limited to '.emacs.d/init.el')
-rw-r--r-- | .emacs.d/init.el | 322 |
1 files changed, 322 insertions, 0 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el new file mode 100644 index 0000000..2f3f4a4 --- /dev/null +++ b/.emacs.d/init.el @@ -0,0 +1,322 @@ +(setq org-dir "~/syncthing/notes/Org") +;; Disable native compilation +(setq org-export-with-drawers t) + +(setq make-backup-files nil) + +(setq default-directory (file-name-as-directory org-dir)) +(add-to-list 'default-frame-alist '(fullscreen . maximized)) +(defun generate-new-file-name () "Ask for a title and generate a file name based on it" + (let* ((file-name (read-string "Title: ")) + (my-path (concat + org-dir ; Or whatever path you want + (format-time-string "%Y%m%d%H%M%S") "-" + (replace-regexp-in-string "[^a-zA-Z0-9-]+" "-" file-name) ".org"))) ; Replace invalid path characters + (setq mc/org-capture-filename file-name) ; Save variable to be used later in the template + my-path)) + + +(setq inhibit-startup-message t) +(scroll-bar-mode -1) +(tool-bar-mode -1) +(tooltip-mode -1) +(set-fringe-mode 10) + + +(menu-bar-mode -1) +(setq visible-bell t) + +(if (daemonp) + (add-hook 'after-make-frame-functions + (lambda (frame) + (with-selected-frame frame + (set-face-attribute 'default nil :font "Hack NF" :height 220)))) + (set-face-attribute 'default nil :font "Hack NF" :height 220)) + + + +;; Make ESC quit prompts +(global-set-key (kbd "<escape>") 'keyboard-escape-quit) + +;; Initialize package sources +(require 'package) + +(setq package-archives '(("melpa" . "https://melpa.org/packages/") + ("org" . "https://orgmode.org/elpa/") + ("elpa" . "https://elpa.gnu.org/packages/"))) + +(package-initialize) +(unless package-archive-contents + (package-refresh-contents)) + +;; Initialize use-package on non-Linux platforms +(unless (package-installed-p 'use-package) + (package-install 'use-package)) + +(require 'use-package) +(setq use-package-always-ensure t) + +;;; Enable all 3 for relative number mode +;; (column-number-mode) +;; (global-display-line-numbers-mode t) +;; (setq display-line-numbers-type 'relative) + +;; Disable line numbers for some modes +(dolist (mode '(term-mode-hook + eshell-mode-hook)) + (add-hook mode (lambda () (display-line-numbers-mode 0)))) + +;; (use-package command-log-mode) +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; 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. + '(org-agenda-files nil) + '(package-selected-packages + '(counsel doom-modeline doom-themes evil evil-collection evil-escape + evil-org general helpful htmlize ivy ivy-rich + org-contacts org-download org-roam projectile + rainbow-delimiters which-key))) +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; 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. + ) + +(use-package ivy + :diminish + :bind (("C-s" . swiper) + :map ivy-minibuffer-map + ("TAB" . ivy-alt-done) + ("C-l" . ivy-alt-done) + ("C-j" . ivy-next-line) + ("C-k" . ivy-previous-line) + :map ivy-switch-buffer-map + ("C-k" . ivy-previous-line) + ("C-l" . ivy-done) + ("C-d" . ivy-switch-buffer-kill) + :map ivy-reverse-i-search-map + ("C-k" . ivy-previous-line) + ("C-d" . ivy-reverse-i-search-kill)) + :demand + :config + (ivy-mode 1)) + + +(use-package doom-modeline + :ensure t + :init (doom-modeline-mode 1) + :custom ((doom-modeline-height 15))) +(use-package rainbow-delimiters + :hook (prog-mode . rainbow-delimiters-mode)) + +(use-package doom-themes) +:init (load-theme 'doom-dracula t) + +(use-package which-key + :init (which-key-mode) + :diminish which-key-mode + :config + (setq which-key-idle-delay 1)) + +(use-package ivy-rich + :init + (ivy-rich-mode 1)) + +(use-package counsel + :bind (("M-x" . counsel-M-x) + ("C-x b" . counsel-ibuffer) + ("C-x C-f" . counsel-find-file) + :map minibuffer-local-map + ("C-r" . 'counsel-minibuffer-history)) + :config + (setq ivy-initial-inputs-alist nil)) ;;Don't start searches with ^ + +(use-package helpful + :ensure t + :custom + (counsel-describe-function-function #'helpful-callable) + (counsel-describe-variable-function #'helpful-variable) + :bind + ([remap describe-function] . counsel-describe-function) + ([remap describe-command] . helpful-command) + ([remap describe-variable] . counsel-describe-variable) + ([remap describe-key] . helpful-key)) +(global-set-key (kbd "C-q") 'save-buffers-kill-terminal) +(use-package general) +(general-create-definer my-leader-def + ;; :prefix my-leader + :prefix "SPC") +(my-leader-def + :states 'normal + :keymaps 'override + ;; bind "SPC a" + "oa" 'org-agenda + "oc" 'org-capture + ;; "ot" 'org-todo + ;; "ox" 'org-toggle-checkbox + "og" 'counsel-org-tag + "osg" 'org-tags-view + ;; "op" 'org-set-property + "oid" 'org-id-get-create + "os" 'org-display-inline-images + "oh" 'org-remove-inline-images + "e" 'ido-find-file + "w" 'save-buffer + "b" 'ido-switch-buffer + "gg" 'counsel-rg + "q" 'quit-window + "Q" 'kill-buffer-and-window + "z" 'org-toggle-link-display + "ff" 'projectile-find-file-in-known-projects) +;; "q" 'kill-this-buffer) +;; Enable Evil +(use-package evil + :init + (setq evil-want-integration t) + (setq evil-want-keybinding nil) + (setq evil-want-C-u-scroll t) + (setq evil-want-C-i-jump nil) + :config + (define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state) + (define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join) + (define-key evil-motion-state-map (kbd "C-h h") 'evil-window-left) + (define-key evil-motion-state-map (kbd "C-a l") 'evil-window-right) + (define-key evil-motion-state-map (kbd "C-a j") 'evil-window-down) + (define-key evil-motion-state-map (kbd "C-a k") 'evil-window-up) + (evil-mode 1)) +;; Add this to your Evil configuration section, after (evil-mode 1) + +;; Configure cursor shapes for different Evil states +(setq evil-normal-state-cursor '(box "orange")) +(setq evil-insert-state-cursor '(bar "red")) +(setq evil-visual-state-cursor '(hollow "purple")) +(setq evil-replace-state-cursor '(hbar "green")) +(setq evil-operator-state-cursor '(hbar "yellow")) + +;; For terminal emacs, ensure cursor type changes are sent to terminal +(unless (display-graphic-p) + ;; Define cursor change function + (defun my/change-cursor-shape (shape) + (send-string-to-terminal (format "\033[%d q" shape))) + + ;; Enable cursor shape changes in terminal + (add-hook 'evil-insert-state-entry-hook (lambda () (my/change-cursor-shape 6))) ; Bar + (add-hook 'evil-normal-state-entry-hook (lambda () (my/change-cursor-shape 2))) ; Block + (add-hook 'evil-visual-state-entry-hook (lambda () (my/change-cursor-shape 2))) ; Block + (add-hook 'evil-replace-state-entry-hook (lambda () (my/change-cursor-shape 4))) ; Underline + (add-hook 'evil-operator-state-entry-hook (lambda () (my/change-cursor-shape 4))) ; Underline + + ;; Reset cursor on exit + (add-hook 'kill-emacs-hook (lambda () (my/change-cursor-shape 2)))) +(use-package evil-collection + :after evil + :config + (evil-collection-init)) + +(use-package evil-escape + :config + (evil-escape-mode 1)) +(setq-default evil-escape-key-sequence "jk") + +(defun mm/org-mode-setup() + (org-indent-mode) + (variable-pitch-mode 1) + (auto-fill-mode 0) + (visual-line-mode 1) + (global-visual-line-mode 1) + (setq evil-auto-indent nil) + ) +(evil-define-key 'normal 'global (kbd "g j") 'evil-next-visual-line) +(evil-define-key 'normal 'global (kbd "g k") 'evil-previous-visual-line) +(evil-define-key 'normal org-mode-map (kbd "g j") 'evil-next-visual-line) +(evil-define-key 'normal org-mode-map (kbd "g k") 'evil-previous-visual-line) + +(use-package org + :hook (org-mode . mm/org-mode-setup) + :config + ;; Load org configuration from separate file + (add-to-list 'load-path org-dir) ;; Adjust path as needed + (require 'org-config)) +(use-package org-download) + +(setq org-file-apps '((t . "gio open %s"))) ;;For Windows, to open files with an external program +(add-hook 'dired-mode-hook 'org-download-enable) + +;; (setq org-startup-with-inline-images t) +(use-package htmlize) +(use-package org-roam + :ensure t + :custom + (org-roam-directory (org-dir)) + :bind (("C-c n l" . org-roam-buffer-toggle) + ("C-c n f" . org-roam-node-find) + ("C-c n g" . org-roam-graph) + ("C-c n i" . org-roam-node-insert) + ("C-c n c" . org-roam-capture) + ;; Dailies + ("C-c n j" . org-roam-dailies-capture-today)) + :config + ;; If you're using a vertical completion framework, you might want a more informative completion interface + (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))) + (org-roam-db-autosync-mode) + ;; If using org-roam-protocol + (require 'org-roam-protocol)) +(require 'org-id) +(setq org-id-link-to-org-use-id t) +;; (setq org-roam-dailies-capture-templates +;; '(("d" "default" entry +;; "* Section 1\n** Section 1.1\n* Section 2\n" +;; :target (file+head "%<%Y-%m-%d>.org" +;; "#+title: %<%Y-%m-%d>\n")) +;; ("n" "default" entry +;; "* Section 1\n** Section 1.1\n* Section 2\n" +;; :target (file+head "%<%Y-%m-%d>.org" +;; "#+title: %<%Y-%m-%d>\n")) +;; )) + +(setq org-agenda-start-on-weekday 1) +(setq calendar-date-style 'iso) +(setq calendar-week-start-day 1) +(setq org-read-date-force-compatible-dates nil) + +(use-package projectile) +(projectile-mode +1) +(setq projectile-known-projects (list org-dir)) +;; Recommended keymap prefix on Windows/Linux +(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map) + +(global-set-key (kbd "C-c l") 'org-store-link) +(global-set-key (kbd "C-c C-l") 'org-insert-link) + +;; Disable the annoying mini buffer when inserting a link +(add-to-list + 'display-buffer-alist + `("*Org Links*" display-buffer-no-window (allow-no-window . t))) + + +;; (setq org-time-stamp-formats '("%Y-%m-%d %a %H:%M")) +(setq org-clock-persist 'history) +(org-clock-persistence-insinuate) +(defun my/timenow () + (interactive) + (let ((current-prefix-arg '(16))) + (call-interactively 'org-time-stamp-inactive))) + +(define-key org-mode-map (kbd "C-c m") 'my/timenow) + +;; Add a direct shortcut for file links with autocomplete + (defun my/org-insert-file-link () + "Insert a file link directly, with path autocomplete and description prompt." + (interactive) + (let* ((org-link-file-path-type 'relative) + (file-path (org-link-complete-file)) + ;; Remove file: prefix if it's already there + (path (substring file-path 5)) + (desc (read-string "Description: " nil nil nil t))) + (org-insert-link nil (concat "file:" path) (if (string= desc "") nil desc)))) + + ;; Bind it to C-c C-f + (define-key org-mode-map (kbd "C-c C-f") 'my/org-insert-file-link) |