On 2020-06-02, Colin Caine wrote:
> Thanks for the link to that code, Gary. Unfortunately, it has very little
> ability to detect which asm syntax is being used:
> 
> func dist#ft#FTasmsyntax()
>   " see if file contains any asmsyntax=foo overrides. If so, change
>   " b:asmsyntax appropriately
>   let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4).
>         \" ".getline(5)." "
>   let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s')
>   if match != ''
>     let b:asmsyntax = match
>   elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? 
> '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library'))
>     let b:asmsyntax = "vmasm"
>   endif
> endfunc
> 
> And the default is asm, which is the only one where we would not want these
> changes...
> 
> If the default was instead unknown asm or something, then we could probably do
> something with that, but that sounds quite breaking. Another option would be 
> to
> set the comments and commentstring values in ft.vim (where we know if we're
> selecting asm as the default or if we're sure), but I think in practice that
> would make very little difference to doing as I have done in this patch
> (because the default is selected basically every time).

There are a number of functions in ft.vim that deal with assembly
files.  In addition to dist#ft#FTasmsyntax there are also
dist#ft#FTasm() and dist#ft#FTprogress_asm().  The last one looks
in the first ten lines for lines beginning with a semicolon.

I was thinking of something like the following for ftplugin/asm.vim.

    if exists("b:did_ftplugin")
      finish
    endif
    let b:did_ftplugin = 1

    let b:undo_ftplugin = "setlocal comments< commentstring<"

    setlocal comments+=:;

    call cursor(1, 1)
    if search('^\s*;', 'cn', 10)
      setlocal commentstring=;%s
    endif

That will always include ; in 'comments', which I didn't think would
hurt anything, but changes 'commentstring' only if a semicolon is
the first non-space character in any of the first ten lines of the
buffer.

Regards,
Gary

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20200603033327.GH10889%40phoenix.

Raspunde prin e-mail lui