Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ruthback's avatar

Auto-indentation not working on PHP files [Neovim]

Hi there,

I've reached the latest lecture released to date on the Neovim series, and went on to try it out on a project. Everything seems to be working fine except for the auto indentation when I'm inside a PHP file. Every other file I've tried works great: JavaScript, CSS, HTML and even Dockerfiles and .yml configuration files.

Because I was using VSCode in the meantime I'm not sure if this broke somewhere along the way... I've tried adding an ftplugin folder for php files, overriding the indentation options to random values to see if they worked but with no luck. Anyone able to help?

Here's the link to the question I posted on the course, it contains the link to the repo with my current setup. https://laracasts.com/series/neovim-as-a-php-ide/episodes/19?reply=22094

Thank you,

0 likes
2 replies
cwhite's avatar
cwhite
Best Answer
Level 19

You need to have indentation enabled in your treesitter config:

require('nvim-treesitter.configs').setup({
    ensure_installed = 'all',
    highlight = {
        enable = true,
    },
    -- Needed because treesitter highlight turns off autoindent for php files
    indent = {
        enable = true,
    },
    // ...
3 likes
ruthback's avatar

@cwhite Wow, thank you for noticing that. I could swear I tried this already but you are right, I was missing it. Thank you!

Please or to participate in this conversation.