decreaseIndentPattern has no effect - visual-studio-code

I am trying to create a TextMate bundle for a new language but am having issues with the decreaseIndentPattern. It seems to have no effect whatsoever, even with a trivial example:
increaseIndentPattern = 'start';
decreaseIndentPattern = 'end';
I have set the scope correctly and the other settings in the same file do work (including the increaseIndentPattern). Am I missing something?

Found out that to enable indentation correction on text based files (my scope starts with text), the following is also required:
disableIndentCorrections = :false;

Related

make nvim-cmp not autoselect the 1st option

I'm using nvim-cmp as my completion engine, which is working fine, but would like to change the default behavior to disable the automatic selection of the first option. The reason is that, when the last word of a line has suggestions, pressing enter will apply the first suggestion instead of just inserting a newline.
For example, in haskell, typing
main = do<CR>
the do matches diso~ from luasnip, and is replaced by something like
main = 2022-12-05T12:50:34
I would prefer the suggestions to be visible but none of them selected until tab is pressed, and if none is selected then <CR> is just a newline. Is this possible?
Answering my own question, I found out that when using lsp-zero, the configuration has to be done there. The documention in advanced-usage.md provides the exact solution, which I'm posting here:
local lsp = require('lsp-zero')
lsp.preset('system-lsp') -- or recommended, or whatever...
lsp.setup_nvim_cmp({
preselect = 'none',
completion = {
completeopt = 'menu,menuone,noinsert,noselect'
},
})
lsp.setup()
First set completeopt=menu,preview,menuone,noselect to configure auto-completion menu.
Then you have to modify your cmp plugin configuration for mapping of CR key :
local cmp = require'cmp'
cmp.setup({
mapping = cmp.mapping.preset.insert({
['<CR>'] = cmp.mapping.confirm({ select = false }),
})
})
See cmp plugins documentation for further explanations about cmp.confirm option.

typo3 read configuration options in typoscript

I've tried several approaches to read the configuration options of my plugin in typoscript, but none of them seem to work
ajax.30 = TEXT
ajax.30.value = {plugin.tx_parser.settings.numVar}
ajax.40 < {tx_parser.settings.numVar}
ajax.50 < {tx_parser.settings.numVar}
ajax.80 = TEXT
ajax.80.value = {options.numVar}
ajax.90 = TEXT
ajax.90.value = {settings.numVar}
Can anyone please explain me the syntax or post a link where it is explained; I can use ext_conf_template.txt explained here https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ExtensionArchitecture/ConfigurationOptions/Index.html but I didn't get these options in typoscript.
All I want is to access (in typoscript) the configuration options of the following picture
If I browse Constants I don't see any of these options
If I add my plugin to the site I see some plugin options but none of them I wanted
You can use constants with this syntax in TypoScript setup or constants
var = {$plugin.tx_parser.settings.numVar}
So in your case:
ajax.30 = TEXT
ajax.30.value = {$plugin.tx_parser.settings.numVar}
See https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/UsingSetting/Constants.html
To assign an earlier declared setup value you would use the < (object copy) operator
ajax.30 = TEXT
ajax.30.value < plugin.tx_parser.settings.numVar
Here is an on overview of its syntax: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/TypoScriptSyntax/Syntax/TypoScriptSyntax.html
The difference between constants and setup is essential. You can check in the backend in the module Template -> Template browser - see https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/UsingSetting/Debugging.html

adding syntax highlighting to Jupyter notebook cell magic

I'm trying to figure out how to activate CodeMirror syntax highlighting for a CodeMirror-supported language (cypher) within a cell for a custom Jupyter cell magic (%%mymagic). The magic isn't associated with a special kernel - it just runs Python commands that process the string entered into the cell that I want to highlight. From what I can tell, this ostensibly can be done using something like
from notebook.services.config.manager import ConfigManager
cm = ConfigManager()
cm.update('notebook', {'CodeCell': {'highlight_modes': {'magic_cypher': {'reg': '^%%mymagic'}}}})
within the class that implements the magic.
I can't seem to get this to work, however; no change in highlighting occurs when I enter stuff in a cell that starts with %%mymagic. Is the above approach accurate? Does 'magic_cypher' need to have a specific format? Does the magic need to somehow specify the MIME type CodeMirror associates with the desired highlighting language? I'm using notebook 5.0.0, jupyter_core 4.3.0, and python 2.7.13.
The following code works for SQL when placed in ~/.jupyter/custom/custom.js with notebook 5.x:
require(['notebook/js/codecell'], function(codecell) {
codecell.CodeCell.options_default.highlight_modes['magic_text/x-mssql'] = {'reg':[/^%%sql/]} ;
Jupyter.notebook.events.one('kernel_ready.Kernel', function(){
Jupyter.notebook.get_cells().map(function(cell){
if (cell.cell_type == 'code'){ cell.auto_highlight(); } }) ;
});
});
Credit goes to Thomas K for this info!
The case where I've been successful doing this was in adding SQL highlighting for the %%sql magic. I did this by adding the following to ~/.jupyter/custom/custom.js. The first line adds the mode to the Codemirror configuration, the rest apply the style to any existing cells in the workbook that need it (later cells will get styled appropriately as they are created). I haven't been successful in having it happen when the magic is installed, although I expect that it is possible.
IPython.CodeCell.config_defaults.highlight_modes['magic_text/x-mssql'] = {'reg':[/^%%sql/]} ;
IPython.notebook.events.one('kernel_ready.Kernel', function(){
IPython.notebook.get_cells().map(function(cell){
if (cell.cell_type == 'code'){ cell.auto_highlight(); } }) ;
});

Gtk.stock is deprecated, what's the alternative?

I've been learning to develop to Gtk and most of the examples online suggests the use of Gtk.stock icons. However, its use produces warnings that it has been deprecated and I can't find the alternative to these icons.
Code examples are:
open_button:Gtk.ToolButton = new ToolButton.from_stock(Stock.OPEN)
open_button.clicked.connect (openfile)
new_button:Gtk.ToolButton = new ToolButton.from_stock(Stock.NEW)
new_button.clicked.connect (createNew)
save_button:Gtk.ToolButton = new ToolButton.from_stock(Stock.SAVE)
save_button.clicked.connect (saveFile)
That generates error as:
/tmp/text_editor-exercise_7_1.vala.c:258:2: warning: 'GtkStock' is deprecated [-Wdeprecated-declarations]
_tmp1_ = (GtkToolButton*) gtk_tool_button_new_from_stock (GTK_STOCK_OPEN);
Which is the alternative and how it would look in the code above?
GTK+3 has moved over to the freedesktop.org Icon Naming Specification and internationalised labels. Taking Gtk.Stock.OPEN as an example. The GNOME Developer documentation for GTK_STOCK_OPEN gives two replacements:
GTK_STOCK_OPEN has been deprecated since version 3.10 and should not be used in newly-written code. Use named icon "document-open" or the label "_Open".
The Named Icon Method
The named icon method would be something like:
var open_icon = new Gtk.Image.from_icon_name( "document-open",
IconSize.SMALL_TOOLBAR
)
var open_button = new Gtk.ToolButton( open_icon, null )
The Label Method
The label method makes use of gettext to translate the label in to the current runtime language of the program. This is indicated by the underscore before the label. The line in your program would be:
var open_button = new Gtk.ToolButton( null, dgettext( "gtk30", "_Open") )
gettext uses domains, which are files containing the translations. The Gtk+3 domain is gtk30. You will also need to add a line at the beginning of your program to change the default locale for the C language, which is US English ASCII, to the locale of the run time environment:
init
Intl.setlocale()
To compile the Genie program you will need to set the default domain for gettext. This is usually set to nothing:
valac -X -DGETTEXT_PACKAGE --pkg gtk+-3.0 my_program.gs
When you run your program you will get the "_Open" translated to your locale. You can also change the locale. If you have the French locale installed then running the program with:
LC_ALL=fr ./my_program
will have the "_Open" label appear in French.
You may see in examples _( "_OPEN" ). The _() is a function like dgettext but uses a default domain. You may want to keep the default domain to the translation file for your own program. Using _( "_translate me" ) is a bit less typing that dgettext( "mydomain", "_translate me" ). To set the default domain in Genie add a line before init:
const GETTEXT_PACKAGE:string = "mydomain"
init
Intl.setlocale()

Problem importing ZEXP files programmatically

I'm developing a Plone Product that needs to import objects programmatically previously exported to ZEXP files. It's working perfectly, except the navigation bar. When one object is imported, it does so correctly, but the navication bar is not updated. The object can be accessed through it's URL and it's parent container contents tab.
Bellow is the code I used to import the objects. It's based on zope's ObjectManager._importObjectFromFile implementation.
def importDocument( app, fileName, container ):
app._p_jar.sync()
owner = 1
connection = container._p_jar
ob = connection.importFile( config.REMOTE_DIR + fileName, customImporters={ magic: importXML, } )
id = ob.id
if hasattr(id, 'im_func'): id = id()
try:
container._setObject( id, ob, set_owner = owner, suppress_events=False )
except AttributeError:
print "AttributeError"
# Try to make ownership implicit if possible in the context
# that the object was imported into
ob = container._getOb( id )
ob.manage_changeOwnershipType( explicit = 0 )
transaction.commit()
return True
I've noticed that the _setObject implementation fires an ObjectAddedEvent event in it's code, and it's after that event that the menu gets updated when I use the ZMI interface to import an object, so I figure something is listening to this event and handling the menu, but oddly, it doesn't happen when using my code.
Generally speaking, importing zexp objects is not supported (in part due to cases like this where unexpected or unintended results may occur). If it works, great. If it doesn't, you are "on your own" and probably better off copying the Data.fs file to a new software stack.
That said, I'm not sure I understand why clear and rebuild the catalog (ZMI -> portal_catalog -> tab 'advance' -> 'clear & rebuild') is not the answer here. According to its description its job is to "walk the entire portal looking for content objects which should be indexed in the catalog and index them".
Unless I misunderstand, you've just described a situation where newly imported content "should be indexed" because it hasn't been indexed yet.
If you are worried about the length of time required to clear and rebuild, try running it from the command line with something like this:
http://svn.plone.org/svn/plone/plone.org/Products.PloneOrg/trunk/scripts/catalog_rebuild.py
If you are worried about crawling the whole site, then call indexObject() on each object (http://dev.plone.org/plone/browser/plone.org/Products.PloneOrg/trunk/scripts/catalog_rebuild.py#L109)
Maybe try manually rebuilding the whole catalog after the import is complete? It might give you more hints to what is wrong ...
ZMI -> portal_catalog -> tab 'advance' -> 'clear & rebuild'.
You may need to "publish" the object after import to make it visible.
Use the manage_importObject method instead.