1

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).

6
  • Making Vim aware of a custom filetype is easy enough and covered by :help new-filetype as 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? Commented Jan 14 at 19:13
  • After some research and some errors it seems to me that there are no nMl syntax available for Vim yet. An filetype approximation is c (:set ft=c) Commented Jan 14 at 22:01
  • In fact it suggests a dialect of standard ML to me, so perhaps try any of the SML filetype plugins (there are some that ship with Vim for set filetype=sml) Commented Jan 15 at 2:24
  • 1
    Sorry for the late reply. So first about the specification of nML, here is the link nML: A Structural Processor Modeling Language for Retargetable Compilation and ASIP Design. I suppose it's something between C and Verilog. I tried searching for plugins but still no available sources. I'll try the SML filetype mentioned by D. Ben Knoble. Thanks for the suggestions. Commented Jan 15 at 10:37
  • 2
    C, SML, and Verilog settings all have some of the syntax but not complete one. I'm using Verilog as an approximation now, which is better than plain text. Another question is, is there any way to put this approximation in the .vimrc file so that Vim could automatically treat .n files as .v files? Commented Jan 15 at 10:56

1 Answer 1

1

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
2
  • This is very helpful. Thanks for the patience and solution! Commented Jan 15 at 17:23
  • Thanks for the feedback! Feel free to ask for more support we are glad to help you :-) Commented Jan 15 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.