From df16380fa64c9c89ebf0b2d3dd1a123d5ca7e925 Mon Sep 17 00:00:00 2001 From: Siddharth Sharma Date: Sun, 3 Mar 2024 00:20:19 +0100 Subject: [PATCH] Add YANG LSP settings This addresses mattn/vim-lsp-settings#724 Signed-off-by: Siddharth Sharma --- README.md | 1 + data/README.md | 2 +- installer/install-yang-lsp.cmd | 15 +++++++++++++++ installer/install-yang-lsp.sh | 9 +++++++++ settings.json | 21 +++++++++++++++++++++ settings/yang-lsp.vim | 14 ++++++++++++++ 6 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 installer/install-yang-lsp.cmd create mode 100644 installer/install-yang-lsp.sh create mode 100644 settings/yang-lsp.vim diff --git a/README.md b/README.md index d54e6561..51e11e6e 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,7 @@ You can change the directory to install servers by set `g:lsp_settings_servers_d | V | vlang-vls | Yes | Yes | | XML | lemminx | Yes | Yes | | YAML | yaml-language-server | Yes | Yes | +| YANG | yang-lsp | Yes | Yes | | ZIG | zls | Yes | Yes | | \* | efm-langserver | Yes | Yes | diff --git a/data/README.md b/data/README.md index 0bbefe05..a1ea62c4 100644 --- a/data/README.md +++ b/data/README.md @@ -4,4 +4,4 @@ JSON Schemas -https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/api/json/catalog.json + diff --git a/installer/install-yang-lsp.cmd b/installer/install-yang-lsp.cmd new file mode 100644 index 00000000..599d1d60 --- /dev/null +++ b/installer/install-yang-lsp.cmd @@ -0,0 +1,15 @@ +@echo off + +setlocal +set VERSION=0.7.6 +curl -L -o yang-language-server.zip https://github.com/TypeFox/yang-lsp/releases/download/v%VERSION%/yang-language-server_%VERSION%.zip +call "%%~dp0\run_unzip.cmd" yang-language-server.zip +del yang-language-server.zip + +echo @echo off^ + +setlocal^ + +%%~dp0\yang-language-server-%VERSION%\bin\yang-language-server.bat %%* ^ + +> yang-lsp.cmd diff --git a/installer/install-yang-lsp.sh b/installer/install-yang-lsp.sh new file mode 100644 index 00000000..051d9db2 --- /dev/null +++ b/installer/install-yang-lsp.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +VERSION=0.7.6 +curl -L -o yang-language-server.zip https://github.com/TypeFox/yang-lsp/releases/download/v$VERSION/yang-language-server_$VERSION.zip +unzip yang-language-server.zip +rm yang-language-server.zip +ln -sf yang-language-server-$VERSION/bin/yang-language-server yang-lsp diff --git a/settings.json b/settings.json index 8ab85997..08b7b6e3 100644 --- a/settings.json +++ b/settings.json @@ -1872,6 +1872,27 @@ ] } ], + "yang": [ + { + "command": "yang-lsp", + "url": "https://github.com/TypeFox/yang-lsp", + "description": "Language Server for YANG Files", + "requires": [ + "java" + ], + "root_uri_patterns": [ + ".git", + ".git/", + "yang.settings" + ], + "vim_plugin": { + "extensions": [ + "yang" + ], + "name": "nathanalderson/yang.vim" + } + } + ], "zig": [ { "command": "zls", diff --git a/settings/yang-lsp.vim b/settings/yang-lsp.vim new file mode 100644 index 00000000..7057d68a --- /dev/null +++ b/settings/yang-lsp.vim @@ -0,0 +1,14 @@ +augroup vim_lsp_settings_yang_lsp + au! + LspRegisterServer { + \ 'name': 'yang-lsp', + \ 'cmd': {server_info->lsp_settings#get('yang-lsp', 'cmd', [lsp_settings#exec_path('yang-lsp')]+lsp_settings#get('yang-lsp', 'args', []))}, + \ 'root_uri':{server_info->lsp_settings#get('yang-lsp', 'root_uri', lsp_settings#root_uri('yang-lsp'))}, + \ 'initialization_options': lsp_settings#get('yang-lsp', 'initialization_options', v:null), + \ 'allowlist': lsp_settings#get('yang-lsp', 'allowlist', ['yang']), + \ 'blocklist': lsp_settings#get('yang-lsp', 'blocklist', []), + \ 'config': lsp_settings#get('yang-lsp', 'config', lsp_settings#server_config('yang-lsp')), + \ 'workspace_config': lsp_settings#get('yang-lsp', 'workspace_config', {}), + \ 'semantic_highlight': lsp_settings#get('yang-lsp', 'semantic_highlight', {}), + \ } +augroup END