Skip to content

feat: customizable lsp event handler and lsp server log #339

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

Merged
merged 1 commit into from
Apr 3, 2025

Conversation

knilink
Copy link
Contributor

@knilink knilink commented Sep 7, 2024

  • adding custom even handler registration function copilot-on-notification, copilot-on-request
  • adding window/logMessage handler and buffer *copilot-language-server-log* for lsp server logging

image

@knilink knilink force-pushed the custom-event-handler branch 2 times, most recently from e40947d to b5b64d8 Compare September 7, 2024 07:58
@knilink knilink force-pushed the custom-event-handler branch 2 times, most recently from b8bec3d to fda007f Compare September 29, 2024 13:26
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 1, 2025

@knilink Lots of changes happened since you've opened this PR, but I think your idea is a good one. Are you still interested in pursuing it?

@knilink knilink force-pushed the custom-event-handler branch from fda007f to bd3f509 Compare April 2, 2025 15:04
@knilink
Copy link
Contributor Author

knilink commented Apr 2, 2025

conflict resolved, looks like this line is the only one causing the conflict

(copilot--dbind (((:completionText completion-text)) ((:score completion-score))) msg

also renamed the log buffer from *copilot agent log* to copilot-language-server-log

'window/logMessage
(lambda (msg)
(copilot--dbind (:type log-level :message log-msg) msg
(with-current-buffer (get-buffer-create "*copilot-language-server-log*")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good idea to extra the buffer names to constants.

Copy link
Contributor Author

@knilink knilink Apr 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ATM, I was trying to stay consistent with the existing code and I think this can be addressed in a different PR.
There were inconsistencies as well such *copilot stderr* doesn't use hyphen like the rest which can be also fixed together.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a fair point.

copilot.el Outdated
"Hash table storing lists of notification handlers.")

(defun copilot-on-notification (method handler)
"Register HANDLER to be called when a notification of type METHOD is received."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is method really the right term here? Perhaps notification-type or something like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rephrased to follow the description in vscode language server doc

@@ -311,6 +311,27 @@ For example:
(setq copilot-network-proxy '(:host "127.0.0.1" :port 7890))
```

### copilot-on-request
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add blank lines after each heading.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Register a handler to be called when a request of type method is received. Return JSON serializable as result or calling `jsonrpc-error` for errors. [readmore](https://www.gnu.org/software/emacs/manual/html_node/elisp/JSONRPC-Overview.html)

For example:
```elisp
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And before the code snippets.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@bbatsov bbatsov mentioned this pull request Apr 3, 2025
@knilink knilink force-pushed the custom-event-handler branch from bd3f509 to 66f7551 Compare April 3, 2025 15:25
@bbatsov bbatsov merged commit 1a8e1e1 into copilot-emacs:main Apr 3, 2025
13 checks passed
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 3, 2025

Great work! Thanks!

I'm looking forward to #343. 😉

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.

2 participants