Language server for OMNeT++

ned_ls

Go to definition, completion and diagnostics for .ned and .ini files, in the editor you already use.

simulations/omnetpp.ini
[General] network = PreemptionNetwork sim-time-limit = 10ms *.sender.numApps = 1 *.sender.app[0].typename = "UdpSourceApp" *.sender.app[0].source.packetLength = 1500B *.reciever.numApps = 1 ned_ls No submodule reciever in network PreemptionNetwork *.receiver.app[0].typename = "UdpSinkApp"
simulations/PreemptionNetwork.ned
package tsn.simulations; import inet.node.ethernet.Eth1G; import inet.node.tsn.TsnDevice; network PreemptionNetworkdefinition { submodules: sender: TsnDevice; receiver: TsnDevice; connections: sender.ethg++ <--> Eth1G <--> receiver.ethg++; }

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.

Features

ned_ls reads your whole workspace, including imported projects like INET, so references resolve across files and projects.

NED .ned

  • Go to definitionfor types, submodules, parameters and gates
  • Find references and renamefor types, with checks against invalid or colliding names
  • Hovershows the documentation comment of the referenced type
  • Completionfor keywords, types, submodules, parameters, gates, connections and package / import statements
  • Diagnosticssyntax errors, packages that do not match the folder structure, unresolved types, imports, extends and like targets, cyclic extends, interface conformance, connection errors (unknown gate, wrong direction, missing vector index), duplicate submodules
  • Formattingbasic formatting of NED files

INI .ini

  • Completionfor configuration options, parameter keys of the selected network and extends
  • Go to definitionfrom INI keys and network names to the NED source
  • Diagnosticsunknown networks, assignments to parameters or gates that do not exist, wrong value types for built-in options, duplicate keys, circular extends between sections

INI diagnostics are intentionally strict, so expect an occasional false positive.


Installation

VS Code and VSCodium

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.

All other editors

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.

Editor setup

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.

Configuration

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.

Status

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.