Skip to content

Cannot export neovim runtime doc #3111

Closed

Description

@foxyseta

How are you using the lua-language-server?

Command Line

Which OS are you using?

Linux

What is the issue affecting?

Other

Expected Behaviour

The doc for a project importing neovim's runtime should succeed.

Actual Behaviour

root uri = file:///home/foxy/.local/share/nvim/site/pack/paks/start/visimp/.
script/cli/doc/export.lua:73: attempt to compare nil with string
stack traceback:
        script/cli/doc/export.lua:73: in function <script/cli/doc/export.lua:71>
        [C]: in function 'table.sort'
        script/cli/doc/export.lua:266: in field '?'
        script/cli/doc/export.lua:115: in field 'documentObject'
        script/cli/doc/export.lua:289: in field 'makeDocs'
        script/cli/doc/init.lua:231: in upvalue 'callback'
        script/lclient.lua:129: in function <script/lclient.lua:128>
stack traceback:
        script/lclient.lua:123: in function 'await.errorHandle'
        script/await.lua:35: in function 'await.checkResult'
        (...tail calls...)
        [C]: in function 'xpcall'
        script/timer.lua:52: in upvalue 'mWakeup'
        script/timer.lua:93: in upvalue 'onTick'
        script/timer.lua:236: in function 'timer.update'
        script/lclient.lua:139: in method 'start'
        script/cli/doc/init.lua:210: in function 'cli.doc.runCLI'
        script/cli/init.lua:22: in main chunk
        [C]: in function 'require'
        ...nvim/mason/packages/lua-language-server/libexec/main.lua:78: in main chunk
        (bootstrap.lua):85: in main chunk
        [C]: in ?
script/lclient.lua:124: [19:31:36.692][error][#0:script/lclient.lua:123]: script/cli/doc/export.lua:73: attempt to compare nil with string
stack traceback:
        script/cli/doc/export.lua:73: in function <script/cli/doc/export.lua:71>
        [C]: in function 'table.sort'
        script/cli/doc/export.lua:266: in field '?'
        script/cli/doc/export.lua:115: in field 'documentObject'
        script/cli/doc/export.lua:289: in field 'makeDocs'
        script/cli/doc/init.lua:231: in upvalue 'callback'
        script/lclient.lua:129: in function <script/lclient.lua:128>
stack traceback:
        script/lclient.lua:123: in function 'await.errorHandle'
        script/await.lua:35: in function 'await.checkResult'
        (...tail calls...)
        [C]: in function 'xpcall'
        script/timer.lua:52: in upvalue 'mWakeup'
        script/timer.lua:93: in upvalue 'onTick'
        script/timer.lua:236: in function 'timer.update'
        script/lclient.lua:139: in method 'start'
        script/cli/doc/init.lua:210: in function 'cli.doc.runCLI'
        script/cli/init.lua:22: in main chunk
        [C]: in function 'require'
        ...nvim/mason/packages/lua-language-server/libexec/main.lua:78: in main chunk
        (bootstrap.lua):85: in main chunk
        [C]: in ?

stack traceback:
        [C]: in function 'error'
        script/lclient.lua:124: in function 'await.errorHandle'
        script/await.lua:35: in function 'await.checkResult'
        (...tail calls...)
        [C]: in function 'xpcall'
        script/timer.lua:52: in upvalue 'mWakeup'
        script/timer.lua:93: in upvalue 'onTick'
        script/timer.lua:236: in function 'timer.update'
        script/lclient.lua:139: in method 'start'
        script/cli/doc/init.lua:210: in function 'cli.doc.runCLI'
        script/cli/init.lua:22: in main chunk
        [C]: in function 'require'
        ...nvim/mason/packages/lua-language-server/libexec/main.lua:78: in main chunk
        (bootstrap.lua):85: in main chunk
        [C]: in ?
/home/foxy/.local/share/nvim/mason/packages/lua-language-server/libexec/bin/lua-language-server: script/lclient.lua:149: two hours later ...
====== C -> S ======
====== S -> C ======
====================
stack traceback:
        [C]: in function 'error'
        script/lclient.lua:149: in method 'start'
        script/cli/doc/init.lua:210: in function 'cli.doc.runCLI'
        script/cli/init.lua:22: in main chunk
        [C]: in function 'require'
        ...nvim/mason/packages/lua-language-server/libexec/main.lua:78: in main chunk
        (bootstrap.lua):85: in main chunk
        [C]: in ?
>>>>================ 0571/3518

Reproduction steps

  1. Create a toy Lua project with the following .luarc.json:
    {
      "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
      "Lua.diagnostics.globals": [
        "vim"
      ],
      "runtime.version": "LuaJIT",
      "workspace": {
        "checkThirdParty": false,
        "library": [
            "/usr/share/nvim/runtime",
        ]
      },
      "diagnostics.libraryFiles": "Disable"
    }
  2. Run lua-language-server --doc=. --doc_out_path=/home/user/desktop/
  3. Now delete the /usr/share/nvim/runtime line and retry. Everything works again!

Additional Notes

No response

Log File

No response

Activity

  1. CppCXY commented on Mar 10, 2025

    @CppCXY
    Member

    for document generate, I suggest you try https://crates.io/crates/emmylua_doc_cli

  2. foxyseta commented on Mar 10, 2025

    @foxyseta
    Author

    That had the benefit of not crashing indeed, but EmmyLua and LuaCATS are not compatible anymore, right?

  3. CppCXY commented on Mar 10, 2025

    @CppCXY
    Member

    That's not the case. In fact, we are compatible with each other. Moreover, the current EmmyLua has been completely rewritten.

  4. foxyseta commented on Mar 10, 2025

    @foxyseta
    Author

    So is this yellow notice out of date?

  5. CppCXY commented on Mar 10, 2025

    @CppCXY
    Member

    you can see #3017

  6. foxyseta commented on Mar 10, 2025

    @foxyseta
    Author

    That still doesn't seem to mention compatibility between annotations, but that's fine.

  7. CppCXY commented on Mar 10, 2025

    @CppCXY
    Member

    and you will see a doc gen example:#3054

  8. dljsjr commented on Dec 4, 2025

    @dljsjr
    Contributor

    I'm seeing this as well; unfortunately the project I'm currently working on isn't open source, so I can't share a reproduction, but I'm getting the exact same crash that @foxyseta is getting when trying to export docs. The language server itself runs fine in the IDE.

    @CppCXY:

    That's not the case. In fact, we are compatible with each other. [...]

    I've seen you mention this elsewhere, and this is not true. First, I do want to say that emmylua-analyzer-rust is an excellent project and I've been using it on and off myself. The speed in particular is really terrific.

    But your statement isn't true. The largest difference is the @module annotation. @module has completely different behavior in emmylua-analyzer-rust compared to lua-ls; in emmylua-analyzer-rust, this declares a module namespace, but in lua-ls, it simulates importing a file so that its types are available in the IDE. This is a pretty huge difference when you have a somewhat large project (5KLoC) that's already annotated using LuaCATs v3.

    I believe that there were some additional minor differences the last time I tried to switch to emmylua-analyzer-rust but I don't remember off the top of my head. Either way, it's definitely not a drop-in replacement, though it is an excellent project and it does have very good support for a lot of the same features.

  9. dljsjr commented on Dec 4, 2025

    @dljsjr
    Contributor
  10. foxyseta commented on Dec 4, 2025

    @foxyseta
    Author

    Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions