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

feature: Add socket (luasocket) library annotations #5

Open
1 task done
ColdMacaroni opened this issue Dec 31, 2024 · 1 comment
Open
1 task done

feature: Add socket (luasocket) library annotations #5

ColdMacaroni opened this issue Dec 31, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@ColdMacaroni
Copy link

Did you check the docs?

  • I have read all the docs

Is your feature request related to a problem? Please describe.

love2d contains an implementation of the luasocket library (see https://www.love2d.org/wiki/socket), however the annotations for it are not included in LuaCATS/love2d.

Describe the solution you'd like

The plugin should add the luasocket annotations (LuaCATS/luasocket) to the lua language server libraries. Probably by also adding it as a submodule to this repo. I'm not sure what the config should look like exactly.

Describe alternatives you've considered

I've made a fork of this plugin with some personal changes. The structure is somewhat different but here's how i'm handling it:

Another alternative would be to get upstream LuaCATS/love2d to include the socket library (and others), but i don't know if that's in scope for that project.

Additional context

love2d also bundles lua-enet and utf8, but i couldn't find LuaCATS annotations for them :(

@ColdMacaroni ColdMacaroni added the enhancement New feature or request label Dec 31, 2024
@S1M0N38
Copy link
Owner

S1M0N38 commented Jan 8, 2025

I'd like to include only LuaCATS for the lib bundled with LÖVE. According to the LÖVE documentation, the bundled libraries are: luasocket, lua-enet, and utf8.

Since this plugin was written in a rush and does not support proper semver, I suggest keeping it simple and avoiding breaking changes, such as modifying existing options in the setup table.

A possible solution is to add path_to_*_library options and ship those libraries with love2d.nvim as git submodules. However, as you mentioned, LuaCATS for lua-enet and utf8 do not exist. Therefore, I propose adding only path_to_luasocket_library for now.

Example config table:

{
  path_to_love_bin = "love",
  path_to_love_library = vim.fn.globpath(vim.o.runtimepath, "love2d/library"),
  path_to_luasocket_library = vim.fn.globpath(vim.o.runtimepath, "luasocket/library"),
  restart_on_save = false,
}

I look forward to merging a PR which implements the following:

  • add LuaCATS/luasocket to this repo as a git submodule
  • update lua/love2d/config.lua setup_lsp function so it takes library_paths (anarray of library paths) as input and configures those libs for LSP.
  • add path_to_luasocket_library to the default config
  • document the option in the help file (doc/love2d.txt) (same behaviour as path_to_love_library if path_to_luasocket_library is set to "", do not set up LSP for luasocket)

(sorry for the late response, ive been quite busy lately)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants