callmekohei's blog

callmekoheiのひとりごと

Windows10でVim8でF#のコードをかいてみる

f:id:callmekohei00:20171112150054p:plain

Summary

visual studio code だと楽はらくなのですが

もっとシンプルな vim8 で fsharp のコードを書く!

それもwindowsで!

環境

Microsoft Windows [Version 10.0.16299.19]

windowsvim

windowsvimを扱うのは意外と大変でした!

必要なもの

vim(64bit, kaoriya version)

mono

Python 3.5.4 - 2017-08-08: Windows x86-64 executable installer

Git

必要なこと

パスを通す

control panel > system properties > advance > environment variablesPATHに書き込みます

つまりこういうことです

コマンドプロンプトmonoと入力しても認識されませんが、パスを通すことでコマンドが通るようになります。

下記ができたらオーケー

C:\Users\callmekohei>mono --version
Mono JIT compiler version 5.4.1 (Visual Studio built mono)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           normal
        SIGSEGV:       normal
        Notification:  Thread + polling
        Architecture:  amd64
        Disabled:      none
        Misc:          softdebug
        LLVM:          supported, not enabled.
        GC:            sgen

C:\Users\callmekohei>vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May  2 2017 12:56:07)
MS-Windows 64-bit console version
Included patches: 1-596
Modified by koron.kaoriya@gmail.com
Compiled by koron.kaoriya@gmail.com

C:\Users\callmekohei>python
Python 3.5.4 (v3.5.4:3f56838, Aug  8 2017, 02:17:05) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()

C:\Users\callmekohei>git --version
git version 2.15.0.windows.1

.vimrcをかく

$HOME.vimrcを書く

$HOMEの場所はコマンドプロンプトでチェック

C:\Users\callmekohei>echo %HOMEPATH%
\Users\callmekohei

こんな感じ

"----------------------------------------------------------
" Plugin manager ( Shougo/dein.vim )
"----------------------------------------------------------

let s:dein_dir = $HOME . '/.config/nvim/dein'
let s:toml     = $HOME . '/.config/nvim/dein.toml'

let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'

if !isdirectory(s:dein_repo_dir)
    execute '!git clone https://github.com/Shougo/dein.vim' s:dein_repo_dir
endif

execute 'set runtimepath+=' . s:dein_repo_dir

if dein#load_state(s:dein_dir)
    call dein#begin(s:dein_dir)
    call dein#load_toml(s:toml, {'lazy': 0})
    call dein#end()
    call dein#save_state()
endif

if dein#check_install()
    call dein#install()
endif

filetype plugin indent on
syntax   enable


set guifont=Mig_2M:h12

set shellpipe=\|\ tee


"----------------------------------------------------------
" General
"----------------------------------------------------------
" Tab
set shiftwidth=4
set tabstop=4
set softtabstop=4
set expandtab

" Clipbord ( see : help clipboard )
set clipboard+=unnamed

" Mouse ( see :help mouse-using )
set mouse=nvic

set nowrap
set number
set noswapfile
set cmdheight=2

"----------------------------------------------------------
" Seek
"----------------------------------------------------------
set wrapscan
set ignorecase
set smartcase
nnoremap <silent> <C-l> :nohlsearch<CR>

"----------------------------------------------------------
" Appearance
"----------------------------------------------------------
"colorscheme Apprentice
colorscheme Wombat


" English menu display
source $VIMRUNTIME/delmenu.vim
set    langmenu=none
source $VIMRUNTIME/menu.vim

"if has("multi_lang")
"    language en_gb
"endif

"----------------------------------------------------------
" Char code
"----------------------------------------------------------
set encoding=utf-8
set fileencodings=utf-8,iso-2022-jp,euc-jp,sjis

"----------------------------------------------------------
" Vim8 
"----------------------------------------------------------
set backspace=indent,eol,start
set hlsearch

set laststatus=2
set wildmenu
set statusline=%f
set statusline+=%m
set statusline+=%r
set statusline+=%h
set statusline+=%w
set statusline+=%=
set statusline+=%l,%c\ \ \ \ \ \ \ \ \ \ \ \ %P

"---------------------------------------------------------
" Python config
" --------------------------------------------------------
"
let g:python_host_prog='C:\Users\callmekohei\AppData\Local\Programs\Python\Python27\python.exe'
let g:python3_host_prog='C:\Users\callmekohei\AppData\Local\Programs\Python\Python35-32\python.exe'

dein.tomlをかく

dein.tomlとはプラグイン管理用の文書

場所はC:\Users\callmekohei\.config\nvimに書いておく

こんな感じ

#----------------------------------------------------------
# Shougo ware
#----------------------------------------------------------

[[plugins]]
repo = 'Shougo/dein.vim'

[[plugins]]
repo = 'Shougo/denite.nvim'

[[plugins]]
repo = 'Shougo/deoplete.nvim'
hook_add = '''
    let g:deoplete#enable_at_startup = 1
'''

[[plugins]]
repo = 'callmekohei/deoplete-fsharp'
hook_post_update = '''
  if dein#util#_is_windows()
    let cmd = 'install.cmd'
  else
    let cmd = 'bash install.bash'
  endif
  let g:dein#plugin.build = cmd
'''


[[plugins]]
repo = 'roxma/nvim-yarp'

[[plugins]]
repo = 'roxma/vim-hug-neovim-rpc'


#----------------------------------------------------------
# Color scheme
#----------------------------------------------------------

[[plugins]]
repo = 'romainl/Apprentice'

[[plugins]]
repo = 'vim-scripts/Wombat'

#----------------------------------------------------------
# QuickRun
#----------------------------------------------------------

[[plugins]]
repo = 'thinca/vim-quickrun'
hook_add = '''
    set splitright
    let g:quickrun_config = {
    \
    \     '_' : {
    \           'runner'                          : 'vimproc'
    \         , 'runner/vimproc/updatetime'       : 60
    \         , 'hook/time/enable'                : 1
    \         , 'hook/time/format'                : "\n*** time : %g s ***"
    \         , 'hook/time/dest'                  : ''
    \         , "outputter/buffer/split"          : 'vertical'
    \         , 'outputter/buffer/close_on_empty' : 1
    \     }
    \
    \     , 'fsharp' : {
    \           'command'                         : 'fsharpi --readline-'
    \         , 'tempfile'                        : '%{tempname()}.fsx'
    \         , 'runner'                          : 'concurrent_process'
    \         , 'runner/concurrent_process/load'  : '#load "%S:gs?\\?/?";;'
    \         , 'runner/concurrent_process/prompt': '> '
    \     },
    \
    \}
'''

感想

マックと違って環境構築がすごく大変 (^_^;;

あとwindows's vimdeoplete2017/11/12現在は発展途中な感じです。今からに期待!ちなみにwindows's neovimだと完璧に動作します。

こんな感じ

Editor Windows Mac
neovim
vim8