lsp-sourcekit icon indicating copy to clipboard operation
lsp-sourcekit copied to clipboard

Indentation problem

Open dabrahams opened this issue 7 months ago • 0 comments

If I attempt to indent-region in code whose syntax I've broken (say, by deleting a necessary closing brace), it fails like this:

lsp-request: Running swift-format failed
<unknown>: warning: Running swift-format without input paths is deprecated and will be removed in the future.

Please update your invocation to do either of the following:

- Pass ‘-‘ to read from stdin (e.g., ‘cat MyFile.swift | swift-format -‘).
- Pass one or more paths to Swift source files or directories containing
  Swift source files. When passing directories, make sure to include the
  ‘--recursive‘ flag.

For more information, use the ‘--help‘ option.
/Users/dave/src/hylo/<stdin>:3815:2: error: expected ’}’ to end struct

If I set lsp-enable-indentation to nil and reopen the buffer, it works using swift-mode's indentation, which is more resilient. If sourcekit-lsp could make indentation fall back to using the mode when swift-format fails, that would be awesome.

Since swift-format doesn't seem capable of ignoring errors, and indentation seems(?) to be provided directly by SourceKit through some kind of textDocument/rangeFormatting request, this might be considered a SourceKit bug. Please advise.

dabrahams avatar May 13 '25 22:05 dabrahams