Vim/Neovim Indent Plugin for SystemVerilog & UVM
Language: English
Maintainer: sqlmap3
Version: 0.1
First Change: 2025-12-06
Last Change: 2025-12-08
This plugin extends nachumk/systemverilog.vim to add UVM support and refine SystemVerilog editing.
It fixes indentation edge cases (case labels, single-line if, grouping blocks), adds UVM-specific syntax highlighting, and completes matchit pairs for common UVM/SV constructs.
- Accurate indentation for SystemVerilog and UVM, including:
- Case branch labels (
{10,11}:, numeric/literal,default:) align with subsequentif/else - UVM macro lines (e.g.,
`uvm_info,`uvm_error) treated as statement terminators - Stable grouping for
class/endclass,function/endfunction,task/endtask - Handles block/line comments and strings robustly
- UVM-specific syntax highlighting and matchit pairs
- Indentation fixes for single-line
if ... begin ... endandelseon next line - Lower priority for
assert/elsein multi-line conditions (if/else jump preferred)
- Case branch labels (
Manual:
- Vim:
indent/systemverilog.vim→~/.vim/indent/ - Neovim: →
~/.config/nvim/indent/ - Windows: →
~/vimfiles/indent/or~/AppData/Local/nvim/indent/
Plugin manager (vim-plug):
Plug 'sqlmap3/systemverilog.vim'Ensure indent/systemverilog.vim is under your runtimepath’s indent/ directory.
Pathogen:
runtime macros/matchit.vim
execute pathogen#infect()
filetype plugin indent onClone:
git clone https://github.com/sqlmap3/systemverilog.vim ~/.vim/bundle/systemverilog.vimPowerShell:
git clone https://github.com/sqlmap3/systemverilog.vim $HOME/vimfiles/bundle/systemverilog.vimVerify:
- Open a
*.svor*.svhfile →:set ft?showsfiletype=systemverilog :set shiftwidth?shows2;%jumps betweenuvm_object_utils_begin/_end
- Install via vim-plug or Pathogen
- Enable matchit:
runtime macros/matchit.vim - Open an SV/UVM file and verify:
:set ft?→filetype=systemverilog
- Use
%to jump betweenuvm_*_utils_begin/_endorcovergroup/endgroup - Indentation respects case labels and single-line
if
*.v,*.vh,*.sv,*.svh,*.svp,*.svi
- Vim 8+ or Neovim
- Optional:
matchit.vimfor keyword pair jumping
Below are some useful Vim/Neovim plugins for SystemVerilog/UVM development.
Most are available via vim-plug or other plugin managers.
- fzf: Fuzzy file finder, fast project navigation.
- indentLine: Indentation guides, visually show indent levels.
- log-highlight: Syntax highlight for log files.
- NERDTree: File explorer, project tree navigation.
- rainbow: Rainbow parentheses/brackets, color matching pairs.
- SrcExpl: Source explorer, code structure navigation.
- Trinity: Multi-pane file navigation.
- vim-snipmate: Snippet engine, code templates.
- vim-snippets: Snippet collection for snipmate/UltiSnips.
- vim-matchup: Enhanced matching and highlighting for keywords/regions.
Requirements:
- Vim 8+ or Neovim recommended for best compatibility.
- Some plugins may require Python support or additional configuration.
If SystemVerilog filetype detection isn’t enabled, add:
augroup ft_sv
autocmd!
autocmd BufRead,BufNewFile *.sv,*.svh setlocal filetype=systemverilog
augroup ENDRecommended indentation:
setlocal shiftwidth=2
setlocal tabstop=2
setlocal expandtabcase+ UVM macros
case (i)
{10,11}: if (1==1)
`uvm_info
else
`uvm_error
end
{12,13}: if (a==2)
`uvm_info
else
`uvm_error
end
endcaseclass+task
class xxxx extends xx;
task item();
bit a;
$display();
temp_str = 0;
endtask
endclassInner statements indent one level relative to grouping keywords (class/task); closing (endtask/endclass) reduces one level.
- Keyword mapping:
- Group start/stop:
class/config/clocking/function/task/... → f; closing:endclass/endfunction/endtask/... → h - Block start/stop:
begin/case/fork/(/{ → b; closing:end/endcase/join/.../)/} → e - Execution/control:
if/else/for/always/initial/... → x - Preprocessor: selected backtick directives mapped to
z
- Group start/stop:
- UVM macros: backtick-prefixed lines converted to
;(statement terminator) to consume single-line indentation from precedingif, not treated as control statements - Branch labels: retained and constrained to avoid affecting
f/hgrouping (e.g., namedendfunction : name) - Indent logic fixes for if/else jump, single-line if/begin/end, and assert priority
- Complex labeled endings (e.g.,
endtask: name) usually align correctly; please submit minimal repros for edge cases - Heavy macro expansions or nonstandard syntax may need extra tuning
- Please report indentation issues via Issues/PRs with a minimal reproducible snippet (10–20 lines)
- Include Vim/Neovim version, platform, and
shiftwidth/tabstop/expandtabsettings
- Upstream: nachumk/systemverilog.vim
- UVM examples referenced from official documentation
- Inspiration and prior art: https://github.com/WeiChungWu/vim-SystemVerilog
- UVM 1.2 library reference: https://github.com/gchinna/uvm-1.2
- Based on upstream ftplugin: https://github.com/nachumk/systemverilog.vim/blob/master/start/systemverilog.vim/ftplugin/systemverilog.vim (extended for UVM support)
- Improve indentation for special UVM/SV cases (case labels, single‑line
if, grouping blocks) - Add UVM syntax highlighting (classes, TLM APIs, phases, macros)
- Complete matchit pairs for common UVM/SV constructs and macros
- License: GPL-2.0. See
LICENSE.