Giter Club home page Giter Club logo

elm-vim's Introduction

elm-vim

logo

Elm & Vim Ecosystem

If you are looking to work with Elm in Vim you should definitely check out:

  • Elm Language Server - The language server implementation for Elm. Language servers provide tooling for working with particular programming languages. The Elm language server provides features like compiler errors, elm-analyse warnings, completions and jump-to-definition amongst many more. There are a number of ways of connecting the language server to vim.
  • elm-tooling/elm-vim - Provides lots of useful information on getting started with working with Elm in Vim.

This Fork

It appears that ElmCast/elm-vim is no longer being updated and does not support Elm 0.19. This fork has been updated for Elm 0.19 and includes some other changes. No major development is planned at the moment but we do plan to keep up with necessary changes and merge requests are welcome. Changes so far:

  • Support for Elm 0.19 compiler
  • Support for building files with test dependencies.
  • Improvements to the gf binding to handle prefixed function calls and module aliases. It also attempts to take you to the line of the function in question though that is behaviour normally associated with C-]. It might be moved at some point.
  • Always execute elm-format in the project root so it can detect the elm version appropriately.
  • Specific highlighting for modules to separate them from types

Features

  1. Syntax highlighting
  2. Automatic indentation
  3. Function completion
  4. Build and package commands
  5. Code formatting and linting
  6. Documentation lookup
  7. REPL integration

Check out this ElmCast video for more detail.

Installation

If you don't have a preferred installation method, I recommend installing vim-plug, and then simply add Plug 'elmcast/elm-vim' to your plugin section:

NOTE: If you are using vim-polyglot, you need to disable its default elm plugin by adding let g:polyglot_disabled = ['elm'] to your config file.

Requirements

First, make sure you have the Elm Platform installed. The simplest method to get started is to use the official npm package.

npm install -g elm

In order to run unit tests from within vim, install elm-test

npm install -g elm-test

For code completion and doc lookups, install elm-oracle.

npm install -g elm-oracle

To automatically format your code, install elm-format.

npm install -g elm-format

Mappings

The plugin provides several <Plug> mappings which can be used to create custom mappings. The following keybindings are provided by default:

Keybinding Description
<Leader>m Compile the current buffer.
<Leader>b Compile the Main.elm file in the project.
<Leader>t Runs the tests of the current buffer or 'tests/TestRunner'.
<Leader>r Opens an elm repl in a subprocess.
<Leader>e Shows the detail of the current error or warning.
<Leader>d Shows the type and docs for the word under the cursor.
<Leader>w Opens the docs web page for the word under the cursor.

You can disable these mappings if you want to use your own.

let g:elm_setup_keybindings = 0

Integration

The preferred linter to use with elm-vim is Ale. It should work out of the box.

Syntastic support should work out of the box, but we recommend the following settings:

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1

let g:elm_syntastic_show_warnings = 1
let g:ycm_semantic_triggers = {
     \ 'elm' : ['.'],
     \}
call neocomplete#util#set_default_dictionary(
  \ 'g:neocomplete#sources#omni#input_patterns',
  \ 'elm',
  \ '\.')

Usage

:help elm-vim
let g:elm_jump_to_error = 0
let g:elm_make_output_file = "elm.js"
let g:elm_make_show_warnings = 0
let g:elm_syntastic_show_warnings = 0
let g:elm_browser_command = ""
let g:elm_detailed_complete = 0
let g:elm_format_autosave = 1
let g:elm_format_fail_silently = 0
let g:elm_setup_keybindings = 1
  • :ElmMake [filename] calls elm-make with the given file. If no file is given it uses the current file being edited.

  • :ElmMakeMain attempts to call elm-make with "Main.elm".

  • :ElmTest calls elm-test with the given file. If no file is given it runs it in the root of your project.

  • :ElmRepl runs elm-repl, which will return to vim on exiting.

  • :ElmErrorDetail shows the detail of the current error in the quickfix window.

  • :ElmShowDocs queries elm-oracle, then echoes the type and docs for the word under the cursor.

  • :ElmBrowseDocs queries elm-oracle, then opens docs web page for the word under the cursor.

  • :ElmFormat formats the current buffer with elm-format.

Screenshots

errors and completion

Credits

  • Other vim-plugins, thanks for inspiration (elm.vim, ocaml.vim, haskell-vim)
  • Contributors of elm-vim

License

Copyright © Joseph Hager. See LICENSE for more details.

elm-vim's People

Contributors

ajhager avatar alex-kononovich avatar alicewriteswrongs avatar alok avatar bitterjug avatar bradurani avatar cloud8421 avatar debois avatar dustinfarris avatar gabrielflorit avatar hermanverschooten avatar hoelzro avatar hovsater avatar hulufei avatar jschomay avatar jwoudenberg avatar kuznero avatar letmein avatar michaeljones avatar mikker avatar ndonze avatar rohanorton avatar romanzolotarev avatar simonteixidor avatar soly avatar stefanbirkner avatar svrist avatar tanob avatar vito avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.