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

Consider marking pragmas as something other than comments #1766

Open
michaelpj opened this issue Oct 7, 2021 · 5 comments
Open

Consider marking pragmas as something other than comments #1766

michaelpj opened this issue Oct 7, 2021 · 5 comments

Comments

@michaelpj
Copy link

The root of this issue is that for lsp-mode-based completions, we would like to complete language pragmas. Since lsp-mode is quite generic, we don't have a good way of saying this, and we just have to say that we want completion in all comments. That is often quite annoying (emacs-lsp/lsp-haskell#135).

@alanz made the suggestion that we could consider not treating pragmas as comments. I think that would mean a change to how haskell-mode tokenizes Haskell source, and ultimately I don't have a good sense of whether it would have lots of unintended consequences. But there is a certain logic to it: unlike normal comments, pragmas are active program elements that have a prescribed structure, and so in that sense are perhaps more like real syntax than comments.

As I said, I don't really know if this is a good idea or not, so I'd appreciate some wisdom!

@alanz
Copy link
Contributor

alanz commented Oct 7, 2021

FWIW I already have this customization:

'(haskell-pragma-face ((t (:inherit font-lock-preprocessor-face :foreground "royal blue"))))

So I think the underlying distinction is already being made.

@michaelpj
Copy link
Author

Right, I meant to mention that: haskell-mode does give them different font-lock highlighting already. I don't understand enough about how syntax processing in emacs works to know what bit would need to change for them not to look like comments (although here is what lsp-mode does to distinguish comments: https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-completion.el#L404).

@purcell
Copy link
Member

purcell commented Oct 7, 2021

This may be technically possible, but it seems like an indirect way to solve what is presumably an underlying issue with the LSP backend not completing very usefully inside comments.

@michaelpj
Copy link
Author

Well, I'm not sure we'll ever get good completion inside comments. We probably just want to have it off. The problem is just that we can't distinguish that case from the weird case where we do want completions: pragmas. And I don't think we have enough context-sensitivity in how completions work in the LSP spec to notice whether or not we're in a comment...

@purcell
Copy link
Member

purcell commented Oct 8, 2021

You could be right, but on the other hand I'd be extremely surprised if the backend for lsp-java doesn't intelligently complete javadoc comment tags like @property, which I think would be similarly context-sensitive. I notice that that lsp-mode backend enables completion-in-comments.

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

3 participants