Plugin for clickable links in code


I’m considering starting a plugin that would allow for ctrl+clicking on code to jump to other files. The most basic version would detect a require('./some/module') in Javascript and ctrl+click would take you to some/module.js.

I looked through the docs, but I don’t see how a plugin can either change parts of the editor to become a link, or to simply detect clicks in the editor. If this exists, can someone point me in the right direction?

PHP: Click namespace/objectnname/function/method to go to file/decleration

I think putting a real link in the editor would be a problem. It might interfere with the complex set of spans put in by the grammar.

You could dynamically look at the text you ctrl-click on (see code befow), but figuring out you want the ctrl-click to mean a link instead of adding a selection might be a problem.

In any case, here is some code I just wrote tonight for a package. It might help. (@subs is an instance of my sub-atom package).

do subscribeToAllEditors = =>
  @subs.add atom.workspace.observeTextEditors (editor) =>
    lines = atom.views.getView(editor).shadowRoot.querySelector '.lines'
    @subs.add lines, 'mousedown', (e) =>
       # if e.ctrlKey then use $( for line and parse for desired target

Let me know if this doesn’t make sense.


Thanks. I was originally thinking converting things to links as you press the button would be ideal for showing what can be clicked on, but that’s probably going to cause too many problems. I can probably generate markers instead.

If I end up having time and ability I’d like to make this like linter where it handles the core functionality and other plugins can do the static analysis to generate “links” to sources.

It took me a few minutes to find sub-atom. It makes sense now.


Maybe you can try this


Thanks! It seems a bit buggy, but that’s what I was looking for. It seems to work, but also throws some exceptions.


Hey AsaAyers, I am the developer on the navigate…thanks for trying it. Would you mind adding the issues you are facing/execption to the github issues log…that way it would be addressed for everyone using the plugin…


Sure, I’m just going to try to gather a little more info first. All I have right now is “it blew up and atom recommended opening a bug”.


Thanks for loging the issue to github. Just to close the conversation, the issue is taken care. Should be good to go… :smiley:


When I started this quest oh so many hours ago :wink: I had some broader goals in mind to be able to link to where a variable was defined and support other languages. Navigate is a good start for jumping around Javascript projects, but I still decided to build my own project last night.

For anyone interested code-links v0.1.0 comes with a very naive implementation for Javascript that just supports relative requires. If anyone else wants to write parsers for other languages (CoffeeScript anyone?) you should be able to provide a service using my javascript-parser as a template. Any feedback is appreciated and I’ll work with anyone looking to add other languages.


looks nice…just to wanted to let you know that navigate should work for any project(html/css/js/coffee file links) just click on the file uri (even if it is not on the path) and f3 to back it out.