2026-03-08 00:46:21 -06:00
|
|
|
# Python imports
|
|
|
|
|
|
|
|
|
|
# Lib imports
|
2026-03-11 23:15:19 -05:00
|
|
|
import gi
|
|
|
|
|
|
|
|
|
|
from gi.repository import GLib
|
2026-03-08 00:46:21 -06:00
|
|
|
|
|
|
|
|
# Application imports
|
|
|
|
|
from libs.event_factory import Event_Factory, Code_Event_Types
|
|
|
|
|
from libs.dto.states import SourceViewStates
|
|
|
|
|
|
|
|
|
|
from plugins.plugin_types import PluginCode
|
|
|
|
|
|
2026-03-15 20:45:58 -05:00
|
|
|
from .dto.code import events as lsp_events
|
2026-03-12 00:04:08 -05:00
|
|
|
from .lsp_manager import LSPManager
|
2026-03-08 00:46:21 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-03-12 00:04:08 -05:00
|
|
|
lsp_manager = LSPManager()
|
2026-03-08 00:46:21 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Plugin(PluginCode):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
super(Plugin, self).__init__()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _controller_message(self, event: Code_Event_Types.CodeEvent):
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
def load(self):
|
2026-03-15 20:45:58 -05:00
|
|
|
Event_Factory.register_events( lsp_events.__dict__.items() )
|
|
|
|
|
|
|
|
|
|
self.register_controller("lsp_manager", lsp_manager)
|
|
|
|
|
|
2026-03-08 00:46:21 -06:00
|
|
|
window = self.request_ui_element("main-window")
|
|
|
|
|
|
2026-03-12 00:04:08 -05:00
|
|
|
lsp_manager.lsp_manager_ui.map_parent_resize_event(window)
|
2026-03-08 00:46:21 -06:00
|
|
|
|
|
|
|
|
event = Event_Factory.create_event("register_command",
|
|
|
|
|
command_name = "LSP Manager",
|
|
|
|
|
command = Handler,
|
|
|
|
|
binding_mode = "released",
|
|
|
|
|
binding = ["<Shift><Control>l", "<Control>g", "<Control>i"]
|
|
|
|
|
)
|
|
|
|
|
self.emit_to("source_views", event)
|
|
|
|
|
|
2026-03-11 23:15:19 -05:00
|
|
|
event = Event_Factory.create_event(
|
2026-03-08 00:46:21 -06:00
|
|
|
"register_provider",
|
|
|
|
|
provider_name = "LSP Completer",
|
2026-03-12 00:04:08 -05:00
|
|
|
provider = lsp_manager.provider,
|
2026-03-08 00:46:21 -06:00
|
|
|
language_ids = []
|
|
|
|
|
)
|
|
|
|
|
self.emit_to("completion", event)
|
|
|
|
|
|
|
|
|
|
event = Event_Factory.create_event(
|
|
|
|
|
"create_source_view",
|
|
|
|
|
state = SourceViewStates.INDEPENDENT
|
|
|
|
|
)
|
|
|
|
|
self.emit_to("source_views", event)
|
|
|
|
|
|
|
|
|
|
source_view = event.response
|
2026-03-12 00:04:08 -05:00
|
|
|
lsp_manager.lsp_manager_ui.set_source_view(source_view)
|
2026-03-11 23:15:19 -05:00
|
|
|
|
feat: Complete plugin lifecycle management with lazy loading and runtime reload
Major changes:
- Add unload() method to all plugins for proper cleanup (unregister commands/providers/LSP clients, destroy widgets, clear state)
- Implement lazy widget loading via "show" signal across all containers
- Add autoload: false manifest option for manual/conditional plugin loading
- Add Plugins UI with runtime load/unload toggle via Ctrl+Shift+p
- Implement controller unregistration system with proper signal disconnection
- Add new events: UnregisterCommandEvent, GetFilesEvent, GetSourceViewsEvent, TogglePluginsUiEvent
- Fix signal leaks by tracking and disconnecting handlers in widgets (search/replace, LSP manager, tabs, telescope, markdown preview)
- Add Save/Save As to tabs context menu
- Improve search/replace behavior (selection handling, focus management)
- Add telescope file initialization from existing loaded files
- Refactor plugin reload watcher to dynamically add/remove plugins on filesystem changes
- Add new plugins: file_history, extend_source_view_menu, godot_lsp_client
- Fix bug in prettify_json (undefined variable reference
2026-03-21 13:26:12 -05:00
|
|
|
def unload(self):
|
|
|
|
|
Event_Factory.unregister_events( lsp_events.__dict__.items() )
|
|
|
|
|
|
|
|
|
|
self.unregister_controller("lsp_manager")
|
|
|
|
|
|
|
|
|
|
window = self.request_ui_element("main-window")
|
|
|
|
|
|
|
|
|
|
lsp_manager.lsp_manager_ui.unmap_parent_resize_event(window)
|
|
|
|
|
|
|
|
|
|
event = Event_Factory.create_event("unregister_command",
|
|
|
|
|
command_name = "LSP Manager",
|
|
|
|
|
command = Handler,
|
|
|
|
|
binding_mode = "released",
|
|
|
|
|
binding = ["<Shift><Control>l", "<Control>g", "<Control>i"]
|
|
|
|
|
)
|
|
|
|
|
self.emit_to("source_views", event)
|
|
|
|
|
|
|
|
|
|
event = Event_Factory.create_event(
|
|
|
|
|
"unregister_provider",
|
|
|
|
|
provider_name = "LSP Completer"
|
|
|
|
|
)
|
|
|
|
|
self.emit_to("completion", event)
|
|
|
|
|
|
|
|
|
|
lsp_manager.handle_destroy()
|
|
|
|
|
|
2026-03-08 00:46:21 -06:00
|
|
|
def run(self):
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
def generate_plugin_element(self):
|
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Handler:
|
|
|
|
|
@staticmethod
|
|
|
|
|
def execute(
|
|
|
|
|
view: any,
|
|
|
|
|
*args,
|
|
|
|
|
**kwargs
|
|
|
|
|
):
|
|
|
|
|
logger.debug("Command: LSP Manager")
|
|
|
|
|
|
|
|
|
|
char_str = args[0]
|
|
|
|
|
if char_str in ["g", "i"]:
|
|
|
|
|
file = view.command.exec("get_current_file")
|
|
|
|
|
buffer = view.get_buffer()
|
|
|
|
|
iter = buffer.get_iter_at_mark( buffer.get_insert() )
|
|
|
|
|
line = iter.get_line()
|
|
|
|
|
column = iter.get_line_offset()
|
|
|
|
|
|
|
|
|
|
if char_str == "g":
|
2026-03-12 00:04:08 -05:00
|
|
|
lsp_manager.lsp_manager_client.process_goto_definition(
|
2026-03-08 00:46:21 -06:00
|
|
|
file.ftype, file.fpath, line, column
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if char_str == "i":
|
|
|
|
|
return
|
|
|
|
|
|
2026-03-12 00:04:08 -05:00
|
|
|
lsp_manager.lsp_manager_ui.hide() if lsp_manager.lsp_manager_ui.is_visible() else lsp_manager.lsp_manager_ui.show()
|