0

I'm having troubles using Syntastic with MobaXterm (which was based off of Cygwin). I already looked at this post: How to set up syntastic for vim?

I used Vundle to properly install Syntastic (I know because :SyntasticCheck doesn't return any errors).

Syntastic is supposedly supposed to work out of the box but it doesn't display anything for a simple broken .c file

Here is the relevant portion of my vimrc:

set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_enable_signs=1
let g:syntastic_check_on_wq = 0

It might be a path problem? Running :echo syntastic#util#system('echo "$PATH"') in vim gives /bin:/drives/c/Users/Justin/DOCUME~1/MobaXterm/slash/bin:/drives/c/WINDOWS:/drives/c/WINDOWS/system32

And the gcc executable is in /drives/c/Users/Justin/DOCUME~1/MobaXterm/slash/bin

Output of running :SyntasticInfo

Syntastic version: 3.8.0-55 (Vim 703, CYGWIN_NT-10.0-WOW)
Info for filetype: c
Global mode: active
Filetype c is active
The current file will be checked automatically
Available checkers: clang_check gcc make
Currently enabled checker: gcc

Running :mes afterwards returns the same output.

Test file with a missing semicolon syntax error:

int main(int argc, const char *argv[]) {
    asdf
    return 0;
}

Output after running :let g:syntastic_debug = 3 and :mes

"t.c" 4L, 66C
syntastic: 12.829662: g:syntastic_version = '3.8.0-55 (Vim 703, CYGWIN_NT-10.0-WOW)'
syntastic: 12.829837: &shell = '/bin/bash.exe', &shellcmdflag = '-c',     &shellpipe = '| tee', &shellquote = '', &shellredir = '>', &shelltemp = 1, &
shellxquote = '', &autochdir = 0, &shellxescape = ''
syntastic: 12.830506: UpdateErrors: default checkers
syntastic: 12.831086: CacheErrors: default checkers
syntastic: 12.832006: g:syntastic_aggregate_errors = 0
syntastic: 12.832240: getcwd() = '/home/mobaxterm'
syntastic: 12.832960: CacheErrors: Invoking checker: c/gcc
syntastic: 12.834858: SyntasticMake: called with options: {'postprocess': [], 'errorformat': '%-G%f:%s:,%-G%f:%l: %#error: %#(Each undeclared identifier is reported only%.%#,%-G%f:%l: %#error: %#for each function it appears%.%#,%-GIn file included%.%#,%-G %#from %f:%l\,,%f:%l:%c: %trror: %m, %f:%l:%c: %tarning: %m,%f:%l:%c: %m,%f:%l: %trror: %m,%f:%l: %tarning: %m,%f:%l: %m', 'makeprg': 'gcc -x c -fsyntax-only -std=gnu99 -I. -I.. -Iinclude -Iincludes -I../include -I../includes   t.c'}
syntastic: 12.930358: system: command run in 0.095090s
syntastic: 12.930519: checker output: ['']
syntastic: 12.930918: raw loclist: [{'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': ''}]
syntastic: 12.931157: getLocList: checker c/gcc returned 1
syntastic: 12.931302: c/gcc raw: [{'lnum': 0, 'bufnr': 0, 'col': 0, 'valid': 0, 'vcol': 0, 'nr': -1, 'type': '', 'pattern': '', 'text': ''}]
syntastic: 12.931547: quiet_messages filter: {}
syntastic: 12.931696: getLocList: checker c/gcc run in 0.098600s
syntastic: 12.932000: aggregated: {'_sorted': 0, '_name': '', '_owner':  1, '_columns': 1, '_rawLoclist': []}
Community
  • 1
  • 1
J-Win
  • 1,322
  • 16
  • 35
  • Please open your test file, run `:SyntasticInfo`, then run `:mes` and post the output. – lcd047 May 21 '17 at 15:40
  • The output of `:SyntasticInfo` looks fine. Please explain what doesn't work: what did you do, what did you expect to happen, and what happened instead. – lcd047 May 22 '17 at 05:15
  • I expected Syntastic to show "signs" indicating a syntax error at the line with the missing semicolon (or at least show some form of error). I ran `:SyntasticCheck` and saw nothing happen. Saving, re-opening the file, and running the check again also does not help – J-Win May 22 '17 at 16:15
  • 1
    Ok, please open your test file, set `g:syntastic_debug` to 3, run `:SyntasticCheck`, then run `:mes` and post the output. – lcd047 May 22 '17 at 17:01
  • Great! Now run in a terminal: `cd /home/mobaxterm`, then `gcc -x c -fsyntax-only -std=gnu99 -I. -I.. -Iinclude -Iincludes -I../include -I../includes t.c`. – lcd047 May 22 '17 at 19:34
  • 1
    Actually, never mind. Your shell-related flags don't make sense. Fix them so that `:echo syntastic#util#system('command')` produce output both when `command` writes to `stdout` and when it writes to `stderr`. – lcd047 May 22 '17 at 19:42
  • I honestly have no clue how to fix the shell-related flags. I ran the `echo` command you gave me and it didn't produce anything. – J-Win May 22 '17 at 20:39
  • 1
    Copying the values from UNIX Vim running the real `bash` is a good place to start: `&shellcmdflag = '-c', &shellpipe = '2>&1| tee', &shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote = '', &autochdir = 0, &shellxescape = ''`. You probably also need `&shellslash = 1`. Basically it won't work until you can get output from `:echo system('gcc -x c -fsyntax-only -std=gnu99 t.c')`. This has nothing to do with syntastic, it's all about Vim and your Cygwin setup. You should post a summary when / if you get it working, so I can add a note to the manual :) – lcd047 May 23 '17 at 04:00
  • It's probably a really basic thing, but how do you actually *change* the shell-related flags? I'm guessing these are the flags `bash` uses? Sorry for all the trouble – J-Win May 25 '17 at 05:13
  • 1
    `let &shellredir = '>%s 2>&1'` and so on. These are flags used by Vim when running external commands. When you change Vim's idea of `shell` you need to change these flags accordingly, otherwise `system()` won't work. Which is what you're seeing above. – lcd047 May 25 '17 at 18:17
  • Yup you were spot on. Changing the Vim flags to the actual UNIX Vim values worked like a charm (specifically &shellpipe and &shellredir needed to be changed). For anyone who comes here, just stick the correct values into your vimrc – J-Win May 26 '17 at 00:51
  • Thank you so much for all of the help – J-Win May 26 '17 at 00:51

1 Answers1

0

If you don't want to read through the comments above,

All I had to do was add the following to my vimrc:

let &shellpipe = '2>&1| tee'
let &shellredir = '>%s 2>&1'
J-Win
  • 1,322
  • 16
  • 35