AutoFileName icon indicating copy to clipboard operation
AutoFileName copied to clipboard

ST3: afn_proj_root not working

Open ghost opened this issue 12 years ago • 15 comments

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.

ghost avatar Jul 22 '13 18:07 ghost

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.

liamcain avatar Jul 22 '13 20:07 liamcain

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?

ghost avatar Jul 22 '13 21:07 ghost

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.

liamcain avatar Jul 22 '13 22:07 liamcain

'Kay, thanks :+1:

ghost avatar Jul 22 '13 22:07 ghost

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.

ghost avatar Jul 22 '13 22:07 ghost

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 "../"

evoactivity avatar Jan 25 '14 23:01 evoactivity

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?

alexbet avatar Jan 29 '14 18:01 alexbet

@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.

evoactivity avatar Jan 30 '14 09:01 evoactivity

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

alexbet avatar Jan 30 '14 14:01 alexbet

@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.

certainlyakey avatar Feb 11 '14 13:02 certainlyakey

@certainlyakey's explanation works!

cyrusdavid avatar Mar 26 '14 12:03 cyrusdavid

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?

katrinkerber avatar May 28 '14 15:05 katrinkerber

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.

juancpgo avatar Jun 18 '14 05:06 juancpgo

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!

matthewlein avatar Nov 07 '14 17:11 matthewlein

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

brightwiths avatar Jan 07 '20 08:01 brightwiths