Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ALE backend support #18

Open
cannorin opened this issue Nov 6, 2019 · 4 comments
Open

Add ALE backend support #18

cannorin opened this issue Nov 6, 2019 · 4 comments
Assignees
Labels
enhancement New feature or request priority: low This will be worked on once other tasks are done/cannot be progressed.

Comments

@cannorin
Copy link
Member

cannorin commented Nov 6, 2019

Related: #5
Refs:

@cannorin cannorin added enhancement New feature or request priority: low This will be worked on once other tasks are done/cannot be progressed. labels Nov 6, 2019
@cannorin cannorin self-assigned this Nov 6, 2019
@cannorin
Copy link
Member Author

cannorin commented Dec 7, 2019

memo:

  • ale#lsp#CreateMessageData -(message data)-> ale#lsp#Send
  • ale#lsp#RegisterCallback

@dhilst
Copy link

dhilst commented Mar 27, 2021

Hi, I would like to help on this! :) Is there any work in progress?

-- Edit --

I could get a basic support with this code

function! Fsharp_callback(bufnr, lines) abort
  " output example: Program.fs(7,5,7,9):FSharpLint warning FL0038: Consider changing `path` to PascalCase.
  let pattern = '\([^(]\+\)(\(\d\+\),\(\d\+\),\(\d\+\),\(\d\+\)):FSharpLint \(\w\+\) \(.*\)$'
  let lines = a:lines[1:-2]
  let result = []
  for line in lines
    let matches = matchlist(line, pattern)
    if len(matches) >= 7
      if matches[6] == 'error'
        let type = 'E'
      else
        let type = 'W'
      end
      let element = {
            \ 'text': matches[7],
            \ 'detail': matches[7],
            \ 'lnum':  matches[2],
            \ 'col': matches[3],
            \ 'end_lnum': matches[4],
            \ 'end_col': matches[5],
            \ 'filename': fnamemodify(matches[1], ':p'),
            \ 'type': type
            \ }
      call add(result, element)
    endif
  endfor
  return result
endfun

call ale#linter#Define('fsharp', {
\   'name': 'FSharpLint',
\   'alias': ['fsharplint'],
\   'executable': 'dotnet',
\   'command': '%e fsharplint --format msbuild lint %t',
\   'callback': 'Fsharp_callback',
\   'lint_file': 1,
\ })

But I'm not very help with it, it depends on files being written to disk and do it's not using LSP, I will try adding an LSP version, but then I would not use dotnet fsharplint at all right? Once I got things more structured I open a PR :)

Great project by the way :-)

-- Edit --

I tested this approach better a it's terribly slow, I don't know if this because the dotnet fsharplint is slow to start or if it's because of disk I/O, I'm betting that the first is the worse problem.

Anyway, I couldn't find a LanguageClient_serverComands line for FsautoComplete anywhere so I don't really know what it would be, I searched in the readme and in your dotfiles/.vimr. Are you using FsharpAutoComplete as LSP server? In theory it would be possible to get all FsharpAutoComplete features without ALE dont? Just LanguageClient_neovim would be enough

-- Edit --

Okay I got it, it was not easy to find out but here is what worked for me

let g:LanguageClient_serverCommands = {
    \ 'fsharp': ['dotnet', expand('~/.vim/plugged/Ionide-vim/fsac/fsautocomplete.dll')]
    \ }

@cannorin
Copy link
Member Author

@dhilst Hi, thank you very much for your work! I'm failing to take the time to improve Ionide-vim, so I don't have any WIP on this. It will help me a lot if you could improve it and make a PR!

@dhilst
Copy link

dhilst commented Mar 31, 2021

@cannorin Hello, no problem I have some spare time at weekends, I will try add ALE support, once I got something working I open a PR so you can review.

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority: low This will be worked on once other tasks are done/cannot be progressed.
Projects
None yet
Development

No branches or pull requests

2 participants