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

Reading full context #343

Open
djtech-dev opened this issue Jun 18, 2023 · 1 comment
Open

Reading full context #343

djtech-dev opened this issue Jun 18, 2023 · 1 comment

Comments

@djtech-dev
Copy link

Hi, I'm working on an LSP Server and right now I'm implementing the Completations.

I wanted to ask how to read the full context (like the actual line of code or the lines of code previous to the current buffer) from CompletionParams.

Thanks.

@tombh
Copy link
Collaborator

tombh commented Jun 20, 2023

Hey, welcome. So I assume by saying "full", you mean that the existing completionContext isn't enough? It certainly doesn't contain the lines of code previous to the location at which the cursor triggered the completion.

So getting more context about the current buffer is actually something that's shown in our quickstart in the README. We have things like this:

document = server.workspace.get_document(params.text_document.uri)
# `params.position` is the current cursor position
current_line = document.lines[params.position.line].strip()

Does that give you some inspiration for exploring getting more context?

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