Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Attempt to detect CM files in SML/NJ checker #1719

Closed
wants to merge 1 commit into from

Conversation

jez
Copy link

@jez jez commented Mar 7, 2016

When editing SML/NJ files inside projects that use Compilation Manager for build
management, Syntastic displays errors incorrectly because it makes no attempt to
look for these *.cm files.

This pull request lets the smlnj checker find the CM file and appropriately
configure the makeprg when these one of these files is present.

Let me know if this is a feature you'd like or not like to include in Syntastic.
I'm open to suggestions. I wrote a bit of documentation in the file itself; I'm
not sure if we'd need to update any documentation elsewhere if this were to be
merged.

Recurses up directory tree until we've found a CM file, or falls back to
the current file if one doesn't exist.
@lcd047
Copy link
Collaborator

lcd047 commented Mar 7, 2016

Actually, you can achieve the same thing without changes to the code. Something like this:

function! s:DetectCM(fname) abort
    let cm = syntastic#util#findGlobInParent('*.cm', fnamemodify(a:fname, ':p:h'))
    if cm !=# ''
        let buf = bufnr(fnameescape(a:fname))
        call setbufvar(buf, 'syntastic_sml_smlnj_args', '-m ' . syntastic#util#shescape(cm))
        call setbufvar(buf, 'syntastic_sml_smlnj_fname', '')
    endif
endfunction

autocmd FileType sml     call s:DetectCM(expand('<amatch>', 1))

Or perhaps put the relevant piece of code in a ftplugin. Either way, it's the kind of manipulation that doesn't make sense for everybody, and thus it's better kept out of syntastic. Sorry, but no.

@lcd047 lcd047 closed this Mar 7, 2016
@jez
Copy link
Author

jez commented Mar 9, 2016

Thanks for the tip! I had no idea that findGlobInParent was already a function; that certainly makes it simpler.

For those who end up finding this issue from a search: I've made this into a plugin (with a few other goodies for SML in general): jez/vim-better-sml.

@lcd047 Out of curiosity, is the existence of syntastic#util documented anywhere? I checked over the wiki documentation on writing a checker but didn't see any mention there.

Thanks again for the snappy response!

@lcd047
Copy link
Collaborator

lcd047 commented Mar 9, 2016

I've made this into a plugin

I sent you a PR.

If you add initialisation to your plugin you'll also need to make sure syntastic is loaded before the rest of the code gets to run. This is not a problem for a ftplugin though, at least not until somebody tries to get smart and thinks to use the new :packadd command to delay loading syntastic until it's actually needed.

Out of curiosity, is the existence of syntastic#util documented anywhere?

It depends on what you mean by that. :h autoload will explain the basics. Beyond that, well, nobody took up the task of documenting the util functions, and the API is still subject to change; some people still seem to have high hopes that syntastic will be able to do async checks some day.

@jez
Copy link
Author

jez commented Mar 9, 2016

If you add initialisation to your plugin you'll also need to make sure syntastic is loaded before the rest of the code gets to run.

I thought about that; I'll probably deal with it if it ever becomes an issue.

It depends on what you mean by that.

I was more referring to which functions were available in util. If the API is still subject to change, it's understandable that it's undocumented. I guess I'll just keep this in mind if my plugin breaks after an update 😛

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants