aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattn <mattn.jp@gmail.com>2020-01-03 14:55:03 +0900
committerGitHub <noreply@github.com>2020-01-03 14:55:03 +0900
commitac4f61f82fd8d0c4b0cbabd4e364dced0c72c645 (patch)
tree2e9ab937b1c03096027ac0cbb2bc755393987a39
parent4e123ae7896ec2c11851d11b91496c2c04c6b66d (diff)
parent6c15c16a88c24a8f2c8e04bd23e34ea367f35608 (diff)
downloadvim-lsp-settings-ac4f61f82fd8d0c4b0cbabd4e364dced0c72c645.tar.gz
vim-lsp-settings-ac4f61f82fd8d0c4b0cbabd4e364dced0c72c645.tar.bz2
vim-lsp-settings-ac4f61f82fd8d0c4b0cbabd4e364dced0c72c645.zip
Merge pull request #59 from johejo/fix/multiple_npm
fix: support multiple npm packages for one language server
-rwxr-xr-xinstaller/npm_install.sh15
-rwxr-xr-xtest/run.sh31
-rwxr-xr-xtest/send.py42
3 files changed, 8 insertions, 80 deletions
diff --git a/installer/npm_install.sh b/installer/npm_install.sh
index 198666c..84073da 100755
--- a/installer/npm_install.sh
+++ b/installer/npm_install.sh
@@ -5,13 +5,14 @@
set -e
-npm init -y
-
-# Avoid the problem of not being able to install the same package as name in package.json.
-# Create an empty package.json.
-cat <<EOF >package.json
-{"name": ""}
-EOF
+# Supporting multiple npm packages(e.g. typescript-language-server uses typescript-language-server and tsserver).
+# If package.json exists, skip calling npm init.
+if [ ! -f package.json ]; then
+ # Avoid the problem of not being able to install the same package as name in package.json.
+ # Create an empty package.json.
+ npm init -y
+ echo '{"name": ""}' >package.json
+fi
npm install "$2"
ln -s "./node_modules/.bin/$1" .
diff --git a/test/run.sh b/test/run.sh
deleted file mode 100755
index 7da9443..0000000
--- a/test/run.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-
-set -e
-
-usage() {
- cat <<USAGE
-Usage: $0 [pattern] [args]
-Examples
-$0 pyls
-$0 "pyls|kotlin"
-$0 bash start
-USAGE
-}
-
-if [ $# == 0 ]; then
- usage
- exit 1
-fi
-
-test_installer() {
- set -e
- "./installer/install-$1.sh"
- ./test/send.py | "./servers/$1/$1" $2
- ret="$?"
- printf "\n\nresult=%s" $ret
-}
-export -f test_installer
-
-jq ".[][].command" -r -c <./settings.json | sort | uniq |
- grep -E "$1" |
- xargs -I% bash -c "test_installer % $2"
diff --git a/test/send.py b/test/send.py
deleted file mode 100755
index 78b89aa..0000000
--- a/test/send.py
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/env python3
-import json
-import sys
-
-
-def send(message: dict):
- raw = json.dumps(message)
- message = "Content-Length: " + str(len(raw)) + "\r\n\r\n" + raw
- sys.stdout.write(message)
-
-
-initialize = {
- "jsonrpc": "2.0",
- "id": 1,
- "method": "initialize",
- "params": {"processId": None, "rootUri": None, "capabilities": {}},
-}
-send(initialize)
-
-initialized = {
- "jsonrpc": "2.0",
- "id": 2,
- "method": "initialized",
- "params": {},
-}
-send(initialized)
-
-shutdown = {
- "jsonrpc": "2.0",
- "id": 3,
- "method": "shutdown",
- "params": {},
-}
-send(shutdown)
-
-_exit = {
- "jsonrpc": "2.0",
- "id": 4,
- "method": "exit",
- "params": {},
-}
-send(_exit)