Skip to content

feat: apply source.organizeImports and source.fixAll during lsp format#75

Merged
crispgm merged 2 commits into
crispgm:mainfrom
smlx:lsp-sync
Apr 1, 2026
Merged

feat: apply source.organizeImports and source.fixAll during lsp format#75
crispgm merged 2 commits into
crispgm:mainfrom
smlx:lsp-sync

Conversation

@smlx

@smlx smlx commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Using lsp for formatting wasn't tidying up imports.

This change adds the two additional formatting features to the lsp formatter:

  • source.organizeImports - goimports functionality
  • source.fixAll - very conservative code fixes

For details see the gopls docs here.

vim.lsp.buf.code_action() is currently asynchronous only so the apply_code_actions_sync() uses a small hack to get the code actions applied synchronously.

@crispgm

crispgm commented Mar 31, 2026

Copy link
Copy Markdown
Owner

Looks good though. The test looks broken (not because of this MR).

@crispgm

crispgm commented Mar 31, 2026

Copy link
Copy Markdown
Owner

I fixed the CI, please format with stylua. Thanks.

@smlx

smlx commented Mar 31, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the tip about stylua! The format should be fixed now.

@crispgm crispgm merged commit d06df0c into crispgm:main Apr 1, 2026
3 checks passed
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.

2 participants