Shougo / deoplete.nvim

:stars: Dark powered asynchronous completion framework for neovim/Vim8
Other
5.94k stars 295 forks source link

deoplete throws an exception, possibly due to vim-javacomplete2 #1133

Closed NobodyXu closed 4 years ago

NobodyXu commented 4 years ago

Warning: I will close the issue without the minimal init.vim and the reproduction instructions.

Problems summary

After I installed artur-shaik/vim-javacomplete2, nvim often stops me in the middle of editing file due to an exception in python.

Expected

No exception should happen.

Environment Information

git commit 7c781f4a887719e1785b3f0c4d8087d99d201e06

Linux pop-os 5.4.0-7642-generic #46~1598628707~20.04~040157c-Ubuntu SMP Fri Aug 28 18:02:16 UTC  x86_64 x86_64 x86_64 GNU/Linux
:version                                                                                                                                                                                                                                       
NVIM v0.4.3                                                                                                                                                                                                                                    
Build type: Release                                                                                                                                                                                                                            
LuaJIT 2.1.0-beta3                                                                                                                                                                                                                             
Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-gOb7vg/neovim-0.4.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=1 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=1 -O2 -DNDEBUG -DM
IN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=always -DINCLUDE_GENERATED_DEC
LARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim-gOb7vg/neovim-0.4.3/build/config -I/build/neovim-gOb7vg/neovim-0.4.3/src -I/usr/include -I/usr/include/lua5.1 -I/build/neovim-gOb7vg/neovim-0.4.3/
build/src/nvim/auto -I/build/neovim-gOb7vg/neovim-0.4.3/build/include                                                                                                                                                                          
Compiled by team+vim@tracker.debian.org                                                                                                                                                                                                        

Features: +acl +iconv +tui                                                                                                                                                                                                                     
See ":help feature-compile"                                                                                                                                                                                                                    

   system vimrc file: "$VIM/sysinit.vim"                                                                                                                                                                                                       
  fall-back for $VIM: "/usr/share/nvim"                                                                                                                                                                                                        

Run :checkhealth for more info                                                                                                                                                                                                                 

health#deoplete#check
========================================================================
## deoplete.nvim
  - OK: exists("v:t_list") was successful
  - OK: has("timers") was successful
  - OK: has("python3") was successful
  - OK: Require Python 3.6.1+ was successful
  - ERROR: Require msgpack 1.0.0+ was not successful
    - ADVICE:
      - Please install/upgrade msgpack 1.0.0+.
  - INFO: If you're still having problems, try the following commands:
    - $ export NVIM_PYTHON_LOG_FILE=/tmp/log
    - $ export NVIM_PYTHON_LOG_LEVEL=DEBUG
    - $ nvim
    - $ cat /tmp/log_{PID}
    - and then create an issue on github

health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: Release

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $VTE_VERSION='6003'
  - INFO: $COLORTERM='truecolor'

## tmux
  - OK: escape-time: 10ms
  - INFO: $TERM: screen-256color
  - WARNING: Neither Tc nor RGB capability set. True colors are disabled. |'termguicolors'| won't work properly.
    - ADVICE:
      - Put this in your ~/.tmux.conf and replace XXX by your $TERM outside of tmux:
          set-option -sa terminal-overrides ',XXX:RGB'
      - For older tmux versions use this instead:
          set-option -ga terminal-overrides ',XXX:Tc'

health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: xclip

## Python 2 provider (optional)
  - WARNING: No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
  - ERROR: Python provider error:
    - ADVICE:
      - provider/pythonx: Could not load Python 2:
          /usr/bin/python2 does not have the "neovim" module. :help |provider-python|
          /usr/bin/python2.7 does not have the "neovim" module. :help |provider-python|
          python2.6 not found in search path or not executable.
          /usr/bin/python does not have the "neovim" module. :help |provider-python|
  - INFO: Executable: Not found

## Python 3 provider (optional)
  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
  - INFO: Multiple python3 executables found.  Set `g:python3_host_prog` to avoid surprises.
  - INFO: Executable: /usr/bin/python3
  - INFO: Other python executable: /bin/python3
  - INFO: Python version: 3.8.5
  - INFO: pynvim version: 0.4.1 (outdated; from /usr/lib/python3/dist-packages/neovim)
  - WARNING: Latest pynvim is NOT installed: 0.4.2

## Ruby provider (optional)
  - INFO: Ruby: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
  - WARNING: `neovim-ruby-host` not found.
    - ADVICE:
      - Run `gem install neovim` to ensure the neovim RubyGem is installed.
      - Run `gem environment` to ensure the gem bin directory is in $PATH.
      - If you are using rvm/rbenv/chruby, try "rehashing".
      - See :help |g:ruby_host_prog| for non-standard gem installations.

## Node.js provider (optional)
  - INFO: Node.js: v10.19.0
  - WARNING: Missing "neovim" npm (or yarn) package.
    - ADVICE:
      - Run in shell: npm install -g neovim
      - Run in shell (if you use yarn): yarn global add neovim

Provide a minimal init.vim/vimrc with less than 50 lines (Required!)

" Basic configurations
" Indentation
set expandtab
set tabstop=4
set shiftwidth=4
"set autoindent
set smartindent

set ruler
set number       " Show the lin number
set laststatus=2 " Always show status line

set termguicolors

" Change current dir automatically to current opened file
set autochdir "" This is nvi internal variable

" Map terminal esc to esc
tnoremap <Esc> <C-\><C-n>

if has('nvim')
  let $GIT_EDITOR = 'nvr -cc split --remote-wait'
endif

autocmd FileType gitcommit,gitrebase,gitconfig set bufhidden=delete

" Enable completion where available.
" This setting must be set before ALE is loaded
let g:ale_competion_enabled = 1

call plug#begin('~/.local/share/nvim/plugged')

Plug 'artur-shaik/vim-javacomplete2'

if has('nvim')
  Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
  Plug 'Shougo/deoplete.nvim'
  Plug 'roxma/nvim-yarp'
  Plug 'roxma/vim-hug-neovim-rpc'
endif

" This plugin is a supplicant for deoplete.nvim
" It shows function signature during completion
Plug 'Shougo/echodoc.vim'

Plug 'Shougo/deoplete-clangx'

" vim-javacomplete2 configurations
autocmd FileType java setlocal omnifunc=javacomplete#Complete
let g:JavaComplete_EnableDefaultMappings = 0
let g:JavaComplete_ClosingBrace = 1

call plug#end()

" Shougo/deoplete-clangx configuration
call deoplete#custom#var('clangx', 'default_c_options', "-std=c11 -Wall")
call deoplete#custom#var('clangx', 'default_cpp_options', "-std=c++17 -Wall")

" shougo/deoplete.nvim configuration
let g:deoplete#enable_at_startup = 1

" Shougo/echodoc.vim configuration
let g:echodoc#enable_at_startup = 1
"" use neovim's virtual virtual text feature.
let g:echodoc#type = 'virtual'

How to reproduce the problem from neovim/Vim startup (Required!)

Use nvim to edit java managed by gradle, with build.gradle like this:

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java project to get you started.
 * For more details take a look at the Java Quickstart chapter in the Gradle
 * User Manual available at https://docs.gradle.org/6.6.1/userguide/tutorial_java_projects.html
 */

plugins {
    // Apply the java plugin to add support for Java
    id 'java'

    // Apply the application plugin to add support for building a CLI application.
    id 'application'

    // Generate code coverage
    id 'jacoco'

    id 'org.openjfx.javafxplugin' version '0.0.9'
}

javafx {
    modules = ['javafx.controls', 'javafx.fxml', 'javafx.media']
}

sourceSets {
    main {
        resources {
            srcDirs "src/main/resources"
        }
    }
}

test {
    finalizedBy jacocoTestReport // report is always generated after tests run
    testLogging {
        exceptionFormat = 'full'
    }
}
jacocoTestReport {
    reports {
        xml.enabled false
        csv.enabled false
        html.destination file("$buildDir/reports/tests/jacoco")
    }

    dependsOn test // tests are required to run before generating the report
}

repositories {
    // Use jcenter for resolving dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {
    // This dependency is used by the application.
    implementation 'com.google.guava:guava:29.0-jre'

    // Use JUnit test framework
    testImplementation 'junit:junit:4.13'

    // Use json-simple to parse json file
    implementation 'com.googlecode.json-simple:json-simple:1.1.1'
}

application {
    // Define the main class for the application.
    mainClassName = '...'
}

Output of nvim (when I was typing)

[deoplete] Traceback (most recent call last):                                                                                                                                                                                                  
  File "/home/nobodyxu/.local/share/nvim/plugged/deoplete.nvim/rplugin/python3/deoplete/child.py", line 194, in _gather_results                                                                                                                
    result = self._get_result(context, source)                                                                                                                                                                                                 
  File "/home/nobodyxu/.local/share/nvim/plugged/deoplete.nvim/rplugin/python3/deoplete/child.py", line 254, in _get_result                                                                                                                    
    ctx['candidates'] = source.gather_candidates(ctx)                                                                                                                                                                                          
  File "/home/nobodyxu/.local/share/nvim/plugged/vim-javacomplete2/rplugin/python3/deoplete/sources/javacomplete2.py", line 21, in gather_candidates                                                                                           
    return self.vim.call('javacomplete#complete#complete#Complete',                                                                                                                                                                            
  File "/usr/lib/python3/dist-packages/pynvim/api/nvim.py", line 299, in call                                                                                                                                                                  
    return self.request('nvim_call_function', name, args, **kwargs)                                                                                                                                                                            
  File "/usr/lib/python3/dist-packages/pynvim/api/nvim.py", line 182, in request                                                                                                                                                               
    res = self._session.request(name, *args, **kwargs)                                                                                                                                                                                         
  File "/usr/lib/python3/dist-packages/pynvim/msgpack_rpc/session.py", line 104, in request                                                                                                                                                    
    raise self.error_wrapper(err)                                                                                                                                                                                                              
pynvim.api.common.NvimError: Vim(echoerr):javacomplete error: {}                                                                                                                                                                               
Error from javacomplete2: Vim(echoerr):javacomplete error: {}.  Use :messages / see above for error details.                                                                                                                                   
Shougo commented 4 years ago

It is javacomplete2 source's error. I cannot fix it.