Language server for OMNeT++
Go to definition, completion and diagnostics for .ned and .ini files, in the editor you already use.
reciever in network PreemptionNetwork
*.receiver.app[0].typename = "UdpSinkApp"
Illustration: Ctrl+click on PreemptionNetwork in the INI file jumps to the network in the NED file, and the misspelled submodule is flagged while you type.
ned_ls reads your whole workspace, including imported projects like INET, so references resolve across files and projects.
package / import statementsextends and like targets, cyclic extends, interface conformance, connection errors (unknown gate, wrong direction, missing vector index), duplicate submodulesextendsextends between sectionsINI diagnostics are intentionally strict, so expect an occasional false positive.
Install the extension from the VS Code Marketplace or Open VSX. The language server is included, so there is nothing else to install. The .vsix files are also on the Releases page.
Download a prebuilt binary from the Releases page, or build it from source. Building needs a Rust toolchain and a C compiler, because Tree-sitter is written in C.
cargo install --git https://github.com/HannHank/ned_ls
Either way, make sure ned_ls is on your PATH. cargo install puts it into ~/.cargo/bin.
ned_ls works with every editor that supports the Language Server Protocol. It talks over stdin and stdout.
Neovim has a built-in LSP client. Add this to your config:
-- Neovim does not know .ned files by default
vim.filetype.add({ extension = { ned = "ned" } })
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.workspace.didChangeWatchedFiles.dynamicRegistration = true
vim.api.nvim_create_autocmd("FileType", {
pattern = { "ned", "dosini" }, -- .ini files have the filetype "dosini"
callback = function()
vim.lsp.start({
name = "ned_ls",
cmd = { "ned_ls" },
capabilities = capabilities,
root_dir = vim.uv.cwd(),
})
end,
})
If you map .ini files to another filetype, for example for an OMNeT++ Tree-sitter grammar, use that name instead of dosini.
Install vim-lsp and register the server:
autocmd BufNewFile,BufRead *.ned setlocal filetype=ned
if executable('ned_ls')
augroup NedLSP
autocmd!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'ned_ls',
\ 'cmd': {server_info->['ned_ls']},
\ 'allowlist': ['ned', 'dosini'],
\ })
augroup END
endif
Vim does not support dynamic file watching, so after deleting files you may need to restart Vim to refresh the index.
Copy the syntax files from editors/sublime in the repository into your Sublime Packages/User folder. Then install the LSP package and add this to Preferences › Package Settings › LSP › Settings:
{
"clients": {
"ned_ls": {
"enabled": true,
"command": ["ned_ls"],
"selector": "source.ned | source.ini.omnetpp"
}
}
}
Install omnetpp-zed from the extensions tab for syntax highlighting. Then use Install Dev Extension and select the editors/zed folder of the ned_ls repository.
The extension uses ned_ls from your PATH. To use a specific binary instead, set its path in your settings.json:
{
"lsp": {
"ned_ls": {
"binary": { "path": "/absolute/path/to/ned_ls" }
}
}
}
In editors like Helix, Emacs or Lapce, configure a language server that runs the command ned_ls for .ned and .ini files. No arguments are needed.
Most projects need no configuration. ned_ls picks up the folders listed in .nedfolders, projects referenced in an OMNeT++ Makefile, and the paths in NEDPATH. To index further projects, like INET, create a Ned_ls.toml in the workspace root:
imported_projects = [
"~/inet/",
"../AutoTSN/",
]
INI support is only active in OMNeT++ workspaces, meaning the workspace contains a .ned file, a .nedfolders or a Ned_ls.toml. That way .ini files in unrelated projects get no OMNeT++ errors.
I use ned_ls daily with OMNeT++ and INET, and the core features are stable for my workflows. Expect rough edges in less common NED and INI constructs.
.msg files are not supported yet.