Exemple #1
0
// Will load view settings respect to current syntax
// e.g if current syntax is Python settings order will be:
// Packages/Python/Python.sublime-settings
// Packages/User/Python.sublime-settings
// <Buffer Specific Settings>
func (v *View) loadSettings() {
	syntax := v.Settings().Get("syntax", "").(string)

	if syntax == "" {
		v.Settings().SetParent(v.window)
		return
	}

	defSettings, usrSettings := &HasSettings{}, &HasSettings{}

	defSettings.Settings().SetParent(v.window)
	usrSettings.Settings().SetParent(defSettings)
	v.Settings().SetParent(usrSettings)

	ed := GetEditor()
	if r, err := rubex.Compile(`([A-Za-z]+?)\.(?:[^.]+)$`); err != nil {
		log.Error(err)
		return
	} else if s := r.FindStringSubmatch(syntax); s != nil {
		p := path.Join(LIME_PACKAGES_PATH, s[1], s[1]+".sublime-settings")
		ed.load(packages.NewPacket(p, defSettings.Settings()))

		p = path.Join(LIME_USER_PACKAGES_PATH, s[1]+".sublime-settings")
		ed.load(packages.NewPacket(p, usrSettings.Settings()))
	}
}
func (p *plugin) loadKeyBindings() {
	ed := backend.GetEditor()
	tmp := ed.KeyBindings().Parent()

	ed.KeyBindings().SetParent(p)
	p.KeyBindings().Parent().KeyBindings().SetParent(tmp)

	pt := path.Join(p.Name(), "Default.sublime-keymap")
	p.load(packages.NewPacket(pt, p.KeyBindings().Parent().KeyBindings()))

	pt = path.Join(p.Name(), "Default ("+ed.Plat()+").sublime-keymap")
	p.load(packages.NewPacket(pt, p.KeyBindings()))
}
func (p *plugin) loadSettings() {
	ed := backend.GetEditor()
	tmp := ed.Settings().Parent()

	ed.Settings().SetParent(p)
	p.Settings().Parent().Settings().Parent().Settings().SetParent(tmp)

	pt := path.Join(p.Name(), "Preferences.sublime-settings")
	p.load(packages.NewPacket(pt, p.Settings().Parent().Settings().Parent().Settings()))

	pt = path.Join(p.Name(), "Preferences ("+ed.Plat()+").sublime-settings")
	p.load(packages.NewPacket(pt, p.Settings().Parent().Settings()))

	pt = path.Join(backend.LIME_USER_PACKAGES_PATH, "Preferences.sublime-settings")
	p.load(packages.NewPacket(pt, p.Settings()))
}
Exemple #4
0
func (e *Editor) loadSettings() {
	e.platformSettings.Settings().SetParent(e.defaultSettings)
	e.Settings().SetParent(e.platformSettings)

	p := path.Join(LIME_DEFAULTS_PATH, "Preferences.sublime-settings")
	defPckt := packages.NewPacket(p, e.defaultSettings.Settings())
	e.load(defPckt)

	p = path.Join(LIME_DEFAULTS_PATH, "Preferences ("+e.Plat()+").sublime-settings")
	platPckt := packages.NewPacket(p, e.platformSettings.Settings())
	e.load(platPckt)

	p = path.Join(LIME_USER_PACKAGES_PATH, "Preferences.sublime-settings")
	usrPckt := packages.NewPacket(p, e.Settings())
	e.load(usrPckt)
}
func TestLoadKeyBinding(t *testing.T) {
	editor := GetEditor()
	pkg := packages.NewPacket("testdata/Default.sublime-keymap", editor.KeyBindings())
	editor.load(pkg)

	kb := editor.KeyBindings().Filter(keys.KeyPress{Key: 'i'})
	if expectedLen := 3; kb.Len() != expectedLen {
		t.Errorf("Expected to have %d keys in the filter, but it had %d", expectedLen, kb.Len())
	}
}
Exemple #6
0
func (e *Editor) loadKeyBindings() {
	e.KeyBindings().SetParent(e.userBindings)
	e.userBindings.KeyBindings().SetParent(e.platformBindings)
	e.platformBindings.KeyBindings().SetParent(e.defaultBindings)

	p := path.Join(LIME_DEFAULTS_PATH, "Default.sublime-keymap")
	defPckt := packages.NewPacket(p, e.defaultBindings.KeyBindings())
	e.load(defPckt)

	p = path.Join(LIME_DEFAULTS_PATH, "Default ("+e.Plat()+").sublime-keymap")
	platPckt := packages.NewPacket(p, e.platformBindings.KeyBindings())
	e.load(platPckt)

	p = path.Join(LIME_USER_PACKAGES_PATH, "Default.sublime-keymap")
	usrPckt := packages.NewPacket(p, e.userBindings.KeyBindings())
	e.load(usrPckt)

	p = path.Join(LIME_USER_PACKAGES_PATH, "Default ("+e.Plat()+").sublime-keymap")
	usrPlatPckt := packages.NewPacket(p, e.KeyBindings())
	e.load(usrPlatPckt)
}
func TestLoadSetting(t *testing.T) {
	editor := GetEditor()
	editor.load(packages.NewPacket("testdata/Default.sublime-settings", editor.Settings()))

	if editor.Settings().Has("tab_size") != true {
		t.Error("Expected editor settings to have tab_size, but it didn't")
	}

	tab_size := editor.Settings().Get("tab_size").(float64)
	if tab_size != 4 {
		t.Errorf("Expected tab_size to equal 4, got: %v", tab_size)
	}
}