silicon icon indicating copy to clipboard operation
silicon copied to clipboard

Add support for plaintext

Open ad-si opened this issue 1 year ago • 2 comments

I think all of those should work and simply not highlight the text:

silicon -l txt
silicon -l text
silicon -l plaintext

ad-si avatar Apr 12 '24 11:04 ad-si

I just bumped into a usecase for this as well. Has anyone found a workaround yet?

I tried by putting the bat syntax-file for plaintext (https://github.com/sublimehq/Packages/blob/759d6eed9b4beed87e602a23303a121c3a6c2fb3/Text/Plain%20text.tmLanguage) inside ~/.config/silicon/syntaxes and ran silicon --build-cache, but it does not recognise it.

For my usecase at the moment using markdown as language was enough, but it won't always be. Hopefully this could become a feature, sadly I cannot do this myself, as Rust is not something I can.

BWindey avatar Jan 28 '25 20:01 BWindey

@BWindey and anyone else wanting to accomplish this, here is how you can add plain text support to Silicon:

  1. Navigate to Silicon's config directory[^1].
  2. Create two subdirectories: themes and syntaxes.
  3. In the syntaxes directory, create a file named text.sublime-syntax.
  4. Paste the following into the file:
%YAML 1.2
---
name: Plain Text
scope: source.txt
file_extensions:
    - txt
contexts:
  main:
    - match: '.'
      scope: text.txt
  1. Navigate back to the config directory and run silicon --build-cache.
  2. Test by running Silicon on a .txt file or by using --language txt or --language "Plain Text".

You can add entries to the file_extensions key in the above YAML to make Silicon auto-recognize other file types as plain text (like READMEs or license files). You can also change the name key to something else (e.g. name: Normal Text would mean using --language "Normal Text" when running Silicon.

[^1]: This is the parent directory displayed when running silicon --config-file. It is %USERPROFILE%\AppData\Local\silicon on Windows, and probably ~/config/silicon on Linux.

freebird-2 avatar Jun 22 '25 06:06 freebird-2