Skip to content

Conversation

miseran
Copy link

@miseran miseran commented Apr 8, 2016

It would be useful if we were able to create mapping or set other options (such as omnifunc) only once IPyConnect is started. With this patch, an autocommand is fired as soon as IPyConnect is run, which allows the user to do just that.

For example,

autocmd User ipy-connect call SetIPyOptions()
function SetIPyOptions()
  map <silent> <CR> <Plug>(IPy-Run)
  set omnifunc=IPyOmniFunc
endfunction

I hope this is the right place to fire it.

@bfredl
Copy link
Owner

bfredl commented Apr 9, 2016

I don't think this is very useful as is, because you could just as well define a function that calls IPyConnect and does the setup. I have in my nvimrc:

function! IpyLaunch(...)
    call call("IPyConnect", a:000)
    call NvimIPyMappings()
    let g:hasipy = 1
endfunction
command! -nargs=* IP :call IpyLaunch(<f-args>)
command! IJ :call IpyLaunch("--kernel", "julia-0.4")

if exists('g:hasipy')
    " when reloading nvimrc
    call NvimIPyMappings()
endif

what could be useful though, is to fire an autocommand towards the end of def connect(). At this point the kernel is fully initialized (so commands can be sent to it) and the kernel info (most importantly the language) is known.

@miseran
Copy link
Author

miseran commented Apr 9, 2016

Thanks for your reply. Defining a new command would be an alternative, yes. I may just do it that way.

I did consider firing the autocommand at the end of def connect(), but I wasn't sure if there would be any problems due to asynchrony. It would certainly be nice if one could e.g. set the filetype of the main buffer appropriately, right now I just set it to python since that's the one I use.

I assume there's no need for me to update the pull request?

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