LoginSignup
10
11

More than 5 years have passed since last update.

Windows 版 neovim で python3 (deoplete.nvim) を無理やり使う

Last updated at Posted at 2016-10-10

Windows 版 neovim で python3 (deoplete.nvim) を無理やり使う

どうしても windows 環境を整えたかったので,色々試したらできるようになったものの,正攻法とは言い難いのでメモ書き程度に.
もし,もっと筋の良い解決方法をご存知であれば,コメントしていただけると幸いです.

neovimのインストール

公式 に従ってインストール.
特につまづくところはないはず.

has('python3') の返り値を1にする

この Issue に書いてあるように, windows 環境では has('python3') の返り値が 0.
python3 系をインストールして, pip3.exe install neovim を実行する.
このコメント の設定を init.vim に追加する.

let g:python3_host_prog = 'C:\Users\username\AppData\Local\Programs\Python\Python35\python.exe'

$VIMRUNTIME\autoload\provider\pythonx.vim に以下のパッチを当てる.

diff --git a/usr/local/share/nvim/runtime/autoload/provider/pythonx.vim b/media/huyu/BEA4-08FB/pythonx.vim
index 6d6b389..0ebae4f 100644
--- a/usr/local/share/nvim/runtime/autoload/provider/pythonx.vim
+++ b/media/huyu/BEA4-08FB/pythonx.vim
@@ -22,7 +22,7 @@ function! provider#pythonx#Require(host) abort

   " Python host arguments
   let prog = (ver == '2' ?  provider#python#Prog() : provider#python3#Prog())
-  let args = [prog, '-c', 'import sys; sys.path.remove(""); import neovim; neovim.start_host()']
+  let args = [prog, '-c', '"import sys; sys.path.remove(\"\"); import neovim; neovim.start_host()"']

   " Collect registered Python plugins into args
   let python_plugins = remote#host#PluginsForHost(a:host.name)
@@ -101,11 +101,11 @@ function! s:check_interpreter(prog, major_ver, skip) abort
   "   2  Neovim module cannot be loaded.
   "   Otherwise something else went wrong (e.g. 1 or 127).
   let prog_ver = system([ a:prog , '-c' ,
-        \ 'import sys; ' .
-        \ 'sys.path.remove(""); ' .
-        \ 'sys.stdout.write(str(sys.version_info[0]) + "." + str(sys.version_info[1])); ' .
+        \ '"import sys; ' .
+        \ 'sys.path.remove(\"\"); ' .
+        \ 'sys.stdout.write(str(sys.version_info[0]) + \".\" + str(sys.version_info[1])); ' .
         \ 'import pkgutil; ' .
-        \ 'exit(2*int(pkgutil.get_loader("neovim") is None))'
+        \ 'exit(2*int(pkgutil.get_loader(\"neovim\") is None))"'
         \ ])

   if v:shell_error == 2 || v:shell_error == 0

nvim-qt を起動して :echo has('python3') すると 1 が返ってくる.
dein.vim とか使って deoplete.nvim を導入すると動く.

動作環境

OS: Windows10(Build 14936)
neovim: v0.1.6-833-g35f67ee
python: 3.5.2

10
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
11