A TextMate Bundle for Forester
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix completion shortcut issues

+77 -40
+20 -11
Forester.tmbundle/Commands/Complete.tmCommand
··· 7 7 <key>command</key> 8 8 <string>#!/usr/bin/env ruby 9 9 # encoding: utf-8 10 - 11 10 require "#{ENV['TM_SUPPORT_PATH']}/lib/ui" 12 11 require 'pathname' 13 12 14 - file = ENV['TM_FILEPATH'] 15 - query = STDIN.read # ENV['TM_CURRENT_WORD'] || "" 13 + file = ENV['TM_FILEPATH'] 14 + scope = ENV['TM_SCOPE'] || "" 15 + raw_query = STDIN.read 16 16 17 + # Determine wrapper and strip it from query 18 + prefix, suffix = case scope 19 + when /meta\.link\.wiki\.forester/ then ['[[', ']]'] 20 + when /meta\.link\.ref\.forester/ then ['{', '}'] 21 + when /meta\.link\.md\.forester/ then ['(', ')'] 22 + else ['', ''] 23 + end 24 + 25 + query = raw_query.dup 26 + query = query[prefix.length..] if prefix.length &gt; 0 &amp;&amp; query.start_with?(prefix) 27 + query = query[0..-(suffix.length + 1)] if suffix.length &gt; 0 &amp;&amp; query.end_with?(suffix) 17 28 18 29 def find_forest_root(path) 19 30 return nil if path.nil? ··· 26 37 end 27 38 28 39 root = find_forest_root(file) 29 - 30 40 unless root 31 41 TextMate::UI.tool_tip "No forest.toml found in ancestor directories." 32 42 exit 200 33 43 end 34 44 35 - 36 45 Dir.chdir(root) do 37 - # Use full path to forester if it's not in your shell PATH 38 46 raw_output = `forester complete --title="#{query}"` 39 47 if $?.exitstatus != 0 40 48 TextMate::UI.tool_tip "forester failed to find completions (try building)." 41 49 exit 200 42 50 end 51 + 43 52 if raw_output.nil? || raw_output.strip.empty? 44 - TextMate::UI.tool_tip ("No matches found.") 53 + TextMate::UI.tool_tip "No matches found." 45 54 exit 200 46 55 end 47 56 ··· 50 59 next nil if id.nil? 51 60 { 52 61 'display' =&gt; "#{title.strip} (#{id.strip})", 53 - 'insert' =&gt; id.strip, 62 + 'insert' =&gt; "#{prefix}#{id.strip}#{suffix}", 54 63 } 55 64 end.compact 56 - 65 + 57 66 if choices.any? 58 67 selected = TextMate::UI.menu(choices.map { |c| c['display'] }) 59 68 print choices[selected]['insert'] if selected ··· 66 75 <key>inputFormat</key> 67 76 <string>text</string> 68 77 <key>keyEquivalent</key> 69 - <string>~</string> 78 + <string>^.</string> 70 79 <key>name</key> 71 80 <string>Complete</string> 72 81 <key>outputCaret</key> ··· 76 85 <key>outputLocation</key> 77 86 <string>replaceInput</string> 78 87 <key>scope</key> 79 - <string>markup.underline.link</string> 88 + <string>meta.link.wiki.forester, meta.link.ref.forester, meta.link.md.forester</string> 80 89 <key>uuid</key> 81 90 <string>63B481D1-6AA9-457D-B872-CFC5EE99F8EC</string> 82 91 <key>version</key>
+57 -29
Forester.tmbundle/Syntaxes/Forester.tmLanguage
··· 155 155 </dict> 156 156 <dict> 157 157 <key>include</key> 158 + <string>#markdown-link-title</string> 159 + </dict> 160 + <dict> 161 + <key>include</key> 158 162 <string>#markdown-link</string> 159 163 </dict> 160 164 <dict> ··· 212 216 </dict> 213 217 <key>markdown-link</key> 214 218 <dict> 215 - <key>captures</key> 219 + <key>begin</key> 220 + <string>(?&lt;=\])(\()</string> 221 + <key>beginCaptures</key> 216 222 <dict> 217 223 <key>1</key> 218 224 <dict> 219 225 <key>name</key> 220 - <string>punctuation.definition.link.begin.forester</string> 226 + <string>punctuation.definition.url.begin.forester</string> 221 227 </dict> 222 - <key>2</key> 228 + </dict> 229 + <key>contentName</key> 230 + <string>markup.underline.link.forester</string> 231 + <key>end</key> 232 + <string>\)</string> 233 + <key>endCaptures</key> 234 + <dict> 235 + <key>0</key> 223 236 <dict> 224 237 <key>name</key> 225 - <string>string.other.link.title.forester</string> 238 + <string>punctuation.definition.url.end.forester</string> 226 239 </dict> 227 - <key>3</key> 240 + </dict> 241 + <key>name</key> 242 + <string>meta.link.md.forester</string> 243 + </dict> 244 + <key>markdown-link-title</key> 245 + <dict> 246 + <key>begin</key> 247 + <string>(\[)</string> 248 + <key>beginCaptures</key> 249 + <dict> 250 + <key>1</key> 228 251 <dict> 229 252 <key>name</key> 230 - <string>punctuation.definition.link.end.forester</string> 253 + <string>punctuation.definition.link.begin.forester</string> 231 254 </dict> 232 - <key>4</key> 233 - <dict> 234 - <key>name</key> 235 - <string>punctuation.definition.url.begin.forester</string> 236 - </dict> 237 - <key>5</key> 255 + </dict> 256 + <key>contentName</key> 257 + <string>string.other.link.title.forester</string> 258 + <key>end</key> 259 + <string>(\])(?=\()</string> 260 + <key>endCaptures</key> 261 + <dict> 262 + <key>1</key> 238 263 <dict> 239 264 <key>name</key> 240 - <string>markup.underline.link.forester</string> 265 + <string>punctuation.definition.link.end.forester</string> 241 266 </dict> 242 - <key>6</key> 267 + </dict> 268 + <key>patterns</key> 269 + <array> 243 270 <dict> 244 - <key>name</key> 245 - <string>punctuation.definition.url.end.forester</string> 271 + <key>include</key> 272 + <string>#macro-content</string> 246 273 </dict> 247 - </dict> 248 - <key>match</key> 249 - <string>(\[)([^\]]+)(\])(\()([^\)]+)(\))</string> 250 - <key>name</key> 251 - <string>meta.link.markdown.forester</string> 274 + </array> 252 275 </dict> 253 276 <key>math</key> 254 277 <dict> ··· 282 305 <key>ref-macro</key> 283 306 <dict> 284 307 <key>begin</key> 285 - <string>(\\)(ref|import|transclude|author)\{</string> 308 + <string>(?&lt;=\\ref|\\import|\\transclude|\\author)\{</string> 286 309 <key>beginCaptures</key> 287 310 <dict> 288 - <key>1</key> 311 + <key>0</key> 289 312 <dict> 290 313 <key>name</key> 291 - <string>keyword.control.forester</string> 292 - </dict> 293 - <key>2</key> 294 - <dict> 295 - <key>name</key> 296 - <string>keyword.control.forester</string> 314 + <string>punctuation.definition.link.begin.forester</string> 297 315 </dict> 298 316 </dict> 299 317 <key>contentName</key> 300 318 <string>markup.underline.link.forester</string> 301 319 <key>end</key> 302 320 <string>\}</string> 321 + <key>endCaptures</key> 322 + <dict> 323 + <key>0</key> 324 + <dict> 325 + <key>name</key> 326 + <string>punctuation.definition.link.end.forester</string> 327 + </dict> 328 + </dict> 329 + <key>name</key> 330 + <string>meta.link.ref.forester</string> 303 331 <key>patterns</key> 304 332 <array> 305 333 <dict>