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: load library on filename #39

Closed
1 task done
al1-ce opened this issue Jul 2, 2024 · 6 comments · Fixed by #41
Closed
1 task done

feature: load library on filename #39

al1-ce opened this issue Jul 2, 2024 · 6 comments · Fixed by #41
Labels
enhancement New feature or request

Comments

@al1-ce
Copy link
Contributor

al1-ce commented Jul 2, 2024

Did you check the docs?

  • I have read all the lazydev.nvim docs

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

I'm adding xmake library definitions which all live in global space (i.e without require("xmake")), so all of functions like add_rules, target.. that are defined by xmake are suggested in all lua files

Describe the solution you'd like

Allow loading library when opening file with certain name, i.e with this configuration:

{
    'folke/lazydev.nvim',
    ft = "lua",
    opts = {
        library = {
            { "xmake-luals-addon/library", file = { "xmake.lua" } },
        }
    },
    dependencies = {
        "LelouchHe/xmake-luals-addon"
    }
}

xmake-luals-addon would only load when I'm opening xmake.lua

Describe alternatives you've considered

Writing enable function that would detect filename, but that'd colide with other library definitions

Additional context

No response

@al1-ce al1-ce added the enhancement New feature or request label Jul 2, 2024
@folke
Copy link
Owner

folke commented Jul 2, 2024

Isn't something like the below enough?

{ "LuaCATS/luassert", name = "luassert-types", lazy = true },
  { "LuaCATS/busted", name = "busted-types", lazy = true },
  {
    "folke/lazydev.nvim",
    opts = function(_, opts)
      vim.list_extend(opts.library, {
        { path = "luassert-types/library", words = { "assert" } },
        { path = "busted-types/library", words = { "describe" } },
      })
    end,
  },

@folke folke closed this as not planned Won't fix, can't repro, duplicate, stale Jul 2, 2024
@al1-ce
Copy link
Contributor Author

al1-ce commented Jul 3, 2024

No it's not enough

Problem is that all of the xmake functions are in global scope and have no common denominator

Here's example xmake:

-- xmake.lua
target("library")
    set_kind("static")
    add_files("src/library/*.c")

target("test")
    set_kind("binary")
    add_files("src/*.c")
    add_deps("library")

And same thing would be apply for premake:

-- premake5.lua
workspace "HelloWorld"
   configurations { "Debug", "Release" }

project "HelloWorld"
   kind "ConsoleApp"
   language "C"
   targetdir "bin/%{cfg.buildcfg}"

   files { "**.h", "**.c" }

   filter "configurations:Debug"
      defines { "DEBUG" }
      symbols "On"

   filter "configurations:Release"
      defines { "NDEBUG" }
      optimize "On"

Both of them use global space functions and don't have unique enough words that you wouldn't encounter when coding normally to identify by, so identifying by file is needed

@folke
Copy link
Owner

folke commented Jul 3, 2024

I don't see the issue tbh. Just add all the words? Or at least the most common ones?

@folke
Copy link
Owner

folke commented Jul 3, 2024

You could probably also just add ---@module 'xmake' to the top of the file

@folke
Copy link
Owner

folke commented Jul 3, 2024

or feel free to provide a PR...

@al1-ce
Copy link
Contributor Author

al1-ce commented Jul 3, 2024

I'll do a PR then, could you reopen issue please?

@folke folke reopened this Jul 3, 2024
folke pushed a commit that referenced this issue Jul 4, 2024
* Implement files option #39

* Remove debug statements and add readme example
@folke folke closed this as completed in #41 Jul 4, 2024
folke pushed a commit that referenced this issue Jul 6, 2024
🤖 I have created a release *beep* *boop*
---


##
[1.7.0](v1.6.0...v1.7.0)
(2024-07-04)


### Features

* added `files` option
[#39](#39)
([#41](#41))
([380e80d](380e80d))
* added support for luarocks installed with lazy
([e3d0d55](e3d0d55))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
folke pushed a commit that referenced this issue Jul 14, 2024
🤖 I have created a release *beep* *boop*
---


##
[1.7.0](v1.6.0...v1.7.0)
(2024-07-14)


### Features

* added `files` option
[#39](#39)
([#41](#41))
([380e80d](380e80d))
* added support for luarocks installed with lazy
([e3d0d55](e3d0d55))


### Bug Fixes

* **util:** notify
([a74b397](a74b397))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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

Successfully merging a pull request may close this issue.

2 participants