Giter Club home page Giter Club logo

Comments (7)

prabirshrestha avatar prabirshrestha commented on May 18, 2024 1

Added a wiki page on how to use flow language server at https://github.com/prabirshrestha/vim-lsp/wiki/Servers-Flow

from vim-lsp.

prabirshrestha avatar prabirshrestha commented on May 18, 2024

It should be similar to typescript. https://github.com/prabirshrestha/vim-lsp/wiki/Servers-TypeScript

from vim-lsp.

entropitor avatar entropitor commented on May 18, 2024

You're the best @prabirshrestha ! 💯

from vim-lsp.

TrySound avatar TrySound commented on May 18, 2024

@prabirshrestha There's also native lsp support in latest versions via flow lsp. Could you provide an example with using it with nearest node_modules/.bin/flow?

from vim-lsp.

prabirshrestha avatar prabirshrestha commented on May 18, 2024

I have updated the docs to use flow lsp.

@TrySound As for the local flow bin, you can write a custom function to return cmd.

function! s:get_flowbin(server_info) 
    let l:nodemodules_dir = lsp#utils#find_nearest_parent_directory(lsp#utils#get_buffer_path(), 'node_modules')
    if !empty(nodemodules_dir)
        " you might also want to verify if flow binary actually exists
        return [&shell, &shellcmdflag, l:nodemodules_dir . '/.bin/flow lsp']
    endif
    " instead of returning empty you could also return ['flow', 'lsp] to tell it to use global flow.
    return []
endfunction

Then update the cmd to point to the function you created above.

'cmd': function('s:get_flowbin')

I personally use typescript every day and prefer to use global which I keep up to date so that when I'm cleaning the git repro or switching branches I always have the binary there.

from vim-lsp.

TrySound avatar TrySound commented on May 18, 2024

@prabirshrestha This is not the case with flow because a few different projects may use different flow versions and produce different errors. I'm sure this is also true for typescript.

from vim-lsp.

TrySound avatar TrySound commented on May 18, 2024

For some reason asyncomplete just doesn't work with vim-lsp. This is my config

let g:lsp_preview_keep_focus = 0
let g:asyncomplete_smart_completion = 1
let g:asyncomplete_force_refresh_on_context_changed = 1
let g:asyncomplete_auto_popup = 0

function! s:check_back_space() abort
    let col = col('.') - 1
    return !col || getline('.')[col - 1]  =~ '\s'
endfunction

inoremap <silent><expr> <TAB>
  \ pumvisible() ? "\<C-n>" :
  \ <SID>check_back_space() ? "\<TAB>" :
  \ asyncomplete#force_refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"

function! s:get_flowbin(server_info) 
    let l:nodemodules_dir = lsp#utils#find_nearest_parent_directory(lsp#utils#get_buffer_path(), 'node_modules')
    if !empty(nodemodules_dir)
        " you might also want to verify if flow binary actually exists
        return [&shell, &shellcmdflag, l:nodemodules_dir . '/.bin/flow lsp']
    endif
    " instead of returning empty you could also return ['flow', 'lsp] to tell it to use global flow.
    return []
endfunction

au User lsp_setup call lsp#register_server({
    \ 'name': 'flow',
    \ 'cmd': function('s:get_flowbin'),
    \ 'root_uri':{server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), '.flowconfig'))},
    \ 'whitelist': ['javascript', 'javascript.jsx'],
    \ })

au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({
    \ 'name': 'file',
    \ 'whitelist': ['*'],
    \ 'priority': 10,
    \ 'completor': function('asyncomplete#sources#file#completor')
    \ }))

from vim-lsp.

Related Issues (20)

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.