tjdevries / nlua.nvim

Lua Development for Neovim
MIT License
262 stars 21 forks source link

My Lua plugin, which doesn't do anything fancy, breaks nlua.nvim's diagnostics #13

Closed f-person closed 3 years ago

f-person commented 3 years ago

When I enable git-blame.nvim, diagnostic messages don't show up in Lua files/projects. When I open a Lua file that is not in a Git repo, diagnostics work. After disabling git-blame.nvim, diagnostics also work. I have no idea why this would happen. git-blame.nvim and sumneko_lua work fine together.

Here's how I set up nlua:

require'nlua.lsp.nvim'.setup(lsp, {
    on_attach = on_attach,
    globals = {'love'},
    disabled_diagnostics = {'lowercase-global'}
})

And default sumneko_lua:

lsp.sumneko_lua.setup {on_attach = on_attach}

My on_attach:

local on_attach = function(_, bufnr)
    require'completion'.on_attach({
        sorter = 'none',
        matcher = {'substring', 'exact', 'fuzzy'}
    })

    -- Mappings
    vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD',
                                '<Cmd>lua vim.lsp.buf.declaration()<CR>',
                                keymap_opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd',
                                '<Cmd>lua vim.lsp.buf.definition()<CR>',
                                keymap_opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K',
                                '<Cmd>lua vim.lsp.buf.hover()<CR>', keymap_opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi',
                                '<cmd>lua vim.lsp.buf.implementation()<CR>',
                                keymap_opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>',
                                '<cmd>lua vim.lsp.buf.signature_help()<CR>',
                                keymap_opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>D',
                                '<cmd>lua vim.lsp.buf.type_definition()<CR>',
                                keymap_opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rr',
                                '<cmd>lua vim.lsp.buf.rename()<CR>', keymap_opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>e',
                                '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>',
                                keymap_opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca',
                                '<cmd>lua vim.lsp.buf.code_action()<CR>',
                                keymap_opts)
    vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>cd',
                                '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>',
                                keymap_opts)
end

I initialize the lsp variable at the top of init.lua:

local lsp = require('lspconfig')

Maybe you have some ideas about why this would happen?

f-person commented 3 years ago

Here's my full init.lua: https://github.com/f-person/dotfiles/blob/6528831614/.config/nvim/init.lua

f-person commented 3 years ago

The problem disappeared after installing the language server with the provided script or some other changes were done (either in nlua.nvim or in git-blame.nvim). Anyways, plugins coexist in peace now.