-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-add rustic mode based on rustic-ts (Treesitter support)
This code is based on #480, but there are some changes based on my testing.
- Loading branch information
Showing
4 changed files
with
86 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
;;; rustic-rust-mode.el --- rust-mode related code -*-lexical-binding: t-*- | ||
;;; Commentary: | ||
|
||
;; Deprecated code related to rust-mode | ||
|
||
;;; Code: | ||
|
||
(setq rust-load-optional-libraries nil) | ||
(setq rust-before-save-hook #'rustic-before-save-hook) | ||
(setq rust-after-save-hook #'rustic-after-save-hook) | ||
(require 'rust-mode) | ||
|
||
;;; Define aliases for removed rustic functions | ||
|
||
(defvaralias 'rustic-indent-offset 'rust-indent-offset) | ||
(defvaralias 'rustic-indent-method-chain 'rust-indent-method-chain) | ||
(defvaralias 'rustic-indent-where-clause 'rust-indent-where-clause) | ||
(defvaralias 'rustic-match-angle-brackets 'rust-match-angle-brackets) | ||
(defvaralias 'rustic-indent-return-type-to-arguments 'rust-indent-return-type-to-arguments) | ||
(defalias 'rustic-indent-line #'rust-mode-indent-line) | ||
(defalias 'rustic-end-of-defun #'rust-end-of-defun) | ||
|
||
;;;###autoload | ||
(define-derived-mode rustic-mode rust-mode "Rustic" | ||
"Major mode for Rust code. | ||
\\{rustic-mode-map}" | ||
:group 'rustic | ||
|
||
(when (bound-and-true-p rustic-cargo-auto-add-missing-dependencies) | ||
(add-hook 'lsp-after-diagnostics-hook 'rustic-cargo-add-missing-dependencies-hook nil t))) | ||
|
||
(provide 'rustic-rust-mode) | ||
;;; rustic-rust-mode.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
;;; rustic-ts-mode.el --- use native rust-ts-mode -*-lexical-binding: t-*- | ||
;;; Commentary: | ||
|
||
;; Derive from rust-ts-mode instead of rust-mode | ||
|
||
;;; Code: | ||
|
||
;;; For the save hooks this is required | ||
(require 'rustic-rustfmt) | ||
|
||
|
||
;;;###autoload | ||
(define-derived-mode rustic-mode rust-ts-mode "Rustic (TS)" | ||
"Major mode for Rust code. | ||
\\{rustic-mode-map}" | ||
:group 'rustic | ||
|
||
(when (bound-and-true-p rustic-cargo-auto-add-missing-dependencies) | ||
(add-hook 'lsp-after-diagnostics-hook 'rustic-cargo-add-missing-dependencies-hook nil t)) | ||
(add-hook 'before-save-hook 'rustic-before-save-hook nil t) | ||
(add-hook 'after-save-hook 'rustic-after-save-hook nil t)) | ||
|
||
(provide 'rustic-ts-mode) | ||
;;; rustic-ts-mode.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters