-
Notifications
You must be signed in to change notification settings - Fork 1
Update the latest vscode-css-languageserver #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
predragnikolic
merged 15 commits into
sublimelsp:master
from
jfcherng-sublime:update-vscode-server
Mar 17, 2020
Merged
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8280789
Update the latest vscode-css-languageserver
jfcherng caf53d7
Adapt changes from lsp-html
jfcherng f353739
chore: "typescript" can be dev-only dependency
jfcherng 7a53216
chore: add missing executable permission bit
jfcherng fdb73a4
fix: Cannot read property 'validProperties' of null
jfcherng 43bf806
feat: add Sass support
jfcherng da8762e
refactor: extract defualt configuration into a method
jfcherng d9b59f8
chore: simplify the build script
jfcherng df62c65
revert: feat: add Sass support
jfcherng 90e9213
feat: use the same configuration with VS Code's
jfcherng 59f638c
chore: add dependencies.json
jfcherng 7225f60
chore: delete .no-sublime-package
jfcherng ec8ef3d
refactor: utilize lsp_utils
jfcherng 0faf497
chore: add some comments
jfcherng 1bac1d5
refactor: migrate settings to flatter structure
jfcherng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| import json | ||
| import os | ||
| import shutil | ||
| import sublime | ||
| import subprocess | ||
| import threading | ||
|
|
||
| from sublime_lib import ResourcePath | ||
|
|
||
|
|
||
| def run_command(on_exit, on_error, popen_args): | ||
| """ | ||
| Runs the given args in a subprocess.Popen, and then calls the function | ||
| on_exit when the subprocess completes. | ||
| on_exit is a callable object, and popen_args is a list/tuple of args that | ||
| on_error when the subprocess throws an error | ||
| would give to subprocess.Popen. | ||
| """ | ||
| def run_in_thread(on_exit, on_error, popen_args): | ||
| try: | ||
| subprocess.check_call(popen_args, shell=sublime.platform() == 'windows') | ||
| on_exit() | ||
| except subprocess.CalledProcessError as error: | ||
| on_error(error) | ||
|
|
||
| thread = threading.Thread(target=run_in_thread, args=(on_exit, on_error, popen_args)) | ||
| thread.start() | ||
| # returns immediately after the thread starts | ||
| return thread | ||
|
|
||
|
|
||
| def log_and_show_message(msg, additional_logs=None): | ||
| print(msg, '\n', additional_logs) if additional_logs else print(msg) | ||
| sublime.active_window().status_message(msg) | ||
|
|
||
|
|
||
| class ServerNpmResource(object): | ||
| """Global object providing paths to server resources. | ||
| Also handles the installing and updating of the server in cache. | ||
|
|
||
| setup() needs to be called during (or after) plugin_loaded() for paths to be valid. | ||
| """ | ||
|
|
||
| def __init__(self, package_name, server_directory, server_binary_path): | ||
| self._initialized = False | ||
| self._package_name = package_name | ||
| self._server_directory = server_directory | ||
| self._binary_path = server_binary_path | ||
| self._package_cache_path = None | ||
|
|
||
| @property | ||
| def binary_path(self): | ||
| return os.path.join(self._package_cache_path, self._binary_path) | ||
|
|
||
| def setup(self): | ||
| if self._initialized: | ||
| return | ||
|
|
||
| self._initialized = True | ||
| self._package_cache_path = os.path.join(sublime.cache_path(), self._package_name) | ||
|
|
||
| self._copy_to_cache() | ||
|
|
||
| def cleanup(self): | ||
| if os.path.isdir(self._package_cache_path): | ||
| shutil.rmtree(self._package_cache_path) | ||
|
|
||
| def _copy_to_cache(self): | ||
| src_path = 'Packages/{}/{}/'.format(self._package_name, self._server_directory) | ||
| dst_path = 'Cache/{}/{}/'.format(self._package_name, self._server_directory) | ||
| cache_server_path = os.path.join(self._package_cache_path, self._server_directory) | ||
|
|
||
| if os.path.isdir(cache_server_path): | ||
| # Server already in cache. Check if version has changed and if so, delete existing copy in cache. | ||
| try: | ||
| src_package_json = json.loads(ResourcePath(src_path, 'package.json').read_text()) | ||
| dst_package_json = json.loads(ResourcePath(dst_path, 'package.json').read_text()) | ||
|
|
||
| if src_package_json['version'] != dst_package_json['version']: | ||
| shutil.rmtree(cache_server_path) | ||
| except FileNotFoundError: | ||
| shutil.rmtree(cache_server_path) | ||
|
|
||
| if not os.path.isdir(cache_server_path): | ||
| # create cache folder | ||
| ResourcePath(src_path).copytree(cache_server_path, exist_ok=True) | ||
|
|
||
| self._install_dependencies(cache_server_path) | ||
|
|
||
| def _install_dependencies(self, cache_server_path): | ||
| dependencies_installed = os.path.isdir(os.path.join(cache_server_path, 'node_modules')) | ||
| print('{}: Server {} installed.'.format(self._package_name, 'is' if dependencies_installed else 'is not')) | ||
|
|
||
| if not dependencies_installed: | ||
| # this will be called only when the plugin gets: | ||
| # - installed for the first time, | ||
| # - or when updated on package control | ||
| log_and_show_message('{}: Installing server.'.format(self._package_name)) | ||
|
|
||
| run_command( | ||
| lambda: log_and_show_message( | ||
| '{}: Server installed.'.format(self._package_name)), | ||
| lambda error: log_and_show_message( | ||
| '{}: Error while installing the server.'.format(self._package_name), error), | ||
| ["npm", "install", "--verbose", "--production", "--prefix", cache_server_path, cache_server_path] | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # download source codes | ||
| /vscode-css-languageserver/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| This repo contains built [vscode-css-languageserver](https://github.com/vscode-langservers/vscode-css-languageserver). | ||
|
|
||
|
|
||
| # Build | ||
|
|
||
| Just run `compile-vscode-css-languageserver.sh`. The built result will be in `out/`. | ||
|
|
||
|
|
||
| # References | ||
|
|
||
| - https://github.com/mattn/vim-lsp-settings/pull/48 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.