jose-elias-alvarez / nvim-lsp-ts-utils

Utilities to improve the TypeScript development experience for Neovim's built-in LSP client.
The Unlicense
438 stars 18 forks source link

[BUG] Custom handlers are not used #64

Closed p00f closed 3 years ago

p00f commented 3 years ago

FAQ

Issues

Neovim Version

NVIM v0.6.0-dev+212-g5f8518b3f Build type: RelWithDebInfo LuaJIT 2.0.5 Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/p00f/.cache/paru/clone/neovim-git/src/build/config -I/home/p00f/.cache/paru/clone/neovim-git/src/neovim-git/src -I/usr/include -I/home/p00f/.cache/paru/clone/neovim-git/src/build/src/nvim/auto -I/home/p00f/.cache/paru/clone/neovim-git/src/build/include Compiled by p00f@ga-h110m Features: +acl +iconv +tui See ":help feature-compile" system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/share/nvim" Run :checkhealth for more info

Steps to reproduce

Register custom diagnostic handlers like:

lspconfig.tsserver.setup {
    capabilities = common.capabilities,
    on_attach  = function(client, bufnr)
        common.on_attach(client, bufnr)
        ts_utils.setup({debug = true})
        ts_utils.setup_client(client)
    end,
    handlers = common.handlers,
    on_init = common.on_init
}

(common is a table containing common config for all servers)

However

lspconfig.tsserver.setup {
    capabilities = common.capabilities,
    on_attach  = common.on_attach,
    handlers = common.handlers,
    on_init = common.on_init
}

uses the correct common.handlers

Expected behavior

Custom diagnostic handlers are used

Actual behavior

Default handlers are used

Debug log

empty

Help

No

Implementation help

No response

p00f commented 3 years ago

It used to work correctly a month ago

jose-elias-alvarez commented 3 years ago

What is inside common.handlers? This most likely has to do with the functionality we added to filter tsserver diagnostics, which overrides the client's diagnostics handler.

p00f commented 3 years ago
{
  ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "single" }),
  ["textDocument/publishDiagnostics"] = vim.lsp.with(
    vim.lsp.diagnostic.on_publish_diagnostics,
    { severity_sort = true, underline = true, update_in_insert = false, virtual_text = false }
  ),
  ["textDocument/signatureHelp"] = vim.lsp.with(
    vim.lsp.handlers.signature_help,
    { border = "single" }
  ),
}
jose-elias-alvarez commented 3 years ago

I'm not 100% sure what lspconfig is doing with the handlers, but I assume it's also overriding the client's handlers, so a1be4743181be6e82500e7cb0d4d7f9c2b4f8f50 may fix the issue. Could you try updating the plugin and let me know if that works for you?

p00f commented 3 years ago

Yes, thanks