Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to find unclosed brackets. #345

Open
xyecoding opened this issue Mar 10, 2022 · 1 comment
Open

Add function to find unclosed brackets. #345

xyecoding opened this issue Mar 10, 2022 · 1 comment

Comments

@xyecoding
Copy link

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!

@LunarWatcher
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants