go.nvim icon indicating copy to clipboard operation
go.nvim copied to clipboard

autoformat on save deletes stuff (with LunarVim)

Open YuqiaoS opened this issue 1 year ago • 3 comments

LunarVim: 1.3 NeoVim: 0.9 go.nvim: latest [v0.2.1]?

Does anyone have problems with LunarVim setup? (don't know about bare nvim) Indents don't always work. Problems often arise when I manually >> the lines. Then autoformat sometimes toggles indents for the new lines every time on save. Sometimes it deletes some stuff, like one or two lines or even some leading part of a word. Even after correcting all the syntax.... Reopening the file fixes the issues I think.

I've got in config.lua

vim.opt.tabstop = 4
vim.opt.shiftwidth = 0

and the go autoformat setup script in the README

YuqiaoS avatar Jan 05 '24 15:01 YuqiaoS

Lazyvim and go.nvim here. Just noticed this as well.

Example: I have DelTask() string then add 5 spaces before DelTask() and when I save, it gets truncated to sk() string.

Not exactly sure how to troubleshoot yet, but will poke around and find out hopefully.

descensus avatar Jan 07 '24 16:01 descensus

Think I found what caused it to me. The documentation is slightly confusing (?).

I follow the lazyvim instructions:

This I assume means that you should add the line to ~/.vimrc:

image

Adding it to ~/.vimrc does nothing for me, but I had it added to my init.lua as a test since its lua anyway: image

Now these strange truncation things starts to happen on indents, so I removed the above lines. These does not seem need as well (at least in lazyvim): require('go.format').goimport() because everything is default in ~/.local/share/nvim/lazy/go.nvim/lua/go.lua already as I interpret it

If you look at the general documentation for format and save, it does mentions init.lua instead of vimrc:

image

I dunno, the neovim ecosystem(s) are bit hard to figure out so maybe I have missed something obvious.

descensus avatar Jan 07 '24 21:01 descensus