0

I'm developing a vim plugin for a new (toy) language called statemachine as part of a bigger project.

I'm trying to get a valid compiler/makeprg loaded in for this file type and I have one defined in compiler/statemachine.vim

However, when I try to run :make or set makeprg? I get make and makeprg= respectively. I also cannot see echoms that I have defined inside compiler/statemachine.vim. So it seems that my code in the file compiler/statemachine.vim is not executing.

Specifically I'm attempting to get this registered with Syntastic as a valid syntax checker, and a pre-requisite for that is getting makeprg and errorformat set to valid values.

I am able to use an equalprg that I have set and can see echoms from syntax_checkers/statemachine/statemachine.vim, so I know that my plugin is being run in some capacity.

And the filetype is detected correctly: set filetype? yields filetype=statemachine

Directory layout of the plugin so far:

.
├── README.md
├── autoload
│   └── statemachine.vim
├── compiler
│   └── statemachine.vim
├── complete.sh
├── example.sm
├── formatter.sh
├── ftdetect
│   └── statemachine.vim
├── ftplugin
│   └── statemachine.vim
├── syntax
│   └── statemachine.vim
├── syntax_checkers
│   └── statemachine
│       └── statemachine.vim
├── test.txt
└── validator.sh

Relevant parts of the vim plugin code:

// autoload/statemachine.vim
function! statemachine#Errorformat()
    return '%f:%l:\ %m'
endfunction

//ftdetect/statemachine.vim
au BufNewFile,BufRead *.sm set filetype=statemachine

// syntax_checkers/statemachine/statemachine.vim
function! SyntaxCheckers_statemachine_statemachine_GetLocList() dict
    let l:makeprg = self.makeprgBuild({'args': ''})
    echom 'inside getloclist'
    return SyntasticMake({'makeprg': l:makeprg,
                        \ 'errorformat': statemachine#errorformat() })
endfunction

call g:SyntasticRegistry.CreateAndRegisterChecker({'filetype': 'statemachine',
                                                \'name': 'statemachine'})

The full vim plugin can be found here: https://github.com/scottopell/vim-statemachine

5
  • Why do you expect compiler/statemachine.vim to be sourced automatically? On an unrelated side note: you don't need to escape the space in errorformat. Commented Oct 8, 2015 at 18:58
  • @SatoKatsura Is that not how it works? I see this pattern referenced in multiple other plugins online and none of them manually call compiler/<filetype>.vim, so I assumed it was automatic similar to syntax/<filetype>.vim etc. Commented Oct 8, 2015 at 20:23
  • You probably need to call compiler statemachine somewhere. Commented Oct 8, 2015 at 21:17
  • As @FDinoff points out, you probably need to add compiler statemachine to your ftplugin. Commented Oct 8, 2015 at 21:36
  • thanks, that did it. If one of you puts that as an answer I can accept it. Commented Oct 9, 2015 at 18:13

1 Answer 1

0

Thanks to Sato Katsura and FDinoff in the comments of my original question, I simply needed to add compiler statemachine somewhere. I chose to add it in ftplugin.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.