Skip to content

Make workspace.checkThirdParty a string enum #2354

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

Merged
merged 2 commits into from
Oct 19, 2023

Conversation

9999years
Copy link
Contributor

@9999years 9999years commented Sep 30, 2023

This lets you skip the "apply third party library to workspace configuration" prompt.

The value of Lua.workspace.checkThirdParty can now be one of:

  • Ask (ask every time; this is equivalent to true)
  • Apply (always apply third-party libraries and set the workspace
    configuration)
  • ApplyInMemory (always apply third-party libraries but don't set the
    workspace configuration)
  • Disable (don't ask and don't apply; this is equivalent to false)

Backwards compatibility with the old boolean configuration values is maintained; true is treated as Ask and false is treated as Disable.

I need some help translating the Taiwanese, Mandarin, and Portugese, but I copied the English in there as a standin -- presumably it's better to have some documentation in the wrong language which can be machine-translated than to have missing information.

I've built and tested this on my machine.

@sumneko
Copy link
Collaborator

sumneko commented Oct 7, 2023

To translate, please modify the file in the locale directory (only need to modify one language file), and then execute the locale and build-doc debugger tasks.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not modify the file format.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, sorry, I have my editor configured to format-on-save with stylua.

@9999years
Copy link
Contributor Author

How do I execute the build-doc debugger task? I can't seem to run it with lua or luajit:

$ luajit tools/build-doc.lua
luajit: tools/build-doc.lua:3: module 'bee.filesystem' not found:

@9999years 9999years force-pushed the dont-ask-third-party branch from 1ab45a7 to 2b21dbe Compare October 10, 2023 20:36
@sumneko
Copy link
Collaborator

sumneko commented Oct 11, 2023

Use "./bin/lua-language-server" tools/locale.lua and "./bin/lua-language-server" tools/locale.lua

@9999years
Copy link
Contributor Author

Thanks! I ran the locale and debugger tasks.

@@ -523,7 +523,7 @@ math.maxinteger['>5.3'] =
'Retorna o valor máximo para um inteiro.'
math.min =
'Retorna o argumento com o valor mínimo de acordo com o operador `<`.'
math.mixinteger['>5.3'] =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this was a typo, it was making the locale script crash.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have resolved it, please pull latest commits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Rebased, the diff looks a lot cleaner now.

This lets you skip the "apply third party library to workspace
configuration" prompt.
@9999years 9999years force-pushed the dont-ask-third-party branch from c0333c6 to 3bbc8dd Compare October 18, 2023 17:01
@sumneko sumneko merged commit 13aebe5 into LuaLS:master Oct 19, 2023
@sumneko
Copy link
Collaborator

sumneko commented Oct 19, 2023

Thank you!

wincent added a commit to wincent/wincent that referenced this pull request Oct 21, 2023
…spam

As suggested here:

- https://smarttech101.com/nvim-lsp-configure-language-servers-shortcuts-highlights/

> If you don’t know what LÖVE/ Luv, and Luassert are, chances are you
> don’t need them. So, disable them permanently

Apparently they are a game engine and an assertion library,
respectively.

Note that lua-language-server only a few days ago changed
`checkThirdParty` from a boolean to a string enum in:

- LuaLS/lua-language-server#2354

but backwards compatibility is maintained (`false` should be equivalent
to `"Disable"`), so I'm going with `false` to have this work in as many
places as possible.
@nfwyst
Copy link

nfwyst commented Nov 7, 2023

true/false not working

@schardev
Copy link

schardev commented Nov 7, 2023

true/false not working

Yeah. Should've kept it as backwards compatible instead of breaking current setups.

@9999years
Copy link
Contributor Author

@nfwyst @schardev Hmm, I intended to keep this backwards compatible:

local checkThirdParty = config.get(uri, 'Lua.workspace.checkThirdParty')
-- Backwards compatability: `checkThirdParty` used to be a boolean.
if not checkThirdParty or checkThirdParty == 'Disable' then
return
elseif checkThirdParty == true then
checkThirdParty = 'Ask'
end

I think the issue is that the config value is now defined as a string:

['Lua.workspace.checkThirdParty'] = Type.String >> 'Ask' << {
'Ask',
'Apply',
'ApplyInMemory',
'Disable',
},

So when the config is loaded as a boolean, it gets converted to a string:

register('String', '', function (self, v)
return type(v) == 'string'
end, function (self, v)
return tostring(v)
end)

@9999years 9999years deleted the dont-ask-third-party branch November 7, 2023 17:11
9999years added a commit to 9999years/lua-language-server that referenced this pull request Nov 7, 2023
I attempted to maintain backwards compatability in LuaLS#2354 but didn't
fully understand the config type system.
@9999years
Copy link
Contributor Author

Attempted fix in #2406 but I haven't tested it yet.

minghongx added a commit to minghongx/nvim that referenced this pull request Nov 8, 2023
Julian added a commit to Julian/dotfiles that referenced this pull request Nov 9, 2023
9999years added a commit to 9999years/lua-language-server that referenced this pull request Nov 9, 2023
I attempted to maintain backwards compatability in LuaLS#2354 and LuaLS#2406 but
didn't fully understand the config type system.

This approach uses `Type.Or` and I even tested it to confirm that it
works!

Thanks to @pysan3 for pointing out how a default would be used for
invalid types and to @sumneko for pointing out `Type.Or`.
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

Successfully merging this pull request may close these issues.

4 participants