GithubHelp home page GithubHelp logo

elm-vim's Introduction

elm-vim

logo

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
<LocalLeader>m Compile the current buffer.
<LocalLeader>b Compile the Main.elm file in the project.
<LocalLeader>t Runs the tests of the current buffer or 'tests/TestRunner'.
<LocalLeader>r Opens an elm repl in a subprocess.
<LocalLeader>e Shows the detail of the current error or warning.
<LocalLeader>d Shows the type and docs for the word under the cursor.
<LocalLeader>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 alok avatar bitterjug avatar bradurani avatar ckipp01 avatar cloud8421 avatar debois avatar dustinfarris avatar gabrielflorit avatar h12 avatar hoelzro avatar hovsater avatar hulufei avatar jasonzurita avatar jschomay avatar jwoudenberg avatar kuznero avatar mdxprograms avatar mikker avatar ndonze avatar pbogut avatar rohanorton avatar romanzolotarev avatar russelldavies avatar simonteixidor avatar soly avatar stefanbirkner avatar svrist avatar tanob avatar vito avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elm-vim's Issues

Running :ElmMake with or without filename fails with generic help message from elm-make-unwrapped

Assuming this isn't much more than PEBKAC, but running :ElmMake with or without a filename shows the help message for elm-make-unwrapped. I just cloned this plugin a few minutes ago and am using it with pathogen. I haven't added any customizations to my .vimrc for this plugin yet.

I'm running elm-make version 0.1.2, Elm Platform 0.15.

screen shot 2015-07-12 at 1 40 26 pm

When I run elm-make Counter.elm from the terminal I am receiving the error output I expected:

screen shot 2015-07-12 at 1 49 03 pm

Comments not properly highlighted.

I'm not sure if some other plugin could be interfering, but for me the syntax highlighting is incorrect for multiline comments.
See screenshot:

screen

I ran :PluginUpdate to make sure I have the most recent version of elm-vim.

Add repo showing the elmcast vimrc setup.

People keep asking about how I setup vim for screencasts. It happens to be my normal config, and is extremely simple and opinionated.

Needs new repo at elmcast/.vim

Add command to install third party tools automatically

There is quite a bit of setup involved just to edit some elm code. elm-oracle, elm-test, elm-format, and even the elm-platform could easily be installed and updated from an editor command. Or at least prompt the user if the command isn't found.

EchoError does not output anything

I've setup elm-vim to format code at write by setting let g:elm_format_autosave=1. If a syntax error occurs I get an empty prompt looking like this:

screen shot 2016-06-11 at 12 44 22

I've debugged the issue and the actual output from elm-format is there. a:msg in the following code contains the correct output.

fun! elm#util#EchoError(title, msg)
    redraws! | echon a:title . " " | echohl ErrorMsg | echon a:msg | echohl None
endf

So, I'm thinking that something redraws the screen after we've echoed out the message and thus clearing the message. However, if I change the function as follows everything works great.

fun! elm#util#EchoError(title, msg)
    redraws! | echon a:title . " " | echohl ErrorMsg | echo a:msg | echohl None
endf

screen shot 2016-06-11 at 12 48 44

All I did was changing echon to echo when echoing out the a:msg. I'm not sure why switching to echo solves the problem, but it does. Is this a fair change to make? I can imagine that this may affect other parts of elm-vim such :ElmMake.

I'd be happy to provide a pull request as we agree on a solution.

installation issue

I tried this plugin with Vundle by adding (Plugin 'elmcast/elm-vim.git') to my .vimrc and running ":PluginInstall", but couldn't get it to work.

The error on running ":ElmRepl" is "E492: Not an editor command: ElmRepl"

The ":PluginList" command lists the plugin in. The files have been checkout into the ~/.vim/bundle folder. But the ":scriptnames" command does not list the "elm.vim" file in the plugin folder as being loaded. The ":func ElmRepl" errors with "E123: Undefined function: ElmRepl".

Any way to troubleshoot why the plugin functions are not getting loaded? Any log files anywhere i should look into?

Elm Docs doesn't seem to work.

with the code:

module Bingo where

import Html
import String

main =
  "bingo! "
    |> String.toUpper
    |> String.repeat 3
    |> Html.text 

with the cursor on String.toUpper

I get the error:

Error detected while processing function elm#ShowDocs:
line    4:
E121: Undefined variable: fullName
E15: Invalid expression: info.fullName | echohl None | echon " : " | echohl Func
tion | echon info.signature | echohl None | echon "\n\n" . info.comment :
E121: Undefined variable: signature
E15: Invalid expression: info.signature | echohl None | echon "\n\n" . info.comm
ent
E121: Undefined variable: comment
E15: Invalid expression: "\n\n" . info.comment
Press ENTER or type command to continue

I'm on a Mac, installed via Plug.

Other commands like :ElmMake work though.

module ... where error

Hi, Elm newbie here. Trying to follow this tutorial and when I put the sample code into a file and edit it with this plugin, it inserts the line module Main (..) where at the top. Elm then barks with the error:

-- SYNTAX PROBLEM -------------------------------------------------- buttons.elm

I ran into something unexpected when parsing your code!

1| module Main (..) where
               ^
I am looking for one of the following things:

    something like `exposing (..)` which replaced `where` in 0.17
    whitespace

The file works just fine without the module line, but your plugin won't abide that. I imagine this is just due to the weird nature of the example program not having a module declaration, but it's frustrating/confusing to someone just learning.

Undo is painful

Hi, I was wondering if your guys encounter this problem, for example, use cw to replace a word, saved with elm-format, then if I want to undo the replacement, it needs press u multi times.

Syntastic integration

I currently use these settings:

let g:elm_jump_to_error = 0
let g:elm_make_show_warnings = 1
let g:elm_make_output_file = '/dev/null'

let g:syntastic_elm_checkers = [ 'elm_make' ]

...in combination with this wrapper in ~/.vim/syntax_checkers/elm/elm_make.vim:

if exists('g:loaded_syntastic_elm_elm_make_checker')
    finish
endif
let g:loaded_syntastic_elm_elm_make_checker = 1

let s:save_cpo = &cpo
set cpo&vim

function! SyntaxCheckers_elm_elm_make_GetLocList() dict
    call elm#Make()
    let fixes = getqflist()
    call setqflist([])
    cclose

    return fixes
endfunction

call g:SyntasticRegistry.CreateAndRegisterChecker({
    \ 'filetype': 'elm',
    \ 'name': 'elm_make',
    \ 'exec': 'elm-make'})

let &cpo = s:save_cpo
unlet s:save_cpo

Which seems to work fine so far, but it would be cleaner if I could get the list of fixes directly from either elm#Make(), or maybe a new function elm#Compile() which extracts the common parts. What do you think?

Syntastic Windows support?

This may just be me, but I have an issue that on save, I always get this one line:

Main.elm|| option --output: acceptable arguments to this flag include: any file that ends with .html or .js

Is anyone else getting this on Windows?

:ElmMake > elm-make fails

Calling :ElmMake on my current .elm file seems to fail. It does create a package.json file but fails to download anything.

:ElmMake
elm-make: building ... Some new packages are needed. Here is the upgrade plan.

  Install:
    elm-lang/core 2.1.0

Do you approve of this plan? (y/n) elm-make: <stdin>: hGetLine: end of file
Press ENTER or type command to continue

elm-oracle integration for functions with symbols is not working

Just started using this vim plugin and loved the integration with elm-oracle! Didn't have time yet to dig into why it doesn't work when my terminal cursor is on top of functions like "|>" and "<<", calling elm-oracle from the terminal and passing them works fine so should be something in vimscript.

Tracking this issue here, will have a look when I have time but you might be faster :-)

elm-make cannot find modules in other folders

This may well be something that I have done rather than a fault with elm-vim, but in the project I am currently working on elm-make cannot find modules which are defined in files stored outside the directory that the file in the buffer is in.

The file structure I have is as follows:

--root (contains elm-package.json)
----src
------elm
--------models
--------views

If, for instance, I edit a file in views that imports a module defined in its parent directory (elm) then the module cannot be found. My elm-package.json lists src/elm in source directories. Symlinking that file into src/elm helps in that dependencies listed there are found by elm-make (they weren't until I set up the symlink), but it still seems strange that the modules defined locally are not found. I am running vim from the root directory.

Is this normal behaviour?

Commands pass malformed arguments to elm tools

elm-vim was working fine for me yesterday, but apparently overnight it decided to go on strike, as now all the elm-vim commands result in the underlying elm tool printing out its help text as if the arguments given to them were invalid. For example, this is the output I get from using the <leader>b command to execute :ElmMake

elm-make: building ... elm-make 0.1.2 (Elm Platform 0.15)

Usage: elm-make [FILES...] [--output FILE] [--yes]
  build Elm projects

Available options:
  -h,--help                Show this help text
  --output FILE            Write output to FILE.
  --yes                    Reply 'yes' to all automated prompts.

To learn more about a particular command run:
    elm-make COMMAND --help
Press ENTER or type command to continue

How is `:ElmTest` supposed to work?

First off, the case where you run :ElmTest without arguments. “If no file is given it attempts to run the tests in 'Test[filename].elm'”. That seems to be implemented as "Test" . expand("%"). :help expand() says that % means “current file name”. I’m not a vim expert, but as far as I understand “current file path” would be more accurate. If I run :echo expand("%") in vim, it seems like paths relative to :pwd are returned, such as Main.elm or src/Foo.elm. gvim seems to output absolute paths, such as /home/lydell/elm-foo/Main.elm. So I think the code should be something like expand("%:h") . "/Test" . expand("%") (see :help expand() for more information on what :h and :t does).


Secondly, I’m quite new to elm-test. elm-test init creates a src/ directory and a tests/ directory. Seems like the suggested way of organizing things is to put source files and tests in different directories. Also, it is not quite clear to me how to split your tests up into several files, since you point elm-test to a “runner” file, not the file where the actual tests are written.

:ElmTest seems to suggest that if you create a file Foo.elm, you should create a file TestFoo.elm next to it (as opposed to into a separate tests/ directory), and put unit tests for Foo.elm in there. But what about the “runner” file?

For now, I ignore :ElmTest and run my entire test suite using elm-test on the command line whenever I want to run tests, because I don’t understand the use case for :ElmTest. Mind clarifying? :)

Missing :ElmFormat

For some reason :ElmFormat seems to be gone. I have not function I can call and nothing happens on save.

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.