Skip to content

Commit d1a4ff1

Browse files
author
Rene Schallner
committed
first commit to zettelkasten mode
1 parent 4addc06 commit d1a4ff1

5 files changed

+958
-2
lines changed

sublime_zk.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class ZkConstants:
2525
"""
2626
Settings_File = 'sublime_zk.sublime-settings'
2727
Syntax_File = 'Packages/sublime_zk/sublime_zk.sublime-syntax'
28+
ZKM_Results_Syntax_File = 'Packages/sublime_zk/zk-mode/sublime_zk_results.sublime-syntax'
2829
Link_Prefix = '['
2930
Link_Prefix_Len = len(Link_Prefix)
3031
Link_Postfix = ']'
@@ -521,7 +522,7 @@ class ExternalSearch:
521522
Static class to group all external search related functions.
522523
"""
523524
SEARCH_COMMAND = 'ag'
524-
EXTERNALIZE = '.search_results.md' # '' to skip
525+
EXTERNALIZE = '.search_results.zkr' # '' to skip
525526

526527
@staticmethod
527528
def search_all_tags(folder, extension):
@@ -679,6 +680,7 @@ def show_search_results(window, folder, title, lines, new_pane_setting):
679680
if ExternalSearch.EXTERNALIZE:
680681
new_view = window.open_file(ExternalSearch.external_file(folder))
681682
window.set_view_index(new_view, PANE_FOR_OPENING_RESULTS, 0)
683+
new_view.set_syntax_file(ZkConstants.ZKM_Results_Syntax_File)
682684
else:
683685
settings = get_settings()
684686
new_pane = settings.get(new_pane_setting)

sublime_zk.sublime-settings

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
// Sort note lists (search results) by
7878
// - title
7979
// - ID <-- default
80-
"sort_notelists_by": "id"
80+
"sort_notelists_by": "id",
8181

82+
// set to true to enable super awesome zettelkasten mode
83+
"zettelkasten_mode" : true,
8284
}

sublime_zk_results.sublime-settings

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"color_scheme": "Packages/sublime_zk/Solarized (Light) - ZK.tmTheme",
3+
"extensions":
4+
[
5+
"zkr"
6+
],
7+
"font_face": "consolas",
8+
"font_size": 10,
9+
}
+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
%YAML 1.2
2+
---
3+
# http://www.sublimetext.com/docs/3/syntax.html
4+
name: Zettelkasten-Results
5+
file_extensions:
6+
- md
7+
- mdown
8+
- markdown
9+
- markdn
10+
scope: text.html.markdown.multimarkdown.custom
11+
contexts:
12+
main:
13+
- match: (?=(?<!\s)---(\s*coffee|\s*json)?\n$)
14+
push: front-matter
15+
- match: ""
16+
set: body
17+
front-matter:
18+
- match: ^\s*---\s*$
19+
with_prototype:
20+
- include: scope:source.yaml#prototype
21+
push:
22+
- meta_scope: markup.raw.yaml.front-matter
23+
- meta_content_scope: source.yaml
24+
- match: ^\s*---\s*
25+
pop: true
26+
- include: scope:source.yaml
27+
- match: ^\s*---\s*coffee\s*$
28+
push:
29+
- meta_scope: markup.raw.coffee.front-matter
30+
- meta_content_scope: source.coffee
31+
- match: ^\s*---\s*
32+
pop: true
33+
- include: scope:source.coffee
34+
- match: ^\s*---\s*json\s*$
35+
push:
36+
- meta_scope: markup.raw.json.front-matter
37+
- meta_content_scope: source.json
38+
- match: ^\s*---\s*
39+
pop: true
40+
- include: scope:source.json
41+
- match: ""
42+
pop: true
43+
set: body
44+
body:
45+
- match: |-
46+
(?x)^
47+
(?= [ ]{,3}>.
48+
| ([ ]{4}|\t)(?!$)
49+
| [#]{1,6}\s*+
50+
| [ ]{,3}(?<marker>[-*_])([ ]{,2}\k<marker>){2,}[ \t]*+$
51+
)
52+
comment: |
53+
We could also use an empty end match and set
54+
applyEndPatternLast, but then we must be sure that the begin
55+
pattern will only match stuff matched by the sub-patterns.
56+
push:
57+
- meta_scope: meta.block-level.markdown
58+
- match: |-
59+
(?x)^
60+
(?! [ ]{,3}>.
61+
| ([ ]{4}|\t)
62+
| [#]{1,6}\s*+
63+
| [ ]{,3}(?<marker>[-*_])([ ]{,2}\k<marker>){2,}[ \t]*+$
64+
)
65+
pop: true
66+
- include: block_quote
67+
- include: block_raw
68+
- include: heading
69+
- include: separator
70+
- match: ''
71+
push: scope:text.html.markdown.multimarkdown
72+
with_prototype:
73+
# [^footnotes]
74+
- match: '(\[)(\^)([^]]*)(\])'
75+
captures:
76+
'1': punctuation.definition.footnote.begin.markdown
77+
'2': support.function.footnote.markdown
78+
'3': support.function.footnote.markdown
79+
'4': punctuation.definition.footnote.begin.markdown
80+
# [#key]: values , ... for autobib insertion mmd style
81+
- match: '(\[)(#)([^]]*)(\])(:)([ ]*)(.*)'
82+
captures:
83+
'1': punctuation.definition.constant.markdown
84+
'2': constant.other.reference.link.markdown
85+
'3': constant.other.reference.link.markdown
86+
'4': punctuation.definition.constant.markdown
87+
'5': punctuation.separator.key-value.markdown
88+
'6': meta.link.reference.def.markdown
89+
'7': markup.underline.link.markdown
90+
# [@pandoc] and [see @pandoc]
91+
- match: '(\[[a-zA-Z:\. ]*)(@)([^]]*)(\])'
92+
captures:
93+
'1': punctuation.definition.footnote.begin.markdown
94+
'2': constant.other.reference.link.markdown
95+
'3': constant.other.reference.link.markdown
96+
'4': punctuation.definition.footnote.begin.markdown
97+
- match: '([\s]+|^)(@)([\S]+)'
98+
captures:
99+
'1': text.html.markdown.multimarkdown.custom
100+
'2': constant.other.reference.link.markdown
101+
'3': constant.other.reference.link.markdown
102+
# all sorts of #tags
103+
- match: '(\s)(#+([^#\W]|[-§]|:[a-zA-Z0-9])+)' # better real just tags matching
104+
captures:
105+
'1': markup.zettel.space
106+
'2': markup.zettel.tag markup.italic
107+
# a [201701010202] note link
108+
- match: '([\[]?\[)([0-9.]{12,18})([^]]*)(\][\]]?)'
109+
captures:
110+
'1': punctuation.definition.footnote.begin.markdown
111+
'2': markup.zettel.link
112+
'3': markup.zettel.linktitle #constant.other.reference.link.markdown
113+
'4': punctuation.definition.footnote.begin.markdown
114+
# olds school §201701010202 note link
115+
- match: '(§)([0-9]{12,14})'
116+
captures:
117+
'1': punctuation.definition.footnote.begin.markdown
118+
'2': markup.zettel.link
119+
# todo
120+
- match: '(?i)(todo:)'
121+
captures:
122+
'1': string.unquoted.plain.out.yaml
123+
# image links ![desc](url){attrs}
124+
- match: '(!\[)(.*)(\])(\()(.*)(\))(\{)?([^\}]*)(\})?'
125+
captures:
126+
'1': meta.image.inline.markdown punctuation.definition.image.begin.markdown
127+
'2': meta.image.inline.description.markdown
128+
'3': meta.image.inline.markdown punctuation.definition.image.end.markdown
129+
'4': meta.image.inline.markdown punctuation.definition.metadata.begin.markdown
130+
'5': meta.image.inline.markdown markup.underline.link.image.markdown
131+
'6': meta.image.inline.markdown punctuation.definition.metadata.end.markdown
132+
'7': meta.image.inline.markdown punctuation.definition.imageattr.begin.markdown
133+
'8': meta.image.inline.markdown.imageattr
134+
'9': meta.image.inline.markdown punctuation.definition.imageattr.end.markdown
135+

0 commit comments

Comments
 (0)