Skip to content

Commit

Permalink
remove LSP: Rename... from sidebar in favor of overriding the existin…
Browse files Browse the repository at this point in the history
…g ST rename_path command
  • Loading branch information
predragnikolic committed Jul 3, 2024
1 parent 93b024a commit 1ff4648
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
},
{
"caption": "LSP: Rename File",
"command": "lsp_rename_path"
"command": "lsp_rename_file"
},
{
"caption": "LSP: Code Action",
Expand Down
8 changes: 0 additions & 8 deletions Side Bar.sublime-menu

This file was deleted.

8 changes: 6 additions & 2 deletions boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
from .plugin.references import LspSymbolReferencesCommand
from .plugin.rename import LspHideRenameButtonsCommand
from .plugin.rename import LspSymbolRenameCommand
from .plugin.rename_file import LspRenameFileCommand
from .plugin.rename_file import LspRenamePathCommand
from .plugin.rename_file import LspRenamePathSidebarCommand
from .plugin.save_command import LspSaveAllCommand
from .plugin.save_command import LspSaveCommand
from .plugin.selection_range import LspExpandSelectionCommand
Expand Down Expand Up @@ -148,8 +148,8 @@
"LspSymbolImplementationCommand",
"LspSymbolReferencesCommand",
"LspSymbolRenameCommand",
"LspRenameFileCommand",
"LspRenamePathCommand",
"LspRenamePathSidebarCommand",
"LspSymbolTypeDefinitionCommand",
"LspToggleCodeLensesCommand",
"LspToggleHoverPopupsCommand",
Expand Down Expand Up @@ -265,6 +265,10 @@ def on_pre_close(self, view: sublime.View) -> None:
tup[1](None)
break

def on_window_command(self, window: sublime.Window, command_name: str, args: dict) -> tuple[str, dict] | None:
if command_name == "rename_path":
return ("lsp_rename_path", args)

def on_post_window_command(self, window: sublime.Window, command_name: str, args: dict[str, Any] | None) -> None:
if command_name == "show_panel":
wm = windows.lookup(window)
Expand Down
6 changes: 3 additions & 3 deletions plugin/rename_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import functools


class LspRenamePathSidebarCommand(LspWindowCommand):
class LspRenamePathCommand(LspWindowCommand):
def run(self, paths: list[str] | None = None) -> None:
old_path = paths[0] if paths else None
path_name = Path(old_path or "").name
Expand All @@ -28,7 +28,7 @@ def run(self, paths: list[str] | None = None) -> None:

def on_done(self, old_path: str | None, new_name: str) -> None:
if new_name:
self.window.run_command('lsp_rename_path', {
self.window.run_command('lsp_rename_file', {
"new_name": new_name,
"old_path": old_path
})
Expand All @@ -55,7 +55,7 @@ def validate(self, path: str) -> bool:
return len(path) > 0


class LspRenamePathCommand(LspWindowCommand):
class LspRenameFileCommand(LspWindowCommand):
capability = 'workspace.fileOperations.willRename'

def is_enabled(self):
Expand Down

0 comments on commit 1ff4648

Please sign in to comment.