### Install Herb Language Server with bun
Source: https://github.com/marcoroth/herb/blob/main/docs/docs/integrations/editors/neovim.md
Install the Herb Language Server globally using bun. This is a prerequisite for manual configuration and some other setup methods.
```bash
bun add -g @herb-tools/language-server
```
--------------------------------
### Quick Start Herb Language Server with NPX
Source: https://github.com/marcoroth/herb/blob/main/docs/docs/integrations/editors.md
Run the Herb Language Server without a global installation using npx. This is convenient for testing or temporary use.
```bash
npx @herb-tools/language-server --stdio
```
--------------------------------
### Install Herb Language Server with yarn
Source: https://github.com/marcoroth/herb/blob/main/docs/docs/integrations/editors/neovim.md
Install the Herb Language Server globally using yarn. This is a prerequisite for manual configuration and some other setup methods.
```bash
yarn global add @herb-tools/language-server
```
--------------------------------
### Install Herb Language Server with npm
Source: https://github.com/marcoroth/herb/blob/main/docs/docs/integrations/editors/neovim.md
Install the Herb Language Server globally using npm. This is a prerequisite for manual configuration and some other setup methods.
```bash
npm install -g @herb-tools/language-server
```
--------------------------------
### Install Herb Language Server with pnpm
Source: https://github.com/marcoroth/herb/blob/main/docs/docs/integrations/editors/neovim.md
Install the Herb Language Server globally using pnpm. This is a prerequisite for manual configuration and some other setup methods.
```bash
pnpm add -g @herb-tools/language-server
```
--------------------------------
### Setup Herb LS with nvim-lspconfig (nvim 0.11+)
Source: https://github.com/marcoroth/herb/blob/main/docs/docs/integrations/editors/neovim.md
Configure the Herb Language Server using nvim-lspconfig for Neovim versions 0.11 and above. Ensure the server is installed globally first.
```lua
require('lspconfig')
vim.lsp.enable('herb_ls')
```
--------------------------------
### Install npm Modules
Source: https://github.com/marcoroth/herb/blob/main/javascript/packages/vscode/CONTRIBUTING.md
Run this command in the project directory to install all necessary npm modules for both the client and server.
```bash
yarn install
```
--------------------------------
### Install stimulus-lint with bun
Source: https://github.com/marcoroth/herb/blob/main/javascript/packages/stimulus-lint/README.md
Use this command to install stimulus-lint using bun.
```shell
bun add stimulus-lint
```
--------------------------------
### Example .herb.yml configuration
Source: https://github.com/marcoroth/herb/blob/main/javascript/packages/config/README.md
This is an example of a `.herb.yml` file, which is used for project-specific configuration. It defines settings for the linter and formatter.
```yaml
version: 0.10.1
linter:
enabled: true
rules:
erb-no-extra-newline:
enabled: false
formatter:
enabled: true
indentWidth: 2
maxLineLength: 120
```
--------------------------------
### Setup Herb LS with nvim-lspconfig (nvim <= 0.10)
Source: https://github.com/marcoroth/herb/blob/main/docs/docs/integrations/editors/neovim.md
Configure the Herb Language Server using nvim-lspconfig for Neovim versions 0.10 and below. Ensure the server is installed globally first.
```lua
require('lspconfig').herb_ls.setup()
```
--------------------------------
### Example Herb Configuration File
Source: https://github.com/marcoroth/herb/blob/main/javascript/packages/language-server/README.md
An example of a .herb.yml configuration file for the Herb tools, including settings for the linter and formatter.
```yaml
# .herb.yml
linter:
enabled: true
formatter:
enabled: true
indentWidth: 2
maxLineLength: 80
```
--------------------------------
### GitHub Actions Output Example (Simple)
Source: https://github.com/marcoroth/herb/blob/main/javascript/packages/linter/README.md
This example demonstrates the output when using the `--github` flag with the simple format. It provides minimal local output while still generating GitHub Actions annotations.
```text
::error file=template.html.erb,line=3,col=3,title=html-img-require-alt • @herb-tools/linter@0.10.1::Missing required `alt` attribute on `` tag [html-img-require-alt]%0A%0A%0Atemplate.html.erb:3:3%0A%0A 1 │
%0A │ ~~~%0A 4 │
%0A │ ~~~%0A 4 │
│ ~~~
4 │
Hello
```
--------------------------------
### Herb Formatter Help and Version
Source: https://github.com/marcoroth/herb/blob/main/javascript/packages/formatter/README.md
Display help information or the version of the Herb Formatter.
```bash
# Show help
herb-format --help
# Show version information
herb-format --version
```
--------------------------------
### Herb Usage (Browser and Node.js)
Source: https://github.com/marcoroth/herb/blob/main/docs/docs/bindings/javascript/reference.md
Demonstrates how to import and use the Herb library in both browser and Node.js environments. It shows the basic steps of loading the library and parsing content.
```APIDOC
## Herb Usage (Browser and Node.js)
### Description
The `Herb` object can be imported from either `@herb-tools/browser` or `@herb-tools/node`. The API remains consistent across both packages.
### Request Example
```js
// Browser
import { Herb } from "@herb-tools/browser"
await Herb.load()
Herb.parse("content")
// Node.js
import { Herb } from "@herb-tools/node"
await Herb.load()
Heb.parse("content")
```
### Further Information
Learn more on [how to install and load the NPM packages](/bindings/javascript/#installation).
```
--------------------------------
### Left Trim at Start of File
Source: https://github.com/marcoroth/herb/blob/main/test/snapshots/engine/whitespace_trimming_test/test_0014_left_trim_at_start_of_file_688979d30ffb1ebd7ad117f92729aa2c.txt
Demonstrates left trimming at the beginning of a template file. Ensure the template syntax is correctly applied for trimming to take effect.
```Ruby
Engine::WhitespaceTrimmingTest#test_0014_left trim at start of file
input: "{source: \"<%- if true %>\\nContent\\n<%- end %>\", locals: {}, options: {}}"
```
--------------------------------
### Configure ALE for Herb (Generic LSP)
Source: https://github.com/marcoroth/herb/blob/main/docs/docs/integrations/editors/vim.md
Use ALE's generic LSP support for a simpler setup with the Herb language server. This involves registering the LSP server with ALE.
```vim
let g:ale_linters = {
\ 'eruby': ['ale_lsp'],
\ 'erb': ['ale_lsp'],
\ }
augroup AleHerbLSP
autocmd!
autocmd User ALEWantResults call ale#lsp#RegisterLSP('eruby', {
\ 'name': 'herb-language-server',
\ 'executable': 'herb-language-server',
\ 'command': '%e --stdio',
\ 'project_root': {buffer -> ale#path#FindNearestDirectory(buffer, '.git')},
\ })
augroup END
```
--------------------------------
### Install Herb Formatter as a Dev Dependency
Source: https://github.com/marcoroth/herb/blob/main/javascript/packages/formatter/README.md
Install the Herb Formatter as a development dependency in your project using npm, pnpm, yarn, or bun.
```shell
npm add -D @herb-tools/formatter
```
```shell
pnpm add -D @herb-tools/formatter
```
```shell
yarn add -D @herb-tools/formatter
```
```shell
bun add -D @herb-tools/formatter
```
--------------------------------
### Install Herb VS Code Extension
Source: https://github.com/marcoroth/herb/blob/main/docs/docs/integrations/editors/vscode.md
Install the Herb extension from the VS Code Marketplace to enable code generation and analysis features.
```bash
code --install-extension herb.herb-vscode
```
--------------------------------
### Inspect General Configuration with `herb config`
Source: https://github.com/marcoroth/herb/blob/main/docs/docs/configuration.md
Use the `bundle exec herb config` command to view the overall resolved configuration, including project root, config file path, and all include/exclude patterns.
```bash
bundle exec herb config
```
--------------------------------
### Invalid ARIA Attributes Example
Source: https://github.com/marcoroth/herb/blob/main/javascript/packages/linter/docs/rules/html-aria-attribute-must-be-valid.md
Examples of incorrectly used ARIA attributes, including typos and unsupported attributes, which will be ignored by assistive technologies.
```html
Hello