forked from govim/govim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
const.go
34 lines (30 loc) · 928 Bytes
/
const.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package govim
import (
"fmt"
"strings"
)
// SwitchBufValue typed constants define the set of values that the Vim setting
// switchbuf can take. See :help switchbuf for more details and definitions of
// each value.
type SwitchBufMode string
const (
SwitchBufUseOpen SwitchBufMode = "useopen"
SwitchBufUseTag SwitchBufMode = "usetab"
SwitchBufSplit SwitchBufMode = "split"
SwitchBufVsplit SwitchBufMode = "vsplit"
SwitchBufNewTab SwitchBufMode = "newtab"
)
// ParseSwitchBufModes assumes vs is a valid value for &switchbuf
func ParseSwitchBufModes(vs string) ([]SwitchBufMode, error) {
var modes []SwitchBufMode
for _, v := range strings.Split(vs, ",") {
sm := SwitchBufMode(v)
switch sm {
case SwitchBufUseOpen, SwitchBufUseTag, SwitchBufSplit, SwitchBufVsplit, SwitchBufNewTab:
default:
return nil, fmt.Errorf("invalid SwitchBufMode %q", sm)
}
modes = append(modes, sm)
}
return modes, nil
}