<commit_before>;;; lang/rust/config.el -*- lexical-binding: t; -*-

(use-package! rust-mode
  :defer t
  :config
  (setq rust-indent-method-chain t)

  ;; This is necessary because both plugins are fighting for supremacy in
  ;; `auto-mode-alist', so rustic-mode *must* load second. It only needs to
  ;; happen once.
  ;;
  ;; rust-mode is still required for `racer'.
  (add-hook! 'rust-mode-hook
    (defun +rust-init-h ()
      "Switch to `rustic-mode', if it's available."
      (when (require 'rustic nil t)
        (rustic-mode))))

  (set-docsets! '(rust-mode rustic-mode) "Rust")
  (when (featurep! +lsp)
    (add-hook 'rust-mode-local-vars-hook #'lsp!))

  ;; TODO PR these upstream
  (after! dtrt-indent
    (pushnew! dtrt-indent-hook-mapping-list
              '(rust-mode default rust-indent-offset)
              '(rustic-mode default rustic-indent-offset)))
  (when (featurep! :tools editorconfig)
    (after! editorconfig
      (pushnew! editorconfig-indentation-alist
                '(rust-mode rust-indent-offset)
                '(rustic-mode rustic-indent-offset)))))


(use-package! racer
  :unless (featurep! +lsp)
  :hook ((rust-mode rustic-mode) . racer-mode)
  :config
  (set-lookup-handlers! 'rust-mode
    :definition '(racer-find-definition :async t)
    :documentation '+rust-racer-lookup-documentation))


(use-package! rustic
  :when EMACS26+<commit_msg>lang/rust: remove redundant editorconfig-indentation-alist entry<commit_after>;;; lang/rust/config.el -*- lexical-binding: t; -*-

(use-package! rust-mode
  :defer t
  :config
  (setq rust-indent-method-chain t)

  ;; This is necessary because both plugins are fighting for supremacy in
  ;; `auto-mode-alist', so rustic-mode *must* load second. It only needs to
  ;; happen once.
  ;;
  ;; rust-mode is still required for `racer'.
  (add-hook! 'rust-mode-hook
    (defun +rust-init-h ()
      "Switch to `rustic-mode', if it's available."
      (when (require 'rustic nil t)
        (rustic-mode))))

  (set-docsets! '(rust-mode rustic-mode) "Rust")
  (when (featurep! +lsp)
    (add-hook 'rust-mode-local-vars-hook #'lsp!))

  ;; TODO PR these upstream
  (after! dtrt-indent
    (pushnew! dtrt-indent-hook-mapping-list
              '(rust-mode default rust-indent-offset)
              '(rustic-mode default rustic-indent-offset)))
  (when (featurep! :tools editorconfig)
    (after! editorconfig
      (pushnew! editorconfig-indentation-alist
                '(rustic-mode rustic-indent-offset)))))


(use-package! racer
  :unless (featurep! +lsp)
  :hook ((rust-mode rustic-mode) . racer-mode)
  :config
  (set-lookup-handlers! 'rust-mode
    :definition '(racer-find-definition :async t)
    :documentation '+rust-racer-lookup-documentation))


(use-package! rustic
  :when EMACS26+
{'fraction_non_alphanumeric': 0.14857554994590697, 'fraction_numerical': 0.00144248106743599, 'mean_word_length': 3.0496350364963503, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2238356', 'n_tokens_mistral': 991, 'n_tokens_neox': 936, 'n_words': 231}