-
Notifications
You must be signed in to change notification settings - Fork 38
Home
This plugin uses ElixirSense to give inside about your elixir project in vim.
- Elixir > v1.3 to run alchemist-server
- OTP 19 and above
- Python elixir_sense_client is the script that talks to ElixirSense
- vim-elixir to enable syntax highlighting, indentation and etc.
You can use your favourite VIM plugin mannger for installation, in this doc we use Vundle
Add this line to your .vimrc
Plugin 'slashmili/alchemist.vim'
- ElixirSense is included into this plugin and YOU DON'T NEED to set it up separately
- auto complete and jump to definition only works if your project or newly added file has been compiled.
Usually it's not a problem if you are building a web app with phoenix, because it gets compiled automatically while
mix phoenix.server
is running.
- Auto completion:
<C-x><C-o>
while your are in INSERT mode.
- asyncomplete.vim (configurations)
- deoplete
- YouCompleteMe (if it doesn't work for you see here and here)
By default the docs are shown as markdown.
- Press
K
while cursor is under a module or function in NORMAL mode.
- ExDoc:
ExDoc [module/function]
provides document (press TAB to get autocomplete).
This plugin works with user defined and downloaded hex packages, for Jumping to Elixir/Erlang source code look at g:alchemist#elixir_erlang_src configs.
- Jump to the definition: Press
<C-]>
while cursor is under the keyword in NORMAL mode. - Jump through tag stack: Press
<C-T>
to jump between tag stack in NORMAL mode.
- ExDef:
ExDef [module/function]
jumps to the definition.
- Disable short keys
In case you don't like alchemist.vim
semi-tag functionality!
let g:alchemist_tag_disable = 1
- Change short keys bindings
let g:alchemist_tag_map = '<C-]>'
let g:alchemist_tag_stack_map = '<C-T>'
- Set source path for Elixir and Erlang
If you haven't build Elixir/Erlang from source, you need to set g:alchemist#elixir_erlang_src
to be able to jump to Elixir/Erlang modules.
let g:alchemist#elixir_erlang_src = "/usr/local/share/src"
This directory should contains two directories, elixir and otp
/usr/local/share/src
├── elixir
│ ├── CHANGELOG.md
│ ├── lib
│ ├── Makefile
│ ├── ...
├── otp
│ ├── AUTHORS
│ ├── lib
│ │ ├── asn1
│ │ ├── stdlib
│ │ ├── ...
│ ├── ...
IEx shell within vim requires either Neovim or ConqueShell. For ConqueShell the setting g:ConqueTerm_CloseOnEnd
should be enabled to properly exit IEx.
- IEx:
IEx [command]
opens a new IEx session if none exists (iex -S mix). If one already exists, it switches to that window (or reopens the window if it was closed). can take a command, which it will run. For example::IEx h Enum.reverse
- IExHide: hides the window that the IEx session is in.
- Set IEx terminal size.
:IEx
opens a new horizontal split for the IEx session. The size of the split can be configured by changingg:alchemist_iex_term_size
.
let g:alchemist_iex_term_size = 15
- Set IEx window split
let g:alchemist_iex_term_split = 'split'
Allows you to run Mix commands from vim.
If you already have an existing Mix command/plugin in vim, Alchemist won't redefine this command.
- Mix:
Mix [command]
run mix command (press TAB to get commands autocomplete).
If the project is compiled in a different system than the one running vim, then the path of the source file used when Jumping to Definitions (C-]) will be the one from the system where the code was compiled, instead of the local path where vim is running.
This is usually the case when you are running your project inside a Docker container and mounting the files inside the container or when you are mounting a remote filesystem locally with FUSE
setting g:alchemist_compile_basepath to the base dir where your project was compiled will allow us to translate it correctly to a relative path in the local file system.
let g:alchemist_compile_basepath = '/app/'
This plugin doesn't do that for you! However it's simple to set it up in your vim
autocmd BufWritePost *.exs,*.ex silent :!mix format %