文件未从 vim 插件中获取 loaded/run
Files not getting loaded/run from in vim plugin
我正在为一种名为 statemachine
的新(玩具)语言开发一个 vim 插件,作为一个更大项目的一部分。
我正在尝试为这种文件类型加载一个有效的 compiler/makeprg,并且我在 compiler/statemachine.vim
中定义了一个
但是,当我尝试 运行 :make
或 set makeprg?
时,我分别得到 make
和 makeprg=
。我也看不到我在 compiler/statemachine.vim
中定义的 echom
s。所以我在文件 compiler/statemachine.vim
中的代码似乎没有执行。
具体来说,我正在尝试将其注册为 Syntastic 作为有效的语法检查器,并且先决条件是将 makeprg
和 errorformat
设置为有效值。
我可以使用我设置的 equalprg
,并且可以从 syntax_checkers/statemachine/statemachine.vim
中看到 echom
,所以我知道我的插件正在 运行一些能力。
并且正确检测到文件类型:set filetype?
产生 filetype=statemachine
到目前为止插件的目录布局:
.
├── 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
vim插件代码的相关部分:
// 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'})
完整的 vim 插件可以在这里找到:https://github.com/scottopell/vim-statemachine
感谢 Sato Katsura 和 FDinoff 在我原来问题的评论中,我只需要在某处添加 compiler statemachine
。我选择添加到ftplugin
.
我正在为一种名为 statemachine
的新(玩具)语言开发一个 vim 插件,作为一个更大项目的一部分。
我正在尝试为这种文件类型加载一个有效的 compiler/makeprg,并且我在 compiler/statemachine.vim
但是,当我尝试 运行 :make
或 set makeprg?
时,我分别得到 make
和 makeprg=
。我也看不到我在 compiler/statemachine.vim
中定义的 echom
s。所以我在文件 compiler/statemachine.vim
中的代码似乎没有执行。
具体来说,我正在尝试将其注册为 Syntastic 作为有效的语法检查器,并且先决条件是将 makeprg
和 errorformat
设置为有效值。
我可以使用我设置的 equalprg
,并且可以从 syntax_checkers/statemachine/statemachine.vim
中看到 echom
,所以我知道我的插件正在 运行一些能力。
并且正确检测到文件类型:set filetype?
产生 filetype=statemachine
到目前为止插件的目录布局:
.
├── 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
vim插件代码的相关部分:
// 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'})
完整的 vim 插件可以在这里找到:https://github.com/scottopell/vim-statemachine
感谢 Sato Katsura 和 FDinoff 在我原来问题的评论中,我只需要在某处添加 compiler statemachine
。我选择添加到ftplugin
.