rgbkrk / python-lsp-zed-extension

Python LSP Server Zed Extension
28 stars 1 forks source link

Jedi hover definitions don't work for external modules. #5

Open NathanielH-snek opened 1 month ago

NathanielH-snek commented 1 month ago

Generally I use venv for projects. I can't seem to get the jedi hover to work on modules that aren't part of base python. For base python functions it seems to work. To me this sounds like some sort of configuration issue. Anyone have any ideas? Here's my config for lsp currently.

{
  "lsp": {
    "pylsp": {
      "initialization_options": {
        "settings": {
          "python": {
            "pythonPath": ".venv/bin/python"
          }
        }
      },
      "settings": {
        "plugins": {
          "pylsp_mypy": {
            "live_mode": true,
            "enabled": true,
            "dmypy": true
          },
          "pylint": {
            "enabled": false
          },
          "pycodestyle": {
            "enabled": false
          },
          "jedi_symbols": {
            "enabled": true
          },
          "jedi_definition": {
            "enabled": true
          },
          "jedi_references": {
            "enabled": true
          },
          "jedi_hover": {
            "enabled": true
          },
          "jedi_completion": {
            "enabled": true
          },
          "jedi_signature_help": {
            "enablded": true
          },
          "pyflakes" : {
            "enabled" : false
          },
          "mccabe" : {
            "enabled" : false
          },
          "autopep8" : {
            "enabled" : false
          }
        }
      }
    },
    "ruff": {
      "initialization_options": {
        "settings": {
          // Ruff server settings goes here
          "lineLength": 80,
          "lint": {
            "extendSelect": ["I"]
            //"ignore": ["F401"]
          }
        }
      }
    }
  }
}
NathanielH-snek commented 1 month ago

Well I was right it was partially a configuration issue. I had to pass the env to jedi. Jedi hover still doesn't work for every method but it's still better than pyright! I'll leave my new config here incase someone runs into similar issues.

{
  "lsp": {
    "basedpyright" : {
      "settings" : {
        "python" : {
          "pythonPath" : ".venv/bin/python"
        },
       "disableOrganizeImports" : true
      }
    },
    "pyright" : {
      "settings" : {
        "python" : {
          "pythonPath" : ".venv/bin/python"
        } 
      }
    },
    "pylsp": {
      "initialization_options": {
        "settings": {
          "python": {
            "pythonPath": ".venv/bin/python"
          }
        }
      },
      "settings": {
        "plugins": {
          "pylsp_mypy": {
            "live_mode": true,
            "enabled": true,
            "dmypy": true
          },
          "pylint": {
            "enabled": false
          },
          "pycodestyle": {
            "enabled": false
          },
          "jedi_symbols": {
            "enabled": true
          },
          "jedi_definition": {
            "enabled": true
          },
          "jedi_references": {
            "enabled": true
          },
          "jedi_hover": {
            "enabled": true
          },
          "jedi_completion": {
            "enabled": true
          },
          "jedi_signature_help": {
            "enabled": true
          },
          "jedi" : {
            "environment" : ".venv/bin/python"
          },
          "pyflakes" : {
            "enabled" : false
          },
          "mccabe" : {
            "enabled" : false
          },
          "autopep8" : {
            "enabled" : false
          }
        }
      }
    },
    "ruff": {
      "initialization_options": {
        "settings": {
          // Ruff server settings goes here
          "lineLength": 80,
          "lint": {
            "extendSelect": ["I"]
            //"ignore": ["F401"]
          }
        }
      }
    }
  }
}

This time I truncated to only the LSP config since I realized the rest is probably extraneous.