robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
34b4df774d
master
1" Vim filetype plugin 2" Language: Mojo 3" Maintainer: Riley Bruins <ribru17@gmail.com> 4" Last Change: 2024 Jul 07 5" 2025 Apr 16 by Vim Project (set 'cpoptions' for line continuation, #17121) 6 7if exists ( 'b:did_ftplugin' ) 8finish 9endif 10let b: did_ftplugin = 1 11 12let s: cpo_save = & cpo 13set cpo & vim 14 15setlocal include = ^\\s*\\(from\\\|import\\) 16setlocal define = ^\\s*\\(\\(async\\s\\+\\)\\?def\\\|class\\) 17 18" For imports with leading .., append / and replace additional .s with ../ 19let b: grandparent_match = '^\(.\.\)\(\.*\)' 20let b: grandparent_sub = '\=submatch(1)."/".repeat("../",strlen(submatch(2)))' 21 22" For imports with a single leading ., replace it with ./ 23let b: parent_match = '^\.\(\.\)\@!' 24let b: parent_sub = './' 25 26" Replace any . sandwiched between word characters with / 27let b: child_match = '\(\w\)\.\(\w\)' 28let b: child_sub = '\1/\2' 29 30setlocal includeexpr = substitute (substitute(substitute( 31 \v:fname, 32 \b: grandparent_match,b: grandparent_sub,''), 33 \b: parent_match,b: parent_sub,''), 34 \b: child_match,b: child_sub,'g') 35 36setlocal suffixesadd = .mojo 37setlocal comments = b:#,fb:- 38setlocal commentstring = #\ %s 39 40let b: undo_ftplugin = 'setlocal include<' 41 \. '|setlocal define<' 42 \. '|setlocal includeexpr<' 43 \. '|setlocal suffixesadd<' 44 \. '|setlocal comments<' 45 \. '|setlocal commentstring<' 46 47let & cpo = s: cpo_save 48unlet s: cpo_save