From e6df1e3c19b66d82a0ddb1ce65c99e78f29d3713 Mon Sep 17 00:00:00 2001 From: Pedro Girardi Date: Tue, 31 Oct 2023 11:17:31 -0300 Subject: [PATCH 01/15] Git ignore '.ruff_cache' --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f2ac132..6d82f36 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ Pep.sublime-workspace .clj-kondo .vscode .cpcache -.idea/ \ No newline at end of file +.idea/ +.ruff_cache From 722c6c511a5d06cac5a844412670c2ccc66b065b Mon Sep 17 00:00:00 2001 From: Pedro Girardi Date: Tue, 31 Oct 2023 11:28:47 -0300 Subject: [PATCH 02/15] Update Clojure & ClojureScript --- deps.edn | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/deps.edn b/deps.edn index b1a37d9..fcad4fd 100644 --- a/deps.edn +++ b/deps.edn @@ -1,2 +1,3 @@ -{:deps {org.clojure/clojure {:mvn/version "1.11.0"} - org.clojure/clojurescript {:mvn/version "1.10.879"}}} +{:deps + {org.clojure/clojure {:mvn/version "1.11.1"} + org.clojure/clojurescript {:mvn/version "1.11.121"}}} From 080a3ad940ab9873b2281436213c19816916fd52 Mon Sep 17 00:00:00 2001 From: Pedro Girardi Date: Tue, 31 Oct 2023 12:25:39 -0300 Subject: [PATCH 03/15] TODO Symbols --- tests/symbols.clj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/symbols.clj b/tests/symbols.clj index b319be6..ec60367 100644 --- a/tests/symbols.clj +++ b/tests/symbols.clj @@ -1,3 +1,11 @@ +;; Problem: +;; Pep finds usages of these symbols in paths, +;; but from a var it doesn't find a symbol. +;; +;; Solution: +;; Searching for usages of symbol or var should +;; also include symbols. + 'clojure.core/map 'example/foo From 90d687ce8c4a03a4372daa5056170a9a3933b3c9 Mon Sep 17 00:00:00 2001 From: Pedro Girardi Date: Tue, 31 Oct 2023 12:26:25 -0300 Subject: [PATCH 04/15] Link Issue --- tests/symbols.clj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/symbols.clj b/tests/symbols.clj index ec60367..cea9dfa 100644 --- a/tests/symbols.clj +++ b/tests/symbols.clj @@ -5,6 +5,8 @@ ;; Solution: ;; Searching for usages of symbol or var should ;; also include symbols. +;; +;; See https://github.com/pedrorgirardi/Pep/issues/68 'clojure.core/map From 65dc3b0d1a08f75bf5e74cab8bd091ef53f424fa Mon Sep 17 00:00:00 2001 From: Pedro Girardi Date: Tue, 31 Oct 2023 12:31:06 -0300 Subject: [PATCH 05/15] More TODO --- tests/example.clj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/example.clj b/tests/example.clj index 8df1a22..ee91537 100644 --- a/tests/example.clj +++ b/tests/example.clj @@ -68,3 +68,6 @@ x (foo 1) (foo 1) + +;; TODO: It should highlight `foo` too. +'example/foo From 526eceff90569accf60f935a0a781549e36148b5 Mon Sep 17 00:00:00 2001 From: Pedro Girardi Date: Fri, 3 Nov 2023 20:10:18 -0300 Subject: [PATCH 06/15] Command to Toggle View Annotations https://github.com/pedrorgirardi/Pep/issues/70 --- Default.sublime-commands | 4 ++++ pep.py | 23 +++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Default.sublime-commands b/Default.sublime-commands index 96ed671..2a34f5f 100644 --- a/Default.sublime-commands +++ b/Default.sublime-commands @@ -23,6 +23,10 @@ "caption": "Pep: Toggle Highlighting", "command": "pg_pep_toggle_highlight" }, + { + "caption": "Pep: Toggle View Annotations", + "command": "pg_pep_toggle_view_annotations" + }, { "caption": "Pep: Outline", "command": "pg_pep_outline" diff --git a/pep.py b/pep.py index 71e07db..535d945 100644 --- a/pep.py +++ b/pep.py @@ -55,6 +55,9 @@ # Setting used to override the clj-kondo config for a view analysis. S_PEP_CLJ_KONDO_CONFIG = "pep_clj_kondo_config" +# Setting used to toggle a view's annotations. +S_PEP_ANNOTATE_VIEW = "pep_annotate_view" + # Configuration shared by paths and view analysis - without a common configuration the index would be inconsistent. CLJ_KONDO_VIEW_PATHS_ANALYSIS_CONFIG = "{:var-definitions true, :var-usages true, :arglists true, :locals true, :keywords true, :symbols true, :java-class-definitions false, :java-class-usages true, :java-member-definitions false, :instance-invocations true}" CLJ_KONDO_CLASSPATH_ANALYSIS_CONFIG = "{:var-usages false :var-definitions {:shallow true} :arglists true :keywords true :java-class-definitions false}" @@ -74,7 +77,7 @@ def af_annotate(context, analysis): """ Analysis Function to annotate view. - Depends on setting to annotate on save. + Depends on setting to annotate view after analysis. """ if view := context["view"]: if annotate_view_after_analysis(view.window()): @@ -2761,6 +2764,13 @@ def finding_minihtml(finding): """ + # Erase regions from previous analysis. + erase_analysis_regions(view) + + # Skip annotation if view explicitly set the custom setting to disable it. + if view.settings().get(S_PEP_ANNOTATE_VIEW) is False: + return + analysis = view_analysis(view.id()) findings = analysis_findings(analysis) @@ -2779,9 +2789,6 @@ def finding_minihtml(finding): warning_region_set.append(finding_region(finding)) warning_minihtml_set.append(finding_minihtml(finding)) - # Erase regions from previous analysis. - erase_analysis_regions(view) - redish = view.style_for_scope("region.redish").get("foreground") orangish = view.style_for_scope("region.orangish").get("foreground") @@ -4127,6 +4134,14 @@ def run(self, edit): self.is_toggled = not self.is_toggled +class PgPepToggleViewAnnotationsCommand(sublime_plugin.TextCommand): + def run(self, edit): + # Is enabled by default: + annotate = self.view.settings().get(S_PEP_ANNOTATE_VIEW, True) + + self.view.settings().set(S_PEP_ANNOTATE_VIEW, not annotate) + + class PgPepViewSummaryStatusCommand(sublime_plugin.TextCommand): def run(self, edit): try: From 77690b2394c4e9641c4098754da851ee682c2ac8 Mon Sep 17 00:00:00 2001 From: Pedro Girardi Date: Fri, 3 Nov 2023 20:11:38 -0300 Subject: [PATCH 07/15] Update CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40c0085..3535cb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. +## 0.20.0 - in development +- [Command to Toggle View Annotations #70](https://github.com/pedrorgirardi/Pep/issues/70) + ## 0.19.0 - 2023-10-31 There were many internal changes in this version and I'm sorry I made some breaking changes. From 1b1678e341ecfa43181c9b6ee8e3d8cbb62409a7 Mon Sep 17 00:00:00 2001 From: Pedro Girardi Date: Fri, 3 Nov 2023 20:14:46 -0300 Subject: [PATCH 08/15] Removed Command to Clear a View's Annotations --- CHANGELOG.md | 1 + Default.sublime-commands | 4 ---- pep.py | 5 ----- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3535cb5..a6d20b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. ## 0.20.0 - in development - [Command to Toggle View Annotations #70](https://github.com/pedrorgirardi/Pep/issues/70) +- Removed Command to Clear a View's Annotations ## 0.19.0 - 2023-10-31 There were many internal changes in this version and I'm sorry I made some breaking changes. diff --git a/Default.sublime-commands b/Default.sublime-commands index 2a34f5f..60aa952 100644 --- a/Default.sublime-commands +++ b/Default.sublime-commands @@ -15,10 +15,6 @@ "caption": "Pep: Annotate View", "command": "pg_pep_annotate" }, - { - "caption": "Pep: Clear View Annotations", - "command": "pg_pep_clear_annotations" - }, { "caption": "Pep: Toggle Highlighting", "command": "pg_pep_toggle_highlight" diff --git a/pep.py b/pep.py index 535d945..5d67b5d 100644 --- a/pep.py +++ b/pep.py @@ -4197,11 +4197,6 @@ def run(self, edit): print("Pep: Error: PgPepViewNamespaceStatusCommand", traceback.format_exc()) -class PgPepClearAnnotationsCommand(sublime_plugin.TextCommand): - def run(self, edit): - erase_analysis_regions(self.view) - - class PgPepAnnotateCommand(sublime_plugin.TextCommand): def run(self, edit): try: From 15d14c3202def508aa10381ade98520fad9d7994 Mon Sep 17 00:00:00 2001 From: Pedro Girardi Date: Fri, 3 Nov 2023 20:32:22 -0300 Subject: [PATCH 09/15] Deleted unused (and broken) Commands - PgPepClearHighlightedCommand - PgPepToggleHighlightCommand --- CHANGELOG.md | 4 ++++ Default.sublime-commands | 4 ---- pep.py | 21 --------------------- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6d20b9..31fd75d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,12 @@ All notable changes to this project will be documented in this file. ## 0.20.0 - in development +New: - [Command to Toggle View Annotations #70](https://github.com/pedrorgirardi/Pep/issues/70) + +Breaking: - Removed Command to Clear a View's Annotations +- Deleted Commands `PgPepClearHighlightedCommand` and `PgPepToggleHighlightCommand` ## 0.19.0 - 2023-10-31 There were many internal changes in this version and I'm sorry I made some breaking changes. diff --git a/Default.sublime-commands b/Default.sublime-commands index 60aa952..efdb5dc 100644 --- a/Default.sublime-commands +++ b/Default.sublime-commands @@ -15,10 +15,6 @@ "caption": "Pep: Annotate View", "command": "pg_pep_annotate" }, - { - "caption": "Pep: Toggle Highlighting", - "command": "pg_pep_toggle_highlight" - }, { "caption": "Pep: Toggle View Annotations", "command": "pg_pep_toggle_view_annotations" diff --git a/pep.py b/pep.py index 5d67b5d..38c636a 100644 --- a/pep.py +++ b/pep.py @@ -4113,27 +4113,6 @@ def run(self, edit): highlight_thingy(self.view) -class PgPepClearHighlightedCommand(sublime_plugin.TextCommand): - def run(self, edit): - self.view.erase_regions(HIGHLIGHTED_REGIONS_KEY) - self.view.set_status(HIGHLIGHTED_STATUS_KEY, "") - - -class PgPepToggleHighlightCommand(sublime_plugin.TextCommand): - def __init__(self, view): - self.view = view - self.is_toggled = ( - True if self.view.get_regions(HIGHLIGHTED_REGIONS_KEY) else False - ) - - def run(self, edit): - self.view.run_command( - "pg_pep_clear_highlighted" if self.is_toggled else "pg_pep_highlight" - ) - - self.is_toggled = not self.is_toggled - - class PgPepToggleViewAnnotationsCommand(sublime_plugin.TextCommand): def run(self, edit): # Is enabled by default: From 4adefe96a6bccf472f77b3bbb2dfa40203847d78 Mon Sep 17 00:00:00 2001 From: Pedro Girardi Date: Fri, 3 Nov 2023 20:36:23 -0300 Subject: [PATCH 10/15] Removed Command to Annotate View The new Command to Toggle View Annotations already does it. --- CHANGELOG.md | 5 +++-- Default.sublime-commands | 4 ---- pep.py | 8 -------- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31fd75d..0bc859a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,9 @@ New: - [Command to Toggle View Annotations #70](https://github.com/pedrorgirardi/Pep/issues/70) Breaking: -- Removed Command to Clear a View's Annotations -- Deleted Commands `PgPepClearHighlightedCommand` and `PgPepToggleHighlightCommand` +- Removed Command `PgPepClearAnnotationsCommand` +- Removed Command `PgPepAnnotateCommand` +- Removed Commands `PgPepClearHighlightedCommand` and `PgPepToggleHighlightCommand` ## 0.19.0 - 2023-10-31 There were many internal changes in this version and I'm sorry I made some breaking changes. diff --git a/Default.sublime-commands b/Default.sublime-commands index efdb5dc..7d0715c 100644 --- a/Default.sublime-commands +++ b/Default.sublime-commands @@ -11,10 +11,6 @@ "caption": "Pep: Analyze", "command": "pg_pep_analyze" }, - { - "caption": "Pep: Annotate View", - "command": "pg_pep_annotate" - }, { "caption": "Pep: Toggle View Annotations", "command": "pg_pep_toggle_view_annotations" diff --git a/pep.py b/pep.py index 38c636a..7cdf15a 100644 --- a/pep.py +++ b/pep.py @@ -4176,14 +4176,6 @@ def run(self, edit): print("Pep: Error: PgPepViewNamespaceStatusCommand", traceback.format_exc()) -class PgPepAnnotateCommand(sublime_plugin.TextCommand): - def run(self, edit): - try: - annotate_view(self.view) - except Exception: - print("Pep: Error: PgPepAnnotateCommand", traceback.format_exc()) - - # --- From 4c3361dc2f64a1e830c0bdcee83db3348976bf61 Mon Sep 17 00:00:00 2001 From: Pedro Girardi Date: Fri, 3 Nov 2023 20:47:38 -0300 Subject: [PATCH 11/15] Removed Command to show a view's namespace in the Status Bar --- CHANGELOG.md | 4 ++++ Pep.sublime-settings | 9 --------- pep.py | 36 ------------------------------------ 3 files changed, 4 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bc859a..e2c5df0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ Breaking: - Removed Command `PgPepClearAnnotationsCommand` - Removed Command `PgPepAnnotateCommand` - Removed Commands `PgPepClearHighlightedCommand` and `PgPepToggleHighlightCommand` +- Removed Command `PgPepViewNamespaceStatusCommand` and its settings: + - `view_status_show_namespace` + - `view_status_show_namespace_prefix` + - `view_status_show_namespace_suffix` ## 0.19.0 - 2023-10-31 There were many internal changes in this version and I'm sorry I made some breaking changes. diff --git a/Pep.sublime-settings b/Pep.sublime-settings index fb3b5c7..d4e8723 100644 --- a/Pep.sublime-settings +++ b/Pep.sublime-settings @@ -52,15 +52,6 @@ // True if you would like to see the number of clj-kondo warnings, if any, in the status bar. "view_status_show_warnings": false, - // True if you would like to show the namespace of the view in the status bar. - "view_status_show_namespace": false, - - // If you would like to add a custom prefix to the namespace of the view in the status bar. - "view_status_show_namespace_prefix": "Namespace: ", - - // If you would like to add a custom suffix to the namespace of the view in the status bar. - "view_status_show_namespace_suffix": "", - // True if you would like to see the number of highlighted regions in the status bar. "view_status_show_highlighted": false, diff --git a/pep.py b/pep.py index 7cdf15a..3f7cdb5 100644 --- a/pep.py +++ b/pep.py @@ -112,20 +112,11 @@ def af_status_summary(context, analysis): view.run_command("pg_pep_view_summary_status") -def af_status_namespace(context, analysis): - """ - Analysis Function to show a view's namespace in the status bar. - """ - if view := context["view"]: - view.run_command("pg_pep_view_namespace_status") - - # Default functions to run after analysis. DEFAULT_VIEW_ANALYSIS_FUNCTIONS = [ af_annotate, af_highlight_thingy, af_status_summary, - af_status_namespace, ] @@ -4149,33 +4140,6 @@ def run(self, edit): print("Pep: Error: PgPepViewSummaryStatusCommand", traceback.format_exc()) -class PgPepViewNamespaceStatusCommand(sublime_plugin.TextCommand): - def run(self, edit): - try: - analysis = view_analysis(self.view.id()) - - view_namespace = "" - - if view_status_show_namespace(self.view.window()): - # It's possible to get the namespace wrong since it's a list of definitions, - # but it's unlikely because of the scope (view) of the analysis. - if namespaces := list(analysis_nindex(analysis).keys()): - namespace_prefix = ( - view_status_show_namespace_prefix(self.view.window()) or "" - ) - - namespace_suffix = ( - view_status_show_namespace_suffix(self.view.window()) or "" - ) - - view_namespace = namespace_prefix + namespaces[0] + namespace_suffix - - self.view.set_status("pg_pep_view_namespace", view_namespace) - - except Exception: - print("Pep: Error: PgPepViewNamespaceStatusCommand", traceback.format_exc()) - - # --- From 845b65b19bce7285d2bdc030ce73d80a3cfe0d82 Mon Sep 17 00:00:00 2001 From: Pedro Girardi Date: Fri, 3 Nov 2023 20:49:49 -0300 Subject: [PATCH 12/15] Settings formatting --- Pep.sublime-settings | 1 - 1 file changed, 1 deletion(-) diff --git a/Pep.sublime-settings b/Pep.sublime-settings index d4e8723..ea92ba0 100644 --- a/Pep.sublime-settings +++ b/Pep.sublime-settings @@ -35,7 +35,6 @@ // (Doesn't do anything if there isn't a *.sublime-project file.) "analyze_classpath_on_load_project": true, - // True if warnings/errors should be displayed right after the analysis is completed. // It's a 'tighter feedback loop' to display warnings/errors after the analysis, but some might find it distracting. "annotate_view_after_analysis": false, From 4314b2737e337b07c72fb67982223034ceb55614 Mon Sep 17 00:00:00 2001 From: Pedro Girardi Date: Fri, 3 Nov 2023 20:54:03 -0300 Subject: [PATCH 13/15] Minor tweak to status bar warnings & errors --- pep.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pep.py b/pep.py index 3f7cdb5..1f9f6ac 100644 --- a/pep.py +++ b/pep.py @@ -4129,9 +4129,6 @@ def run(self, edit): status_message = ", ".join(status_messages) if status_messages else "" - if status_message: - status_message = "⚠ " + status_message - # Show the number of errors and/or warnings. # (Setting the value to the empty string will clear the status.) self.view.set_status("pg_pep_view_summary", status_message) From c30c5accae387f5e7960471c9ef86a5d4c8b3ce2 Mon Sep 17 00:00:00 2001 From: Pedro Girardi Date: Sat, 4 Nov 2023 09:16:06 -0300 Subject: [PATCH 14/15] Update README --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 303e2ac..8dfe450 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ | Command | Description | | ------- | ----------- | | `pg_pep_analyze` | Analyze view, paths or classpath | -| `pg_pep_browse_classpath` | Go to anything in the classpath | | `pg_pep_outline` | Show symbols defined in the namespace - it might also be known as 'file structure' | -| `pg_pep_goto_anything` | Go to anything in view or paths | +| `pg_pep_goto_anything_in_classpath` | Go to anything in the classpath | +| `pg_pep_goto_anything_in_view_paths` | Go to anything in view or paths | | `pg_pep_goto_namespace` | Go to namespace in paths | | `pg_pep_goto_definition` | Go to definition of symbol or keyword under the cursor | | `pg_pep_goto_warning_error_in_view` | Go to clj-kondo analysis finding (warning or error) | @@ -21,8 +21,6 @@ | `pg_pep_select` | Select occurrences of symbol or keyword under the cursor | | `pg_pep_replace` | Replace occurrences of symbol or keyword under the cursor | | `pg_pep_highlight` | Highlight occurrences of symbol or keyword under the cursor | -| `pg_pep_annotate_view` | Annotate view (show warnings/errors) | -| `pg_pep_clear_view_annotations` | Clear view annotations | | `pg_pep_copy_name` | Copy name of keyword or symbol to the clipboard | | `pg_pep_show_name` | Show name of keyword or symbol in a popup | From a26ce007801b649caf513029793e1614349f134b Mon Sep 17 00:00:00 2001 From: Pedro Girardi Date: Sat, 4 Nov 2023 09:21:27 -0300 Subject: [PATCH 15/15] Prepare release --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2c5df0..790dbcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. -## 0.20.0 - in development +## 0.20.0 - 2023-11-04 New: - [Command to Toggle View Annotations #70](https://github.com/pedrorgirardi/Pep/issues/70)