Skip to content

Commit

Permalink
giga refactor (#2)
Browse files Browse the repository at this point in the history
Giga refactoring, improved code, structure and features.

- Improve error handling and alert windows
- Add go to error line feature
- Improve document will/did save error handling
  • Loading branch information
vigo authored May 10, 2024
1 parent e0ff35e commit 958cc18
Show file tree
Hide file tree
Showing 23 changed files with 935 additions and 333 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Change Log

**2024-05-10**

Giga refactoring, improved code, structure and features.

- Improve error handling and alert windows
- Add go to error line feature
- Improve document will/did save error handling

**2024-05-06**

Mega refactoring, improved code structure and speed.

- Remove `TM_PYRUFF_DEBUG` TextMate variable.
- Add logging mechanism
- Speed improvements, integrated and tested on `ruff` version `0.4.2`
12 changes: 6 additions & 6 deletions Commands/Auto fix errors.tmCommand
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby18 -wKU
require "#{ENV['TM_BUNDLE_SUPPORT']}/helper"
Ruff.auto_fix_errors
</string>
require ENV["TM_BUNDLE_SUPPORT"] + "/ruff_linter"
RuffLinter.run_document_will_save</string>
<key>input</key>
<string>document</string>
<key>inputFormat</key>
<string>text</string>
<key>name</key>
<string>Auto fix errors</string>
<string>Document Will Save</string>
<key>outputCaret</key>
<string>interpolateByLine</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>replaceDocument</string>
<key>scope</key>
<string>source.python</string>
<string>source.python.ruff</string>
<key>semanticClass</key>
<string>callback.document.will-save.1</string>
<string>callback.document.will-save.50</string>
<key>uuid</key>
<string>F2DC6971-9B06-4593-9EC6-D467AADB43AF</string>
<key>version</key>
Expand Down
56 changes: 56 additions & 0 deletions Commands/Go to error line.tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>autoScrollOutput</key>
<true/>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby18 -wKU
require ENV['TM_SUPPORT_PATH'] + '/lib/ui'
TM_DOCUMENT_UUID = ENV["TM_DOCUMENT_UUID"]
filename = "/tmp/textmate-ruff-#{TM_DOCUMENT_UUID}.goto"
if File.exist?(filename)
errors = File.read(filename)
if errors
errors = errors.split("\n").sort
selected_index = TextMate::UI.menu(errors)
unless selected_index.nil?
selected_error = errors[selected_index]
if selected_error
line = selected_error.split(" ").first
system(ENV["TM_MATE"], "--uuid", TM_DOCUMENT_UUID, "--line", line)
end
end
end
end
</string>
<key>input</key>
<string>none</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>~g</string>
<key>name</key>
<string>Go to error line</string>
<key>outputCaret</key>
<string>interpolateByChar</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>discard</string>
<key>scope</key>
<string>source.python.ruff</string>
<key>uuid</key>
<string>40241AB3-EAF3-4967-8F02-555020846FB4</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>
7 changes: 4 additions & 3 deletions Commands/NOQAlizer all.tmCommand
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby18 -wKU
require "#{ENV['TM_BUNDLE_SUPPORT']}/helper"
Ruff.noqalize_all
require ENV["TM_BUNDLE_SUPPORT"] + "/ruff_linter"
RuffLinter.noqalize_all
</string>
<key>input</key>
<string>document</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>^N</string>
<string>~a</string>
<key>name</key>
<string>NOQAlizer all</string>
<key>outputCaret</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby18 -wKU
require "#{ENV['TM_BUNDLE_SUPPORT']}/helper"
Ruff.show_rules
</string>
require ENV["TM_BUNDLE_SUPPORT"] + "/ruff_linter"
RuffLinter.run_document_will_save(:autofix =&gt; true)</string>
<key>input</key>
<string>document</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>^R</string>
<string>~f</string>
<key>name</key>
<string>Show rules for existing errors</string>
<string>Run Autofix Manually</string>
<key>outputCaret</key>
<string>interpolateByLine</string>
<string>afterOutput</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>discard</string>
<string>replaceDocument</string>
<key>scope</key>
<string>source.python</string>
<string>source.python.ruff</string>
<key>uuid</key>
<string>7F9DF791-D14A-44AD-A580-75EA74F28895</string>
<string>D16E4203-64E5-46BF-B8B9-6B5AABA4795B</string>
<key>version</key>
<integer>2</integer>
</dict>
Expand Down
12 changes: 6 additions & 6 deletions Commands/Run Ruff Linter on save.tmCommand
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby18 -wKU
require "#{ENV['TM_BUNDLE_SUPPORT']}/helper"
Ruff.run_ruff_linter
</string>
require ENV["TM_BUNDLE_SUPPORT"] + "/ruff_linter"
RuffLinter.run_document_did_save</string>
<key>input</key>
<string>document</string>
<key>inputFormat</key>
<string>text</string>
<key>name</key>
<string>Run Ruff Linter on save</string>
<string>Document Did Save</string>
<key>outputCaret</key>
<string>interpolateByLine</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>discard</string>
<key>scope</key>
<string>source.python</string>
<string>source.python.ruff</string>
<key>semanticClass</key>
<string>callback.document.did-save.1</string>
<string>callback.document.did-save.50</string>
<key>uuid</key>
<string>9DB6C68B-B678-40FA-962B-799733FCA199</string>
<key>version</key>
Expand Down
Loading

0 comments on commit 958cc18

Please sign in to comment.