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

fix: move indent level to rust-common #538

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Dev380
Copy link
Contributor

@Dev380 Dev380 commented Apr 13, 2024

Emacs complains that rust-indent-offset
isn't set and a few minor modes (e.g.
formatting, smartparens) stop working.
This moves that variable to the common
file so the treesitter mode has the
variable set.

I'm not sure why more of the rust-prog-mode variables aren't in the rust-common file so I left them there. But, this was the only variable that was causing breakage for me. There is a rust-ts-mode-indent-offset variable too (which is also 4 by default) - should rust-mode override that variable with this one, override the rust-mode variable with the tree sitter one when the tree sitter mode is on, or keep them independent?

Emacs complains that `rust-indent-offset`
isn't set and a few minor modes (e.g.
formatting, smartparens) stop working.
This moves that variable to the common
file so the treesitter mode has the
variable set.
@@ -16,5 +16,11 @@
:type 'function
:group 'rust-mode)

(defcustom rust-indent-offset 4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of moving it here, do you think a defvaralias should be instead created. Something similar to this: https://github.com/psibi/rustic/blob/4dac7f34c30d91e3ecb2602fff7e81b6efdc75d7/rustic.el#L52

@Dushistov
Copy link

Dushistov commented Jan 16, 2025

Also lsp-mode for some reason complains about "void-variable rust-indent-offset":

Debugger entered--Lisp error: (void-variable rust-indent-offset)
  lsp--on-type-formatting("." ["=" "<" ">" "{" "(" "|"])
  #f(compiled-function () #<bytecode 0x199033851ccb>)()
  self-insert-command(1 46)
  funcall-interactively(self-insert-command 1 46)
  command-execute(self-insert-command)

lsp-mode has such code:

    (rust-mode                  . rust-indent-offset)               ; Rust
    (rust-ts-mode               . rust-ts-mode-indent-offset)

but for some reason it try to access rust-indent-offset instead of rust-ts-mode-indent-offset.

@psibi
Copy link
Member

psibi commented Jan 16, 2025

@Dushistov Does this PR fix that for you ?

@Dushistov
Copy link

@Dushistov Does this PR fix that for you ?

It fixes, but for reason introduce new bug: lsp-mode for files except lib.rs stop detects that it belong to project.

So for file.rs lsp-mode not activated and I have to run M-x lsp-mode for all files except lib.rs.

@psibi
Copy link
Member

psibi commented Jan 16, 2025

It fixes, but for reason introduce new bug: lsp-mode for files except lib.rs stop detects that it belong to project.

That strange and looks to be a different bug since lsp-mode detection is not done in rust-mode AFAIK.

If you can address this comment: #538 (comment) I think we can merge a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants