nvim-code-action-menu icon indicating copy to clipboard operation
nvim-code-action-menu copied to clipboard

handle commands on the client side

Open aspeddro opened this issue 3 years ago • 1 comments

Some commands on the ltex lsp are resolved on the client side.

Example:

  • _ltex.addToDictionary
  • _ltex.disableRules
  • _ltex.hideFalsePositives

Docs: ltex commands

local lspconfig = require 'lspconfig'
local opts = {
  root_dir = function(filename)
    return lspconfig.util.path.dirname(filename)
  end,
  on_init = function(client, _)
    vim.lsp.commands['_ltex.addToDictionary'] = function(cmd, ctx)
      print(vim.inspect { cmd, ctx })
    end
  end,
  settings = {
    ltex = {
      completionEnabled = true,
      language = 'en-US',
      checkFrequency = 'edit',
      setenceCacheSize = 5000,
      additionalRules = {
        enablePickyRules = true,
        motherTongue = 'en-US',
      },
      dictionary = {
        ['en-US'] = { 'Hello', 'Neovim' },
      },
    },
  },
}
lspconfig.ltex.setup(opts)

Using :CodeActionMenu not run the command _ltex.addToDictionary. But using :lua vim.lsp.buf.code_action() works.

https://user-images.githubusercontent.com/16160544/160704020-a61c2bf6-e8be-4524-b2fb-eafd4d90c71e.mp4

aspeddro avatar Mar 29 '22 20:03 aspeddro

Hey 👋🏾 Thanks for the detailed issue report. 🙏🏾

I guess I somehow need to apply this part of what NeoVim core does. Unfortunately it is inside a not accessible function. 😑

I would be happy if you would open a PR which adds this functionality I linked. You have already the perfect test environment for this "feature", so a contribution would be the optimal case for me. Else I'll try to find some time. But usually if I find the time and motivation to rather work on version 2.0 of this plugin...

weilbith avatar Mar 30 '22 08:03 weilbith