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

Use InitializationOptions instead of flags to drive capabilities #280

Closed
ramya-rao-a opened this issue May 15, 2018 · 3 comments
Closed
Assignees

Comments

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented May 15, 2018

At present there are 2 flags to the go-langserver that control features of the language server

  • gocodecompletion
  • func-snippet-enabled

One can easily imagine other configuration options we would want to have down the line that controls other features. One such is already being discussed in #272 (comment) which is about the tool to use for formatting i.e gofmt vs goimports

InitializationOptions is something sent to the server from the client which seems like a much better place than flags to control/configure features. Adding more flags to go-langserver itself doesnt scale.

cc @keegancsmith @slimsag

@Contextualist
Copy link
Contributor

Contextualist commented May 16, 2018

Agree. The only draw back for such change is that all solution depends on us must adjust their cmd spawning the go-langserver process, or it will refuse to work.

FYI, I am actually considering deprecating -gocodecompletion when we switch to mdempsky/gocode. Currently, it doesn't support cache and thus no cache setup is needed, so the flag now does no more than switching the ServerCapabilities (and thus pretty pointless). go-langserver will behave as if there's no completion support if the client never issues a completion request.

edit: It does support some caching without any extra setup.

@ramya-rao-a
Copy link
Contributor Author

ramya-rao-a commented May 16, 2018

My another concern with flags is that when new flags get added, there is no clean way for the client to know if the user has the version of the language server that supports the said flag. The only way to do this would be to parse the output of go-langserver -h and look for all the supported flags

So, why do we even have the gocodecompletion flag?

@keegancsmith
Copy link
Member

keegancsmith commented May 17, 2018

I agree with this. Moving to InitializationOptions is much more reasonable. I think the flag was added originally since it was the easiest way to toggle on the experimental feature for existing users. I'm going to propose this, sound good:

interface GoInitializationOptions {
  /**
   * funcSnippetEnabled enables the returning of enable argument snippets
   * on `func` completions, eg. func(foo string, arg2 bar).
   * Requires code completion to be enabled.
   *
   * Defaults to true if not specified.
   */
  funcSnippetEnabled?: boolean;

  /**
   * gocodeCompletionEnabled enables code completion feature (using gocode).
   *
   * Defaults to false if not specified.
   */
  gocodeCompletionEnabled?: boolean;

  /**
   * MaxParallelism controls the maximum number of goroutines that should be used
   * to fulfill requests. This is useful in editor environments where users do
   * not want results ASAP, but rather just semi quickly without eating all of
   * their CPU.
   *
   * Defaults to 8 if not specified.
   */
  maxParallelism?: number;

  /**
   * useBinaryPkgCache controls whether or not $GOPATH/pkg binary .a files should
   * be used.
   *
   * Defaults to true if not specified.
   */
  useBinaryPkgCache?: boolean;
}

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

No branches or pull requests

3 participants