Home Download Buy Blog Forum Support

word auto-completion

word auto-completion

Postby hellysium on Fri Nov 18, 2011 7:39 pm

Hi,

Is there any way to get auto-completion for words from other files than the file I am currently working on?

I'd want to auto complete CSS classes / IDs when working on php files.

Thank you.
hellysium
 
Posts: 17
Joined: Tue Nov 08, 2011 6:08 am

Re: word auto-completion

Postby C0D312 on Sat Nov 19, 2011 1:41 pm

It's not possible; however, it could be possible with a plugin. I try to make it...
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: word auto-completion

Postby C0D312 on Sat Nov 19, 2011 2:14 pm

Since I'm not a PHP dev, could you answer a quick question(s)?

In your PHP, do you indicate the name of the css file anywhere (for example: UseThisAsCSS = "style.css), or does it look at anything in your directory that ends in .CSS?

EDIT: How is your project structure set up? (are php and css in the same directory)?
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: word auto-completion

Postby hellysium on Sun Nov 20, 2011 7:04 am

Hi C0D312,

The plugin would be great!

C0D312 wrote:In your PHP, do you indicate the name of the css file anywhere (for example: UseThisAsCSS = "style.css), or does it look at anything in your directory that ends in .CSS?

EDIT: How is your project structure set up? (are php and css in the same directory)?


I use this feature in PHPdesigner when working on WordPress projects. I think it looks for .css files and scans directories recursively i.e it doesn't matter where the css files are.

But if it is a problem, scanning directory of the current file (or using .css from the same directory) should be enough for the start :)
hellysium
 
Posts: 17
Joined: Tue Nov 08, 2011 6:08 am

Re: word auto-completion

Postby C0D312 on Sun Nov 20, 2011 5:15 pm

I already had a plugin that did something similar so I just made some modifications. Since I'm not positive what your looking for just let me know if there's something you'd like me to change. I put the plugin on Github: https://github.com/BoundInCode/CSS-completion-for-PHP because it uses several files and so anyone can make a change if they need to.

Usage: in a PHP file, press '#' to open the autocomplete box which lists all the classes and ids from your css file (in the current directory). Let me know if it should be in a different directory.

Enjoy. Hope this helps!
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: word auto-completion

Postby hellysium on Sun Nov 20, 2011 7:19 pm

wow it was quick

Thank you!

I copied the plugin into the packages folder. Pressing '#' didn't open auto-completion box.. I tried to remap the '#' to something else but still no success.

Did I miss something? Any dependencies?

EDIT:

1. It works but only between php delimiters
Code: Select all
<?php ...here it works... ?>


when I have code like this

Code: Select all
?> <div class="[here I'd like to open auto-compl. box]"></div> <?php


nothing happens

2. It scans only first .css file found in directory

3. the classes and ids should be printed without '.' or '#'
like 'myclass', not '.myclass'

Thank you
hellysium
 
Posts: 17
Joined: Tue Nov 08, 2011 6:08 am

Re: word auto-completion

Postby C0D312 on Sun Nov 20, 2011 8:52 pm

1. The reason for the first problem is because it looks for a particular scope, in this case: source.php. I'll get a fix for that.
2. This one will take a little longer.
3. That's an easy fix. I'll post it shortly.

EDIT: That was a lot easier to fix than I thought. See the new version here: https://github.com/BoundInCode/CSS-completion-for-PHP
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: word auto-completion

Postby hellysium on Mon Nov 21, 2011 4:14 am

Magnifique! :)

We have a brand new plugin!

Now I am going to look at some regex tutorial and play with your plugin (it prints classes with empty space after word).

btw is there any way to avoid showing duplicated classes and ids (words)?

Thank you so much C0D312.
hellysium
 
Posts: 17
Joined: Tue Nov 08, 2011 6:08 am

Re: word auto-completion

Postby C0D312 on Mon Nov 21, 2011 3:04 pm

I removed the spaces and removed the duplicates. Check github for the changes.
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: word auto-completion

Postby hellysium on Mon Nov 21, 2011 3:37 pm

It didn't work.

When I removed this line, the autocompl. box appeeared but with duplicated words.
Code: Select all
completions = list(set(completions))
hellysium
 
Posts: 17
Joined: Tue Nov 08, 2011 6:08 am

Next

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 7 guests