LCOV - code coverage report
Current view: top level - /lua/yoda/commands/dev_setup - python.lua (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 13 13
Test Date: 2026-04-14 10:33:13 Functions: - 0 0

            Line data    Source code
       1              : -- lua/yoda/commands/dev_setup/python.lua
       2              : -- Python development environment setup commands
       3              : 
       4            1 : local M = {}
       5              : 
       6            1 : local notify = require("yoda-adapters.notification")
       7              : 
       8            1 : function M.setup()
       9              :   -- Python development setup
      10           22 :   vim.api.nvim_create_user_command("YodaPythonSetup", function()
      11              :     local logger = require("yoda-logging.logger")
      12              :     logger.set_strategy("console")
      13              :     logger.set_level("info")
      14              : 
      15              :     logger.info("🐍 Setting up Python development environment...")
      16              : 
      17              :     -- Check if Mason is available
      18              :     local mason_ok, mason = pcall(require, "mason")
      19              :     if not mason_ok then
      20              :       notify.notify("❌ Mason not available. Install via :Lazy sync first", "error")
      21              :       return
      22              :     end
      23              : 
      24              :     -- Install Python tools via Mason
      25              :     logger.info("Installing basedpyright via Mason...")
      26              :     vim.cmd("MasonInstall basedpyright")
      27              : 
      28              :     logger.info("Installing debugpy (Python debugger) via Mason...")
      29              :     vim.cmd("MasonInstall debugpy")
      30              : 
      31              :     logger.info("Installing ruff (linter/formatter) via Mason...")
      32              :     vim.cmd("MasonInstall ruff")
      33              : 
      34              :     -- Notify user
      35              :     notify.notify(
      36              :       "🐍 Python tools installation started!\n"
      37              :         .. "Installing: basedpyright, debugpy, ruff\n"
      38              :         .. "Check :Mason for progress.\n"
      39              :         .. "Restart Neovim after installation completes.",
      40              :       "info",
      41              :       { title = "Yoda Python Setup" }
      42              :     )
      43              : 
      44              :     logger.info("✅ Python setup initiated. Restart Neovim after Mason installation completes.")
      45           11 :   end, { desc = "Install Python development tools (basedpyright, debugpy, ruff) via Mason" })
      46              : 
      47              :   -- Stop pyright LSP
      48           22 :   vim.api.nvim_create_user_command("StopPyright", function()
      49              :     local clients = vim.lsp.get_clients({ name = "pyright" })
      50              :     if #clients == 0 then
      51              :       notify.notify("No pyright clients running", "info")
      52              :       return
      53              :     end
      54              : 
      55              :     for _, client in ipairs(clients) do
      56              :       client:stop()
      57              :       notify.notify(string.format("Stopped pyright client (id:%d)", client.id), "info")
      58              :     end
      59           11 :   end, { desc = "Stop pyright LSP clients (we use basedpyright)" })
      60              : 
      61              :   -- Uninstall pyright from Mason
      62           22 :   vim.api.nvim_create_user_command("UninstallPyright", function()
      63              :     notify.notify("Uninstalling pyright from Mason...", "info")
      64              :     vim.cmd("MasonUninstall pyright")
      65              :     notify.notify("✅ Pyright uninstalled!\nWe use basedpyright instead.\nRestart Neovim for changes to take effect.", "info")
      66           11 :   end, { desc = "Uninstall pyright from Mason (we use basedpyright)" })
      67              : 
      68              :   -- Python virtual environment selector
      69           22 :   vim.api.nvim_create_user_command("YodaPythonVenv", function()
      70              :     local ok = pcall(vim.cmd, "VenvSelect")
      71              :     if not ok then
      72              :       notify.notify("❌ venv-selector not available. Install via :Lazy sync", "error")
      73              :     end
      74           11 :   end, { desc = "Select Python virtual environment" })
      75           12 : end
      76              : 
      77            1 : return M
        

Generated by: LCOV version 2.0-1