14
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WindowsにNeoVim環境を構築(Scoop版)

Last updated at Posted at 2020-09-27

準備(パッケージ管理ツール)

パッケージ管理ツールのScoopをインストールしていない場合は、インストールしておきます。

PowerShell
Set-ExecutionPolicy RemoteSigned -scope CurrentUser -force
iwr -useb get.scoop.sh | iex

インストール

NeoVim本体と各言語のプロバイダーをインストールします。

PowerShell
scoop install neovim

scoop install python
pip install neovim

scoop install ruby
scoop install msys2
ridk install
gem install neovim

scoop install nodejs-lts
npm install -g neovim

NeoVimのコマンドモードで :CheckHealth すればプロバイダーの有効状況を確認できます。
上記の例では、Python2 はインストールしていませんが、必要あればインストールしてください。

設定(init.vim)

公式ドキュメントに .vimrc の代わりに init.vim を使って設定しろと書いてあるので従います。

  • Use $XDG_CONFIG_HOME/nvim/init.vim instead of .vimrc for configuration.

インストールしただけでは、init.vim は作成されません。自分で作成する必要があります。

init.vim のパス

NeoVimのコマンドモードで :CheckHealth すれば、init.vim を配置すべきパスを確認することができます。

  • デフォルトのパス
    パスは、デフォルトで $HOME\AppData\Local\nvim\init.vim になっているので、この場所に init.vim を自分で作成してください。

  • パスを変更する場合
    環境変数 $XDG_CONFIG_HOME を設定することで、init.vim のパスも設定可能です。

PowerShell(パスを$HOME.config\nvim\init.vimに変更する場合)
mkdir -p ~/.config/nvim
$ENV:XDG_CONFIG_HOME = $HOME+"\.config"
[Environment]::SetEnvironmentVariable("XDG_CONFIG_HOME", $ENV:XDG_CONFIG_HOME, [EnvironmentVariableTarget]::User)

init.vimを編集

PowerShell
# デフォルトパスの場合
nvim $HOME/AppData/Local/nvim/init.vim

# パスを変更した場合
nvim $ENV:XDG_CONFIG_HOME/nvim/init.vim
init.vim
" encoding setting
set encoding=utf-8                     " バッファ内で扱う文字コード
set fileencoding=utf-8                 " 書き込み時UTF-8出力
set fileencodings=utf-8,cp932          " 読み込み時UTF-8、Shift_JISの順で自動判別
" editor setting
set number                             " 行番号表示
set showcmd                           " 入力中のコマンドをステータスに表示
set splitbelow                         " 水平分割時に下に表示
set splitright                         " 縦分割時を右に表示
set noequalalways                      " 分割時に自動調整を無効化
set wildmenu                           " コマンドモードの補完
set smartindent                        " スマートインデントを行う
" temporary file setting
set noundofile                         " undofileを作らない
set noswapfile                         " swapfileを作らない
" cursor setting
set ruler                              " カーソルの位置表示
set cursorline                         " カーソルハイライト
" tab setting
set expandtab                          " tabを複数のspaceに置き換え
set tabstop=4                          " tabは半角4文字
set shiftwidth=4                       " tabの幅

プラグインマネージャー(dein.vim)

dein.vimは、Vimのプラグインを管理するためプラグインです。
https://github.com/Shougo/dein.vim

dein.vimをダウンロード

PowerShell
iwr https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.ps1 -OutFile installer.ps1
./installer.ps1 ~/.cache/dein
rm ./installer.ps1

1行目:インストール用スクリプトをダウンロード
2行目:インストール用スクリプトを実行し、引数でインストール先を $HOME/.cache/dein に指定

deim.vimの設定

init.vim に dein.vim の設定を行う。

init.vim
if &compatible
  set nocompatible
endif
" Add the dein installation directory into runtimepath
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/dein.vim

if dein#load_state('~/.cache/dein')
  call dein#begin('~/.cache/dein')

  call dein#add('~/.cache/dein/repos/github.com/Shougo/dein.vim')
  call dein#add('Shougo/deoplete.nvim')
  if !has('nvim')
    call dein#add('roxma/nvim-yarp')
    call dein#add('roxma/vim-hug-neovim-rpc')
  endif

  call dein#end()
  call dein#save_state()
endif

filetype plugin indent on
syntax enable

deim.vimのインストール

NeoVimのコマンドモードで :call dein#install() を実行する。

14
8
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
14
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?