Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registerFunction with lower-case function name is difficult to debug (fails without explaining the capitalization issue). #461

Open
dlants opened this issue Dec 22, 2024 · 1 comment

Comments

@dlants
Copy link

dlants commented Dec 22, 2024

I'm defining a function:

  plugin.registerFunction(
    "magenta_lsp_response",
    (result: unknown) => {
      context.logger.log(
        `magenta_lsp_response got callback ${JSON.stringify(result)}`,
      );
    },
    {},
  );

I am running :UpdateRemotePlugins, and seeing the function defined in the rplugin manifest:

" node plugins
call remote#host#RegisterPlugin('node', '/Users/denislantsman/src/magenta.nvim/rplugin/node/magenta', [
      \ {'sync': v:false, 'name': 'WinClosed', 'type': 'autocmd', 'opts': {'pattern': '*'}},
      \ {'sync': v:false, 'name': 'Magenta', 'type': 'command', 'opts': {'nargs': '1'}},
      \ {'sync': v:false, 'name': 'MagentaKey', 'type': 'command', 'opts': {'nargs': '1'}},
      \ {'sync': v:false, 'name': 'magenta_lsp_response', 'type': 'function', 'opts': {}},
     \ ])

However, when I try and use it from nvim, I get "unknown function":

:call magenta_lsp_response()
E117: Unknown function: magenta_lsp_response
:lua vim.fn.magenta_lsp_response()
E5108: Error executing lua Vim:E117: Unknown function: magenta_lsp_response
stack traceback:
        [C]: in function 'magenta_lsp_response'
        [string ":lua"]:1: in main chunk

Any help would be appreciated. Thanks!

@dlants
Copy link
Author

dlants commented Dec 22, 2024

Ah, it was failing since non-built-in functions must start with capital letters. I think it would be nice if this failed with a more obvious error message.

@dlants dlants changed the title Docs on how to use registerFunction from neovim side? registerFunction with lower-case function name is difficult to debug (fails silently). Dec 22, 2024
@dlants dlants changed the title registerFunction with lower-case function name is difficult to debug (fails silently). registerFunction with lower-case function name is difficult to debug (fails without explaining the capitalization issue). Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant