Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "provide alternative rustic mode that derives from rust-ts-mode" #481

Merged
merged 1 commit into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ jobs:
os: [ubuntu-latest]
emacs-version:
- 27.2
- 28.2
# - snapshot

- 28.1
steps:
- uses: actions/checkout@v2

Expand Down
24 changes: 0 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
- [Installation](#installation)
- [package](#package)
- [straight](#straight)
- [treesitter](#treesitter)
- [remote](#remote)
- [Compilation](#compilation)
- [Navigating errors](#navigating-errors)
Expand Down Expand Up @@ -137,29 +136,6 @@ additional [installation
instructions](https://github.crookster.org/switching-to-straight.el-from-emacs-26-builtin-package.el/)
for moving your package management from package.el to straight.

## treesitter

You can try the new native treesitter mode `rust-ts-mode` with:

```elisp
(use-package rustic
:init
(setq rustic-treesitter-derive t))
```

In case you want to use treesitter but can't use emacs master, you can
take a look at
[tree-sitter](https://github.com/emacs-tree-sitter/elisp-tree-sitter). When
the dependencies are installed you can activate the feature with:

```elisp
(use-package tree-sitter
:config
(require 'tree-sitter-langs)
(global-tree-sitter-mode)
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode))
```

## remote

rustfmt and most of the common cargo commands should work remotely.
Expand Down
34 changes: 0 additions & 34 deletions rustic-rust-mode.el

This file was deleted.

22 changes: 0 additions & 22 deletions rustic-ts-mode.el

This file was deleted.

39 changes: 29 additions & 10 deletions rustic.el
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,28 @@

(require 'dash)

(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)

;;; Customization

(defgroup rustic nil
"Support for Rust code."
:link '(url-link "https://www.rustic-lang.org/")
:group 'languages)

;;; 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)

;;; Workspace

(defvar-local rustic--buffer-workspace nil
Expand Down Expand Up @@ -96,13 +111,6 @@ this variable."
:type 'function
:group 'rustic)

(defcustom rustic-treesitter-derive nil
"Whether rustic should derive from the new treesitter mode `rust-ts-mode'
instead of `rust-mode'. This option requires emacs29+."
:version "29.1"
:type 'boolean
:group 'rustic)

;;; Mode

(defvar rustic-mode-map
Expand Down Expand Up @@ -137,13 +145,24 @@ instead of `rust-mode'. This option requires emacs29+."
map)
"Keymap for `rustic-mode'.")

(if (and (version<= "29.1" emacs-version) rustic-treesitter-derive)
(require 'rustic-ts-mode)
(require 'rustic-rust-mode))
;;;###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)))

;;;###autoload
(add-to-list 'auto-mode-alist '("\\.rs\\'" . rustic-mode))

;; remove rust-mode from `auto-mode-alist'
(let ((mode '("\\.rs\\'" . rust-mode)))
(when (member mode auto-mode-alist)
(setq auto-mode-alist (remove mode auto-mode-alist))))

;;; _

(defun rustic-reload ()
Expand Down