kwakzalver / duckytype.nvim

NeoVim plugin simulating monkeytype.com
54 stars 2 forks source link

Code snippet geme? #4

Open adamkali opened 1 year ago

adamkali commented 1 year ago

Any intention of adding games for writing dummy code? Rust snippet for example: :DuckyCode

pub fn foo(bar: &str, baz: bool) {
    if baz {
        printf!(bar)
    }
}

Could probably be done with some sort of lua string template and then passing the English language constants into the template and writing the result to the string. Then use random to actually loop through the snippets. Here is my best guess without doing any serious testing:

snippet = [[
    pub fn %s(%s: &str, %s: bool){
        if %s {
            printf!("%s")
         }
    }
]]

local function setup_code_snippet(code_snippet, table_constants) { 
   string.format(code_snippet, table.unpack(table_constants))
}

Anyways great work on this project!

kwakzalver commented 1 year ago

Sorry for not responding earlier. I read it, then forgot due to new year etc.

It does sound like it could be a fun addition, but I don't want to put in a lot of time in making it happen. If anyone else feels like they want to pick it up I'll happily merge later.

adamkali commented 1 year ago

I will start working on it seriously this weekend after if finish my company's sprint this week.

Initial looks into it will just need to make 3 new functions. (New Game, Start Game, and update maybe correct me if I am wrong lol)

Glad to here about the intrest!