diff options
author | mattn <mattn.jp@gmail.com> | 2019-12-25 09:23:07 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-25 09:23:07 +0900 |
commit | 008181bf9aedf976fdb725dcf9340e7f775d1fa8 (patch) | |
tree | f5b9276c1369379ff821277659853a03dbced4c4 | |
parent | 0bbdaf2e780fb8172a5be9bf25ba3fadc1d1cef9 (diff) | |
parent | bc6a978d443a07c993cae278e57fa6b1a1948fac (diff) | |
download | vim-lsp-settings-008181bf9aedf976fdb725dcf9340e7f775d1fa8.tar.gz vim-lsp-settings-008181bf9aedf976fdb725dcf9340e7f775d1fa8.tar.bz2 vim-lsp-settings-008181bf9aedf976fdb725dcf9340e7f775d1fa8.zip |
Merge pull request #12 from johejo/feature/add_servers_fortls_metals
Feature/add servers fortls metals
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | installer/install-bash-language-server.sh | 11 | ||||
-rwxr-xr-x | installer/install-css-languageserver.sh | 8 | ||||
-rwxr-xr-x | installer/install-docker-langserver.sh | 11 | ||||
-rwxr-xr-x | installer/install-fortls.sh | 6 | ||||
-rwxr-xr-x | installer/install-html-languageserver.sh | 8 | ||||
-rwxr-xr-x | installer/install-javascript-typescript-langserver.sh | 18 | ||||
-rwxr-xr-x | installer/install-metals.sh | 16 | ||||
-rwxr-xr-x | installer/install-pyls.sh | 9 | ||||
-rwxr-xr-x | installer/install-typescript-language-server.sh | 16 | ||||
-rwxr-xr-x | installer/install-vim-language-server.sh | 18 | ||||
-rwxr-xr-x | installer/install-yaml-language-server.sh | 13 | ||||
-rw-r--r-- | installer/npm.sh | 23 | ||||
-rw-r--r-- | installer/pip3.sh | 16 | ||||
-rw-r--r-- | settings.json | 18 | ||||
-rw-r--r-- | settings/fortls.vim | 12 | ||||
-rw-r--r-- | settings/metals.vim | 12 | ||||
-rwxr-xr-x | test/run.sh | 31 | ||||
-rwxr-xr-x | test/send.py | 42 |
19 files changed, 209 insertions, 81 deletions
@@ -63,6 +63,8 @@ Currently, no way to uninstall/update server. Run this command again, newer vers | Dockerfile | dockerfile-language-server-nodejs | Yes | | YAML | yaml-language-server | Yes | | XML | lsp4xml | Yes | +| Fortran | fortls | Yes | +| Scala | Metals | Yes | ## License diff --git a/installer/install-bash-language-server.sh b/installer/install-bash-language-server.sh index 44f6efd..c27d0d8 100755 --- a/installer/install-bash-language-server.sh +++ b/installer/install-bash-language-server.sh @@ -2,14 +2,7 @@ set -e -server_dir="../servers/bash-language-server" - cd $(dirname $0) -[ -d $server_dir ] && rm -rf $server_dir -mkdir $server_dir && cd $server_dir - -npm init -y -sed -i -e 's/\"name\":.*$/\"name\": \"\",/' package.json -npm install bash-language-server -ln -s ./node_modules/.bin/bash-language-server . +. ./npm.sh +npm_install bash-language-server bash-language-server diff --git a/installer/install-css-languageserver.sh b/installer/install-css-languageserver.sh new file mode 100755 index 0000000..ae7c8a6 --- /dev/null +++ b/installer/install-css-languageserver.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +cd $(dirname $0) + +. ./npm.sh +npm_install css-languageserver vscode-css-languageserver-bin diff --git a/installer/install-docker-langserver.sh b/installer/install-docker-langserver.sh index 59e0b7e..28b433f 100755 --- a/installer/install-docker-langserver.sh +++ b/installer/install-docker-langserver.sh @@ -2,14 +2,7 @@ set -e -server_dir="../servers/docker-langserver" - cd $(dirname $0) -[ -d $server_dir ] && rm -rf $server_dir -mkdir $server_dir && cd $server_dir - -npm init -y -sed -i -e 's/\"name\":.*$/\"name\": \"\",/' package.json -npm install dockerfile-language-server-nodejs -ln -s ./node_modules/.bin/docker-langserver . +. ./npm.sh +npm_install docker-langserver dockerfile-language-server-nodejs diff --git a/installer/install-fortls.sh b/installer/install-fortls.sh new file mode 100755 index 0000000..9685151 --- /dev/null +++ b/installer/install-fortls.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +cd $(dirname $0) + +. ./pip3.sh +pip_install fortls fortran-language-server diff --git a/installer/install-html-languageserver.sh b/installer/install-html-languageserver.sh new file mode 100755 index 0000000..6838379 --- /dev/null +++ b/installer/install-html-languageserver.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +set -e + +cd $(dirname $0) + +. ./npm.sh +npm_install html-languageserver vscode-html-languageserver-bin diff --git a/installer/install-javascript-typescript-langserver.sh b/installer/install-javascript-typescript-langserver.sh index 572a8df..de35663 100755 --- a/installer/install-javascript-typescript-langserver.sh +++ b/installer/install-javascript-typescript-langserver.sh @@ -1,20 +1,8 @@ -#!/bin/sh +#!/bin/bash set -e cd $(dirname $0) -[ -d ../servers/javascript-typescript-langserver ] && rm -rf ../servers/javascript-typescript-langserver -mkdir ../servers/javascript-typescript-langserver -cd ../servers/javascript-typescript-langserver -git clone https://github.com/sourcegraph/javascript-typescript-langserver . -npm install -npm build -cat <<EOF > javascript-typescript-langserver -#!/bin/sh - -DIR=\$(cd \$(dirname \$0); pwd) -node \$DIR/lib/language-server-stdio.js -EOF - -chmod +x javascript-typescript-langserver +. ./npm.sh +npm_install javascript-typescript-langserver javascript-typescript-langserver diff --git a/installer/install-metals.sh b/installer/install-metals.sh new file mode 100755 index 0000000..58c7a23 --- /dev/null +++ b/installer/install-metals.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +cd $(dirname $0) + +server_dir="../servers/metals" + +[ -d $server_dir ] && rm -rf $server_dir +mkdir $server_dir && cd $server_dir + +curl -Lo ./coursier https://git.io/coursier-cli +chmod +x ./coursier + +version="0.7.6" +java -jar ./coursier bootstrap --ttl Inf "org.scalameta:metals_2.12:$version" -r "bintray:scalacenter/releases" -r "sonatype:public" -r "sonatype:snapshots" -o ./metals diff --git a/installer/install-pyls.sh b/installer/install-pyls.sh index 4b280fd..fa61803 100755 --- a/installer/install-pyls.sh +++ b/installer/install-pyls.sh @@ -2,12 +2,7 @@ set -e -server_dir="../servers/pyls" - cd $(dirname $0) -[ -d $server_dir ] && rm -rf $server_dir -mkdir $server_dir && cd $server_dir -python3 -m venv ./venv -./venv/bin/pip3 install python-language-server -ln -s ./venv/bin/pyls . +. ./pip3.sh +pip_install pyls python-language-server diff --git a/installer/install-typescript-language-server.sh b/installer/install-typescript-language-server.sh index 8b0cf7e..7669018 100755 --- a/installer/install-typescript-language-server.sh +++ b/installer/install-typescript-language-server.sh @@ -3,18 +3,6 @@ set -e cd $(dirname $0) -[ -d ../servers/typescript-language-server ] && rm -rf ../servers/typescript-language-server -mkdir ../servers/typescript-language-server -cd ../servers/typescript-language-server -git clone https://github.com/theia-ide/typescript-language-server . -yarn -yarn build -cat <<EOF > typescript-language-server -#!/bin/sh - -DIR=\$(cd \$(dirname \$0); pwd) -node \$DIR/server/lib/cli.js --stdio -EOF - -chmod +x typescript-language-server +. ./npm.sh +npm_install typescript-language-server typescript-language-server diff --git a/installer/install-vim-language-server.sh b/installer/install-vim-language-server.sh index be76522..17b87df 100755 --- a/installer/install-vim-language-server.sh +++ b/installer/install-vim-language-server.sh @@ -1,20 +1,8 @@ -#!/bin/sh +#!/bin/bash set -e cd $(dirname $0) -[ -d ../servers/vim-language-server ] && rm -rf ../servers/vim-language-server -mkdir ../servers/vim-language-server -cd ../servers/vim-language-server -git clone https://github.com/iamcco/vim-language-server . -yarn -yarn build -cat <<EOF > vim-language-server -#!/bin/sh - -DIR=\$(cd \$(dirname \$0); pwd) -node \$DIR/bin/index.js --stdio -EOF - -chmod +x vim-language-server +. ./npm.sh +npm_install vim-language-server vim-language-server diff --git a/installer/install-yaml-language-server.sh b/installer/install-yaml-language-server.sh index 015f953..d3f0e47 100755 --- a/installer/install-yaml-language-server.sh +++ b/installer/install-yaml-language-server.sh @@ -4,14 +4,5 @@ set -e cd $(dirname $0) -server_dir="../servers/yaml-language-server" -[ -d $server_dir ] && rm -rf $server_dir -mkdir $server_dir && cd $server_dir - -npm init -y -cat <<EOF >package.json -{"name": ""} -EOF -npm install yaml-language-server - -ln -s ./node_modules/.bin/yaml-language-server . +. ./npm.sh +npm_install yaml-language-server yaml-language-server diff --git a/installer/npm.sh b/installer/npm.sh new file mode 100644 index 0000000..c1ec529 --- /dev/null +++ b/installer/npm.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +# Usage +# $ . npm.sh +# $ npm_install [EXECUTABLE_NAME] [NPM_NAME] +npm_install() { + server_dir="../servers/$1" + [ -d "$server_dir" ] && rm -rf "$server_dir" + mkdir "$server_dir" && cd "$server_dir" + + 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 + + npm install "$2" + ln -s "./node_modules/.bin/$1" . +} diff --git a/installer/pip3.sh b/installer/pip3.sh new file mode 100644 index 0000000..b309e88 --- /dev/null +++ b/installer/pip3.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -e + +# Usage +# $ . pip3.sh +# $ pip_install [EXECUTABLE_NAME] [PYPI_NAME] +pip_install() { + server_dir="../servers/$1" + [ -d "$server_dir" ] && rm -rf "$server_dir" + mkdir "$server_dir" && cd "$server_dir" + + python3 -m venv ./venv + ./venv/bin/pip3 install "$2" + ln -s "./venv/bin/$1" . +} diff --git a/settings.json b/settings.json index b453245..83cb3b5 100644 --- a/settings.json +++ b/settings.json @@ -107,7 +107,7 @@ { "command": "vim-language-server", "requires": [ - "yarn" + "npm" ] } ], @@ -172,5 +172,21 @@ "java" ] } + ], + "fortran": [ + { + "command": "fortls", + "requires": [ + "python3" + ] + } + ], + "scala": [ + { + "command": "metals", + "requires": [ + "java" + ] + } ] } diff --git a/settings/fortls.vim b/settings/fortls.vim new file mode 100644 index 0000000..78c29ea --- /dev/null +++ b/settings/fortls.vim @@ -0,0 +1,12 @@ +augroup vimlsp_settings_fortls + au! + autocmd User lsp_setup ++once call lsp#register_server({ + \ 'name': 'fortls', + \ 'cmd': {server_info->lsp_settings#get('fortls', 'cmd', [lsp_settings#exec_path('fortls')])}, + \ 'initialization_options': lsp_settings#get('fortls', 'initialization_options', v:null), + \ 'whitelist': lsp_settings#get('fortls', 'whitelist', ['fortran']), + \ 'blacklist': lsp_settings#get('fortls', 'blacklist', []), + \ 'config': lsp_settings#get('fortls', 'config', {}), + \ 'workspace_config': lsp_settings#get('fortls', 'workspace_config', {}), + \ }) +augroup END diff --git a/settings/metals.vim b/settings/metals.vim new file mode 100644 index 0000000..e61377b --- /dev/null +++ b/settings/metals.vim @@ -0,0 +1,12 @@ +augroup vimlsp_settings_metals + au! + autocmd User lsp_setup ++once call lsp#register_server({ + \ 'name': 'metals', + \ 'cmd': {server_info->lsp_settings#get('metals', 'cmd', [lsp_settings#exec_path('metals')])}, + \ 'root_uri':{server_info->lsp_settings#get('metals', 'root_uri', lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), ['.git/', 'build.sbt'])))}, + \ 'whitelist': lsp_settings#get('metals', 'whitelist', ['scala', 'sbt']), + \ 'blacklist': lsp_settings#get('metals', 'blacklist', []), + \ 'config': lsp_settings#get('metals', 'config', {}), + \ 'workspace_config': lsp_settings#get('metals', 'workspace_config', {}), + \ }) +augroup END diff --git a/test/run.sh b/test/run.sh new file mode 100755 index 0000000..7da9443 --- /dev/null +++ b/test/run.sh @@ -0,0 +1,31 @@ +#!/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 new file mode 100755 index 0000000..78b89aa --- /dev/null +++ b/test/send.py @@ -0,0 +1,42 @@ +#!/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) |