Hydrogen: filepath autocompletion

Created on 19 Jan 2018  路  7Comments  路  Source: nteract/hydrogen

Hi,

is it possible to enable file path autocompletion? In RSTUDIO if I e.g. type

setwd('user/example...')

then I could press tab and it picks the matching folder/file if there is one. Would be cool if hydrogen will support that soon or in case I can enable it, please someone give me a hint.

Thanks!

Most helpful comment

Thanks for reporting!

I looked into why this is happening, and it turns out that hydrogen isn't really using the full power of the Jupyter protocol to do autocomplete. The protocol is designed to accept a code block and a cursor position, and output completions. Hydrogen instead using a custom regex to send the kernel a completion string (with the cursor position field always set to the end of the string). Moreover, hydrogen disables autocomplete inside strings.

Fixing this seems like it would take a bit of work, but the good news is that it's language-independent and can bring other benefits besides path completion (e.g. completion of dictionary keys)

All 7 comments

Thanks for reporting!

I looked into why this is happening, and it turns out that hydrogen isn't really using the full power of the Jupyter protocol to do autocomplete. The protocol is designed to accept a code block and a cursor position, and output completions. Hydrogen instead using a custom regex to send the kernel a completion string (with the cursor position field always set to the end of the string). Moreover, hydrogen disables autocomplete inside strings.

Fixing this seems like it would take a bit of work, but the good news is that it's language-independent and can bring other benefits besides path completion (e.g. completion of dictionary keys)

Any update on this? Thanks!

This is already fixed, at least for Python

Thanks Kyle for your prompt reply. I am new to Hydrogen so might miss something here. In Jupiter Notebook, when I write "/U" and tab it will autocomplete to "/Users" but when I do it In Hydrogen, I have to write "/Use" and then it will give me a couple of options including the "/User" but not as the first option. If that is what I suppose to get then that is okay. I just wanted to double check. Thanks again!

You can change the number of characters needed to generate autocomplete suggestions in the settings for autocomplete-plus. There might be autocomplete suggestions from other packages listed before the Hydrogen ones. It's hard to tell without a screenshot

Great! I already changed it and it feels much better. Thanks for the tip! here is the screenshot:
screen shot 2019-02-13 at 10 14 40 am

@kashuk

    inclusionPriority: 1,
    suggestionPriority: atom.config.get("Hydrogen.showAutocompleteFirst")
      ? 3
      : 1,
    excludeLowerPriority: false,

you can change this code inside of hydrogens autocomplete-provider.js file, but in your config you should be be able to set showAutocompleteFirst to true to make it appear first
docs to the autocomplete provider code

Was this page helpful?
0 / 5 - 0 ratings

Related issues

olegantonyan picture olegantonyan  路  3Comments

neurotronix picture neurotronix  路  4Comments

danbri picture danbri  路  4Comments

lgeiger picture lgeiger  路  3Comments

wadethestealth picture wadethestealth  路  3Comments