Skip to content

[vim-plugin] Adding support for async calls - #890

Closed
dantleech wants to merge 2 commits into
developfrom
vim-async-call
Closed

dantleech wants to merge 2 commits into
developfrom
vim-async-call

Conversation

@dantleech

@dantleech dantleech commented Feb 23, 2020 •

Copy link
Copy Markdown
Collaborator

Adding support for making async calls to Phpactor (mainly to facilitate maintaining an indexer process).

Also adds:

:PhpactorIndexStart
:PhpactorIndexStop

to control the indexer provided by https://github.com/phpactor/workspace-query

TODO:

  • Introduce request ID and/or original action name in RPC response (option to disallow concurrent requests to same RPC method? Ability to cancel job?)
  • Support VIM 8 in addition to Nvim
  • Nice to have: Support in-proces communication? (or at least the ability for the job to send notifications to the editor)
  • Handle SIGTERM gracefully in Phpactor when running RPC (e.g. send termination message)
  • Make asyncable commands async (e.g. find all references Implement a loading message for the vim plugin #747)

@dantleech dantleech changed the title ]vim-plugin] Adding support for async calls [vim-plugin] Adding support for async calls Feb 23, 2020
Comment thread autoload/phpactor.vim

let s:indexerJobId = v:null
function! phpactor#IndexStart()
let s:indexerJobId = phpactor#nvim#asyncCall("index", {"watch": v:true})

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Abstract the VIM/Neovim job control

Comment thread ftplugin/php/commands.vim

""
" Generate accessors for the current class
command! -nargs=0 PhpactorIndexStart call phpactor#IndexStart()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove spurious doc

return job
endfunc

let s:stdout = []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also still have no idea how to catch the response without using non-local scope (like the above).

What do you think about creating a RPC server between vim and one-time phpactor commands? PHPCD mentioned already somewhere had a such solution.

I did not tested behaviour of vim-specific ch_evalraw.

@dantleech dantleech Mar 16, 2020 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One idea of this PR was to allow messages to be sent from Phpactor during a command's execution (i.e. to send progress notifications from the Indexer).

I'm not sure there are benefits to having an 2-way RPC connection. I can imagine a use-case would be to cancel an operation - and in that case sending a SIGTERM from VIM should be enough?

@dantleech dantleech Mar 16, 2020 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in anycase it's worth concentrating on the language server solution for now - we can support most of Phpactor's operations (even refactoring) over LSP and it if it works well, it could replace the Phpactor VIM client one day.

Although it's still worth refactoring to use the jobstart / VIM equivalent mechanism rather than system

@dantleech
dantleech force-pushed the develop branch 2 times, most recently from b95ed15 to 31f48a0 Compare December 18, 2020 12:19
@dantleech dantleech closed this Feb 1, 2021
@dantleech
dantleech deleted the vim-async-call branch February 1, 2021 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants