ServerForFile returns the server spec for a file based on its extension, applying any env override of the command.
(path string)
| 41 | // ServerForFile returns the server spec for a file based on its extension, |
| 42 | // applying any env override of the command. |
| 43 | func ServerForFile(path string) (ServerSpec, bool) { |
| 44 | ext := strings.ToLower(filepath.Ext(path)) |
| 45 | spec, ok := extensionServers[ext] |
| 46 | if !ok { |
| 47 | return ServerSpec{}, false |
| 48 | } |
| 49 | if spec.EnvKey != "" { |
| 50 | if override := strings.TrimSpace(os.Getenv(spec.EnvKey)); override != "" { |
| 51 | spec.Command = strings.Fields(override) |
| 52 | } |
| 53 | } |
| 54 | return spec, true |
| 55 | } |
| 56 | |
| 57 | // SupportedExtensions lists the recognized file extensions (for help/UX). |
| 58 | func SupportedExtensions() []string { |
no outgoing calls