如何在没有包控制的情况下安装 sublime 包?

How to install sublime package without package control?

如何在没有包控制的情况下手动安装 sublimetext3 包。我正在尝试修复现有包中的错误,因此我需要一种方法来测试我的更改。

命名 zip 文件时应遵循哪些命名约定? 我把它放在哪里? 我还需要做什么其他配置?

下载 ZIP,然后将其放在您的 Packages 目录中,可以通过执行 Sublime Text -> Preferences -> Browse Packages...

找到

what are the naming conventions to be followed when naming the zip file? Where do I place it? what other configurations I have to do?

这实际上取决于您下载的具体包。对于某些包,您可以随意命名。对于其他人,名称必须准确。如果您从 GitHub 手动下载这些包,我强烈建议您阅读 README 中的文档。他们通常提供手动安装说明。例如,如果您想手动下载 Spacegray 主题,它会告诉您下载 ZIP,解压缩文件夹,然后将其重命名为 Theme - Spacegray

根据您的 OS,您的包目录可能是其中之一,对于大多数包,只需将内容提取到此文件夹(以其根文件夹作为名称)

Linux: ~/.config/sublime-text-3/Packages

OS X: ~/Library/Application Support/Subime Text 3/Packages

Windows: %APPDATA%\Sublime Text 3

I am trying to fix a bug in an existing package, therefore I need a way to test my changes.

我遇到了同样的情况。接受的答案对我不起作用,因为包控制会自动删除该文件夹。我发现这很有用:

https://packagecontrol.io/docs/customizing_packages

Sublime Text 3 offers the most options for overriding a package. By default, packages will be installed by placing a .sublime-package file in the Install Packages/ folder. Then users may override individual files in the package by creating a folder Packages/{Package Name}/ and placing edited files in there.

另一种方法是 PackageResourceViewer,它允许您从包中提取和覆盖单个文件,包括内置包。

到目前为止,我认为最好的答案是

also has some really useful information, such as the link to the spacegray package which states:

Manual

You can also install the theme manually:

  1. Download the .zip
  2. Unzip and rename the folder to Theme - Spacegray
  3. Copy the folder into Packages directory, which you can find using the menu item Sublime Text -> Preferences -> Browse Packages...

这是我第一次了解到 Packages 文件夹的存在以及如何找到它的路径的地方。

结合使用这些答案,加上大约 1 个周末的时间来学习 Sublime Text 包和语法高亮显示的工作原理,我写了以下“Developer Notes & Package Development Tutorial", on GitHub, as well as these "manual installation" 说明。

简而言之,要使用 OUT Package Control“安装包”,您需要做的就是将包放入您的 Sublime Text Packages 文件夹,其路径可以通过 Preferences --> Browse Packages... 找到。文件夹名称可以是任意。如果你想 override 一个 already-installed 之前由 Package Control 以“打包”(zip 文件)格式安装的包。

除了我的教程,你应该学习的主要 link 是:https://packagecontrol.io/docs/customizing_packages.

1。如何手动安装包

以下是我 manual installation instructions and tutorial.

的一些关键引述和说明

再次注意,我只要求 Packages 文件夹中的名称是下面说明中的 gcode 之类的特定名称,因为我的说明旨在 覆盖 Package-Control-installed 包 reader 可能已经安装。如果你是第一次安装,制作一个新包,你在Packages文件夹中使用的文件夹名称可以是任何东西.

2. Manual installation

In Sublime Text, find the path to your Packages folder by clicking Preferences --> Browse Packages.... This will open up your GUI file manager to the path where Sublime Text packages are stored. For me on Linux Ubuntu 20.04, that's /home/gabriel/.config/sublime-text-3/Packages (even though I am running Sublime Text 4).

Now, extract this package to that folder.

Option 1: the GUI way: click the green "Code" button above --> "Download ZIP" --> save the zip file, extract it to your Packages path above, and rename it to gcode.

OR Option 2 [what I prefer]: the command-line way:

# --------------
# Option 2.A: clone the repo directly into your "Packages" dir
# --------------

# cd to the Packages dir (change this path according to your Packages path above)
cd "$HOME/.config/sublime-text-3/Packages"
# clone the repo
git clone https://github.com/ElectricRCAircraftGuy/sublime_gcode.git
# rename the repo dir to "gcode"
mv sublime_gcode gcode

# --------------
# OR Option 2.B [what I prefer]: clone the repo into wherever you want, and then
# symlink it into your "Packages" dir
# --------------

# clone repo into ~/dev
mkdir -p ~/dev
cd ~/dev
git clone https://github.com/ElectricRCAircraftGuy/sublime_gcode.git
# now symlink it into your Packages dir
ln -si ~/dev/sublime_gcode ~/.config/sublime-text-3/Packages/gcode

That's it! The gcode entry is now instantly available in your syntax highlighting menu.

Developer Notes & Package Development Tutorial

...
...
...

Sublime Text packages and syntax highlighting--how it all works

这里有一些 关于 Sublime Text 包和包控制如何工作的非常重要的注意事项:

1. Sublime Text packages

Any folder inside of your Sublime Text Packages folder (found via Preferences --> Browse Packages...) is automatically instantly loaded by Sublime Text as a "package".

Packages installed by the Package Control package, however, come in two types:

  1. Packed: most packages installed by Package Control are "packed" into a zip file named packageName.sublime-package and are located inside the Installed Packages dir which is at the same level as the Packages dir.
    1. If you manually create a dir inside the Packages dir and name it packageName (to match the packed file above), then any files in it with the same name as those in the packed package will override those in the packed package. See the "Overrides" section here: https://packagecontrol.io/docs/customizing_packages.
  2. Unpacked: any package which is installed in the Packages dir is unpacked.
    1. Developers can tell Package Control to unpack a package installed by Package Control by placing a file named .no-sublime-package at the root of their repo. See here: https://packagecontrol.io/docs/submitting_a_package.
    2. Unpacked packages are required if they contain binary executables which need to be run by the system, for instance, as they apparently can't run from inside the packed zip file.

2. Syntax highlighting

希望我把这一切都弄清楚了。

如果您想详细了解 Sublime Text 中的语法高亮,以及它如何映射到配色方案中的 scope 个条目,请阅读我的教程。

2。测试您的更改

I am trying to fix a bug in an existing package, therefore I need a way to test my changes.

另见 this section in my tutorial:

To modify and test changes to this package locally...

...in case you'd like to change it or contribute to it, follow the "manual installation" instructions above. If you have already installed it via Package Control, then what is in your /home/$USERNAME/.config/sublime-text-3/Packages/gcode folder will override what is in your /home/$USERNAME/.config/sublime-text-3/Installed Packages/gcode.sublime-package zip file which Package Control installed, so long as the folder and file names are the same.

Modify any files in the Packages/gcode dir as desired. Each time you save, the changes will instantly be reflected in all Sublime Text editors you have open. As a quick test:

  1. Open a gcode file.
  2. Click your cursor on some text in the file.
  3. Use the Tools --> Developer --> Show Scope Name trick to see what the scope is for that text.
  4. Open the corresponding *.sublime-syntax file.
  5. Change or delete the regular expression in the match entry for that corresponding scope you just found, so that it no longer matches the text on which you placed your cursor.
  6. Save the *.sublime-syntax file and you will instantly see the formatting of that text in the gcode file change.
  7. Undo your change to the match entry and save again. The formatting will return to how it was.
  8. Go to Preferences --> Customize Color Scheme, and add a custom rules entry for that scope, with new formatting for that scope. Save it and watch the formatting instantly change again. Delete that custom entry when done, if desired.