Home

Awesome

coc-blade

Laravel Blade Templates extension for coc.nvim. Provides "formatter", "linter", "completion" and more...

<img width="760" alt="coc-blade-demo" src="https://user-images.githubusercontent.com/188642/135827583-09771a6d-2d14-48ee-bd9e-e1081ee3c8ad.gif">

Features

Install

CocInstall:

:CocInstall coc-blade

vim-plug:

Plug 'yaegassy/coc-blade', {'do': 'yarn install --frozen-lockfile'}

Recommended coc extension:

(Optional) Additional installation of laravel blade related coc-extension

Note

Filetype related

The "filetype" must be blade for this extension to work.

Install "blade" related plugin (e.g. jwalton512/vim-blade or sheerun/vim-polyglot or nvim-treesitter with tree-sitter-blade).

For more information on setup tree-sitter-blade in nvim-treesitter, please click here.

Usage Topics

formatter (blade-formatter)

Run:

If there is a "syntax error" in the blade template, the formatting will fail.

Configuration file: .bladeformatterrc.json or .bladeformatterrc:

To configure settings per project, put .bladeformatterrc.json or .bladeformatterrc to your project root will blade-formatter treat it as setting files.

Configuration file will like below:

{
    "indentSize": 4,
    "wrapAttributes": "auto",
    "wrapLineLength": 120,
    "endWithNewLine": true,
    "useTabs": false,
    "sortTailwindcssClasses": true
}

Ignoring Files: .bladeignore:

To ignore specific file, put .bladeignore to your repository root will blade-formatter treat it as ignored files.

resources/views/users/index.blade.php
resources/views/products/*
resources/views/books/**/*

Disabling format in file:

In coc-blade, there is a code action feature to add a blade comment to disable the formatting.

linter (using Stillat/blade-parser-typescript)

This feature is enabled by default. If you do not need the linter feature, set blade.bladeParserLint.enable to false

snippets completion (laravel-blade-snippets-vscode)

You can auto-complete by typing b:, lv:, Blade::, livewire::.

It uses snippet files from onecentlin/laravel-blade-snippets-vscode to provide completion.

directive completion

You can auto-complete by typing @.

Configuration options

Commands

Code Actions

Example key mapping (Code Action related):

nmap <silent> ga <Plug>(coc-codeaction-line)
nmap <silent> gA <Plug>(coc-codeaction)

Actions:

Thanks

License

MIT


This extension is built with create-coc-extension