8 votes

Does emacs or vim have better support for PHP parameter hinting and intellisense?

In the coming days, I'm going to give a serious try to one of these "super flexible but super high learning curve editors" called vim and emacs. I'm just unable to make up my mind on which one though I've heard and read many good things about both.

Right now I use Notepad++ and php type hints is one of the essential features I highly depend on. When I type a php function call such as strpos(, NPP shows the function signature in tooltip.

From my initial research so far, I came to know that none of these editors provide this basic feature out of the box, at least not without some tweaks. For example, vim does provide something called "omni-box" when you press C-X C-O but even in that case, it won't show the popup/hint in case of a single completion option (for that you have to enable the menuone option as described here).

The point is that I want to have a seamless and comfy PHP editing environment without spending a lot of time on these tweaks - I might invest some learning time if there is more utility in the long term, especially compared to what I currently get from Notepad++. How does emacs fare in this regard? Is there better PHP support than vim for that?

Finally, I'm already ruling out the "heavy" IDEs like Eclipse PDT and PHP Storm as my laptop configuration isn't that high, it has an Intel Atom processor and just 2 GB RAM which crawls if I try to put too much load on it.

16 comments

  1. [7]
    lou
    Link
    Emacs is all about tweaking. I'm not a programmer. I don't really know the answer, but I've used Emacs intensely for many years. From experience, it's unlikely that Emacs has superior PHP support...

    From my initial research so far, I came to know that none of these editors provide this basic feature out of the box, at least not without some tweaks.

    Emacs is all about tweaking.

    I'm not a programmer. I don't really know the answer, but I've used Emacs intensely for many years. From experience, it's unlikely that Emacs has superior PHP support than something like VSCode. There are many reasons to use Emacs. IDE-like support for modern languages is not one of them. At the most, it is just as good as everything else, and definitely more flexible, but expect having to put in significant work to achieve your "nirvana". Emacs is like a toy that arrives disassembled -- it's about giving you the power and ability to get what you want if you put in the work.

    To start off, take a look a Doom Emac's PHP layer: https://docs.doomemacs.org/v21.12/modules/lang/php/. Doom is awesome and facilitates things, but still, don't expect a tweaks-free IDE-like experience.

    Edit: the same is largely true about Vim and Neovim.

    9 votes
    1. [6]
      pyeri
      Link Parent
      Literally, the only two features I absolutely need are type hinting and intellisense/omni-completion. As a third one, going to function definition would be nice to have with CTAGS or something but...

      IDE-like support for modern languages is not one of them.

      Literally, the only two features I absolutely need are type hinting and intellisense/omni-completion. As a third one, going to function definition would be nice to have with CTAGS or something but that's it. The bloated IDEs provide a zillion other functions but I need only these at most. I'm prepared to invest time in vim/emacs provided it's even possible to have these with tweaking.

      Thanks for the link, will have a look at it.

      1 vote
      1. cstby
        Link Parent
        On emacs, intellisense is often achieved with LSP, and it looks like there's a well-supported LSP sever for PHP.

        On emacs, intellisense is often achieved with LSP, and it looks like there's a well-supported LSP sever for PHP.

        5 votes
      2. [2]
        pyeri
        Link Parent
        Sometimes, your own comment feels absolutely illuminating and awakening to you and this is just one of those moments! I just came to realize that NPP already has everything I need and there is not...

        Literally, the only two features I absolutely need are type hinting and intellisense/omni-completion.

        Sometimes, your own comment feels absolutely illuminating and awakening to you and this is just one of those moments! I just came to realize that NPP already has everything I need and there is not real pragmatic benefit of learning vim right now (apart from it being a bragging point for undergoing a steeper learning curve with some muscle memory). I'll still try to learn it as a side learning project as I get time.

        1. TangibleLight
          Link Parent
          I think there's a real benefit to remapping CapsLock and learning vim motions. They're much more comfortable after some practice since you're not reaching for the mouse, arrow keys, or...

          I think there's a real benefit to remapping CapsLock and learning vim motions. They're much more comfortable after some practice since you're not reaching for the mouse, arrow keys, or Home/End/etc. block nearly as much. Specifically the Insert/Normal mode concept, hjkl movement, and a few select others.

          There's also value in setting up a language server for things like inline documentation, goto definition, search references. It makes navigating big projects much faster. Sure, you can approximate it with search-in-directory, but it's nice to just get straight to the definition without skimming over search results and losing your train of thought.

          You don't necessarily need vim specifically to do either of those, although I don't think you'll be able to do it with npp.

          I tried switching to Neovim cold-turkey and, while it was illuminating, I don't really think it's worth all the fuss for its minimalism. Setting up innumerable plugins for each thing that I miss gets old fast.

          I've since switched back to the JetBrains suite, mainly for multi-cursor editing, but with IdeaVim for vim motions. I am aware of multicursors.nvim but the learning curve of another interaction mode with another set of bespoke keybinds was the final straw that lured me back to JetBrains. IdeaVim handles it seamlessly in visual and insert modes by default.

          1 vote
  2. [3]
    unkz
    Link
    I’m not a php programmer, but this is what most php programmers use with vim. I should add, you probably want to use neovim rather than vim....

    I’m not a php programmer, but this is what most php programmers use with vim. I should add, you probably want to use neovim rather than vim.

    https://phpactor.readthedocs.io/en/master/usage/vim-plugin.html

    https://github.com/phpactor/phpactor

    5 votes
    1. bitwyze
      Link Parent
      Lazy is also a good plugin manager for neovim. Pretty easy to configure and helps make the environment faster by lazy loading extensions.

      Lazy is also a good plugin manager for neovim. Pretty easy to configure and helps make the environment faster by lazy loading extensions.

      2 votes
    2. dsh
      Link Parent
      I have made the move to NeoVim + Phpactor from PhpStorm and I find it works almost just as good these days. I'd vouch for this combination.

      I have made the move to NeoVim + Phpactor from PhpStorm and I find it works almost just as good these days. I'd vouch for this combination.

      2 votes
  3. [4]
    fxgn
    Link
    They'd both use the same LSP server, so this functionality would essentially be identical in both of them. IMO you should go with Neovim if you want a lightweight, configurable editor. It's much...

    They'd both use the same LSP server, so this functionality would essentially be identical in both of them. IMO you should go with Neovim if you want a lightweight, configurable editor. It's much easier to configure than Emacs, is very quick at integrating modern features, and has an awesome community. I think Emacs is only good if you either:

    1. Want to configure everything - there's some stuff that can't be changed in nvim, and although that's not a lot, some people need that functionality enough that they use Emacs
    2. You like the Emacs way of doing everything in your editor

    If you just want to write PHP, I think Neovim would be easier. But again, the code completion itself will be the same, as it'll be provided by the exact same language server.

    (Also I'm not mentioning regular Vim because there's basically no reason to use it)

    4 votes
    1. [3]
      joelthelion
      Link Parent
      For what it's worth, regular vim has improved tremendously. I use it with lsp and copilot, I don't think it's missing anything. It's also rock solid. Why should I switch?

      (Also I'm not mentioning regular Vim because there's basically no reason to use it)

      For what it's worth, regular vim has improved tremendously. I use it with lsp and copilot, I don't think it's missing anything. It's also rock solid. Why should I switch?

      2 votes
      1. fxgn
        Link Parent
        For me it's mostly the fact that Neovim has a much bigger plugin ecosystem, since the plugins and configurations are written in a nice language instead of a weird DSL. For the same reason, it's...

        Why should I switch?

        For me it's mostly the fact that Neovim has a much bigger plugin ecosystem, since the plugins and configurations are written in a nice language instead of a weird DSL. For the same reason, it's also easier to configure if you need to do anything more complicated then setting an option.

        Also Neovim has built-in LSP. And treesitter. Treesitter is one of my favorite features, I can barely imagine using nvim without it.

        3 votes
      2. TintedJellyfish
        Link Parent
        Vim's development pace has definitely accelerated considerably. I've recently tried neovim on a new setup and found it had some small differences in behaviour that were sort of off-putting to...

        Vim's development pace has definitely accelerated considerably. I've recently tried neovim on a new setup and found it had some small differences in behaviour that were sort of off-putting to me... Nothing major but also not configurable since it is "working as intended." I think if you're happy, staying with vim is just fine :>

        1 vote
  4. DrStone
    Link
    Take a moment to consider why you want to switch from your current editor, or any modern IDE, to emacs or vim. For me, I started with and would recommend vim. More specifically, get fluent in...

    Take a moment to consider why you want to switch from your current editor, or any modern IDE, to emacs or vim.

    For me, I started with and would recommend vim. More specifically, get fluent in vanilla vim first, as an editor, before you customize and install plugins. Why? For all intents and purposes, it is everywhere, unlike emacs. No matter what system you’re on, what you ssh remote into, fresh install or long lived, default configured vim will be there. If you know vim, you can be productive immediately anywhere instead of learning or fiddling with the editor itself.

    Further, the vim keybindings have made their way into various other applications over the years - at least as an option - so learning them benefits beyond just vim.

    If you’d prefer to customize every aspect of Lisp-based operating system that happens to include a ok text editor, then emacs is the way to go.

    4 votes
  5. conniereynhart
    Link
    I don't really have a recommendation regarding Vim or Emacs. A colleague of mine swears by emacs, and basically does all his tasks (including things like keeping a todo-list) with it. Both are...

    I don't really have a recommendation regarding Vim or Emacs. A colleague of mine swears by emacs, and basically does all his tasks (including things like keeping a todo-list) with it. Both are highly customizable as far as I can tell.

    I just wanted to say - since you mentioned you don't want any heavy editors like Eclipse - you might want to give VS Code a try, yoo. You'll find plenty of extensions for PHP for sure. These extensions can be installed directly from within VS code itself. I am finding myself often editing code in VS Code when I don't want to fire up heavier IDEs like IntelliJ.

    1 vote