Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support sublime context menu and file syntax option #19

Merged
merged 2 commits into from
Nov 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
[
{
"caption": "Preferences",
"id": "preferences",
"mnemonic": "n",
"children":
[
{
"caption": "Package Settings",
"id": "package-settings",
"mnemonic": "P",
"children":
[
{
"caption": "QuickSimplenote",
"children":
[
{
"args": {
"file": "${packages}/QuickSimplenote/README.md"
},
"caption": "README",
"command": "open_file"
},
{ "caption": "-" },
{
"command": "open_file",
"args": {"file": "${packages}/QuickSimplenote/quick_simplenote.sublime-settings"},
"caption": "Settings – Default"
},
{
"command": "open_file",
"args": {"file": "${packages}/User/quick_simplenote.sublime-settings"},
"caption": "Settings – User"
},
{ "caption": "-" },
{
"args": {
"file": "${packages}/QuickSimplenote/Default (Windows).sublime-keymap",
"platform": "Windows"
},
"caption": "Key Bindings \u2013 Default",
"command": "open_file"
},
{
"args": {
"file": "${packages}/QuickSimplenote/Default (OSX).sublime-keymap",
"platform": "OSX"
},
"caption": "Key Bindings \u2013 Default",
"command": "open_file"
},
{
"args": {
"file": "${packages}/QuickSimplenote/Default (Linux).sublime-keymap",
"platform": "Linux"
},
"caption": "Key Bindings \u2013 Default",
"command": "open_file"
},
{
"args": {
"file": "${packages}/User/Default (Windows).sublime-keymap",
"platform": "Windows"
},
"caption": "Key Bindings \u2013 User",
"command": "open_file"
},
{
"args": {
"file": "${packages}/User/Default (OSX).sublime-keymap",
"platform": "OSX"
},
"caption": "Key Bindings \u2013 User",
"command": "open_file"
},
{
"args": {
"file": "${packages}/User/Default (Linux).sublime-keymap",
"platform": "Linux"
},
"caption": "Key Bindings \u2013 User",
"command": "open_file"
},
{ "caption": "-" }
]
}
]
}
]
}
]
17 changes: 12 additions & 5 deletions quick_simplenote.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def get_note_from_path(view_filepath):
if note:
note = note[0]


return note

def get_note_name(note):
Expand Down Expand Up @@ -294,6 +294,13 @@ def flush_saves():
HandleNoteViewCommand.waiting_to_save.append(new_entry)
sublime.set_timeout(flush_saves, debounce_time)

def on_load(self, view):
view_filepath = view.file_name()
note = get_note_from_path(view_filepath)
syntax = settings.get('note_syntax')
if note and syntax:
view.set_syntax_file(syntax)

def get_current_content(self, view):
note_file_content = ""
try:
Expand Down Expand Up @@ -433,7 +440,7 @@ def notes_synch(self, notes):
for view in view_list:
if view.file_name() == None:
continue

if view.is_dirty():
open_files_dirty.append(path.split(view.file_name())[1])
else:
Expand All @@ -447,13 +454,13 @@ def notes_synch(self, notes):

if not note['needs_update']:
continue

try:
filename = note['filename']
except KeyError as e:
others.append(note)
continue

if filename in open_files_dirty:
lu.append(note)
elif filename in open_files_ok:
Expand Down Expand Up @@ -637,4 +644,4 @@ def reload_if_needed():
settings.add_on_change('username', reload_if_needed)
settings.add_on_change('password', reload_if_needed)

reload_if_needed()
reload_if_needed()
11 changes: 9 additions & 2 deletions quick_simplenote.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"username": ""
,"password": ""
// --------------------------------
// Simplenote Synctax setting:
// (If you are using MarkdownEditing, try
// "note_syntax": "Packages/MarkdownEditing/Markdown.tmLanguage"
// )
// --------------------------------
,"note_syntax": ""
// --------------------------------
// Sync settings:
// --------------------------------
// Sync when sublime text starts:
Expand Down Expand Up @@ -32,5 +39,5 @@
// "title_regex": "\\[ST\\]",
// "extension": "todo"
// }]
}

}