diff --git a/plugins/code/language_server_clients/godot_lsp_client/config/lsp-server-config.json b/plugins/code/language_server_clients/godot_lsp_client/config/lsp-server-config.json index a5268b7..1edbec3 100644 --- a/plugins/code/language_server_clients/godot_lsp_client/config/lsp-server-config.json +++ b/plugins/code/language_server_clients/godot_lsp_client/config/lsp-server-config.json @@ -7,46 +7,46 @@ "socket": "ws://127.0.0.1:9999/gdscript", "socket-two": "ws://127.0.0.1:9999/?name=gdscript", "initialization-options": { - "processId": , - "clientInfo": { - "name": "Godot", - "version": "4.4" - }, - "rootUri": "file://{workspace.folder}", - "capabilities": { - "workspace": { - "applyEdit": true, - "workspaceEdit": { - "documentChanges": true - } + "processId": null, + "clientInfo": { + "name": "Godot", + "version": "4.4" }, - "textDocument": { - "synchronization": { - "dynamicRegistration": true, - "willSave": false, - "didSave": true, - "willSaveWaitUntil": false - }, - "completion": { - "dynamicRegistration": true, - "completionItem": { - "snippetSupport": true + "rootUri": "file://{workspace.folder}", + "capabilities": { + "workspace": { + "applyEdit": true, + "workspaceEdit": { + "documentChanges": true } }, - "hover": { - "dynamicRegistration": true - }, - "definition": { - "dynamicRegistration": true - }, - "references": { - "dynamicRegistration": true - }, - "documentSymbol": { - "dynamicRegistration": true + "textDocument": { + "synchronization": { + "dynamicRegistration": true, + "willSave": false, + "didSave": true, + "willSaveWaitUntil": false + }, + "completion": { + "dynamicRegistration": true, + "completionItem": { + "snippetSupport": true + } + }, + "hover": { + "dynamicRegistration": true + }, + "definition": { + "dynamicRegistration": true + }, + "references": { + "dynamicRegistration": true + }, + "documentSymbol": { + "dynamicRegistration": true + } } - } - }, - "trace": "off" + }, + "trace": "off" } } diff --git a/plugins/code/language_server_clients/python_lsp_client/config/jedi-lsp-server-config.json b/plugins/code/language_server_clients/python_lsp_client/config/jedi-lsp-server-config.json new file mode 100644 index 0000000..2aeb1cc --- /dev/null +++ b/plugins/code/language_server_clients/python_lsp_client/config/jedi-lsp-server-config.json @@ -0,0 +1,100 @@ +{ + "info": "https://github.com/python-lsp/python-lsp-server", + "command": "lsp-ws-proxy -- pylsp", + "alt-command": "pylsp", + "alt-command2": "lsp-ws-proxy --listen 4114 -- pylsp", + "alt-command3": "pylsp --ws --port 4114", + "socket": "ws://127.0.0.1:9999/python", + "socket-two": "ws://127.0.0.1:9999/?name=pylsp", + "initialization-options": { + "pylsp": { + "rope": { + "ropeFolder": "{user.home}/.config/newton/lsps/ropeproject" + }, + "plugins": { + "ruff": { + "enabled": true, + "extendSelect": ["I"], + "lineLength": 80 + }, + "pycodestyle": { + "enabled": false + }, + "pyflakes": { + "enabled": false + }, + "pylint": { + "enabled": true + }, + "mccabe": { + "enabled": false + }, + "pylsp_rope": { + "rename": false + }, + "rope_rename": { + "enabled": false + }, + "rope_autoimport": { + "enabled": true + }, + "rope_completion": { + "enabled": false, + "eager": false + }, + "jedi_rename": { + "enabled": true + }, + "jedi_completion": { + "enabled": true, + "include_class_objects": true, + "include_function_objects": true, + "fuzzy": false + }, + "jedi": { + "root_dir": "file://{workspace.folder}", + "extra_paths": [ + "{user.home}/Portable_Apps/py-venvs/pylsp-venv/venv/lib/python3.10/site-packages" + ] + } + } + } + } +}, +"python - jedi-language-server": { + "hidden": true, + "info": "https://pypi.org/project/jedi-language-server/", + "command": "jedi-language-server", + "alt-command": "lsp-ws-proxy --listen 3030 -- jedi-language-server", + "socket": "ws://127.0.0.1:9999/python", + "socket-two": "ws://127.0.0.1:9999/?name=jedi-language-server", + "initialization-options": { + "jediSettings": { + "autoImportModules": [], + "caseInsensitiveCompletion": true, + "debug": false + }, + "completion": { + "disableSnippets": false, + "resolveEagerly": false, + "ignorePatterns": [] + }, + "markupKindPreferred": "markdown", + "workspace": { + "extraPaths": [ + "{user.home}/Portable_Apps/py-venvs/pylsp-venv/venv/lib/python3.10/site-packages" + ], + "environmentPath": "{user.home}/Portable_Apps/py-venvs/gtk-apps-venv/venv/bin/python", + "symbols": { + "ignoreFolders": [ + ".nox", + ".tox", + ".venv", + "__pycache__", + "venv" + ], + "maxSymbols": 20 + } + } + } +} diff --git a/plugins/code/language_server_clients/python_lsp_client/config/lsp-server-config.json b/plugins/code/language_server_clients/python_lsp_client/config/lsp-server-config.json index 2aeb1cc..5b81dc4 100644 --- a/plugins/code/language_server_clients/python_lsp_client/config/lsp-server-config.json +++ b/plugins/code/language_server_clients/python_lsp_client/config/lsp-server-config.json @@ -60,41 +60,4 @@ } } } -}, -"python - jedi-language-server": { - "hidden": true, - "info": "https://pypi.org/project/jedi-language-server/", - "command": "jedi-language-server", - "alt-command": "lsp-ws-proxy --listen 3030 -- jedi-language-server", - "socket": "ws://127.0.0.1:9999/python", - "socket-two": "ws://127.0.0.1:9999/?name=jedi-language-server", - "initialization-options": { - "jediSettings": { - "autoImportModules": [], - "caseInsensitiveCompletion": true, - "debug": false - }, - "completion": { - "disableSnippets": false, - "resolveEagerly": false, - "ignorePatterns": [] - }, - "markupKindPreferred": "markdown", - "workspace": { - "extraPaths": [ - "{user.home}/Portable_Apps/py-venvs/pylsp-venv/venv/lib/python3.10/site-packages" - ], - "environmentPath": "{user.home}/Portable_Apps/py-venvs/gtk-apps-venv/venv/bin/python", - "symbols": { - "ignoreFolders": [ - ".nox", - ".tox", - ".venv", - "__pycache__", - "venv" - ], - "maxSymbols": 20 - } - } - } -} +} \ No newline at end of file diff --git a/src/core/widgets/code/command_system/__init__.py b/src/core/widgets/code/command_system/__init__.py index bd5eb3b..b10a930 100644 --- a/src/core/widgets/code/command_system/__init__.py +++ b/src/core/widgets/code/command_system/__init__.py @@ -2,4 +2,4 @@ Code Command System Package """ -from .command_system import CommandSystem +from .source_view_command_system import SourceViewCommandSystem diff --git a/src/core/widgets/code/command_system/command_system.py b/src/core/widgets/code/command_system/command_system.py deleted file mode 100644 index a723f46..0000000 --- a/src/core/widgets/code/command_system/command_system.py +++ /dev/null @@ -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) \ No newline at end of file diff --git a/src/core/widgets/code/mixins/command_system_mixin.py b/src/core/widgets/code/command_system/source_view_command_system.py similarity index 79% rename from src/core/widgets/code/mixins/command_system_mixin.py rename to src/core/widgets/code/command_system/source_view_command_system.py index 6dd7804..4eb4df5 100644 --- a/src/core/widgets/code/mixins/command_system_mixin.py +++ b/src/core/widgets/code/command_system/source_view_command_system.py @@ -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... """ + ... diff --git a/src/core/widgets/code/controllers/commands_controller.py b/src/core/widgets/code/controllers/commands_controller.py index 532bb07..780b66c 100644 --- a/src/core/widgets/code/controllers/commands_controller.py +++ b/src/core/widgets/code/controllers/commands_controller.py @@ -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 diff --git a/src/core/widgets/code/controllers/views/marker_manager.py b/src/core/widgets/code/controllers/views/marker_manager.py index dc20b2d..70bf0b1 100644 --- a/src/core/widgets/code/controllers/views/marker_manager.py +++ b/src/core/widgets/code/controllers/views/marker_manager.py @@ -115,7 +115,7 @@ class MarkerManager(MarkSupportMixin): buffer.move_mark(start_mark, collapse_itr) buffer.move_mark(end_mark, collapse_itr) - def move_word(self, itr: Gtk.TextIter, count: int): + def move_along_word(self, itr: Gtk.TextIter, count: int): def not_is_word(ch: str): return not is_word(ch) @@ -160,7 +160,7 @@ class MarkerManager(MarkSupportMixin): if mode == "char": itr_.forward_char() if is_forward else itr_.backward_char() elif mode == "word": - self.move_word(itr_, 1 if is_forward else -1) + self.move_along_word(itr_, 1 if is_forward else -1) elif mode == "line": line = itr_.get_line() offset = itr_.get_line_offset() diff --git a/src/core/widgets/code/controllers/views/states/source_view_multi_insert_state.py b/src/core/widgets/code/controllers/views/states/source_view_multi_insert_state.py index c8b5f1e..1df1a82 100644 --- a/src/core/widgets/code/controllers/views/states/source_view_multi_insert_state.py +++ b/src/core/widgets/code/controllers/views/states/source_view_multi_insert_state.py @@ -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( diff --git a/src/libs/command_system.py b/src/libs/command_system.py new file mode 100644 index 0000000..221c2b3 --- /dev/null +++ b/src/libs/command_system.py @@ -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)