Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

textDocument/completion support via gocode #219

Merged
merged 7 commits into from
Dec 18, 2017

Conversation

Contextualist
Copy link
Contributor

@Contextualist Contextualist commented Dec 14, 2017

Support textDocument/completion by vendoring nsf/gocode. Gocode maintains a separated package cache, thus this implementation is not optimal for memory.

Known issues:

Commit ff980ce also fixes #215 .
This closes #27, closes #77, and closes #201

@keegancsmith
Copy link
Member

Thanks!! I'll take a look at this tomorrow. cc @sqs @slimsag

@keegancsmith
Copy link
Member

Apologies I won't have time today, I've put it onto my TODO list to review on Monday though.

@Contextualist
Copy link
Contributor Author

@keegancsmith That's fine. I also need some time to test the feature with some corner cases as well as with real-world setting.

@Contextualist Contextualist changed the title WIP textDocument/completion support via gocode textDocument/completion support via gocode Dec 17, 2017
Copy link
Member

@keegancsmith keegancsmith left a comment

Choose a reason for hiding this comment

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

So this code assumes that we never have more than one langserver running in a process. However, the only place this isn't true (that I know of) is Sourcegraph.com and we don't do autocompletion on sourcegraph. So this LGTM! Thanks so much for the PR!

@@ -72,6 +73,13 @@ type LangHandler struct {

// reset clears all internal state in h.
func (h *LangHandler) reset(init *InitializeParams) error {
for _, k := range init.Capabilities.TextDocument.Completion.CompletionItemKind.ValueSet {
if k == lsp.CIKConstant {
CIKConstantSupported = lsp.CIKConstant
Copy link
Member

Choose a reason for hiding this comment

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

you are setting a global variable here, but langserver supports multiple instances running at once in the same process.

@keegancsmith keegancsmith merged commit 6d17b63 into sourcegraph:master Dec 18, 2017
@keegancsmith
Copy link
Member

@ramya-rao-a you may be interested in trying out the completion support in go-langserver this PR added. You need to ensure you are on latest master and run the langserver with the flag -gocodecompletion.

Thanks again @Contextualist!

@ramya-rao-a
Copy link
Contributor

nice, will give it a try

@ramya-rao-a
Copy link
Contributor

This works pretty well, nice job @Contextualist

There are a few extra things that the Go extension to VS Code does for completions apart from what gocode returns. Once I figure out how they can play well with the basic completions from the language server, I can include this.

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

Successfully merging this pull request may close these issues.

CompletionItem.TextEdit should be a pointer Code completion. Support textDocument/completion Feature request: Completion provider
3 participants