I have been unable to setup neovim lsp for python. Nothing seems to work

I have tried all the available servers the config has: pyls, pylsp, pyright, but none of them work. I have followed the debugging steps on the main page and have noted the default configurations in the CONFIG.md file. I originally opened an issue a while back and since then I have still not figured out a solution (getting desperate lol; see original issue here - Am I the only one where both `pyls` and `pylsp` are not attaching? · Issue #893 · neovim/nvim-lspconfig · GitHub).

For example, for pylsp I have followed all the steps:

pipx install 'python-lsp-server[all]'
mkdir test_py
git init
python3 -m venv venv
source venv/bin/activate
# I even tried installing pylsp in my virtualenv
touch requirements.txt # with some random stuff
touch main.py
nvim main.py

When I follow these steps and open main.py, I expect the language server to attach, but it doesn’t. When I run :LspInfo it recognizes that I have the server installed, but specifies that there are 0 clients attached.

Granted: I can start it myself by running something like :LspStart pylsp, but this is not ideal (maybe I’m lazy for sure) because I would have to re-run this for every file I open.

Really appreciate any help I can get with this, I have been struggling for months lol. I have a lua file where all my lsp-related things are initialized, here is a snippet of what happens in there:

local nvim_lsp = require'lspconfig'

local custom_attach = function(client)
    print("LSP started.");
    -- require'completion'.on_attach(client)
    -- require('folding').on_attach()
    -- require'diagnostic'.on_attach(client)
        bind = true,
        handler_opts = {
            border = "single"

    utils.map('n','gD','<cmd>lua vim.lsp.buf.declaration()<CR>')
    utils.map('n','gd','<cmd>lua vim.lsp.buf.definition()<CR>')
    utils.map('n','K','<cmd>lua vim.lsp.buf.hover()<CR>')
    utils.map('n','gr','<cmd>lua vim.lsp.buf.references()<CR>')
    utils.map('n','gs','<cmd>lua vim.lsp.buf.signature_help()<CR>')
    utils.map('n','gi','<cmd>lua vim.lsp.buf.implementation()<CR>')
    utils.map('n','gt','<cmd>lua vim.lsp.buf.type_definition()<CR>')
    utils.map('n','<leader>gw','<cmd>lua vim.lsp.buf.document_symbol()<CR>')
    utils.map('n','<leader>gW','<cmd>lua vim.lsp.buf.workspace_symbol()<CR>')
    utils.map('n','<leader>ah','<cmd>lua vim.lsp.buf.hover()<CR>')
    utils.map('n','<leader>ac','<cmd>lua vim.lsp.buf.code_action()<CR>')
    utils.map('n','<leader>ee','<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>')
    utils.map('n','<leader>ar','<cmd>lua vim.lsp.buf.rename()<CR>')
    utils.map('n','<leader>=', '<cmd>lua vim.lsp.buf.formatting()<CR>')
    utils.map('n','<leader>ai','<cmd>lua vim.lsp.buf.incoming_calls()<CR>')
    utils.map('n','<leader>ao','<cmd>lua vim.lsp.buf.outgoing_calls()<CR>')
    utils.map('n',']g','<cmd>lua vim.lsp.diagnostic.goto_next({ enable_popup = true })<CR>')
    utils.map('n','[g','<cmd>lua vim.lsp.diagnostic.goto_prev({ enable_popup = true })<CR>')

local servers = {'clangd', 'tsserver', 'vimls', 'bashls', 'pylsp'}
for _, s in ipairs(servers) do
    nvim_lsp[s].setup{on_attach=custom_attach, }

The custom_attach if don’t call

Wrtie on_attach = custom_attach to call

I’m sorry, but I don’t follow. That’s what I’m doing

I’m no Python dev but my config is working for Python and literally all I have is


Obviously I have pyright installed on my system and available on my path.

So I figured it out. I had a python.vim file in my ftplugin directory. For some reason this caused my python lsp servers not to load on init. Is this meant to happen?