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

Undo not working on go files when auto-save is enabled. #51

Open
cwakshay opened this issue Sep 4, 2019 · 1 comment
Open

Undo not working on go files when auto-save is enabled. #51

cwakshay opened this issue Sep 4, 2019 · 1 comment

Comments

@cwakshay
Copy link

cwakshay commented Sep 4, 2019

First off - this is a great plugin and always ensures all my buffers are in sync with the disk.

However with go files (I use fatih/vim-go plugin), whenever I do any change, the auto-save plugin saves my work and the go plugins run a sanity check and linting.

Post that, I am not able to perform any undo action.
Undo is working absolutely fine in all other files, just not with go files.

Here is my vimrc

packadd! matchit
set ruler
filetype plugin indent on
filetype plugin on
set nocompatible
set history=100
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
set autowrite
set tabstop=4
set softtabstop=4
set expandtab
set showcmd
filetype indent on
set wildmenu
set showmatch
set undofile
set undodir=/Users/akshay/.vim/undo
if empty(glob('/Users/akshay/.vim/autoload/plug.vim'))
silent !curl -fLo /Users/akshay/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-plug'
Plug 'dkarter/bullets.vim'
Plug 'fatih/vim-go'
Plug 'tpope/vim-fugitive'
Plug '907th/vim-auto-save'
Plug 'vim-airline/vim-airline'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'ctrlpvim/ctrlp.vim'
call plug#end()

let mapleader=","
nnoremap :nohlsearch
map :cnext
map :cprevious
map :GoDecls
map :GoDeclsDir
nnoremap a :cclose
nnoremap al :GoAlternate
nnoremap e :GoTest
nnoremap f :GoTestFunc
nnoremap gs :Gstatus
nnoremap sr :source~/.vimrc
nnoremap t

autocmd vimenter * NERDTree
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif

function! s:build_go_files()
let l:file = expand('%')
if l:file =# '^\f+_test.go$'
call go#test#Test(0, 1)
elseif l:file =
# '^\f+.go$'
call go#cmd#Build(0)
endif
endfunction

autocmd FileType go nmap b :call build_go_files()
autocmd FileType go nmap c (go-coverage-toggle)
autocmd FileType go nmap r (go-run)
autocmd FileType go nmap e (go-test)
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
let g:auto_save=1
let g:auto_save_no_updatetime = 1
let g:auto_save_write_all_buffers=1
let g:go_fmt_command = "goimports"
let g:go_auto_type_info = 1
let g:go_auto_sameids = 1
let g:go_list_type = "quickfix"
`

Sample go file

package main
import (
"os"
"text/template"
)
type Test struct {
Name string
}
func main() {
tmp := template.New("SMS").Option("missingkey=zero").Delims("${", "}")
tmp, _ = tmp.Parse("${.otp} is your OTP for ${.company} Freight")
par := make(map[string]string)
par["otp"] = "1234"
tmp.Execute(os.Stdout, par)
}

@Maxfer4Maxfer
Copy link

I've got absolutely the same problem.
Quite annoying.

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

2 participants