Git Product home page Git Product logo

Comments (15)

s-kostyaev avatar s-kostyaev commented on August 11, 2024 1

Hi! I really like this cool project. And I wrote simple wrapper for emacs - https://github.com/s-kostyaev/comby.el

from comby.

rvantonder avatar rvantonder commented on August 11, 2024 1

@s-kostyaev this is great. I'll add a section about editor support to the comby.dev site and link to this project.

from comby.

rvantonder avatar rvantonder commented on August 11, 2024

That would be wonderful. Let's use this issue to track progress. Perhaps external contributors may be interested in implement these features, especially since others may be more familiar with the editors. Right now there are a few core features planned in the roadmap, which may get updated with editor extensions over time.

from comby.

tjbell avatar tjbell commented on August 11, 2024

Onivim might be a good target editor as well. It is written in Reason so it might be an easier path to integration.

from comby.

giltho avatar giltho commented on August 11, 2024

@tjbell Onivim will (or maybe already does) support vscode extensions.

I've started writing a vscode extension. There are a lot of choices I don't like, but vscode doesn't allow to write a nice search and replace extension. Its own search-and-replace is kinda "hardcoded".
I published the extension, here
I used one of the favicon from comby.dev as logo.
Any PR is welcome, or issue. And also, I haven't licensed it yet, and I don't really know how I should proceed with regard to the logo there's probably a copyright or something.
Note that I just worked a few hours on this, it's really a prototype, I'm not even cleaning properly the strings for the command line call. I'm mostly exploring how this should be done

from comby.

rvantonder avatar rvantonder commented on August 11, 2024

@giltho: thanks for posting your update here. This is really neat, especially the selective replace parts in the UI!

I used one of the favicon from comby.dev as logo.

That's fine. I'll update CONTRIBUTING.md to make things around this sort of thing clear :)

Any PR is welcome, or issue. And also, I haven't licensed it yet, ... Note that I just worked a few hours on this. I'm mostly exploring how this should be done.

Sounds good. Keep us posted as you develop a better idea of how you plan to go about things.

from comby.

st-schneider avatar st-schneider commented on August 11, 2024

@giltho I really like the extension, but I also need more instructions/examples for JavaScript from @rvantonder since I tried something like const :[x] = ':[y]'; and it does not match all constants that have string but pretty much everthing ???

from comby.

rvantonder avatar rvantonder commented on August 11, 2024

Hi @bm-stschneider -- please bring questions about usage and patterns over to the gitter channel.

from comby.

stefanbuck avatar stefanbuck commented on August 11, 2024

I think a Comby VSCode extension is crucial to get much more adoption. Also it ease the experience for existing comby users as well. I use https://comby.live quite a lot, similar to https://regexr.com/ when writing / testing regular expressions. However, translating the template into a bash command is kind of complicated Just noticed the "Run in Terminal" button for the first time ๐Ÿ˜ . Anyway, a proper integration into VSCode would be really useful IMO.

vscode doesn't allow to write a nice search and replace extension. Its own search-and-replace is kinda "hardcoded".

Does it have to be integrated into the native search and replace bar? Sure, this would be nice, but what if Comby adds a new panel like shown in this quick mockup.

Group 2

from comby.

giltho avatar giltho commented on August 11, 2024

Would be great to do that.
When I wrote the "extension" (very much in quote since it's barely a proof of concept...), such custom panels weren't possible.

I think it is still the case that, so far, the only custom panel you can create is a tree view. Tree views don't have inputs...
VScode doesn't expose an API to extend the search panel either, so I don't see much of an elegant solution for now.

The perfect solution would be to make the search view customisable in my opinion. That would mean writing a big PR to VSCode, but I'm pretty sure the VSCode team would be happy merging any elegant solution. If I ever have time, I'll probably try, but right now I can't :(

By the way, @rvantonder, I haven't pushed to the extension for quite a while, I don't know when I'll have time again to work on it. If at any moment you wish that I transfer the ownership of the project or remove the extension or any other thing, please do tell me :) I do wish to take any action that you feel is the best for comby

from comby.

vindarel avatar vindarel commented on August 11, 2024

Hello there, I started to integrate Comby into my workflow too, and I wrote a set of rules for Lisp (only Common Lisp so far) with an integration with Emacs. It differs from comby.el in that the latter gives you a prompt to write your own rules on the fly, while colisper comes with a set of rules for CL, an interface to select them, and a script to run them on the terminal. It needs more work but I use it.

from comby.

s-kostyaev avatar s-kostyaev commented on August 11, 2024

@vindarel Hi! You can use comby.el not only for interactive usage, but also as library to exucte set of rules. I was thinking of creating package for simple golang refactoring on top of comby.el, but I have found already implemented features inside gopls.

from comby.

vindarel avatar vindarel commented on August 11, 2024

I'll look into it then, thanks.

from comby.

felixfbecker avatar felixfbecker commented on August 11, 2024

I think it's possible nowadays to add a WebView to the sidebar in VS Code, i.e. you could implement an interface similar to the search sidebar in HTML (even optimize it for comby, e.g. use multi-line text inputs): microsoft/vscode@6b083b4
And maybe the results could actually use a tree view that opens diffs for each file?

from comby.

moonbaseDelta avatar moonbaseDelta commented on August 11, 2024

Hi all, I guess that more reliable approach will be use select-n-replace-with-piped-output method.

For VS Code there is that extension available: https://github.com/popurax/vscode-filtertext
It has the idea, but does not work properly: it should pipe selection to any particular shell or binary, and with flags also. I'll try to repair that extension in spare time though.

For Notepad++ there is a NPPExec plugin that do all right.


I do it on Win10 machine with Ubuntu 20.04 on top of WSL2, pwsh it's just a name for PowerShell7 given by MS.

NPPExec script is this (taken from https://community.notepad-plus-plus.org/topic/16158/is-it-possible-to-run-text-through-an-external-program/3):

cmd.exe /c exit %RANDOM%	  // cannot access $(SYS.RANDOM) directly through NppExec, but can tell cmd.exe to return it as a value
set destfile = $(SYS.TEMP)\NppFilterDestinatino_$(EXITCODE).tmp  // create random destfile name
set sourcefile = $(SYS.TEMP)\NppFilterSource_$(EXITCODE).tmp     // create associated sourcefile name
sel_saveto "$(sourcefile)" :a	                                                           // save selection to the sourcefile	(use :a to save as ansi, to prevent unicode prefix รฟรพ getting embedded)
pwsh c:\yer_path\script.ps1  "$(destfile)" "$(sourcefile)" 	//
sel_loadfrom "$(destfile)"	 
pwsh -command "Remove-Item -Force '$(sourcefile)'"
pwsh -command "Remove-Item -Force "$(destfile)"  

And the .ps1-script body will be like:

$dest_file   = $args[0]
$source_file = $args[1] 
  
$cmd0 = "/mnt/c/yer_path/shell-script.sh" # or whatever path you enjoy to have there
$listo=@( 
    $cmd0 
    $dest_file.Replace('\', '\\')
    $source_file.Replace('\', '\\')
    (Get-Content -Path $source_file -Raw)
)
# .Replace('\', '\\') - 'cause single slash get lost during arg-pass

Start-Process   wsl -ArgumentList $listo -NoNewWindow -PassThru -Wait | Out-Null

WSL script be like:

# mutating windows-path to wsl-mnt path
destfile=$(wslpath -a "$1")
srcfile=$(wslpath -a "$2") 

# whatever template and rule you wanted, by now it just make 'a s d f' -> 's d f'
comby_res=$(comby 'a :[1]' ':[1]' -f $srcfile -stdout -matcher .generic) 

echo -e "\n [ Here it goes ]" > $destfile 
echo "$comby_res" >> $destfile
echo -e " [ over. ]" >> $destfile

With a setup like that you can call literally any scenario, not only with comby, but mixing comby with python, semgrep, sed, awk, whatever. And those scripts may just be called by their purposes, like 'remove null-checks' or 'refactor my fancy stuff into proper code-style approved code-piece'.

Of cource in that manner you can run this on any shells and machines, not just Win10+pwsh+wsl.


So, in my opinion the extension for VS Code \ vim \ other should work in the same fashion. May be with proper sctucture of final .sh-scripts logic and special tab-layout for editing this. It will be much more flexible and more in the spirit of comby than just comby-extension.

from comby.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.