09nvim内置lsp搭建python IDE
2021年12月10日更新: 由于视频中用于的nvim-lspinstall
插件已经停止更新,所以按视频来会报错。现在用williamboman/nvim-lsp-installer
插件做替代。功能更强大,使用方法类似。 新的插件地址: https://github.com/williamboman/nvim-lsp-installer 网盘中的配置文件已经更新: 链接:
https://pan.baidu.com/s/1K7PB3J538iL-1nWZNJT6HQ
提取码: yiqn
nvim-lsp-installer
插件
这里以packer为例,packer插件管理器安装方法: 修改~/.config/nvim/lua/plugins.lua
文件,并增加如下内容:
use 'williamboman/nvim-lsp-installer'
:wq
退出重新打开nvim后,执行:PackerInstall
安装。
创建配置文件如下:
~/.config/nvim/after/plugin/nvim-lsp-installer.lua
配置文件的内容是:
local lsp_installer = require("nvim-lsp-installer")
-- Register a handler that will be called for all installed servers.
-- Alternatively, you may also register handlers on specific server instances instead (see example below).
lsp_installer.on_server_ready(function(server)
local opts = {}
-- (optional) Customize the options passed to the server
-- if server.name == "tsserver" then
-- opts.root_dir = function() ... end
-- end
-- This setup() function is exactly the same as lspconfig's setup function.
-- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
server:setup(opts)
end)
使用方法:
安装python的语法支持,就直接运行 :LspInstall python
即可。
~~~~~~~~~~~~教程结束~~~~~~~~~~
以下内容是老版本图文教程,已经过时,新来的朋友不用看。
以下内容已经过时2021年12月10日更新 以下内容是视频中对应的内容,由于https://github.com/kabouzeid/nvim-lspinstall这个项目停止维护了,导致以下配置无法正常使用了。
正片大家好,本期内空主要是说如何快速的搭建python的开发环境。
neovim 0.5安装lsp需要手动配置,对于新手来说还是有一些难度的。 手动配置教程如下: https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md
评论区有小伙伴表示“有点看不懂,不知道修改哪个配置文件”。那么今天跟大家推荐一个简单的配置方法。
lsp安装神器nvim-lspinstall
项目地址: https://github.com/kabouzeid/nvim-lspinstall
可以简化lsp安装配置,自动配置lsp。
先决条件06_[nvim0.5+从0单排]_Native LSP 自动补全、语法检查、code action、代码段—TypeScript篇 https://blog.csdn.net/lxyoucan/article/details/120632264
首先这个文章中涉及的插件要先安装了,相关配置也好了。
安装nvim-lspinstall
插件
这里以packer为例,packer插件管理器安装方法: 修改~/.config/nvim/lua/plugins.lua
文件,并增加如下内容:
use 'kabouzeid/nvim-lspinstall'
:wq
退出重新打开nvim后,执行:PackerInstall
安装。
创建配置文件如下:
~/.config/nvim/after/plugin/nvim-lspinstall.lua
配置文件的内容是:
require'lspinstall'.setup() -- important
local servers = require'lspinstall'.installed_servers()
for _, server in pairs(servers) do
require'lspconfig'[server].setup{}
end
使用方法
:LspInstall
to install/update the language server for
(e.g.
:LspInstall python
).:LspUninstall
to uninstall the language server for
.
require'lspinstall'.setup()
to make configs of installed servers available for require’lspconfig’..setup{}.
安装python的语法支持,就直接运行 :LspInstall python
即可。
https://github.com/kabouzeid/nvim-lspinstall