snibbets 2.0.23 → 2.0.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4b84e73a8183169220197b680d511137b7aa5e191f22df4a4d8bc30217b9835
4
- data.tar.gz: 6add8e505ca052e703c79aa43f99b2b58a1f05d71d850cda998681a58ac8f01a
3
+ metadata.gz: 3b985def8adf2eefbe7b5f52bc67d909a8d156361f72b30e48df434946648490
4
+ data.tar.gz: 146c828808bea3f147e18852a6bcd362dd894a4e451c6abb1dd1ae0fcc8570f7
5
5
  SHA512:
6
- metadata.gz: dd8b8a316b2fd98445a3d7e387ed54218af99788c40aa0cf73b8bc149339bdc525b7e8cdb47da4cf211d642e65dfa591aabfb2e2ea49fe82650e58ad157f7099
7
- data.tar.gz: 760f09adcce3a26ebb9093f019413e0b6ac14cc020f4cd8c4fbe4aff348bd75651b0c4170eabfd7b64445b47136181f56d9a0d0a38e9af6e60c399a16291b7a1
6
+ metadata.gz: be4e25292cfd9f4b1d13e67b7e211916a6bff4d6acd231f1c64da927901812226267880dac66b68cdc628b79455fbe4ed9e2a7cae869f24b23a60c8d7d82e234
7
+ data.tar.gz: 864ffc66ca4fccf693743ccc2f02990ba0f6ea804de561471c285d14bb8b48b321d8aba8c397b4c1cd219ff2604a09ff2c4660ad97a7caff4c017a93991af952
data/CHANGELOG.md CHANGED
@@ -1,3 +1,37 @@
1
+ ### 2.0.25
2
+
3
+ 2023-04-16 11:09
4
+
5
+ #### NEW
6
+
7
+ - `--nvultra` will open the selected snippet in nvUltra
8
+
9
+ #### IMPROVED
10
+
11
+ - Use Readline for entering info with `--paste`, allows for better editing experience
12
+ - Allow `--edit` with `--paste` to open the new snippet in your editor immediately
13
+
14
+ #### FIXED
15
+
16
+ - Code indentation with `--paste`
17
+
18
+ ### 2.0.24
19
+
20
+ 2023-04-16 10:49
21
+
22
+ #### NEW
23
+
24
+ - `--nvultra` will open the selected snippet in nvUltra
25
+
26
+ #### IMPROVED
27
+
28
+ - Use Readline for entering info with `--paste`, allows for better editing experience
29
+ - Allow `--edit` with `--paste` to open the new snippet in your editor immediately
30
+
31
+ #### FIXED
32
+
33
+ - Code indentation with `--paste`
34
+
1
35
  ### 2.0.23
2
36
 
3
37
  2023-04-16 10:33
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- snibbets (2.0.23)
4
+ snibbets (2.0.25)
5
5
  mdless (~> 1.0, >= 1.0.32)
6
6
  tty-reader (~> 0.9, >= 0.9.0)
7
7
  tty-which (~> 0.5, >= 0.5.0)
data/README.md CHANGED
@@ -155,7 +155,7 @@ Snibbet's implementation of Skylighting has limited but better-looking themes, a
155
155
  ### Usage
156
156
 
157
157
  ```
158
- Snibbets v2.0.23
158
+ Snibbets v2.0.25
159
159
 
160
160
  Usage: snibbets [options] query
161
161
  -a, --all If a file contains multiple snippets, output all of them (no menu)
@@ -169,6 +169,7 @@ Usage: snibbets [options] query
169
169
  --configure Open the configuration file in your default editor
170
170
  --[no-]blockquotes Include block quotes in output
171
171
  --[no-]highlight Use pygments or skylighting to syntax highlight (if installed)
172
+ --nvultra Open the result in nvUltra
172
173
  --save Save the current command line options to the YAML configuration
173
174
  -h, --help Display this screen
174
175
  -v, --version Display version information
data/bin/snibbets CHANGED
@@ -81,6 +81,10 @@ module Snibbets
81
81
  options[:highlight] = v
82
82
  end
83
83
 
84
+ opts.on('--nvultra', 'Open the result in nvUltra') do
85
+ arguments[:nvultra] = true
86
+ end
87
+
84
88
  opts.on('--save', 'Save the current command line options to the YAML configuration') do
85
89
  arguments[:save_config] = true
86
90
  end
@@ -8,7 +8,8 @@ module Snibbets
8
8
  save_config: false,
9
9
  edit_config: false,
10
10
  edit_snippet: false,
11
- paste_snippet: false
11
+ paste_snippet: false,
12
+ nvultra: false
12
13
  }.freeze
13
14
 
14
15
  DEFAULT_OPTIONS = {
@@ -28,12 +28,12 @@ module Snibbets
28
28
  end
29
29
 
30
30
  def ext_to_lang(ext)
31
- matches = lexers.select { |lex| lex[:extensions].map(&:downcase).include?(ext.downcase) }
31
+ matches = lexers.select { |lex| lex[:extensions]&.include?(ext.downcase) }
32
32
  matches.map { |lex| lex[:lexer] }.first || ext
33
33
  end
34
34
 
35
35
  def lang_to_ext(lexer)
36
- matches = lexers.select { |lex| lex[:lexer] == lexer || lex[:aliases].map(&:downcase).include?(lexer.downcase) }
36
+ matches = lexers.select { |lex| lex[:lexer] == lexer || lex[:aliases]&.include?(lexer.downcase) }
37
37
  matches.map { |lex| lex[:extensions].first }.first || lexer
38
38
  end
39
39
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Snibbets
4
- VERSION = '2.0.23'
4
+ VERSION = '2.0.25'
5
5
  end
data/lib/snibbets.rb CHANGED
@@ -1,15 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'cgi'
4
+ require 'erb'
5
+ require 'fileutils'
6
+ require 'json'
7
+ require 'open3'
3
8
  require 'optparse'
4
9
  require 'readline'
5
- require 'json'
6
- require 'cgi'
7
10
  require 'shellwords'
8
- require 'yaml'
9
- require 'fileutils'
10
- require 'tty-which'
11
11
  require 'tty-reader'
12
- require 'open3'
12
+ require 'tty-which'
13
+ require 'yaml'
13
14
  require_relative 'snibbets/version'
14
15
  require_relative 'snibbets/config'
15
16
  require_relative 'snibbets/which'
@@ -111,6 +112,14 @@ module Snibbets
111
112
  search(try: try + 1) if matches.empty?
112
113
  end
113
114
 
115
+ def open_snippet_in_nvultra(filepath)
116
+ notebook = Snibbets.options[:source].gsub(/ /, '%20')
117
+ note = ERB::Util.url_encode(File.basename(filepath, '.md'))
118
+ url = "x-nvultra://open?notebook=#{notebook}&note=#{note}"
119
+ puts url
120
+ `open '#{url}'`
121
+ end
122
+
114
123
  def open_snippet_in_editor(filepath)
115
124
  editor = Snibbets.options[:editor] || Snibbets::Config.best_editor
116
125
 
@@ -181,6 +190,7 @@ module Snibbets
181
190
  puts "New snippet written to #{filename}."
182
191
 
183
192
  open_snippet_in_editor(filepath) if Snibbets.arguments[:edit_snippet]
193
+ open_snippet_in_nvultra(filepath) if Snibbets.arguments[:nvultra]
184
194
  end
185
195
 
186
196
  def handle_launchbar(results)
@@ -254,6 +264,11 @@ module Snibbets
254
264
  Process.exit 0
255
265
  end
256
266
 
267
+ if Snibbets.arguments[:nvultra]
268
+ open_snippet_in_nvultra(filepath)
269
+ Process.exit 0
270
+ end
271
+
257
272
  snippets = input.snippets
258
273
 
259
274
  if snippets.empty?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snibbets
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.23
4
+ version: 2.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra