[vim/vim] Odin lang filetype/syntax/indent plugin (PR #13867)

71 views
Skip to first unread message

Maxim Kim

unread,
Jan 14, 2024, 7:30:47 PM1/14/24
to vim/vim, Subscribed

Vim has Odin filetype detection but misses actual Odin filetype, syntax and indent.

Repo: https://github.com/habamax/vim-odin

image.png (view on web)

image.png (view on web)


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

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

Commit Summary

File Changes

(3 files)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867@github.com>

Maxim Kim

unread,
Jan 14, 2024, 7:55:08 PM1/14/24
to vim/vim, Push

@habamax pushed 1 commit.

  • f8499d4 fix long /* multiline comments */


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867/push/16636150531@github.com>

Maxim Kim

unread,
Jan 14, 2024, 8:07:54 PM1/14/24
to vim/vim, Push

@habamax pushed 1 commit.

  • a15823c support nested block comments


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867/push/16636241613@github.com>

dkearns

unread,
Jan 14, 2024, 11:00:53 PM1/14/24
to vim/vim, Subscribed

@dkearns requested changes on this pull request.

Thanks, I was just watching an interview with the ginger one.

You're probably aware but Vim9-script runtime files won't be picked up by Neovim.


In runtime/ftplugin/odin.vim:

> @@ -0,0 +1,18 @@
+vim9script
+
+# Vim filetype plugin file
+# Language: odin

s/odin/Odin/


In runtime/ftplugin/odin.vim:

> +# Vim filetype plugin file
+# Language: odin
+# Maintainer: Maxim Kim <hab...@gmail.com>
+# Website: https://github.com/habamax/vim-odin
+# Last Change: 2024-01-15
+
+if exists("b:did_ftplugin")
+    finish
+endif
+b:did_ftplugin = 1
+
+b:undo_ftplugin = 'setlocal commentstring<'
+      \ .. '| setlocal suffixesadd<'
+
+setlocal suffixesadd=.odin
+setlocal commentstring=//%s

Could we also set comments for formatting commands?


In runtime/syntax/odin.vim:

> +syntax match odinInteger "\-\?\<\d\+\>" display
+syntax match odinFloat "\-\?\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\%([eE][+-]\=[0-9_]\+\)\=" display
+syntax match odinHex "\<0[xX][0-9A-Fa-f]\+\>" display
+syntax match odinDoz "\<0[zZ][0-9a-bA-B]\+\>" display
+syntax match odinOct "\<0[oO][0-7]\+\>" display
+syntax match odinBin "\<0[bB][01]\+\>" display
+
+syntax match odinAddressOf "&" display
+syntax match odinDeref "\^" display
+
+syntax match odinMacro "#\<\w\+\>" display
+
+syntax match odinTemplate "$\<\w\+\>"
+
+syntax region odinLineComment start=/\/\// end=/$/  contains=@Spell,odinTodo
+syntax region odinBlockComment start=/\v\/\*/ end=/\v\*\// contains=@Spell,odinTodo,odinBlockComment

The \v modifier isn't doing any work here.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867/review/1820702028@github.com>

Maxim Kim

unread,
Jan 14, 2024, 11:38:21 PM1/14/24
to vim/vim, Push

@habamax pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867/push/16637763011@github.com>

Maxim Kim

unread,
Jan 14, 2024, 11:44:19 PM1/14/24
to vim/vim, Subscribed

Thanks, I was just watching an interview with the ginger one.

Indeed language looks promising.

You're probably aware but Vim9-script runtime files won't be picked up by Neovim. They're not rewriting them in legacy script.

I think they can update it to legacy vimscript if needed? It shouldn't be too difficult, it is GetOdinIndent() function and a bit of script variable assignments here and there.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867/c1891293842@github.com>

Maxim Kim

unread,
Jan 15, 2024, 1:16:21 AM1/15/24
to vim/vim, Subscribed

found an issue with the last commit (wrt indentation), investigating.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867/c1891368349@github.com>

Maxim Kim

unread,
Jan 15, 2024, 1:58:03 AM1/15/24
to vim/vim, Subscribed

while cindent does almost what I think Odin needs, on edge cases it fails miserably. Let me convert this to draft for now, I will need to re-implement indentation algorithm from scratch.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867/c1891426407@github.com>

Maxim Kim

unread,
Jan 15, 2024, 3:40:20 AM1/15/24
to vim/vim, Push

@habamax pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867/push/16640077812@github.com>

Maxim Kim

unread,
Jan 15, 2024, 3:41:20 AM1/15/24
to vim/vim, Subscribed

Indentation looks ok so far -- tested it on demo.odin bundled with the language.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867/c1891572010@github.com>

Maxim Kim

unread,
Jan 15, 2024, 4:21:18 AM1/15/24
to vim/vim, Push

@habamax pushed 1 commit.

  • 223c743 fix additional indent edge cases


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867/push/16640625662@github.com>

Christian Clason

unread,
Jan 15, 2024, 5:48:20 AM1/15/24
to vim/vim, Subscribed

I think they can update it to legacy vimscript if needed? It shouldn't be too difficult, it is GetOdinIndent() function and a bit of script variable assignments here and there.

I won't, for the record; I'll just include the syntax file (and possibly the ftplugin; that indeed looks fairly trivial to translate back). Non-trivial vim9script files will be skipped until we get automated transpiling working (which is looking unlikely soon). If someone were to contribute a manual translation that is close enough to the original so changes can be backported (again, manually) easily, that could also be accepted. (Nobody has, so far, so there's no official policy around that yet.)

(Not complaining, to be clear; just wanted to let you know what is what from our side since you do take it into consideration -- which I appreciate. No hard feelings whatever you do!)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867/c1891866961@github.com>

Maxim Kim

unread,
Jan 15, 2024, 5:48:57 AM1/15/24
to vim/vim, Push

@habamax pushed 1 commit.

  • 2156618 cover more indent edge cases


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867/push/16641902735@github.com>

Maxim Kim

unread,
Jan 15, 2024, 6:21:12 AM1/15/24
to vim/vim, Push

@habamax pushed 1 commit.


View it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867/push/16642345805@github.com>

Christian Brabandt

unread,
Jan 16, 2024, 11:34:15 AM1/16/24
to vim/vim, Subscribed

Thanks!


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867/c1894099581@github.com>

Christian Brabandt

unread,
Jan 16, 2024, 11:34:38 AM1/16/24
to vim/vim, Subscribed

Merged #13867 into master.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/13867/issue_event/11501263829@github.com>

Reply all
Reply to author
Forward
0 new messages