vim-auto-save icon indicating copy to clipboard operation
vim-auto-save copied to clipboard

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

Open cwakshay opened this issue 6 years ago • 1 comments

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<CR> map <C-n> :cnext<CR> map <C-m> :cprevious<CR> map <C-p> :GoDecls<CR> map <C-g> :GoDeclsDir<CR> nnoremap a :cclose<CR> nnoremap al :GoAlternate<CR> nnoremap e :GoTest<CR> nnoremap f :GoTestFunc<CR> nnoremap gs :Gstatus<CR> nnoremap sr :source~/.vimrc<CR> nnoremap t <C-W><C-W>

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 :<C-u>call <SID>build_go_files()<CR> autocmd FileType go nmap <Leader>c <Plug>(go-coverage-toggle) autocmd FileType go nmap r <Plug>(go-run) autocmd FileType go nmap e <Plug>(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) }

cwakshay avatar Sep 04 '19 07:09 cwakshay

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

Maxfer4Maxfer avatar Mar 25 '20 13:03 Maxfer4Maxfer