GithubHelp home page GithubHelp logo

elm-vim's Introduction

elm-vim

Instructions to get started with Elm tooling in Vim.

Setup

Language Server

Install elm-language-server and its dependencies. It provides most features, e.g. diagnostics (elm make), linting (elm-analyse), jump to definition, formatting (elm-format) and more. It is a standalone implementation of the language server protocol (LSP). There exist multiple language server client implementations (e.g. CoC or ale).

Syntax highlighting

If you have Vim/Neovim > 8.2 patch 929, Elm syntax is already included in Vim!

Otherwise install elm-vim-syntax to add syntax highlighting and indentation.

Code formatting

elm-format is used by elm-language-server to format code. An alternative is ale's elm-format fixer.

Linting

elm-analyse is used by elm-language-server for static code analysis of elm code. It doesn't need to be installed manually. Its checks can be configured.

Snippets

elm-language-server provides snippets (e.g. with CoC).

An alternative is to install Ultisnips for snippet functionality. Install honza/vim-snippets which contains elm.snippets

Tests

Install vim-test to run tests. It contains elmtest.vim. :TestFile will execute elm-test.

Tagbar

Install majutsushi/tagbar and configure content displayed in the tagbar.

let g:tagbar_type_elm = {
      \ 'kinds' : [
      \ 'f:function:0:0',
      \ 'm:modules:0:0',
      \ 'i:imports:1:0',
      \ 't:types:1:0',
      \ 'a:type aliases:0:0',
      \ 'c:type constructors:0:0',
      \ 'p:ports:0:0',
      \ 's:functions:0:0',
      \ ]
      \}

Configuration examples

There is an example configuration to showcase a small Vim setup for Elm.

User configurations

It's a good idea to take a look how others are configuring their environments. Here are some examples:

FAQ

Frequently asked questions. Feel free to contribute.

"How do I configure CoC and set up keybindings?"

Start with the official CoC example configuration. Then start to look into our example configuration and user configurations. It'll take some time and tweaking until you find a configuration that's perfect for you.

"How can I format files on save with CoC?"

Add "coc.preferences.formatOnSaveFiletypes": ["elm"] to coc-settings.json.

"CoC or the language server is not working. How can I debug?"

With CoC you can use :CocInfo to see all client/server messages or :CocOpenLog to show the log. Set elmLS.trace.server to verbose. Make sure you're using a valid elm project with an elm.json file or verify behavior with elm-spa-example.

"CoC shows only first lines of error message in floating window"

CoC uses floating windows to display diagnostics (error messages). By default only the first 8 lines are shown.

"How can I disable elm-analyse inside of elm-language-server?"

It's possible to configure when elm-analyse will be triggered or disable it with config "elmAnalyseTrigger": "never". See "server settings".

"How can I disable an elm-analyse rule?"

Add a elm-analyse.json config file like this and add check names.

{
  "checks": {
    "UnusedTypeAlias": false
  }
}

"What about ElmCast/elm-vim and Zaptic/elm-vim?"

ElmCast/elm-vim an older vim plugin people used before there existed a language server implementation. We're grateful it existed in the past, but seems to be unmaintained and isn't necessary anymore.

Zaptic/elm-vim is a maintained fork. It can be a simple alternative to the elm-language-server with fewer features and easier setup.

elm-vim's People

Contributors

andys8 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.