Age | Commit message (Collapse) | Author |
|
|
|
* feat: add new format option: undojoin
This option allow user to automatically perform undojoin command before
formatting. This is useful if the user uses an autosave plugin + format
on save, because in case of undo, it will undo the last change AND the
formatting. Without this option, it will only undo the formatting.
* fix: passed linting
* fix: apply undojoin for LSP formatting
* doc: fix type annotations for apply_format
* doc: regenerate documentation
---------
Co-authored-by: Steven Arcangeli <stevearc@stevearc.com>
|
|
* doc: add LSP annotations for `lsp_format` options
* doc: regenerate documentation
---------
Co-authored-by: Steven Arcangeli <stevearc@stevearc.com>
|
|
The bug would present itself when there were formatters configured for a
filetype that were not available (not installed, or some other issue).
This would also happen if the filetype configured an empty list of
formatters.
The fix was to make sure that we fall back to LSP formatting _either_ if
the filetype had no formatters configured, _or_ if none of the
configured formatters are available.
|
|
|
|
|
|
|
|
* docs: extract conform.format(opts) into it's own class
* docs: extract conform.format_lines(opts) into it's own class
* refactor: use new nvim_doc_tools capability to remove duplicated class definition
---------
Co-authored-by: Steven Arcangeli <stevearc@stevearc.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
formatters (#273)
* feat: add dry_run option and pass return values for if buffer would be modified
* fix: implement dry_run for blocking calls to lsp formatter
* refactor: change `changed` variable to `did_edit`
* docs: Update README
* fix: address PR comments
* fix: small cleanups
---------
Co-authored-by: Steven Arcangeli <stevearc@stevearc.com>
|
|
file (#272)
solves: https://github.com/stevearc/conform.nvim/issues/271
|
|
|
|
|
|
|
|
This makes the behavior of formatexpr more consistent with
`vim.lsp.formatexpr`; do not run vim's builtin formatter.
Problem: When conform's formatexpr is used and (range or buffer) but
conform can't do formatting and there is no LSP formatter with the
formatting capabilities, it will fall back to the (wrong) built-in
formatting, which might result in simply concatenating all the words.
This is a breaking change, reverting the behavior introduced in #55.
|
|
This is a breaking API change, but there is a shim in place that will keep existing functions working, just with a warning notification. Most people should not encounter this at all. For anyone overriding a formatter config value with a function that takes `(ctx)` as the parameter, it will need to be updated to take `(self, ctx)`.
|
|
|
|
|
|
|
|
This breaking change should make it significantly easier to modify formatters. While I expect 99% of configs to be backwards-compatible, this can still potentially cause problems. If you:
* define a formatter in the `formatters` option
* that has the same name as a built-in formatter
* and omits a property from the original formatter (e.g. leaves out `range_args` or `cwd`)
Then you may encounter breaking behavior from this commit, because now your config definition will be merged with the built-in definition, and so will inherit those omitted properties. This config merging behavior can be opted-out of by adding `inherit = false` to your formatter config.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This fixes one the main issue with a BufWritePost format autocmd:
that if the user does `:wq` vim will exit before the formatting changes
are applied. Now we will block in VimLeavePre until the formatter
completes (or a timeout is reached).
|
|
|
|
|
|
|
|
|
|
When lsp_fallback = true AND the only formatters for the buffer are from
the "*" or "_" filetype, format with LSP instead of the "*"/"_"
formatters.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Alternations are now supported. You can specify a sub-list in place of a
formatter name and conform will use the first formatter in that list
that is available. For example, this will use either prettierd or
prettier (whichever is available), and then always trim whitespace
afterwards:
conform.format(formatters = { { "prettierd", "prettier" }, "trim_whitespace" })
This syntax is available both in the formatters_by_ft config option and
in the `formatters` argument of the `format` method.
|
|
run_all_formatters is now the default. To only run the first formatter
(the previous behavior), see the next commit
|