您当前的位置: 首页 >  Python

ITKEY_

暂无认证

  • 0浏览

    0关注

    732博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

09_[nvim0.5+从0单排]_nvim内置lsp搭建python IDE

ITKEY_ 发布时间:2021-10-11 21:19:23 ,浏览量:0

视频与目录 项目值教程目录https://blog.csdn.net/lxyoucan/article/details/120641546视频全屏https://www.bilibili.com/video/BV1cQ4y1z7J3/视频

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

关注
打赏
1665243900
查看更多评论
立即登录/注册

微信扫码登录

0.0504s