Deoplete.nvim: Not effect on_init method

Created on 6 May 2018  路  4Comments  路  Source: Shougo/deoplete.nvim

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

Problems summary

Not effect on_init method.

Expected

Effect on_init method.

Environment Information

  • deoplete version(SHA1):
deoplete.nvim [master]$ gittree | head -n 1
*    3fb71d7 Fri May 4 12:19:43 2018 +0900 Fix #749 asynchronous completion loop  (HEAD -> master, origin/master, origin/HEAD)
  • OS:
tmp$ sw_vers 
ProductName:    Mac OS X
ProductVersion: 10.13.4
BuildVersion:   17E202
  • neovim/Vim :version output:
tmp$ nvim --version
NVIM v0.3.0-1182-g1e7d5e8cd
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/local/Homebrew/Library/Homebrew/shims/super/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -I/tmp/neovim-20180415-12562-17myfqm/build/config -I/tmp/neovim-20180415-12562-17myfqm/src -I/usr/local/include -I/sw/include -I/tmp/neovim-20180415-12562-17myfqm/build/src/nvim/auto -I/tmp/neovim-20180415-12562-17myfqm/build/include
Compiled by [email protected]

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

      銈枫偣銉嗐儬 vimrc: "$VIM/sysinit.vim"
       鐪佺暐鏅傘伄 $VIM: "/usr/local/Cellar/neovim/HEAD-1e7d5e8_1/share/nvim"

Run :checkhealth for more info
  • :checkhealth or :CheckHealth result(neovim only):
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: $TERM_PROGRAM='Apple_Terminal'

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

## Python 2 provider (optional)
  - INFO: `g:python_host_prog` is not set.  Searching for python2 in the environment.
  - INFO: Executable: /usr/local/bin/python2
  - INFO: Python2 version: 2.7.14
  - INFO: python2-neovim version: 0.2.6
  - OK: Latest python2-neovim is installed: 0.2.6

## Python 3 provider (optional)
  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
  - INFO: Executable: /usr/local/bin/python3
  - INFO: Python3 version: 3.6.5
  - INFO: python3-neovim version: 0.2.6
  - OK: Latest python3-neovim is installed: 0.2.6

## Ruby provider (optional)
  - INFO: Ruby: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
  - 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)
  - WARNING: `node` and `npm` must be in $PATH.
    - ADVICE:
      - Install Node.js and verify that `node` and `npm` commands work.

health#deoplete#check
========================================================================
## deoplete.nvim
  - OK: has("nvim") was successful
  - OK: exists("v:t_list") was successful
  - OK: has("timers") was successful
  - OK: has("python3") was successful
  - 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

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

" set path
set runtimepath+=/Users/callmekohei/.config/nvim/dein/repos/github.com/Shougo/deoplete.nvim
set runtimepath+=/Users/callmekohei/.config/nvim/test-deoplete

" setting of deoplete
let g:deoplete#enable_at_startup = 1

" turn on plugins
set nocompatible
syntax enable
filetype plugin indent on

" othres
set cmdheight=2

The reproduce ways from neovim/Vim starting (Required!)

//  1. launch neovim

$  nvim -N -u minimal.vimrc foo.txt

// 2. open neovim

display nothing at command line

// 3. press i

foo <-- display at  command line

Sample source

from deoplete.source.base import Base

class Source(Base):
    def __init__(self, vim):
        super().__init__(vim)
        self.name      = 'callmekohei'
        self.mark      = '[callmekohei]'
        self.filetypes = ['text']

    def on_init(self,context):
        self.vim.command("echo 'foo'")

    def gather_candidates(self, context):
        return ["apple","banana","cherry"]

work around

class Source(Base):
    def __init__(self, vim):

        # somthing

        # work around
        if self.vim.eval("&filetype") in self.filetypes:
            self.vim.command("call deoplete#send_event('InsertEnter')")

    def on_init(self,context):

        # somthing

Screen shot (if possible)

foo

Generate a logfile if appropriate

  1. export NVIM_PYTHON_LOG_FILE=/tmp/log
  2. export NVIM_PYTHON_LOG_LEVEL=DEBUG
  3. nvim -u minimal.vimrc
  4. some works
  5. cat /tmp/log_{PID}

Upload the log file

All 4 comments

It seems intended behavior.

The source initialization is lazy loaded until insert enter.

It is for performance problem.

  for event in ['InsertEnter', 'BufWritePost', 'DirChanged']
    call s:define_on_event(event)
  endfor

If you need call events manually, please use call deoplete#send_event({event}).

I think the source should not depend on_init() call timing.

Thank you very much 馃槃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

westlywright picture westlywright  路  6Comments

pappasam picture pappasam  路  4Comments

tcstory picture tcstory  路  5Comments

tomspeak picture tomspeak  路  5Comments

letharion picture letharion  路  5Comments