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

clink support #2665

Open
mcexit opened this issue Dec 28, 2024 · 5 comments
Open

clink support #2665

mcexit opened this issue Dec 28, 2024 · 5 comments
Labels
cmd-clink enhancement New feature or request fund Fundable with polar.sh

Comments

@mcexit
Copy link

mcexit commented Dec 28, 2024

Request

Clink combines the native Windows shell cmd.exe with the powerful command line editing features of the GNU Readline library, which provides rich completion, history, and line-editing capabilities.

Clink offers robust completion configuration utilizing Lua. It is already compatible with Starship. This request is to add carapace support for Clink.

Proposed solution

The documentation for adding completions can be found here. The solution is for either the author of carapace-bin, myself or another contributor to take on the task of adding Clink as a shell for completion support.

Anything else?

No response

Polar

Fund with Polar
@mcexit mcexit added enhancement New feature or request fund Fundable with polar.sh labels Dec 28, 2024
@rsteube
Copy link
Member

rsteube commented Dec 28, 2024

Looks doable, though painful (windows and me aren't the best friends 😄 ).

  • Usage Hint for usage/errors
  • Word Breaks can be disabled
  • Colors seems similar to zsh
  • Function to provide the dynamic completion (got word, linestate,...)
  • load to invoke carapace
  • builder to return the results (got display, description,...)

I don't see yet where you can add a completion for any position (e.g. .addargany).
Basic example has a strict flag/argument structure.
Carapace is detached from that as it handles such things itself.
So for clink everything would be simply a positional argument.

edit: ok there's loop for that

@rsteube
Copy link
Member

rsteube commented Dec 28, 2024

rough prototype:

local function carapace(word, word_index, line_state, match_builder) 
  args = { "carapace", "git", "fish", "\"\"" } 
  for i = 2,word_index,1 do 
    table.insert(args, line_state:getword(i)) 
  end 
  -- table.insert(args, word) 
 
  output = io.popen(table.concat(args, " ")):read("*a") 
  for line in string.gmatch(output, '[^\r\n]+') do 
    -- match_builder:addmatch(line) 
    match_builder:addmatch(string.gsub(line, '\t.*', "")) 
  end 
   
  return true 
end 
 
clink.argmatcher("git") 
:addarg({ carapace }) 
:loop(1)

@rsteube
Copy link
Member

rsteube commented Dec 28, 2024

Started work in carapace-sh/carapace#1067 .
io.popen taking a single string as argument will pose some trouble.
Also gotta see what's best to pass data between carapace and the lua script.
Json is probably the easiest, but needs an external library.

I think there are some quick wins, but fully fledged support will take a while.
Help on it is appreciated.

@mcexit
Copy link
Author

mcexit commented Dec 28, 2024

Amazing work already and thanks for jumping on it so quick! I'll gladly help out but its probably going to be a few days for me before I can commit. I don't use Lua that often either unless I'm trying to mod a game or something, but I've played around with it in my Vim & Neovim configs in the past.

I'll prob throw some questions at Gemini, Claude or ChatGPT if I get stuck, but I'll make sure that I understand what it is doing & is efficient (not copy & paste). That is if you don't get to it first. Feel free to hold off if you have other things to attend to. You're already spending quite a bit of time for the community, and deserve to have others contributing.

In the off chance as well, I see that Clink receives updates pretty regularly and the author may be interested in sharing some ideas. Your project has been so helpful. So I may see about opening an issue there linking to your work thus far, especially if it looks like Clink may need some changes to have proper support.

When you said earlier that "windows and me aren't the best friends," I totally get it! I seriously feel bad if you're doing this work if you're not running Windows regularly. I have been a long time Linux user and know that Windows is hostile & invasive, but at some point I needed to use it again for Adobe & all that crap, where there is nothing comparable on Linux. I wish more than anything GPU manufacturers would stop being so monopolistic & antitrust and provide vGPU support on consumer cards. At least that way I would have GPU acceleration in my apps without needing a secondary video card.

@rsteube
Copy link
Member

rsteube commented Dec 28, 2024

No worries, I'm just doing a short spike to see if it's feasible.
Will gonna take a while anyway where I'm jumping between this and other things 😁 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmd-clink enhancement New feature or request fund Fundable with polar.sh
Projects
None yet
Development

No branches or pull requests

2 participants