Skip to content

Commit

Permalink
✨ (init.el) Add consult sources
Browse files Browse the repository at this point in the history
✨ (init.el) Add vertico-directory

✨ (init.el) Update puni config

✨ (init.el) Add keymaps on evil-mode

✨ (init.el) Update consult settings and add cape

✨ (init.el) Add projectile settings

✨ (init.el) Add nyan-mode

✨ (init.el) Add yasnippets, yasnippets soruce and yasnippet template

✨ (init.el) Add settings for diary

✨ (init.el) Add plugins direx and request

✨ (init.el) Add comments

✨ (init.el) Add config to shutting out ring-bell
  • Loading branch information
Comamoca committed Dec 3, 2024
1 parent 1a902a1 commit 78cb417
Showing 1 changed file with 103 additions and 4 deletions.
107 changes: 103 additions & 4 deletions emacs.d/init.el
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

;; <leaf-install-code>
(eval-and-compile
(customize-set-variable
Expand Down Expand Up @@ -37,6 +38,8 @@
:init
(vertico-mode))

(leaf vertico-directory :ensure t)

;; Fuzzy match for vertico
(leaf orderless
:ensure t
Expand All @@ -46,6 +49,14 @@

;; Sources for vertico
(leaf consult :ensure t)
(leaf consult-dir :ensure t)
(leaf embark-consult :ensure t
:bind
((minibuffer-mode-map
:package emacs
("M-." . embark-dwin)
("C-." . embark-act))))

(leaf consult-ghq :ensure t
:url "https://github.com/tomoya/consult-ghq"
:config
Expand All @@ -58,16 +69,31 @@
;; (define-key evil-insert-state-map "jk" #'evil-normal-state)
;; (define-key evil-normal-state-map (kbd "S-j") nil)
;; (define-key evil-normal-state-map (kbd "S-j") #'evil-scroll-down)

(define-key evil-normal-state-map (kbd "C-k") #'evil-scroll-up)
(define-key evil-normal-state-map (kbd "C-j") #'evil-scroll-down)

(define-key evil-normal-state-map (kbd "M-g") #'projectile-switch-project)
(define-key evil-normal-state-map (kbd "C-l") #'consult-line)
(define-key evil-normal-state-map (kbd "SPC k") #'avy-goto-line)

(define-key evil-normal-state-map (kbd "C-i") #'consult-buffer)
(define-key evil-normal-state-map (kbd "C-.") #'embark-act)

(define-key evil-normal-state-map (kbd "C-p") #'puni-slurp-forward)
(define-key evil-normal-state-map (kbd "C-n") #'puni-barf-forward)

;; (define-key evil-normal-state-map (kbd "C-j") #'evil-scroll-down)
:init
(evil-mode 1))

;; key-chord library for evil's
(leaf key-chord :ensure t)

;; For edit
(leaf paredit :ensure t
(leaf puni :ensure t
:init
(paredit-mode))
(puni-global-mode))

(leaf highlight-indent-guides :ensure t)

Expand Down Expand Up @@ -199,11 +225,22 @@

;; Completion
(leaf corfu :ensure t
:custom
(setq corfu-auto-prefix 1)
:config
(setq corfu-auto t)
:init
(global-corfu-mode))

;; Completin soruce
(leaf cape :ensure t)

;; with icon
(leaf kind-icon :ensure t
:custom (kind-icon-default-face 'corfu-default)
:config
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))

;; Hydra
(leaf hydra :ensure t)
(leaf major-mode-hydra :ensure t)
Expand All @@ -214,10 +251,69 @@
;; Gleam support
(leaf gleam-ts-mode :ensure t)

;; ======================= My Configuration =======================
;; Projectile
(leaf projectile :ensure t
:init
(when (executable-find "ghq")
(setq projectile-known-projects
(mapcar
(lambda (x) (abbreviate-file-name x))
(split-string (shell-command-to-string "ghq list --full-path"))))))

;; Nyan-mode
(leaf nyan-mode :ensure t
:init
(nyan-start-animation))

;; Snippets
(leaf yasnippet :ensure t
:config
(setq yas-snippet-dirs '("~/emacs.d/snippets/"))
(yas-global-mode 1))

;; Snippet collections
(leaf yasnippet-snippets :ensure t)

;; Templates
(leaf yatemplate :ensure t
:cofig)

;; For diary
(defun latest-diary ()
"Open latest diary. This function call in `src/blog/` directory at blog repository."
(interactive)
(let* ((date (format-time-string "%Y-%m-%d"))
(file-name (format "%s-diary.md" date))
(path (concat (file-name-as-directory "./src/blog/") file-name)))
(find-file file-name)))

(defun consult-diary ()
(interactive)
(let* ((blog-repo "/home/coma/.ghq/github.com/Comamoca/blog/src/blog")
(diary (consult--read (sort-by-date (cl-remove-if-not (lambda (str) (string-match-p "-diary.md" str))
(directory-files blog-repo))))))
(find-file (expand-file-name diary blog-repo))))

(defun extract-date (path)
(if (string-match "\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\)" path)
(match-string 1 path)))

(defun sort-by-date (diaries)
(sort diaries (lambda (a b)
(let ((date-a (extract-date a))
(date-b (extract-date b)))
(string< date-a date-b)))))

;; Filer
(leaf direx :ensure t)

;; HTTP Request
(leaf request :ensure t)

;; ================ My extentions ================

(defun gitmoji-completion ()
"Completion source for gitmoji"
(let ((bounds (bounds-of-thing-at-point 'word)))
(when bounds
(let* ((gitmoji-file-path "~/.emacs.d/gitmoji.json")
Expand All @@ -236,17 +332,20 @@
gitmoji-codes
:exclusive 'no)))))


;; Enable at git-commit-mode
(add-hook 'git-commit-mode-hook (lambda ()
(setq-local completion-at-point-functions #'gitmoji-completion)))

;; ================ My configuratons ================

(electric-pair-mode 1)

(hl-line-mode)

(setq vc-follow-symlinks t)

(setq ring-bell-function 'ignore)

;; Disable menu bar and tool bar
(menu-bar-mode -1)
(tool-bar-mode 0)
Expand Down

0 comments on commit 78cb417

Please sign in to comment.