From 329585dc39ae0afb7a0313c471bef8e053205c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ch=C5=82odnicki?= Date: Sat, 4 Sep 2021 21:02:31 +0200 Subject: [PATCH] Use modern API to update formatting settings (#109) Just a simpler way of doing the same. And this API is called every time on sending configuration settings rather than only once which could be an advantage. --- plugin.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/plugin.py b/plugin.py index 929c361..5e6b3ed 100644 --- a/plugin.py +++ b/plugin.py @@ -1,13 +1,14 @@ +from LSP.plugin import DottedDict from lsp_utils import NpmClientHandler import os import sublime -def plugin_loaded(): +def plugin_loaded() -> None: LspVuePlugin.setup() -def plugin_unloaded(): +def plugin_unloaded() -> None: LspVuePlugin.cleanup() @@ -16,17 +17,13 @@ class LspVuePlugin(NpmClientHandler): server_directory = 'server' server_binary_path = os.path.join(server_directory, 'node_modules', 'vls', 'bin', 'vls') - @classmethod - def on_client_configuration_ready(cls, configuration: dict): + def on_settings_changed(self, settings: DottedDict) -> None: view = sublime.active_window().active_view() if view: view_settings = view.settings() - configuration \ - .setdefault('settings', {}) \ - .setdefault('vetur', {}) \ - .setdefault('format', {}) \ - .setdefault('options', {}) \ - .update({ + settings.update({ + 'vetur.format.options': { 'tabSize': view_settings.get('tab_size', 4), 'useTabs': not view_settings.get('translate_tabs_to_spaces', False) - }) + } + })