Skip to content

Few enhancements to the plugin api. #178

Closed

Description

@231tr0n

Feature description

  1. require("guard.filetype")("java"):lint("checkstyle") - There is no way to run the linter if a formatter is not configured.
  2. Provide Guard lint to only lint and not format file. Also make Guard fmt to only format and not lint file.
  3. Can I have a combination where linter is run asynchronously and formatter is run synchronously.
  4. Provide options for configuring async nature of linters and formatters in vim.g.guard_config.

Activity

  1. xiaoshihou514 commented on Dec 9, 2024

    @xiaoshihou514
    Member

    There is no way to run the linter if a formatter is not configured.

    You can hook into the linter logic in any way you want

    Provide Guard lint to only lint and not format file.

    Are there occasions where you want to do this manually? Please describe them.

    Can I have a combination where linter is run asynchronously and formatter is run synchronously.

    Sync stuff is not normally what people want, what's the motivation?

    Provide options for configuring async nature of linters and formatters in vim.g.guard_config.

    Same as above

    Also a small doubt, I wanted know to why was the setup function deprecated. Most people generally expect for a setup function. Is there any chance to remove the vim.deprecate function in the setup?

    You can read more about the motivation here :)

  2. 231tr0n commented on Dec 9, 2024

    @231tr0n
    Author

    @xiaoshihou514 Thank you for responding to my queries first of all.

    1. require("guard.filetype")("java"):lint("checkstyle") - For the first point what I meant was that the configured linter doesnt run and throws a message saying no configured formatters. Basically, I just configured java checkstyle for linting with no formatter and ran Guard fmt and got a error message saying formatter not configured or something of that sort.
    2. I wanted this feature because at my work, there are many cases where I should not touch the formatting of files since it changes git blame to my name even though I essentially made no change. But I still need the functionality to lint without formatting. That was my intention behind Guard fmt and Guard lint change.
    3. For the third point, I wanted this feature because, let us just say a formatter takes time to format and other edits happen in the buffer, they get replaced by the text from formatter. Hence, I generally run it in sync mode. Linters can be run in async mode but formatters work best for me when run in sync mode.
  3. xiaoshihou514 commented on Dec 9, 2024

    @xiaoshihou514
    Member

    Basically, you want to only run checkstyle manually and infrequently, but guard doesn't provide configs for events.

  4. 231tr0n commented on Dec 9, 2024

    @231tr0n
    Author

    Basically, you want to only run checkstyle manually and infrequently, but guard doesn't provide configs for events.

    No what I meant is if I configure java linter like this require("guard.filetype")("java"):lint("checkstyle") It wont run and throw error saying no formatters found.

  5. xiaoshihou514 commented on Dec 9, 2024

    @xiaoshihou514
    Member

    This doesn't sound right, I will take a look a bit later.

  6. 231tr0n commented on Dec 9, 2024

    @231tr0n
    Author

    This doesn't sound right, I will take a look a bit later.

    Sure

  7. xiaoshihou514 commented on Dec 9, 2024

    @xiaoshihou514
    Member

    Screenshot_2024-12-09-17-47-36-147_com.termux-edit.jpg

    Can't seem to repro (linter works standalone as in screenshot)

  8. 231tr0n commented on Dec 9, 2024

    @231tr0n
    Author

    Screenshot_2024-12-09-17-47-36-147_com.termux-edit.jpg

    Can't seem to repro

    Nvm I found out what the issue was! I did not push checkstyle changes to my forked repo while developing linter for checkstyle! Really sorry for making you debug this issue.

  9. 231tr0n commented on Dec 9, 2024

    @231tr0n
    Author

    Screenshot_2024-12-09-17-47-36-147_com.termux-edit.jpg
    Can't seem to repro

    Nvm I found out what the issue was! I did not push checkstyle changes to my forked repo while developing linter for checkstyle! Really sorry for making you debug this issue.

    image
    Ok! I am able to reproduce it. Just run Guard fmt with the following config
    image

  10. xiaoshihou514 commented on Dec 9, 2024

    @xiaoshihou514
    Member

    Well... You didn't specify a formatter, so obviously Guard fmt can't do anything useful...

  11. 231tr0n commented on Dec 9, 2024

    @231tr0n
    Author

    Well... You didn't specify a formatter, so obviously Guard fmt can't do anything useful...

    Yeah But I configured a linter right. So how do I get it to lint is my doubt.

  12. 231tr0n commented on Dec 9, 2024

    @231tr0n
    Author

    So there is no way to run a linter without configuring a formatter? Is it possible to provide a Guard lint to only lint and make Guard fmt to only format. Probably just invoking Guard can do both linting and formatting. I think this is a really good idea.

  13. xiaoshihou514 commented on Dec 9, 2024

    @xiaoshihou514
    Member

    Hey the linter is triggered automatically on these events

    local events = require('guard.events')
    local evs = { 'User GuardFmt', 'BufWritePost', 'BufEnter' }
    if config.stdin then
    table.insert(events, 'TextChanged')
    table.insert(events, 'InsertLeave')

    image

    Maybe inject a few print statements into the linter to see if your regex is working properly.

    You can trigger a manual lint refresh by :lua require("guard.lint").do_lint()

    Hope that helps :)

  14. locked and limited conversation to collaborators on Dec 9, 2024
  15. converted this issue into a discussion #180 on Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions