HealsCodes / vim-gas

Advanced syntax highlighting for GNU As
BSD 3-Clause "New" or "Revised" License
143 stars 21 forks source link

Lone comment not matched #5

Closed justinjhendrick closed 8 years ago

justinjhendrick commented 8 years ago

When a comment does not have code preceding it, it is not highlighted.

The problem is fixed when I comment out this line: https://github.com/Shirk/vim-gas/blob/master/syntax/gas.vim#L2021

Below is an example program that gcc compiles just fine, but the comment beneath the "Hello, world!" string is not highlighted by gas.

  .globl  main
  .type  main, @function
.LC0:
  .string "Hello,\0 world!\n"
  # include \0 as a reminder that strings ending in \0 is a C thing.
  .text
main:
.LFB0:
  .cfi_startproc
  pushq  %rbp
  .cfi_def_cfa_offset 16
  .cfi_offset 6, -16
  movq  %rsp, %rbp
  .cfi_def_cfa_register 6
  movq $1, %rdi # write to stdout
  movq $.LC0, %rsi # ptr to string
  movq $15, %rdx # length of string
  movq $1, %rax # value for syscall
  syscall # sys_write(unsigned int fd, const char* buf, size_t count)
  popq  %rbp
  .cfi_def_cfa 7, 8
  ret
  .cfi_endproc
.LFE0:
  .size  main, .-main
  .ident  "GCC: (GNU) 4.7.4 20140401 for GNAT GPL gpl-2014 (20140405)"
  .section  .note.GNU-stack,"",@progbits
HealsCodes commented 8 years ago

Yes, I can see the problem here.. (and it applies only to a very specific set of comments :wink:):

Your sample comment starts with #include which also happens to be a valid GCC preprocessor directive and thus is not highlighted as a comment (try adding any letter before the first 'i' and the highlight returns to comment-mode).

GAS supports preprocessing files by GCCs preprocessor and gas.vim knows about this and applies special highlighting to the directives #include, #if, #else, #endif and #define.

I don't think removing line 2021 and thus the preprocessor highlighting is the right way to go. However I could provide an option to explicitly disable preprocessor detection (something like let g:gasDisablePreproc=1).

justinjhendrick commented 8 years ago

Ah, it's only starting with include, haha

I wasn't suggesting removing 2021, just letting you know where the clash was occurring. That setting sounds like a reasonable solution. Thanks!