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

Add setting to override nonstandardSymbol Type #2327

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

niekschoemaker
Copy link

I'm not sure if I covered everything in the changes given.

But this feature would be helpful for FiveM development, since the backticks (`) are used for compile time hashing, so the type of that would be an integer and not string, this is causing some warnings here and there in code.

Let me know if I've missed anything or if anything else needs to be done for this pull request to be merged.

@sumneko
Copy link
Collaborator

sumneko commented Sep 14, 2023

I think this won't work. Have you tested it?

@niekschoemaker niekschoemaker marked this pull request as draft September 15, 2023 19:14
@niekschoemaker
Copy link
Author

I think this won't work. Have you tested it?

Yes sorry about that, I wanted to check in if this is a correct feature before committing fully, I have tested it a bit on my own branch, but without the config (not sure how to test this, so requires some figuring out on my part)

But I did run into some weird errors so I'll have a look, I converted it to a draft for the time being till I fully complete it.

@niekschoemaker niekschoemaker marked this pull request as ready for review September 18, 2023 15:50
@niekschoemaker
Copy link
Author

Alright, this is the working version as far as I can see.

Fixed some things with config template and tested it in vscode (by updating vscode-lua, will pull request that too if this gets accepted)

When the setting doesn't exist the plugin functions as normal, so nothing changes, but I can set it to override the type of "`" to be an integer which does exactly what it's supposed to.

@sumneko
Copy link
Collaborator

sumneko commented Sep 20, 2023

For your needs, I think using a plugin would be better.

  1. Create a plugin file in somewhere such is lua_plugin.lua with:
local function exampleHash(words)
    local result = 0
    for c in words:gmatch '.' do
        result = (result * 256 + string.byte(c)) & 0xFFFFFFFF
    end
    return result
end

function OnSetText(uri, text)
    local patchs = {}
    for pos1, words, pos2 in text:gmatch '()`(.-)`()' do
        patchs[#patchs+1] = {
            start  = pos1,
            finish = pos2 - 1,
            text   = tostring(exampleHash(words))
        }
    end
    if #patchs == 0 then
        return nil
    end
    return patchs
end
  1. Set config "runtime.plugin": "lua_plugin.lua"
  2. See result:
    image

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.

None yet

2 participants