fatih / vim-go

Go development plugin for Vim
https://www.patreon.com/bhcleek
Other
15.9k stars 1.45k forks source link

Execution: GoFmt changes the Chinese at the end to <e4> #3641

Closed scrawld closed 4 months ago

scrawld commented 4 months ago

What did you do? (required: The issue will be closed when not provided)

Execution: GoFmt changes the Chinese at the end to

package main

import "fmt"

func main() {
        fmt.Println("vim-go") // 中

}

After executing: GoFmt it becomes

package main

import "fmt"

func main() {
        fmt.Println("vim-go") // <e4>

}

What did you expect to happen?

Delete the extra blank lines and do not change the Chinese at the end.

What happened instead?

Changed the 中 into

Configuration (MUST fill this out):

call plug#begin()
Plug 'fatih/vim-go', {'do': ':GoUpdateBinaries'}   " Go 插件 首次安装执行 :GoInstallBinaries 该命令将 go install 所有必需的二进制文件
call plug#end()

let g:go_fmt_autosave = 0

vim-go version: VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jun 22 2023 04:08:04)

vimrc you used to reproduce:

vimrc ```vim call plug#begin() Plug 'fatih/vim-go', {'do': ':GoUpdateBinaries'} " Go 插件 首次安装执行 :GoInstallBinaries 该命令将 go install 所有必需的二进制文件 call plug#end() let g:go_fmt_autosave = 0 ```

Vim version (first three lines from :version):

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jun 22 2023 04:08:04) Included patches: 1-3995, 4563, 4646, 4774, 4895, 4899, 4901, 4919 Modified by team+vim@tracker.debian.org

Go version (go version):

go version go1.21.3 linux/amd64

Go environment

go env Output:

GO111MODULE='auto'
GOARCH='amd64'
GOBIN='/root/etc/go/bin'
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/root/etc/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/root/etc/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.3'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/root/work/example/test_func/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2141352485=/tmp/go-build -gno-record-gcc-switches'

gopls version

gopls version Output:

golang.org/x/tools/gopls v0.14.2
    golang.org/x/tools/gopls@v0.14.2 h1:sIw6vjZiuQ9S7s0auUUkHlWgsCkKZFWDHmrge8LYsnc=

vim-go configuration:

vim-go configuration
g:go_loaded_install = 1
g:go_fmt_autosave = 0
g:go_jump_to_error = 1
g:go_loaded_gosnippets = 1

filetype detection configuration:

filetype detection
filetype detection:ON  plugin:ON  indent:ON
bhcleek commented 4 months ago

Thank you for the bug report. Interestingly, I can only duplicate this if there is either whitespace and only whitespace following the chinese character or the newline immediately follows the chinese character.

I'll need to dig in later to determine if this is a problem in vim-go specifically or if it's a bug in gopls. I suspect the problem is vim-go.

scrawld commented 4 months ago

Thank you for your reply. I also suspect it is a bug in vim-go, because it is normal for me to execute go fmt in the terminal.