Skip to content

Commit

Permalink
Use modern API to update formatting settings (#109)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rchl authored Sep 4, 2021
1 parent 04eed66 commit 329585d
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions plugin.py
Original file line number Diff line number Diff line change
@@ -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()


Expand All @@ -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)
})
}
})

0 comments on commit 329585d

Please sign in to comment.