Editing the same file in a split causes vim to jump to the top of the file when saving with autoformatter

This page summarizes the projects mentioned and recommended in the original post on /r/neovim

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • config

    Personal Config - Consume at your own risk. (by CKolkey)

  • My bet would be that the LSP is returning the entire buffer via formatting. I've got a thing that takes the returned buffer, diffs it to the current state, and constructs linewise edits for LSP to use. You can check that here: https://github.com/CKolkey/config/blob/master/nvim/lua/plugins/lsp/formatting.lua

  • formatter.nvim

  • This might have something to do with extmarks being clobbered when the new text is written. For example, here is a GitHub issue describing the problem: https://github.com/mhartington/formatter.nvim/issues/22 This is for formatter.nvim, but this would likely apply to any process that rewrites the whole buffer.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • efm-langserver

    General purpose Language Server

  • As far as I know, the only solution (other than getting formatting directly from a LSP server) is to use EFM (https://github.com/mattn/efm-langserver), which implements the tricky logic of figuring out how to only update the changed text.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts