Created
September 8, 2018 00:36
-
-
Save jsatk/50d72465f26302d48edfb28bb571c743 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Uses Dispatch to print the flow type of the variable under the cursor. | |
" | |
" Example: | |
" | |
" ```javascript | |
" | |
" type Person = {age: number, name: string, sex: 'male' | 'female'} | |
" const person: Person = {age: 35, name: 'Bob', sex: 'male'}; | |
" const {a|ge, sex} = person; | |
" ^ | |
" cursor | |
" | |
" // Would print `number`. | |
" | |
" const {age, s|ex} = person; | |
" ^ | |
" cursor | |
" | |
" // Would print `'male' | 'female'`. | |
" ``` | |
function! GetFlowType() | |
let cursorcolumn = col('.') | |
let cursorline = line('.') | |
let localflow = "~/khan/webapp/node_modules/.bin/flow" | |
execute "Dispatch " . localflow . " type-at-pos --quiet " . expand('%:p') . " " . cursorline. " " .cursorcolumn | |
endfunction | |
nnoremap <leader>t :call GetFlowType()<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This line could use some love. We should probably check for the flow binary in a safer way but 🤷♂️