Skip to content

Commit

Permalink
refactor: remove guesslang
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <[email protected]>
  • Loading branch information
jfcherng committed Feb 18, 2024
1 parent 76de1e2 commit dbb2ade
Show file tree
Hide file tree
Showing 18 changed files with 1 addition and 817 deletions.
103 changes: 1 addition & 102 deletions AutoSetSyntax.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,8 @@
"selector": "text.plain",
"match": "all",
"rules": [
// the guesslang server does a better job at guessing JavaScript vs TypeScript
{
"constraint": "is_guesslang_enabled",
"constraint": "is_magika_enabled",
"inverted": true
},
{
Expand Down Expand Up @@ -703,105 +702,5 @@
"winregistry": ["scope:source.reg"],
"xml": ["scope:text.xml"],
"yaml": ["scope:source.yaml"]
},

///////////////////////////////////////
// Guesslang settings (experimental) //
/////////////////////////////////////////////////////////////////////////
// You have to restart ST after modifying any of guesslang's settings. //
/////////////////////////////////////////////////////////////////////////

// To use this feature, you have to install the server.
// @see https://jfcherng-sublime.github.io/ST-AutoSetSyntax/experimental/ml-based-syntax-detection/#prerequisites
"guesslang.enabled": false,
// The path of the node-like executable. Leave it blank for auto determination.
"guesslang.node_bin": "",
// Extra command line arguments for invoking the node-like executable.
"guesslang.node_bin_args": [],
// The port number which should be used by the guesslang server.
// You can use a negative number for auto determination.
"guesslang.port": -1,
"guesslang.syntax_map": {
"asm": [
// no good way to do this?
"scope:source.asm.x86_64",
"scope:source.asm.arm",
"scope:source.rvasm",
"scope:source.assembly"
],
"bat": ["scope:source.dosbatch"],
"c": ["scope:source.c"],
"cbl": ["scope:source.cobol"],
"clj": ["scope:source.clojure"],
"cmake": ["scope:source.cmake"],
"coffee": ["scope:source.coffee"],
"cpp": ["scope:source.c++"],
"cs": ["scope:source.cs"],
"css": [
// SCSS is a superset and this server can't distinguish SCSS and CSS
"scope:source.scss",
"scope:source.css"
],
"csv": ["scope:text.advanced_csv", "scope:text.csv"],
"dart": ["scope:source.dart"],
"dm": ["scope:source.dm"],
"dockerfile": ["scope:source.dockerfile"],
"erl": ["scope:source.erlang"],
"ex": ["scope:source.elixir"],
"f90": ["scope:source.modern-fortran"],
"go": ["scope:source.go"],
"groovy": ["scope:source.groovy"],
"hs": ["scope:source.haskell"],
"html": ["scope:text.html.basic"],
"ini": ["scope:source.ini"],
"java": ["scope:source.java"],
"jl": ["scope:source.julia"],
"js": ["scope:source.js"],
"json": ["scope:source.json"],
"kt": ["scope:source.Kotlin"],
"lisp": ["scope:source.lisp"],
"lua": ["scope:source.lua"],
"makefile": ["scope:source.makefile"],
"matlab": ["scope:source.matlab"],
"md": ["scope:text.html.markdown"],
"ml": [], // what is this?
"mm": ["objective-c"],
"pas": ["scope:source.pascal"],
"php": ["scope:embedding.php", "scope:text.html.php"],
"pl": ["scope:source.perl"],
"pm": [], // what is this?
"prolog": ["scope:source.prolog"],
"ps1": ["scope:source.powershell"],
"py": ["scope:source.python"],
"r": ["scope:source.r"],
"rb": ["scope:source.ruby"],
"rs": ["scope:source.rust"],
"scala": ["scope:source.scala"],
"sh": ["scope:source.shell.bash"],
"sql": ["scope:source.sql"],
"swift": ["scope:source.swift"],
"tex": ["scope:text.tex.latex"],
"toml": ["scope:source.toml"],
"ts": ["scope:source.ts"],
"v": ["scope:source.verilog"],
"vba": ["scope:source.vbs"],
"xml": ["scope:text.xml"],
"yml": ["scope:source.yaml"],
// extra from vscode-regexp-languagedetection (modelLangToVSCodeLang)
"coffeescript": ["=coffee"],
"csharp": ["=cs"],
"erlang": ["=erl"],
"haskell": ["=hs"],
"javascript": ["=js"],
"markdown": ["=md"],
"objective-c": ["=mm"],
"perl": ["=pl"],
"powershell": ["=ps1"],
"python": ["=py"],
"ruby": ["=rb"],
"rust": ["=rs"],
"shellscript": ["=sh"],
"typescript": ["=ts"],
"yaml": ["=yml"]
}
}
12 changes: 0 additions & 12 deletions docs/src/configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -497,18 +497,6 @@ To edit project settings, go to `Project` » `Edit Project`.

If `case_insensitive` is not provided, it will be `true` on Windows but `false` on other OSes.

#### `is_guesslang_enabled`

!!! example

```js
{
"constraint": "is_guesslang_enabled",
}
```

Test whether the `guesslang` server is enabled.

#### `is_hidden_syntax`

!!! example
Expand Down
45 changes: 0 additions & 45 deletions docs/src/experimental/ml-based-syntax-detection.md

This file was deleted.

8 changes: 0 additions & 8 deletions menus/Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@
"caption": "AutoSetSyntax: Download Dependencies",
"command": "auto_set_syntax_download_dependencies",
},
{
"caption": "AutoSetSyntax: Download Guesslang Server",
"command": "auto_set_syntax_download_guesslang_server",
},
{
"caption": "AutoSetSyntax: Restart Guesslang Server",
"command": "auto_set_syntax_restart_guesslang",
},
{
"caption": "AutoSetSyntax: Settings",
"command": "edit_settings",
Expand Down
8 changes: 0 additions & 8 deletions plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
AutoSetSyntaxCreateNewMatchCommand,
AutoSetSyntaxDebugInformationCommand,
AutoSetSyntaxDownloadDependenciesCommand,
AutoSetSyntaxDownloadGuesslangServerCommand,
AutoSetSyntaxRestartGuesslangCommand,
run_auto_set_syntax_on_view,
)
from .constants import PLUGIN_CUSTOM_MODULE_PATHS, PLUGIN_NAME, PLUGIN_PY_LIBS_DIR
Expand Down Expand Up @@ -51,8 +49,6 @@
"AutoSetSyntaxCreateNewMatchCommand",
"AutoSetSyntaxDebugInformationCommand",
"AutoSetSyntaxDownloadDependenciesCommand",
"AutoSetSyntaxDownloadGuesslangServerCommand",
"AutoSetSyntaxRestartGuesslangCommand",
# ST: listeners
"AioSettings",
"AutoSetSyntaxEventListener",
Expand Down Expand Up @@ -83,7 +79,6 @@ def _plugin_loaded() -> None:

if get_merged_plugin_setting("run_on_startup_views"):
sublime.set_timeout_async(_run_on_startup_views)
sublime.run_command("auto_set_syntax_restart_guesslang")


def plugin_unloaded() -> None:
Expand All @@ -93,9 +88,6 @@ def plugin_unloaded() -> None:
for window in sublime.windows():
tear_down_window(window)

if G.guesslang_server:
G.guesslang_server.stop()


def _settings_changed_callback(window: sublime.Window) -> None:
clear_all_cached_functions()
Expand Down
4 changes: 0 additions & 4 deletions plugin/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
)
from .auto_set_syntax_debug_information import AutoSetSyntaxDebugInformationCommand
from .auto_set_syntax_download_dependencies import AutoSetSyntaxDownloadDependenciesCommand
from .auto_set_syntax_download_guesslang_server import AutoSetSyntaxDownloadGuesslangServerCommand
from .auto_set_syntax_restart_guesslang import AutoSetSyntaxRestartGuesslangCommand

__all__ = (
# ST: commands
Expand All @@ -15,8 +13,6 @@
"AutoSetSyntaxCreateNewMatchCommand",
"AutoSetSyntaxDebugInformationCommand",
"AutoSetSyntaxDownloadDependenciesCommand",
"AutoSetSyntaxDownloadGuesslangServerCommand",
"AutoSetSyntaxRestartGuesslangCommand",
# ...
"run_auto_set_syntax_on_view",
)
Loading

0 comments on commit dbb2ade

Please sign in to comment.