liamcain / AutoFileName

Sublime Text plugin that autocompletes filenames
514 stars 78 forks source link

ST3: afn_proj_root not working #34

Open ghost opened 11 years ago

ghost commented 11 years ago

With the following settings:

"afn_use_project_root": true,
"afn_proj_root": "/"

I load my project but I sill get my boot drive root when typing / on a path. It should start from my project root, no?

Tested on ST3, Mac OS X 10.7.5.

liamcain commented 11 years ago

Maybe I should have made afn_proj_root more clear. Use that to specify either the absolute path to your project or the relative path from the current file. So if your project is in ~/Projects/my_project/ you would put that as the path. If you want to just use the root of your Sublime Text project, you can leave afn_proj_root blank.

ghost commented 11 years ago

I see... so if I use "afn_proj_root": "/path/to/project1", it works on a specific project. But if I load another .sublime-project file ( Project > Quick Switch Project ) the path will not be the same anymore. If I leave it blank, "afn_proj_root": "", typing / on a path will default to ST's default packages folder (?).

I don't think I'm doing it right. How should I set it so by typing / it will always default to the current loaded project root?

liamcain commented 11 years ago

Hmm okay. I'll take a look at it soon. Sounds like a bug. It shouldn't be using the st packages directory at all. Thanks for bringing it to my attention.

ghost commented 11 years ago

'Kay, thanks :+1:

ghost commented 11 years ago

And now, typing / with "afn_proj_root": "" set, shows Sublime Text's Package Contents (OS X)... Not sure what happened in between but just reporting that it seems that's going after ST's Packages folder anyway.

evoactivity commented 10 years ago

Has there been any progress with this bug?

edit: ok, so I know this is not the right way to fix it, but I wanted a solution tonight and it works for me

I changed line 232 from

if proot:

to

if len(proot)>1:

and line 240 from

cur_path = f

to

cur_path = f + cur_path

The problem appears to be that setting "afn_proj_root" to "" doesn't actually seem to overwrite the default of "../"

alexbet commented 10 years ago

I also need this fixed, but this bug seems to have been ignored for 6 months now. Evoactivity, do you mind telling me where you edited this so I can do it too?

evoactivity commented 10 years ago

@alexbet install PackageResourceViewer through the package manager, then hit ctrl + shit +p and select "Open Resource", you can then select AutoFileName which will show you the files in the package, then edit autofilename.py with the changes I posted above. Like I said, it's definitely not the right way to fix this, which is why I didn't submit a pull request, I don't know enough about python or the sublime api to fix this properly.

alexbet commented 10 years ago

@evoactivity thanks a lot, that worked like a charm. :)

certainlyakey commented 10 years ago

@evoactivity's tip helped me too, but to get things working I had to check the ST documentation, where it's stated how custom settings should be added to project file:

{
    "folders":
    [
        {
            "path": "/",
        },
    ],
    "settings": {
        "afn_use_project_root": true,
        "afn_proj_root": "/Volumes/doxx/Dropbox/docs/journ/workshops"
    }
}

Also, empty or absent afn_proj_root setting does not make stuff happening, only full path to the project, which makes this settings file nontransferable.

cyrusdavid commented 10 years ago

@certainlyakey's explanation works!

katrinkerber commented 10 years ago

Running on ST2 on OSX and I can't get root paths to work.

I've added settings to the project's file the way @certainlyakey pointed out, but starting with a / still shows the folders of my disk root. And I can't find the lines of code in the autofilename.py that @evoactivity pointed out.

Anyone know a solution or an alternative plugin/way?

juancpgo commented 10 years ago

Same issue here, it's showing disk root. I have to edit the sublime-project file. I think that should be default the root to be the current root folder opened in sublime.

matthewlein commented 9 years ago

Thanks for the tip, its still an issue. The sublime-project solution worked, along with the string "true" fix for widths, I'm all set!

braivs commented 4 years ago

Tried to set this by the guide in this topic. But no work. "settings": { "afn_valid_scopes":["string","css","sass","less","scss","pug"], "afn_use_project_root": true, "afn_proj_root": "release/img" } I using Pug and my result files located in /release