bash-language-server
bash-language-server copied to clipboard
Code actions to disable shellcheck rules for lines or entire files
What is the problem this feature will solve?
Currently it seems there are only code actions to apply fixes when available. Code actions to disable the rules (using comments) would also be appreciated.
https://github.com/bash-lsp/bash-language-server/issues/490#issuecomment-1406298247
What is the feature you are proposing to solve the problem?
Additional code actions, eg. null-ls offers:
Disable ShellCheck rule 2059 for the entire file
Disable ShellCheck rule 2059 for this line
What alternatives have you considered?
No response
+1 for this idea 💡
@polyzen i’m not sure what editor you use, but as a stopgap, i’ve written a little neovim lua command to insert a shellcheck disable statement based on the current line’s lsp diagnostics into your buffer:
https://github.com/xero/dotfiles/commit/f3821bebb4ec3149a83413c606140741124c45f7#diff-cf8a96b3f61615a85a1fb4313e82a75b58d6e0bd71869e9c3b1ead9d1bbd91ab
hope this helps for now.
@xero I think I found a better solution for neovim: https://github.com/bash-lsp/bash-language-server/issues/999#issuecomment-1763539911
Hello there!
I have made a first draft to try to address this issue: https://github.com/ThomasFaivre/bash-language-server/commit/d0b80ffaa580b25e91ed1f996ea258708f83ebdb It does stuff (tested in neovim+LazyVim), but it is not finished for several reasons:
- [x] handle indentation
- [x] handle existing disable lines
- [x] make tests
- [ ] Stuff I'm missing
I wanted to get some inputs before continuing. And I have some questions. I am very new to Typescript (like, this is the second time I am touching javascript related code :D ), so I apologize if my questions are strange.
- What would be the best way to get indentation? I'm assuming it would have something to do with the
TextDocument, but how to get a given line? Kind of the same question to detect an existing disabling line. - Should I keep using
getTextEdit*methods? Since data does not come from aShellCheckReplacementobject. I could use aTextEditobject directly. For instance,insertionPointandprecedenceare not used. codeActionsvariable could directly be an array, instead of a mapping of array withidas keys that we just flatten after creating it. But I'm afraid of breaking #700.- I have no idea how the node engine works, so there might be some optimization/performance concerns to deal with.
As for enhancement, this patch would open the possibility of adding a disabling of the rule at the scope level (function/if/while...) which does not exist in nvimtools/none-ls.nvim.
Also, tell me if you want a Pull Request in order to start a proper review.
Hope this will help!