 |
|
13
churchill 2023 年 12 月 7 日
我的配置, 如果要调试的话还得加上 dap ,个人体验并不好用 return { { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) vim.list_extend(opts.ensure_installed, { "ninja", "python", "rst", "toml" }) end, }, { "jose-elias-alvarez/null-ls.nvim", opts = function(_, opts) local nls = require("null-ls") table.insert(opts.sources, nls.builtins.formatting.black) end, }, { "williamboman/mason.nvim", opts = function(_, opts) vim.list_extend(opts.ensure_installed, { "debugpy", "black", "ruff" }) end, }, { "neovim/nvim-lspconfig", opts = { servers = { ruff_lsp = {}, pyright = { settings = { python = { analysis = { autoImportCompletions = true, typeCheckingMode = "off", autoSearchPaths = true, useLibraryCodeForTypes = true, diagnosticMode = "openFilesOnly", stubPath = vim.fn.stdpath("data") .. "/lazy/python-type-stubs/stubs", }, }, }, }, }, setup = { ruff_lsp = function() local lsp_utils = require("plugin.lsp.utils") lsp_utils.on_attach(function(client, _) if client.name == "ruff_lsp" then client.server_capabilities.hoverProvider = false end end) end, pyright = function(_, _) local lsp_utils = require("plugin.lsp.utils") lsp_utils.on_attach(function(client, bufnr) local map = function(mode, lhs, rhs, desc) if desc then desc = desc end vim.keymap.set( mode, lhs, rhs, { silent = true, desc = desc, buffer = bufnr, noremap = true } ) end if client.name == "pyright" then map("n", "<leader>lo", "<cmd>PyrightOrganizeImports<cr>", "Organize Imports" ) map("n", "<leader>lC", function() require("dap-python").test_class() end, "Debug Class" ) map("n", "<leader>lM", function() require("dap-python").test_method() end, "Debug Method" ) map("v", "<leader>lE", function() require("dap-python").debug_selection() end, "Debug Selection" ) end end) end, }, }, }, { "microsoft/python-type-stubs", cond = false, }, { "linux-cultist/venv-selector.nvim", cmd = "VenvSelect", opts = {}, keys = { { "<leader>lv", "<cmd>:VenvSelect<cr>", desc = "Select VirtualEnv" } }, }, }
|