-
-
Notifications
You must be signed in to change notification settings - Fork 27
feat!: event API #181
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
feat!: event API #181
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
2d67975
chore: minor code simplification
xiaoshihou514 d2b03a1
feat!: event api
xiaoshihou514 7911e94
fix: test
xiaoshihou514 bd33a3b
feat: provide command interface
xiaoshihou514 7b7fb54
chore(doc): auto generate docs
github-actions[bot] 771fa7b
feat: add error reporting for linters
xiaoshihou514 1193099
chore(doc): auto generate docs
github-actions[bot] 596b3a3
ci: add linter test
xiaoshihou514 b82a8f7
Merge branch 'main' of github.com:xiaoshihou514/guard.nvim
xiaoshihou514 fbcbafd
ci: more tests
xiaoshihou514 8e12ec8
chore: update bug report issue template
xiaoshihou514 5510a1f
Update bug_report.yml
xiaoshihou514 964e5e3
chore(doc): auto generate docs
github-actions[bot] 4ad9e63
wip: add custom event support for formatting
xiaoshihou514 c91acd5
chore(doc): auto generate docs
github-actions[bot] dcba169
ci: add tests for custom formatter events
xiaoshihou514 8678e4e
fix: enable/disable-fmt
xiaoshihou514 83350ac
fix(side quest): fix generic linters properly
xiaoshihou514 ec7a632
update
xiaoshihou514 3a36483
Merge branch 'main' into main
xiaoshihou514 5975c60
fix: type check
xiaoshihou514 e3dc4b8
scaffold more stuff
xiaoshihou514 7bb6967
chore(doc): auto generate docs
github-actions[bot] 1eda07b
feat: add custom linter event logic
xiaoshihou514 016f0e9
chore(doc): auto generate docs
github-actions[bot] f39be05
update
xiaoshihou514 3897c36
feat: auto_lint
xiaoshihou514 0042dbe
chore(doc): auto generate docs
github-actions[bot] c8ea85f
special treat
xiaoshihou514 fb45f0f
fix global state
xiaoshihou514 a2cd3ea
feat: add lint interval option + naming changes
xiaoshihou514 9cb6efb
chore(doc): auto generate docs
github-actions[bot] 101e2db
Update lua/guard/filetype.lua
xiaoshihou514 cde7233
Update lua/guard/filetype.lua
xiaoshihou514 bd3a151
Update lua/guard/events.lua
xiaoshihou514 422dedb
Update lua/guard/events.lua
xiaoshihou514 46649a9
Update lua/guard/events.lua
xiaoshihou514 6d36c7d
feat: unify guard info with healthcheck
xiaoshihou514 a5f309e
chore: tweak issue template
xiaoshihou514 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| -- These are considered public API and changing their signature would be a breaking change | ||
| local M = {} | ||
| local api = vim.api | ||
| local events = require('guard.events') | ||
|
|
||
| ---Format bufnr or current buffer | ||
| ---@param bufnr number? | ||
| function M.fmt(bufnr) | ||
| require('guard.format').do_fmt(bufnr) | ||
| end | ||
|
|
||
| ---Lint bufnr or current buffer | ||
| ---@param bufnr number? | ||
| function M.lint(bufnr) | ||
| require('guard.lint').do_lint(bufnr) | ||
| end | ||
|
|
||
| ---Enable format for bufnr or current buffer | ||
| ---@param bufnr number? | ||
| function M.enable_fmt(bufnr) | ||
| local buf = bufnr or api.nvim_get_current_buf() | ||
| local ft_handler = require('guard.filetype') | ||
| local ft = vim.bo[buf].ft | ||
| local head = vim.tbl_get(ft_handler, ft, 'formatter', 1) | ||
| if type(head) == 'table' and type(head.events) == 'table' then | ||
| events.fmt_attach_custom(ft, head.events) | ||
| else | ||
| events.try_attach_fmt_to_buf(buf) | ||
| end | ||
| end | ||
|
|
||
| ---Disable format for bufnr or current buffer | ||
| ---@param bufnr number? | ||
| function M.disable_fmt(bufnr) | ||
| local buf = bufnr or api.nvim_get_current_buf() | ||
| vim.iter(events.get_format_autocmds(buf)):each(function(it) | ||
| api.nvim_del_autocmd(it.id) | ||
| end) | ||
| events.user_fmt_autocmds[vim.bo[buf].ft] = {} | ||
| end | ||
|
|
||
| ---Enable lint for bufnr or current buffer | ||
| ---@param bufnr number? | ||
| function M.enable_lint(bufnr) | ||
| local buf = bufnr or api.nvim_get_current_buf() | ||
| local ft = require('guard.filetype')[vim.bo[buf].ft] or {} | ||
| if ft.linter and #ft.linter > 0 then | ||
| events.try_attach_lint_to_buf( | ||
| buf, | ||
| require('guard.util').linter_events(ft.linter[1]), | ||
| vim.bo[buf].ft | ||
| ) | ||
| end | ||
| end | ||
|
|
||
| ---Disable format for bufnr or current buffer | ||
| ---@param bufnr number? | ||
| function M.disable_lint(bufnr) | ||
| local aus = events.get_lint_autocmds(bufnr or api.nvim_get_current_buf()) | ||
| vim.iter(aus):each(function(au) | ||
| api.nvim_del_autocmd(au.id) | ||
| end) | ||
| end | ||
|
|
||
| ---Show guard info for current buffer | ||
| function M.info() | ||
| vim.cmd('checkhealth guard') | ||
| end | ||
|
|
||
| return M | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.