r/PHP • • Apr 05 '22

Use Vim as a PHP IDE

https://spacevim.org/use-vim-as-a-php-ide/
17 Upvotes

21 comments sorted by

22

u/supertoughfrog Apr 05 '22

This is cool, more options are good. Making phpstorm work like vim with the ideavim plugin works better for me than trying to make vim work like phpstorm.

5

u/naught-me Apr 05 '22

I agree, but they're both like 50% solutions at best. Just, if you're writing PHP, it's better to have 100% of PHPStorm and 50% of Vim, than vice-versa.

2

u/MattBD Apr 05 '22

I'd much rather have vice versa. My RSI makes using any IDE physically painful, and no other editor's vi/Vim mode has ever been up to scratch - the closest was Evil mode in Emacs.

If they were to make a language server I could use with Neovim via LSP I might consider using that.

2

u/supertoughfrog Apr 06 '22 edited Apr 06 '22

I feel like a phpstorm shill but its keyboard shortcuts are super configurable, and have good defaults. Not sure of a shortcut? Cmd+shift+a and search for "format code". The ideavim plugin is great out of the box as well, I can gd to go to definitions or find usages, and all the normal vim movements work, it also reads .vimrc files, there's an easymotion plugin as well. Navigating backwards and forwards works with cmd+[or]. Running tests: ctrl+shift+r. Go to the debugger cmd+5. Recent files cmd+e. I can set breakpoints and debug tests or php-fpm based apps.

If you put in the effort you can probably make almost any ide work well without a mouse, so I should just stop... I used vim with nerdtree and some fuzzy finding thing, etc... for a couple years, but it doesn't hold a candle to phpstorm as far as being a cohesive product. In my vim phase I scoffed at idea ide's but its because they're pretty ugly and cluttered by default but you can remove all the noise if you want, change the font (wow), themes (wow). Most the developers I work with use the default appearance and are mouse heavy which is a shame.

This article demonstrates how minimal you can make it: https://ntsanov.com/blog/phpstorm-but-better-getting-rid-of-the-distractions

1

u/MattBD Apr 06 '22

It's not impossible, but I really don't think it's worth it. It'd take at least a month to get to a point where I could even begin to see if I can make it work for me, and all that time I'd be having to struggle through a new workflow, possibly falling back in the bad habit of using the mouse in the meantime. I also sometimes have trouble with chording-style keyboard shortcuts - I'm generally OK with the modal ones too. The user interface bugs me too, in so many ways.

And I honestly haven't seen anything that PHPstorm can give me that I want and can't get. I use ALE to integrate Psalm and Codesniffer, and thanks to Phpactor I have pretty good completion and automated refactorings. Maybe if they extract the completion and stuff to an LSP server I might consider using that.

1

u/naught-me Apr 05 '22 edited Apr 05 '22

There is a pretty good language server that I use in NeoVim.

https://intelephense.com/

I bought the paid version and have been really happy with it - it's by far the best nvim experience I've had in any programming language, and was basically plug-and-play (I've put a lot more work into Python and C++, and they're both still pretty meh). Oh, but I am using Coc, not the built-in language server.

I've been developing RSI, myself - could you please share what particularly makes vim help you so much? I think I barely take advantage of what's there.

2

u/MattBD Apr 05 '22

I developed RSI during a previous career. Before I became a developer I was an insurance clerk, and grunt-level workers like me got crap keyboards and mice (you could only get an ergonomic keyboard if you were a manager or had already been diagnosed with RSI), and these were often gunked up all the time - if they weren't someone would inevitably come along and swap your clean one for their yucky one. It was the days of Windows XP, which wasn't great for keyboard shortcuts, and we used a lot of bespoke applications which were dreadfully inaccessible and didn't generally have any keyboard shortcuts at all. As such I had to use the (inevitably crappy and unresponsive mouse all the time), and started having problems after about five years of that.

My RSI is now mostly mouse-based. If I have to touch the mouse regularly, my hand starts feeling tired quite quickly, then becomes painful. I'm a little bit better off with a trackball, but I still have trouble if I have to use it more than about once every few minutes. However, as long as I have a decent keyboard (I use a Das Keyboard when working from home, and a Mac-style keyboard in the office) I don't have any issues typing for a long period.

As a result the big thing for me about using Vim (and Neovim in recent years) is that I can avoid touching the mouse for a long period of time. I run it in a terminal and explicitly disable all mouse support so that I'm never inclined to use it.

I do find the whole line completion (Ctrl-X Ctrl-L) to be a very useful tool that's often overlooked. But in all honesty it's more about the workflow than of any particular feature - I've never had a need to do much in the way of custom key mappings to deal with any particularly difficult stretches or anything like that. I do swear by PhpActor for automated refactorings and vim-fzf for fuzzy search, and like you I use Coc.nvim (although I currently use Phpactor's completions).

2

u/naught-me Apr 05 '22

Ah. I had the mouse thing creeping up, and I switched to a trackball that I use with my left hand. I highly recommend it.

My problem is that I've got a few fingers that are kind of lame from previous injuries. I really want to get into the Talon voice programming engine, when I can budget for one of the expensive mics they use.

10

u/ConsistentWish6441 Apr 05 '22

1

u/StrawberryFields4Eve Apr 05 '22

This is so good :))

1

u/ConsistentWish6441 Apr 05 '22

that guy is a gem

1

u/therealgaxbo Apr 05 '22

"gq5<up>"

Pffft. As if the sort of person who called themselves a Vim enthusiast on video would ever say that rather than "gq5k". Even acknowledging cursor keys exist at all is heresy to such people - let alone using them for basic motions.

I use cursors all the time

2

u/MattBD Apr 05 '22

I don't know how it would integrate with SpaceVim, but I use Neovim for writing PHP and find Phpactor indispensable for automated refactorings.

2

u/Hjine Apr 06 '22

This is a general guide for using SpaceVim as a PHP IDE,

2

u/pikknz Apr 05 '22

Is the answer not good? It kinda implies you are editing live servers which is bad. I do use it for editing config files sometimes.

2

u/therealgaxbo Apr 05 '22

It kinda implies you are editing live servers

What makes you say that? I'm not seeing anything in the post suggesting that.

1

u/usernameqwerty005 Apr 06 '22

Use Vim as Vim

Fixed ^^

1

u/[deleted] Apr 06 '22

Another, vim junky, wasting time where not needed, very sad times.

2

u/aleste2 Apr 07 '22

please buy our product instead!