Skip to content

Instantly share code, notes, and snippets.

@Boorj
Last active July 17, 2020 13:16
Show Gist options
  • Save Boorj/6049252320bfdf9e6b42e4ad1784eca7 to your computer and use it in GitHub Desktop.
Save Boorj/6049252320bfdf9e6b42e4ad1784eca7 to your computer and use it in GitHub Desktop.
Jetbrains IDE (i.e. PhpStorm, WebStorm) config for highlighting Sphinx config files
<filetype binary="false" description="Sphinx.conf" name="Sphinx config file" icon="AllIcons.Nodes.Static">
<highlighting>
<options>
<option name="LINE_COMMENT" value="#" />
<option name="COMMENT_START" value="" />
<option name="COMMENT_END" value="" />
<option name="HEX_PREFIX" value="" />
<option name="NUM_POSTFIXES" value="" />
<option name="HAS_BRACES" value="true" />
</options>
<keywords keywords="index;indexer;searchd;source;common" ignore_case="false" />
<keywords2 keywords="sql_host;sql_user;sql_pass;type;sql_db;sql_port;sql_sock;mysql_connect_flags;mysql_ssl_key;mysql_ssl_cert;mysql_ssl_ca;mssql_winauth;mssql_unicode;sql_query_pre;sql_query;sql_query_range;sql_range_step;sql_query_killlist;sql_attr_uint;sql_attr_bool;sql_attr_timestamp;sql_attr_str2ordinal;sql_attr_float;sql_attr_bigint;sql_attr_multi;sql_query_post;sql_query_post_index;sql_ranged_throttle;sql_query_info;xmlpipe_command;xmlpipe_field;xmlpipe_attr_uint;xmlpipe_attr_timestamp;xmlpipe_attr_str2ordinal;xmlpipe_attr_bool;xmlpipe_attr_float;xmlpipe_attr_bigint;xmlpipe_attr_multi;xmlpipe_attr_multi_64;xmlpipe_attr_string;xmlpipe_attr_wordcount;xmlpipe_attr_json;xmlpipe_field_string;xmlpipe_field_wordcount;xmlpipe_fixup_utf8;sql_str2ordinal_column;unpack_zlib;unpack_mysqlcompress;unpack_mysqlcompress_maxsize;odbc_dsn;sql_joined_field;sql_attr_string;sql_attr_str2wordcount;sql_field_string;sql_field_str2wordcount;sql_file_field;sql_column_buffers;sql_attr_json;hook_connect;hook_query_range;hook_post_index;tsvpipe_command;tsvpipe_field;tsvpipe_attr_uint;tsvpipe_attr_timestamp;tsvpipe_attr_bool;tsvpipe_attr_float;tsvpipe_attr_bigint;tsvpipe_attr_multi;tsvpipe_attr_multi_64;tsvpipe_attr_string;tsvpipe_attr_json;tsvpipe_field_string;csvpipe_command;csvpipe_field;csvpipe_attr_uint;csvpipe_attr_timestamp;csvpipe_attr_bool;csvpipe_attr_float;csvpipe_attr_bigint;csvpipe_attr_multi;csvpipe_attr_multi_64;csvpipe_attr_string;csvpipe_attr_json;csvpipe_field_string;csvpipe_delimiter;source;path;docinfo;mlock;morphology;stopwords;exceptions;wordforms;embedded_limit;min_word_len;charset_type;charset_table;ignore_chars;min_prefix_len;min_infix_len;max_substring_len;prefix_fields;infix_fields;enable_star;ngram_len;ngram_chars;phrase_boundary;phrase_boundary_step;ondisk_dict;type;local;agent;agent_blackhole;agent_persistent;agent_connect_timeout;ha_strategy;agent_query_timeout;html_strip;html_index_attrs;html_remove_elements;preopen;inplace_enable;inplace_hit_gap;inplace_docinfo_gap;inplace_reloc_factor;inplace_write_factor;index_exact_words;min_stemming_len;overshort_step;stopword_step;blend_chars;expand_keywords;hitless_words;hit_format;rt_field;rt_attr_uint;rt_attr_bigint;rt_attr_float;rt_attr_timestamp;rt_attr_string;rt_attr_multi;rt_attr_multi_64;rt_attr_json;rt_attr_bool;rt_mem_limit;dict;index_sp;index_zones;blend_mode;regexp_filter;bigram_freq_words;bigram_index;index_field_lengths;divide_remote_ranges;stopwords_unstemmed;global_idf;rlp_context;ondisk_attrs;index_token_filter;mem_limit;max_iops;max_iosize;max_xmlpipe2_field;max_file_field_buffer;write_buffer;on_file_field_error;on_json_attr_error;json_autoconv_numbers;json_autoconv_keynames;lemmatizer_cache;address;port;listen;log;query_log;read_timeout;client_timeout;max_children;pid_file;max_matches;seamless_rotate;preopen_indexes;unlink_old;ondisk_dict_default;attr_flush_period;max_packet_size;mva_updates_pool;max_filters;max_filter_values;listen_backlog;read_buffer;read_unhinted;max_batch_queries;subtree_docs_cache;subtree_hits_cache;workers;prefork;dist_threads;binlog_flush;binlog_path;binlog_max_log_size;thread_stack;expansion_limit;rt_flush_period;query_log_format;mysql_version_string;plugin_dir;collation_server;collation_libc_locale;watchdog;prefork_rotation_throttle;snippets_file_prefix;sphinxql_state;rt_merge_iops;rt_merge_maxiosize;ha_ping_interval;ha_period_karma;predicted_time_costs;persistent_connections_limit;ondisk_attrs_default;shutdown_timeout;query_log_min_msec;agent_connect_timeout;agent_query_timeout;agent_retry_delay;agent_retry_count;net_wait_tm;net_throttle_action;net_throttle_accept;net_send_job;net_workers;queue_max_length;qcache_ttl_sec;qcache_max_bytes;qcache_thresh_msec;sphinxql_timeout;hostname_lookup;lemmatizer_base;on_json_attr_error;json_autoconv_numbers;json_autoconv_keynames;rlp_root;rlp_environment;rlp_max_batch_size;rlp_max_batch_docs;plugin_dir;progressive_merge" />
<keywords3 keywords="=;{;}" />
<keywords4 keywords="mysql41;sphinxql;:sphinx;threads;fork;xmlpipe2;tsvpipe;utf8_general_ci;stem_ru;stem_en" />
</highlighting>
<extensionMap>
<mapping pattern="*.sphinx.conf" />
</extensionMap>
</filetype>
@Boorj
Copy link
Author

Boorj commented Sep 18, 2018

Purpose

Syntax highlighting

see the image below

autocomplete

image

comment shortcut, code formatting

Standard highlighting module doesn't allow to add comment using shorcut Ctrl+/. So i had to redefine this style.

How it looks:

image

How to install

Put this file to c:\Users\USERNAME\.PhpStorm2018.X\config\filetypes\Conf2.xml
It will appear here:

image

If some keywords are missing

Just add them to <keywords2 keywords="... . Don't forget about semicolon;

.conf confilct

If you're using Smarty or Apache .conf, you can define another pattern for sphinx config, i. e. *.sphinx.conf.

<mapping pattern="*.sphinx.conf" />

Keys are taken from

https://github.com/sphinxsearch/sphinx/blob/master/src/sphinxutils.cpp

@Boorj
Copy link
Author

Boorj commented Sep 18, 2018

Icon

Also you can add an icon with icon="AllIcons.FileTypes.JavaScript" attribute to root node.

<filetype binary="false" description="Sphinx.conf" name="Sphinx config file"  icon="AllIcons.Nodes.Static">
icon="AllIcons.FileTypes.Config"

image

icon="AllIcons.Nodes.Static"

image

The Problem

But Storm will remove that on next relaunch 😢 .

How to deal with it

I made a command script, which copies this config on PhpStorm's startup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment