[vim/vim] add rsc syntax (PR #9097)

62 views
Skip to first unread message

zainin

unread,
Nov 5, 2021, 5:08:42 PM11/5/21
to vim/vim, Subscribed

Add syntax file for RouterOS script.

Let me know if there's any issues to fix before merge.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/9097

Commit Summary

File Changes

(3 files)

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

Christian Brabandt

unread,
Nov 5, 2021, 5:46:37 PM11/5/21
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In runtime/ftplugin/rsc.vim:

> @@ -0,0 +1,6 @@
+" Vim filetype plugin file
+" Language:     RouterOS scripts
+" Maintainer:   zainin
+" Last Change:  2017-07-26
+
+au BufRead,BufNewFile *.rsc set filetype=rsc

This should go into filetype.vim, not into a filetype plugin.

Christian Brabandt

unread,
Nov 5, 2021, 5:47:09 PM11/5/21
to vim/vim, Subscribed

@chrisbra commented on this pull request.


In runtime/syntax/rsc.vim:

> @@ -0,0 +1,82 @@
+" Vim syntax file
+" Language:        RouterOS scripts
+" Maintainer:      zainin
+" Original Author: ndbjorne @ MikroTik forums
+" Last Change:     2017-07-26
+
+" quit when a syntax file was already loaded
+if exists("b:current_syntax")
+  finish
+endif
+
+syn case ignore
+
+set iskeyword=A-Z,a-z

this needs to be :syn iskeyword

zainin

unread,
Nov 5, 2021, 6:44:47 PM11/5/21
to vim/vim, Push

@zainin pushed 1 commit.

  • 3332b73 rsc syntax: fix syntax and filetype detection


You are receiving this because you are subscribed to this thread.

View it on GitHub.

zainin

unread,
Nov 5, 2021, 6:45:18 PM11/5/21
to vim/vim, Subscribed

@zainin commented on this pull request.


In runtime/ftplugin/rsc.vim:

> @@ -0,0 +1,6 @@
+" Vim filetype plugin file
+" Language:     RouterOS scripts
+" Maintainer:   zainin
+" Last Change:  2017-07-26
+
+au BufRead,BufNewFile *.rsc set filetype=rsc

My bad, fixed.

zainin

unread,
Nov 5, 2021, 6:46:22 PM11/5/21
to vim/vim, Subscribed

@zainin commented on this pull request.


In runtime/syntax/rsc.vim:

> @@ -0,0 +1,82 @@
+" Vim syntax file
+" Language:        RouterOS scripts
+" Maintainer:      zainin
+" Original Author: ndbjorne @ MikroTik forums
+" Last Change:     2017-07-26
+
+" quit when a syntax file was already loaded
+if exists("b:current_syntax")
+  finish
+endif
+
+syn case ignore
+
+set iskeyword=A-Z,a-z

Turns out it wasn't really necessary, so I've removed this line.

zainin

unread,
Nov 6, 2021, 7:03:35 AM11/6/21
to vim/vim, Subscribed

@zainin commented on this pull request.


In src/testdir/test_filetype.vim:

> @@ -422,6 +422,7 @@ let s:filename_checks = {
     \ 'robots': ['robots.txt'],
     \ 'rpcgen': ['file.x'],
     \ 'rpl': ['file.rpl'],
+    \ 'rsc': ['file.rsc'],

@dkearns , it's already here, or am I missing something?

Doug Kearns

unread,
Nov 6, 2021, 7:25:29 AM11/6/21
to vim/vim, Subscribed

@dkearns commented on this pull request.


In src/testdir/test_filetype.vim:

> @@ -422,6 +422,7 @@ let s:filename_checks = {
     \ 'robots': ['robots.txt'],
     \ 'rpcgen': ['file.x'],
     \ 'rpl': ['file.rpl'],
+    \ 'rsc': ['file.rsc'],

Nope, it's there alright. I assumed it would be in the second commit and didn't even check the first.

Sorry for wasting your time.

Doug Kearns

unread,
Nov 6, 2021, 10:39:57 AM11/6/21
to vim/vim, Subscribed

@dkearns commented on this pull request.


In runtime/syntax/rsc.vim:

> @@ -0,0 +1,82 @@
+" Vim syntax file
+" Language:        RouterOS scripts
+" Maintainer:      zainin
+" Original Author: ndbjorne @ MikroTik forums
+" Last Change:     2017-07-26
+
+" quit when a syntax file was already loaded
+if exists("b:current_syntax")
+  finish
+endif
+
+syn case ignore
+
+set iskeyword=A-Z,a-z

There's a few hyphenated keywords like as-value that are being missed because 'iskeyword' doesn't include -. If you don't want to use syn-iskeyword you could make them a syn-match.

Doug Kearns

unread,
Nov 6, 2021, 10:48:38 AM11/6/21
to vim/vim, Subscribed

Thanks for adding this filetype.

It looks like you're missing the return command and boolean true/false.

You could also consider using the #!rsc by RouterOS\n shebang line for filetype detection. That would go in runtime/scripts.vim.

zainin

unread,
Nov 6, 2021, 11:57:05 AM11/6/21
to vim/vim, Push

@zainin pushed 1 commit.

  • 23e0fa7 rsc syntax: fix keywords, improve file detection


You are receiving this because you are subscribed to this thread.

View it on GitHub.

zainin

unread,
Nov 6, 2021, 11:57:25 AM11/6/21
to vim/vim, Subscribed

@zainin commented on this pull request.


In runtime/syntax/rsc.vim:

> @@ -0,0 +1,82 @@
+" Vim syntax file
+" Language:        RouterOS scripts
+" Maintainer:      zainin
+" Original Author: ndbjorne @ MikroTik forums
+" Last Change:     2017-07-26
+
+" quit when a syntax file was already loaded
+if exists("b:current_syntax")
+  finish
+endif
+
+syn case ignore
+
+set iskeyword=A-Z,a-z

Sorry, I didn't notice - isn't included by default. It should be better now.

zainin

unread,
Nov 6, 2021, 11:58:06 AM11/6/21
to vim/vim, Subscribed

@dkearns , I added the missing keywords.

For the detection I added a regex as well since RouterOS adds a line like this during config export:
# nov/05/2021 22:01:24 by RouterOS 6.41.3

codecov[bot]

unread,
Nov 7, 2021, 5:56:45 AM11/7/21
to vim/vim, Subscribed

Codecov Report

Merging #9097 (23e0fa7) into master (15d9890) will decrease coverage by 87.68%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@

##           master    #9097       +/-   ##

===========================================

- Coverage   90.13%    2.45%   -87.69%     

===========================================

  Files         151      149        -2     

  Lines      169289   166371     -2918     

===========================================

- Hits       152594     4089   -148505     

- Misses      16695   162282   +145587     
Flag Coverage Δ
huge-clang-none ?
huge-gcc-none ?
huge-gcc-testgui ?
huge-gcc-unittests 2.45% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/float.c 0.00% <0.00%> (-99.22%) ⬇️
src/gui_gtk_f.c 0.00% <0.00%> (-97.43%) ⬇️
src/crypt_zip.c 0.00% <0.00%> (-97.06%) ⬇️
src/cmdhist.c 0.00% <0.00%> (-97.03%) ⬇️
src/sha256.c 0.00% <0.00%> (-96.94%) ⬇️
src/evalbuffer.c 0.00% <0.00%> (-96.88%) ⬇️
src/textprop.c 0.00% <0.00%> (-96.84%) ⬇️
src/match.c 0.00% <0.00%> (-96.76%) ⬇️
src/libvterm/src/rect.h 0.00% <0.00%> (-96.56%) ⬇️
src/evalfunc.c 0.00% <0.00%> (-96.51%) ⬇️
... and 137 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 15d9890...23e0fa7. Read the comment docs.

Christian Brabandt

unread,
Nov 8, 2021, 7:43:23 AM11/8/21
to vim/vim, Subscribed

please also update .github/CODEOWNERS

zainin

unread,
Nov 8, 2021, 11:53:09 AM11/8/21
to vim/vim, Push

@zainin pushed 1 commit.

  • ca164ce update CODEOWNERS for rsc.vim


You are receiving this because you are subscribed to this thread.

View it on GitHub.

zainin

unread,
Nov 8, 2021, 11:53:29 AM11/8/21
to vim/vim, Subscribed

@chrisbra , sure, done.

Doug Kearns

unread,
Nov 12, 2021, 4:46:11 AM11/12/21
to vim/vim, Subscribed

Would this filetype be better named as routeros? As far as I can tell it's mostly known as RouterOS Script or sometimes MikroTik Script.

Doug Kearns

unread,
Nov 12, 2021, 6:48:11 AM11/12/21
to vim/vim, Subscribed

@dkearns commented on this pull request.


In runtime/syntax/rsc.vim:

> @@ -11,6 +11,8 @@ endif
 
 syn case ignore
 
+syn iskeyword @,-

You've missed digits used in, for example, toip6. So at a minimum I think you'll need:

syn iskeyword @,48-57,-

zainin

unread,
Nov 12, 2021, 11:53:43 AM11/12/21
to vim/vim, Push

@zainin pushed 1 commit.

  • fb5a8ef rsc syntax: match keywords with digits


You are receiving this because you are subscribed to this thread.

View it on GitHub.

zainin

unread,
Nov 12, 2021, 11:54:12 AM11/12/21
to vim/vim, Subscribed

@zainin commented on this pull request.


In runtime/syntax/rsc.vim:

> @@ -11,6 +11,8 @@ endif
 
 syn case ignore
 
+syn iskeyword @,-

You're right, fixed.

zainin

unread,
Nov 12, 2021, 12:08:47 PM11/12/21
to vim/vim, Subscribed

Would this filetype be better named as routeros?

Makes sense, I didn't actually realize it's named like this in other editors.

I think we can change this after we take care of the other PR you sent me to avoid conflicts.

Bram Moolenaar

unread,
Nov 13, 2021, 5:40:05 AM11/13/21
to vim/vim, Subscribed

If we are going to use "routeros" we better do this right away, no point in first adding rsc and then renaming.

Doug Kearns

unread,
Nov 13, 2021, 5:51:02 AM11/13/21
to vim/vim, Subscribed

Yes, we're just working on a couple of changes in zainin's fork under the old name then it'll be updated to the new name before it's offered for merging here.

zainin

unread,
Nov 15, 2021, 12:17:22 PM11/15/21
to vim/vim, Push

@zainin pushed 8 commits.

  • e9209f6 Add escape sequence highlighting
  • 9eb332b Add and/or/in operator highlighting
  • b7035ef Add new rsc filetype plugin
  • cd0339a Exclude leading whitespace from comment highlighting
  • 193baed Remove rscSpecial delimiter highlighting from strings
  • 584d729 Highlight the line continuation character
  • cda2ae6 Rename rsc filetype to routeros
  • 58105d2 Merge pull request #1 from dkearns/improve-rsc-syntax-highlighting


You are receiving this because you are subscribed to this thread.

View it on GitHub.

zainin

unread,
Nov 15, 2021, 12:19:48 PM11/15/21
to vim/vim, Push

@zainin pushed 1 commit.

  • b6e5a52 add routerous maintainer contact


You are receiving this because you are subscribed to this thread.

View it on GitHub.

zainin

unread,
Nov 15, 2021, 12:21:41 PM11/15/21
to vim/vim, Subscribed

I think we're done for now, let me know if there's anything else to tweak.


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub.

Bram Moolenaar

unread,
Nov 15, 2021, 4:43:46 PM11/15/21
to vim/vim, Subscribed

Thanks, I'll include it. The filetype detection will be a patch, the rest will come with the next runtime file update.

Bram Moolenaar

unread,
Nov 15, 2021, 4:44:58 PM11/15/21
to vim/vim, Subscribed

Closed #9097 via 0818ab8.

Reply all
Reply to author
Forward
0 new messages