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

Issues related with Rust Format #9

Closed
ocfox opened this issue Jan 12, 2022 · 5 comments · Fixed by #10
Closed

Issues related with Rust Format #9

ocfox opened this issue Jan 12, 2022 · 5 comments · Fixed by #10
Labels
bug Something isn't working

Comments

@ocfox
Copy link
Contributor

ocfox commented Jan 12, 2022

Hi,before v3.13.0. I can use :RustFmt format code. Now if i use :RustFmt it just print origin code in console. I try to add vim.g.rustfmt_autosave=1 in lua but not effected. I don't know it may be rust.vim plugin moved or other reasons. So how to use rustfmt now.

@Avimitin
Copy link
Owner

I'm still trying to figure it out. It says that the neovim has built-in rustfmt function. But I fail to use that command too. You can import the rust.vim plugins back for now. I will update document after I find the correct usage.

@Avimitin Avimitin added the bug Something isn't working label Jan 12, 2022
@Avimitin
Copy link
Owner

@Avimitin
Copy link
Owner

Avimitin commented Jan 13, 2022

So the current workaround is to use the built-in LSP format function: vim.lsp.buf.formatting. It is set to space-m in lua/utils.lua#L146.

This may be the best workaround since it will call different formatter based on the filetype. It is now working on Rust, Golang. I will manage to integrate it with lua format.

I will replace it with gf in the future release. This is because I've set most the lsp keymap to start with key g.

Besides, you can map this key to vim.lsp.buf.formatting_sync(nil, 5000) to avoid format timeout. 5000 stands for 5000 ms.

@Avimitin
Copy link
Owner

@ocfox
Copy link
Contributor Author

ocfox commented Jan 13, 2022

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants