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

Treat function-scope static variables as locals #587

Closed
wants to merge 1 commit into from

Conversation

acowley
Copy link
Contributor

@acowley acowley commented Mar 11, 2020

If we report such variables as symbols in response to a
textDocument/documentSymbol, then we can no longer navigate to the
containing function using imenu in emacs.

Fixes #77

If we report such variables as symbols in response to a
`textDocument/documentSymbol`, then we can no longer navigate to the
containing function using imenu in emacs.

Fixes MaskRay#77
@MaskRay
Copy link
Owner

MaskRay commented Mar 12, 2020

From emacs-lsp/lsp-mode#1424

Ask a question in emacs-devel and file a bug there is no option for that.
Ask @MaskRay to provide a setting in ccls to ignore variables in function bodies.
Use alternative that works - lsp-treemacs-symbols works fine.
File a feature request for helm-lsp to implement imenu like interface without losing this info.

Maybe we should report it to emacs-devel. A function-local static variable has static duration duration . Such variables may be interesting in the textDocument/documentSymbol result.

@acowley
Copy link
Contributor Author

acowley commented Mar 12, 2020

I don't relish the idea of losing the duration information like this, but my concern is that this will be deemed out of scope for imenu. I use imenu for this because I like using it with helm, but the suggestion to use lsp-treemacs-symbols is perfectly valid.

This limitation of imenu is apparent elsewhere, so I think it is expected behavior. In an org-mode document, for example, imenu presents top-level headings. You can select one, and see the sub-headings below it, but you can not (afaict) navigate to that top-level heading. It seems like a limitation of the available interaction: you hit enter on an imenu item and it either drills down to sub-items, or moves point to that item if it is a leaf.

I'm okay with closing this PR as it's no trouble for me to continue using the patch, and I agree that in a perfect world this wouldn't be a change imposed on ccls.

@acowley acowley closed this Mar 12, 2020
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

Successfully merging this pull request may close these issues.

When processing textDocument/documentSymbol, function scoped static variables may be better not to be reported
2 participants