neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

mojo.vim (1371B)


      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 
      7 if exists('b:did_ftplugin')
      8  finish
      9 endif
     10 let b:did_ftplugin = 1
     11 
     12 let s:cpo_save = &cpo
     13 set cpo&vim
     14 
     15 setlocal include=^\\s*\\(from\\\|import\\)
     16 setlocal define=^\\s*\\(\\(async\\s\\+\\)\\?def\\\|class\\)
     17 
     18 " For imports with leading .., append / and replace additional .s with ../
     19 let b:grandparent_match = '^\(.\.\)\(\.*\)'
     20 let b:grandparent_sub = '\=submatch(1)."/".repeat("../",strlen(submatch(2)))'
     21 
     22 " For imports with a single leading ., replace it with ./
     23 let b:parent_match = '^\.\(\.\)\@!'
     24 let b:parent_sub = './'
     25 
     26 " Replace any . sandwiched between word characters with /
     27 let b:child_match = '\(\w\)\.\(\w\)'
     28 let b:child_sub = '\1/\2'
     29 
     30 setlocal 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 
     36 setlocal suffixesadd=.mojo
     37 setlocal comments=b:#,fb:-
     38 setlocal commentstring=#\ %s
     39 
     40 let b:undo_ftplugin = 'setlocal include<'
     41      \ . '|setlocal define<'
     42      \ . '|setlocal includeexpr<'
     43      \ . '|setlocal suffixesadd<'
     44      \ . '|setlocal comments<'
     45      \ . '|setlocal commentstring<'
     46 
     47 let &cpo = s:cpo_save
     48 unlet s:cpo_save