Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php indenting inside html #5962

Open
adpce opened this issue Jan 23, 2024 · 0 comments
Open

php indenting inside html #5962

adpce opened this issue Jan 23, 2024 · 0 comments
Labels
bug Something isn't working indent Issues or PRs about indentation queries or module

Comments

@adpce
Copy link

adpce commented Jan 23, 2024

Describe the bug

In php files, using php tags in html results in the php inside these tags being indented incorrectly.

To Reproduce

  1. Open nvim with an empty php file.
  2. Write some html, then add php tags.
  3. Notice that the php doesn't indent.
  4. Observe that gg=G doesn't fix the issue.

Expected behavior

Ideally, the php inside the php tags should observe the same indenting rules as any other php.

Output of :checkhealth nvim-treesitter

nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- OK `tree-sitter` found 0.20.8 (660481dbf71413eba5a928b0b0ab8da50c1109e0) (parser generator, only needed for :TSInstallFromGrammar)
- WARNING `node` executable not found (only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "x86_64",
  release = "5.19.0-32-generic",
  sysname = "Linux",
  version = "#33~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jan 30 17:03:34 UTC 2"
} ~

Parser/Features         H L F I J
  - bash                ✓ ✓ ✓ . ✓
  - c                   ✓ ✓ ✓ ✓ ✓
  - css                 ✓ . ✓ ✓ ✓
  - fish                ✓ ✓ ✓ ✓ ✓
  - git_config          ✓ . ✓ . ✓
  - gitcommit           ✓ . . . ✓
  - html                ✓ ✓ ✓ ✓ ✓
  - javascript          ✓ ✓ ✓ ✓ ✓
  - json                ✓ ✓ ✓ ✓ .
  - lua                 ✓ ✓ ✓ ✓ ✓
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . . ✓
  - php                 ✓ ✓ ✓ ✓ ✓
  - php_only            ✓ ✓ ✓ ✓ ✓
  - python              ✓ ✓ ✓ ✓ ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - rust                ✓ ✓ ✓ ✓ ✓
  - scss                ✓ . ✓ ✓ .
  - sql                 ✓ . . ✓ ✓
  - ssh_config          ✓ ✓ ✓ ✓ ✓
  - toml                ✓ ✓ ✓ ✓ ✓

Output of nvim --version

NVIM v0.10.0-dev-2170+g8b2365369
Build type: Release
LuaJIT 2.1.1705947465
Run "nvim -V1 -v" for more info

Additional context

Here is simple code that reproduces the problem (after gg=G), so you can verify:

<?php require('/example.php'); ?>
<?php
$var = 0;
?>

<div>
        <div>
                <div>
                        <?php
                        if ($var > 0) {
                        echo 'yes';
                        } else {
                        echo 'no';
                        }
                        ?>
                </div>
        </div>
        <?php
        if ($var > 0) {
        echo 'yes';
        } else {
        echo 'no';
        }
        ?>
</div>

How it should look:

<?php require('/example.php'); ?>
<?php
$var = 0;
?>

<div>
        <div>
                <div>
                        <?php
                        if ($var > 0) {
                            echo 'yes';
                        } else {
                            echo 'no';
                        }
                        ?>
                </div>
        </div>
        <?php
        if ($var > 0) {
            echo 'yes';
        } else {
            echo 'no';
        }
        ?>
</div>

Treesitter config in lua:

require'nvim-treesitter.configs'.setup {
        -- A list of parser names, or "all" (the five listed parsers should always be installed)
        ensure_installed = {
                "bash",
                "c",
                "css",
                "fish",
                "git_config",
                "gitcommit",
                "html",
                "javascript",
                "json",
                "lua",
                "php",
                "php_only",
                "query",
                "rust",
                "scss",
                "sql",
                "ssh_config",
                "toml",
                "vim",
                "vimdoc"
        },

        -- Install parsers synchronously (only applied to `ensure_installed`)
        sync_install = false,

        -- Automatically install missing parsers when entering buffer
        -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
        auto_install = true,

        highlight = {
                enable = true,
                additional_vim_regex_highlighting = false
        },

        incremental_selection = {
                enable = true
        },

        indent = {
                enable = true
        }
}

Thank you for your time.

@adpce adpce added the bug Something isn't working label Jan 23, 2024
@clason clason added the indent Issues or PRs about indentation queries or module label Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working indent Issues or PRs about indentation queries or module
Projects
None yet
Development

No branches or pull requests

2 participants