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 Interactivity package #8922

Merged
merged 5 commits into from
Jul 3, 2024
Merged

Add Interactivity package #8922

merged 5 commits into from
Jul 3, 2024

Conversation

ichichikin
Copy link
Contributor

  • I'm the package's author and/or maintainer.
  • I have have read [the docs][1].
  • I have tagged a release with a [semver][2] version number.
  • My package repo has a description and a README describing what it's for and how to use it.
  • My package doesn't add context menu entries. *
  • My package doesn't add key bindings. **
  • Any commands are available via the command palette.
  • Preferences and keybindings (if any) are listed in the menu and the command palette, and open in split view.
  • If my package is a syntax it doesn't also add a color scheme. ***
  • If my package is a syntax it is named after the language it supports (without suffixes like "syntax" or "highlighting").
  • I use [.gitattributes][3] to exclude files from the package: images, test files, sublime-project/workspace.

My package is Interactivity.
This plugin allows you to run shell commands and scripts directly within the editor, providing their output right alongside your written content, making your workflow more dynamic and interactive.

@kaste
Copy link
Contributor

kaste commented Jun 17, 2024

Not gonna lie, that looks good (lgtm). I think the configuration is a bit awkward. E.g. you have

"text_shortcuts": "@ -> ##param##\n@@ -> chat4(r\"\"\"##param##\"\"\")",

and I wonder why that isn't just a mapping prefix: command. E.g. {"@": "##param##"}. I'm also not sure how I would define a command that runs Node instead of python. Or how I could add my own function, e.g. instead of chat4. Also ##param## looks unfamiliar (instead of, e.g., $param or ${param}) but that maybe makes sense in your context.

@kaste
Copy link
Contributor

kaste commented Jun 17, 2024

Ah, the entry here, add it sorted case-insensitive.

@ichichikin
Copy link
Contributor Author

@kaste I'm glad that you liked the package. I made changes to settings management as you suggested.

Regarding ##param##, I intentionally picked this unusual syntax to reduce the chance of interference with any possible REPLs.

For interacting with Node, please try these settings:

{
    "append_output": "",
    "environment_variables": {},
    "lines_to_suppress": 2,
    "output_filter": "^>\\s(?:\\.\\.\\.\\s)*",
    "prepend_output": " ",
    "shell": "node",
    "shell_params": [
        "-i"
    ],
    "shutdown_commands": ".exit",
    "startup_commands": "",
    "text_shortcuts": {
        "@": "##param##"
    }
}

If you want to add custom functions in Python, please follow these steps.

I'd be glad if you commit any useful modules for Node as well.

@kaste
Copy link
Contributor

kaste commented Jun 18, 2024

Ok, I see, you basically have to decide which language process you're gonna use, and replace most of the settings. My initial understanding was that you can have commands targeting different "shells"/servers at the same time. So as I understand it, it could also be

"configuration": {
	"python": {
		"shell_params": "-qi",
       ... lots more
	},
	"node": {
		"shell_params": "-i",
	}
}

and then you choose which one you use. Maybe it would be useful to restrict these to some view. Basically the user would specify a syntax/scope for which these "commands"/expansions are enabled. Take this as random notes how I understand the package.

The following two changes are required though:

  • As it is, you need to add an empty .no-sublime-package file to the plugin because the modules folder must be reachable as a normal directory. This is only true for the python configuration you ship by default of course. That's not ideal IMO but I don't have a ready-made solution to shared as well. An idea is that the package would copy the executable bits, i.e. the modules folder, to e.g. sublime.packages_path() / "Interactivity" / "modules" as that would be editable by the user without doing a pull request. (The package itself would be stored compressed in sublime.installed_packages_path() which is the default behavior if you don't set .no-sublime-package.)
  • Please lift the plugin to run on the 3.8 host. For that, create a file .python-version with its only contents 3.8\n in the root of your package.

@ichichikin
Copy link
Contributor Author

@kaste thank you for sharing your ideas!

I didn't want to overload the plugin too much, but I like your idea of accessing different shells simultaneously. I will consider this functionality for future releases.

I've added all the necessary files to my repository.

@kaste
Copy link
Contributor

kaste commented Jul 1, 2024

Check the sorting. #8922 (comment)

@ichichikin
Copy link
Contributor Author

@kaste, it looks like I'm missing something here. Could you please tell me more about what exactly should be sorted case-insensitively?

@kaste
Copy link
Contributor

kaste commented Jul 2, 2024

Then entries in i.json should be sorted by name.

@ichichikin
Copy link
Contributor Author

@kaste, got it, thanks! Done.

@kaste
Copy link
Contributor

kaste commented Jul 3, 2024

@braver I think that LGTM.

Copy link
Collaborator

@packagecontrol-bot packagecontrol-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated testing result: WARNING

Repo link: Interactivity
Results help

Packages added:
  - Interactivity

Processing package "Interactivity"
  - WARNING: '.no-sublime-package' is defined. Please verify that it is *really* necessary

@braver
Copy link
Collaborator

braver commented Jul 3, 2024

@kaste , thanks, your help here is really appreciated 👍🏻

@braver braver merged commit 31723d0 into wbond:master Jul 3, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants