Ale: Add support for Dart LSP

Created on 18 Oct 2017  Â·  18Comments  Â·  Source: dense-analysis/ale

Related: https://github.com/w0rp/ale/issues/1002 (dartanalyzer is too slow)

Non-official implementations of a langserver plugin for Dart have been built:

I don't know much about LSP, but I'm assuming the perfs are similar for any language implementation. Might also be easier to implement than https://github.com/w0rp/ale/issues/1005

new tool

Most helpful comment

Now NeoVim is working, the Dart LSP should be supported everywhere.

All 18 comments

To be clear - vim-lsc and vim-lsp are vim plugins to communicate with arbitrary LSP servers.

https://github.com/natebosch/dart_language_server is the Dart server following the langserver protocol that should be compatible with ale if it's configured to run like any other LSP server.

Cool. If you can communicate with it via stdin, it shouldn't be hard to integrate with.

Yup, communicate via stdin/stdout.

It's more feature limited than the api provided by the normal analysis server, and requires a separate install - but it should be a lot less custom code since it's a standard protocol and it should support everything needed for ale.

Sounds pretty good. If someone is familiar with Dart, feel free to give it a go.

@w0rp I've been working on this for the past two days, however, I can't seem to be able to find the cause of this issue: ale starts the server but doesn't actually send any data (other than Content-Length: x\r\n; tested using a shell script that mocks a language server). Here's my language_server.vim. And the output of :ALEInfo. I also tested this with language_server-ruby and clangd, none of those worked. For some reason, rls and php's langserver both work.

I recommend debugging what's going on between Vim and the LSP with ch_logfile(). You can log _all_ of the data going back and forth.

I have yet to see a single LSP client or server which implements everything correctly.

@w0rp On vim 8, that language_server.vim works perfectly. It looks like this problem is specific to NeoVim. Oh and by the way, NeoVim doesn't support ch_logfile.
That makes me wonder: how can rls work if stdio lsp type doesn't work on NeoVim.

LSP via stdio should work in NeoVim. It's easier to debug issues with LSP in Vim 8.

Yeah, it is. However, that language_server.vim does work in Vim 8, but doesn't when tested in NeoVim.
Can't say for sure, but it looks like a problem with either the server or ALE.

@w0rp Uh, sorry, but I still can't figure out what's wrong with my Dart LSP linter implementation. I'm leaning towards it being an ALE problem, because (as mentioned above) Dart LSP works perfectly in Vim 8.
Or, it could be that the server doesn't implement the specification correctly.

I'll have a look when I get the time. Could you submit a pull request with what you have so far?

Sure!

Now NeoVim is working, the Dart LSP should be supported everywhere.

@aurieh thanks for your work.

Just tried to set it up, but it's not working yet. Here's what I've done:

  1. install dart_language_server

    $ pub global activate dart_language_server
    
  2. add ~/.pub-cache/bin to my PATH

    export PATH=/home/dori/.pub-cache/bin:$PATH
    
  3. Update my vim packages to get the latest version of ale

    :PlugUpdate
    
  4. Change my ale_linters

    let g:ale_linters = {
    \   'javascript': ['eslint'],
    \   'dart': ['language_server'],
    \}
    
  5. Source my zshrc, open a dart file, intentionally put an error ⇒ Not seeing any issue from vim

  6. Confirmed that the error should be shown by running flutter analyze --watch in another pane.

I'm missing something, wondering what that is. I also don't get how this dart_language_server is supposed to be used, nor why your code is supposed to use it (feeling stupid)

Could you include the output of :ALEInfo?

My bad, it works. It just doesn't support all dart style recommendations (eg space before { in function body), so I got misled last week.

@Fandekasp - The analyzer wont' lint for formatting issues. If you use https://github.com/dart-lang/dart-vim-plugin see help :DartFmt to auto format to the effective dart format guidelines.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EdmundsEcho picture EdmundsEcho  Â·  3Comments

sublee picture sublee  Â·  3Comments

plexigras picture plexigras  Â·  3Comments

alexlafroscia picture alexlafroscia  Â·  4Comments

lervag picture lervag  Â·  3Comments