-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No way to disable .ropeproject directory on Lua and Neovim #622
Comments
Can't you just use |
I tried to test Here is a Dockerfile for reproduction. Please refer to the comment at the end for the test procedure. # syntax=docker/dockerfile:1
FROM ubuntu:24.04
# Install apt packages.
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
<<EOF
set -eu
rm /etc/apt/apt.conf.d/docker-clean
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache
apt-get update
apt-get install -y --no-install-recommends curl git python3 python3-venv
EOF
# Create a Python3 virtual environment and install pip packages.
RUN --mount=type=cache,target=/root/.cache/pip <<EOF
python3 -m venv /venv
. /venv/bin/activate
pip install pylsp-rope "python-lsp-server[all]"
echo '. /venv/bin/activate' >>~/.bashrc
EOF
# Install NeoVim.
RUN curl -sLS https://github.com/neovim/neovim/releases/download/v0.10.4/nvim-linux-x86_64.tar.gz | tar -xz -C /opt
ENV PATH="/opt/nvim-linux-x86_64/bin:$PATH"
# Install nvim-lspconfig.
RUN git clone --depth=1 --branch=v1.7.0 \
https://github.com/neovim/nvim-lspconfig \
~/.config/nvim/pack/nvim/start/nvim-lspconfig
COPY <<EOF /app/main.py
print("hello")
EOF
# Configure pylsp.
RUN mkdir -p ~/.config/nvim
COPY <<EOF /root/.config/nvim/init.lua
require("lspconfig").pylsp.setup {
settings = {
pylsp = {
rope = {
-- I'm not sure if this line is working correctly.
-- I can't test vim.NIL without confirming that this works.
ropeFolder = "my_rope_folder",
},
},
},
on_attach = function(client, buf)
-- Run code_action() to have pylsp-rope create a rope folder.
vim.lsp.buf.code_action()
end,
}
EOF
WORKDIR /app
# Test procedure:
# 1. Build and run this Docker image.
# 2. The entrypoint will run the `vim.lsp.buf.code_action()` function on the `/app/main.py` file.
# Close NeoVim afterward.
# 3. The entrypoint will run `ls --almost-all`.
# Check if it prints `my_rope_folder`.
# If it does, the configuration `ropeFolder = "my_rope_folder"` is working as expected.
ENTRYPOINT ["/bin/bash", "-ic", "nvim main.py; ls --almost-all"] If it works correctly, a directory named |
CONFIGURATION.md specifies that
|
I tried it, but I still get the same result. |
A user must set
pylsp.rope.ropeFolder
tonull
if they do not want to create a.ropeproject
directory. However, this is not possible in Neovim because Lua 5.1, which is used for setting up LSPs in Neovim, does not allownil
values to be stored in tables. This issue can also arise in TOML, which lacks support for null values.I have come up with two solutions.
Pass
ropefolder=None
to the constructor ofProject
on line 83 below.python-lsp-server/pylsp/workspace.py
Lines 80 to 83 in cc6d398
This method changes the default behavior when
pylsp.rope.ropeFolder
is unspecified. That is, the.ropeproject
directory will no longer be created by default, and if you wish to create it with the old default value, pass".ropeproject"
to thepylsp.rope.ropeFolder
.Create a new configuration key, e.g.
pylsp.rope.disableRopeFolder
.If its value is
true
, the.ropeproject
directory will no longer be created. Most file formats that are used for LSP configuration (including Lua and TOML) should support boolean values, so this should work.The text was updated successfully, but these errors were encountered: