Skip to content

Commit

Permalink
Merge pull request #6 from rchl/fix/snippets-option
Browse files Browse the repository at this point in the history
fix: pass globalSnippetDir option to vls to avoid crash
  • Loading branch information
predragnikolic authored Sep 9, 2019
2 parents e67d123 + 0728cbb commit 804dfe3
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ def logAndShowMessage(msg, additional_logs=None):
sublime.active_window().status_message(msg)


def getGlobalSnippetDir() -> str:
"""
Returns default global directory for user's snippets.
Uses same logic and paths as vetur.
See https://github.com/vuejs/vetur/blob/master/client/userSnippetDir.ts
"""
appName = 'Code'
if sublime.platform() == 'windows':
return os.path.expandvars('%%APPDATA%%\\{}\\User\\snippets\\vetur').format(appName)
elif sublime.platform() == 'osx':
return os.path.expanduser('~/Library/Application Support/{}/User/snippets/vetur').format(appName)
else:
return os.path.expanduser('~/.config/{}/User/snippets/vetur').format(appName)


class LspVuePlugin(LanguageHandler):
@property
def name(self) -> str:
Expand All @@ -73,6 +89,7 @@ def name(self) -> str:
def config(self) -> ClientConfig:
settings = sublime.load_settings("LSP-vue.sublime-settings")
config = settings.get('config')
globalSnippetDir = settings.get('globalSnippetDir', getGlobalSnippetDir())
view = sublime.active_window().active_view()
if view is not None:
config['vetur']['format']['options']['tabs_size'] = view.settings().get("tab_size", 4)
Expand All @@ -86,7 +103,8 @@ def config(self) -> ClientConfig:
tcp_port=None,
enabled=True,
init_options={
"config": config
"config": config,
"globalSnippetDir": globalSnippetDir
},
settings=dict(),
env=dict(),
Expand Down

0 comments on commit 804dfe3

Please sign in to comment.