2

I am using the vim-better-whitespace plugin to highlight trailing whitespaces. For some buffers, I don't want this behavior and vim-better-whitespace usually provides an option to list the filetypes where it shouldn't apply.

However, I am also using nvim-ipy to integrate with ipython and this plugin opens a new buffer for console output, where filetype is empty and buftype is set to nofile.

Is there any way to construct an autocmd to call DisableWhitespace once the respective ipython buffer is created?

3
  • I don't use any of these tools so that is just a random guess: It seems like an autocommand will not be possible since you can't determine to buffer type/filetype but if you open your new buffer with a mapping maybe you could try something like this: nnoremap <key> <Plug>(IPy-Run) <bar>:DisableWhitespace<CR>. This would create a mapping which would open the buffer and then call the command you're looking for. Once again this is just a guess I'm not sure it would work.
    – statox
    Commented Oct 25, 2016 at 15:12
  • @statox I think the problem with this approach is that nvim-ipy doesn't focus the ipython buffer. So I would also have to add commands to move there etc....
    – languitar
    Commented Oct 26, 2016 at 9:19
  • Indeed that would make you create a whole wrapper for the plugin which is not the ideal solution. Have you tried to ask the author his opinion? Maybe the issue tracker would be a good place to ask for help.
    – statox
    Commented Oct 26, 2016 at 9:21

1 Answer 1

1

Here is a solution using BufFilePost based on the buffer name being [jupyter]:

augroup filetype_jupyter
  autocmd!
  autocmd BufFilePost \[jupyter\]
  \ setlocal filetype=python |
  \ DisableWhitespace
augroup END

It also sets the filetype to Python.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.