Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

notomo/lsp-handler-intercept.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lsp-handler-intercept.nvim

This is a neovim plugin to intercept lsp-handler call.

Example

-- switch tsserver and cssmodules_ls handler by context

vim.lsp.handlers[vim.lsp.protocol.Methods.textDocument_hover] =
  require("lsp-handler-intercept").wrap(vim.lsp.handlers.hover)

vim.lsp.handlers[vim.lsp.protocol.Methods.textDocument_definition] = require("lsp-handler-intercept").wrap(function()
  -- implement
end)

-- The following is after/ftplugin/typescriptreact.lua

local cursor_on_jsx_class_name = function()
  -- implement
  return true
end

local methods = {
  vim.lsp.protocol.Methods.textDocument_definition,
  vim.lsp.protocol.Methods.textDocument_hover,
}
require("lsp-handler-intercept").on_request(function() end, {
  bufnr = 0,
  client_names = { "tsserver" },
  methods = methods,
  predicate = function()
    return cursor_on_jsx_class_name()
  end,
})
require("lsp-handler-intercept").on_request(function() end, {
  bufnr = 0,
  client_names = { "cssmodules_ls" },
  methods = methods,
  predicate = function()
    return not cursor_on_jsx_class_name()
  end,
})

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published