Open xyecoding opened 2 years ago
There isn't, and it's not feasible to implement.
Entire files, particularly in Vim, need to be context-dependent. Beyond just making sure the pairs are balanced in the file, it has to make sure they are balanced in the code and not in the comments, for most files. Then it has to eliminate certain contexts, such as std::cout <<
vs. the <> pair's role in templating. It then gets even more fun with languages like markdown, where files can contain multiple distinct languages. The same also applies to C and C++, where it's possible to sneak assembly in alongside the C/C++ code. I imagine there's more examples, but it doesn't matter.
The TL;DR: is that this cascades into a semantic language parser, which is obscenely complex, and well outside the scope of what a Vim plugin written in old Vimscript should be doing anyway. Use an LSP client instead (prabirshrestha/vim-lsp, neoclide/coc.nvim, or others), or an LSP linter (dense-analysis/ale, or others) if you only care about linting and not autocomplete, or don't want autocomplete at all.
Yes, it can be somewhat RAM-heavy, but it comes with more benefits than just pair balance checks, notably by checking all syntax problems, and not just balancing issues. Also, most semi-modern computers have more than enough RAM to run an LSP. Beyond that, you get the choice between nothing, or a dumb, context-disregarding check that can and inevitably will cause more problems than it's worth. Or, of course, running a compiler manually yourself, or a linter if a compiler doesn't exist for your language.
There are often unclosed brackets are typed by mistake. I wonder if there any method to find the unclosed brackets in the whole file. Thank you!