2

I currently have my php-mode configuration like so:

(require 'php-mode)
(add-hook 'php-mode-hook
          (lambda ()
             (require 'ac-php-company)
             (company-mode t)
             (setq c-syntactic-indentation nil)
             (setq indent-tabs-mode t)
             (setq tab-width 4)
             (setq c-basic-indent 4)
             (c-set-offset 'topmost-intro 4)
             (c-set-offset 'cpp-macro -4)
             (add-to-list 'company-backends 'company-ac-php-backend)))

I would like to use this configuration to start using web-mode and have php in web-mode use this configuration, however I can't seem to figure out how to configure php in web-mode.

How would I use this configuration for php in web-mode?

EDIT

I should probably clarify a little better what I am trying to achieve for the PHP portion of web-mode.

One thing I do in php-mode is have it configured to indent my PHP code inside the <?php block like so:

<?php

    echo "hello world";
    do_some_func();

This is one of the main things I would like to do in web-mode, along with use company as my auto-complete engine.

Would anyone be able to provide me with examples or point me in the direction of solving this problem?

EDIT 2

Thanks to the comment by phils I was able to get my indentation set up correctly, however I still can't figure out how to set up company php in web mode, and googling doesn't seem to provide me with any answers. Any help would be much appreciated.

Sorry for not being as clear originally.

Damon Swayn
  • 121
  • 3
  • n.b. In general use `(lambda...)` not `'(lambda...)`. Quoted lambda forms cannot be compiled. But even better, define some named function `foo` and use `'foo` instead (I would suggest `my-php-mode-hook` as a name). Anonymous functions in hook variables makes them awkward to update without leaving old versions of the function in the hook as well, whereas your `foo` function can be reevaluated at any time, and the hook will use the new version automatically. – phils Apr 19 '16 at 00:00
  • Use `M-x customize-group RET web-mode` to browse the options provided by `web-mode`. You will need to figure out which `web-mode`-specific variables you need to configure. I would *guess* that it won't recognise the `php-mode` variables at all (but others will probably be able to tell you more). – phils Apr 19 '16 at 00:05

1 Answers1

0

For indentation,

(setq indent-tabs-mode t)
(setq web-mode-markup-indent-offset 4) ; web-mode, html tag in html file
(setq web-mode-css-indent-offset 4) ; web-mode, css in html file
(setq web-mode-code-indent-offset 4) ; web-mode, js code in html file

BTW, I don't think you need mix auto-complete and company-mode, just stick to company.

For code completion, see my answer for another question,

PHP completion with Company does not work on local variables

chen bin
  • 4,781
  • 18
  • 36
  • No, that's no the only setup he needs. He still needs to instantiate Web mode for php/etc files. Which is well documented on the Web mode Web page. – RichieHH Dec 08 '19 at 12:24