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

Evaluate expression and insert result in code view #121

Open
andreasthoelke opened this issue Nov 30, 2017 · 2 comments
Open

Evaluate expression and insert result in code view #121

andreasthoelke opened this issue Nov 30, 2017 · 2 comments

Comments

@andreasthoelke
Copy link

andreasthoelke commented Nov 30, 2017

This maybe be a feature request or just something that I overlooked:

I would like to evaluate an expression or top level symbol and then get the result in vimscript, so I can insert it below the symbol name in the code view - similar to how PSCIDEaddTypeAnnotation inserts the type. This mostly saves me switching back and forth between a psci window and the code, but has other nice properties as well.
It seems there is no related feature in the psc-ide protocol, so I'll probably have to ask there, but I wanted to ask here first, to hear if I'm missing a psc-ide-vim feature and if others think this may be a useful feature.

@coot
Copy link
Collaborator

coot commented Mar 11, 2018

I don't think there is support for that in psc-ide protocol.

@andreasthoelke
Copy link
Author

andreasthoelke commented Mar 12, 2018

Right, it's not in the psc-ide protocol and I'm not sure if others think this would be a useful feature.

I'm now simply using nvim terminal mode to insert pulp repl results into the code:

function! OnEvent(job_id, data, event) dict
  if a:event == 'stdout'
    if a:data[0] =~ 'Error'
      call append(line('.'), a:data)
    else
      call append(line('.'), a:data)
    endif
  elseif a:event == 'stderr'
    call append(line('.'), a:data)
  else
    call append(line('.'), "Unknown event?!")
  endif
endfunction

function! PursEval(expr)
  call jobsend(g:PursReplID, a:expr . "\n")
endfun

let Cbs = {
\ 'on_stdout': function('OnEvent'),
\ 'on_stderr': function('OnEvent'),
\ 'on_exit': function('OnEvent')
\ }

command! PursRepl :let PursReplID = jobstart("pulp repl", Cbs)

It would need filtering in the event handler to not clutter your code with all outputs. Not a very elegant approach, so not sure how others are doing this.

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

No branches or pull requests

2 participants