0
文件我有崇高的目錄結構是這樣的:得到一個設定值,從位於非標準目錄
Packages
|-- Foo
| |-- Markdown.sublime-settings
|
|-- Bar
| |-- plugin.py
|
|-- User
|-- Markdown.sublime-settings
於是,我試圖讓一個wrap_width
值,存儲在Foo/Markdown.sublime-setting
。出於某種原因,看來load_setting
方法不起作用,儘管save_settings
工作正常。
import sublime
import sublime_plugin
class MarkdownSettings(sublime_plugin.EventListener):
def on_activated(self, view):
path = view.file_name()
if path:
e = view.file_name().split('.')[1]
if e == ("md" or "mmd"):
# Simple test. It works
x = sublime.load_settings("Markdown.sublime-settings")
wrap_width = x.get("wrap_width")
print(wrap_width) # Prints 50
# If I change directory to "../Foo", `load_setting` method would not work
x = sublime.load_settings("../Foo/Markdown.sublime-settings")
wrap_width = x.get("wrap_width")
print(wrap_width) # Prints None
# The code below is added just for demonstration purposes,
# to show that `save_setting` method works fine.
x = sublime.load_settings("../Foo/Markdown.sublime-settings")
x.set("wrap_width", 20)
sublime.save_settings("../Foo/Markdown.sublime-settings") # File updated
我怎麼能獲取存儲在Foo/Markdown.sublime-settings
wrap_width
價值?