Skip to content

Commit

Permalink
Add compound filetype support note to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mfussenegger committed Feb 6, 2025
1 parent 0f42a8b commit 6e9dd54
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,21 @@ require('lint').linters_by_ft = {
```

To get the `filetype` of a buffer you can run `:= vim.bo.filetype`.
The `filetype` can also be a compound `filetype`. For example, if you have a buffer
with a `filetype` like `yaml.ghaction`, you can use either `ghaction`, `yaml` or
the full `yaml.ghaction` as key in the `linters_by_ft` table and the linter
will be picked up in that buffer. This is useful for linters like
[actionlint][actionlint] in combination with `vim.filetype` patterns like
`[".*/.github/workflows/.*%.yml"] = "yaml.ghaction",`

Then setup a autocmd to trigger linting. For example:

Then setup a `autocmd` to trigger linting. For example:

```vimL
au BufWritePost * lua require('lint').try_lint()
```

or with Lua autocmds:
or with Lua auto commands:

```lua
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
Expand All @@ -70,7 +77,7 @@ vim.api.nvim_create_autocmd({ "BufWritePost" }, {
```

Some linters require a file to be saved to disk, others support linting `stdin`
input. For such linters you could also define a more aggressive autocmd, for
input. For such linters you could also define a more aggressive `autocmd`, for
example on the `InsertLeave` or `TextChanged` events.


Expand Down

0 comments on commit 6e9dd54

Please sign in to comment.