用 vim/nvim 写 Python 用什么插件?

153 天前
 shuiguomayi

各位,用 vim/nvim 写 python 用什么插件? 比如,

2030 次点击
所在节点    Vim
24 条回复
biglion666
153 天前
ale 加 ruff
补全用 YCM
vituralfuture
153 天前
先安装个 mason ,它能帮你解决 linter ,formator ,lsp server 的安装,lsp 可以用 pyright ,虽然功能没有 pylance 多,但是 pylance 闭源页用不了,lsp 提供了跳转到定义,到声明,查找引用这些功能

我并没有找到一个大统一的插件,我用 neovim 觉得最大的问题就是,缺少一个 code runner ,导致我每次运行都要手动输入命令
还有一个比较影响体验的就是 lsp 的补全提示太过简单粗暴,把太多无关的东西都显示出来了,而 jetbrain 的 IDE 自然是做过优化,比如结合上下文去掉不合理的,甚至还利用机器学习将候选补全选项排序
vituralfuture
153 天前
另外说一下,如果想要把(n)vim 当做 IDE ,不建议使用 vim ,vim 体系已经很老了,比如 vim script 性能问题,异步支持太差,lsp 支持也没有。
neovim 使用纯 lua 配置不仅性能好,能干的事也更多了,neovim 内置 lsp 支持,还解决了 vim 一直以来存在的异步太弱的问题,倒逼 vim 也添加了异步功能
BBCCBB
153 天前
不想折腾就用 coc.nvim
popil1987
153 天前
astrovim 试试
xxiaowangwang
153 天前
use("williamboman/mason.nvim")
use("williamboman/mason-lspconfig.nvim")
use("neovim/nvim-lspconfig")
use("hrsh7th/cmp-nvim-lsp")
use({
"glepnir/lspsaga.nvim",
branch = "main",
requires = {
-- { "nvim-tree/nvim-web-devicons" },
{ "nvim-treesitter/nvim-treesitter" },
},
})
use("jose-elias-alvarez/null-ls.nvim")
use("jayp0521/mason-null-ls.nvim")
use({
"nvim-treesitter/nvim-treesitter",
run = function()
local ts_update = require("nvim-treesitter.install").update({ with_sync = true })
ts_update()
end,
})

仅供参考。。。漏了啥不确定
TimePPT
153 天前
https://vim.fisadev.com/
这个项目可以参考
iorilu
153 天前
不建议浪费时间折腾

有那空可以多写点代码
PTLin
153 天前
直接用 LazyVim ,别折磨自己,安装完成直接在 nvim 里运行 LazyExtras 命令安装 python 支持。
SiLenceControL
153 天前
直接 vscode 不香吗。。。。?
yfixx
153 天前
ale+ycm
ck65
153 天前
我在用的一键包 https://nvchad.com 终结( in most common cases )所有的折腾。
churchill
153 天前
我的配置, 如果要调试的话还得加上 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" } },
},
}
Guaidaodl
153 天前
@vituralfuture CodeRunner 的替代可以考虑 asynctask
Ocean810975
153 天前
lazyvim 吧,我记得对 Python 支持挺好的,虽然我不用它写 Python
fcfangcc
153 天前
为何要折磨自己,vscode remote 不香吗
Dimen61
153 天前
大家能说一下现在直接用 vim 而不是 vscode + vimmode 的好处🐴
shuiguomayi
152 天前
@xxiaowangwang jose-elias-alvarez/null-ls.nvim", 可惜,这个已经停止维护了。
shuiguomayi
152 天前
@vituralfuture nvim 很好用,哈哈。
xxiaowangwang
152 天前
@shuiguomayi https://github.com/nvimtools/none-ls.nvim 可以用这个替代。我还没试,等我有空更新下我的 vim 的配置

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/998262

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX