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
Add lsp-ws-connection to repo #107
Changes from all commits
f8113bd
8fbad03
4f1f93e
63af0b0
c4481d4
1e17fcf
cb2aeb7
5bfd42c
17a5139
f32ae48
75cea57
318b0bb
b4b14dd
ff09fcc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,3 +112,4 @@ node_modules | |
atest/output/ | ||
junit.xml | ||
coverage/ | ||
.vscode/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2019, jupyter-lsp contributors | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we should not stop at the fork mention, but also add "Copyright (c) 2018, William Conlon, ISC" in here. Legalities aside I would like to credit @wylieconlon as it would not be possible to start this project without the leading work of @wylieconlon (and obviously lots of code in this PR is @wylieconlon code with slight modifications). @wylieconlon would you like any specific backlinks or mentions? Are you ok with the current mentions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, happy to give credit where due! I think we may end up moving further and further from what remains of the code from upstream: for example, using tsee would let us keep the full event typing information, and remove the conflicts we're seeing between Of course, because we don't control the end-user jupyterlab |
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
Portions of this code derived from: | ||
|
||
ISC License (ISC) | ||
Copyright 2019 William Conlon | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER | ||
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | ||
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE | ||
USE OR PERFORMANCE OF THIS SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# lsp-ws-connection | ||
bollwyvl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
> This is a fork of [lsp-editor-adapter](https://github.com/wylieconlon/lsp-editor-adapter), with | ||
> a number of modifications made to make it more easily integrated into [jupyterlab-lsp](https://github.com/krassowski/jupyterlab-lsp) | ||
|
||
## Installation | ||
|
||
> TBD | ||
|
||
## Developing | ||
|
||
This library is built and tested as part of the [`jupyterlab-lsp` monorepo](https://github.com/krassowski/jupyterlab-lsp). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
process.env.CHROME_BIN = require('puppeteer').executablePath(); | ||
|
||
module.exports = function(config) { | ||
config.set({ | ||
basePath: '', | ||
|
||
files: [ | ||
// The entry files are processed by webpack | ||
'lib/test/**/*.test.js' | ||
], | ||
|
||
browsers: ['ChromeHeadless'], | ||
|
||
mime: { | ||
'text/x-typescript': ['ts', 'tsx'] | ||
}, | ||
|
||
module: 'commonjs', | ||
|
||
singleRun: true, | ||
autoWatch: false, | ||
colors: true, | ||
|
||
frameworks: ['mocha'], | ||
|
||
reporters: ['mocha'], | ||
|
||
preprocessors: { | ||
'**/*!(.d).ts': 'webpack', | ||
'**/*!(.d).js': 'webpack' | ||
}, | ||
|
||
plugins: [ | ||
'karma-mocha', | ||
'karma-chrome-launcher', | ||
'karma-webpack', | ||
'karma-mocha-reporter' | ||
], | ||
|
||
webpack: { | ||
mode: 'development', | ||
resolve: { | ||
extensions: ['.tsx', '.ts', '.js'] | ||
}, | ||
target: 'web', | ||
node: { | ||
net: 'mock' | ||
} | ||
} | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"name": "lsp-ws-connection", | ||
"version": "0.2.0", | ||
"description": "Utility for adapting editors to language server protocol", | ||
"main": "dist/index.js", | ||
"module": "dist/index.js", | ||
"files": [ | ||
"dist", | ||
"lib" | ||
], | ||
"types": "lib/index.d.ts", | ||
"scripts": { | ||
"lab:link": "jupyter labextension link . --no-build", | ||
"build": "webpack", | ||
"test": "karma start", | ||
"test-dev": "karma start --browsers Chrome --singleRun false --timeout 30000 --autoWatch", | ||
"watch": "webpack --watch", | ||
"bundle": "npm pack .", | ||
"clean": "rimraf lib dist" | ||
}, | ||
"author": "Wylie Conlon", | ||
"maintainers": [ | ||
"Michał Krassowski" | ||
], | ||
"license": "ISC", | ||
"keywords": [ | ||
"lsp", | ||
"languageserver" | ||
], | ||
"homepage": "https://github.com/krassowski/lsp-ws-connection", | ||
"repository": "github:krassowski/lsp-ws-connection", | ||
"dependencies": { | ||
"vscode-jsonrpc": "^4.1.0-next", | ||
"vscode-languageclient": "^5.2.1", | ||
"vscode-languageserver-protocol": "^3.14.1", | ||
"vscode-languageserver-types": "^3.14.0", | ||
"vscode-ws-jsonrpc": "0.1.1" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.1.7", | ||
"@types/mocha": "^5.2.7", | ||
"@types/node": "^12.0.7", | ||
"@types/sinon": "^7.0.12", | ||
"chai": "^4.2.0", | ||
"file-loader": "~3.0.1", | ||
"karma": "^4.1.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-mocha": "^1.3.0", | ||
"karma-mocha-reporter": "^2.2.5", | ||
"karma-webpack": "^4.0.0-rc.6", | ||
"mocha": "^6.1.4", | ||
"puppeteer": "^1.17.0", | ||
"rimraf": "^2.6.3", | ||
"sinon": "^7.3.2", | ||
"source-map-loader": "~0.2.1", | ||
"typescript": "^3.7.2", | ||
"webpack": "^4.32.2", | ||
"webpack-cli": "^3.3.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './ws-connection'; | ||
export * from './types'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { | ||
Registration, | ||
ServerCapabilities, | ||
Unregistration | ||
} from 'vscode-languageserver-protocol'; | ||
|
||
interface IFlexibleServerCapabilities extends ServerCapabilities { | ||
[key: string]: any; | ||
} | ||
|
||
function registerServerCapability( | ||
serverCapabilities: ServerCapabilities, | ||
registration: Registration | ||
): ServerCapabilities { | ||
const serverCapabilitiesCopy = JSON.parse( | ||
JSON.stringify(serverCapabilities) | ||
) as IFlexibleServerCapabilities; | ||
const { method, registerOptions } = registration; | ||
const providerName = method.substring(13) + 'Provider'; | ||
|
||
if (providerName) { | ||
if (!registerOptions) { | ||
serverCapabilitiesCopy[providerName] = true; | ||
} else { | ||
serverCapabilitiesCopy[providerName] = JSON.parse( | ||
JSON.stringify(registerOptions) | ||
); | ||
} | ||
} else { | ||
throw new Error('Could not register server capability.'); | ||
} | ||
|
||
return serverCapabilitiesCopy; | ||
} | ||
|
||
function unregisterServerCapability( | ||
serverCapabilities: ServerCapabilities, | ||
unregistration: Unregistration | ||
): ServerCapabilities { | ||
const serverCapabilitiesCopy = JSON.parse( | ||
JSON.stringify(serverCapabilities) | ||
) as IFlexibleServerCapabilities; | ||
const { method } = unregistration; | ||
const providerName = method.substring(13) + 'Provider'; | ||
|
||
delete serverCapabilitiesCopy[providerName]; | ||
|
||
return serverCapabilitiesCopy; | ||
} | ||
|
||
export { registerServerCapability, unregisterServerCapability }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be able to clean these up, now that they are no longer fighting...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still didn't look at these yet...