Skip to content

Add conform.nvim for format-on-save, prefer LSP where available#27

Open
jfornoff wants to merge 1 commit into
masterfrom
claude/add-conform
Open

Add conform.nvim for format-on-save, prefer LSP where available#27
jfornoff wants to merge 1 commit into
masterfrom
claude/add-conform

Conversation

@jfornoff
Copy link
Copy Markdown
Owner

Summary

  • Adds conform.nvim in a new plugins/formatting.lua file
  • Removes the hand-rolled BufWritePre autocmd from LspAttach in completion.lua
  • lsp_format = "prefer": LSP formatting runs when the attached server supports it; conform formatters are fallback only
  • Fallback formatters configured: stylua (Lua), shfmt (shell) — for filetypes where no LSP formatter is attached
  • 500ms timeout on format-on-save to avoid hangs on slow servers
  • Multi-client filtering TODO moved to default_format_opts where it's now actionable

Test plan

  • Save a Rust file — rust-analyzer formats it (LSP path)
  • Save a Lua file — lua_ls formats it (LSP path); if lua_ls formatting is disabled, stylua runs instead
  • Save a shell script — shfmt formats it (no LSP formatter for bash by default)
  • Verify no duplicate formatting occurs

https://claude.ai/code/session_015qGfcBj6cGkPtgdCESj83g


Generated by Claude Code

Replaces the hand-rolled BufWritePre autocmd in LspAttach with conform.nvim,
which provides a cleaner format-on-save with proper timeout handling. LSP
formatting takes precedence via lsp_format = "prefer"; the formatters_by_ft
table covers filetypes where no LSP formatter is attached (stylua for Lua,
shfmt for shell). The multi-client filtering concern is documented where it
is now actionable — in conform's default_format_opts.

https://claude.ai/code/session_015qGfcBj6cGkPtgdCESj83g
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