func Load() (*Config, error) {
	filename := os.Getenv("ACME_LSP_CONFIG")
	if filename == "" {
		var err error
		filename, err = userConfigFilename()
		if err != nil {
			return nil, err
		}
		if _, err := os.Stat(filename); os.IsNotExist(err) {
			return Default(), nil
		}
	}
	cfg, err := load(filename)
	if err != nil {
		return nil, err
	}
	def := Default()
	if cfg.File.ProxyNetwork == "" {
		cfg.File.ProxyNetwork = def.File.ProxyNetwork
	}
	if cfg.File.ProxyAddress == "" {
		cfg.File.ProxyAddress = def.File.ProxyAddress
	}
	if cfg.File.AcmeNetwork == "" {
		cfg.File.AcmeNetwork = def.File.AcmeNetwork
	}
	if cfg.File.AcmeAddress == "" {
		cfg.File.AcmeAddress = def.File.AcmeAddress
	}
	if cfg.File.RootDirectory == "" {
		cfg.File.RootDirectory = def.File.RootDirectory
	}
	cacheDir, err := os.UserCacheDir()
	if err != nil {
		return nil, err
	}
	cacheDir = filepath.Join(cacheDir, "acme-lsp")
	err = os.MkdirAll(cacheDir, 0700)
	if err != nil {
		return nil, err
	}
	for key := range cfg.Servers {
		if len(key) > 0 && key[0] == '_' {
			return nil, fmt.Errorf("server key %q begins with underscore", key)
		}
		s := cfg.File.Servers[key]
		if s.StderrFile != "" && !filepath.IsAbs(s.StderrFile) {
			s.StderrFile = filepath.Join(cacheDir, s.StderrFile)
		}
		if s.LogFile != "" && !filepath.IsAbs(s.LogFile) {
			s.LogFile = filepath.Join(cacheDir, s.LogFile)
		}
	}
	return cfg, nil
}
Load loads Config from file system. It first looks at ACME_LSP_CONFIG
environment variable for location of configuration file and loads
it if it is set.  If the environment variable is not set, it'll use
UserConfigDir/acme-lsp/config.toml if it exists. Otherwise, it'll
falling back to a default configuration.
package config
import (
	"errors"
	"flag"
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"path/filepath"
	"runtime"
	"strings"
	"github.com/BurntSushi/toml"
	"github.com/fhs/9fans-go/plan9/client"
	"github.com/fhs/acme-lsp/internal/lsp/protocol"
)
type Flags uint
const (
	LangServerFlags Flags = 1 << iota
	ProxyFlags
)
type File struct {
	ProxyNetwork, ProxyAddress string
	AcmeNetwork, AcmeAddress string
	WorkspaceDirectories []string
	RootDirectory string
	HideDiagnostics bool
	FormatOnPut bool
	RPCTrace bool
	CodeActionsOnPut []protocol.CodeActionKind
	Servers map[string]*Server
	FilenameHandlers []FilenameHandler
}
type Config struct {
	File
	ShowConfig bool
	Verbose bool
	filename string
}
type Server struct {
	Command []string
	Address string
	StderrFile string
	LogFile string
	Options interface{}
}
type FilenameHandler struct {
	Pattern string
	LanguageID string
	ServerKey string
}
func Default() *Config {
	rootDir := "/"
	switch runtime.GOOS {
	case "windows":
		rootDir = `C:\`
	}
	return &Config{
		File: File{
			ProxyNetwork:         "unix",
			ProxyAddress:         filepath.Join(client.Namespace(), "acme-lsp.rpc"),
			AcmeNetwork:          "unix",
			AcmeAddress:          filepath.Join(client.Namespace(), "acme"),
			WorkspaceDirectories: nil,
			RootDirectory:        rootDir,
			FormatOnPut:          true,
			CodeActionsOnPut: []protocol.CodeActionKind{
				protocol.SourceOrganizeImports,
			},
			Servers:          nil,
			FilenameHandlers: nil,
		},
	}
}
func userConfigFilename() (string, error) {
	dir, err := UserConfigDir()
	if err != nil {
		return "", err
	}
	return filepath.Join(dir, "acme-lsp/config.toml"), nil
}