I'm trying to use Vim with ASIP Designer and read files written in nML, a description language for processor designs. I searched Google and the community with the tag "nML" but saw no related solutions. As I'm just a beginner at nML, I'm wondering if anyone knows how to set up syntax highlighting for this kind of file (*.n).
1 Answer
Syntax
It seems to me that the nML language is relatively close to c.
I have prepared a simple syntax file that enrich the c syntax:
~/.vim/syntax/nml.vim:
" Vim syntax file
" Language: nML
" Maintainer: Vivian De Smedt ([email protected])
" Last Change: 2025 Jan 15^
" quit when a syntax file was already loaded.
if exists("b:current_syntax")
finish
endif
source $VIMRUNTIME/syntax/c.vim
syn keyword cStatement opn
syn match cUserLabel "\<\w*\>\ze\s*:\>"
let b:current_syntax = "nml"
" vim:set sw=2 sts=2 ts=8 noet:
Filetype Detection
If you set the filetype of your buffer to nml (:set ft=nml) the buffer should be correctly colorized.
If you want the *.n to be automatically detected as n file you could add a nml.vim file in the ~/.vim/ftdetect/ folder:
~/.vim/ftdetect/nml.vim:
autocmd BufNewFile,BufRead *.n setfiletype nml
-
This is very helpful. Thanks for the patience and solution!Yike Li– Yike Li2025-01-15 17:23:47 +00:00Commented Jan 15 at 17:23
-
Thanks for the feedback! Feel free to ask for more support we are glad to help you :-)2025-01-15 17:32:04 +00:00Commented Jan 15 at 17:32
:help new-filetypeas well as by several answers on this site. Writing a full ftplugin from scratch may be beyond the scope of a question on this site. Can you share a link to the specification of nML? Have you tried searching for existing plugins?c(:set ft=c)set filetype=sml)