Giter Site home page Giter Site logo

Comments (6)

mfussenegger avatar mfussenegger commented on May 31, 2024

Are you opening neovim outside of the project directory?

'%:p:~:.:r:gs?/?.?' looks a bit redundandent. :p turns the path into an absolute path, :~ makes it relative to the home directory, :. makes it relative to the current directory. Those are kinda incompatible with each other.

See :help filename-modifiers

from nvim-dap-python.

rhinoxi avatar rhinoxi commented on May 31, 2024

Thanks @mfussenegger .

'%:p:~:.:r:gs?/?.?' looks a bit redundandent.

Yes, %:p:~:.:r:gs?/?.? and %:.:r:gs?/?.? are returning the same results.

Are you opening neovim outside of the project directory?

No, I don't think so.

Let me use https://github.com/navdeep-G/samplemod to show the detail.

cd /Users/lds
git clone [email protected]:navdeep-G/samplemod.git
cd samplemod/sample
nvim core.py

Then use :e tests/test_basic.py to switch to the test file, and running the following command get different results:

  • :echo expand('%:r:gs?/?.?') get .Users.lds.samplemod.tests.test_basic
  • :echo expand('%:.:r:gs?/?.?') get tests.test_basic

If I want to get :lua require('dap-python').test_method() works fine, I think the second one is necessary.

from nvim-dap-python.

mfussenegger avatar mfussenegger commented on May 31, 2024

In your example I get tests.test_basic in both cases which is kinda the expected behavior of neovim. (Assuming you opened neovim in samplemod root, not sampelmod/sample, :e tests/test_basic.py would not work from inside the sample folder)

Are you using some kind of rooter plugin as well ?

In any case, I'd accept a PR that adds the :. to force a relative path on the working dir.

from nvim-dap-python.

rhinoxi avatar rhinoxi commented on May 31, 2024

ok, I'll try to figure out which plugin or config is causing this behavior.

from nvim-dap-python.

rhinoxi avatar rhinoxi commented on May 31, 2024

It seems like this project.nvim plugin is changing the working directory automatically, so that I can use :e tests/test_basic.py to switch when opening nvim in samplemod/sample.

But with nvim + project.nvim, both :echo expand('%:r:gs?/?.?') and :echo expand('%:.:r:gs?/?.?') will get the same result, tests.test_basic.

I got the problem with LunarVim and some custom configuration, still looking into it.

from nvim-dap-python.

rhinoxi avatar rhinoxi commented on May 31, 2024

[pyright] Python files are opened using a different path than the one I typed
When customizing root_dir, buffer names end-up being absolute, but only in pyright
it seems to be a behavior of pyright.
I'll close this and send a PR.

from nvim-dap-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.