Skip to content

Commit

Permalink
🐛 FIX: Split javascript and typescript servers into separate classes
Browse files Browse the repository at this point in the history
  • Loading branch information
predragnikolic committed Nov 13, 2019
1 parent 7f5c2e7 commit ef391d6
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 14 deletions.
21 changes: 21 additions & 0 deletions LSP-javascript.sublime-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"client" : {
"enabled": true,
"languages": [
{
"languageId": "javascript",
"scopes": [
"source.js",
"source.jsx"
],
"syntaxes": [
"Packages/User/JS Custom/Syntaxes/React.sublime-syntax",
"Packages/JavaScript/JavaScript.sublime-syntax",
"Packages/Babel/JavaScript (Babel).sublime-syntax"
]
}
],
"initializationOptions": {},
"settings": {}
}
}
8 changes: 1 addition & 7 deletions LSP-typescript.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
{
"languageId": "typescript",
"scopes": [
"source.js",
"source.jsx",
"source.ts",
"source.tsx"
],
"syntaxes": [
"Packages/User/JS Custom/Syntaxes/React.sublime-syntax",
"Packages/JavaScript/JavaScript.sublime-syntax",
"Packages/Babel/JavaScript (Babel).sublime-syntax",
"Packages/TypeScript Syntax/TypeScript.tmLanguage",
"Packages/TypeScript Syntax/TypeScriptReact.tmLanguage",
"Packages/User/TypeScriptReactGraphQL.sublime-syntax"
"Packages/TypeScript Syntax/TypeScriptReact.tmLanguage"
]
}
],
Expand Down
54 changes: 47 additions & 7 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,12 @@ def config(self) -> ClientConfig:
{
"languageId": "typescript",
"scopes": [
"source.js",
"source.jsx",
"source.ts",
"source.tsx"
],
"syntaxes": [
"Packages/User/JS Custom/Syntaxes/React.sublime-syntax",
"Packages/JavaScript/JavaScript.sublime-syntax",
"Packages/Babel/JavaScript (Babel).sublime-syntax",
"Packages/TypeScript Syntax/TypeScript.tmLanguage",
"Packages/TypeScript Syntax/TypeScriptReact.tmLanguage",
"Packages/User/TypeScriptReactGraphQL.sublime-syntax"
"Packages/TypeScript Syntax/TypeScriptReact.tmLanguage"
]
}
],
Expand All @@ -117,5 +111,51 @@ def on_start(self, window) -> bool:
return False
return True

def on_initialized(self, client) -> None:
pass # extra initialization here.


class LspJavaScriptPlugin(LanguageHandler):
@property
def name(self) -> str:
return 'lsp-javascript'

@property
def config(self) -> ClientConfig:
settings = sublime.load_settings("LSP-javascript.sublime-settings")
client_configuration = settings.get('client')

default_configuration = {
"command": [
"node",
server_path,
'--stdio'
],
"languages": [
{
"languageId": "javascript",
"scopes": [
"source.js",
"source.jsx"
],
"syntaxes": [
"Packages/User/JS Custom/Syntaxes/React.sublime-syntax",
"Packages/JavaScript/JavaScript.sublime-syntax",
"Packages/Babel/JavaScript (Babel).sublime-syntax"
]
}
],
"initializationOptions": {}
}

default_configuration.update(client_configuration)
return read_client_config('lsp-javascript', default_configuration)

def on_start(self, window) -> bool:
if not is_node_installed():
sublime.status_message('Please install Node.js for the JavaScript Language Server to work.')
return False
return True

def on_initialized(self, client) -> None:
pass # extra initialization here.

0 comments on commit ef391d6

Please sign in to comment.