Hi! Editor question: has somebody managed to get a...
# general
a
Hi! Editor question: has somebody managed to get a good vim config to work with pants? I run all the ide functions (pylint, etc) on vim so I need to start the editor in an environment that knows about third party deps, the libraries, etc. If I create a virtualenv, then I can’t really run any pants command from there, so I was wondering if I was missing something
h
Hi! It doesn't address vim in particular, but have you seen https://www.pantsbuild.org/docs/setting-up-an-ide?
a
yup, I tried to do that, but vim is a bit dumber than VSCode… If I create a virtualenv and run from it, pants complains, so I need to have a terminal without virtualenv for pants and another one for vim with the virtualenc
which is a bit annoying
but if by accident I run a pants command inside the virtualenv, it all stops working
h
Hm, what do you mean it stops working?
a
Copy code
$ ./pants dependencies --type=3rdparty ::
22:51:37.74 [ERROR] Exception caught: (pants.engine.internals.scheduler.ExecutionError)
  File "/Users/albert/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.SIcoX6/install/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 234, in _run_inner
    return self._perform_run(goals)
  File "/Users/albert/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.SIcoX6/install/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 173, in _perform_run
    return self._perform_run_body(goals, poll=False)
  File "/Users/albert/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.SIcoX6/install/lib/python3.9/site-packages/pants/bin/local_pants_runner.py", line 190, in _perform_run_body
    return self.graph_session.run_goal_rules(
  File "/Users/albert/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.SIcoX6/install/lib/python3.9/site-packages/pants/init/engine_initializer.py", line 135, in run_goal_rules
    exit_code = self.scheduler_session.run_goal_rule(
  File "/Users/albert/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.SIcoX6/install/lib/python3.9/site-packages/pants/engine/internals/scheduler.py", line 533, in run_goal_rule
    self._raise_on_error([t for _, t in throws])
  File "/Users/albert/.cache/pants/setup/bootstrap-Darwin-x86_64/pants.SIcoX6/install/lib/python3.9/site-packages/pants/engine/internals/scheduler.py", line 501, in _raise_on_error
    raise ExecutionError(

Exception message: 1 Exception encountered:

  Exception: While expanding link "venv/bin/python": Failed to read link "/Users/albert/Arxiu/Work/Projects/Ongoing/python-apps-pants/venv/bin/python3": Absolute symlink: "/Users/albert/Arxiu/Work/Projects/Ongoing/python-apps-pants/venv/bin/python3"
things like that
h
Oh, you should be able to set
pants_ignore
so that Pants doesn't look inside those
Copy code
[GLOBAL]
pants_ignore.add = ["venv/"]
a
ooh, thanks!
❤️ 1
b
So does it work for you now? If you had to do any special config for vim, that'd be a great addition for the docs. There's a "suggest edits" button near the top right.
a
I haven’t found anything that works super well yet
vim runs the linters basically on the command line, so I am figuring out the equivalent to VScode “Sources”
but editing the pythonpath is not terrible I guess 🤷
b
Is using Jupyter Notebook an option for some of your need? https://www.pantsbuild.org/docs/jupyter It's not a substitute for an IDE, obviously.
a
unfortunately not, but I found something that works now and could be automated with some extra tooling
I’ll play around with it
🤞 1
and if I see it works in the coming weeks, I’ll try to make an edit with the info
b
Thank you!
c
I use neovim. For pylint I have my config in tox.ini which I believe gets picked up by both pants and neomake plugin. I am fairly happy with my setup and haven't had any need to let neovim actually run pants. That being said I don't have any smart completion plugins installed so I haven't had to wrestle wit that.
a
mmm, and how do you handle dependencies?
c
Based on how I have my vim configured I don't need to
I'm guessing you need that for better code completion?
a
yeah, basically I check also whether things can be imported, etc, and this needs the deps. I thought pylint would need this too?
c
i'm using flake8 so maybe it's different
sorry should have clarified that
i run pants on a vm so I keep a separate pane open in my terminal that has a session on the vm - I have some aliases there to quickly run pants commands as well as a pre-commit hook that runs
./pants lint --changed-since=HEAD || exit 1
a
ah, that’s why
ok