Skip to content

Commit

Permalink
docs: add supported sources & sort rule-data
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed Sep 21, 2023
1 parent 972da2e commit 760e81d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<!-- TODO uncomment shields when available in dotfyle.com -->
<!-- <a href="https://dotfyle.com/plugins/chrisgrieser/nvim-rulebook"><img src="https://dotfyle.com/plugins/chrisgrieser/nvim-rulebook/shield" /></a> -->

Add inline-comments to rules. Lookup rule documentation online.
1. Lookup rule documentation online.
2. Add inline-comments that ignore diagnostic rules, like `// eslint-disable-line [ruleName]`.

Some LSPs provide code actions for to do that – this plugin adds commands for linters and LSPs that don't.

<!--toc:start-->
- [Features](#features)
- [Supported Sources](#supported-sources)
- [For adding ignore comments](#for-adding-ignore-comments)
- [For looking up rule documentation](#for-looking-up-rule-documentation)
Expand All @@ -18,34 +18,40 @@ Some LSPs provide code actions for to do that – this plugin adds commands for
- [Credits](#credits)
<!--toc:end-->

## Features
- Add inline-comments that ignore diagnostic rules.
- Location of the ignore comment, like next line or previous line, is configurable.
- Perform a web search for a diagnostic rule.
- Requires diagnostics provided by a source that supports neovim's builtin diagnostics system (`vim.diagnostic`). nvim's builtin LSP client and [nvim-lint](https://github.com/mfussenegger/nvim-lint) are such sources.

## Supported Sources
You easily add a custom source via the [plugin configuration](#configuration). However, please consider making a PR to add support for a linter if it is missing.
You easily add a custom source via the [plugin configuration](#configuration). Though, please consider making a PR to add support for a linter if it is missing.

[Ignore Rule Data for the supported linters](./lua/rulebook/ignoreRuleData.lua)
[Rule Data for the supported linters](./lua/rulebook/rule-data.lua)

### For adding ignore comments
<!-- TODO: auto-generate this list -->
- selene
- shellcheck
- vale
- LTeX
- yamllint
- stylelint
- LTeX
- typescript
- eslint
- biome
- pylint
- Pyright

### For looking up rule documentation
- selene
- shellcheck
- pylint
<!-- TODO: auto-generate this list -->
- selene
- shellcheck
- biome
- yamllint
- stylelint
- eslint
- Lua Diagnostics
- pylint
- fallback

## Installation
> [!NOTE]
> This plugin requires diagnostics provided by a source that supports neovim's builtin diagnostics system. (nvim's builtin LSP client or [nvim-lint](https://github.com/mfussenegger/nvim-lint) are such sources.)
```lua
-- lazy.nvim
Expand Down Expand Up @@ -113,7 +119,6 @@ defaultConfig = {
## Limitations
- The diagnostics have to contain the necessary data, [that is a diagnostic code and diagnostic source](https://neovim.io/doc/user/diagnostic.html#diagnostic-structure). Most LSPs and most linters configured for `nvim-lint` do that, but some diagnostic sources do not (for example `efm-langserver` with incorrectly defined errorformat). Please open an issue at the diagnostics provider to fix.
- This plugin does *not* hook into `vim.lsp.buf.code_action`, but provides its own independent selector.
- As opposed to [null-ls](https://github.com/jose-elias-alvarez/null-ls.nvim)'s code action feature, this plugin does not support arbitrary code actions, but only actions based on a diagnostic.

## Credits
<!-- vale Google.FirstPerson = NO -->
Expand Down
13 changes: 7 additions & 6 deletions lua/rulebook/rule-data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ local M = {}

---@type table<string, ruleIgnoreConfig>
M.ignoreComments = {
Pyright = {
comment = "# pyright: ignore %s",
location = "sameLine",
docs = "https://microsoft.github.io/pyright/#/comments",
},
shellcheck = {
comment = "# shellcheck disable=%s",
location = "prevLine",
Expand Down Expand Up @@ -52,6 +47,11 @@ M.ignoreComments = {
location = "sameLine",
docs = "https://pylint.readthedocs.io/en/latest/user_guide/messages/message_control.html",
},
Pyright = {
comment = "# pyright: ignore %s",
location = "sameLine",
docs = "https://microsoft.github.io/pyright/#/comments",
},
eslint = {
comment = "// eslint-disable-line %s",
location = "sameLine",
Expand All @@ -76,9 +76,10 @@ M.ignoreComments = {
M.ruleDocs = {
selene = "https://kampfkarren.github.io/selene/lints/%s.html",
shellcheck = "https://www.shellcheck.net/wiki/SC%s",
biome = "https://biomejs.dev/linter/rules/%s",
yamllint = "https://yamllint.readthedocs.io/en/stable/rules.html#module-yamllint.rules.%s",

stylelint = "https://stylelint.io/user-guide/rules/%s",
biome = "https://biomejs.dev/linter/rules/%s",
eslint = "https://eslint.org/docs/latest/rules/%s",

-- source name for lua_ls
Expand Down

0 comments on commit 760e81d

Please sign in to comment.