From f055265bff24f047320bca1a402ab55a32b35111 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 20 Mar 2024 17:18:11 +0100 Subject: [PATCH] feat(python): added option to configure basedpyright as lsp. Check the python extra docs. Fixes #2787 --- lua/lazyvim/plugins/extras/lang/python.lua | 25 +++++++++++++++++++++- lua/lazyvim/types.lua | 4 ++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 lua/lazyvim/types.lua diff --git a/lua/lazyvim/plugins/extras/lang/python.lua b/lua/lazyvim/plugins/extras/lang/python.lua index cc9bc52e..559594db 100644 --- a/lua/lazyvim/plugins/extras/lang/python.lua +++ b/lua/lazyvim/plugins/extras/lang/python.lua @@ -1,3 +1,9 @@ +if lazyvim_docs then + -- LSP Server to use for Python. + -- Set to "basedpyright" to use basedpyright instead of pyright. + vim.g.lazyvim_python_lsp = "pyright" +end + return { { "nvim-treesitter/nvim-treesitter", @@ -7,11 +13,28 @@ return { end end, }, + -- basedpyright support. + -- Remove when merged: https://github.com/williamboman/mason-lspconfig.nvim/pull/379 + { + "williamboman/mason.nvim", + optional = true, + opts = function(_, opts) + if vim.g.lazyvim_python_lsp == "basedpyright" then + opts.ensure_installed = opts.ensure_installed or {} + table.insert(opts.ensure_installed, "basedpyright") + end + end, + }, { "neovim/nvim-lspconfig", opts = { servers = { - pyright = {}, + pyright = { + enabled = vim.g.lazyvim_python_lsp ~= "basedpyright", + }, + basedpyright = { + enabled = vim.g.lazyvim_python_lsp == "basedpyright", + }, ruff_lsp = { keys = { { diff --git a/lua/lazyvim/types.lua b/lua/lazyvim/types.lua new file mode 100644 index 00000000..73a5fe7b --- /dev/null +++ b/lua/lazyvim/types.lua @@ -0,0 +1,4 @@ +---@class LazyVimGlobals +vim.g = {} + +_G.lazyvim_docs = true