From 95e0b43012f39959ec291ab4448e127088285147 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 12 Aug 2024 19:46:40 -0400 Subject: [PATCH 1/5] fix: "Malformed pattern in custom ignore file .project" error I introduced '--ignore-file .project' to `projectile-git-fd-args` in 4fcf332 expecting fd to ignore the file if it didn't exist, but it throws an error if it doesn't, causing it to throw these errors in any project without a .project file. Amend: 4fcf33274915 --- lisp/doom-projects.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/doom-projects.el b/lisp/doom-projects.el index b59c40903..b3d608551 100644 --- a/lisp/doom-projects.el +++ b/lisp/doom-projects.el @@ -193,7 +193,7 @@ And if it's a function, evaluate it." (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-git-fd-args (concat "-L -tl " projectile-git-fd-args) projectile-indexing-method 'hybrid projectile-generic-command (lambda (_) From fa153d5b914d5480f384d62548cca9dbce22c2c7 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 13 Aug 2024 16:31:12 -0400 Subject: [PATCH 2/5] refactor(ocaml): use apheleia instead of ocamlformat.el The ocamlformat.el package reinvents what Apheleia is already doing, but Apheleia's default definition for ocamlformat is a little simplistic. This merges the efforts of both and allows us to cut down on an unneeded dependency. --- modules/lang/ocaml/config.el | 24 +++++++----------------- modules/lang/ocaml/packages.el | 5 ----- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/modules/lang/ocaml/config.el b/modules/lang/ocaml/config.el index 27a57ac21..de338bcdd 100644 --- a/modules/lang/ocaml/config.el +++ b/modules/lang/ocaml/config.el @@ -13,6 +13,13 @@ (after! tuareg + (set-formatter! 'ocamlformat + '("ocamlformat" "-" "--name" filepath "--enable-outside-detected-project" + (if (locate-dominating-file default-directory ".ocamlformat") + (pcase (apheleia-formatters-extension-p "eliom" "eliomi") + ("eliom" '("--impl")) + ("eliomi" '("--intf"))) + '("--profile=ocamlformat")))) ;; tuareg-mode has the prettify symbols itself (set-ligatures! 'tuareg-mode :alist (append tuareg-prettify-symbols-basic-alist @@ -101,23 +108,6 @@ (ocp-setup-indent)))) -(use-package! ocamlformat - :when (modulep! :editor format) - :commands ocamlformat - :hook (tuareg-mode-local-vars . +ocaml-init-ocamlformat-h) - :config - ;; TODO Fix region-based formatting support - (defun +ocaml-init-ocamlformat-h () - (setq-local +format-with 'ocp-indent) - (when (and (executable-find "ocamlformat") - (locate-dominating-file default-directory ".ocamlformat")) - (when buffer-file-name - (let ((ext (file-name-extension buffer-file-name t))) - (cond ((equal ext ".eliom") - (setq-local ocamlformat-file-kind 'implementation)) - ((equal ext ".eliomi") - (setq-local ocamlformat-file-kind 'interface))))) - (setq-local +format-with 'ocamlformat)))) (use-package! opam-switch-mode :hook (tuareg-mode-local-vars . +ocaml-init-opam-switch-h) diff --git a/modules/lang/ocaml/packages.el b/modules/lang/ocaml/packages.el index bf64fb7e4..6bb5a5a20 100644 --- a/modules/lang/ocaml/packages.el +++ b/modules/lang/ocaml/packages.el @@ -18,11 +18,6 @@ (when (modulep! :tools eval) (package! utop :pin "384b3098c8c4a2e26b87167053952b753aa8a63a")) -(when (modulep! :editor format) - (package! ocamlformat - :recipe (:host github :repo "ocaml-ppx/ocamlformat" :files ("emacs/*.el")) - :pin "c43f89bc0ebd536009151814214320bdf3988c50")) - (package! dune :recipe (:host github :repo "ocaml/dune" :files ("editor-integration/emacs/*.el")) :pin "aac3d84f1d5abdf276d72be3dccac23bf99b3c7c") From 8519f6fed249f12d177fdeda08255471683b9b00 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 13 Aug 2024 16:32:59 -0400 Subject: [PATCH 3/5] refactor(ocaml): entry points into ocp-indent & opam-switch-mode Reduces edge cases, in the case the user eagerly loads any of these packages. Also replaces all hardcoded paths to ocp-indent and opam's executables with variables, respecting user configuration. --- modules/lang/ocaml/config.el | 40 +++++++++++++++++++--------------- modules/lang/ocaml/packages.el | 10 ++++----- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/modules/lang/ocaml/config.el b/modules/lang/ocaml/config.el index de338bcdd..75beb8645 100644 --- a/modules/lang/ocaml/config.el +++ b/modules/lang/ocaml/config.el @@ -98,33 +98,39 @@ (use-package! ocp-indent - ;; must be careful to always defer this, it has autoloads that adds hooks - ;; which we do not want if the executable can't be found - :hook (tuareg-mode-local-vars . +ocaml-init-ocp-indent-h) + :hook (tuareg-mode-local-vars . ocp-setup-indent) + :hook (caml-mode-local-vars . ocp-indent-caml-mode-setup) + :init + (defadvice! +ocaml--init-ocp-indent-maybe-h (fn &rest args) + "Run `ocp-setup-indent' only if the ocp-indent binary is found." + :around #'ocp-setup-indent + (when (executable-find ocp-indent-path) + (apply fn args))) :config - (defun +ocaml-init-ocp-indent-h () - "Run `ocp-setup-indent', so long as the ocp-indent binary exists." - (when (executable-find "ocp-indent") - (ocp-setup-indent)))) - + ;; HACK: The package adds these hooks, but they're redundant (even + ;; counter-productive) with the hooks I add above. + (remove-hook 'tuareg-mode-hook #'ocp-setup-indent) + (remove-hook 'caml-mode-hook #'ocp-indent-caml-mode-setup)) (use-package! opam-switch-mode - :hook (tuareg-mode-local-vars . +ocaml-init-opam-switch-h) - :init - (map! :localleader + :hook (tuareg-mode-local-vars . opam-switch-mode) + :preface + (map! :after tuareg + :localleader :map tuareg-mode-map "w" #'opam-switch-set-switch) - - (defun +ocaml-init-opam-switch-h () + :init + (defadvice! +ocaml--init-opam-switch-mode-maybe-h (fn &rest args) "Activate `opam-switch-mode' if the opam executable exists." - (when (executable-find "opam") - (opam-switch-mode))) + :around #'opam-switch-mode + (when (executable-find opam-switch-program-name) + (apply fn args))) :config ;; Use opam to set environment (setq tuareg-opam-insinuate t) (opam-switch-set-switch (tuareg-opam-current-compiler))) -;; Tree sitter + (eval-when! (modulep! +tree-sitter) - (add-hook! 'tuareg-mode-local-vars-hook #'tree-sitter!)) + (add-hook 'tuareg-mode-local-vars-hook #'tree-sitter!)) diff --git a/modules/lang/ocaml/packages.el b/modules/lang/ocaml/packages.el index 6bb5a5a20..ef2711c2a 100644 --- a/modules/lang/ocaml/packages.el +++ b/modules/lang/ocaml/packages.el @@ -2,8 +2,11 @@ ;;; lang/ocaml/packages.el (package! tuareg :pin "1d53723e39f22ab4ab76d31f2b188a2879305092") - (package! opam-switch-mode :pin "1069e56a662f23ea09d4e05611bdedeb99257012") +(package! ocp-indent :pin "f38578c25d62701847b1bcb45099a9020e2032fe") +(package! dune + :recipe (:host github :repo "ocaml/dune" :files ("editor-integration/emacs/*.el")) + :pin "aac3d84f1d5abdf276d72be3dccac23bf99b3c7c") (unless (modulep! +lsp) (package! merlin :pin "b6ff2d4d569c23dd8fa91639d26fb984e9411862") @@ -13,11 +16,6 @@ (not (modulep! :checkers syntax +flymake))) (package! flycheck-ocaml :pin "77f8ddbd9bfc3a11957ac7ec7e45d5fa9179b192"))) -(package! ocp-indent :pin "f38578c25d62701847b1bcb45099a9020e2032fe") - (when (modulep! :tools eval) (package! utop :pin "384b3098c8c4a2e26b87167053952b753aa8a63a")) -(package! dune - :recipe (:host github :repo "ocaml/dune" :files ("editor-integration/emacs/*.el")) - :pin "aac3d84f1d5abdf276d72be3dccac23bf99b3c7c") From 29fcd474e201c5ce2e605fc9dcd08b2510234c48 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 13 Aug 2024 16:36:00 -0400 Subject: [PATCH 4/5] bump: :lang ocaml ocaml/dune@aac3d84f1d5a -> ocaml/dune@96ed5fb42f2c ocaml/merlin@b6ff2d4d569c -> ocaml/merlin@9fa77dbe81c8 --- modules/lang/ocaml/packages.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/lang/ocaml/packages.el b/modules/lang/ocaml/packages.el index ef2711c2a..289c23feb 100644 --- a/modules/lang/ocaml/packages.el +++ b/modules/lang/ocaml/packages.el @@ -6,12 +6,12 @@ (package! ocp-indent :pin "f38578c25d62701847b1bcb45099a9020e2032fe") (package! dune :recipe (:host github :repo "ocaml/dune" :files ("editor-integration/emacs/*.el")) - :pin "aac3d84f1d5abdf276d72be3dccac23bf99b3c7c") + :pin "96ed5fb42f2c534578cb77191887f8d5a7bf5529") (unless (modulep! +lsp) - (package! merlin :pin "b6ff2d4d569c23dd8fa91639d26fb984e9411862") + (package! merlin :pin "9fa77dbe81c893476646d873c5ac5106b94b7107") (package! merlin-eldoc :pin "bf8edc63d85b35e4def352fa7ce4ea39f43e1fd8") - (package! merlin-company :pin "b6ff2d4d569c23dd8fa91639d26fb984e9411862") + (package! merlin-company :pin "9fa77dbe81c893476646d873c5ac5106b94b7107") (when (and (modulep! :checkers syntax) (not (modulep! :checkers syntax +flymake))) (package! flycheck-ocaml :pin "77f8ddbd9bfc3a11957ac7ec7e45d5fa9179b192"))) From 84f7eb2affeae9bb5f85379dd8677f2c0a372c83 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 13 Aug 2024 16:36:28 -0400 Subject: [PATCH 5/5] feat(cc): set eglot client for cuda-mode to clangd Fix: #7993 --- modules/lang/cc/config.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/lang/cc/config.el b/modules/lang/cc/config.el index e69e28ec2..067973ddf 100644 --- a/modules/lang/cc/config.el +++ b/modules/lang/cc/config.el @@ -282,6 +282,8 @@ If rtags or rdm aren't available, fail silently instead of throwing a breaking e :desc "References (Write)" "w" #'+cc/ccls-show-references-write))) (when (modulep! :tools lsp +eglot) + (set-eglot-client! 'cuda-mode '("clangd")) + ;; Map eglot specific helper (map! :localleader :after cc-mode