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

make it possible tu use :GpWhisper <LANGUAGE> #125

Merged
merged 3 commits into from
Jul 17, 2024

Conversation

teto
Copy link
Collaborator

@teto teto commented Apr 2, 2024

so this can be changed on the fly.

Ideally I would like to be able to pass it an existing file too but I wanted to do a minimum first contribution. Also I develop on top of #93 which doesn't help

@teto
Copy link
Collaborator Author

teto commented Jul 16, 2024

@Robitx you mentioned pending comments but I dont see any ? could you precise please

lua/gp/init.lua Outdated Show resolved Hide resolved
lua/gp/init.lua Outdated Show resolved Hide resolved
lua/gp/init.lua Outdated Show resolved Hide resolved
@Robitx
Copy link
Owner

Robitx commented Jul 16, 2024

@teto sorry, I've forgot the review in the pending state 🤦‍♂️

@teto
Copy link
Collaborator Author

teto commented Jul 16, 2024

ha yeah the log commands interrupt the user, quite bad ^^'''
I wish we could have logging to a file though, it's just too helpful to diagnose issues.
What do you think of vendoring https://github.com/nvim-neorocks/rocks.nvim/blob/master/lua/rocks/log.lua (or something else but there doesn't seem to be a clear winner among logging library yet, plenary.nvim''s is bad) ? could be for another PR or this one.

@Robitx
Copy link
Owner

Robitx commented Jul 16, 2024

@teto another PR, I can do the logging soon but I'm currently rewriting the Prompt function used in the hooks because the signature got a bit unwieldy with multiple providers and leads to bugs. (Sadly another necessary breaking change).

For logging I wouldn't drag another dependency just for this

  • adjusting M._log to append all messages to some configurable log file (defaulting to /tmp/) with max history size should be trivial.
  • all the messages could also be put into M._log_history list which would be part of the output of :GpInspectPlugin
  • and add M.debug which goes only into log file and _log_history

gp.nvim/lua/gp/init.lua

Lines 547 to 574 in 0878f2f

---@param msg string # message to log
---@param kind string # hl group to use for logging
---@param history boolean # whether to add the message to history
M._log = function(msg, kind, history)
vim.schedule(function()
vim.api.nvim_echo({
{ M._Name .. ": " .. msg, kind },
}, history, {})
end)
end
-- nicer error messages using nvim_echo
---@param msg string # error message
M.error = function(msg)
M._log(msg, "ErrorMsg", true)
end
-- nicer warning messages using nvim_echo
---@param msg string # warning message
M.warning = function(msg)
M._log(msg, "WarningMsg", true)
end
-- nicer plain messages using nvim_echo
---@param msg string # plain message
M.info = function(msg)
M._log(msg, "Normal", true)
end

@teto teto force-pushed the teto/whisper-dynamic-lang branch from 3cc206e to 2d45996 Compare July 17, 2024 09:49
@teto
Copy link
Collaborator Author

teto commented Jul 17, 2024

rebased, addressed comments and updated the doc. Tested locally with French and English. Worked nicely.

For logging I wouldn't drag another dependency just for this

I was not proposing to add a dependency (yet :) ) but just to copy/paste that file into our codebase.

@Robitx
Copy link
Owner

Robitx commented Jul 17, 2024

@teto btw. the doc/gp.nvim.txt is made automatically by a CI function, README is the source of truth from which it's made.

@teto teto force-pushed the teto/whisper-dynamic-lang branch from 2d45996 to 6a7a78f Compare July 17, 2024 10:03
@Robitx Robitx self-requested a review July 17, 2024 10:07
@teto
Copy link
Collaborator Author

teto commented Jul 17, 2024

How do you prefer to work ? once approved, the committer can selfmerge ?

@Robitx
Copy link
Owner

Robitx commented Jul 17, 2024

@teto I've enabled auto merge so next time, the approved PR should get merged automatically. With this one feel free to merge it.

@teto teto merged commit 49ded50 into Robitx:main Jul 17, 2024
1 check passed
@teto teto deleted the teto/whisper-dynamic-lang branch July 17, 2024 10:29
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.

2 participants