Compare commits

..
2 Commits
Author SHA1 Message Date
Riyyi 3e43420f56 Add consult package 2021-03-13 01:44:10 +01:00
Riyyi 801040ffe5 Switch to projectile-project-root as project root find function 2021-03-13 01:22:42 +01:00
+32 -20
View File
@@ -68,6 +68,7 @@
- [[#lsp-functions][LSP Functions]] - [[#lsp-functions][LSP Functions]]
- [[#neotree-functions][Neotree Functions]] - [[#neotree-functions][Neotree Functions]]
- [[#org-functions][Org Functions]] - [[#org-functions][Org Functions]]
- [[#projectile-functions][Projectile Functions]]
- [[#selectrum-functions][Selectrum Functions]] - [[#selectrum-functions][Selectrum Functions]]
- [[#which-key-functions][Which-Key Functions]] - [[#which-key-functions][Which-Key Functions]]
- [[#advice-and-aliases][Advice and Aliases]] - [[#advice-and-aliases][Advice and Aliases]]
@@ -231,8 +232,14 @@ Install and configure packages.
(use-package marginalia (use-package marginalia
:after selectrum :after selectrum
:config :config
(marginalia-mode) (setq marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light))
(setq marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light))) (marginalia-mode))
(use-package consult
:after selectrum
:config
(autoload 'projectile-project-root "projectile")
(setq consult-project-root-function #'projectile-project-root))
(use-package avy (use-package avy
:defer t) :defer t)
@@ -1117,21 +1124,6 @@ Functions that only use built-in Emacs functionality.
(split-window-right) (split-window-right)
(other-window 1)) (other-window 1))
(defun find-project-root ()
"Return root of the project, determined by `.git/', `default-directory' otherwise."
(let ((search-directory (locate-dominating-file "." ".git")))
(if search-directory
search-directory
default-directory))
)
(defun find-file-in-project-root ()
"Find file in project root."
(interactive)
(let ((default-directory (find-project-root)))
(call-interactively 'find-file)))
;; https://emacsredux.com/blog/2013/05/04/rename-file-and-buffer/ ;; https://emacsredux.com/blog/2013/05/04/rename-file-and-buffer/
(defun rename-file-and-buffer () (defun rename-file-and-buffer ()
"Rename the current buffer and file it is visiting." "Rename the current buffer and file it is visiting."
@@ -1317,7 +1309,7 @@ Vim equivalence: >gv"
(defun neotree-toggle-in-project-root () (defun neotree-toggle-in-project-root ()
"Toggle Neotree in project root." "Toggle Neotree in project root."
(interactive) (interactive)
(let ((default-directory (find-project-root))) (let ((default-directory (projectile-project-root)))
(call-interactively #'neotree-toggle))) (call-interactively #'neotree-toggle)))
#+END_SRC #+END_SRC
@@ -1340,6 +1332,23 @@ If point is on:
))) )))
#+END_SRC #+END_SRC
*** Projectile Functions
#+BEGIN_SRC emacs-lisp
(defun find-file-in-project-root ()
"Find file in project root."
(interactive)
(let ((default-directory (projectile-project-root)))
(call-interactively 'find-file)))
(defun compile-latex ()
"Compile LaTeX project."
(interactive)
(let ((default-directory (projectile-project-root)))
(projectile-save-project-buffers)
(shell-command "make")))
#+END_SRC
*** Selectrum Functions *** Selectrum Functions
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
@@ -1783,9 +1792,12 @@ General.el ~leader key binds.
;; Search ;; Search
"s" '(:ignore t :which-key "search") "s" '(:ignore t :which-key "search")
"s a" '(avy-goto-char-timer :which-key "Avy goto char") "s a" '(avy-goto-char-timer :which-key "Avy goto char")
"s b" '(bookmark-jump :which-key "Jump to bookmark") "s b" '(consult-line :which-key "Search buffer")
"s f" '(consult-find :which-key "Search file")
"s l" '(avy-goto-line :which-key "Avy goto line") "s l" '(avy-goto-line :which-key "Avy goto line")
"s s" '(evil-ex-nohighlight :which-key "Stop search") "s m" '(bookmark-jump :which-key "Jump to bookmark")
"s p" '(consult-grep :which-key "Search project")
"s q" '(evil-ex-nohighlight :which-key "Stop search")
;; Tabs / toggle ;; Tabs / toggle
"t" '(:ignore t :which-key "tabs/toggle") "t" '(:ignore t :which-key "tabs/toggle")