From ac7a1dc60b300f4bc49c95fec923741a4ef1b7c4 Mon Sep 17 00:00:00 2001 From: Mark Korondi Date: Tue, 20 Aug 2024 15:28:42 +0200 Subject: [PATCH] Add starpls server (Starlark LSP) "starpls is a language server for Starlark, the configuration language used by Bazel and Buck2." [1] [1]: https://github.com/withered-magic/starpls --- README.md | 1 + installer/install-starpls.cmd | 3 +++ installer/install-starpls.sh | 41 +++++++++++++++++++++++++++++++++++ settings.json | 8 +++++++ settings/starpls.vim | 15 +++++++++++++ 5 files changed, 68 insertions(+) create mode 100644 installer/install-starpls.cmd create mode 100755 installer/install-starpls.sh create mode 100644 settings/starpls.vim diff --git a/README.md b/README.md index 661016a..0b5880c 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,7 @@ You can change the directory to install servers by set `g:lsp_settings_servers_d | SQL | sql-language-server | Yes | Yes | | SQL | sqls | Yes | Yes | | SQL | plpgsql-server | UNIX Only | Yes | +| Starlark | starpls | Yes | Yes | | Scala | Metals | Yes | Yes | | Svelte | svelte-language-server | Yes | Yes | | Svelte | tailwindcss-intellisense | Yes | Yes | diff --git a/installer/install-starpls.cmd b/installer/install-starpls.cmd new file mode 100644 index 0000000..7a9f3a9 --- /dev/null +++ b/installer/install-starpls.cmd @@ -0,0 +1,3 @@ +@echo off + +curl -L -o "starpls.exe" "https://github.com/withered-magic/starpls/releases/latest/download/starpls-windows-amd64.exe" diff --git a/installer/install-starpls.sh b/installer/install-starpls.sh new file mode 100755 index 0000000..6360524 --- /dev/null +++ b/installer/install-starpls.sh @@ -0,0 +1,41 @@ +#!/bin/sh + +set -e + +os=$(uname -s | tr "[:upper:]" "[:lower:]") +arch="$(uname -m)" + +case $os in +linux) + if [ "$arch" = "x86_64" ]; then + platform="linux-amd64" + else + echo "unknown architecture: $arch" + exit 1 + fi + ;; +darwin) + if [ "$arch" = "aarch64" ] || [ "$arch" = "arm64" ]; then + platform="darwin-arm64" + else + echo "unknown architecture: $arch" + exit 1 + fi + ;; +mingw64_nt*) + if [ "$arch" = "x86_64" ]; then + platform="windows-amd64.exe" + else + echo "unknown architecture: $arch" + exit 1 + fi + ;; +*) + echo "unknow platform: $os" + exit 1 + ;; +esac + +curl -L -o "starpls" "https://github.com/withered-magic/starpls/releases/latest/download/starpls-$platform" + +chmod +x starpls diff --git a/settings.json b/settings.json index 302aae5..04b594f 100644 --- a/settings.json +++ b/settings.json @@ -66,6 +66,14 @@ ] } ], + "bzl": [ + { + "command": "starpls", + "url": "https://github.com/withered-magic/starpls", + "description": "An LSP implementation for Starlark, the configuration language used by Bazel and Buck2.", + "requires": [] + } + ], "c": [ { "command": "clangd", diff --git a/settings/starpls.vim b/settings/starpls.vim new file mode 100644 index 0000000..210b510 --- /dev/null +++ b/settings/starpls.vim @@ -0,0 +1,15 @@ +augroup vim_lsp_settings_starpls + au! + LspRegisterServer { + \ 'name': 'starpls', + \ 'cmd': {server_info->lsp_settings#get('starpls', 'cmd', [lsp_settings#exec_path('starpls')]+lsp_settings#get('starpls', 'args', []))}, + \ 'root_uri':{server_info->lsp_settings#get('starpls', 'root_uri', lsp_settings#root_uri('starpls'))}, + \ 'initialization_options': lsp_settings#get('starpls', 'initialization_options', {}), + \ 'allowlist': lsp_settings#get('starpls', 'allowlist', ['bzl', 'starlark']), + \ 'blocklist': lsp_settings#get('starpls', 'blocklist', []), + \ 'config': lsp_settings#get('starpls', 'config', lsp_settings#server_config('starpls')), + \ 'workspace_config': lsp_settings#get('starpls', 'workspace_config', {}), + \ 'semantic_highlight': lsp_settings#get('starpls', 'semantic_highlight', {}), + \ } +augroup END +