installed vim-go
set let g:go_fmt_experimental = 1
folded some code
vertically split the screen (editing different locations of the same file)
wrote to the file
folds are maintained. related to https://github.com/fatih/vim-go/issues/502
the folds on the split i was not focused on disappeared
vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):vimrc
" use vim settings over vi
set nocompatible
" PLUGIN CONFIG
" ---------------------------------
" set dir for plugins
call plug#begin('~/.vim/plugged')
" plugins
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" initialize plugin system
call plug#end()
" GENERAL CONFIG
" ---------------------------------
" syntax highlighting
syntax on
" colorscheme
set background=dark
let g:gruvbox_contrast_dark='hard'
colorscheme gruvbox
" colorize matched searches
set hlsearch
" allow me to change buffers without saving
set hidden
" do not create backup files
set nobackup
" do not create swap files
set noswapfile
" exclude files/dirs we don't care about
set wildignore+=/tmp/,dist,node_modules,*.pyc
" workaround to ensure :E maps to Explore
let g:loaded_logipat=1
" DISPLAY CONFIG
" ---------------------------------
" open splits to right/bottom
set splitbelow
set splitright
" always use vertical diffs
set diffopt+=vertical
" remember my folds pls
set foldmethod=syntax
set viewoptions=cursor,folds,slash,unix
" LANGUAGE CONFIG
" ---------------------------------
" let g:go_fmt_command = "goimports"
let g:go_fmt_experimental = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_parameters= 1
let g:go_highlight_extra_types = 1
let g:go_highlight_function_calls = 1
:version):
NVIM v0.3.8
Build type: Release
LuaJIT 2.0.5
go version):
go version go1.13 darwin/amd64
go env Output:
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/salarkhan/Library/Caches/go-build"
GOENV="/Users/salarkhan/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/salarkhan/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dr/x4vv3lc11zsdlkyz__mfv1980000gn/T/go-build740225835=/tmp/go-build -gno-record-gcc-switches -fno-common"
This can likely be improved with gopls by using its incremental updates to format specific areas, but it might be a little tricky and will take me some time to get to. Short of that, I'll take a look soon to see if I can identify any fixes for this with the current method of formatting.
I'm experiencing this without any splits. let g:go_fmt_experimental = 1 will allow folds to remain after saving the file.
let g:go_fmt_experimental = 1 is set in my .vimrc -- that's the bummer. i've updated the issue accordingly
The fix is relatively simple. These two blocks need to be updated to iterate through all windows that are displaying the buffer being formatted:
I think #2729 should resolve this when you use gopls to format.
Most helpful comment
The fix is relatively simple. These two blocks need to be updated to iterate through all windows that are displaying the buffer being formatted: