简体   繁体   English

Syntastic NASM检查器

[英]Syntastic NASM Checker

So I've been doing some work in my Assembly class for college, and I use Vim as my primary code editor. 所以我在大学课堂上做了一些工作,我使用Vim作为我的主要代码编辑器。 I'm having a problem with Syntastic where I'm writing assembly for NASM, but Syntastic only wants to run the gcc error checker (which tells me all my code is wrong). 我在使用Syntastic时出现问题,我正在为NASM编写程序集,但Syntastic只想运行gcc错误检查程序(它告诉我所有代码都错误)。 I tried to run the NASM checker explicitly with SyntasticCheck nasm but that didn't seem to work. 我尝试使用SyntasticCheck nasm明确地运行NASM检查程序, SyntasticCheck nasm似乎不起作用。 I also attempted to let g:syntastic_asm_checkers = ['nasm'] in my .vimrc but that didn't seem to do anything. 我还尝试在我的.vimrc中let g:syntastic_asm_checkers = ['nasm'] ,但似乎没有做任何事情。 How can I get Syntastic to run the NASM checker here? 如何让Syntastic在这里运行NASM检查器?

As a note, I tested this by just writing something like mov eax, to get an error out of NASM. 作为一个注释,我通过编写类似mov eax,类的东西来测试它mov eax,以便从NASM中获取错误。

You need to either 你需要

  • force the association between .asm with nasm. 强制.asm与nasm之间的关联。 Just add this anywhere in your .vimrc 只需在.vimrc中的任何位置添加它即可

     autocmd BufNewFile,BufRead *.asm set filetype=nasm 
  • use the .nasm extension. 使用.nasm扩展名。 Then everything will just work. 一切都会好起来的。

I edited the file nasm.vim in ~/.vim/bundle/syntastic/syntax_checkers/nasm to work for asm and saved the edited file in ~/.vim/bundle/syntastic/syntax_checkers/asm with the same name nasm.vim . 我在~/.vim/bundle/syntastic/syntax_checkers/nasm编辑了nasm.vim文件,用于asm,并将编辑后的文件保存在~/.vim/bundle/syntastic/syntax_checkers/asm ,名称为nasm.vim Doing so, you can put let g:syntastic_asm_checkers = ['nasm'] into your .vimrc configuration and it works just fine :) 这样做,你可以把let g:syntastic_asm_checkers = ['nasm']放到你的.vimrc配置中,它运行得很好:)

You can find the edited file as well as some details on https://srv2.mysnet.me/casm/tutorial/vim-configuration . 您可以在https://srv2.mysnet.me/casm/tutorial/vim-configuration上找到已编辑的文件以及一些详细信息。

Well, I know that it has been a few years old question, but it'll help others at east, I hope. 嗯,我知道它已经有几年的问题了,但是我希望它会帮助东方的其他人。 (at least I was looking for an answer myself until I figured out tweaking the files might work out thanks to @netskink :D) (至少我自己一直在寻找答案,直到我发现调整文件可能会有效,这要归功于@netskink:D)

As mentioned in the comments above, it turns out nasm only works for files with a nasm file extension. 正如上面的评论中所提到的,结果是nasm仅适用于具有nasm文件扩展名的文件。 After renaming my file to <file>.nasm I discovered that vim doesn't automatically detect the nasm filetype after running set ft? 将我的文件重命名为<file>.nasm我发现vim在运行set ft?后没有自动检测到nasm文件类型set ft? , so I'll have to modify my .vimrc to support the extension. ,所以我将不得不修改我的.vimrc以支持扩展。

For what its worth, I tried to dork with the files: 为了它的价值,我试图用文件dork:

plugins/syntastic/registry.vim
syntax_checkers/nasm/nasm.vim
syntax_checkers/asm/gcc.vim

To disable .asm syntax and replace it with nasm syntax but it did not work. 要禁用.asm语法并将其替换为nasm语法,但它不起作用。 I could the errors to go away but I could not get the snytax coloring or checker to work automatically. 我可以将错误消失,但我无法让snytax着色或检查器自动工作。 I reverted my changes and just do this instead: 我恢复了我的更改而只是这样做:

:SyntasticCheck nasm
:set filetype=nasm
:SyntasticCheck nasm

After the second syntasticcheck command, it will have syntax coloring and nasm syntax checking enabled. 在第二个syntasticcheck命令之后,它将启用语法着色和nasm语法检查。 Not sure why it takes two passes. 不知道为什么需要两次传球。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM