Skip to content

Commit

Permalink
Add run scalafix command (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoub-benali authored Sep 18, 2022
1 parent 68de35f commit 2058041
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 3 additions & 2 deletions LSP-metals.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@
"command_args": ["${file_uri}"]
}
},
{
{
"caption": "LSP-metals: Show Build Target Info",
"command": "lsp_metals_show_build_target_info",
"args": {"command_name": "list-build-targets"}
}
},
{ "caption": "LSP-metals: Run Scalafix", "command": "lsp_metals_run_scalafix"}
]
16 changes: 16 additions & 0 deletions commands/lsp_metals_run_scalafix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from . lsp_metals_text_command import LspMetalsTextCommand
from LSP.plugin.core.views import text_document_position_params, first_selection_region

import sublime

class LspMetalsRunScalafixCommand(LspMetalsTextCommand):

def run(self, edit: sublime.Edit) -> None:
region = first_selection_region(self.view)
if region is not None:
point = region.begin()
args = {
"command_name": "scalafix-run",
"command_args": [text_document_position_params(self.view, point)]
}
self.view.run_command("lsp_metals_execute", args)
5 changes: 3 additions & 2 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@
sublime.error_message('This version requires st4, use the st3 branch')
else:
from . commands.lsp_metals_analyze_stacktrace import LspMetalsAnalyzeStacktraceCommand
from . commands.lsp_metals_copy_worksheet import LspMetalsCopyWorksheetCommand
from . commands.lsp_metals_execute_command import LspMetalsExecuteCommand
from . commands.lsp_metals_file_decoder import LspMetalsFileDecoderCommand
from . commands.lsp_metals_find_in_dependency import LspMetalsFindInDependencyCommand
from . commands.lsp_metals_focus import LspMetalsFocusViewCommand, ActiveViewListener
from . commands.lsp_metals_goto import LspMetalsGoto
from . commands.lsp_metals_metals_goto_location import LspMetalsMetalsGotoLocationCommand
from . commands.lsp_metals_goto_super_method import LspMetalsSendPositionCommand
from . commands.lsp_metals_metals_goto_location import LspMetalsMetalsGotoLocationCommand
from . commands.lsp_metals_run_scalafix import LspMetalsRunScalafixCommand
from . commands.lsp_metals_show_build_target_info import LspMetalsShowBuildTargetInfoCommand
from . commands.lsp_metals_text_command import LspMetalsTextCommand
from . core.decorations import WorksheetListener, LspMetalsClearPhantomsCommand
from . commands.lsp_metals_copy_worksheet import LspMetalsCopyWorksheetCommand
from . core.metals import Metals

def plugin_loaded() -> None:
Expand Down

0 comments on commit 2058041

Please sign in to comment.