cappyzawa
cappyzawa
Jun 5 · 10 min read

環境

$ node -v
v11.12.0
$ npm --version
6.7.0
$ elm --version
0.19.0
$ elm-format --help
elm-format 0.8.1
$ elm-test --version
0.19.0-rev6
$ vim -v
NVIM v0.4.0-dev

セットアップ

syntax

neovim/vim ともに執筆現在はelmのためのsyntaxはdefaultでは入っていない

Plug 'ElmCast/elm-vim', { 'for': 'elm' }
ss
ss
let g:elm_setup_keybindings = 0

Lsp Server

elm-tooling/elm-language-server: Language server implementation for Elm

$ git clone https://github.com/elm-tooling/elm-language-server.git
$ cd elm-language-server
$ git rev-parse HEAD
78aca21bd308bfc33540ef0c90b275ea4aaa4eb1
$ npm install
$ npm run compile
$ npm link
$ source ~/.zshrc
$ which elm-language-server
/Users/cappyzawa/.anyenv/envs/nodenv/shims/elm-language-server

Lsp Client

vimで利用できるLsp Clientは以下のようなものがある

if executable('elm-language-server')
au User lsp_setup call lsp#register_server({
\ 'name': 'elm-language-server',
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'elm-language-server --stdio']},
\ 'initialization_options': {
\ 'runtime': 'node',
\ 'elmPath': 'elm',
\ 'elmFormatPath': 'elm-format',
\ 'elmTestPath': 'elm-test',
\ 'rootPatterns': 'elm.json'
\ },
\ 'whitelist': ['elm'],
\ })
autocmd BufWritePre *.elm LspDocumentFormat
endif

付録

language-serverのsupport actionの一覧 => Langserver.org

追記

普段は以下のようにしてpluginの住み分けをしている

Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}}
Plug 'w0rp/ale'
Plug 'ElmCast/elm-vim', { 'for': 'elm' }
" elm-vim
let g:elm_format_autosave = 0
let g:elm_setup_keybinding = 0
let g:elm_jump_to_error = 0
" ale
let g:ale_fix_on_save = 1
let g:ale_set_quickfix = 1
let g:ale_sign_error = '🔥'
let g:ale_sign_warning = '⚡️'
let g:ale_echo_msg_error_str = '🔥'
let g:ale_echo_msg_warning_str = '⚡️'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_fixers = {
\ 'elm': ['elm-format'],
\}
let g:ale_elm_format_executable = 'elm-format'
let g:ale_elm_format_options = '--yes --elm-version=0.19'
" coc.nvim
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
nmap <silent> gt <Plug>(coc-rename)
nnoremap <silent> gk :call <SID>show_documentation()<CR>
function! s:show_documentation()
if &filetype ==# 'vim'
execute 'h '.expand('<cword>')
else
if coc#util#has_float()
pc
else
call CocActionAsync('doHover')
endif
endif
endfunction
{
"suggest.triggerAfterInsertEnter": true,
"suggest.noselect": false,
"suggest.minTriggerInputLength": 2,
"suggest.acceptSuggestionOnCommitCharacter": true,
"suggest.snippetIndicator": " ►",
"suggest.enablePreview": true,
"coc.preferences.hoverTarget": "float",
"coc.preferences.diagnostic.displayByAle": true,
"list.autoResize": true,
"languageserver": {
"elmLS": {
"command": "elm-language-server",
"args": [
"--stdio"
],
"filetypes": [
"elm"
],
"rootPatterns": [
"elm.json"
],
"initializationOptions": {
"runtime": "node",
"elmPath": "elm",
"elmFormatPath": "elm-format"
}
}
}
}

2019/06/22

antew/vim-elm-language-server merged into w0rp/ale · Issue #1 · cappyzawa/medium

$ npm i -g @elm-tooling/elm-language-server

cappyzawa

Written by

cappyzawa

#golang #concourse #vim

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade