DICOM metadata viewer for Neovim 0.12+. Displays .dcm file headers as an
expandable table with cursor-row highlighting.
- Neovim ≥ 0.12
- Python 3 with pydicom (
uv tool install pydicom)
vim.pack.add({
"Gabsha/dcm-nvim",
config = function()
require("dcm").setup({
tag_width = 14,
name_width = 32,
auto_open = true,
})
end,
}){
"Gabsha/dcm-nvim",
ft = "dcm",
config = function()
require("dcm").setup({
auto_open = true,
})
end,
}Open any .dcm file — the raw/binary buffer is replaced in-place with the
rendered metadata table (no binary content is ever shown). If you invoke
:DcmOpen <file> for a file that isn't the current buffer, the viewer opens
in a right-side split instead:
nvim scan.dcm
| Command | Description |
|---|---|
:DcmOpen [file] |
Open viewer for a DICOM file |
:DcmToggle |
Toggle viewer on/off |
:DcmClose |
Close all DICOM viewers |
| Key | Action |
|---|---|
<CR> |
Expand / collapse a list-valued row |
q |
Close viewer |
j / k |
Navigate rows |
<C-d> |
Page down |
<C-u> |
Page up |
┌──────────────┬──────────────────────────────────┬────────────────────┐
│ Tag │ Name (VR) │ Value │
├──────────────┼──────────────────────────────────┼────────────────────┤
│ (0008,0008) │ ImageType (CS) │ ["ORIGINAL", ...] │
│ (0010,0010) │ PatientName (PN) │ Doe^John │
│ (0010,0030) │ PatientBirthDate (DA) │ 19700101 │
│ (0020,000E) │ StudyInstanceUID (UI) │ 1.2.3.4.5.6... │
│ ... │ ... │ ... │
└──────────────┴──────────────────────────────────┴────────────────────┘
Rows with ▶ can be expanded with <CR>. Expanded rows show ▼ and list
all contained values. This includes DICOM Sequences (VR SQ), which are
nested datasets: expanding a sequence reveals its [n] Item rows, and
expanding an Item reveals its own tags -- indented one level further. Since
sequences can nest arbitrarily deep (an Item can itself contain another
Sequence), this works recursively to any depth, and every row can be
expanded/collapsed independently of its siblings and parents.
require("dcm").setup({
tag_width = 14, -- width of the (xxxx,xxxx) column
name_width = 32, -- width of Name (VR) column
auto_open = true, -- auto-open on FileType=dcm
expand_key = "<CR>", -- key to expand/collapse
close_key = "q", -- key to close viewer
})vim.api.nvim_set_hl(0, "DcmCurrentRow", { bg = "#3a3a5c", bold = true })
vim.api.nvim_set_hl(0, "DcmHeader", { fg = "#c0caf5", bold = true })
vim.api.nvim_set_hl(0, "DcmExpandable", { underline = true, sp = "#7aa2f7" })
vim.api.nvim_set_hl(0, "DcmChild", { fg = "#9aa5ce" })Available groups: DcmHeader, DcmSeparator, DcmFooter, DcmRow,
DcmExpandable, DcmExpanded, DcmChild, DcmCurrentRow.
ftdetect/dcm.luasetsfiletype=dcmfor.dcmfiles- An autocmd fires on
FileType dcmand callspydicomviavim.system() - Pydicom parses the DICOM header and returns JSON
- The JSON is rendered into a scratch buffer as a scrollable table
- Rows with list values, or DICOM Sequences (nested datasets), are
expandable via
<CR>-- sequences recurse to arbitrary depth - Cursor movement triggers row highlighting via extmarks
MIT
