Git Product home page Git Product logo

Comments (5)

stevearc avatar stevearc commented on June 1, 2024 1

Hmmm...this will take some more thought. We don't want to automatically add the on_output_quickfix component to all the cargo tasks, but we would like to provide a default value for errorformat if the component is added. We would also like to use that in the "set quickfix" action. I have the seeds of an idea for this; will play around with it and see if it works out.

from overseer.nvim.

stevearc avatar stevearc commented on June 1, 2024

How are you sending the output to the quickfix? The on_output_quickfix component has a parameter to customize the errorformat.

I also just added some better utilities for customizing the components of a template or template provider.

---Add a hook that runs on a TaskDefinition before the task is created
---@param name string Name of template or template module to hook
---@param hook fun(task_defn: overseer.TaskDefinition, util: overseer.TaskUtil)
---@example
--- -- Add on_output_quickfix component to all "cargo" templates
--- overseer.hook_template("cargo", function(task_defn, util)
--- util.add_component(task_defn, { "on_output_quickfix", open = true })
--- end)
--- -- Remove the on_complete_notify component from "cargo clean" task
--- overseer.hook_template("cargo clean", function(task_defn, util)
--- util.remove_component(task_defn, "on_complete_notify")
--- end)
M.hook_template = lazy_pend("template", "hook_template")

All together, I think this should do what you want:

  overseer.hook_template("cargo", function(task_defn, util)
    util.add_component(task_defn, {
      "on_output_quickfix",
      errorformat = [[%Eerror: %\%%(aborting %\|could not compile%\)%\@!%m,]]
        .. [[%Eerror[E%n]: %m,]]
        .. [[%Inote: %m,]]
        .. [[%Wwarning: %\%%(%.%# warning%\)%\@!%m,]]
        .. [[%C %#--> %f:%l:%c,]]
        .. [[%E  left:%m,%C right:%m %f:%l:%c,%Z,]]
        .. [[%.%#panicked at \'%m\'\, %f:%l:%c]]
    })
  end)

from overseer.nvim.

Shatur avatar Shatur commented on June 1, 2024

How are you sending the output to the quickfix?

I just used an action on task from Telescope.

All together, I think this should do what you want:

Thank you!
Should we hook this by default? Otherwise Cargo messages will have wrong filenames capture.

from overseer.nvim.

stevearc avatar stevearc commented on June 1, 2024

I've committed a feature for this. Tasks can now have a default_component_params table:

return {
cmd = cmd,
default_component_params = {
errorformat = [[%Eerror: %\%%(aborting %\|could not compile%\)%\@!%m,]]
.. [[%Eerror[E%n]: %m,]]
.. [[%Inote: %m,]]
.. [[%Wwarning: %\%%(%.%# warning%\)%\@!%m,]]
.. [[%C %#--> %f:%l:%c,]]
.. [[%E left:%m,%C right:%m %f:%l:%c,%Z,]]
.. [[%.%#panicked at \'%m\'\, %f:%l:%c]],
},
}

These values will be used as the default for any params on any components that are both not supplied by the user and defined as default_from_task = true

errorformat = {
desc = "See :help errorformat",
type = "string",
optional = true,
default_from_task = true,
},

The "open output in quickfix" action will also search here for the errorformat to use.

from overseer.nvim.

Shatur avatar Shatur commented on June 1, 2024

Thank you a lot, a very convenient feature!

from overseer.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.