vim-elixirls


Ⅰ. 插件描述

Vim plugin that integrates elixir-ls with Vim through ALE

Ⅱ. 基本信息

创建日期:  2019-05-07
使用用户:  7
Github星:  15
插件作者:  Grzegorz Kozub

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'grzegorzkozub/vim-elixirls'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'grzegorzkozub/vim-elixirls'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'grzegorzkozub/vim-elixirls'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/grzegorzkozub/vim-elixirls

Ⅳ. 文档说明

# What is it

Vim and Neovim plugin that integrates elixir-ls with Vim through ALE. It will download and compile elixir-ls upon installation. I also provided configuration instructions for integrating with ALE and a command for on-demand compilation.

How to install

Use your favorite plugin manager. I prefer vim-plug:

Plug 'GrzegorzKozub/vim-elixirls', { 'do': ':ElixirLsCompileSync' }

Note that we're using post-update hooks to automatically compile elixir-ls after this plugin has been installed or updated.

How to integrate with ALE

At the minimum, you will need to tell ALE where the compiled elixir-ls sits and enable it as linter:

if has('nvim')
  let s:user_dir = stdpath('config')
else
  let s:user_dir = has('win32') ? expand('~/vimfiles') : expand('~/.vim')
endif

let g:ale_elixir_elixir_ls_release = s:user_dir . '/plugins/vim-elixirls/elixir-ls/release'

" https://github.com/JakeBecker/elixir-ls/issues/54
let g:ale_elixir_elixir_ls_config = { 'elixirLS': { 'dialyzerEnabled': v:false } }

let g:ale_linters = {}
let g:ale_linters.elixir = [ 'credo', 'elixir-ls' ]

I'm using the following Vim key mappings for quick code navigation:

autocmd FileType elixir,eelixir nnoremap <C-]> :ALEGoToDefinition<CR>
autocmd FileType elixir,eelixir nnoremap <C-\> :ALEFindReferences<CR>

You can use a version of elixir-ls other than the one that comes with this
plugin by setting g:vim_elixir_ls_elixir_ls_dir to the path to your elixir-ls

  1. Make sure to also set g:ale_elixir_elixir_ls_release as mentioned
    above.

I'm using mix format to format my elixir code with this config:

let g:ale_fixers = {}
let g:ale_fixers.elixir = [ 'mix_format' ]

autocmd FileType elixir,eelixir nnoremap <Leader>f :ALEFix<CR>

The :ALEInfo command is useful for figuring out why things are not working.

Compiling elixir-ls manually

For elixir-ls to work, it needs to be compiled with the same elixir version as your code. Here's a handy command:

:ElixirLsCompile

添加新评论