refactor(command-system): replace legacy CommandSystem with SourceViewCommandSystem

- Remove CommandSystem and CommandSystemMixin
- Introduce SourceViewCommandSystem and shared libs/command_system
- Update CommandsController to use new command system
- Adjust package exports accordingly

feat(lsp): clean up and normalize LSP configurations

- Fix invalid JSON in Godot LSP config (processId -> null, formatting)
- Remove embedded jedi-language-server config from main Python LSP config
- Add separate jedi-lsp-server-config.json

refactor(markers): rename move_word -> move_along_word for clarity

- Update all usages in MarkerManager

chore: minor formatting and whitespace fixes
This commit is contained in:
2026-04-04 14:21:58 -05:00
parent e367e31890
commit b13d9c2397
8 changed files with 171 additions and 162 deletions

View File

@@ -2,4 +2,4 @@
Code Command System Package
"""
from .command_system import CommandSystem
from .source_view_command_system import SourceViewCommandSystem

View File

@@ -1,120 +0,0 @@
# Python imports
# Lib imports
# Application imports
from libs.event_factory import Event_Factory, Code_Event_Types
from ..mixins.command_system_mixin import CommandSystemMixin
from ..source_view import SourceView
from . import commands
class CommandSystem(CommandSystemMixin):
def __init__(self):
super(CommandSystem, self).__init__()
self.data: list = ()
def set_data(self, *args, **kwargs):
self.data = (args, kwargs)
def exec(self, command: str) -> any:
if not hasattr(commands, command): return
method = getattr(commands, command)
args, kwargs = self.data
return method.execute(*args, **kwargs)
def exec_with_args(self, command: str, *args, **kwargs) -> any:
if not hasattr(commands, command): return
method = getattr(commands, command)
return method.execute(*args, **kwargs)
def add_command(self, command_name: str, command: callable):
setattr(commands, command_name, command)
def remove_command(self, command_name: str, command: callable):
if hasattr(commands, command_name):
delattr(commands, command_name)
def emit(self, event: Code_Event_Types.CodeEvent):
""" Monkey patch 'emit' from command controller... """
...
def emit_to(self, controller: str, event: Code_Event_Types.CodeEvent):
""" Monkey patch 'emit_to' from command controller... """
...
# def filter_out_loaded_files(self, uris: list[str]):
# event = Event_Factory.create_event(
# "filter_out_loaded_files",
# uris = uris
# )
#
# self.emit_to("files", event)
#
# return event.response
#
# def set_info_labels(self, data: tuple[str]):
# event = Event_Factory.create_event(
# "set_info_labels",
# info = data
# )
#
# self.emit_to("plugins", event)
#
# def get_file(self, view: SourceView):
# event = Event_Factory.create_event(
# "get_file",
# view = view,
# buffer = view.get_buffer()
# )
#
# self.emit_to("files", event)
#
# return event.response
#
# def get_swap_file(self, view: SourceView):
# event = Event_Factory.create_event(
# "get_swap_file",
# view = view,
# buffer = view.get_buffer()
# )
#
# self.emit_to("files", event)
#
# return event.response
#
# def new_file(self, view: SourceView):
# event = Event_Factory.create_event("add_new_file", view = view)
#
# self.emit_to("files", event)
#
# return event.response
#
# def remove_file(self, view: SourceView):
# event = Event_Factory.create_event(
# "remove_file",
# view = view,
# buffer = view.get_buffer()
# )
#
# self.emit_to("files", event)
#
# return event.response
#
# def request_completion(self, view: SourceView):
# event = Event_Factory.create_event(
# "request_completion",
# view = view,
# buffer = view.get_buffer()
# )
#
# self.emit_to("completion", event)

View File

@@ -4,12 +4,19 @@
# Application imports
from libs.event_factory import Event_Factory, Code_Event_Types
from libs.command_system import CommandSystem
from ..source_view import SourceView
from . import commands
class SourceViewCommandSystem(CommandSystem):
def __init__(self):
super(SourceViewCommandSystem, self).__init__(commands)
class CommandSystemMixin:
def toggle_plugins_ui(self):
event = Event_Factory.create_event( "toggle_plugins_ui" )
@@ -81,3 +88,11 @@ class CommandSystemMixin:
)
self.emit_to("completion", event)
def emit(self, event: Code_Event_Types.CodeEvent):
""" Monkey patch 'emit' from command controller... """
...
def emit_to(self, controller: str, event: Code_Event_Types.CodeEvent):
""" Monkey patch 'emit_to' from command controller... """
...

View File

@@ -7,7 +7,7 @@ from libs.controllers.controller_base import ControllerBase
from libs.event_factory import Code_Event_Types
from ..command_system import CommandSystem
from ..command_system import SourceViewCommandSystem
@@ -21,7 +21,7 @@ class CommandsController(ControllerBase, list):
event.response = self.get_new_command_system()
def get_new_command_system(self):
command_system = CommandSystem()
command_system = SourceViewCommandSystem()
command_system.emit = self.emit
command_system.emit_to = self.emit_to

View File

@@ -59,6 +59,7 @@ class SourceViewsMultiInsertState(SourceViewsBaseState):
buffer.insert(start_itr, text, -1)
self.marker_manager.apply_to_marks(buffer, replace_word)
return True
def move_cursor(

View File

@@ -0,0 +1,50 @@
# Python imports
import types
# Lib imports
# Application imports
from .event_factory import Event_Factory, Code_Event_Types
class CommandSystem:
def __init__(self, commands: dict | types.ModuleType):
super(CommandSystem, self).__init__()
self.commands: dict | types.ModuleType = commands
self.data: tuple = ()
def set_data(self, *args, **kwargs):
self.data = (args, kwargs)
def exec(self, command: str) -> any:
"""
The 'exec' method passes the default 'self.data' to commands where custom args are not needed.
Ex: The 'code' widget has many internally created commands that
only need 'source_view' and so 'set_data' is called to set that.
"""
if not hasattr(self.commands, command): return
method = getattr(self.commands, command)
args, kwargs = self.data
return method.execute(*args, **kwargs)
def exec_with_args(self, command: str, *args, **kwargs) -> any:
"""
The 'exec_with_args' method passes custom args with the understanding
that the recipient has proper method signature to accept it- whether
*args or **kwargs or something else entirely.
"""
if not hasattr(self.commands, command): return
method = getattr(self.commands, command)
return method.execute(*args, **kwargs)
def add_command(self, command_name: str, command: callable):
setattr(self.commands, command_name, command)
def remove_command(self, command_name: str, command: callable):
if hasattr(self.commands, command_name):
delattr(self.commands, command_name)