From 2c210dd7ec5b2c53fa24bbb8005d6e6d08cec0b2 Mon Sep 17 00:00:00 2001 From: HenryHsieh Date: Sat, 4 Jun 2022 00:05:10 +0800 Subject: feat: add svlangserver support (#1916) --- .../server_configurations/svlangserver.lua | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 lua/lspconfig/server_configurations/svlangserver.lua (limited to 'lua') diff --git a/lua/lspconfig/server_configurations/svlangserver.lua b/lua/lspconfig/server_configurations/svlangserver.lua new file mode 100644 index 00000000..613f815a --- /dev/null +++ b/lua/lspconfig/server_configurations/svlangserver.lua @@ -0,0 +1,66 @@ +local util = require 'lspconfig.util' + +local bin_name = 'svlangserver' +local cmd = { bin_name } + +if vim.fn.has 'win32' == 1 then + cmd = { 'cmd.exe', '/C', bin_name } +end + +local function build_index() + local params = { + command = 'systemverilog.build_index', + } + vim.lsp.buf.execute_command(params) +end + +local function report_hierarchy() + local params = { + command = 'systemverilog.report_hierarchy', + arguments = { vim.fn.expand '' }, + } + vim.lsp.buf.execute_command(params) +end + +return { + default_config = { + cmd = cmd, + filetypes = { 'verilog', 'systemverilog' }, + root_dir = function(fname) + return util.root_pattern '.nvim'(fname) or util.find_git_ancestor(fname) + end, + single_file_support = true, + settings = { + systemverilog = { + includeIndexing = { '*.{v,vh,sv,svh}', '**/*.{v,vh,sv,svh}' }, + }, + }, + on_init = function(client) + local json = '' + for line in io.lines(client.config.root_dir .. '/.nvim/lspconfig.json') do + json = json .. line + end + json = vim.json.decode(json) + client.config.cmd = { json.languageserver.svlangserver.command } + client.config.filetypes = json.languageserver.svlangserver.filetypes + client.config.settings = json.languageserver.svlangserver.settings + end, + }, + commands = { + SvlangserverBuildIndex = { + build_index, + description = 'Instructs language server to rerun indexing', + }, + SvlangserverReportHierarchy = { + report_hierarchy, + description = 'Generates hierarchy for the given module', + }, + }, + docs = { + description = [[ +https://github.com/imc-trading/svlangserver + +`svlangserver`, a language server for systemverilog +]], + }, +} -- cgit v1.2.3-70-g09d2