The language server can be hooked up to your IDE or text editor to provide assistance while programming. It helps highlight syntax errors or lint violations and provides fixes for issues if they are available.
The language server is part of the Verible suite and called
verible-verilog-ls
.
There are a few changes in the review pipeline, so here is the current progress
- Publish diagnostics for syntax errors and lint rules
- Use lint configuration from
.rules.verible_lint
instead of all enabled
- Use lint configuration from
- Provide code actions for autofixes provided by lint rules
- Generate file symbol outline ('navigation tree')
- Provide formatting.
- Highlight all the symbols that are the same as current under cursor.
- Take scope and type into account to only highlight same symbols.
- Provide useful information on hover (#1187)
- Find definition of symbol even if in another file. (#1189)
- Provide Document Links (e.g. opening include files) (#1190)
- Rename refactor a symbol
After installing the verible tools, you can configure your editor to use the language server.
This will be specific to your editor. In essence, you need to tell
it to start the verible-verilog-ls
language server whenever it works with
Verilog or SystemVerilog files.
Here are a few common editors, but there are many more that support language servers. If you have configured it for your editor, consider sending a pull request that adds a section to this README (or file an issue an mention what you had to do and we add it here).
In alphabetical order
The lsp-mode
needs to be installed from wherever you get your emacs
packages.
Here is a simple setup: put this in your ~/.emacs
file
and make sure the binary is in your $PATH
(or use full path).
(require 'lsp-mode)
(add-to-list 'lsp-language-id-configuration '(verilog-mode . "verilog"))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection "verible-verilog-ls")
:major-modes '(verilog-mode)
:server-id 'verible-ls))
(add-hook 'verilog-mode-hook 'lsp)
https://docs.kde.org/trunk5/en/kate/kate/kate-application-plugin-lspclient.html
First, enable LSP by checking Settings > Configure Kate > Plugins > LSP Client
Then, there is a new {} LSP Client
icon appearing on the left of the configure dialog. In the User Server Settings tab, enter the lsp server configuration
to get it started up on our Verilog/SystemVerilog projects.
{
"servers": {
"verilog": {
"command": ["verible-verilog-ls"],
"root": "",
"url": "https://github.com/chipsalliance/verible"
},
"systemverilog": {
"command": ["verible-verilog-ls"],
"root": "",
"url": "https://github.com/chipsalliance/verible"
}
}
}
Make sure to have version 0.5.0
or newer and install the nvim-lspconfig plugin.
You can install it with the popular vim-plug plugin manager by adding the following code to your ~/.config/nvim/init.vim file:
call plug#begin()
Plug 'neovim/nvim-lspconfig'
call plug#end()
Then to install it open neovim and type: :PlugInstall
After installing nvim-lspconfig, enable the verible config by appending the following script to your ~/.config/nvim/init.nvim file:
lua << EOF
-- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap=true, silent=true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap=true, silent=true, buffer=bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>a', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<space>f', vim.lsp.buf.formatting, bufopts)
end
local lsp_flags = {
-- This is the default in Nvim 0.7+
debounce_text_changes = 150,
}
require'lspconfig'.verible.setup {
on_attach = on_attach,
flags = lsp_flags,
root_dir = function() return vim.loop.cwd() end
}
EOF
This script initializes the verible language server in neovim and also enables shortcuts for functionalities such as auto-fix (space + a). See https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#verible for configuration options.
Consult https://lsp.readthedocs.io/
Installation steps
- Enable package control if not already
Tools > Install Package control...
- Install LSP base package:
Preferences > Package Control
search forInstall Package
. Confirm, then search forLSP
. - Also, while at it, if you haven't already, install the
SystemVerilog
package, which gives you general syntax highlighting. - Go to
Preferences > Package Settings > LSP > Settings
. It opens a global setting file and a user setting skeleton. Put the following in your userLSP.sublime-settings
; it already provides the empty outer braces, you need to add the"clients"
section.
// Settings in here override those in "LSP/LSP.sublime-settings"
{
"clients": {
"verible-verilog-ls": {
"command": ["verible-verilog-ls"],
"enabled": true,
"selector": "source.systemverilog"
}
}
}
There is a Tools > LSP > Troubleshoot Server Configuration
which might
be helpful in case of issues.
TBD. What I found so far, there is vim-lsp that can be used. There is also neovim.
In the vscode/ subdirectory, you find instructions how to build and install an extension for VSCode.