Defining Functions for Geany "Filetype" - geany

I am using Geany as my text editor. I have started working on snakemake, which, from a syntax point-of-view, is Python with a few modifications. Python functions are defined by:
def bla:
bunch_of_code
snakemake adds the definition of "rules" in a similar way:
rule bla:
bunch_of_code
Geany presents in the side bar all the Python functions, but I also want it to present all the rules. However, I was not able to find how to define the keywords for a function in the file geany/filetypes.python (I want to add the keyword rule).
Does anyone have any idea?

Related

Use lexer or parser generator to generate bash autocompletions for a text parameter?

I'd like to customize auto-completion in bash (such as is described at https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Programmable-Completion) such that a parameter can use auto-completion, where the parameter is an expression that should conform to a defined grammar (LALR, PEG or other).
Assuming the grammar definition already exists, is there any way to automate the generation of the resources needed to add this autocomplete capability to bash?
As an example, let's say I have sql.l and sql.y which I can compile with flex and bison to generate a check_sql executable that takes a single SQL "select" query as a parameter, and then prints "Valid" or "Invalid" depending on whether the query is valid SQL syntax. Further assume the command syntax is:
check_sql <sql query>
Then, if I typed in:
check_sql "sel
and then hit Tab, I would like autocomplete to propose to add "ect" to finish the word "select".
Similarly, if I typed in:
check_sql "select my_column from my_table
and then hit Tab, I would like autocomplete to show options such as "where", "inner", or "having".
Finally, I would like to generate the scripts and resources that implement this behavior, using sql.l, sql.y or both as inputs, so that if/as my grammar definition files change, it is easy to also update the bash completion resources.
Is this possible and/or feasible? I have used this approach to implement autocomplete using Monaco (with a PEG grammar rather than an LALR one)-- and it seems in theory that it shouldn't be too hard to do with bash autocomplete, but I'm not finding any relevant documentation or examples.

Is it possible to use `xxx` to define stem formulas in AsciiDoctor?

I would like to redefine the backticks so that I can use them to type formulas in AsciiDoctor documents. For example, instead of typing
stem:[my formula]
I would like to type just
`my formula`
How can this be done?
As far as I know this is not possible. You have to tell ascidoc(tor) what you want. So you need the usual steps:
activate stem support with :stem:
write your equation either inline or as a block
See more details and examples here: https://asciidoctor.org/docs/user-manual/#activating-stem-support

Code Formatting for the ReadTheDocs System

I'm using Read the Docs for the first time. I'm writing docs for a command line system, and my "code samples" include a log of shell output. The shell output ends up looking like this
That is -- the service (or my use of it?) is trying to format this example of running a shell command as though it was source code, and is treating the magento2:generate as though it was a class constant.
Can I control which code blocks get source code formatting in read the docs? I've tried setting no base language in the admin, but it doesn't seem to have an effect. Or is this something I need to control at the mkdocs of sphinx level? (read the docs works by turning your markdown or sphinx files into nice HTML files) Or something else? Or am I out of luck?
You need to define the "language" of the code block in your source document. Both Sphinx and MkDocs will attempt to guess the language, which often is good enough. However, on occasion, it will guess incorrectly and result in weird highlighting. To avoid that, both implementations provide a mechanism to manually define the language of each code block.
Sphinx
For Sphinx, you can use the code-block directive and include the "language" of the block:
.. code-block:: console
You shell commands go here
In the above example, I used console for the a shell session. The alias shell-session would work as well. Note that the alternative lexer bash (and its aliases: sh, ksh, zsh, and shell) woudl not strictly be appropriate as they are for a shell script, whereas you are displaying both the command and theoutput in a shell session.
A complete list of supported language codes can be found in the Pygments documentation.
MkDocs
MkDocs makes use of the Fenced Code Block Markdown extension to define the "language" of a code block:
``` shell
Your shell commands go here
```
As MkDocs uses highlight.js rather than Pygments, the list of supported languages is different. Therefore, I used shell (for a shell-session) in the above example.

Sublime text 3 ugly syntax highlighting

I'm learning Ruby and I'm using Sublime Text 3 but I find the syntax highlighting really strange.
For example :
Ugly syntax
Even after setting the syntax to ruby.
Ruby syntax set
I'd like to know if this is normal, or if I need to change something on the users
settings or something like that.
The syntax file for Ruby (Ruby.sublime-syntax) contains a list of unresolved issues. Among them is:
text:
"p << end
print me!
end"
symptoms:
not recognized as a heredoc
solution:
there is no way to distinguish perfectly between the << operator and the start
of a heredoc. Currently, we require assignment to recognize a heredoc. More
refinement is possible.
• Heredocs with indented terminators (<<-) are always distinguishable, however.
• Nested heredocs are not really supportable at present
So yeah, it's normal.
You could visit https://packagecontrol.io/ and use something like Railscast Colour Scheme
The basic syntax highlighting that comes w/ sublime is pretty sparse - these packages usually do a better job. Also this is just one example. There's plenty of themes and color schemes.
To install package control ctrl+ and past in the snippet according to your version of sublime from this page https://packagecontrol.io/installation#st3

Adding keyword commands and functions to Textmate 2 bundle syntax

I want to add some additional syntax highlighting definitions to an existing bundle, but I need some general advice on how to do this. I'm not building a syntax from scratch, and I think my request is pretty simple, but I think it involves some subtleties for which I find the manual somewhat impenetrable in finding the answer.
Basically, I'm trying to fill out the syntax definitions for the Stata bundle. It's great, but there is no built in support for automatically highlighting the base commands and the installed functions, only a handful of basic control statements. Stata is a language which is primarily used by calling lots of different high level pre-defined command calls, like command foo bar, options(). The convention is that these command calls be highlighted.
There are a ton of these commands, and stubs which are used for convenience. Just the base install has almost 3500. Even optimizing them using the bundle helper, which obviously gets rid of the stub issue, still yields a massive regex list. I can easily cut this down to less than 1000 important ones, but its still a lot. There are also 350 "functions" which I would like to match with the syntax function()
I essentially have 3 questions:
Am I creating a serious problem by including a very comprehensive list of matching definitions?
How do I restrict a command to only highlight when it either begins a line or there is only whitespace between the beginning line and the command
What is the preferred way of restricting the list of functions() to only highlight when they have attached parentheses?

Resources