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

提供选中区域格式化的功能 #916

Closed
zijianyue opened this issue Apr 23, 2024 · 9 comments
Closed

提供选中区域格式化的功能 #916

zijianyue opened this issue Apr 23, 2024 · 9 comments

Comments

@zijianyue
Copy link

能否提供一个支持选中区域格式化的功能,目前只找到lsp-bridge-code-format,会对整个文件格式化,局部格式化一是更快,二是有时候不想改动其他位置的格式,以免代码差异过多,不便查看修改记录

@manateelazycat
Copy link
Owner

我看了看 LSP 的协议 https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#formattingOptions

目前 LSP 协议还不支持指定区域格式化, 因为格式化的调整有可能会调整换行的情况, 目前也没法通过对比LSP Server返回的信息, 在Elisp端精确控制格式化区域。

@manateelazycat
Copy link
Owner

Range Format 协议已经支持

977d344

请更新测试, 有任何问题欢迎反馈。

@zijianyue
Copy link
Author

我用的后端是clangd 18.1,选中区域执行 lsp-bridge-code-format,报错
[LSP-Bridge] Current server not support range format

@manateelazycat
Copy link
Owner

那就是clangd lsp server不支持局部格式化这个功能

@zijianyue
Copy link
Author

zijianyue commented Apr 26, 2024

通过lsp-mode的诊断来看clangd应该是有这个功能的
image

@manateelazycat
Copy link
Owner

lsp-mode可以支持区域格式化,能否帮忙确认下? 谢谢

manateelazycat added a commit that referenced this issue Apr 27, 2024
…eFormattingProvider/rangesSupport, some LSP server's range format depend on documentRangeFormattingProvider.
@manateelazycat
Copy link
Owner

我推送了 dd70010

这是补丁解决不同LSP Server range format返回格式不一致的问题, pyright/ruff 返回的是 documentRangeFormattingProvider/rangesSupport, clangd 返回的是 documentRangeFormattingProvider

@zijianyue
Copy link
Author

太好了,现在正常工作了

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

No branches or pull requests

2 participants