const fs = require('fs');
const path = require('path');

/**
 * Go LSP adapter — gopls.
 *
 * gopls is a Go binary; we can't install it into node_modules. installMode
 * is 'system' which means the configure flow prints the canonical install
 * command and the user runs it themselves. The verify step still checks
 * that the binary is in PATH.
 */
class GoAdapter {
  constructor(cwd = process.cwd()) { this.cwd = cwd; }

  get name() { return 'go'; }
  get label() { return 'Go (gopls)'; }
  get binary() { return 'gopls'; }
  get installMode() { return 'system'; }

  installCommand() { return 'go install golang.org/x/tools/gopls@latest'; }
  verifyCommand() { return 'gopls version'; }
  claudePluginId() { return 'gopls-lsp@claude-plugins-official'; }

  static detect(cwd = process.cwd()) {
    return fs.existsSync(path.join(cwd, 'go.mod'));
  }
}

module.exports = GoAdapter;
