Sublime Forum

AutoFileName (ST2/ST3)

#32

True-true :smile:

Now the only issue I have is that all items in auto-complete box have backslash ‘’ instead of normal slash ‘/’.
I believe I can fix it by replacing d += os.path.sep with d += ‘/’ correct?

0 Likes

#33

[quote=“pod”]

True-true :smile:

Now the only issue I have is that all items in auto-complete box have backslash ‘’ instead of normal slash ‘/’.
I believe I can fix it by replacing d += os.path.sep with d += ‘/’ correct?[/quote]

I changed this because when I was trying to fix all the windows bugs, I changed all references of ‘/’ to os.path.sep I’ll change it back though.

0 Likes

#34

It would be marvellous if the plugin would somehow use the Sublime Project root as “/”, because it’s often the case that my CSS files are in /css/ and my images are in /images/, and all of my references to files in CSS are absolute paths. So instead of background: url(…/images/bg.png), I use background: url(/images/bg.png). In this context, the plugin is of no use :frowning:

Also, is there some way to have the auto-complete window make suggestions immediately as I type, rather than after a manual invocation with CTRL+SPACE? It was also unable to complete a filename if I began typing one that I knew already. IE: …/images/backg[CTRL+SPACE] yields no suggestions, even though I have a background.png image in there.

Just thought I’d post my feedback! Thanks for making this :smile:

0 Likes

#35

The Sublime Text API doesn’t have much support for working with projects, so this request might be pretty difficult to implement… I’ll look into it but it might be more work then it’s worth.

This is already possible if you add the following to your Settings file (Preferences > Settings - User): [code] “auto_complete_triggers”:

	{
		"characters": "<",
		"selector": "text.html"
	},
	{
		"characters": "/",
		"selector": "text.html, source.css"
	}
][/code] (The '<' part is from your default settings so you don't want to override that.)  Essentially, ST2's autocomplete will activate when you type letters.  This setting gives exceptions, other characters that also trigger the autocompletion popup. As for why ../images/backg[CTRL+SPACE] yields no suggestions, this is because the plugin checks if the previous character is a /.  If the autocomplete is already up though, this is not a problem.  

Hope that helps!

0 Likes

#36

Ah, it does. Thank you!

0 Likes

#37

OMG. Just discovered this plugin and it’s so useful. Thanks!

I do second aaronmw’s request that the plugin somehow work with absolute paths though. It would be great if I could specify the root directory as a user preference.

0 Likes

#38

UPDATE

Notable changes:

  • Support for wildcards
  • The cursor position acts as a wildcard
  • Behaves smarter
  • No longer restricted to / to be activated
  • Directories no longer end in / when inserted into the view
  • Settings

    Use project root at root for AutoFileName
    Define a custom project root

0 Likes

#39

I merged all my beta changes to the master branch.

I’ll update the README soon but there have been a lot of changes.

  • Web designers/developers: AutoFileName now inserts width and height attributes for you.
  • Autocompletion will now feel automatic (No more pressing control+space).
  • Working on a project but want to use absolute paths? You can now adjust the plugin to use either the current project’s root or a custom path. Both of these settings can be found by going to Preferences > Package Settings > AutoFileName.

Please let me know if there are any bugs or features requests. (P.S. this has not yet been tested on windows so results could be interesting.)

0 Likes

#40

Hi man,
Thank you for new update, I noticed changes in a way how plugin works and was amazed - it is great! Tested only out-of-box functional on windows, everything works nice and smooth :smile:

0 Likes

#41

Got new plugin idea (idea is based on this plugin), not sure if you will be interested or got time to implement, or if it’s even possible.
Anyway: Will it be possible to parse css and find out classnames [and maybe ids], then if you cursor is in following position

plugin will bring list of classnames?

Also noticed that currently your plugin shows autocompletion list even if cursor is inside classname or id. I see that sublime doesn’t tell you what kind of attribute you are editing, but maybe it is possible to read current string where cursor is and find out if you are editing ‘src’ or ‘href’ (I think only these two recuire filenames autocompletion).

Again, thank you very much for this plugin, really nice work!

0 Likes

#42
0 Likes

#43

[quote=“C0D312”]

0 Likes

#44

I haven’t really paid much attention to any of my plugins recently and I was bored. So here. Anyway, the plugin is a lot more configurable via settings. I tweaked the behavior so it should feel fluid. I fixed a couple of bugs that have been there for way too long.

Feel free to send me feature requests.

Windows users: feel free to send pull requests since this might be broken for you :confused:

P.S. Check out the backspace key when within a path :smile:

0 Likes

#45

There is quite easily reproducible crash triggered by the plugin.

Place the caret inside a string and restart Sublime. If both the completions popup and “Slow plugin” dialogs will trigger, Sublime will crash. This is pretty much DOS because it’s quite hard to get out of this situation. Have to modify session file.

I know that crash is generally not a plugin’s problem and should be reported to jps but plugin should do everything possible to not trigger “slow plugin” dialog.

0 Likes

#46

@rchl,

Alright. I’ve yet to experience the slow_plugin warning, but I think I have a solution to the crash. Pushing a fix to github now. Let me know.

0 Likes

#47

Alright. I’ve yet to experience the slow_plugin warning

He says from Ivy / SSD land

0 Likes

#48

It’s really not about the disk speed (I have SSD too). It happens when there are many calls to some very frequently called callbacks which happens on restoring session with many files. And I’m on i7 so CPU is not that slow either.

Thanks for the fixes C0D312, I’ll check them out later.

0 Likes

#49

[quote=“castles_made_of_sand”]>>> Alright. I’ve yet to experience the slow_plugin warning

He says from Ivy / SSD land[/quote]

:smile:

@rchl, yeah, it seems the on_modified and on_selection_modified eventlisteners get called while the files load, so it was a quick fix. Hopefully it works.

0 Likes

#50

def on_query_completions(self, view, prefix, locations): settings = sublime.load_settings('autofilename.sublime-settings') is_proj_rel = settings.get("afn_use_project_root") valid_scopes = settings.get("afn_valid_scopes")

Hi, I did change on_query_completions a little and it worked for Windows. Sorry I didn’t have much time to check what you are doing there with view.settings(), but if you just need to read settings from autofilename.sublime-settings - why are you not using sublime.load_settings(‘autofilename.sublime-settings’)? There potentially could be other places where you may want to change view.settings() to sublime.load_settings().

Thank you for supporting this plugin, it is really neat.

0 Likes

#51

Yeah, ignore that. I broke the plugin :confused:

0 Likes