Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add configuration value for what auto-require adds#3201

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
NyakoFox wants to merge1 commit intoLuaLS:master
base:master
Choose a base branch
Loading
fromNyakoFox:configurable-auto-require

Conversation

NyakoFox
Copy link
Contributor

@NyakoFoxNyakoFox commentedJun 13, 2025
edited
Loading

Auto-require always adds therequire function specifically. However, it's common in projects to have their own specialrequire functions, likeimport orinclude -- so this PR adds a configuration option which lets you change what it imports.

Lua.completion.requireFunction defaults to"require". I think I did this right?

This is open as a draft because I'm unable to test this -- I don't fully understand the environment or how to debug this project. If someone could test this, it'd be great. (The built exe did nothing when ran, unlike the exe included in VSCode... not really sure what's happening there.)

Auto-require always adds the `require` function specifically. However,it's common in projects to have their own special `require` functions,like `import` or `include` -- so this PR adds a configuration optionwhich lets you change what it imports.
Copy link

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

This PR introduces a configurable option to customize the auto-require insertion function, allowing users to override the default "require" with alternatives such as "import" or "include".

  • Updated autoRequire logic to fetch the function name from configuration
  • Added corresponding configuration entry in the template and updated documentation and locales
  • Updated changelog to highlight the new setting

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
script/core/command/autoRequire.luaUses config to dynamically set the require function in auto-require
script/config/template.luaAdds a new configuration setting for the require function
locale/*/setting.luaUpdates locale files with a new setting; translations need completing
doc/*/config.mdDocuments the new configuration option
changelog.mdUpdates changelog with new setting information
Comments suppressed due to low confidence (2)

script/core/command/autoRequire.lua:123

  • Consider adding unit tests to verify that the auto-require functionality correctly uses the configured function name instead of a hard-coded value.
local requireName = config.get(uri, "Lua.completion.requireFunction")

locale/zh-tw/setting.lua:182

  • Update the TODO translation in this locale to provide a proper translated string for clarity.
config.completion.requireFunction        = -- TODO: need translate!

@carsakiller
Copy link
Collaborator

I believeruntime.special already allows users to specify an alternative name forrequire, such asimport orinclude.

I think it would make more sense to build this functionality into that setting, rather than adding a whole new setting.

@NyakoFox
Copy link
ContributorAuthor

runtime.special exists to make variables act like certain other variables -- the user should use these two together, but I don't think they should be the same setting. You can make multiple variables act likerequire withruntime.special or make one variable act like another which isn'trequire, but this PR adds a setting for specifically the auto-require system which doesn't have much to do withruntime.special.

@NyakoFox
Copy link
ContributorAuthor

I do wonder actually -- could the auto completion system somehow be exposed to plugins? That'd solve the issue I'm trying to solve here, while also solving#3202. Since we have strict requirements for our codebase (and also mess with paths a little) it'd be great if we could handle how it works ourselves. Unfortunately I wouldn't know how to program that -- but that'd solve a lot of my problems, including some which I haven't talked about (mainly the path stuff), and I'm more than sure that this sort of system would solve problems for others as well.@sumneko I'm curious what you think about such a system; I was thinking for a bit that I'd make my own helper extension for my project, but something like this incorporated into the Lua language server itself would be a great step in customizability & allowing different setups than expected!

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

Copilot code reviewCopilotCopilot left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@NyakoFox@carsakiller

[8]ページ先頭

©2009-2025 Movatter.jp