Skip to content

chore: cleaner readme #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 30 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
## guard.nvim

Asynchronous formatting and lint checking plug-ins, I personally don't like the way that handle lsp
request then get data from thirty part tool. Accept lsp request or notify then spawn tool then
get result and send back. Why add a process in the middle, There is a proverb in China called
**Paint a snake with feet**. and lsp is getting dumber 👿
Async formatting and linting utility for neovim. I personally don't like the way that third party formatters and linters have to be requested via the lsp interface. Why add another process in the middle. There is a proverb in China called **Paint a snake with feet**. It's making lsp dumber 👿

## Features

- Blazing fast
- Blazingly fast
- Async using coroutine and luv spawn
- Support config mulitple tools for format or lint on buffer
- Builtin support for popular formatters and linters
- Light-weight

## Setup
## Usage

use any plugin manager you like then call setup
Use any plugin manager you like. Guard is configured in format like this:

```lua
--config must before this line
require('guard').setup({})
ft('c'):fmt('tool-1')
:append('tool-2')
:lint('lint-tool-1')
:append('lint-tool-2')
```

## Config Options
if the tool is not supported, you will have to pass in a table instead of a string, see [here](https://github.com/nvimdev/guard.nvim/tree/main/lua%2Fguard%2Ftools) for some examples, more info below.

- `fmt_on_save` auto format when save file
```lua
local ft = require('guard.filetype')

command `GuardFmt` for command use, use `GuardDisable` to diable auto format.
-- use clang-format and clang-tidy for c files
ft('c'):fmt('clang-format')
:lint('clang-tidy')

## Usage
-- use stylua to format lua files and no linter
ft('lua'):fmt('stylua')

an example usage
-- use lsp to format first then use golines to format
ft('go'):fmt('lsp')
:append('golines')
:lint('golangci')

```lua
local ft = require('guard.filetype')
ft('c'):fmt('clang-format'):lint('clang-tidy')
ft('lua'):fmt('stylua')
ft('go'):fmt('lsp'):append('golines'):lint('golangci')
--note setup must be last line
require('guard').setup()
-- call setup LAST
require('guard').setup({
-- the only option for the setup function
fmt_on_save = true,
})
```

chain call you can use `ft(your-filetype)` with `fmt` `lint` `append` function a chain call like
`ft('c'):fmt('tool-1'):append('tool-2'):lint('lint-tool-1'):append('lint-tool-2')`

first import `guard.filetype` module then call it to register filetype,then use chain call to
register format or tool config by using `fmt` and `append` function.type of them is `table` or
`string` if you want use the builin config just pass string if you want use a custom config pass table.
Use `GuardFmt` to manually call format, use `GuardDisable` to diable auto format.

### Builtin tools

Expand All @@ -59,7 +58,7 @@ register format or tool config by using `fmt` and `append` function.type of them
- `golines`
- `black`

table format for custom tool
Table format for custom tool:

```
{
Expand All @@ -80,9 +79,8 @@ table format for custom tool

- `clang-tidy`

## Trobule

if guard do nothing when save file run `checkhealth` first.
## Trobuleshooting

if guard does not auto format on save, run `checkhealth` first.

## License MIT