Use pyright (if available), fallback to pylsp otherwise
This commit is contained in:
parent
667115842f
commit
e5cb627087
|
@ -38,7 +38,7 @@ Plugin definitions are in `plugins.lua`, inside `vim` run `:PackerSync` to insta
|
|||
pyenv virtualenv neovim3 # Assumes working pyenv
|
||||
pyenv activate neovim3
|
||||
pip install -U pip setuptools wheel
|
||||
pip install -U pynvim "python-lsp-server[all]" fortls pylsp-mypy python-lsp-black
|
||||
pip install -U pynvim pyright fortl # If pyright not available, fallback to: "python-lsp-server[all]" pylsp-mypy
|
||||
pyenv deactivate
|
||||
```
|
||||
|
||||
|
|
|
@ -104,8 +104,24 @@ cmp.setup.cmdline(':', {
|
|||
-- Setup lspconfig.
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
|
||||
local function file_exists(name)
|
||||
local f=io.open(name,"r")
|
||||
if f~=nil then io.close(f) return true else return false end
|
||||
end
|
||||
|
||||
local pyright_file = os.getenv( "HOME" ).."/.pyenv/versions/neovim3/bin/pyright-langserver"
|
||||
local pylsp_file = os.getenv( "HOME" ).."/.pyenv/versions/neovim3/bin/pylsp"
|
||||
|
||||
if file_exists(pyright_file) then
|
||||
require('lspconfig')['pyright'].setup{
|
||||
cmd = {pyright_file, "--stdio"},
|
||||
on_attach = on_attach,
|
||||
flags = lsp_flags,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
elseif file_exists(pylsp_file) then
|
||||
require('lspconfig')['pylsp'].setup{
|
||||
cmd = {os.getenv( "HOME" ).."/.pyenv/versions/neovim3/bin/pylsp"},
|
||||
cmd = {pylsp_file},
|
||||
on_attach = on_attach,
|
||||
flags = lsp_flags,
|
||||
settings = {
|
||||
|
@ -118,6 +134,8 @@ require('lspconfig')['pylsp'].setup{
|
|||
},
|
||||
capabilities = capabilities
|
||||
}
|
||||
end
|
||||
|
||||
require('lspconfig')['fortls'].setup{
|
||||
cmd = {os.getenv( "HOME" ).."/.pyenv/versions/neovim3/bin/fortls"},
|
||||
on_attach = on_attach,
|
||||
|
|
Loading…
Reference in a new issue