benschwarz / sublime-bower

Install Bower packages from within Sublime
MIT License
226 stars 12 forks source link

Add snippets/completions for main / source file paths #13

Open benschwarz opened 11 years ago

benschwarz commented 11 years ago

Consider the following interface:

bower<tab>

Should autocomplete / list the available packages that you have installed in a contextual menu (not sure if possible? - need to research). Pressing <enter> should complete the string into bower:packageName

bower:packageName<tab>

Should insert the paths(s) of the main files outlined in the packages' component.json file. If you're currently focused on a HTML file, it should:

If you're currently focused on any other kind of file, paste the raw path.

If anyone wants to start implementing this, that'd be gnarly. Otherwise, I'll roll my sleeves up and sort it out when I get the chance.

danheberden commented 11 years ago

+1

Unless it's on a line that doesn't start with \s*<script or is after </script>\s* - then it should just be the text. etc, yada yada, dot dot dot

jaredwy commented 11 years ago

Unfortunately i am not sure sublime text is up to it at least as a snippet.

http://sublimetext.info/docs/en/extensibility/snippets.html

benschwarz commented 11 years ago

I think, it should be a completion. http://docs.sublimetext.info/en/latest/extensibility/completions.html

jaredwy commented 11 years ago

Ah that is new :) Carry on.

On Wed, Apr 3, 2013 at 10:07 AM, Ben Schwarz notifications@github.comwrote:

I think, it should be a completion. http://docs.sublimetext.info/en/latest/extensibility/completions.html

— Reply to this email directly or view it on GitHubhttps://github.com/benschwarz/sublime-bower/issues/13#issuecomment-15808495 .

jaredwy commented 11 years ago

That whole doc page is new! When i was a lad we had to dump python objects in the console then walk backwards up a hill.

On Wed, Apr 3, 2013 at 10:07 AM, Jared Wyles jared.wyles@gmail.com wrote:

Ah that is new :) Carry on.

On Wed, Apr 3, 2013 at 10:07 AM, Ben Schwarz notifications@github.comwrote:

I think, it should be a completion. http://docs.sublimetext.info/en/latest/extensibility/completions.html

— Reply to this email directly or view it on GitHubhttps://github.com/benschwarz/sublime-bower/issues/13#issuecomment-15808495 .

paulirish commented 11 years ago

hot. want it. :lips:

benschwarz commented 11 years ago

The above commits add two classes, PackageDefinition and BowerRC.

The idea being that PackageDefinition().read('normalize-css') will return a python object that is the contents of components/normalize.css/component.json.

We need to read .bowerrc to ensure that the user hasn't set another directory for the components to be stored in. If there isn't one, we default back to using the assumed path.

This code is untested, but reads okay after quickly bashing it out. It shouldn't be too hard to complete from here.

Melindrea commented 11 years ago

...Do want...

I am assuming that the path will be based on the directory of the .bowerrc as well, so that it'll toss out <script src="my/weird/path/jquery/jquery.js"></script> if my directory is set to "my/weird/path"?

benschwarz commented 11 years ago

@Melindrea, yeah—thats the implementation that I'm going with.

benschwarz commented 11 years ago
benschwarz commented 11 years ago

I don't understand your last comment @jaredwy? Will what respect??

Where do you want to go with this PR? The binding stuff is seemingly hella difficult to get right. We could add a Default.sublime-keymap file to the plugin, then specify a key combo:

<binding key="ctrl+alt+b" command="insert-bower-package"/>

… from there we could show a quick panel to list our packages:

Sublime's quick panel

Open for suggestions here.

jaredwy commented 11 years ago

It was in reference to bower not seeming to respect the directory attribute in my ~/.bowerrc but you said it does for you so i must have done something wrong.

jaredwy commented 11 years ago

I am thinking unless someone with some sublime knowledge can let us know how to go getting the autocomplete working with out modifying the user settings for a file with scope html then a command might have to be the way forward. I am pretty sure you can show the same auto complete window from a command.

benschwarz commented 11 years ago

If you installed bower a long time ago (before 0.3.0 - See https://github.com/twitter/bower/issues/102), .bowerc was either broken or not implemented.

benschwarz commented 11 years ago

Okay, perhaps we should make a post on the sublime plugin forums, because the IRC room is quiet at the best of times.

@sublimeText, do you have any pointers?

chid commented 10 years ago

This would be really nice +1

jaredwy commented 10 years ago

I might take another stab at this, the apis were just not there in sublime text 2. Would people be interested if it was sublime text 3+?

On Sat, Nov 30, 2013 at 9:29 PM, Charley Peng notifications@github.comwrote:

This would be really nice +1

— Reply to this email directly or view it on GitHubhttps://github.com/benschwarz/sublime-bower/pull/13#issuecomment-29549886 .

benschwarz commented 10 years ago

I dunno… I still use ST2, but thats mostly because a lot of plugins didn't bother to do all the work to run under 3. … Why don't you check it out?

jaredwy commented 10 years ago

I will chat to you about it. But you remember my pain ;)

On Sun, Dec 1, 2013 at 9:41 AM, Ben Schwarz notifications@github.comwrote:

I dunno… I still use ST2, but thats mostly because a lot of plugins didn't bother to do all the work to run under 3. … Why don't you check it out?

— Reply to this email directly or view it on GitHubhttps://github.com/benschwarz/sublime-bower/pull/13#issuecomment-29562743 .