dev: merge from master

This commit is contained in:
Matt Nish-Lapidus 2024-08-11 16:20:19 -04:00
commit 237251f442
19 changed files with 114 additions and 60 deletions

View file

@ -219,7 +219,7 @@ in."
file (/ size 1024 1024.0))
(explain! "Consider deleting it from your system (manually)"))))
(unless (ignore-errors (executable-find doom-projectile-fd-binary))
(unless (ignore-errors (executable-find doom-fd-executable))
(warn! "Couldn't find the `fd' binary; project file searches will be slightly slower"))
(require 'projectile)

View file

@ -12,19 +12,36 @@ Emacs.")
(defvar doom-projectile-cache-purge-non-projects nil
"If non-nil, non-projects are purged from the cache on `kill-emacs-hook'.")
(defvar doom-projectile-fd-binary
(cl-find-if #'executable-find (list "fdfind" "fd"))
"The filename of the `fd' executable. On some distros it's 'fdfind' (ubuntu,
debian, and derivatives). On most it's 'fd'.")
(define-obsolete-variable-alias 'doom-projectile-fd-binary 'doom-fd-executable "v3.0.0")
(defvar doom-fd-executable (cl-find-if #'executable-find (list "fdfind" "fd"))
"The filename of the fd executable.
(defvar doom-projects--fd-version nil)
On some distros it's fdfind (ubuntu, debian, and derivatives). On most it's fd.
Is nil if no executable is found in your PATH during startup.")
(defvar doom-ripgrep-executable (executable-find "rg")
"The filename of the Ripgrep executable.
Is nil if no executable is found in your PATH during startup.")
;;
;;; Packages
(after! project
(setq project-list-file (file-name-concat doom-data-dir "projects")))
(use-package! project
:defer t
:init
(setq project-list-file (file-name-concat doom-profile-state-dir "projects"))
:config
;; Not valid vc backends, but I use it to inform (global) file index
;; exclusions below and elsewhere.
(add-to-list 'project-vc-backend-markers-alist '(Jujutsu . ".jj"))
(add-to-list 'project-vc-backend-markers-alist '(Sapling . ".sl"))
(add-to-list 'project-vc-extra-root-markers ".jj")
;; TODO: Advice or add command for project-wide `find-sibling-file'.
)
;; DEPRECATED: Will be replaced with project.el
(use-package! projectile
@ -44,7 +61,8 @@ debian, and derivatives). On most it's 'fd'.")
projectile-kill-buffers-filter 'kill-only-files
projectile-known-projects-file (concat doom-cache-dir "projectile.projects")
projectile-ignored-projects '("~/")
projectile-ignored-project-function #'doom-project-ignored-p)
projectile-ignored-project-function #'doom-project-ignored-p
projectile-fd-executable doom-fd-executable)
(global-set-key [remap evil-jump-to-tag] #'projectile-find-tag)
(global-set-key [remap find-tag] #'projectile-find-tag)
@ -81,20 +99,16 @@ debian, and derivatives). On most it's 'fd'.")
;;
;; In the interest of performance, we reduce the number of project root marker
;; files/directories projectile searches for when resolving the project root.
(setq projectile-project-root-files-bottom-up
(append '(".projectile" ; projectile's root marker
".project" ; doom project marker
".git") ; Git VCS root dir
(when (executable-find "hg")
'(".hg")) ; Mercurial VCS root dir
(when (executable-find "bzr")
'(".bzr"))) ; Bazaar VCS root dir
;; This will be filled by other modules. We build this list manually so
;; projectile doesn't perform so many file checks every time it resolves
;; a project's root -- particularly when a file has no project.
projectile-project-root-files '()
;;
;; These will be filled by other modules. We build this list manually so
;; projectile doesn't perform so many file checks every time it resolves a
;; project's root -- particularly when a file has no project.
(setq projectile-project-root-files '()
projectile-project-root-files-top-down-recurring '("Makefile"))
;; Adds a more editor/plugin-agnostic project marker.
(add-to-list 'projectile-project-root-files-bottom-up ".project")
(push (abbreviate-file-name doom-local-dir) projectile-globally-ignored-directories)
;; Per-project compilation buffers
@ -104,8 +118,9 @@ debian, and derivatives). On most it's 'fd'.")
;; Support the more generic .project files as an alternative to .projectile
(defadvice! doom--projectile-dirconfig-file-a ()
:override #'projectile-dirconfig-file
(cond ((file-exists-p! (or ".projectile" ".project") (projectile-project-root)))
((expand-file-name ".project" (projectile-project-root)))))
(let ((proot (projectile-project-root)))
(cond ((file-exists-p! (or projectile-dirconfig-file ".project") proot))
((expand-file-name ".project" proot)))))
;; Disable commands that won't work, as is, and that Doom already provides a
;; better alternative for.
@ -150,13 +165,14 @@ c) are not valid projectile projects."
and do (remhash proot projectile-project-type-cache))
(projectile-serialize-cache))))
;; Some MSYS utilities auto expanded the `/' path separator, so we need to prevent it.
;; HACK: Some MSYS utilities auto expanded the `/' path separator, so we need
;; to prevent it.
(when doom--system-windows-p
(setenv "MSYS_NO_PATHCONV" "1") ; Fix path in Git Bash
(setenv "MSYS2_ARG_CONV_EXCL" "--path-separator")) ; Fix path in MSYS2
;; HACK Don't rely on VCS-specific commands to generate our file lists. That's
;; 7 commands to maintain, versus the more generic, reliable and
;; HACK: Don't rely on VCS-specific commands to generate our file lists.
;; That's 7 commands to maintain, versus the more generic, reliable, and
;; performant `fd' or `ripgrep'.
(defadvice! doom--only-use-generic-command-a (fn vcs)
"Only use `projectile-generic-command' for indexing project files.
@ -166,41 +182,59 @@ And if it's a function, evaluate it."
(not (file-remote-p default-directory)))
(funcall projectile-generic-command vcs)
(let ((projectile-git-submodule-command
(get 'projectile-git-submodule-command 'initial-value)))
(or projectile-git-submodule-command
(get 'projectile-git-submodule-command 'initial-value))))
(funcall fn vcs))))
;; `projectile-generic-command' doesn't typically support a function, but my
;; `doom--only-use-generic-command-a' advice allows this. I do it this way so
;; that projectile can adapt to remote systems (over TRAMP), rather then look
;; for fd/ripgrep on the remote system simply because it exists on the host.
;; It's faster too.
;; HACK: `projectile-generic-command' doesn't typically support a function,
;; but my `doom--only-use-generic-command-a' advice allows this. I do it
;; this way to make it easier for folks to undo the change (if not set to a
;; function, projectile will revert to default behavior).
(put 'projectile-git-submodule-command 'initial-value projectile-git-submodule-command)
(setq projectile-git-submodule-command nil
;; Include and follow symlinks in file listings.
projectile-git-fd-args (concat "-L -tl " projectile-git-fd-args " --ignore-file .project")
projectile-indexing-method 'hybrid
projectile-generic-command
(lambda (_)
;; If fd exists, use it for git and generic projects. fd is a rust
;; program that is significantly faster than git ls-files or find, and
;; it respects .gitignore. This is recommended in the projectile docs.
;; If fd or ripgrep exists, use it to produce file listings for
;; projectile commands. fd is a rust program that is significantly
;; faster than git ls-files, find, or the various VCS commands
;; projectile is configured to use. Plus, it respects .gitignore.
(cond
((when-let*
((bin (if (ignore-errors (file-remote-p default-directory nil t))
(cl-find-if (doom-rpartial #'executable-find t)
(list "fdfind" "fd"))
doom-projectile-fd-binary))
((doom-fd-executable)
(projectile-git-use-fd)
;; REVIEW Temporary fix for #6618. Improve me later.
(version (with-memoization doom-projects--fd-version
(cadr (split-string (cdr (doom-call-process bin "--version"))
(version (with-memoization (get 'doom-fd-executable 'version)
(cadr (split-string (cdr (doom-call-process doom-fd-executable "--version"))
" " t))))
((ignore-errors (version-to-list version))))
(concat (format "%s . -0 -H --color=never --type file --type symlink --follow --exclude .git %s"
bin (if (version< version "8.3.0")
"" "--strip-cwd-prefix"))
(if doom--system-windows-p " --path-separator=/"))))
(string-join
(delq
nil (list doom-fd-executable "."
(if (version< version "8.3.0")
(replace-regexp-in-string "--strip-cwd-prefix" "" projectile-git-fd-args t t)
projectile-git-fd-args)
(when project-vc-backend-markers-alist
(mapconcat (fn! (format "-E %s" (shell-quote-argument (cdr %))))
project-vc-backend-markers-alist
" "))
(if doom--system-windows-p " --path-separator=/" "")))
" ")))
;; Otherwise, resort to ripgrep, which is also faster than find
((executable-find "rg" t)
(concat "rg -0 --files --follow --color=never --hidden -g!.git"
(doom-ripgrep-executable
(string-join
(delq
nil (list doom-ripgrep-executable
"-0 --files --follow --color=never --hidden"
(when project-vc-backend-markers-alist
(mapconcat (fn! (format "-g!%s" (shell-quote-argument (cdr %))))
project-vc-backend-markers-alist
" "))
(if doom--system-windows-p " --path-separator=/")))
" "))
((not doom--system-windows-p) "find . -type f | cut -c3- | tr '\\n' '\\0'")
("find . -type f -print0"))))
(defadvice! doom--projectile-default-generic-command-a (fn &rest args)

View file

@ -286,7 +286,7 @@ workable results ripgrep produces, despite the error."
"Change `counsel-file-jump' to use fd or ripgrep, if they are available."
:override #'counsel--find-return-list
(cl-destructuring-bind (find-program . args)
(cond ((when-let (fd (executable-find (or doom-projectile-fd-binary "fd") t))
(cond ((when-let (fd (executable-find (or doom-fd-executable "fd") t))
(append (list fd "--hidden" "--type" "file" "--type" "symlink" "--follow" "--color=never")
(cl-loop for dir in projectile-globally-ignored-directories
collect "--exclude"

View file

@ -211,15 +211,15 @@ targets."
;;;###autoload
(defun +vertico/consult-fd-or-find (&optional dir initial)
"Runs consult-fd if fd version > 8.6.0 exists, consult-find otherwise.
See URL `https://github.com/minad/consult/issues/770'."
See minad/consult#770."
(interactive "P")
;; TODO this condition was adapted from a similar one in lisp/doom-projects.el, to be replaced with a more robust check post v3
(if (when-let*
((bin (if (ignore-errors (file-remote-p default-directory nil t))
(cl-find-if (doom-rpartial #'executable-find t)
(list "fdfind" "fd"))
doom-projectile-fd-binary))
(version (with-memoization doom-projects--fd-version
doom-fd-executable))
(version (with-memoization (get 'doom-fd-executable 'version)
(cadr (split-string (cdr (doom-call-process bin "--version"))
" " t))))
((ignore-errors (version-to-list version))))

View file

@ -210,7 +210,7 @@ orderless."
"C-x C-d" #'consult-dir
"C-x C-j" #'consult-dir-jump-file))
:config
;; DEPRECATED: Remove when Doom core replaces projectile with project.el
;; DEPRECATED: Remove when projectile is replaced with project.el
(setq consult-dir-project-list-function #'consult-dir-projectile-dirs)
(when (modulep! :tools docker)

View file

@ -211,7 +211,7 @@ we have to clean it up ourselves."
(use-package! fd-dired
:when doom-projectile-fd-binary
:when doom-fd-executable
:defer t
:init
(global-set-key [remap find-dired] #'fd-dired)

View file

@ -3,7 +3,7 @@
#+since: 21.12.0
* Description
These modules specialize in integration particular languages and their
These modules specialize in the integration of particular languages and their
ecosystems into (Doom) Emacs.
* Frequently asked questions

View file

@ -75,8 +75,7 @@ recommended.
+ clangd (must be v9 or newer) :: clangd is included with =llvm= which should be
available through your OS' package manager.
- Linux:
- Debian 11 & Ubuntu 20.10: ~$ apt-get install clangd-11~
- 20.04 LTS: [[https://pkgs.org/search/?q=clangd][clangd-10]]
- Debian & Ubuntu: ~$ apt-get install clangd~
- Fedora & CentOS/RHEL 8+: ~$ dnf install clang-tools-extra~
- openSUSE: ~$ zypper install clang~
- Arch: ~$ pacman -S clang~

View file

@ -303,6 +303,9 @@ If rtags or rdm aren't available, fail silently instead of throwing a breaking e
:defer t
:init
(defvar ccls-sem-highlight-method 'font-lock)
(after! project
(add-to-list 'project-vc-ignores "^\\.ccls-cache$"))
;; DEPRECATED: Remove when projectile is replaced with project.el
(after! projectile
(add-to-list 'projectile-globally-ignored-directories "^.ccls-cache$")
(add-to-list 'projectile-project-root-files-bottom-up ".ccls-root")

View file

@ -1,5 +1,6 @@
;;; lang/elixir/config.el -*- lexical-binding: t; -*-
;; DEPRECATED: Remove when projectile is replaced with project.el
(after! projectile
(add-to-list 'projectile-project-root-files "mix.exs"))

View file

@ -1,5 +1,9 @@
;;; lang/gdscript/config.el -*- lexical-binding: t; -*-
(after! project
(add-to-list 'project-vc-extra-root-markers "project.godot"))
;; DEPRECATED: Remove when projectile is replaced with project.el
(after! projectile
(add-to-list 'projectile-project-root-files "project.godot"))

View file

@ -1,5 +1,6 @@
;;; lang/haskell/config.el -*- lexical-binding: t; -*-
;; DEPRECATED: Remove when projectile is replaced with project.el
(after! projectile
(add-to-list 'projectile-project-root-files "stack.yaml"))

View file

@ -68,7 +68,9 @@ gfm-mode:
- ~$ pip install proselint~
- Or through your OS package manager
- MacOS: ~$ brew install proselint~
- Arch Linux: ~$ pacman -S proselint~
- Arch Linux: [[https://aur.archlinux.org/packages/proselint][proselint in AUR]]
- Debian & Ubuntu: ~$ apt-get install python3-proselint~
- Fedora: ~$ dnf install proselint~
- [[https://github.com/textlint/textlint][textlint]] (~$ npm install textlint~)
** Markdown compiler

View file

@ -187,7 +187,12 @@ brew install gnuplot
#+begin_src sh
pacman -S texlive-core texlive-bin texlive-science texlive-latexextra
pacman -S gnuplot
pacman -S jupyter # required by +jupyter
#+end_src
** Debian & Ubuntu
#+begin_src sh
apt-get install texlive dvipng
apt-get install gnuplot
#+end_src
** NixOS

View file

@ -12,6 +12,7 @@
(defvar +php-run-tests-in-docker nil
"Whether or not to run tests in a docker environment")
;; DEPRECATED: Remove when projectile is replaced with project.el
(after! projectile
(add-to-list 'projectile-project-root-files "composer.json"))

View file

@ -1,5 +1,6 @@
;;; lang/racket/config.el -*- lexical-binding: t; -*-
;; DEPRECATED: Remove when projectile is replaced with project.el
(after! projectile
(add-to-list 'projectile-project-root-files "info.rkt"))

View file

@ -1,5 +1,6 @@
;;; lang/ruby/config.el -*- lexical-binding: t; -*-
;; DEPRECATED: Remove when projectile is replaced with project.el
(after! projectile
(add-to-list 'projectile-project-root-files "Gemfile"))

View file

@ -1,5 +1,6 @@
;;; lang/rust/config.el -*- lexical-binding: t; -*-
;; DEPRECATED: Remove when projectile is replaced with project.el
(after! projectile
(add-to-list 'projectile-project-root-files "Cargo.toml"))

View file

@ -1,5 +1,6 @@
;;; lang/zig/config.el -*- lexical-binding: t; -*-
;; DEPRECATED: Remove when projectile is replaced with project.el
(after! projectile
(add-to-list 'projectile-project-root-files "build.zig"))