Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/python.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Default values:
auto_venv_lsp_attach_patterns = { "*.py" },

-- Filetypes to activate commands for python.nvim
command_setup_filetypes = { "python" },
command_setup_buf_pattern = { "*.py" },

-- Load python.nvim python snippets
python_lua_snippets = false,
Expand Down
13 changes: 10 additions & 3 deletions lua/lualine/components/python.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ function M:init(options)
end

function M:update_status()
local venv = require("python.venv").current_venv()
if venv then
return venv.name
local venv_path = vim.fn.getenv("VIRTUAL_ENV")
local conda_env = vim.fn.getenv("CONDA_DEFAULT_ENV")

if venv_path ~= vim.NIL then
if vim.fs.basename(venv_path) == ".venv" then
return vim.fs.basename(vim.fs.dirname(venv_path))
end
return vim.fs.basename(venv_path)
elseif conda_env ~= nil then
return conda_env
else
return "no venv"
end
Expand Down
2 changes: 1 addition & 1 deletion lua/python/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ PythonConfig.defaults = {
auto_venv_lsp_attach_patterns = { "*.py" },

-- Filetypes to activate commands for python.nvim
command_setup_filetypes = { "python" },
command_setup_buf_pattern = { "*.py" },

-- Load python.nvim python snippets
python_lua_snippets = false,
Expand Down
1 change: 0 additions & 1 deletion lua/python/hatch/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ end

function PythonHatchCommands.hatch_list_python()
local versions = hatch_installed_versions()
vim.print(versions)
end

function PythonHatchCommands.hatch_delete_python()
Expand Down
4 changes: 2 additions & 2 deletions lua/python/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ function Python.setup(opts)
})

-- Load up commands for users
vim.api.nvim_create_autocmd({ "FileType" }, {
pattern = config.command_setup_filetypes,
vim.api.nvim_create_autocmd({ "BufEnter" }, {
pattern = config.command_setup_buf_pattern,
desc = "python.nvim: Loading commands for python",
group = id,
callback = function()
Expand Down
2 changes: 1 addition & 1 deletion lua/python/venv/create.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function PythonVENVCreate.python_set_venv(venv_path, venv_name, venv_source)
if current_venv then
current_venv_name = current_venv.name
end
if vim.fs.basename(venv_path) ~= current_venv_name then
if vim.fs.basename(venv_path) and current_venv_name ~= venv_name then
if not venv_source then
venv_source = "venv"
end
Expand Down
2 changes: 1 addition & 1 deletion lua/python/venv/detect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function DetectVEnv:found_in_cwd()

-- set venv if cwd is found in state before doing searches.
if python_state.venvs[cwd] ~= nil and vim.fn.isdirectory(python_state.venvs[cwd].venv_path) ~= 0 then
local venv_name = vim.fs.basename(python_state.venvs[cwd].venv_path)
local venv_name = vim.fs.basename(vim.fs.dirname(python_state.venvs[cwd].venv_path))
if not venv_name then
return false
end
Expand Down
1 change: 0 additions & 1 deletion lua/python/venv/interpreters.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ function PythonVENVInterpreters.python_interpreters()
if IS_WINDOWS then
return { "python3" }
end
-- TODO for macos we probably need to look in other places other than homebrew
local pythons = vim.fn.globpath("/usr/bin/", "python3.*", false, true)

if IS_MACOS then
Expand Down
2 changes: 1 addition & 1 deletion scripts/minimal_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require("nvim-treesitter.locals")
require("nvim-treesitter").setup()
require("mini.test").setup()
require("mini.doc").setup()
local ts_configs = require("nvim-treesitter.configs").setup({
require("nvim-treesitter.configs").setup({
modules = {
"highlight",
},
Expand Down
1 change: 1 addition & 0 deletions tests/test_text_actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ local get_lines = function()
end

T["text_actions"] = MiniTest.new_set({
n_retry = 3,
hooks = {
pre_case = function()
child.cmd("e _not_existing_new_buffer.py")
Expand Down
Loading