Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Formatting resets some content of a file #351

Open
dominicmeyer opened this issue Nov 26, 2023 · 0 comments
Open

Bug: Formatting resets some content of a file #351

dominicmeyer opened this issue Nov 26, 2023 · 0 comments

Comments

@dominicmeyer
Copy link

Problem

On some files, neovim seems to get 'stuck' on some values and when doing vim.lsp.buf.format({ async = false }) the changes get undone.

The above is an example from my current vue project. The content after using the command is the previous content of those fields. Right now I observed it happening with volar, but I'm not sure, if this is caused by volar or Lsp-Zero.

When doing the command this happens:

<template>
	<div class="d-flex align-center justify-center pa-4">
		<v-btn :disabled="page === 1" icon="mdi-arrow-left" density="comfortable" variant="tonal" rounded
-			@click="emit('prevPage')"></v-btn>
+                       @click="prevPage"></v-btn>

		<div class="mx-2 text-caption">
			Page {{ page }} of {{ pageCount }}
		</div>

		<v-btn :disabled="page >= pageCount" icon="mdi-arrow-right" density="comfortable" variant="tonal" rounded
-			@click="emit('nextPage')"></v-btn>
+                       @click="nextPage"></v-btn>
	</div>
</template>

<script setup lang="ts">
import { defineProps } from 'vue';

defineEmits(["nextPage", "prevPage"])

defineProps({
  page: {
	  type: Number,
		required: true
	},
  pageCount: {
	  type: Number,
		required: true
	},
  nextPage: {
		type: Function,
		required: true
	},
  prevPage: {
		type: Function,
		required: true
	}
})
</script>

Steps to reproduce

Still unknown, seems the happening random.

Expected behavior

Refactoring not changing the codes content like this

Neovim version

0.9.2

Lsp-Zero config (Lazy.nvim)

return {
	{
		'williamboman/mason.nvim',
		version = "1.8.3"
	},
	{
		'williamboman/mason-lspconfig.nvim',
		version = "v1.22.0"
	},
	{
		'VonHeikemen/lsp-zero.nvim',
		branch = 'v3.x'
	},
	{
		'neovim/nvim-lspconfig',
		commit = "29939f6f07bc0f3b9fc563fbfbee06ac88c8c439"
	},
	{
		'hrsh7th/cmp-nvim-lsp',
		commit = "44b16d11215dce86f253ce0c30949813c0a90765"
	},
	{
		'hrsh7th/nvim-cmp',
		version = "v0.0.1"
	},
	{
		'L3MON4D3/LuaSnip',
		version = "v2.1.0"
	}
}
local lsp_zero = require('lsp-zero')
lsp_zero.extend_lspconfig()

lsp_zero.on_attach(function(client, bufnr)
	-- see :help lsp-zero-keybindings
	-- to learn the available actions
	lsp_zero.default_keymaps({ buffer = bufnr })
end)

require('mason').setup({})
require('mason-lspconfig').setup({
	ensure_installed = { "dockerls", "bashls", "volar", "yamlls", "jsonls", "pylsp",
		"marksman", "rust_analyzer", "tsserver", "emmet_ls", "html", "lua_ls" },
	handlers = {
		lsp_zero.default_setup,
	},
})

Operating system/version

macOS 14.1.1

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

No branches or pull requests

1 participant