T
T
TheOnlyFastCoder22021-10-24 19:54:29
Sublime Text
TheOnlyFastCoder2, 2021-10-24 19:54:29

Sublime does not register a command for a plugin. Why?

Created a plugin in ".\sublimeText\Data\Packages\HCompiler" directory.
I did everything according to the documentation, but sublime does not want to register the command under the plugin.
I did the same in the User directory, just not a slave.
registered the command in the console view.run_command("hcompiler").

The plugin folder contains three files:
HCompiler.py

import sublime
import sublime_plugin

class HCompiler(sublime_plugin.TextCommand):
  def run(self, edit):
    print(2)

HCompiler.sublime-commands:
[
  {
    "caption":"Run HCompiler",
    "command":"hcompiler"
  }
]

HCompiler.sublime-keymap
[
  {
    "keys":["ctrl+l"],
    "command":"hcompiler"
  }
]


The plugin itself is handled by :
reloading plugin HCompiler.HCompiler

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TheOnlyFastCoder2, 2021-10-24
@TheOnlyFastCoder2

Solution:
Classes should not have an underscore in their names, they should always end with the word Command.
And the call of the command is carried out by underscore and at the end there should not be the word Command .
For example:

class CompilerCommand() -> .run_command("compiler") 
class HelperCompilerCommand() -> .run_command("helper_compiler") 
class CompilerHelperCommand() -> .run_command("compiler_helper")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question