Skip to content
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

feat!: fine tune user interface #158

Merged
merged 48 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0246a33
doc: planning the changes
xiaoshihou514 Aug 9, 2024
e6fbfdc
chore(doc): auto generate docs
github-actions[bot] Aug 9, 2024
bb286fa
feat: use subcommands
xiaoshihou514 Aug 18, 2024
4ad719e
chore(doc): auto generate docs
github-actions[bot] Aug 18, 2024
6ae2ebf
wip: getting rid of setup()
xiaoshihou514 Aug 18, 2024
43fe2f2
fix: wrong condition
xiaoshihou514 Aug 18, 2024
a9dae2c
perf: remove some vim.validate
xiaoshihou514 Aug 18, 2024
4c59bb3
chore: deprecate setup
xiaoshihou514 Aug 18, 2024
dc749bf
ci: add luarocks workflow, etc
xiaoshihou514 Aug 18, 2024
2b4aae9
chore(doc): auto generate docs
github-actions[bot] Aug 18, 2024
dd81a07
ci: use better testing action
xiaoshihou514 Aug 18, 2024
7006260
Merge branch 'main' of github.com:xiaoshihou514/guard.nvim
xiaoshihou514 Aug 18, 2024
acb4b95
fix(ci): testing ci
xiaoshihou514 Aug 18, 2024
d491019
fix(ci): add related files
xiaoshihou514 Aug 18, 2024
17ec0d3
fix(test): remove deprecated setup
xiaoshihou514 Aug 18, 2024
821433c
fix(test): autocmd_spec
xiaoshihou514 Aug 18, 2024
e4d740e
chore: add name for stylua download step
xiaoshihou514 Aug 18, 2024
9c31562
chore: issue template + special check for mason
xiaoshihou514 Aug 19, 2024
f06f00b
chore(doc): auto generate docs
github-actions[bot] Aug 19, 2024
736e4fc
chore: more robust getopt + move type decl
xiaoshihou514 Aug 25, 2024
a467e34
chore(doc): auto generate docs
github-actions[bot] Aug 25, 2024
9f36d5a
test: new settings
xiaoshihou514 Aug 30, 2024
faec7f7
Merge branch 'main' of github.com:xiaoshihou514/guard.nvim
xiaoshihou514 Aug 30, 2024
fc7880d
chore(doc): auto generate docs
github-actions[bot] Aug 30, 2024
2208374
fix test?
xiaoshihou514 Aug 30, 2024
5fa819f
feat: add guard info
xiaoshihou514 Aug 31, 2024
8b0bc6e
chore(doc): auto generate docs
github-actions[bot] Aug 31, 2024
4ea81c7
rock: add dep
xiaoshihou514 Aug 31, 2024
41284f2
update bug_report.yml
xiaoshihou514 Aug 31, 2024
d9ed2f0
add more tests
xiaoshihou514 Aug 31, 2024
ab8b49d
rm dep
xiaoshihou514 Aug 31, 2024
0ec3697
fix test
xiaoshihou514 Aug 31, 2024
da45de2
fix test
xiaoshihou514 Aug 31, 2024
dcd10be
fix: try detecting existing autocmd
xiaoshihou514 Aug 31, 2024
5d670c9
fix: nil
xiaoshihou514 Aug 31, 2024
8c2a858
fix: silly mistake...
xiaoshihou514 Aug 31, 2024
263755f
fix: missing description
xiaoshihou514 Aug 31, 2024
39ad95f
fix: invalid subcmd warning, au group export, guard info...
xiaoshihou514 Sep 1, 2024
4b1e7ab
chore(doc): auto generate docs
github-actions[bot] Sep 1, 2024
4fa63d6
chore: imporve readbility
xiaoshihou514 Sep 1, 2024
f474495
fix: types
xiaoshihou514 Sep 1, 2024
ce4164f
update bug_report.yml
xiaoshihou514 Sep 4, 2024
a9f396e
chore(doc): auto generate docs
github-actions[bot] Sep 4, 2024
db8ad9d
fix: wrong line numbers
xiaoshihou514 Oct 3, 2024
df9c039
chore(doc): auto generate docs
github-actions[bot] Oct 3, 2024
686a40e
feat: function formatters / linters
xiaoshihou514 Oct 3, 2024
7395daf
fix: don't check executable if is function
xiaoshihou514 Oct 3, 2024
966d466
chore: fix test
xiaoshihou514 Oct 3, 2024
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
13 changes: 13 additions & 0 deletions .busted
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
return {
_all = {
coverage = false,
lpath = "lua/?.lua;lua/?/init.lua",
lua = "nlua",
},
default = {
verbose = true,
},
tests = {
verbose = true,
},
}
68 changes: 68 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# https://github.com/mrcjkb/haskell-tools.nvim/blob/master/.github/ISSUE_TEMPLATE/bug_report.yml
name: Bug Report
description: Report a problem with guard.nvim
labels: [bug]
body:

- type: input
attributes:
label: "Neovim version (nvim -v)"
placeholder: "v0.10.0"
validations:
required: true
- type: input
attributes:
label: "Operating system/version"
placeholder: "Fedora Linux 40"
validations:
required: true
- type: textarea
attributes:
label: "Output of :checkhealth guard"
render: "console"
placeholder: |
Perhaps the tools are not in your $PATH?
validations:
required: true
- type: textarea
attributes:
label: "Output of :Guard info"
render: "markdown"
placeholder: |
Are the autocmds attached?
validations:
required: true
- type: textarea
attributes:
label: "How to reproduce the issue"
placeholder: |
git clone https://github.com/nvimdev/guard.nvim /tmp
git clone https://github.com/nvimdev/guard-collection /tmp
echo "vim.opt.rtp:append('/tmp/guard.nvim')" >> /tmp/repro.lua
echo "vim.opt.rtp:append('/tmp/guard-collection')" >> /tmp/repro.lua
validations:
required: true
- type: textarea
attributes:
label: "Expected behaviour"
description: "Describe the behaviour you expect."
validations:
required: true
- type: textarea
attributes:
label: "Actual behaviour"
validations:
required: true
- type: textarea
attributes:
label: "The minimal config used to reproduce this issue."
description: |
Run with `nvim -u /tmp/repro.lua`
placeholder: |
vim.opt.rtp:append('/tmp/guard.nvim')
vim.opt.rtp:append('/tmp/guard-collection')
-- do anything else you need to do to reproduce the issue

render: "Lua"
validations:
required: true
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# https://github.com/mrcjkb/haskell-tools.nvim/blob/master/.github/ISSUE_TEMPLATE/feature_request.yml
name: Feature request
description: Request an enhancement for guard.nvim
labels: [enhancement]
body:

- type: markdown
attributes:
value: |
Maybe checkout `:h guard.nvim-advanced-tips`?

- type: textarea
attributes:
label: "Feature description"
validations:
required: true
31 changes: 0 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,3 @@ jobs:
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"

test:
name: Run Test
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: rhysd/action-setup-vim@v1
id: vim
with:
neovim: true
version: nightly

- name: luajit
uses: leafo/gh-actions-lua@v10
with:
luaVersion: "luajit-2.1.0-beta3"

- name: luarocks
uses: leafo/gh-actions-luarocks@v4

- name: run test
shell: bash
run: |
wget "https://github.com/JohnnyMorganz/StyLua/releases/download/v0.18.0/stylua-linux.zip" -P /home/runner/.local/bin
unzip /home/runner/.local/bin/stylua-linux.zip -d /home/runner/.local/bin
chmod +x /home/runner/.local/bin/stylua
luarocks install luacheck
luarocks install vusted
vusted ./test
21 changes: 21 additions & 0 deletions .github/workflows/luarocks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Push to Luarocks

on:
push:
tags: # Will upload to luarocks.org when a tag is pushed
- "*"
pull_request: # Will test a local install without uploading to luarocks.org
workflow_dispatch:

jobs:
luarocks-upload:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: LuaRocks Upload
uses: nvim-neorocks/luarocks-tag-release@v7
env:
LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}
with:
dependencies: |
guard-collection
22 changes: 22 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release Please

on:
push:
branches:
- main
- master
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
release:
name: release
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.PAT }}
release-type: simple
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Run tests
on:
pull_request: ~
push:
branches:
- main

jobs:
build:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
neovim_version: ['nightly', 'stable']

steps:
- uses: actions/checkout@v4
- name: Download stylua
shell: bash
run: |
wget "https://github.com/JohnnyMorganz/StyLua/releases/download/v0.18.0/stylua-linux.zip" -P /home/runner/.local/bin
unzip /home/runner/.local/bin/stylua-linux.zip -d /home/runner/.local/bin
chmod +x /home/runner/.local/bin/stylua
- name: Run tests
uses: nvim-neorocks/nvim-busted-action@v1
with:
nvim_version: ${{ matrix.neovim_version }}
8 changes: 3 additions & 5 deletions ADVANCED.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ fn main() {
That's a lot of output! But we can see three main blocks: the first two diagnostics and the last one an overview. We only need the first two:

```lua
local clippy_diagnostic_parse =
parse = lint.from_json({
local clippy_diagnostic_parse = lint.from_json({
get_diagnostics = function(line)
local json = vim.json.decode(line)
-- ignore overview json which does not have position info
Expand All @@ -158,11 +157,10 @@ Now our diagnostics are transformed into a list of json, we just need to get the
attributes = {
-- it is json turned into a lua table
lnum = function(it)
-- clippy has really weird indexes
return math.ceil(tonumber(it.spans[1].line_start) / 2)
return math.ceil(tonumber(it.spans[1].line_start))
end,
lnum_end = function(it)
return math.ceil(tonumber(it.spans[1].line_end) / 2)
return math.ceil(tonumber(it.spans[1].line_end))
end,
code = function(it)
return it.code.code
Expand Down
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# guard.nvim

[![LuaRocks](https://img.shields.io/luarocks/v/nvimdev/guard.nvim?logo=lua&color=green)](https://luarocks.org/modules/nvimdev/guard.nvim)

Async formatting and linting utility for neovim `0.10+`.

## Features
Expand All @@ -12,7 +14,13 @@ Async formatting and linting utility for neovim `0.10+`.

## Usage

Installation for lazy.nvim
For rocks.nvim

```vim
Rocks install guard.nvim
```

For lazy.nvim

```lua
{
Expand All @@ -24,33 +32,33 @@ Installation for lazy.nvim
}
```

Guard is configured as follows:
To register formatters and linters:

```lua
local ft = require('guard.filetype')

-- Assuming you have guard-collection
-- Put this in your ftplugin/lang.lua to lazy load guard
ft('lang'):fmt('format-tool-1')
:append('format-tool-2')
:env(env_table)
:lint('lint-tool-1')
:extra(extra_args)

-- Call setup() LAST!
require('guard').setup({
-- Choose to format on every write to a buffer
-- change this anywhere in your config, these are the defaults
vim.g.guard_config = {
-- format on write to buffer
fmt_on_save = true,
-- Use lsp if no formatter was defined for this filetype
-- use lsp if no formatter was defined for this filetype
lsp_as_default_formatter = false,
-- By default, Guard writes the buffer on every format
-- You can disable this by setting:
-- save_on_fmt = false,
})
-- whether or not to save the buffer after formatting
save_on_fmt = true,
}
```

- Use `GuardFmt` to manually call format, when there is a visual selection only the selection is formatted. **NOTE**: Regional formatting just sends your selection to the formatter, if there's not enough context incoherent formatting might occur (e.g. indent being erased)
- `GuardDisable` disables auto format for the current buffer, you can also `GuardDisable 16` (the buffer number)
- Use `GuardEnable` to re-enable auto format, usage is the same as `GuardDisable`
- Use `Guard fmt` to manually call format, when there is a visual selection only the selection is formatted. **NOTE**: Regional formatting just sends your selection to the formatter, if there's not enough context incoherent formatting might occur (e.g. indent being erased)
- `Guard disable` disables auto format for the current buffer, you can also `Guard disable 16` (the buffer number)
- Use `Guard enable` to re-enable auto format, usage is the same as `Guard disable`

Format c files with clang-format and lint with clang-tidy:

Expand Down
Loading
Loading