rcarriga / vim-ultest

The ultimate testing plugin for (Neo)Vim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disable for specific file types

farzadmf opened this issue · comments

Hi, I was wondering if there's a way to disable ultest altogether for specific file types.

Use case: I'm setting MANPAGER to neovim, and when I open a man page, ultest gives an error (there are no tests to run for a man page 😆). I tried to check :h ultest-config, but looking quickly, I didn't find any settings to achieve that

Thank you

Can you elaborate more on the error you're getting? There should be no issue for files that aren't test files so it's something else that's going wrong. Also can you show exactly how you're using neovim as a manpager?

Sure @rcarriga , sorry if I didn't provide enough information.

As for configuring neovim as the manager, I do this (I saw it on Reddit)

export MANPAGER='nvim +Man!'

And, as for the error I get, an example for when I do man ls:

Error: vim-ultest encountered an unknown error on startup, check v:exception

I tried to do :echo v:exception, but I'm not sure if that's the proper way to do it 😝

I can't reproduce the issue unfortunately. echo v:exception should work but you can remove the catch statement for the error to show itself, just remove these lines https://github.com/rcarriga/vim-ultest/blob/master/autoload/ultest/handler.vim#L20-L25 in your local repo.

Hey @rcarriga , I commented out the catch block, and this seems to be the exception:

Error invoking '/home/farzad/.vim/plugged/vim-ultest/rplugin/python3/ultest:function:_ultest_get_nearest_test' on channel 5 (python3-rplugin-host):
error caught in request handler '/home/farzad/.vim/plugged/vim-ultest/rplugin/python3/ultest:function:_ultest_get_nearest_test [[1, 'man://ls(1)', True]]':
Traceback (most recent call last):
  File "/home/farzad/.vim/plugged/vim-ultest/rplugin/python3/ultest/__init__.py", line 103, in _get_nearest_test
    return self.handler.get_nearest_test_dict(*args)
  File "/home/farzad/.vim/plugged/vim-ultest/rplugin/python3/ultest/handler/__init__.py", line 221, in get_nearest_test_dict
    test = self.get_nearest_position(line, file_name, strict)
  File "/home/farzad/.vim/plugged/vim-ultest/rplugin/python3/ultest/handler/__init__.py", line 212, in get_nearest_position
    positions = self._tracker.file_positions(file_name)
  File "/home/farzad/.vim/plugged/vim-ultest/rplugin/python3/ultest/handler/tracker.py", line 93, in file_positions
    absolute_path = self._vim.sync_call("fnamemodify", file, ":p")
  File "/home/farzad/.vim/plugged/vim-ultest/rplugin/python3/ultest/vim_client/__init__.py", line 121, in sync_call
    return self._eval(expr, sync=True)
  File "/home/farzad/.vim/plugged/vim-ultest/rplugin/python3/ultest/vim_client/__init__.py", line 134, in _eval
    return self._vim.eval(expr, async_=not sync)
  File "/home/farzad/.asdf/installs/python/3.10.0/lib/python3.10/site-packages/pynvim/api/nvim.py",line 295, in eval
    return self.request('nvim_eval', string, **kwargs)
  File "/home/farzad/.asdf/installs/python/3.10.0/lib/python3.10/site-packages/pynvim/api/nvim.py", line 182, in request
    res = self._session.request(name, *args, **kwargs)
  File "/home/farzad/.asdf/installs/python/3.10.0/lib/python3.10/site-packages/pynvim/msgpack_rpc/session.py", line 102, in request
    raise self.error_wrapper(err)
pynvim.api.common.NvimError: Vim:E121: Undefined variable: man

Thanks for the error, this should be fixed in latest commit now!

Nice @rcarriga , updated the plugin and the error seems to be gone, thank you

But still, I think, it would be nice if there was an option in vim-ultest to allow disabling the plugin for specific file types (maybe even with regex support)