jwalton512 / vim-blade

Vim syntax highlighting for Blade templates.
226 stars 37 forks source link

Add support to eclim indent #41

Closed jn-jairo closed 8 years ago

jn-jairo commented 8 years ago

Currently indentation is based on the function HtmlIndent which is the default.

But there are plugins that add their own indentation. The eclim is one of those.

It is good to give the user option to continue using HTML and PHP indenting of your favorite plugin and only add the Blade indentation.

I added a check to see which base indentation should follow, if none is defined or is not valid, will use the default HtmlIndent. It also checks if the required function exists.

For now I only know eclim, but if someone inform other cases like this, it will be easy to add.

This change does not alter the operation of anyone, even if you use the eclim.

If someone has the eclim and want to use the standard indentation eclim and only add the indentation blade, just add in your .vimrc the following line:

let g:BladeIndentBase = 'eclim'

The main difference in eclim indentation is that it increases the indentation when there is line break between attributes.

Default:

<input name="example"
value="example" />

Eclim:

<input name="example"
        value="example" />

It was this difference that I realized I had something was out of the pattern of other files.

jwalton512 commented 8 years ago

Hi @jn-jairo, thanks for the pull request. I'm not overly familiar with eclim, but I believe I understand the concern and objective here.

I would like to modify the implementation a bit, though. I would like to make it less specific to eclim. How about if we just check for the existence of some function and if it exists we use that as the default. So eclim users could create this function and just have it call the eclim function mentioned in the code.

This way if there are other vim customizations like eclim, those users can use this enhancement as well.

Let me know if that makes sense.

jn-jairo commented 8 years ago

Great idea, I tested here and is working. Take a look to see if that's what you meant.

I tried adding the following in vimrc and it worked perfectly.

function! GetBladeIndentCustom()
    return EclimGetPhpHtmlIndent(v:lnum)
endfunction
jwalton512 commented 8 years ago

@jn-jairo Yep, that looks perfect.

jn-jairo commented 8 years ago

Done, I updated the branch

jwalton512 commented 8 years ago

Thanks for the contributions @jn-jairo !