Skip to content
Permalink
Browse files

Introduce Vim wrapper for ElixirLS

  • Loading branch information...
GrzegorzKozub committed May 7, 2019
0 parents commit 15f05895d57abeed0e46c1117014b7e5d273ab2f
Showing with 49 additions and 0 deletions.
  1. +3 −0 .gitmodules
  2. +37 −0 autoload/elixirls.vim
  3. +1 −0 elixir-ls
  4. +8 −0 plugin/elixirls.vim
@@ -0,0 +1,3 @@
[submodule "elixir-ls"]
path = elixir-ls
url = https://github.com/JakeBecker/elixir-ls.git
@@ -0,0 +1,37 @@
if exists('g:vim_elixirls_loaded') | finish | endif

if !exists('*job_start')
echoerr 'The vim-elixirls plugin requires Vim 8 with job_start()'
finish
endif

let s:repo = expand('<sfile>:p:h:h') . '/elixir-ls'
if exists('s:job_id') | unlet s:job_id | endif

function! elixirls#compile() abort
if exists('s:job_id')
echomsg 'ElixirLS is already currently compiling in the background'
return
endif
let l:script = 'mix deps.get && mix compile && mix elixir_ls.release -o release'
let l:command = has('win32') ? 'cmd /c ' . l:script : ['/bin/sh', '-c', l:script]
let s:job_id = job_start(l:command, { 'cwd': s:repo, 'exit_cb': function('s:exit_cb') })
if job_status(s:job_id) ==# 'run'
echomsg 'ElixirLS compilation started'
else
echoerr 'ElixirLS compilation failed to start'
unlet s:job_id
endif
endfunction

function! s:exit_cb(job, exit_status) abort
if a:exit_status == 0
echomsg 'ElixirLS compiled successfully'
else
echoerr 'ElixirLS compilation failed (' . a:exit_status . ')'
endif
unlet s:job_id
endfunction

let g:vim_elixirls_loaded = 1

Submodule elixir-ls added at ca277c
@@ -0,0 +1,8 @@
if exists('g:vim_elixirls_plugin_loaded')
finish
endif

command! ElixirLsCompile call elixirls#compile()

let g:vim_elixirls_plugin_loaded = 1

0 comments on commit 15f0589

Please sign in to comment.
You can’t perform that action at this time.