fatih / vim-go

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

Some weird characters are printed onto the screen #71

Closed tchap closed 10 years ago

tchap commented 10 years ago

When I use the arrow keys to move around in the command mode, from time to time some weird characters are printed, like

^[OA args.B = &data.BenchmarkOptions{
^[OA     RandomOutput: true,
}

Started happening after I installed vim-go...

bcarrell commented 10 years ago

I'm getting this as well. Using terminal mvim. It's not isolated with arrow keys, though. I've seen hjkl appear (visually, not in the file) while navigating around.

fatih commented 10 years ago

I've found those two things:

http://stackoverflow.com/questions/6987317/while-moving-the-cursor-across-a-vim-process-open-in-a-tmux-session-every-now-a http://vim.wikia.com/wiki/Fix_arrow_keys_that_display_A_B_C_D_on_remote_shell

Probably a setting is leading to this behavior. It's only happening in Terminal. I need time to further investigate it because I've never encountered this on iterm2 mac os x

bcarrell commented 10 years ago

If it helps, my version information is:

❯ mvim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled May 12 2014 16:35:33)
MacOS X (unix) version
Included patches: 1-258
Compiled by Homebrew
...

My .vimrc is located here: https://github.com/bcarrell/dotfiles/blob/master/vimrc

I usually run macvim in a terminal/tmux setting with mvim -v within iterm2. Thanks fatih.

bcarrell commented 10 years ago

image

There's a screenshot I captured of it occurring. The l appeared while navigating the current line in normal mode; it will persist if I enter insert mode. If I navigate to the line above or below, it'll disappear, but while I'm on the line it'll seem to stay until I actually edit the line.

schmichael commented 10 years ago

I'm seeing this on Ubuntu 14.04 w/Terminator and console vim.

It seems to have started sometime around May 12th.

igungor commented 10 years ago

Since I reproduce this issue anytime, I did a quick bisect and identified the possible cause of the problem, in the context of vim-go.

I think the cause of this issue is automatically showing type info.

Commit f7954356aa70 adds go-info goodness to vim-go. Since go-info is not called automatically, the weird characters does not pop out of nowhere, unless you bind space character to go-info and pressing the space button like a monkey.

Commit 238cabea6a62 automatically shows type info (go-info) with 500ms delay. Since the issue arises from go-info, frequently calling it made the weird characters popping out more often.

Commit c38a9df84d1d decreases the latency (300ms) to automatically call go-info. After this commit, gathering the type info is more snappy but weird characters are popping out more and more frequently.

A quick workaround is to disable auto_type_info by adding "let g:auto_type_info=0" to your vimrc.

I hope this information helps the author to identify the main cause of the issue.

fatih commented 10 years ago

@igungor thanks for the detailed report. I'll change the behavior to non automatic and give the option for people to enable it (like me). At least it would solve the problem in the short term.

fatih commented 10 years ago

Please confirm. If it doesn't solve we should check somewhere else for a solution.

schmichael commented 10 years ago

Confirmed that disabling auto type info fixes it for me.

oryband commented 9 years ago

A question everyone: Do you happen to use zsh and not bash? I have had this problem occurring in vim in mac+iterm2 and ubuntu+urxvt, unrelated to writing go and using vim-go at all:

https://groups.google.com/forum/#!topic/vim_use/UVxDG3lMQ0U/discussion

The common thing between these two setups was zsh + oh-my-zsh

In any case @fatih I'm using an updated vim-go version an still having this annoying garbage characters.

oryband commented 9 years ago

Maybe youcompleteme or someother plugin is causing updates on cursor move just like vim-go did before this issue was fixed, and is polluting the screen in its place.

vimalk78 commented 7 years ago

i am also facing the same issue, in Ubuntu as well as Mac

tamasd commented 7 years ago

I have a similar issue with macOS + iTerm + zsh + oh-my-zsh.

For me the only thing that makes it go away is disabling neocomplete. It seems that after pressing the ., something takes too much time, so I see garbage characters displayed. In my case, the easiest way to reproduce is when I type a package name that is not imported yet, and then I start typing a function name really fast. If I wait about a second after typing the dot, it doesn't really happen.

Additionally, if I try to correct a function name, there is a noticeable delay between pressing the backspace and the removal of the character from the screen.

JuanCabre commented 7 years ago

I am having the same issue.

I noticed that if i scroll the screen so that the escape sequences are no longer in the window, then when I scroll back, they are gone.

I have auto type info also on.

rafaeljesus commented 7 years ago

I facing with a similar problem when using auto completion, every time I write code which is completable like (t testing.T) e.g T when T appears I can't do anything else, even opening the file again once I go to the code the error comes again avoiding me to write anything else,

Pls see the pic below screen shot 2017-03-21 at 12 49 07 am

I already disabled auto_type_info but the error persists, shall I open an new issue?

rafaeljesus commented 7 years ago

I found myself a temporary solution for this autocmd FileType go set omnifunc= even losing completion features at least I can write code 🙂

178inaba commented 7 years ago

I also encountered this problem. My environment is macOS + iTerm2 I used neocomplete for autocomplete.

I will report that I could avoid the problem by deleting $GOPATH/bin/gocode or disabling neocomplete. In addition, the report of @rafaeljesus was effective.

To me the cause of this problem seemed to be a conflict between gocode and neocomplete.

My vimrc:

if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.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 'airblade/vim-gitgutter'
Plug 'altercation/vim-colors-solarized'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'editorconfig/editorconfig-vim'
Plug 'fatih/vim-go'
Plug 'kchmck/vim-coffee-script'
Plug 'mattn/sonictemplate-vim'
Plug 'Shougo/neocomplete.vim'
Plug 'tpope/vim-fugitive'
Plug 'udalov/kotlin-vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'vim-syntastic/syntastic'
call plug#end()

" Basics
set backspace=indent,eol,start
set directory=~/tmp,/var/tmp,/tmp
set hlsearch
set laststatus=2
set noshowmode
set ruler
set whichwrap=b,s,h,l,<,>,~,[,]

" Indents
set shiftwidth=4
set tabstop=4

" altercation/vim-colors-solarized
set background=dark
let g:solarized_termcolors = 256
colorscheme solarized

" fatih/vim-go
let g:go_fmt_command = "goimports"
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_generate_tags = 1
let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
let g:go_list_type = "quickfix"

" Shougo/neocomplete.vim
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_auto_select = 1

" vim-airline/vim-airline-themes
let g:airline_theme = 'solarized'
let g:airline_solarized_bg = 'dark'

" vim-syntastic/syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0

Screenshot:

2017-06-16 19 04 02
kuiro5 commented 7 years ago

Had this issue with zsh/oh-my-zsh. Using vanilla bash solved this issue (amongst others) that I was having with vim.

syifan commented 7 years ago

I am experiencing the problem in vanilla BASH, Terminator. Disabling same_id highlighting solves the problem.

kregan77 commented 6 years ago

I'm having the same issue on OSX 10.12.6, ITerm2 3.1.5, vim-go, YCM. Here's vimrc:

set tabstop=4
set shiftwidth=4
set expandtab
set number
set backspace=indent,eol,start

vnoremap <C-c> :w !pbcopy<CR><CR> 
noremap <C-v> :r !pbpaste<CR><CR>

set background=dark

set laststatus=2

filetype plugin indent on

" attempt to fix issue with characters from vim normal mode getting crapped
" out onto the screen
let g:auto_type_info=0

call plug#begin('~/.vim/plugged')

Plug 'Valloric/YouCompleteMe'
Plug 'fatih/vim-go'
Plug 'w0rp/ale'

call plug#end()

EDIT: I can confirm this actually has nothing to do with vim-go - I still get this behavior with the plugin disabled and I also get it in both normal terminal as well as iterm2. I disabled all the plugins and it still happens although less frequently. Seems to happen when the process is interrupted.

eidge commented 6 years ago

Any chance this is related to tmux? I'm seeing this happening very frequently now, but only if running nvim inside tmux..

vim345 commented 6 years ago

I was having this issue on Vim8 on Ubuntu SSHed from iterm 2, using tmux, and ZSH. I disabled all my plugins, yet I got the same garbage characters showing up in my screen. Then I went through my vimrc line by line and noticed the issue was related to this line:

function! GitBranch()
  return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
endfunction

function! StatuslineGit()
  let l:branchname = GitBranch()
  return strlen(l:branchname) > 0
endfunction

set statusline+=%#TabLine#
set statusline+=%{StatuslineGit()}

The project that I'm working on is rather large. So it takes a long time to find the current branch all the time. I believe the delay in finding the current branch is making vim to show garbage characters in my screen.

I'm not too sure if this use case applies to many people though. I'm just sharing it here just in case.

I-Dont-Remember commented 6 years ago

I found the same thing as @vim345 , I also have the StatuslineGit function and after commenting out my usage of it all issues dissapeared.

arp242 commented 6 years ago

It would be much better to get the branch name just one with an autocmd on BufNewFile and BufReadFile, store that in a buffer-local variable, and display it. You could also add some other autocmds (e.g. WinEnter) to get updates as well.

IMHO that's much better than running a shell command (any shell command) on every screen update ;-)

john9631 commented 3 years ago

So I had it when I moved from Tilix to Terminator. There is lots of discussion but I found that the approach below worked for me if the others don't resolve it for you - basically brute force to manage the cursor shapes and clear the screen. There are references in the docstring.

" Solve extra characters on vim screens in terminator in Linux
" Enable different cursors based on the mode from
" https://github.com/mjedmonds/dotfiles/commit/41c1d4639d7b2b047d260602f27a80695cf73f9c
" Information on cursors to complete it from
" https://vim.fandom.com/wiki/Change_cursor_shape_in_different_modes"

if has("autocmd")
  au BufNewFile,VimEnter,BufEnter,InsertLeave * 
    \ silent execute '!echo -ne "\e[2 q"' | redraw!
  au InsertEnter,InsertChange *
    \ if v:insertmode == 'i' | 
    \   silent execute '!echo -ne "\e[6 q"' | redraw! |
    \ elseif v:insertmode == 'r' |
    \   silent execute '!echo -ne "\e[4 q"' | redraw! |
    \ endif
  au VimLeave * silent execute '!echo -ne "\e[ q"' | redraw!
endif

let &t_SI = "\<Esc>P\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_SR = "\<Esc>P\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
let &t_EI = "\<Esc>P\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
mynyml commented 2 years ago

It's been over a year since the last post but I'm also getting this issue on the latest update. Only happening with go file types. Using vim8.1 in plain LXTerminal. I confirmed that it stops after I disable vim-go. The suggestion above to disable auto_type_info did not help in my case.