0.18.11 • Published 2 months ago

coc-blade v0.18.11

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

coc-blade

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

Features

  • Format
  • Lint
  • Completion
    • Blade Snippets Completion
    • Blade Directive Completion
  • Definition
    • Jump to template file specified by @extends, @include directive, etc.
    • Jump to "Blade Components" file.
      • Warning Class-based Components are not supported.
    • Jump to "Jetstream Components" file.
  • Code Action
    • Add a blade comment to disable the formatting.
  • Hover

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

  • @yaegassy/coc-laravel
    • Various completions, definitions, references, hovers, diagnostics, codeActions, artisan and sail commands integration and more features for Laravel projects.
  • @yaegassy/coc-intelephense
    • intelephense (PHP language server) extension for coc.nvim. intelephense's various LSP features and this extension's additional features are available.
  • coc-html
    • html-related support will be added in blade

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:

  • :call CocAction('format')
  • :CocCommand bladeFormatter.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

  • blade.enable: Enable coc-blade extension, default: true
  • blade.completion.enable: Enable completion feature, default: true
  • blade.completion.enableDirective: Enable directive completion, default: true
  • blade.completion.enableSnippets: Enable snippets completion, default: true
  • blade.completion.excludeSnippets: Exclude specific prefix in snippet completion, e.g. ["b:extends", "lv:url", "Blade::component"], default: []
  • blade.bladeFormatter.enable: Enable/Disable the formatting feature by blade-formatter, default: true
  • blade.bladeFormatter.optIndentSize: Indent size, valid type integer or null, default: null,
  • blade.bladeFormatter.optWrapLineLength: The length of line wrap size, valid type integer or null, default: null
  • blade.bladeFormatter.optWrapAttributes: The way to wrap attributes, valid options ["auto", "force", "force-aligned", "force-expand-multiline", "aligned-multiple", "preserve", "preserve-aligned"], valid type string or null, default: null
  • blade.bladeFormatter.optEndWithNewLine: End output with newline, default: true
  • blade.bladeFormatter.optEndOfLine: End of line character(s), valid options ["LF", "CRLF"], valid type string or null, default: null
  • blade.bladeFormatter.optUseTabs: Use tab as indentation character, default: false
  • blade.bladeFormatter.optSortTailwindcssClasses: Sort Tailwindcss classes automatically. This option respects tailwind.config.js and sort classes according to settings, valid type boolean or null, default: null
  • blade.bladeFormatter.optSortHtmlAttributes: Sort HTML Attributes in the specified order, valid option ["none", "alphabetical", "code-guide", "idiomatic", "vuejs", "custom"], default: "none"
  • blade.bladeFormatter.optCustomHtmlAttributesOrder: Comma separated custom HTML attributes order. To enable this you must specify sort html attributes option as custom. You can use regex for attribute names, valid type string, string[] or null default: null
  • blade.bladeFormatter.optNoMultipleEmptyLines: Collapses multiple blank lines into a single blank line, default: false
  • blade.bladeFormatter.optNoPhpSyntaxCheck: Disable PHP syntax check. Enabling this will suppress PHP syntax error reporting, default: false
  • blade.bladeFormatter.optNoSingleQuote: Use double quotes instead of single quotes for php expression, default: false
  • blade.bladeFormatter.optWrapAttributesMinAttrs: Minimum number of html tag attributes for force wrap attribute options. Wrap the first attribute only if 'force-expand-multiline' is specified in wrap attributes, valid type integer or null, default: null
  • blade.bladeFormatter.optIndentInnerHtml: Indent <head> and <body> tag sections in html, default: false
  • blade.bladeFormatter.optNoTrailingCommaPhp: If set to true, no trailing commas are printed for php expression, default: false
  • blade.bladeFormatter.optExtraLiners: Comma separated list of tags that should have an extra newline before them, default: []
  • blade.bladeParserLint.enable: Enable/Disable the linting feature using stillat-blade-parser, default: true
  • blade.bladeParserLint.debug: Output the results of the parsing of stillat-blade-parser to the channel log, default: false
  • blade.bladeParserLint.optCustomIfs: A list of custom if directives, default: []
  • blade.bladeParserLint.optDirectives: A list of directives that can be parsed, default: []
  • blade.bladeParserLint.optIgnoreDirectives: A list of directive names that should be ignored, default: []

Commands

  • blade.showOutput: Show blade output channel
  • blade.bladeFormatter.run: Run blade-formatter
  • blade.showReferences: Show BladeDirective (@...) or BladeEcho ({{ ... }}, {!! ... !!}) location information for the current file

Code Actions

Example key mapping (Code Action related):

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

Actions:

  • Add "blade-formatter-disable-next-line" for this line
  • Add "blade-formatter-disable" for this line
  • Add "blade-formatter-enable" for this line
  • Add "blade-formatter-disable" for whole file

Thanks

License

MIT


This extension is built with create-coc-extension

0.18.11

2 months ago

0.18.10

2 months ago

0.18.9

3 months ago

0.18.8

3 months ago

0.17.2

9 months ago

0.17.0

9 months ago

0.17.1

9 months ago

0.18.1

9 months ago

0.18.2

9 months ago

0.18.3

8 months ago

0.18.4

7 months ago

0.18.5

7 months ago

0.18.6

7 months ago

0.18.7

6 months ago

0.18.0

9 months ago

0.16.6

10 months ago

0.16.7

10 months ago

0.16.8

10 months ago

0.16.9

10 months ago

0.16.4

10 months ago

0.16.5

10 months ago

0.16.3

11 months ago

0.16.1

12 months ago

0.16.2

12 months ago

0.14.17

1 year ago

0.15.0

1 year ago

0.16.0

1 year ago

0.14.16

1 year ago

0.14.15

1 year ago

0.14.13

1 year ago

0.14.14

1 year ago

0.14.12

1 year ago

0.14.11

1 year ago

0.14.10

1 year ago

0.14.6

1 year ago

0.14.7

1 year ago

0.14.8

1 year ago

0.14.9

1 year ago

0.14.5

1 year ago

0.14.0

2 years ago

0.14.1

2 years ago

0.14.2

2 years ago

0.14.3

2 years ago

0.14.4

1 year ago

0.13.12

2 years ago

0.13.7

2 years ago

0.13.8

2 years ago

0.13.9

2 years ago

0.13.11

2 years ago

0.13.10

2 years ago

0.13.6

2 years ago

0.13.0

2 years ago

0.11.28

2 years ago

0.13.1

2 years ago

0.11.29

2 years ago

0.13.2

2 years ago

0.13.3

2 years ago

0.13.4

2 years ago

0.13.5

2 years ago

0.11.30

2 years ago

0.11.31

2 years ago

0.11.32

2 years ago

0.11.37

2 years ago

0.11.33

2 years ago

0.11.34

2 years ago

0.11.35

2 years ago

0.11.36

2 years ago

0.12.0

2 years ago

0.12.1

2 years ago

0.11.20

2 years ago

0.11.21

2 years ago

0.11.26

2 years ago

0.11.27

2 years ago

0.11.22

2 years ago

0.11.23

2 years ago

0.11.24

2 years ago

0.11.25

2 years ago

0.11.19

2 years ago

0.11.17

2 years ago

0.11.18

2 years ago

0.11.9

2 years ago

0.11.10

2 years ago

0.11.15

2 years ago

0.11.16

2 years ago

0.11.11

2 years ago

0.11.12

2 years ago

0.11.13

2 years ago

0.11.14

2 years ago

0.11.8

2 years ago

0.11.0

2 years ago

0.11.1

2 years ago

0.11.2

2 years ago

0.11.3

2 years ago

0.11.4

2 years ago

0.11.5

2 years ago

0.11.6

2 years ago

0.11.7

2 years ago

0.9.0

2 years ago

0.9.2

2 years ago

0.7.4

2 years ago

0.9.1

2 years ago

0.7.3

2 years ago

0.7.6

2 years ago

0.7.5

2 years ago

0.7.8

2 years ago

0.7.7

2 years ago

0.10.0

2 years ago

0.8.0

2 years ago

0.7.2

2 years ago

0.7.1

2 years ago

0.7.0

2 years ago

0.6.7

2 years ago

0.6.6

2 years ago

0.6.9

2 years ago

0.6.8

2 years ago

0.6.10

2 years ago

0.6.12

2 years ago

0.6.11

2 years ago

0.6.13

2 years ago

0.6.3

2 years ago

0.6.2

2 years ago

0.6.5

2 years ago

0.6.4

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.3.2

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.1

2 years ago

0.4.2

2 years ago

0.3.3

2 years ago

0.3.0

2 years ago

0.2.1

3 years ago

0.2.3

2 years ago

0.2.2

3 years ago

0.2.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago