7

So I've been doing some work in my Assembly class for college, and I use Vim as my primary code editor. 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). I tried to run the NASM checker explicitly with SyntasticCheck nasm but that didn't seem to work. I also attempted to let g:syntastic_asm_checkers = ['nasm'] in my .vimrc but that didn't seem to do anything. How can I get Syntastic to run the NASM checker here?

As a note, I tested this by just writing something like mov eax, to get an error out of NASM.

emanguy
  • 71
  • 4
  • `:set ft?` what it shows? – Jason Hu Sep 25 '15 at 01:03
  • 2
    Did you look at the [list of checkers](https://github.com/scrooloose/syntastic/wiki/Syntax-Checkers#user-content-nasm)? `nasm` is a checker for filetype `nasm`, not `asm`. – Sato Katsura Sep 25 '15 at 05:32
  • @HuStmpHrrr : Vim shows that it wasn't detecting the filetype when I was entering your command. I did some more research and apparently it's a known problem that Vim doesn't detect the .nasm filetype as detailed [here](http://ubuntuforums.org/showthread.php?t=697049). Everything worked again after I ```set filetype=nasm```. Thanks! @SatoKatsura : You were right, nasm is a checker for filetype nasm. For some reason I was under the impression that I could still run it anyway. I'll have to look more into getting vim to recognize the nasm filetype... – emanguy Sep 25 '15 at 15:39

4 Answers4

4

You need to either

  • force the association between .asm with nasm. Just add this anywhere in your .vimrc

    autocmd BufNewFile,BufRead *.asm set filetype=nasm
    
  • use the .nasm extension. Then everything will just work.

Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
Jack Evans
  • 43
  • 3
  • 3
    Could you please [edit] in an explanation of why this code answers the question? Code-only answers are [discouraged](https://meta.stackexchange.com/q/148272), because they don't teach the solution. – Nathan Tuggy Apr 25 '17 at 02:00
0

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. Doing so, you can put let g:syntastic_asm_checkers = ['nasm'] into your .vimrc configuration and it works just fine :)

You can find the edited file as well as some details on 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)

-1

As mentioned in the comments above, it turns out nasm only works for files with a nasm file extension. After renaming my file to <file>.nasm I discovered that vim doesn't automatically detect the nasm filetype after running set ft?, so I'll have to modify my .vimrc to support the extension.

emanguy
  • 71
  • 4
  • you can type `:autocmd BufRead` and `:autocmd BufEnter` and find filetypedetect section to check if your vim implementation recognize the file extension or it is a real bug. – Jason Hu Sep 25 '15 at 18:10
-1

For what its worth, I tried to dork with the files:

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. I could the errors to go away but I could not get the snytax coloring or checker to work automatically. 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. Not sure why it takes two passes.

netskink
  • 4,033
  • 2
  • 34
  • 46