feat: Pass fname and cwd to parse function#247
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds file path and working directory context to linter provider functions by passing fname and cwd parameters to both parse and fn functions. This enhancement allows custom linters to access file location information when processing lint results or generating lint output.
Changes:
- Updated
lint.parse()calls to includefnameandcwdparameters (lines 107, 122) - Updated
lint.fn()call to includefnameandcwdparameters (line 120)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Instead of fname, would bufid be a better choice? 🤔 Seems much more natural as an api. Could you remind me again why you need cwd? |
|
As I wrote in the issue: " Example with {
"format_version": "1.0",
"valid": true,
"error_count": 0,
"warning_count": 2075,
"diagnostics": [
{
"severity": "warning",
"summary": "Deprecated Resource",
"detail": "This resource is deprecated...",
"address": "module.some.module.address.abcd.name",
"range": {
"filename": ".terraform/modules/some.address/main.tf",
...
}
}
... other 2074 warnings
]
}
Regarding |
|
How about a get state function that runs outside of the coroutine? |
|
You cannot safely call neovim api inside the fast event context A callable outside the coroutine only helps if the state is already available or the parsing logic is refactored into a pure sync function. Trying to obtain the path with |
|
Act I think you can do it with a small cache populated by autocmds (e.g. |
|
Ah you are right it's a bit awkward given the current impl |
|
Can you update the docs? Just change the type signature. (optionally add how you used this feature for tf) Will merge afterwards. |
|
👍🏻 Since there wasn't a section for this, I created one with the basic and extended forms. Also happy to PR the terraform linter to guard-collection next if that sounds good. |
|
Sorry, the nvim doc is auto generated from markdown files, could you modify those instead? tf pr sounds great :) |
5c961bc to
2c63eca
Compare
|
Didn’t know it was generated, but think I’ve fixed it. |
Both
parseandfnprovider functions now receivefnameandcwdparameters to provide file path and working directory context.