2072 / PHP-Indenting-for-VIm

The official VIm indent script for PHP
http://www.2072productions.com/to/phpindent.txt
128 stars 29 forks source link

Problems with Indenting PHP when not inside <?php -- ?> #19

Closed webplantmedia closed 10 years ago

webplantmedia commented 11 years ago

Indents inside php files is not acting as the way described in the readme file.

screen shot 2013-09-12 at 12 31 39 pm

However, I know the plugin is working because writing code inside of functions works perfectly. Even writing switch statements. I can also read the help text provided from within vim.

screen shot 2013-09-12 at 12 36 40 pm

I downloaded 7.4.22 MacVim and Vim from homebrew on my Mac.

Notable settings in my .vimrc include: filetype plugin indent on set nocompatible set noexpandtab set shiftwidth=4 set tabstop=4 set softtabstop=4 set lbr set tw=500 set showbreak=-----> set nosmartindent set autoindent set nocindent set wrap "Wrap lines let g:PHP_vintage_case_default_indent = 1 let g:PHP_removeCRwhenUnix = 1

Here is a snapshot of plugins I'm using along with pathogen.

screen shot 2013-09-12 at 12 41 36 pm

Is there any settings that I need set or disabled? Or are there any plugins that can conflict with php-indent? Thanks!

2072 commented 11 years ago

try to disable simple-javacript-indenter.

Also not that the php indent script ignores HTML, it just let it as is, the only exception being the content of javascript tags.

webplantmedia commented 11 years ago

I had originally tested it on Vim 7.4 without any plugins activated. And the behavior was exactly the same. I'm not trying to get HTML indent to work inside *.php files. But I am trying to figure out why my php doesn't indent when outside <?php .. ?> as described in your examples under the section "A more complete example of its capabilities:"

What's the best way to reproduce this potential bug? Is this not a problem anyone else has had?

2072 commented 10 years ago

I don't understand what you mean, in the example you are referring to (http://www.2072productions.com/to/phpindent.txt ) indented PHP code is inside PHP tags... There is php code outside tags just to show that the indent script doesn't touch it.

webplantmedia commented 10 years ago

I'm sorry for not being clearer. In your documentation, you give a specific example of your php indent in action

screen shot 2013-09-23 at 2 25 18 pm

However, when I try to do the same thing inside of my php file, the php indent script produces the following

7c3ff112-1bd1-11e3-8db4-79df8215b6ee

What makes this particular problem inconvenient is that any new line of code inside my php file, when placed outside <?php ... ?>, always places my cursor in the first character position.

screen shot 2013-09-23 at 2 31 16 pm

I hope this is clearer. This is still a great plugin. I'm hoping it's something with my configuration. I tested this on a clean Vim 7.4 installation.

2072 commented 10 years ago

Actually, the problem is that the indent script doesn't support the alternative syntax you are using for control structure ( http://php.net/manual/en/control-structures.alternative-syntax.php ).

As for the example from my website not behaving the same, it's because you're missing the first lines :

<?php
if ($foo="thing") // as you see an opened bracket isn't needed to indent correctly
    if (foo("something"))
    {
        somethingelse("blabla");
?>
LaserMoai commented 6 years ago

Why is the alternative syntax not supported though?

2072 commented 6 years ago

Because I created this indentation script more than 13 years ago and you are the first person to ask this question.