Giter Club home page Giter Club logo

Comments (16)

neowit avatar neowit commented on June 1, 2024

Yes, I did consider asynchronous mode in the past. The problem is that there is no standard way of doing this with vim.

Neovim, as you mentioned, has one sort of job control, Vim (as of recently) has job_start which is incompatible with the one used in Neovim.
There is also vim-dispatch, which came along before both Neovim and job_start in vim.

I'd love to enable asynchronous deployment, but presently there is no clear winner in async approaches for vim, so if we pick any of the above methods it would be available only to a small minority of vim users.

Ideal scenario would be if vim & neovim were to standardise their async API.

Do you have experience with any of those async methods?

from vim-force.com.

chexxor avatar chexxor commented on June 1, 2024

I'd love to enable asynchronous deployment, but presently there is no clear winner in async approaches for vim,

After reading the Channel & job design thread thread on their vim-dev group, I see what you mean. Vim is currently working on adding async tools, but Bram and Thiago, the Vim and Neovim project leaders, haven't agreed on the basic structure of async (e.g. channels & callbacks).

I don't have have much experience with async methods, no.

I searched for how some Neovim plugins which use Neovim's job_control are written. fasd.vim wraps job_start:

    if has('nvim')
      call jobstart(cmd)
    elseif has('job')
      call job_start(cmd)
    else
      call system(join(cmd, ' '))
    endif

And redismru.vim wraps is in a similar way

  let start = has('nvim') ? 'jobstart' : 'job_start'
  execute 'call '.start.'(a:cmd, opts)'

vim-force.com already has a relatively complicated command runner to add support for Windows via Python and vimproc, so it seems ok to add another small conditional to support Neovim. :)

from vim-force.com.

neowit avatar neowit commented on June 1, 2024

thank you for the examples, I'll give it a closer look at some point.

from vim-force.com.

chexxor avatar chexxor commented on June 1, 2024

@neowit, if you don't need background deploy, then you shouldn't spend too much time on it.

I wanted your quick opinion on it because I want to test background processing in vim. I'm just figuring the price we'd have to pay to get it. I plan to move forward with adding support for Neovim's background jobs (but not sure how soon, as I'm pretty slow). I'll update this thread if I make any discoveries.

from vim-force.com.

ViViDboarder avatar ViViDboarder commented on June 1, 2024

In my plugin I wrote an implementation that leverages Neomake, Dispatch or just blocking commands in Vim. An ideal solution would be to use jobs directly, but this provides a super quick way to drop in support without worrying about how each API works.

https://github.com/ViViDboarder/force-vim/blob/master/plugin/ForceCli.vim#L71

from vim-force.com.

neowit avatar neowit commented on June 1, 2024

Hello @ViViDboarder,

Thank you for the suggestion.

Have tried force-vim plugin just now (with Dispatch installed) and let g:force_dispatch_background = 1, but have not been able to see much visual feedback when running commands like :ForceTest or :ForceDeploy.
All I could see is last executed external command, e.g. !force test "Test1" (iterm/56905)
It also spawns a separate terminal window, which may not be to everyone's taste.

I am probably doing something wrong - do you have an example/video of running background job ?
When background mode enabled - is it possible to see a visual progress/feedback ?

Also, am I right assuming that neither Neomake nor Dispatch can be used in GUI mode, e.g. MacVim or gVim?

from vim-force.com.

ViViDboarder avatar ViViDboarder commented on June 1, 2024

That behavior is part of Dispatch. Dispatch offers a few ways to spawn the background command. I typically use tmux to do it. You actually want foreground mode and tmux if you want to see it. Then it will auto create a split with it running.

https://github.com/tpope/vim-dispatch#foreground-builds

from vim-force.com.

neowit avatar neowit commented on June 1, 2024

Thank you for the clarification.

In case of vim-force.com plugin - Dispatch or Neomake (or any other async utility) can not be easily employed to enable async calls.
Main reason is that existing code base does a lot of stuff after call to sfdc has finished.
Before any async method is implemented all those logical parts (following SFDC call completion) have to be moved to callback methods.

Additionally (assuming existing plugin codebase has been updated with callbacks) there is a question of how to present feedback (messages) shown upon command completion.
For example :ApexPrintConflicts may result in many messages with details. With current (synchronous method) vim does it for you automatically.
With any async method :messages window has to be opened somehow, ideally from vim script. Unfortunately few tests I have done so far have shown that with current vim build calling something like :10message from a callback method crashes vim most of the time. Hopefully this is just a temporary issue (since job_start/callbacks are a new thing), but it is a problem right now nevertheless.

from vim-force.com.

neowit avatar neowit commented on June 1, 2024

Hi guys,

I have had a go on implementing new vim async jobs support in vim-force.com, but not quite ready to release it yet.
If you wan to try it out and give me your feedback please checkout branch vim-async and use tooling-force.com-0.3.6.2.jar.

vim-async version requires server mode (see :help 'g:apex_server') and still has few (mostly visual) problems (e.g. when you run first command, and server starts, the way it is shown looks ugly).
Not all commands have been implemented in async mode, but the important ones like :ApexSave, :ApexDeploy, :ApexTest are using async jobs.

There is no documentation yet, but the only new command you need to know is :ApexMessages - it opens special buffer with log of all operations done in current session. In case of problems/errors it should open automatically, but if it does not, or you are not sure what is happening, make sure to call :ApexMessages.

IMPORTANT: you must be on the latest vim version. Especially if you use MacVim. Up until very recently there were some problems with jobs implementation.

Here is the version I know works: VIM - Vi IMproved 7.4, Included patches: 1-1831

from vim-force.com.

chexxor avatar chexxor commented on June 1, 2024

I only tried :ApexDeployOne command for now, and it was successful. @neowit, this is a really awesome user experience. I'll keep using it to see if I encounter any problems.

I use Nix to install tools like Vim. I had to manually bump the vim version from 7.4.1585 to 7.4.1941 to get the commands in the vim-async branch to work. Here's the ~/.nixpkgs/config.nix file I used to do that, if others need to do same.

let
  vim-version = "7.4.1941";
in
{
  packageOverrides = pkgs: rec {
    vim = pkgs.vim.overrideDerivation (oldAttrs: {
      name = "vim-${vim-version}";
      src = pkgs.fetchFromGitHub {
        owner = "vim";
        repo = "vim";
        rev = "v${vim-version}";
        sha256 = "0apq7sv1fbyfzqh4q0r2z19bn4gbjlb97wyl80kj7qsqmsy7m1lm";                                                                                                                                         
      };
    });
  };
}

from vim-force.com.

chexxor avatar chexxor commented on June 1, 2024

@neowit, I wonder if you've also noticed this:

When I start an async command, like ApexDeployOne, I hit a key to return to the buffer I was using and continue to watch the deploy updates in the status bar. If I change focus to a non-Apex syntax buffer, like the command history, then I see error messages appearing in the status bar. They don't affect the status of deployment, however, so I don't mind too much.

Any idea where to look to debug this?

from vim-force.com.

neowit avatar neowit commented on June 1, 2024

Hello @chexxor,

No, this is not something I have observed, but that is probably just because of insufficient amount of testing.

Can you give a step-by-step scenario how to reproduce this ?

Also, which vim do you use? Console or one of GUI variants? What version?

If you could record a video/gif of the issue that would be even better.
Thanks.

from vim-force.com.

chexxor avatar chexxor commented on June 1, 2024

I'm using Vim 7.4.1941 in Terminal on Mac Yosemite 10.10.5.
When I have an async command running, then do q: to get command history, I get the following error appearing the in command history window when the next async job status update appears. I'll look at getting a video soon.

Failed to identify resource name for file 
Error detected while processing function 112[8]..apexMessages#log[1]..<SNR>86_logHeader[3]..<SNR>86_cacheLines[6]..<SNR>86_isVisible[1]..<SNR>86_getBufNumber[1]..<SNR>86_getBufferName[1]..apex#getApexProjectSrcPath[5]..apex#getSFDCPro
jectPathAndName:
line   24:
E605: Exception not caught: src folder not found
Error detected while processing function 112[8]..apexMessages#log[1]..<SNR>86_logHeader[3]..<SNR>86_cacheLines:
-- More --

from vim-force.com.

neowit avatar neowit commented on June 1, 2024

thank you for the details.
No need for video actually, I get the idea. Will try to reproduce it...

from vim-force.com.

neowit avatar neowit commented on June 1, 2024

Hello @chexxor,

The error you were experiencing was caused by a redundant piece of code which is now removed.
Please try again with latest version of vim-async branch and let me know if the issue is still there.

from vim-force.com.

chexxor avatar chexxor commented on June 1, 2024

@neowit, I did some quick testing - the issue I described above with q: command seems to be resolved. Works great!

from vim-force.com.

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.