From 670f8192c8d68c33e42b95847edd0678f87ca39b Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Thu, 7 Mar 2019 22:31:04 -0800 Subject: [PATCH 01/18] Set up command boilerplate for provide-module and require-module --- src/commands.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/commands.cc b/src/commands.cc index ef597f6f..3c50accb 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -2405,6 +2405,36 @@ const CommandDesc enter_user_mode_cmd = { } }; +const CommandDesc provide_module_cmd = { + "provide-module", + nullptr, + "provide-module [] : declares a module provided by ", + ParameterDesc{ + { { "override", { false, "allow overriding an existing module" } } }, + ParameterDesc::Flags::None, + 2, 2 + }, + CommandFlags::None, + CommandHelper{}, + CommandCompleter{}, + [](const ParametersParser& parse, Context& context, const ShellContext&) + { + } +}; + +const CommandDesc require_module_cmd = { + "require-module", + nullptr, + "require-module : ensures that module has been loaded", + ParameterDesc{ {}, ParameterDesc::Flags::None, 1, 1 }, + CommandFlags::None, + CommandHelper{}, + CommandCompleter{}, + [](const ParametersParser& parser, Context& context, const ShellContext&) + { + } +}; + } void register_commands() @@ -2470,6 +2500,8 @@ void register_commands() register_command(fail_cmd); register_command(declare_user_mode_cmd); register_command(enter_user_mode_cmd); + register_command(provide_module_cmd); + register_command(require_module_cmd); } } From 6092852640096c777f700cf669666504b10e2a58 Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Tue, 12 Mar 2019 10:34:30 -0700 Subject: [PATCH 02/18] Added 'provide-module' and 'require-module' commands --- src/command_manager.cc | 27 +++++++++++++++++++++++++++ src/command_manager.hh | 14 ++++++++++++++ src/commands.cc | 12 +++++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/command_manager.cc b/src/command_manager.cc index 5e8c8196..91c41bd3 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -40,6 +40,33 @@ void CommandManager::register_command(String command_name, std::move(completer) }; } +bool CommandManager::module_defined(StringView module_name) const +{ + return m_modules.find(module_name) != m_modules.end(); +} + +void CommandManager::register_module(String module_name, String commands) +{ + auto module = m_modules.find(module_name); + if (module != m_modules.end() and module->value.loaded) + throw runtime_error{format("module already loaded: '{}'", module_name)}; + + m_modules[module_name] = { false, std::move(commands) }; +} + +void CommandManager::load_module(StringView module_name, Context& context) +{ + auto module = m_modules.find(module_name); + if (module == m_modules.end()) + throw runtime_error{format("no such module: '{}'", module_name)}; + if (module->value.loaded) + return; + + module->value.loaded = true; + execute(module->value.commands, context); + module->value.commands.clear(); +} + struct parse_error : runtime_error { parse_error(StringView error) diff --git a/src/command_manager.hh b/src/command_manager.hh index 0468a1fc..329c24f2 100644 --- a/src/command_manager.hh +++ b/src/command_manager.hh @@ -123,6 +123,12 @@ public: void clear_last_complete_command() { m_last_complete_command = String{}; } + bool module_defined(StringView module_name) const; + + void register_module(String module_name, String commands); + + void load_module(StringView module_name, Context& context); + private: void execute_single_command(CommandParameters params, Context& context, @@ -143,6 +149,14 @@ private: String m_last_complete_command; int m_command_depth = 0; + struct Module + { + bool loaded; + String commands; + }; + using ModuleMap = HashMap; + ModuleMap m_modules; + CommandMap::const_iterator find_command(const Context& context, StringView name) const; }; diff --git a/src/commands.cc b/src/commands.cc index 3c50accb..264ad46c 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -2417,8 +2417,17 @@ const CommandDesc provide_module_cmd = { CommandFlags::None, CommandHelper{}, CommandCompleter{}, - [](const ParametersParser& parse, Context& context, const ShellContext&) + [](const ParametersParser& parser, Context& context, const ShellContext&) { + const String& module_name = parser[0]; + auto& cm = CommandManager::instance(); + + if (not all_of(module_name, is_identifier)) + throw runtime_error(format("invalid module name: '{}'", module_name)); + + if (cm.module_defined(module_name) and not parser.get_switch("override")) + throw runtime_error(format("module '{}' already defined", module_name)); + cm.register_module(module_name, parser[1]); } }; @@ -2432,6 +2441,7 @@ const CommandDesc require_module_cmd = { CommandCompleter{}, [](const ParametersParser& parser, Context& context, const ShellContext&) { + CommandManager::instance().load_module(parser[0], context); } }; From 1fab727f2be4be4e4b6e85887c283daf86aef722 Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Tue, 12 Mar 2019 22:24:33 -0700 Subject: [PATCH 03/18] Modified a bunch of language support files to use modules --- rc/filetype/asciidoc.kak | 8 ++++++++ rc/filetype/c-family.kak | 9 +++++++++ rc/filetype/clojure.kak | 8 ++++++++ rc/filetype/css.kak | 8 ++++++++ rc/filetype/d.kak | 8 ++++++++ rc/filetype/dart.kak | 9 +++++++++ rc/filetype/dockerfile.kak | 8 ++++++++ rc/filetype/go.kak | 8 ++++++++ rc/filetype/html.kak | 13 +++++++++++++ rc/filetype/javascript.kak | 8 ++++++++ rc/filetype/json.kak | 8 ++++++++ rc/filetype/kakrc.kak | 12 +++++++++++- rc/filetype/lisp.kak | 8 ++++++++ rc/filetype/makefile.kak | 8 ++++++++ rc/filetype/markdown.kak | 8 ++++++++ rc/filetype/nim.kak | 8 ++++++++ rc/filetype/ocaml.kak | 10 +++++++++- rc/filetype/perl.kak | 8 ++++++++ rc/filetype/pony.kak | 8 ++++++++ rc/filetype/protobuf.kak | 8 ++++++++ rc/filetype/python.kak | 8 ++++++++ rc/filetype/restructuredtext.kak | 8 ++++++++ rc/filetype/ruby.kak | 8 ++++++++ rc/filetype/scheme.kak | 14 +++++++++++--- rc/filetype/sh.kak | 8 ++++++++ rc/filetype/sql.kak | 8 ++++++++ rc/tools/clang.kak | 8 ++++++++ rc/tools/go/go-tools.kak | 8 ++++++++ 28 files changed, 238 insertions(+), 5 deletions(-) diff --git a/rc/filetype/asciidoc.kak b/rc/filetype/asciidoc.kak index 8bdcce07..21607da0 100644 --- a/rc/filetype/asciidoc.kak +++ b/rc/filetype/asciidoc.kak @@ -8,6 +8,12 @@ hook global BufCreate .+\.(a(scii)?doc|asc) %{ set-option buffer filetype asciidoc } +hook -once global BufSetOption filetype=asciidoc %{ + require-module asciidoc +} + +provide-module asciidoc %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -41,3 +47,5 @@ hook -group asciidoc-highlight global WinSetOption filetype=asciidoc %{ add-highlighter window/asciidoc ref asciidoc hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/asciidoc } } + +} diff --git a/rc/filetype/c-family.kak b/rc/filetype/c-family.kak index fbfa702a..68c2a387 100644 --- a/rc/filetype/c-family.kak +++ b/rc/filetype/c-family.kak @@ -23,6 +23,13 @@ hook global BufCreate .*\.m %{ set-option buffer filetype objc } +hook -once global BufSetOption filetype=(c|cpp|objc) %{ + require-module c-family +} + + +provide-module c-family %🦀 + define-command -hidden c-family-trim-indent %{ # remove the line if it's empty when leaving the insert mode try %{ execute-keys -draft 1s^(\h+)$ d } @@ -441,3 +448,5 @@ define-command cpp-alternative-file -docstring "Jump to the alternate cpp file ( define-command objc-alternative-file -docstring "Jump to the alternate objc file (header/implementation)" %{ c-family-alternative-file } + +🦀 diff --git a/rc/filetype/clojure.kak b/rc/filetype/clojure.kak index da6134a6..d19708af 100644 --- a/rc/filetype/clojure.kak +++ b/rc/filetype/clojure.kak @@ -10,6 +10,12 @@ hook global BufCreate .*[.](clj|cljc|cljs|cljx|edn) %{ set-option buffer filetype clojure } +hook -once global BufSetOption filetype=clojure %{ + require-module clojure +} + +provide-module clojure %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -206,3 +212,5 @@ hook global WinSetOption filetype=clojure %[ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window clojure-.+ } ] + +} diff --git a/rc/filetype/css.kak b/rc/filetype/css.kak index ecc456ed..8c5def9c 100644 --- a/rc/filetype/css.kak +++ b/rc/filetype/css.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](css) %{ set-option buffer filetype css } +hook -once global BufSetOption filetype=css %{ + require-module css +} + +provide-module css %[ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -74,3 +80,5 @@ hook global WinSetOption filetype=css %[ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window css-.+ } ] + +] diff --git a/rc/filetype/d.kak b/rc/filetype/d.kak index f0f08248..b042f4f9 100644 --- a/rc/filetype/d.kak +++ b/rc/filetype/d.kak @@ -8,6 +8,12 @@ hook global BufCreate .*\.di? %{ set-option buffer filetype d } +hook -once global BufSetOption filetype=d %{ + require-module d +} + +provide-module d %🦀 + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -130,3 +136,5 @@ hook global WinSetOption filetype=d %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window d-.+ } } + +🦀 diff --git a/rc/filetype/dart.kak b/rc/filetype/dart.kak index 5b5600cb..49701429 100644 --- a/rc/filetype/dart.kak +++ b/rc/filetype/dart.kak @@ -8,6 +8,12 @@ hook global BufCreate .*\.dart %{ set-option buffer filetype dart } +hook -once global BufSetOption filetype=dart %{ + require-module dart +} + +provide-module dart %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -104,3 +110,6 @@ hook global WinSetOption filetype=dart %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window dart-.+ } } + +# balancing }}} +} diff --git a/rc/filetype/dockerfile.kak b/rc/filetype/dockerfile.kak index 07da2347..b76716e2 100644 --- a/rc/filetype/dockerfile.kak +++ b/rc/filetype/dockerfile.kak @@ -10,6 +10,12 @@ hook global BufCreate .*/?Dockerfile(\.\w+)?$ %{ set-option buffer filetype dockerfile } +hook -once global BufSetOption filetype=dockerfile %{ + require-module dockerfile +} + +provide-module dockerfile %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -46,3 +52,5 @@ hook -group dockerfile-highlight global WinSetOption filetype=dockerfile %{ add-highlighter window/dockerfile ref dockerfile hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dockerfile } } + +} diff --git a/rc/filetype/go.kak b/rc/filetype/go.kak index 8aebe657..2df0ba9d 100644 --- a/rc/filetype/go.kak +++ b/rc/filetype/go.kak @@ -8,6 +8,12 @@ hook global BufCreate .*\.go %{ set-option buffer filetype go } +hook -once global BufSetOption filetype=go %{ + require-module go +} + +provide-module go %🦀 + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -95,3 +101,5 @@ hook global WinSetOption filetype=go %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window go-.+ } } + +🦀 diff --git a/rc/filetype/html.kak b/rc/filetype/html.kak index 5f76721d..81db5c9b 100644 --- a/rc/filetype/html.kak +++ b/rc/filetype/html.kak @@ -12,6 +12,17 @@ hook global BufCreate .*\.xml %{ set-option buffer filetype xml } +hook -once global BufSetOption filetype=(html|xml) %{ + require-module html +} + +provide-module html %[ + +try %{ + require-module css + require-module javascript +} + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -73,3 +84,5 @@ hook global WinSetOption filetype=(html|xml) %{ remove-hooks window ""%val{hook_param_capture_1}-.+"" " } + +] diff --git a/rc/filetype/javascript.kak b/rc/filetype/javascript.kak index 4d16ee68..7dc2034d 100644 --- a/rc/filetype/javascript.kak +++ b/rc/filetype/javascript.kak @@ -9,6 +9,12 @@ hook global BufCreate .*[.](ts)x? %{ set-option buffer filetype typescript } +hook -once global BufSetOption filetype=(java|type)script %{ + require-module javascript +} + +provide-module javascript %🦀 + # Commands # ‾‾‾‾‾‾‾‾ @@ -115,3 +121,5 @@ add-highlighter shared/typescript/code/ regex \b(array|boolean|date|number|objec # Keywords grabbed from https://github.com/Microsoft/TypeScript/issues/2536 add-highlighter shared/typescript/code/ regex \b(as|constructor|declare|enum|from|implements|interface|module|namespace|package|private|protected|public|readonly|static|type)\b 0:keyword + +🦀 diff --git a/rc/filetype/json.kak b/rc/filetype/json.kak index ae04c55a..d863d596 100644 --- a/rc/filetype/json.kak +++ b/rc/filetype/json.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](json) %{ set-option buffer filetype json } +hook -once global BufSetOption filetype=json %{ + require-module json +} + +provide-module json %( + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -58,3 +64,5 @@ hook global WinSetOption filetype=json %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window json-.+ } } + +) diff --git a/rc/filetype/kakrc.kak b/rc/filetype/kakrc.kak index 7a9af989..1b270b80 100644 --- a/rc/filetype/kakrc.kak +++ b/rc/filetype/kakrc.kak @@ -8,6 +8,14 @@ hook global BufCreate (.*/)?(kakrc|.*.kak) %{ set-option buffer filetype kak } +hook -once global BufSetOption filetype=kak %{ + require-module kak +} + +provide-module kak %🦀 + +require-module sh + # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ @@ -33,7 +41,7 @@ evaluate-commands %sh{ set-option unset-option update-option declare-option execute-keys evaluate-commands prompt menu on-key info set-face unset-face rename-client set-register select change-directory rename-session colorscheme declare-user-mode enter-user-mode - edit! write! kill! quit! write-quit! delete-buffer!" + edit! write! kill! quit! write-quit! delete-buffer! provide-module require-module" attributes="global buffer window current normal insert menu prompt goto view user object number-lines show-matching show-whitespaces fill regex dynregex group flag-lines @@ -108,3 +116,5 @@ hook global WinSetOption filetype=kak %~ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kak-.+ } ~ + +🦀 diff --git a/rc/filetype/lisp.kak b/rc/filetype/lisp.kak index 378bb3c5..39f946e7 100644 --- a/rc/filetype/lisp.kak +++ b/rc/filetype/lisp.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](lisp) %{ set-option buffer filetype lisp } +hook -once global BufSetOption filetype=lisp %{ + require-module lisp +} + +provide-module lisp %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -72,3 +78,5 @@ hook global WinSetOption filetype=lisp %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window lisp-.+ } } + +} diff --git a/rc/filetype/makefile.kak b/rc/filetype/makefile.kak index 569d51f9..c6f13dfd 100644 --- a/rc/filetype/makefile.kak +++ b/rc/filetype/makefile.kak @@ -5,6 +5,12 @@ hook global BufCreate .*(/?[mM]akefile|\.mk) %{ set-option buffer filetype makefile } +hook -once global BufSetOption filetype=makefile %{ + require-module makefile +} + +provide-module makefile %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -58,3 +64,5 @@ hook global WinSetOption filetype=makefile %{ hook window InsertChar \n -group makefile-indent makefile-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window makefile-.+ } } + +} diff --git a/rc/filetype/markdown.kak b/rc/filetype/markdown.kak index 18f3ccf6..be193269 100644 --- a/rc/filetype/markdown.kak +++ b/rc/filetype/markdown.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](markdown|md|mkd) %{ set-option buffer filetype markdown } +hook -once global BufSetOption filetype=markdown %{ + require-module markdown +} + +provide-module markdown %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -83,3 +89,5 @@ hook global WinSetOption filetype=markdown %{ hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } } + +} diff --git a/rc/filetype/nim.kak b/rc/filetype/nim.kak index 901ce68a..0bdd8ef6 100644 --- a/rc/filetype/nim.kak +++ b/rc/filetype/nim.kak @@ -8,6 +8,12 @@ hook global BufCreate .*\.nim(s|ble)? %{ set-option buffer filetype nim } +hook -once global BufSetOption filetype=nim %{ + require-module nim +} + +provide-module nim %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -110,3 +116,5 @@ hook global WinSetOption filetype=nim %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window nim-.+ } } + +} diff --git a/rc/filetype/ocaml.kak b/rc/filetype/ocaml.kak index 0a3d49bf..8b8c771c 100644 --- a/rc/filetype/ocaml.kak +++ b/rc/filetype/ocaml.kak @@ -5,9 +5,15 @@ # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.mli? %{ - set-option buffer filetype ocaml + set-option buffer filetype ocaml } +hook -once global BufSetOption filetype=ocaml %{ + require-module ocaml +} + +provide-module ocaml %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -36,3 +42,5 @@ evaluate-commands %sh{ } " } + +} diff --git a/rc/filetype/perl.kak b/rc/filetype/perl.kak index e69058d3..342eb3b2 100644 --- a/rc/filetype/perl.kak +++ b/rc/filetype/perl.kak @@ -8,6 +8,12 @@ hook global BufCreate .*\.(t|p[lm])$ %{ set-option buffer filetype perl } +hook -once global BufSetOption filetype=perl %{ + require-module perl +} + +provide-module perl %🦀 + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -112,3 +118,5 @@ hook global WinSetOption filetype=perl %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window perl-.+ } } + +🦀 diff --git a/rc/filetype/pony.kak b/rc/filetype/pony.kak index 713cc295..8aaa0233 100644 --- a/rc/filetype/pony.kak +++ b/rc/filetype/pony.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](pony) %{ set-option buffer filetype pony } +hook -once global BufSetOption filetype=pony %{ + require-module pony +} + +provide-module pony %{ + # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ @@ -90,3 +96,5 @@ hook global WinSetOption filetype=pony %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pony-.+ } } + +} diff --git a/rc/filetype/protobuf.kak b/rc/filetype/protobuf.kak index 2ef10480..4924cb05 100644 --- a/rc/filetype/protobuf.kak +++ b/rc/filetype/protobuf.kak @@ -7,6 +7,12 @@ hook global BufCreate .*\.proto$ %{ set-option buffer filetype protobuf } +hook -once global BufSetOption filetype=protobuf %{ + require-module protobuf +} + +provide-module protobuf %[ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -83,3 +89,5 @@ hook global WinSetOption filetype=protobuf %[ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window protobuf-.+ } ] + +] diff --git a/rc/filetype/python.kak b/rc/filetype/python.kak index 9084dd1c..82fe9971 100644 --- a/rc/filetype/python.kak +++ b/rc/filetype/python.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](py) %{ set-option buffer filetype python } +hook -once global BufSetOption filetype=python %{ + require-module python +} + +provide-module python %{ + # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ @@ -146,3 +152,5 @@ hook global WinSetOption filetype=python %{ hook window ModeChange insert:.* -group python-trim-indent %{ try %{ execute-keys -draft \; s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window python-.+ } } + +} diff --git a/rc/filetype/restructuredtext.kak b/rc/filetype/restructuredtext.kak index 1eaf4bfc..362c9806 100644 --- a/rc/filetype/restructuredtext.kak +++ b/rc/filetype/restructuredtext.kak @@ -5,6 +5,12 @@ hook global BufCreate .*[.](rst) %{ set-option buffer filetype restructuredtext } +hook -once global BufSetOption filetype=restructuredtext %{ + require-module restructuredtext +} + +provide-module restructuredtext %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -72,3 +78,5 @@ hook -group restructuredtext-highlight global WinSetOption filetype=restructured add-highlighter window/restructuredtext ref restructuredtext hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/restructuredtext } } + +} diff --git a/rc/filetype/ruby.kak b/rc/filetype/ruby.kak index 3e5cfcfa..d9bdcfe6 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -8,6 +8,12 @@ hook global BufCreate .*(([.](rb))|(irbrc)|(pryrc)|(Brewfile)|(Capfile|[.]cap)|( set-option buffer filetype ruby } +hook -once global BufSetOption filetype=ruby %{ + require-module ruby +} + +provide-module ruby %[ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -166,3 +172,5 @@ hook global WinSetOption filetype=ruby %{ unalias window alt ruby-alternative-file } } + +] diff --git a/rc/filetype/scheme.kak b/rc/filetype/scheme.kak index ec86638b..20d2f35f 100644 --- a/rc/filetype/scheme.kak +++ b/rc/filetype/scheme.kak @@ -1,8 +1,6 @@ # http://www.scheme-reports.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -# require lisp.kak - # Detection # ‾‾‾‾‾‾‾‾‾ @@ -10,6 +8,14 @@ hook global BufCreate (.*/)?(.*\.(scm|ss|sld)) %{ set-option buffer filetype scheme } +hook -once global BufSetOption filetype=scheme %{ + require-module scheme +} + +provide-module scheme %{ + +require-module lisp + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -100,7 +106,7 @@ evaluate-commands %sh{ exec awk -f - <<'EOF' BEGIN { printf("hook global WinSetOption filetype=scheme %%{ set-option window static_words "); - print_words(keywords); print_words(meta); print_words(operators); print_words(builtins); + print_words(keywords); print_words(meta); print_words(operators); print_words(builtins); printf(" }\n") add_word_highlighter(keywords, "keyword"); @@ -131,3 +137,5 @@ hook global WinSetOption filetype=scheme %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scheme-.+ } } + +} diff --git a/rc/filetype/sh.kak b/rc/filetype/sh.kak index acd62993..b7468520 100644 --- a/rc/filetype/sh.kak +++ b/rc/filetype/sh.kak @@ -2,6 +2,12 @@ hook global BufCreate .*\.(z|ba|c|k|mk)?sh(rc|_profile)? %{ set-option buffer filetype sh } +hook -once global BufSetOption filetype=sh %{ + require-module sh +} + +provide-module sh %[ + add-highlighter shared/sh regions add-highlighter shared/sh/code default-region group add-highlighter shared/sh/double_string region %{(? /dev/null 2>&1; then @@ -180,3 +186,5 @@ define-command go-share-selection -docstring "Share the selection using the Go P snippet_id=$(printf %s\\n "${kak_selection}" | curl -s https://play.golang.org/share --data-binary @-) printf "echo https://play.golang.org/p/%s" ${snippet_id} } } + +} From c3f694a28f2da1454119ff49540377f4370f940d Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Wed, 13 Mar 2019 11:15:59 -0700 Subject: [PATCH 04/18] Modified base files to use modules --- rc/filetype/clojure.kak | 4 ++-- rc/filetype/etc.kak | 45 +++++++++++++++++++++++++++++++++------ rc/filetype/fish.kak | 8 +++++++ rc/filetype/gas.kak | 8 +++++++ rc/filetype/git.kak | 27 +++++++++++++++++------ rc/filetype/haskell.kak | 8 +++++++ rc/filetype/ini.kak | 8 +++++++ rc/filetype/java.kak | 8 +++++++ rc/filetype/julia.kak | 8 +++++++ rc/filetype/lua.kak | 8 +++++++ rc/filetype/mail.kak | 8 +++++++ rc/filetype/mercurial.kak | 13 +++++++++++ rc/filetype/rust.kak | 8 +++++++ rc/filetype/scala.kak | 8 +++++++ rc/filetype/swift.kak | 8 +++++++ rc/filetype/yaml.kak | 8 +++++++ rc/windowing/screen.kak | 12 +++++++---- rc/windowing/tmux.kak | 14 +++++++----- rc/windowing/x11.kak | 12 +++++++++++ 19 files changed, 198 insertions(+), 25 deletions(-) diff --git a/rc/filetype/clojure.kak b/rc/filetype/clojure.kak index d19708af..062e4f0c 100644 --- a/rc/filetype/clojure.kak +++ b/rc/filetype/clojure.kak @@ -1,8 +1,6 @@ # http://clojure.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -# require lisp.kak - # Detection # ‾‾‾‾‾‾‾‾‾ @@ -16,6 +14,8 @@ hook -once global BufSetOption filetype=clojure %{ provide-module clojure %{ +require-module lisp + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ diff --git a/rc/filetype/etc.kak b/rc/filetype/etc.kak index 1e2067fe..29c6296d 100644 --- a/rc/filetype/etc.kak +++ b/rc/filetype/etc.kak @@ -11,7 +11,32 @@ hook global BufCreate .*/etc/env.d/.* %{ set-option buffer fil hook global BufCreate .*/etc/profile(\.(csh|env))? %{ set-option buffer filetype sh } hook global BufCreate .*/etc/profile\.d/.* %{ set-option buffer filetype sh } + +hook -once global BufSetOption filetype=etc-hosts %{ + require-module etc-hosts +} +hook -once global BufSetOption filetype=etc-resolv-conf %{ + require-module etc-resolv-conf +} +hook -once global BufSetOption filetype=etc-shadow %{ + require-module etc-shadow +} +hook -once global BufSetOption filetype=etc-passwd %{ + require-module etc-passwd +} +hook -once global BufSetOption filetype=etc-gshadow %{ + require-module etc-gshadow +} +hook -once global BufSetOption filetype=etc-group %{ + require-module etc-group +} +hook -once global BufSetOption filetype=etc-fstab %{ + require-module etc-fstab +} + # Highlighters + +provide-module etc-resolv-conf %{ ## /etc/resolv.conf add-highlighter shared/etc-resolv-conf group add-highlighter shared/etc-resolv-conf/ regex ^#.*?$ 0:comment @@ -20,8 +45,9 @@ add-highlighter shared/etc-resolv-conf/ regex ^(nameserver|server|domain|sortlis hook -group etc-resolv-conf-highlight global WinSetOption filetype=etc-resolv-conf %{ add-highlighter window/etc-resolv-conf ref etc-resolv-conf hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-resolv-conf } -} +}} +provide-module etc-hosts %{ ## /etc/hosts add-highlighter shared/etc-hosts group add-highlighter shared/etc-hosts/ regex ^(.+?)[\s\t]+?(.*?)$ 1:type 2:attribute @@ -30,8 +56,9 @@ add-highlighter shared/etc-hosts/ regex '#.*?$' 0:comment hook -group etc-hosts-highlight global WinSetOption filetype=etc-hosts %{ add-highlighter window/etc-hosts ref etc-hosts hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-hosts } -} +}} +provide-module etc-fstab %{ ## /etc/fstab add-highlighter shared/etc-fstab group add-highlighter shared/etc-fstab/ regex ^(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})(?:\s+)?$ 1:keyword 2:value 3:type 4:string 5:attribute 6:attribute @@ -40,8 +67,9 @@ add-highlighter shared/etc-fstab/ regex '#.*?$' 0:comment hook -group etc-fstab-highlight global WinSetOption filetype=etc-fstab %{ add-highlighter window/etc-fstab ref etc-fstab hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-fstab } -} +}} +provide-module etc-group %{ ## /etc/group add-highlighter shared/etc-group group add-highlighter shared/etc-group/ regex ^(\S+?):(\S+?)?:(\S+?)?:(\S+?)?$ 1:keyword 2:type 3:value 4:string @@ -49,8 +77,9 @@ add-highlighter shared/etc-group/ regex ^(\S+?):(\S+?)?:(\S+?)?:(\S+?)?$ 1:keywo hook -group etc-group-highlight global WinSetOption filetype=etc-group %{ add-highlighter window/etc-group ref etc-group hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-group } -} +}} +provide-module etc-gshadow %{ ## /etc/gshadow add-highlighter shared/etc-gshadow group add-highlighter shared/etc-gshadow/ regex ^(\S+?):(\S+?)?:(\S+?)?:(\S+?)?$ 1:keyword 2:type 3:value 4:string @@ -58,8 +87,9 @@ add-highlighter shared/etc-gshadow/ regex ^(\S+?):(\S+?)?:(\S+?)?:(\S+?)?$ 1:key hook -group etc-gshadow-highlight global WinSetOption filetype=etc-gshadow %{ add-highlighter window/etc-gshadow ref etc-gshadow hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-gshadow } -} +}} +provide-module etc-shadow %{ ## /etc/shadow add-highlighter shared/etc-shadow group add-highlighter shared/etc-shadow/ regex ^(\S+?):(\S+?):([0-9]+?):([0-9]+?)?:([0-9]+?)?:([0-9]+?)?:([0-9]+?)?:([0-9]+?)?:(.*?)?$ 1:keyword 2:type 3:value 4:value 5:value 6:value 7:value 8:value @@ -67,8 +97,9 @@ add-highlighter shared/etc-shadow/ regex ^(\S+?):(\S+?):([0-9]+?):([0-9]+?)?:([0 hook -group etc-shadow-highlight global WinSetOption filetype=etc-shadow %{ add-highlighter window/etc-shadow ref etc-shadow hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-shadow } -} +}} +provide-module etc-passwd %{ ## /etc/passwd add-highlighter shared/etc-passwd group add-highlighter shared/etc-passwd/ regex ^(\S+?):(\S+?):([0-9]+?):([0-9]+?):(.*?)?:(.+?):(.+?)$ 1:keyword 2:type 3:value 4:value 5:string 6:attribute 7:attribute @@ -76,4 +107,4 @@ add-highlighter shared/etc-passwd/ regex ^(\S+?):(\S+?):([0-9]+?):([0-9]+?):(.*? hook -group etc-passwd-highlight global WinSetOption filetype=etc-passwd %{ add-highlighter window/etc-passwd ref etc-passwd hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-passwd } -} +}} diff --git a/rc/filetype/fish.kak b/rc/filetype/fish.kak index 24da9d20..db62a354 100644 --- a/rc/filetype/fish.kak +++ b/rc/filetype/fish.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](fish) %{ set-option buffer filetype fish } +hook -once global BufSetOption filetype=fish %{ + require-module fish +} + +provide-module fish %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -71,3 +77,5 @@ hook global WinSetOption filetype=fish %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window fish-.+ } } + +} diff --git a/rc/filetype/gas.kak b/rc/filetype/gas.kak index 0c1f79f8..ba32472a 100644 --- a/rc/filetype/gas.kak +++ b/rc/filetype/gas.kak @@ -4,6 +4,12 @@ hook global BufCreate .*\.(s|S|asm)$ %{ set-option buffer filetype gas } +hook -once global BufSetOption filetype=gas %{ + require-module gas +} + +provide-module gas %{ + add-highlighter shared/gas regions add-highlighter shared/gas/code default-region group add-highlighter shared/gas/string region '"' (?]+@.*?> 0:string @@ -11,3 +17,5 @@ hook -group mail-highlight global WinSetOption filetype=mail %{ add-highlighter window/mail ref mail hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/mail } } + +} diff --git a/rc/filetype/mercurial.kak b/rc/filetype/mercurial.kak index 3f84eea2..5c014ee7 100644 --- a/rc/filetype/mercurial.kak +++ b/rc/filetype/mercurial.kak @@ -8,6 +8,17 @@ hook global BufCreate .*hg-editor-\w+\.txt$ %{ set-option buffer filetype hg-commit } +hook -once global BufSetOption filetype=hg-commit %{ + require-module hg-commit +} + +provide-module hg-commit %{ + +# Faces +# ‾‾‾‾‾ + +set-face global MercurialCommitComment cyan + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -16,3 +27,5 @@ hook -group hg-commit-highlight global WinSetOption filetype=hg-commit %{ add-highlighter window/hg-commit-highlight regex '^HG:[^\n]*' 0:comment hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/hg-commit-highlight } } + +} diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index 28cb98c3..7018ff31 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](rust|rs) %{ set-option buffer filetype rust } +hook -once global BufSetOption filetype=rust %{ + require-module rust +} + +provide-module rust %🦀 + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -93,3 +99,5 @@ hook global WinSetOption filetype=rust %[ hook global WinSetOption filetype=rust %[ set window formatcmd 'rustfmt' ] + +🦀 diff --git a/rc/filetype/scala.kak b/rc/filetype/scala.kak index 1e62e2ad..ce890058 100644 --- a/rc/filetype/scala.kak +++ b/rc/filetype/scala.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](scala) %{ set-option buffer filetype scala } +hook -once global BufSetOption filetype=scala %{ + require-module scala +} + +provide-module scala %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -73,3 +79,5 @@ hook global WinSetOption filetype=scala %[ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scala-.+ } ] + +} diff --git a/rc/filetype/swift.kak b/rc/filetype/swift.kak index 1526cadb..4cf71613 100644 --- a/rc/filetype/swift.kak +++ b/rc/filetype/swift.kak @@ -2,6 +2,12 @@ hook global BufCreate .*\.(swift) %{ set-option buffer filetype swift } +hook -once global BufSetOption filetype=swift %{ + require-module swift +} + +provide-module swift %{ + add-highlighter shared/swift regions add-highlighter shared/swift/code default-region group add-highlighter shared/swift/string region %{(? Date: Wed, 13 Mar 2019 12:46:53 -0700 Subject: [PATCH 05/18] Added ModuleLoad hook that uses the module name as the parameter --- src/command_manager.cc | 2 ++ src/hook_manager.hh | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/command_manager.cc b/src/command_manager.cc index 91c41bd3..aff9e3fd 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -65,6 +65,8 @@ void CommandManager::load_module(StringView module_name, Context& context) module->value.loaded = true; execute(module->value.commands, context); module->value.commands.clear(); + + context.hooks().run_hook(Hook::ModuleLoad, module_name, context); } struct parse_error : runtime_error diff --git a/src/hook_manager.hh b/src/hook_manager.hh index 1653791c..38d1c611 100644 --- a/src/hook_manager.hh +++ b/src/hook_manager.hh @@ -57,12 +57,13 @@ enum class Hook WinCreate, WinDisplay, WinResize, - WinSetOption + WinSetOption, + ModuleLoad }; constexpr auto enum_desc(Meta::Type) { - return make_array, 41>({ + return make_array, 42>({ {Hook::BufCreate, "BufCreate"}, {Hook::BufNewFile, "BufNewFile"}, {Hook::BufOpenFile, "BufOpenFile"}, @@ -104,6 +105,7 @@ constexpr auto enum_desc(Meta::Type) {Hook::WinDisplay, "WinDisplay"}, {Hook::WinResize, "WinResize"}, {Hook::WinSetOption, "WinSetOption"}, + {Hook::ModuleLoad, "ModuleLoad"} }); } From aa6d19bee69e6a2b845553f5ba19cfe4e4cf6b12 Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Wed, 13 Mar 2019 14:00:59 -0700 Subject: [PATCH 06/18] Added modules to extra files --- rc/detection/editorconfig.kak | 2 +- rc/filetype/cabal.kak | 8 ++++++ rc/filetype/cmake.kak | 8 ++++++ rc/filetype/coffee.kak | 8 ++++++ rc/filetype/cucumber.kak | 8 ++++++ rc/filetype/elixir.kak | 11 ++++++-- rc/filetype/elm.kak | 8 ++++++ rc/filetype/exherbo.kak | 18 +++++++++++++ rc/filetype/haml.kak | 11 ++++++++ rc/filetype/hbs.kak | 8 ++++++ rc/filetype/i3.kak | 8 ++++++ rc/filetype/just.kak | 8 ++++++ rc/filetype/kickstart.kak | 8 ++++++ rc/filetype/latex.kak | 8 ++++++ rc/filetype/moon.kak | 8 ++++++ rc/filetype/php.kak | 9 +++++++ rc/filetype/pug.kak | 8 ++++++ rc/filetype/ragel.kak | 8 ++++++ rc/filetype/sass.kak | 8 ++++++ rc/filetype/scss.kak | 12 +++++++-- rc/filetype/taskpaper.kak | 10 +++++++- rc/filetype/toml.kak | 8 ++++++ rc/filetype/troff.kak | 8 ++++++ rc/filetype/tupfile.kak | 8 ++++++ rc/tools/autorestore.kak | 4 +-- rc/tools/python/jedi.kak | 10 +++++++- rc/tools/rust/racer.kak | 8 ++++++ rc/windowing/iterm.kak | 12 ++++++--- rc/windowing/kitty.kak | 21 +++++++++------ rc/windowing/repl/tmux.kak | 48 ++++++++++++++++++++--------------- rc/windowing/repl/x11.kak | 8 ++++++ 31 files changed, 278 insertions(+), 42 deletions(-) diff --git a/rc/detection/editorconfig.kak b/rc/detection/editorconfig.kak index 9421e033..388e0540 100644 --- a/rc/detection/editorconfig.kak +++ b/rc/detection/editorconfig.kak @@ -8,7 +8,7 @@ hook global BufCreate .*[.](editorconfig) %{ set-option buffer filetype ini set-option buffer static_words indent_style indent_size tab_width \ end_of_line charset insert_final_newline trim_trailing_whitespace root \ - latin1 utf-8 utf-8-bom utf-16be utf-16le lf cr crlf unset space tab + latin1 utf-8 utf-8-bom utf-16be utf-16le lf cr crlf unset space tab } declare-option -hidden bool editorconfig_trim_trailing_whitespace false diff --git a/rc/filetype/cabal.kak b/rc/filetype/cabal.kak index b3e7e58c..daff0bff 100644 --- a/rc/filetype/cabal.kak +++ b/rc/filetype/cabal.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](cabal) %{ set-option buffer filetype cabal } +hook -once global BufSetOption filetype=cabal %{ + require-module cabal +} + +provide-module cabal %[ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -72,3 +78,5 @@ hook global WinSetOption filetype=cabal %[ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window cabal-.+ } ] + +] diff --git a/rc/filetype/cmake.kak b/rc/filetype/cmake.kak index 77ec18c5..c0c3bb2c 100644 --- a/rc/filetype/cmake.kak +++ b/rc/filetype/cmake.kak @@ -6,6 +6,12 @@ hook global BufCreate .*/CMakeCache.txt %{ set-option buffer filetype ini } +hook -once global BufSetOption filetype=cmake %{ + require-module cmake +} + +provide-module cmake %{ + add-highlighter shared/cmake regions add-highlighter shared/cmake/code default-region group add-highlighter shared/cmake/comment region '#' '$' fill comment @@ -25,3 +31,5 @@ hook -group cmake-highlight global WinSetOption filetype=cmake %{ add-highlighter window/cmake ref cmake hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cmake } } + +} diff --git a/rc/filetype/coffee.kak b/rc/filetype/coffee.kak index c8e7384e..f0b5ac58 100644 --- a/rc/filetype/coffee.kak +++ b/rc/filetype/coffee.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](coffee) %{ set-option buffer filetype coffee } +hook -once global BufSetOption filetype=coffee %{ + require-module coffee +} + +provide-module coffee %[ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -77,3 +83,5 @@ hook global WinSetOption filetype=coffee %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window coffee-.+ } } + +] diff --git a/rc/filetype/cucumber.kak b/rc/filetype/cucumber.kak index 180da7d0..55fe892a 100644 --- a/rc/filetype/cucumber.kak +++ b/rc/filetype/cucumber.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](feature|story) %{ set-option buffer filetype cucumber } +hook -once global BufSetOption filetype=cucumber %{ + require-module cucumber +} + +provide-module cucumber %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -87,3 +93,5 @@ hook global WinSetOption filetype=cucumber %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window cucumber-.+ } } + +} diff --git a/rc/filetype/elixir.kak b/rc/filetype/elixir.kak index a2587d1e..83321f00 100644 --- a/rc/filetype/elixir.kak +++ b/rc/filetype/elixir.kak @@ -8,6 +8,11 @@ hook global BufCreate .*[.](ex|exs) %{ set-option buffer filetype elixir } +hook -once global BufSetOption filetype=elixir %{ + require-module elixir +} + +provide-module elixir %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -48,11 +53,11 @@ define-command -hidden elixir-trim-indent %{ define-command -hidden elixir-indent-on-new-line %{ evaluate-commands -draft -itersel %{ - # copy -- comments prefix and following white spaces + # copy -- comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K--\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft \; K } - # indent after line ending with: + # indent after line ending with: # try %{ execute-keys -draft k x (do|else|->)$ & } # filter previous line try %{ execute-keys -draft k : elixir-trim-indent } @@ -75,3 +80,5 @@ hook global WinSetOption filetype=elixir %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elixir-.+ } } + +] diff --git a/rc/filetype/elm.kak b/rc/filetype/elm.kak index 05d1248b..8b97ff22 100644 --- a/rc/filetype/elm.kak +++ b/rc/filetype/elm.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](elm) %{ set-option buffer filetype elm } +hook -once global BufSetOption filetype=elm %{ + require-module elm +} + +provide-module elm %[ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -65,3 +71,5 @@ hook global WinSetOption filetype=elm %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elm-.+ } } + +] diff --git a/rc/filetype/exherbo.kak b/rc/filetype/exherbo.kak index 42cc618c..b0f73929 100644 --- a/rc/filetype/exherbo.kak +++ b/rc/filetype/exherbo.kak @@ -25,6 +25,19 @@ hook global BufCreate .*/etc/paludis(-.*)?/repository_defaults\.conf hook global BufCreate .*/etc/paludis(-.*)?/specpath\.conf %{ set-option buffer filetype paludis-key-value-conf } hook global BufCreate .*/etc/paludis(-.*)?/suggestions(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-specs-conf } +hook -once global BufSetOption filetype=exheres-0-(licence-groups|metadata) %{ + require-module exheres +} + +hook -once global BufSetOption filetype=paludis-(key-value|options|mirrors|specs)-conf %{ + require-module paludis +} + +hook -once global BufSetOption filetype=glep42 %{ + require-module glep42 +} + +provide-module exheres %{ # Highlighters ## exheres-0 Repository metadata files add-highlighter shared/exheres-0-metadata group @@ -61,7 +74,9 @@ hook -group exheres-0-licence-groups-highlight global WinSetOption filetype=exhe add-highlighter window/exheres-0-licence-groups ref exheres-0-licence-groups hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/exheres-0-licence-groups } } +} +provide-module paludis %{ ## Paludis configurations ### options.conf add-highlighter shared/paludis-options-conf group @@ -108,7 +123,9 @@ hook -group paludis-specs-conf-highlight global WinSetOption filetype=paludis-sp add-highlighter window/paludis-specs-conf ref paludis-specs-conf hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-specs-conf } } +} +provide-module glep42 %{ ## News items (GLEP42) add-highlighter shared/glep42 group add-highlighter shared/glep42/ regex ^(Title|Author|Translator|Content-Type|Posted|Revision|News-Item-Format|Display-If-Installed|Display-If-Keyword|Display-If-Profile):([^\n]*(?:\n\h+[^\n]+)*)$ 1:keyword 2:attribute @@ -119,3 +136,4 @@ hook -group glep42-highlight global WinSetOption filetype=glep42 %{ add-highlighter window/glep42 ref glep42 hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/glep42 } } +} diff --git a/rc/filetype/haml.kak b/rc/filetype/haml.kak index e3e7f593..c802e1ff 100644 --- a/rc/filetype/haml.kak +++ b/rc/filetype/haml.kak @@ -8,6 +8,15 @@ hook global BufCreate .*[.](haml) %{ set-option buffer filetype haml } +hook -once global BufSetOption filetype=haml %{ + require-module haml +} + +provide-module haml %[ +require-module ruby +require-module coffee +require-module sass + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -60,3 +69,5 @@ hook global WinSetOption filetype=haml %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window haml-.+ } } + +] diff --git a/rc/filetype/hbs.kak b/rc/filetype/hbs.kak index a0948e6f..d21f8d52 100644 --- a/rc/filetype/hbs.kak +++ b/rc/filetype/hbs.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](hbs) %{ set-option buffer filetype hbs } +hook -once global BufSetOption filetype=hbs %{ + require-module hbs +} + +provide-module hbs %[ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -95,3 +101,5 @@ hook global WinSetOption filetype=hbs %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window hbs-.+ } } + +] diff --git a/rc/filetype/i3.kak b/rc/filetype/i3.kak index e661fcd7..16819cf7 100644 --- a/rc/filetype/i3.kak +++ b/rc/filetype/i3.kak @@ -2,6 +2,12 @@ hook global BufCreate .*(sway|i3)/config %{ set buffer filetype i3 } +hook -once global BufSetOption filetype=i3 %{ + require-module i3 +} + +provide-module i3 %{ + add-highlighter shared/i3 regions add-highlighter shared/i3/code default-region group add-highlighter shared/i3/double_string region %{"} %{"} group @@ -79,3 +85,5 @@ hook global WinSetOption filetype=i3 %[ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window i3-.+ } ] + +} diff --git a/rc/filetype/just.kak b/rc/filetype/just.kak index 201bfc3d..63a847d7 100644 --- a/rc/filetype/just.kak +++ b/rc/filetype/just.kak @@ -5,6 +5,12 @@ hook global BufCreate .*/?[jJ]ustfile %{ set-option buffer filetype justfile } +hook -once global BufSetOption filetype=justfile %{ + require-module justfile +} + +provide-module justfile %{ + # Indentation # ‾‾‾‾‾‾‾‾‾‾‾ @@ -46,3 +52,5 @@ hook global WinSetOption filetype=justfile %{ hook window InsertChar \n -group justfile-indent just-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window justfile-.+ } } + +} diff --git a/rc/filetype/kickstart.kak b/rc/filetype/kickstart.kak index 6f30b4b8..c939a252 100644 --- a/rc/filetype/kickstart.kak +++ b/rc/filetype/kickstart.kak @@ -2,6 +2,12 @@ hook global BufCreate .*\.ks %{ set-option buffer filetype kickstart } +hook -once global BufSetOption filetype=kickstart %{ + require-module kickstart +} + +provide-module kickstart %{ + add-highlighter shared/kickstart regions add-highlighter shared/kickstart/code default-region group add-highlighter shared/kickstart/comment region '(^|\h)\K#' $ fill comment @@ -28,3 +34,5 @@ hook -group kickstart-highlight global WinSetOption filetype=kickstart %{ add-highlighter window/kickstart ref kickstart hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/kickstart } } + +} diff --git a/rc/filetype/latex.kak b/rc/filetype/latex.kak index acb5c1fc..3b8511d1 100644 --- a/rc/filetype/latex.kak +++ b/rc/filetype/latex.kak @@ -8,6 +8,12 @@ hook global BufCreate .*\.tex %{ set-option buffer filetype latex } +hook -once global BufSetOption filetype=latex %{ + require-module latex +} + +provide-module latex %( + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -33,3 +39,5 @@ hook -group latex-highlight global WinSetOption filetype=latex %{ add-highlighter window/latex ref latex hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/latex } } + +) diff --git a/rc/filetype/moon.kak b/rc/filetype/moon.kak index a1d2ecb8..1963905b 100644 --- a/rc/filetype/moon.kak +++ b/rc/filetype/moon.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](moon) %{ set-option buffer filetype moon } +hook -once global BufSetOption filetype=moon %{ + require-module moon +} + +provide-module moon %[ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -105,3 +111,5 @@ hook global WinSetOption filetype=moon %{ unalias window alt moon-alternative-file } } + +] diff --git a/rc/filetype/php.kak b/rc/filetype/php.kak index 4acfde85..e2759129 100644 --- a/rc/filetype/php.kak +++ b/rc/filetype/php.kak @@ -5,6 +5,13 @@ hook global BufCreate .*[.](php) %{ set-option buffer filetype php } +hook -once global BufSetOption filetype=php %{ + require-module php +} + +provide-module php %( +require-module html + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -88,3 +95,5 @@ hook global WinSetOption filetype=php %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window php-.+ } } + +) diff --git a/rc/filetype/pug.kak b/rc/filetype/pug.kak index 13aa839f..121b0b37 100644 --- a/rc/filetype/pug.kak +++ b/rc/filetype/pug.kak @@ -12,6 +12,12 @@ hook global BufCreate .*[.](pug|jade) %{ set-option buffer filetype pug } +hook -once global BufSetOption filetype=pug %{ + require-module pug +} + +provide-module pug %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -72,3 +78,5 @@ hook global WinSetOption filetype=pug %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pug-.+ } } + +} diff --git a/rc/filetype/ragel.kak b/rc/filetype/ragel.kak index b6e8dd4c..0aa6ad03 100644 --- a/rc/filetype/ragel.kak +++ b/rc/filetype/ragel.kak @@ -10,6 +10,12 @@ hook global BufCreate .*[.](ragel|rl) %{ set-option buffer filetype ragel } +hook -once global BufSetOption filetype=ragel %{ + require-module ragel +} + +provide-module ragel %🦀 + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -68,3 +74,5 @@ hook global WinSetOption filetype=ragel %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window ragel-.+ } } + +🦀 diff --git a/rc/filetype/sass.kak b/rc/filetype/sass.kak index d23a7b81..46145f7c 100644 --- a/rc/filetype/sass.kak +++ b/rc/filetype/sass.kak @@ -8,6 +8,12 @@ hook global BufCreate .*[.](sass) %{ set-option buffer filetype sass } +hook -once global BufSetOption filetype=sass %{ + require-module sass +} + +provide-module sass %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -60,3 +66,5 @@ hook global WinSetOption filetype=sass %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window sass-.+ } } + +} diff --git a/rc/filetype/scss.kak b/rc/filetype/scss.kak index bb720db5..de5e4acc 100644 --- a/rc/filetype/scss.kak +++ b/rc/filetype/scss.kak @@ -1,8 +1,6 @@ # http://sass-lang.com # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -# require css.kak - # Detection # ‾‾‾‾‾‾‾‾‾ @@ -10,6 +8,14 @@ hook global BufCreate .*[.](scss) %{ set-option buffer filetype scss } +hook -once global BufSetOption filetype=scss %{ + require-module scss +} + +provide-module scss %[ + +require-module css + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -43,3 +49,5 @@ hook global WinSetOption filetype=scss %[ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scss-.+ } ] + +] diff --git a/rc/filetype/taskpaper.kak b/rc/filetype/taskpaper.kak index dca5de1e..1e5cb321 100644 --- a/rc/filetype/taskpaper.kak +++ b/rc/filetype/taskpaper.kak @@ -6,7 +6,13 @@ hook global BufCreate .*\.taskpaper %{ set-option buffer filetype taskpaper -} +} + +hook -once global BufSetOption filetype=taskpaper %{ + require-module taskpaper +} + +provide-module taskpaper %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -45,3 +51,5 @@ hook global WinSetOption filetype=taskpaper %{ hook window InsertChar \n -group taskpaper-indent taskpaper-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window taskpaper-.+ } } + +} diff --git a/rc/filetype/toml.kak b/rc/filetype/toml.kak index f95fbb9d..141a21fd 100644 --- a/rc/filetype/toml.kak +++ b/rc/filetype/toml.kak @@ -8,6 +8,12 @@ hook global BufCreate .*\.(toml) %{ set-option buffer filetype toml } +hook -once global BufSetOption filetype=toml %{ + require-module toml +} + +provide-module toml %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -61,3 +67,5 @@ hook global WinSetOption filetype=toml %{ hook -once -always window WinSetOption filetype=.* %{ remove-hooks window toml-.+ } } + +} diff --git a/rc/filetype/troff.kak b/rc/filetype/troff.kak index 072cc3d1..73170675 100644 --- a/rc/filetype/troff.kak +++ b/rc/filetype/troff.kak @@ -5,6 +5,12 @@ hook global BufCreate .*\.\d+ %{ set-option buffer filetype troff } +hook -once global BufSetOption filetype=troff %{ + require-module troff +} + +provide-module troff %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -28,3 +34,5 @@ hook -group troff-highlight global WinSetOption filetype=troff %{ add-highlighter window/troff ref troff hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/troff } } + +} diff --git a/rc/filetype/tupfile.kak b/rc/filetype/tupfile.kak index e7ba0d52..a21b6408 100644 --- a/rc/filetype/tupfile.kak +++ b/rc/filetype/tupfile.kak @@ -8,6 +8,12 @@ hook global BufCreate .*/?Tup(file|rules)(\.\w+)?$ %{ set-option buffer filetype tupfile } +hook -once global BufSetOption filetype=tupfile %{ + require-module tupfile +} + +provide-module tupfile %{ + # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -31,3 +37,5 @@ hook -group tupfile-highlight global WinSetOption filetype=tupfile %{ add-highlighter window/tupfile ref tupfile hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/tupfile } } + +} diff --git a/rc/tools/autorestore.kak b/rc/tools/autorestore.kak index f8e3e14d..329a45b0 100644 --- a/rc/tools/autorestore.kak +++ b/rc/tools/autorestore.kak @@ -22,7 +22,7 @@ define-command autorestore-restore-buffer -docstring "Restore the backup for the echo -debug Old backup file(s) found: will not restore ${older} . " fi - exit + exit fi printf %s\\n " @@ -39,7 +39,7 @@ define-command autorestore-restore-buffer -docstring "Restore the backup for the nop %sh{ if [ \"\${kak_opt_autorestore_purge_restored}\" = true ]; then - rm -f \"${buffer_dirname}/.${buffer_basename}.kak.\"* + rm -f \"${buffer_dirname}/.${buffer_basename}.kak.\"* fi } } diff --git a/rc/tools/python/jedi.kak b/rc/tools/python/jedi.kak index a0fe9449..69a41da0 100644 --- a/rc/tools/python/jedi.kak +++ b/rc/tools/python/jedi.kak @@ -1,3 +1,9 @@ +hook -once global BufSetOption filetype=python %{ + require-module jedi +} + +provide-module jedi %{ + declare-option -hidden str jedi_tmp_dir declare-option -hidden completions jedi_completions declare-option -docstring "colon separated list of path added to `python`'s $PYTHONPATH environment variable" \ @@ -17,7 +23,7 @@ define-command jedi-complete -docstring "Complete the current selection" %{ cd $(dirname ${kak_buffile}) header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}" - export PYTHONPATH="$kak_opt_jedi_python_path:$PYTHONPATH" + export PYTHONPATH="$kak_opt_jedi_python_path:$PYTHONPATH" compl=$(python 2> "${dir}/fifo" <<-END import jedi script=jedi.Script(open('$dir/buf', 'r').read(), $kak_cursor_line, $kak_cursor_column - 1, '$kak_buffile') @@ -45,3 +51,5 @@ define-command jedi-disable-autocomplete -docstring "Disable jedi completion" %{ remove-hooks window jedi-autocomplete unalias window complete jedi-complete } + +} diff --git a/rc/tools/rust/racer.kak b/rc/tools/rust/racer.kak index 2371c597..53659a05 100644 --- a/rc/tools/rust/racer.kak +++ b/rc/tools/rust/racer.kak @@ -1,3 +1,9 @@ +hook -once global BufSetOption filetype=rust %{ + require-module racer +} + +provide-module racer %{ + declare-option -hidden str racer_tmp_dir declare-option -hidden completions racer_completions @@ -151,3 +157,5 @@ define-command racer-show-doc -docstring "Show the documentation about the rust fi } } + +} diff --git a/rc/windowing/iterm.kak b/rc/windowing/iterm.kak index 7518d2d0..c48aebc8 100644 --- a/rc/windowing/iterm.kak +++ b/rc/windowing/iterm.kak @@ -5,13 +5,12 @@ ## an iTerm session if not in a tmux session. hook global KakBegin .* %sh{ if [ "$TERM_PROGRAM" = "iTerm.app" ] && [ -z "$TMUX" ]; then - echo " - alias global focus iterm-focus - alias global terminal iterm-terminal-vertical - " + echo "require-module iterm" fi } +provide-module iterm %{ + define-command -hidden -params 2.. iterm-terminal-split-impl %{ nop %sh{ direction="$1" @@ -129,3 +128,8 @@ If no client is passed then the current one is used' \ fi } } + +alias global focus iterm-focus +alias global terminal iterm-terminal-vertical + +} diff --git a/rc/windowing/kitty.kak b/rc/windowing/kitty.kak index 1d2155f7..954af045 100644 --- a/rc/windowing/kitty.kak +++ b/rc/windowing/kitty.kak @@ -1,17 +1,14 @@ -declare-option -docstring %{window type that kitty creates on new and repl calls (kitty|os)} str kitty_window_type kitty hook -group kitty-hooks global KakBegin .* %sh{ if [ "$TERM" = "xterm-kitty" ] && [ -z "$TMUX" ]; then - echo " - alias global terminal kitty-terminal - alias global terminal-tab kitty-terminal-tab - alias global focus kitty-focus - alias global repl kitty-repl - alias global send-text kitty-send-text - " + echo "require-module kitty" fi } +provide-module kitty %{ + +declare-option -docstring %{window type that kitty creates on new and repl calls (kitty|os)} str kitty_window_type kitty + define-command kitty-terminal -params 1.. -shell-completion -docstring ' kitty-terminal []: create a new terminal as a kitty window The program passed as argument will be executed in the new terminal' \ @@ -63,3 +60,11 @@ define-command kitty-send-text -docstring "send the selected text to the repl wi kitty @ send-text -m=title:kak_repl_window "${kak_selection}" } } + +alias global terminal kitty-terminal +alias global terminal-tab kitty-terminal-tab +alias global focus kitty-focus +alias global repl kitty-repl +alias global send-text kitty-send-text + +} diff --git a/rc/windowing/repl/tmux.kak b/rc/windowing/repl/tmux.kak index a176f5f5..291717db 100644 --- a/rc/windowing/repl/tmux.kak +++ b/rc/windowing/repl/tmux.kak @@ -1,28 +1,14 @@ # http://tmux.github.io/ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -declare-option -docstring "tmux pane id in which the REPL is running" str tmux_repl_id - -hook global KakBegin .* %sh{ - if [ -n "$TMUX" ]; then - VERSION_TMUX=$(tmux -V | cut -d' ' -f2) - VERSION_TMUX=${VERSION_TMUX%%.*} - - if [ "${VERSION_TMUX}" = "master" ] \ - || [ "${VERSION_TMUX}" -ge 2 ]; then - echo " - alias global repl tmux-repl-horizontal - alias global send-text tmux-send-text - " - else - echo " - alias global repl tmux-repl-disabled - alias global send-text tmux-repl-disabled - " - fi - fi +hook global ModuleLoad tmux %{ + require-module tmux-repl } +provide-module tmux-repl %{ + +declare-option -docstring "tmux pane id in which the REPL is running" str tmux_repl_id + define-command -hidden -params 1..2 tmux-repl-impl %{ evaluate-commands %sh{ if [ -z "$TMUX" ]; then @@ -52,7 +38,7 @@ define-command tmux-repl-window -params 0..1 -command-completion -docstring "Cre define-command -hidden tmux-send-text -params 0..1 -docstring "tmux-send-text [text]: Send text(append new line) to the REPL pane. If no text is passed, then the selection is used" %{ nop %sh{ - if [ $# -eq 0 ]; then + if [ $# -eq 0 ]; then tmux set-buffer -b kak_selection "${kak_selection}" else tmux set-buffer -b kak_selection "$1" @@ -65,3 +51,23 @@ define-command -hidden tmux-repl-disabled %{ evaluate-commands %sh{ VERSION_TMUX=$(tmux -V) printf %s "echo -markup %{{Error}The version of tmux is too old: got ${VERSION_TMUX}, expected >= 2.x}" } } + +evaluate-commands %sh{ + VERSION_TMUX=$(tmux -V | cut -d' ' -f2) + VERSION_TMUX=${VERSION_TMUX%%.*} + + if [ "${VERSION_TMUX}" = "master" ] \ + || [ "${VERSION_TMUX}" -ge 2 ]; then + echo " + alias global repl tmux-repl-horizontal + alias global send-text tmux-send-text + " + else + echo " + alias global repl tmux-repl-disabled + alias global send-text tmux-repl-disabled + " + fi +} + +} diff --git a/rc/windowing/repl/x11.kak b/rc/windowing/repl/x11.kak index 865e2748..54966c2a 100644 --- a/rc/windowing/repl/x11.kak +++ b/rc/windowing/repl/x11.kak @@ -1,3 +1,9 @@ +hook global ModuleLoad x11 %{ + require-module x11-repl +} + +provide-module x11-repl %{ + # termcmd should already be set in x11.kak define-command -docstring %{x11-repl []: create a new window for repl interaction All optional parameters are forwarded to the new window} \ @@ -24,3 +30,5 @@ define-command x11-send-text -docstring "send the selected text to the repl wind alias global repl x11-repl alias global send-text x11-send-text + +} From 49b00992ca3417800acf689033a3557725ff3dc1 Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Wed, 13 Mar 2019 14:38:21 -0700 Subject: [PATCH 07/18] Fix x11 overriding tmux --- rc/windowing/x11.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/windowing/x11.kak b/rc/windowing/x11.kak index a1a747cf..0bf457b0 100644 --- a/rc/windowing/x11.kak +++ b/rc/windowing/x11.kak @@ -1,7 +1,7 @@ # x11 hook global KakBegin .* %sh{ - if [ -n "$DISPLAY" ]; then + if [ -n "$DISPLAY" && [ -z "$TMUX" ]; then echo "require-module x11" fi } From 87bcf23f3ef60d292aba6043087d91cf510abe38 Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Fri, 15 Mar 2019 11:52:33 -0700 Subject: [PATCH 08/18] Added module system to changelog, commands, and hooks doc files --- doc/pages/changelog.asciidoc | 9 ++++++++- doc/pages/commands.asciidoc | 9 +++++++++ doc/pages/hooks.asciidoc | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/doc/pages/changelog.asciidoc b/doc/pages/changelog.asciidoc index 6c7ab63d..206a3c5a 100644 --- a/doc/pages/changelog.asciidoc +++ b/doc/pages/changelog.asciidoc @@ -15,13 +15,20 @@ released versions. * `edit -scratch` with no buffer name will create a new scratch buffer with a unique autogenerated name. +* Introduced a module system using the `provides-module` and + `requires-module` commands that allows for lazily loading language + support files with dependency resolution. + +* Added a new hook `ModuleLoad` which is run when a module is loaded, as + now options needed by modules aren't defined until the module is loaded. + == Kakoune 2019.01.20 * `auto_complete` has been renamed to `autocomplete` for more consistency. * Start of a builtin key parser in the ncurses ui bypassing - the ncurses one. Can be favored by setting the ui option + the ncurses one. Can be favored by setting the ui option `ncurses_builtin_key_parser` to `true`. * Right clicks extend the current selection, the control modifier allows diff --git a/doc/pages/commands.asciidoc b/doc/pages/commands.asciidoc index 62b80818..9f5e238e 100644 --- a/doc/pages/commands.asciidoc +++ b/doc/pages/commands.asciidoc @@ -312,6 +312,15 @@ but not really useful in that context. *debug* {info,buffers,options,memory,shared-strings,profile-hash-maps,faces,mappings}:: print some debug information in the *\*debug** buffer +== Module commands + +*provide-module* [] :: + declares a new module that is provided by the given commands. The commands + passed into the module are guaranteed to be run only once. + +*require-module* :: + guarantees the module is loaded before continuing command execution + == Multiple commands Commands (c.f. previous sections) can be chained, by being separated either diff --git a/doc/pages/hooks.asciidoc b/doc/pages/hooks.asciidoc index a0f00bf4..d91781fb 100644 --- a/doc/pages/hooks.asciidoc +++ b/doc/pages/hooks.asciidoc @@ -180,6 +180,9 @@ name. Hooks with no description will always use an empty string. *RawKey* `key`:: Triggered whenever a key is pressed by the user +*ModuleLoad* `module`:: + Triggered when a module is loaded + Note that some hooks will not consider underlying scopes depending on what context they are bound to be run into, e.g. the `BufWritePost` hook is a buffer hook, and will not consider the `window` scope. From 93ced79f37fab2cc6843d9c8f097f577b69aad9a Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Sat, 16 Mar 2019 01:09:42 -0700 Subject: [PATCH 09/18] Updated the changelog, commands, and hooks docs to be clearer --- doc/pages/changelog.asciidoc | 4 ++-- doc/pages/commands.asciidoc | 12 +++++++++--- doc/pages/hooks.asciidoc | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/doc/pages/changelog.asciidoc b/doc/pages/changelog.asciidoc index 206a3c5a..61b2af89 100644 --- a/doc/pages/changelog.asciidoc +++ b/doc/pages/changelog.asciidoc @@ -19,8 +19,8 @@ released versions. `requires-module` commands that allows for lazily loading language support files with dependency resolution. -* Added a new hook `ModuleLoad` which is run when a module is loaded, as - now options needed by modules aren't defined until the module is loaded. +* Added a new hook `ModuleLoad` which is run when a module is loaded, + allowing for module specific configuration. == Kakoune 2019.01.20 diff --git a/doc/pages/commands.asciidoc b/doc/pages/commands.asciidoc index 9f5e238e..c9c84b96 100644 --- a/doc/pages/commands.asciidoc +++ b/doc/pages/commands.asciidoc @@ -315,11 +315,17 @@ but not really useful in that context. == Module commands *provide-module* [] :: - declares a new module that is provided by the given commands. The commands - passed into the module are guaranteed to be run only once. + declares a module *name* that is defined by *commands*. *commands* will be + evaluated as if by source the first time *require-module * is run. + +*-override*::: + allow the module to replace and existing one with the same name *require-module* :: - guarantees the module is loaded before continuing command execution + guarantees the commands associated with *name* have been evaluated before + continuing command execution. Fails if *name* has not been defined by a + *provide-module* command. Does nothing if the associated commands have + already been evaluated. == Multiple commands diff --git a/doc/pages/hooks.asciidoc b/doc/pages/hooks.asciidoc index d91781fb..2615bc52 100644 --- a/doc/pages/hooks.asciidoc +++ b/doc/pages/hooks.asciidoc @@ -181,7 +181,7 @@ name. Hooks with no description will always use an empty string. Triggered whenever a key is pressed by the user *ModuleLoad* `module`:: - Triggered when a module is loaded + Triggered when a module is evaluated by the first `require-module` call Note that some hooks will not consider underlying scopes depending on what context they are bound to be run into, e.g. the `BufWritePost` hook is a buffer From c40bb6fc009bd0933290b61717605c0d5bf68aee Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Sat, 16 Mar 2019 01:38:32 -0700 Subject: [PATCH 10/18] Evaluate modules in an empty context --- src/command_manager.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/command_manager.cc b/src/command_manager.cc index aff9e3fd..1fdfa34d 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -63,7 +63,8 @@ void CommandManager::load_module(StringView module_name, Context& context) return; module->value.loaded = true; - execute(module->value.commands, context); + Context empty_context{Context::EmptyContextFlag{}}; + execute(module->value.commands, empty_context); module->value.commands.clear(); context.hooks().run_hook(Hook::ModuleLoad, module_name, context); From 891c6ca8e2b28942f1aeb0cfe553fb052a420024 Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Sat, 16 Mar 2019 01:41:30 -0700 Subject: [PATCH 11/18] Fix typo in changelog --- doc/pages/changelog.asciidoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/pages/changelog.asciidoc b/doc/pages/changelog.asciidoc index 61b2af89..5d1493fe 100644 --- a/doc/pages/changelog.asciidoc +++ b/doc/pages/changelog.asciidoc @@ -15,8 +15,8 @@ released versions. * `edit -scratch` with no buffer name will create a new scratch buffer with a unique autogenerated name. -* Introduced a module system using the `provides-module` and - `requires-module` commands that allows for lazily loading language +* Introduced a module system using the `provide-module` and + `require-module` commands that allows for lazily loading language support files with dependency resolution. * Added a new hook `ModuleLoad` which is run when a module is loaded, From 887a5223ac8e71ca6d7f0cd9c764d68ce3d90dbe Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Wed, 27 Mar 2019 10:17:37 -0700 Subject: [PATCH 12/18] Fixed if statement in x11 detection --- rc/windowing/x11.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/windowing/x11.kak b/rc/windowing/x11.kak index 0bf457b0..004b0b0a 100644 --- a/rc/windowing/x11.kak +++ b/rc/windowing/x11.kak @@ -1,7 +1,7 @@ # x11 hook global KakBegin .* %sh{ - if [ -n "$DISPLAY" && [ -z "$TMUX" ]; then + if [ -n "$DISPLAY" ] && [ -z "$TMUX" ]; then echo "require-module x11" fi } From 80ac46e09de0a30c0bf590fd50b6cbf9bfd1c41b Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Tue, 9 Apr 2019 20:54:19 -0700 Subject: [PATCH 13/18] Fixed many of the filetype support modules to not use `BufSetOption` to load --- rc/filetype/asciidoc.kak | 16 ++-- rc/filetype/c-family.kak | 76 +++++++++---------- rc/filetype/clojure.kak | 35 +++++---- rc/filetype/css.kak | 35 +++++---- rc/filetype/d.kak | 42 +++++----- rc/filetype/dart.kak | 47 ++++++------ rc/filetype/dockerfile.kak | 23 +++--- rc/filetype/elixir.kak | 31 ++++---- rc/filetype/go.kak | 68 ++++++++--------- rc/filetype/haskell.kak | 33 ++++---- rc/filetype/html.kak | 41 +++++----- rc/filetype/javascript.kak | 45 ++++++----- rc/filetype/json.kak | 36 ++++----- rc/filetype/kakrc.kak | 45 +++++------ rc/filetype/latex.kak | 18 ++--- rc/filetype/lisp.kak | 30 ++++---- rc/filetype/lua.kak | 43 +++++------ rc/filetype/makefile.kak | 32 ++++---- rc/filetype/nim.kak | 38 +++++----- rc/filetype/ocaml.kak | 34 +++++---- rc/filetype/perl.kak | 78 +++++++++---------- rc/filetype/php.kak | 32 ++++---- rc/filetype/pony.kak | 38 +++++----- rc/filetype/protobuf.kak | 61 ++++++++------- rc/filetype/pug.kak | 31 ++++---- rc/filetype/python.kak | 152 ++++++++++++++++++------------------- rc/filetype/ragel.kak | 32 ++++---- rc/filetype/ruby.kak | 48 ++++++------ rc/filetype/rust.kak | 47 ++++++------ rc/filetype/scheme.kak | 39 +++++----- rc/filetype/scss.kak | 35 +++++---- rc/filetype/sh.kak | 17 ++--- rc/filetype/sql.kak | 24 +++--- rc/filetype/swift.kak | 13 ++-- rc/filetype/troff.kak | 18 ++--- rc/filetype/tupfile.kak | 17 ++--- 36 files changed, 712 insertions(+), 738 deletions(-) diff --git a/rc/filetype/asciidoc.kak b/rc/filetype/asciidoc.kak index 21607da0..b6e79002 100644 --- a/rc/filetype/asciidoc.kak +++ b/rc/filetype/asciidoc.kak @@ -8,8 +8,14 @@ hook global BufCreate .+\.(a(scii)?doc|asc) %{ set-option buffer filetype asciidoc } -hook -once global BufSetOption filetype=asciidoc %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook -group asciidoc-highlight global WinSetOption filetype=asciidoc %{ require-module asciidoc + + add-highlighter window/asciidoc ref asciidoc + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/asciidoc } } provide-module asciidoc %{ @@ -40,12 +46,4 @@ add-highlighter shared/asciidoc/ regex ^:[-\w]+: 0:meta # Commands # ‾‾‾‾‾‾‾‾ -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group asciidoc-highlight global WinSetOption filetype=asciidoc %{ - add-highlighter window/asciidoc ref asciidoc - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/asciidoc } -} - } diff --git a/rc/filetype/c-family.kak b/rc/filetype/c-family.kak index 68c2a387..9e30e200 100644 --- a/rc/filetype/c-family.kak +++ b/rc/filetype/c-family.kak @@ -23,8 +23,39 @@ hook global BufCreate .*\.m %{ set-option buffer filetype objc } -hook -once global BufSetOption filetype=(c|cpp|objc) %{ +hook global WinSetOption filetype=(c|cpp|objc) %[ require-module c-family + + evaluate-commands "set-option window static_words %%opt{%val{hook_param_capture_1}_static_words}" + + hook -group "%val{hook_param_capture_1}-trim-indent" window ModeChange insert:.* c-family-trim-indent + hook -group "%val{hook_param_capture_1}-insert" window InsertChar \n c-family-insert-on-newline + hook -group "%val{hook_param_capture_1}-indent" window InsertChar \n c-family-indent-on-newline + hook -group "%val{hook_param_capture_1}-indent" window InsertChar \{ c-family-indent-on-opening-curly-brace + hook -group "%val{hook_param_capture_1}-indent" window InsertChar \} c-family-indent-on-closing-curly-brace + hook -group "%val{hook_param_capture_1}-insert" window InsertChar \} c-family-insert-on-closing-curly-brace + + alias window alt "%val{hook_param_capture_1}-alternative-file" + + hook -once -always window WinSetOption filetype=.* " + remove-hooks window %val{hook_param_capture_1}-.+ + unalias window alt %val{hook_param_capture_1}-alternative-file + " +] + +hook -group c-highlight global WinSetOption filetype=c %{ + add-highlighter window/c ref c + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/c } +} + +hook -group cpp-highlight global WinSetOption filetype=cpp %{ + add-highlighter window/cpp ref cpp + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cpp } +} + +hook -group objc-highlight global WinSetOption filetype=objc %{ + add-highlighter window/objc ref objc + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/objc } } @@ -234,9 +265,7 @@ evaluate-commands %sh{ join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } # Add the language's grammar to the static completion list - printf '%s\n' "hook global WinSetOption filetype=c %{ - set-option window static_words $(join "${keywords} ${attributes} ${types} ${macros}" ' ') - }" + printf %s\\n "declare-option str-list c_static_words $(join "${keywords} ${attributes} ${types} ${macros}" ' ')" # Highlight keywords printf %s " @@ -286,9 +315,7 @@ evaluate-commands %sh{ join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } # Add the language's grammar to the static completion list - printf %s\\n "hook global WinSetOption filetype=cpp %{ - set-option window static_words $(join "${keywords} ${attributes} ${entities} ${types} ${values}" ' ') - }" + printf %s\\n "declare-option str-list cpp_static_words $(join "${keywords} ${attributes} ${entities} ${types} ${values}" ' ')" # Highlight keywords printf %s " @@ -328,9 +355,7 @@ evaluate-commands %sh{ join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } # Add the language's grammar to the static completion list - printf %s\\n "hook global WinSetOption filetype=objc %{ - set-option window static_words $(join "${keywords} ${attributes} ${types} ${values} ${decorators}" ' ') - }" + printf %s\\n "declare-option str-list objc_static_words $(join "${keywords} ${attributes} ${types} ${values} ${decorators}" ' ')" # Highlight keywords printf %s " @@ -342,37 +367,6 @@ evaluate-commands %sh{ " } -hook global WinSetOption filetype=(c|cpp|objc) %[ - hook -group "%val{hook_param_capture_1}-trim-indent" window ModeChange insert:.* c-family-trim-indent - hook -group "%val{hook_param_capture_1}-insert" window InsertChar \n c-family-insert-on-newline - hook -group "%val{hook_param_capture_1}-indent" window InsertChar \n c-family-indent-on-newline - hook -group "%val{hook_param_capture_1}-indent" window InsertChar \{ c-family-indent-on-opening-curly-brace - hook -group "%val{hook_param_capture_1}-indent" window InsertChar \} c-family-indent-on-closing-curly-brace - hook -group "%val{hook_param_capture_1}-insert" window InsertChar \} c-family-insert-on-closing-curly-brace - - alias window alt "%val{hook_param_capture_1}-alternative-file" - - hook -once -always window WinSetOption filetype=.* " - remove-hooks window %val{hook_param_capture_1}-.+ - unalias window alt %val{hook_param_capture_1}-alternative-file - " -] - -hook -group c-highlight global WinSetOption filetype=c %{ - add-highlighter window/c ref c - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/c } -} - -hook -group cpp-highlight global WinSetOption filetype=cpp %{ - add-highlighter window/cpp ref cpp - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cpp } -} - -hook -group objc-highlight global WinSetOption filetype=objc %{ - add-highlighter window/objc ref objc - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/objc } -} - declare-option -docstring %{control the type of include guard to be inserted in empty headers Can be one of the following: ifdef: old style ifndef/define guard diff --git a/rc/filetype/clojure.kak b/rc/filetype/clojure.kak index 062e4f0c..e7852227 100644 --- a/rc/filetype/clojure.kak +++ b/rc/filetype/clojure.kak @@ -8,8 +8,22 @@ hook global BufCreate .*[.](clj|cljc|cljs|cljx|edn) %{ set-option buffer filetype clojure } -hook -once global BufSetOption filetype=clojure %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ +hook global WinSetOption filetype=clojure %[ require-module clojure + + set-option window static_words %opt{clojure_static_words} + + hook window ModeChange insert:.* -group clojure-trim-indent clojure-trim-indent + hook window InsertChar \n -group clojure-indent clojure-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window clojure-.+ } +] + +hook -group clojure-highlight global WinSetOption filetype=clojure %{ + add-highlighter window/clojure ref clojure + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/clojure } } provide-module clojure %{ @@ -157,12 +171,11 @@ evaluate-commands %sh{ print_word_highlighter(core_fns, "function"); print_word_highlighter(core_vars, "variable"); - printf(" hook global WinSetOption filetype=clojure %%{\n"\ - " set-option window static_words "); + printf("declare-option str-list clojure_static_words ") print_static_words(keywords); print_static_words(core_fns); print_static_words(core_vars); - printf("\n }\n"); + printf("\n"); } EOF } @@ -199,18 +212,4 @@ define-command -hidden clojure-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group clojure-highlight global WinSetOption filetype=clojure %{ - add-highlighter window/clojure ref clojure - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/clojure } -} - -hook global WinSetOption filetype=clojure %[ - hook window ModeChange insert:.* -group clojure-trim-indent clojure-trim-indent - hook window InsertChar \n -group clojure-indent clojure-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window clojure-.+ } -] - } diff --git a/rc/filetype/css.kak b/rc/filetype/css.kak index 8c5def9c..f8a0d26e 100644 --- a/rc/filetype/css.kak +++ b/rc/filetype/css.kak @@ -8,10 +8,26 @@ hook global BufCreate .*[.](css) %{ set-option buffer filetype css } -hook -once global BufSetOption filetype=css %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=css %[ require-module css + + hook window ModeChange insert:.* -group css-trim-indent css-trim-indent + hook window InsertChar \n -group css-indent css-indent-on-new-line + hook window InsertChar \} -group css-indent css-indent-on-closing-curly-brace + set-option buffer extra_word_chars '_' '-' + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window css-.+ } +] + +hook -group css-highlight global WinSetOption filetype=css %{ + add-highlighter window/css ref css + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/css } } + provide-module css %[ # Highlighters @@ -64,21 +80,4 @@ define-command -hidden css-indent-on-closing-curly-brace %[ ] ] -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group css-highlight global WinSetOption filetype=css %{ - add-highlighter window/css ref css - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/css } -} - -hook global WinSetOption filetype=css %[ - hook window ModeChange insert:.* -group css-trim-indent css-trim-indent - hook window InsertChar \n -group css-indent css-indent-on-new-line - hook window InsertChar \} -group css-indent css-indent-on-closing-curly-brace - set-option buffer extra_word_chars '_' '-' - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window css-.+ } -] - ] diff --git a/rc/filetype/d.kak b/rc/filetype/d.kak index b042f4f9..3772ff8b 100644 --- a/rc/filetype/d.kak +++ b/rc/filetype/d.kak @@ -8,8 +8,26 @@ hook global BufCreate .*\.di? %{ set-option buffer filetype d } -hook -once global BufSetOption filetype=d %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=d %{ require-module d + + set-option window static_words %opt{d_static_words} + + # cleanup trailing whitespaces when exiting insert mode + hook window ModeChange insert:.* -group d-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } + hook window InsertChar \n -group d-indent d-indent-on-new-line + hook window InsertChar \{ -group d-indent d-indent-on-opening-curly-brace + hook window InsertChar \} -group d-indent d-indent-on-closing-curly-brace + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window d-.+ } +} + +hook -group d-highlight global WinSetOption filetype=d %{ + add-highlighter window/d ref d + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/d } } provide-module d %🦀 @@ -68,9 +86,7 @@ evaluate-commands %sh{ decorators="disable|property|nogc|safe|trusted|system" # Add the language's grammar to the static completion list - printf %s\\n "hook global WinSetOption filetype=d %{ - set-option window static_words ${keywords} ${attributes} ${types} ${values} ${decorators} ${properties} - }" | tr '|' ' ' + printf %s\\n "declare-option str-list d_static_words ${keywords} ${attributes} ${types} ${values} ${decorators} ${properties}" | tr '|' ' ' # Highlight keywords printf %s " @@ -119,22 +135,4 @@ define-command -hidden d-indent-on-closing-curly-brace %[ try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group d-highlight global WinSetOption filetype=d %{ - add-highlighter window/d ref d - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/d } -} - -hook global WinSetOption filetype=d %{ - # cleanup trailing whitespaces when exiting insert mode - hook window ModeChange insert:.* -group d-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } - hook window InsertChar \n -group d-indent d-indent-on-new-line - hook window InsertChar \{ -group d-indent d-indent-on-opening-curly-brace - hook window InsertChar \} -group d-indent d-indent-on-closing-curly-brace - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window d-.+ } -} - 🦀 diff --git a/rc/filetype/dart.kak b/rc/filetype/dart.kak index 49701429..660c550e 100644 --- a/rc/filetype/dart.kak +++ b/rc/filetype/dart.kak @@ -8,11 +8,29 @@ hook global BufCreate .*\.dart %{ set-option buffer filetype dart } -hook -once global BufSetOption filetype=dart %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=dart %{ require-module dart + + set-option window static_words %opt{dart_static_words} + + # cleanup trailing whitespaces when exiting insert mode + hook window ModeChange insert:.* -group dart-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } + hook window InsertChar \n -group dart-indent dart-indent-on-new-line + hook window InsertChar \{ -group dart-indent dart-indent-on-opening-curly-brace + hook window InsertChar \} -group dart-indent dart-indent-on-closing-curly-brace + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window dart-.+ } } -provide-module dart %{ +hook -group dart-highlight global WinSetOption filetype=dart %{ + add-highlighter window/dart ref dart + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dart } +} + +provide-module dart %🦀 # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -44,9 +62,7 @@ evaluate-commands %sh{ classes="[A-Z][a-zA-Z0-9]*" # Add the language's grammar to the static completion list - printf %s\\n "hook global WinSetOption filetype=dart %{ - set-option window static_words ${keywords} ${attributes} ${types} ${values} - }" | tr '|' ' ' + printf %s\\n "declare-option str-list dart_static_words ${keywords} ${attributes} ${types} ${values}" | tr '|' ' ' # Highlight keywords printf %s " @@ -93,23 +109,4 @@ define-command -hidden dart-indent-on-closing-curly-brace %[ try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group dart-highlight global WinSetOption filetype=dart %{ - add-highlighter window/dart ref dart - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dart } -} - -hook global WinSetOption filetype=dart %{ - # cleanup trailing whitespaces when exiting insert mode - hook window ModeChange insert:.* -group dart-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } - hook window InsertChar \n -group dart-indent dart-indent-on-new-line - hook window InsertChar \{ -group dart-indent dart-indent-on-opening-curly-brace - hook window InsertChar \} -group dart-indent dart-indent-on-closing-curly-brace - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window dart-.+ } -} - -# balancing }}} -} +🦀 diff --git a/rc/filetype/dockerfile.kak b/rc/filetype/dockerfile.kak index b76716e2..f308ec92 100644 --- a/rc/filetype/dockerfile.kak +++ b/rc/filetype/dockerfile.kak @@ -10,8 +10,17 @@ hook global BufCreate .*/?Dockerfile(\.\w+)?$ %{ set-option buffer filetype dockerfile } -hook -once global BufSetOption filetype=dockerfile %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=dockerfile %{ require-module dockerfile + set-option window static_words %opt{dockerfile_static_words} +} + +hook -group dockerfile-highlight global WinSetOption filetype=dockerfile %{ + add-highlighter window/dockerfile ref dockerfile + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dockerfile } } provide-module dockerfile %{ @@ -31,9 +40,7 @@ evaluate-commands %sh{ keywords="${keywords}|MAINTAINER|RUN|SHELL|STOPSIGNAL|USER|VOLUME|WORKDIR" # Add the language's grammar to the static completion list - printf %s\\n "hook global WinSetOption filetype=dockerfile %{ - set window static_words ONBUILD|${keywords} - }" | tr '|' ' ' + printf %s\\n "declare-option str-list dockerfile_static_words ONBUILD|${keywords}" | tr '|' ' ' # Highlight keywords printf %s " @@ -45,12 +52,4 @@ evaluate-commands %sh{ add-highlighter shared/dockerfile/code/ regex '\$\{[\w_]+\}' 0:value add-highlighter shared/dockerfile/code/ regex '\$[\w_]+' 0:value -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group dockerfile-highlight global WinSetOption filetype=dockerfile %{ - add-highlighter window/dockerfile ref dockerfile - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dockerfile } -} - } diff --git a/rc/filetype/elixir.kak b/rc/filetype/elixir.kak index 83321f00..56c3681e 100644 --- a/rc/filetype/elixir.kak +++ b/rc/filetype/elixir.kak @@ -8,10 +8,24 @@ hook global BufCreate .*[.](ex|exs) %{ set-option buffer filetype elixir } -hook -once global BufSetOption filetype=elixir %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=elixir %{ require-module elixir + + hook window ModeChange insert:.* -group elixir-trim-indent elixir-trim-indent + hook window InsertChar \n -group elixir-indent elixir-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elixir-.+ } } +hook -group elixir-highlight global WinSetOption filetype=elixir %{ + add-highlighter window/elixir ref elixir + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/elixir } +} + + provide-module elixir %[ # Highlighters @@ -66,19 +80,4 @@ define-command -hidden elixir-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group elixir-highlight global WinSetOption filetype=elixir %{ - add-highlighter window/elixir ref elixir - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/elixir } -} - -hook global WinSetOption filetype=elixir %{ - hook window ModeChange insert:.* -group elixir-trim-indent elixir-trim-indent - hook window InsertChar \n -group elixir-indent elixir-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elixir-.+ } -} - ] diff --git a/rc/filetype/go.kak b/rc/filetype/go.kak index 2df0ba9d..d697c574 100644 --- a/rc/filetype/go.kak +++ b/rc/filetype/go.kak @@ -8,8 +8,26 @@ hook global BufCreate .*\.go %{ set-option buffer filetype go } -hook -once global BufSetOption filetype=go %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=go %{ require-module go + + set-option window static_words %opt{go_static_words} + + # cleanup trailing whitespaces when exiting insert mode + hook window ModeChange insert:.* -group go-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } + hook window InsertChar \n -group go-indent go-indent-on-new-line + hook window InsertChar \{ -group go-indent go-indent-on-opening-curly-brace + hook window InsertChar \} -group go-indent go-indent-on-closing-curly-brace + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window go-.+ } +} + +hook -group go-highlight global WinSetOption filetype=go %{ + add-highlighter window/go ref go + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/go } } provide-module go %🦀 @@ -29,26 +47,26 @@ add-highlighter shared/go/code/ regex %{-?([0-9]*\.(?!0[xX]))?\b([0-9]+|0[xX][0- evaluate-commands %sh{ # Grammar - keywords="break|default|func|interface|select|case|defer|go|map|struct" - keywords="${keywords}|chan|else|goto|package|switch|const|fallthrough|if|range|type" - keywords="${keywords}|continue|for|import|return|var" - types="bool|byte|chan|complex128|complex64|error|float32|float64|int|int16|int32" - types="${types}|int64|int8|interface|intptr|map|rune|string|struct|uint|uint16|uint32|uint64|uint8" - values="false|true|nil|iota" - functions="append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover" + keywords='break default func interface select case defer go map struct + chan else goto package switch const fallthrough if range type + continue for import return var' + types='bool byte chan complex128 complex64 error float32 float64 int int16 int32 + int64 int8 interface intptr map rune string struct uint uint16 uint32 uint64 uint8' + values='false true nil iota' + functions='append cap close complex copy delete imag len make new panic print println real recover' + + join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } # Add the language's grammar to the static completion list - printf %s\\n "hook global WinSetOption filetype=go %{ - set-option window static_words ${keywords} ${attributes} ${types} ${values} ${functions} - }" | tr '|' ' ' + printf %s\\n "declare-option str-list go_static_words $(join "${keywords} ${attributes} ${types} ${values} ${functions}" ' ')" # Highlight keywords printf %s " - add-highlighter shared/go/code/ regex \b(${keywords})\b 0:keyword - add-highlighter shared/go/code/ regex \b(${attributes})\b 0:attribute - add-highlighter shared/go/code/ regex \b(${types})\b 0:type - add-highlighter shared/go/code/ regex \b(${values})\b 0:value - add-highlighter shared/go/code/ regex \b(${functions})\b 0:builtin + add-highlighter shared/go/code/ regex \b($(join "${keywords}" '|'))\b 0:keyword + add-highlighter shared/go/code/ regex \b($(join "${attributes}" '|'))\b 0:attribute + add-highlighter shared/go/code/ regex \b($(join "${types}" '|'))\b 0:type + add-highlighter shared/go/code/ regex \b($(join "${values}" '|'))\b 0:value + add-highlighter shared/go/code/ regex \b($(join "${functions}" '|'))\b 0:builtin " } @@ -84,22 +102,4 @@ define-command -hidden go-indent-on-closing-curly-brace %[ try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group go-highlight global WinSetOption filetype=go %{ - add-highlighter window/go ref go - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/go } -} - -hook global WinSetOption filetype=go %{ - # cleanup trailing whitespaces when exiting insert mode - hook window ModeChange insert:.* -group go-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } - hook window InsertChar \n -group go-indent go-indent-on-new-line - hook window InsertChar \{ -group go-indent go-indent-on-opening-curly-brace - hook window InsertChar \} -group go-indent go-indent-on-closing-curly-brace - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window go-.+ } -} - 🦀 diff --git a/rc/filetype/haskell.kak b/rc/filetype/haskell.kak index ecedbcfd..88b3ed29 100644 --- a/rc/filetype/haskell.kak +++ b/rc/filetype/haskell.kak @@ -8,10 +8,25 @@ hook global BufCreate .*[.](hs) %{ set-option buffer filetype haskell } -hook -once global BufSetOption filetype=haskell %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=haskell %{ require-module haskell + + set-option window extra_word_chars '_' "'" + hook window ModeChange insert:.* -group haskell-trim-indent haskell-trim-indent + hook window InsertChar \n -group haskell-indent haskell-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window haskell-.+ } } +hook -group haskell-highlight global WinSetOption filetype=haskell %{ + add-highlighter window/haskell ref haskell + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/haskell } +} + + provide-module haskell %[ # Highlighters @@ -94,20 +109,4 @@ define-command -hidden haskell-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group haskell-highlight global WinSetOption filetype=haskell %{ - add-highlighter window/haskell ref haskell - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/haskell } -} - -hook global WinSetOption filetype=haskell %{ - set-option window extra_word_chars '_' "'" - hook window ModeChange insert:.* -group haskell-trim-indent haskell-trim-indent - hook window InsertChar \n -group haskell-indent haskell-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window haskell-.+ } -} - ] diff --git a/rc/filetype/html.kak b/rc/filetype/html.kak index 81db5c9b..57d1ee6e 100644 --- a/rc/filetype/html.kak +++ b/rc/filetype/html.kak @@ -12,10 +12,29 @@ hook global BufCreate .*\.xml %{ set-option buffer filetype xml } -hook -once global BufSetOption filetype=(html|xml) %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=(html|xml) %{ require-module html + + hook window ModeChange insert:.* -group "%val{hook_param_capture_1}-trim-indent" html-trim-indent + hook window InsertChar '>' -group "%val{hook_param_capture_1}-indent" html-indent-on-greater-than + hook window InsertChar \n -group "%val{hook_param_capture_1}-indent" html-indent-on-new-line + + hook -once -always window WinSetOption "filetype=.*" " + remove-hooks window ""%val{hook_param_capture_1}-.+"" + " } +hook -group html-highlight global WinSetOption filetype=(html|xml) %{ + add-highlighter "window/%val{hook_param_capture_1}" ref html + hook -once -always window WinSetOption "filetype=.*" " + remove-highlighter ""window/%val{hook_param_capture_1}"" + " +} + + provide-module html %[ try %{ @@ -65,24 +84,4 @@ define-command -hidden html-indent-on-new-line %{ try %{ execute-keys -draft k (?!area)(?!base)(?!br)(?!col)(?!command)(?!embed)(?!hr)(?!img)(?!input)(?!keygen)(?!link)(?!menuitem)(?!meta)(?!param)(?!source)(?!track)(?!wbr)(?!/)(?!>)[a-zA-Z0-9_-]+[^>]*?>$ j } } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group html-highlight global WinSetOption filetype=(html|xml) %{ - add-highlighter "window/%val{hook_param_capture_1}" ref html - hook -once -always window WinSetOption "filetype=.*" " - remove-highlighter ""window/%val{hook_param_capture_1}"" - " -} - -hook global WinSetOption filetype=(html|xml) %{ - hook window ModeChange insert:.* -group "%val{hook_param_capture_1}-trim-indent" html-trim-indent - hook window InsertChar '>' -group "%val{hook_param_capture_1}-indent" html-indent-on-greater-than - hook window InsertChar \n -group "%val{hook_param_capture_1}-indent" html-indent-on-new-line - - hook -once -always window WinSetOption "filetype=.*" " - remove-hooks window ""%val{hook_param_capture_1}-.+"" - " -} - ] diff --git a/rc/filetype/javascript.kak b/rc/filetype/javascript.kak index 7dc2034d..d45cf3b1 100644 --- a/rc/filetype/javascript.kak +++ b/rc/filetype/javascript.kak @@ -13,6 +13,34 @@ hook -once global BufSetOption filetype=(java|type)script %{ require-module javascript } +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=(javascript|typescript) %{ + require-module javascript + + hook window ModeChange insert:.* -group "%val{hook_param_capture_1}-trim-indent javascript-trim-indent" + hook window InsertChar .* -group "%val{hook_param_capture_1}-indent javascript-indent-on-char" + hook window InsertChar \n -group "%val{hook_param_capture_1}-indent javascript-indent-on-new-line" + + hook -once -always window WinSetOption filetype=.* " + remove-hooks window %val{hook_param_capture_1}-.+ + " +} + +hook -group javascript-highlight global WinSetOption filetype=javascript %{ + add-highlighter window/javascript ref javascript + + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/javascript } +} + +hook -group typescript-highlight global WinSetOption filetype=typescript %{ + add-highlighter window/typescript ref typescript + + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/typescript } +} + + provide-module javascript %🦀 # Commands @@ -93,23 +121,6 @@ define-command -hidden init-javascript-filetype -params 1 %~ # Keywords are collected at # https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords add-highlighter "shared/%arg{1}/code/" regex \b(async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|export|extends|finally|for|function|if|import|in|instanceof|let|new|of|return|static|super|switch|throw|try|typeof|var|void|while|with|yield)\b 0:keyword - - # Initialization - # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - - hook -group "%arg{1}-highlight" global WinSetOption "filetype=%arg{1}" " - add-highlighter window/%arg{1} ref %arg{1} - - hook -once -always window WinSetOption filetype=.* %%{ remove-highlighter window/%arg{1} } - " - - hook global WinSetOption "filetype=%arg{1}" " - hook window ModeChange insert:.* -group %arg{1}-trim-indent javascript-trim-indent - hook window InsertChar .* -group %arg{1}-indent javascript-indent-on-char - hook window InsertChar \n -group %arg{1}-indent javascript-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %%{ remove-hooks window %arg{1}-.+ } - " ~ init-javascript-filetype javascript diff --git a/rc/filetype/json.kak b/rc/filetype/json.kak index d863d596..9af3d6b9 100644 --- a/rc/filetype/json.kak +++ b/rc/filetype/json.kak @@ -9,9 +9,27 @@ hook global BufCreate .*[.](json) %{ } hook -once global BufSetOption filetype=json %{ - require-module json } +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=json %{ + require-module json + + hook window ModeChange insert:.* -group json-trim-indent json-trim-indent + hook window InsertChar .* -group json-indent json-indent-on-char + hook window InsertChar \n -group json-indent json-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window json-.+ } +} + +hook -group json-highlight global WinSetOption filetype=json %{ + add-highlighter window/json ref json + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/json } +} + + provide-module json %( # Highlighters @@ -49,20 +67,4 @@ define-command -hidden json-indent-on-new-line %< > > -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group json-highlight global WinSetOption filetype=json %{ - add-highlighter window/json ref json - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/json } -} - -hook global WinSetOption filetype=json %{ - hook window ModeChange insert:.* -group json-trim-indent json-trim-indent - hook window InsertChar .* -group json-indent json-indent-on-char - hook window InsertChar \n -group json-indent json-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window json-.+ } -} - ) diff --git a/rc/filetype/kakrc.kak b/rc/filetype/kakrc.kak index 1b270b80..fcfd6e82 100644 --- a/rc/filetype/kakrc.kak +++ b/rc/filetype/kakrc.kak @@ -8,8 +8,27 @@ hook global BufCreate (.*/)?(kakrc|.*.kak) %{ set-option buffer filetype kak } -hook -once global BufSetOption filetype=kak %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=kak %~ require-module kak + + set-option window static_words %opt{kak_static_words} + + hook window InsertChar \n -group kak-indent kak-indent-on-new-line + hook window InsertChar [>)}\]] -group kak-indent kak-indent-on-closing-matching + hook window InsertChar (?![[{(<>)}\]])[^\s\w] -group kak-indent kak-indent-on-closing-char + # cleanup trailing whitespaces on current line insert end + hook window ModeChange insert:.* -group kak-trim-indent %{ try %{ execute-keys -draft \; s ^\h+$ d } } + set-option buffer extra_word_chars '_' '-' + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kak-.+ } +~ + +hook -group kak-highlight global WinSetOption filetype=kak %{ + add-highlighter window/kakrc ref kakrc + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/kakrc } } provide-module kak %🦀 @@ -52,10 +71,7 @@ evaluate-commands %sh{ join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } # Add the language's grammar to the static completion list - printf '%s\n' "hook global WinSetOption filetype=kak %{ - set-option window static_words $(join "${keywords} ${attributes} ${types} ${values}" ' ')' - set-option -- window extra_word_chars '_' '-' - }" + printf %s\\n "declare-option str-list kak_static_words $(join "${keywords} ${attributes} ${types} ${values}" ' ')'" # Highlight keywords (which are always surrounded by whitespace) printf '%s\n' "add-highlighter shared/kakrc/code/keywords regex (?:\s|\A)\K($(join "${keywords}" '|'))(?:(?=\s)|\z) 0:keyword @@ -98,23 +114,4 @@ define-command -hidden kak-indent-on-closing-char %{ try %{ execute-keys -draft -itersel ^\h*\Q %val{hook_param} \E$gi %val{hook_param} %\w*\Q %val{hook_param} \E$ s \A|.\z gi 1 } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group kak-highlight global WinSetOption filetype=kak %{ - add-highlighter window/kakrc ref kakrc - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/kakrc } -} - -hook global WinSetOption filetype=kak %~ - hook window InsertChar \n -group kak-indent kak-indent-on-new-line - hook window InsertChar [>)}\]] -group kak-indent kak-indent-on-closing-matching - hook window InsertChar (?![[{(<>)}\]])[^\s\w] -group kak-indent kak-indent-on-closing-char - # cleanup trailing whitespaces on current line insert end - hook window ModeChange insert:.* -group kak-trim-indent %{ try %{ execute-keys -draft \; s ^\h+$ d } } - set-option buffer extra_word_chars '_' '-' - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kak-.+ } -~ - 🦀 diff --git a/rc/filetype/latex.kak b/rc/filetype/latex.kak index 3b8511d1..ebdeb97c 100644 --- a/rc/filetype/latex.kak +++ b/rc/filetype/latex.kak @@ -8,10 +8,18 @@ hook global BufCreate .*\.tex %{ set-option buffer filetype latex } -hook -once global BufSetOption filetype=latex %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=latex %{ require-module latex } +hook -group latex-highlight global WinSetOption filetype=latex %{ + add-highlighter window/latex ref latex + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/latex } +} + provide-module latex %( # Highlighters @@ -32,12 +40,4 @@ add-highlighter shared/latex/content/ regex '\\(emph|textit)\{([^}]+)\}' 2:defau # Bold text add-highlighter shared/latex/content/ regex '\\textbf\{([^}]+)\}' 1:default+b -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group latex-highlight global WinSetOption filetype=latex %{ - add-highlighter window/latex ref latex - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/latex } -} - ) diff --git a/rc/filetype/lisp.kak b/rc/filetype/lisp.kak index 39f946e7..1efed1eb 100644 --- a/rc/filetype/lisp.kak +++ b/rc/filetype/lisp.kak @@ -8,8 +8,21 @@ hook global BufCreate .*[.](lisp) %{ set-option buffer filetype lisp } -hook -once global BufSetOption filetype=lisp %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=lisp %{ require-module lisp + + hook window ModeChange insert:.* -group lisp-trim-indent lisp-trim-indent + hook window InsertChar \n -group lisp-indent lisp-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window lisp-.+ } +} + +hook -group lisp-highlight global WinSetOption filetype=lisp %{ + add-highlighter window/lisp ref lisp + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/lisp } } provide-module lisp %{ @@ -64,19 +77,4 @@ define-command -hidden lisp-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group lisp-highlight global WinSetOption filetype=lisp %{ - add-highlighter window/lisp ref lisp - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/lisp } -} - -hook global WinSetOption filetype=lisp %{ - hook window ModeChange insert:.* -group lisp-trim-indent lisp-trim-indent - hook window InsertChar \n -group lisp-indent lisp-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window lisp-.+ } -} - } diff --git a/rc/filetype/lua.kak b/rc/filetype/lua.kak index c3411c91..ed97cbb8 100644 --- a/rc/filetype/lua.kak +++ b/rc/filetype/lua.kak @@ -8,10 +8,30 @@ hook global BufCreate .*[.](lua) %{ set-option buffer filetype lua } -hook -once global BufSetOption filetype=lua %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=lua %{ require-module lua + + hook window InsertChar .* -group lua-indent lua-indent-on-char + hook window InsertChar \n -group lua-indent lua-indent-on-new-line + hook window InsertChar \n -group lua-insert lua-insert-on-new-line + + alias window alt lua-alternative-file + + hook -once -always window WinSetOption filetype=.* %{ + remove-hooks window lua-.+ + unalias window alt lua-alternative-file + } } +hook -group lua-highlight global WinSetOption filetype=lua %{ + add-highlighter window/lua ref lua + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/lua } +} + + provide-module lua %[ # Highlighters @@ -87,25 +107,4 @@ define-command -hidden lua-insert-on-new-line %[ ] ] -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group lua-highlight global WinSetOption filetype=lua %{ - add-highlighter window/lua ref lua - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/lua } -} - -hook global WinSetOption filetype=lua %{ - hook window InsertChar .* -group lua-indent lua-indent-on-char - hook window InsertChar \n -group lua-indent lua-indent-on-new-line - hook window InsertChar \n -group lua-insert lua-insert-on-new-line - - alias window alt lua-alternative-file - - hook -once -always window WinSetOption filetype=.* %{ - remove-hooks window lua-.+ - unalias window alt lua-alternative-file - } -} - ] diff --git a/rc/filetype/makefile.kak b/rc/filetype/makefile.kak index c6f13dfd..7f7ebbe5 100644 --- a/rc/filetype/makefile.kak +++ b/rc/filetype/makefile.kak @@ -5,8 +5,21 @@ hook global BufCreate .*(/?[mM]akefile|\.mk) %{ set-option buffer filetype makefile } -hook -once global BufSetOption filetype=makefile %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=makefile %{ require-module makefile + + set-option window static_words %opt{makefile_static_words} + + hook window InsertChar \n -group makefile-indent makefile-indent-on-new-line + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window makefile-.+ } +} + +hook -group makefile-highlight global WinSetOption filetype=makefile %{ + add-highlighter window/makefile ref makefile + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/makefile } } provide-module makefile %{ @@ -28,9 +41,7 @@ evaluate-commands %sh{ keywords="ifeq|ifneq|ifdef|ifndef|else|endif|define|endef" # Add the language's grammar to the static completion list - printf %s\\n "hook global WinSetOption filetype=makefile %{ - set-option window static_words ${keywords} - }" | tr '|' ' ' + printf %s\\n "declare-option str-list makefile_static_words ${keywords}" | tr '|' ' ' # Highlight keywords printf %s "add-highlighter shared/makefile/content/ regex \b(${keywords})\b 0:keyword" @@ -52,17 +63,4 @@ define-command -hidden makefile-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group makefile-highlight global WinSetOption filetype=makefile %{ - add-highlighter window/makefile ref makefile - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/makefile } -} - -hook global WinSetOption filetype=makefile %{ - hook window InsertChar \n -group makefile-indent makefile-indent-on-new-line - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window makefile-.+ } -} - } diff --git a/rc/filetype/nim.kak b/rc/filetype/nim.kak index 0bdd8ef6..1b9283cb 100644 --- a/rc/filetype/nim.kak +++ b/rc/filetype/nim.kak @@ -8,8 +8,24 @@ hook global BufCreate .*\.nim(s|ble)? %{ set-option buffer filetype nim } -hook -once global BufSetOption filetype=nim %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=nim %{ require-module nim + + set-option window static_words %opt{nim_static_words} + + hook window InsertChar \n -group nim-indent nim-indent-on-new-line + # cleanup trailing whitespaces on current line insert end + hook window ModeChange insert:.* -group nim-trim-indent %{ try %{ exec -draft \; s ^\h+$ d } } + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window nim-.+ } +} + +hook -group nim-highlight global WinSetOption filetype=nim %{ + add-highlighter window/nim ref nim + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/nim } } provide-module nim %{ @@ -57,9 +73,7 @@ evaluate-commands %sh{ static_words="$(join "${keywords} ${types} ${operator} ${values}" ' ')" # Add the language's grammar to the static completion list - printf %s "hook global WinSetOption filetype=nim %{ - set-option window static_words ${static_words} - }" + printf %s\\n "declare-option str-list nim_static_words ${static_words}" keywords="$(join "${keywords}" '|')" operators="$(join "${operators}" '|')" @@ -101,20 +115,4 @@ def -hidden nim-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group nim-highlight global WinSetOption filetype=nim %{ - add-highlighter window/nim ref nim - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/nim } -} - -hook global WinSetOption filetype=nim %{ - hook window InsertChar \n -group nim-indent nim-indent-on-new-line - # cleanup trailing whitespaces on current line insert end - hook window ModeChange insert:.* -group nim-trim-indent %{ try %{ exec -draft \; s ^\h+$ d } } - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window nim-.+ } -} - } diff --git a/rc/filetype/ocaml.kak b/rc/filetype/ocaml.kak index 8b8c771c..33a4dbd4 100644 --- a/rc/filetype/ocaml.kak +++ b/rc/filetype/ocaml.kak @@ -8,8 +8,17 @@ hook global BufCreate .*\.mli? %{ set-option buffer filetype ocaml } -hook -once global BufSetOption filetype=ocaml %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=ocaml %{ require-module ocaml + set-option window static_words %opt{ocaml_static_words} +} + +hook -group ocaml-highlight global WinSetOption filetype=ocaml %{ + add-highlighter window/ocaml ref ocaml + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ocaml } } provide-module ocaml %{ @@ -22,24 +31,19 @@ add-highlighter shared/ocaml/code default-region group add-highlighter shared/ocaml/string region '"' (?s^\h+$d } } + hook window InsertChar \n -group perl-indent perl-indent-on-new-line + hook window InsertChar \{ -group perl-indent perl-indent-on-opening-curly-brace + hook window InsertChar \} -group perl-indent perl-indent-on-closing-curly-brace + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window perl-.+ } +} + +hook -group perl-highlight global WinSetOption filetype=perl %{ + add-highlighter window/perl ref perl + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/perl } } provide-module perl %🦀 @@ -26,31 +44,31 @@ add-highlighter shared/perl/comment region (?^\h+\}$hms\A|.\z1 ] ] -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group perl-highlight global WinSetOption filetype=perl %{ - add-highlighter window/perl ref perl - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/perl } -} - -hook global WinSetOption filetype=perl %{ - # cleanup trailing whitespaces when exiting insert mode - hook window ModeChange insert:.* -group perl-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } - hook window InsertChar \n -group perl-indent perl-indent-on-new-line - hook window InsertChar \{ -group perl-indent perl-indent-on-opening-curly-brace - hook window InsertChar \} -group perl-indent perl-indent-on-closing-curly-brace - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window perl-.+ } -} - 🦀 diff --git a/rc/filetype/php.kak b/rc/filetype/php.kak index e2759129..8ee1d8ce 100644 --- a/rc/filetype/php.kak +++ b/rc/filetype/php.kak @@ -5,8 +5,22 @@ hook global BufCreate .*[.](php) %{ set-option buffer filetype php } -hook -once global BufSetOption filetype=php %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=php %{ require-module php + + hook window ModeChange insert:.* -group php-trim-indent php-trim-indent + hook window InsertChar .* -group php-indent php-indent-on-char + hook window InsertChar \n -group php-indent php-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window php-.+ } +} + +hook -group php-highlight global WinSetOption filetype=php %{ + add-highlighter window/php-file ref php-file + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/php-file } } provide-module php %( @@ -80,20 +94,4 @@ define-command -hidden php-indent-on-new-line %< > > -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group php-highlight global WinSetOption filetype=php %{ - add-highlighter window/php-file ref php-file - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/php-file } -} - -hook global WinSetOption filetype=php %{ - hook window ModeChange insert:.* -group php-trim-indent php-trim-indent - hook window InsertChar .* -group php-indent php-indent-on-char - hook window InsertChar \n -group php-indent php-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window php-.+ } -} - ) diff --git a/rc/filetype/pony.kak b/rc/filetype/pony.kak index 8aaa0233..762f7c1a 100644 --- a/rc/filetype/pony.kak +++ b/rc/filetype/pony.kak @@ -8,8 +8,24 @@ hook global BufCreate .*[.](pony) %{ set-option buffer filetype pony } -hook -once global BufSetOption filetype=pony %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=pony %{ require-module pony + + set-option window static_words %opt{pony_static_words} + + hook window InsertChar \n -group pony-indent pony-indent-on-new-line + # cleanup trailing whitespaces on current line insert end + hook window ModeChange insert:.* -group pony-trim-indent %{ try %{ execute-keys -draft \; s ^\h+$ d } } + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pony-.+ } +} + +hook -group pony-highlight global WinSetOption filetype=pony %{ + add-highlighter window/pony ref pony + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter pony } } provide-module pony %{ @@ -39,9 +55,7 @@ evaluate-commands %sh{ # Add the language's grammar to the static completion list static_words="${values} ${meta} ${keywords} ${types_decl} ${capabilities}" static_words="${static_words} ${struct}" - printf %s\\n "hook global WinSetOption filetype=pony %{ - set-option window static_words ${static_words} - }" | tr '|' ' ' + printf %s\\n "declare-option str-list pony_static_words ${static_words}" | tr '|' ' ' # Highlight keywords printf %s " @@ -81,20 +95,4 @@ define-command -hidden pony-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group pony-highlight global WinSetOption filetype=pony %{ - add-highlighter window/pony ref pony - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter pony } -} - -hook global WinSetOption filetype=pony %{ - hook window InsertChar \n -group pony-indent pony-indent-on-new-line - # cleanup trailing whitespaces on current line insert end - hook window ModeChange insert:.* -group pony-trim-indent %{ try %{ execute-keys -draft \; s ^\h+$ d } } - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pony-.+ } -} - } diff --git a/rc/filetype/protobuf.kak b/rc/filetype/protobuf.kak index 4924cb05..4e568704 100644 --- a/rc/filetype/protobuf.kak +++ b/rc/filetype/protobuf.kak @@ -7,8 +7,24 @@ hook global BufCreate .*\.proto$ %{ set-option buffer filetype protobuf } -hook -once global BufSetOption filetype=protobuf %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=protobuf %[ require-module protobuf + + set-option window static_words %opt{protobuf_static_words} + + hook -group protobuf-indent window InsertChar \n protobuf-indent-on-newline + hook -group protobuf-indent window InsertChar \{ protobuf-indent-on-opening-curly-brace + hook -group protobuf-indent window InsertChar \} protobuf-indent-on-closing-curly-brace + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window protobuf-.+ } +] + +hook -group protobuf-highlight global WinSetOption filetype=protobuf %{ + add-highlighter window/protobuf ref protobuf + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/protobuf } } provide-module protobuf %[ @@ -26,31 +42,30 @@ add-highlighter shared/protobuf/code/ regex %{(0x)?[0-9]+\b} 0:value evaluate-commands %sh{ # Grammer - keywords="default|deprecated|enum|extend|import|message|oneof|option" - keywords="${keywords}|package|service|syntax" - attributes="optional|repeated|required" - types="double|float|int32|int64|uint32|uint64|sint32|sint64|fixed32|fixed64" - types="${types}|sfixed32|sfixed64|bool|string|bytes|rpc" - values="false|true" + keywords='default deprecated enum extend import message oneof option + package service syntax' + attributes='optional repeated required' + types='double float int32 int64 uint32 uint64 sint32 sint64 fixed32 fixed64 + sfixed32 sfixed64 bool string bytes rpc' + values='false true' + + join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } # Add the language's grammer to the static completion list - printf '%s\n' "hook global WinSetOption filetype=protobuf %{ - set-option window static_words ${keywords} ${attributes} ${types} ${values} - }" | tr '|' ' ' + printf %s\\n "declare-option str-list protobuf_static_words $(join "${keywords} ${attributes} ${types} ${values}" ' ')" # Highlight keywords printf %s " - add-highlighter shared/protobuf/code/keywords regex \b(${keywords})\b 0:keyword - add-highlighter shared/protobuf/code/attributes regex \b(${attributes})\b 0:attribute - add-highlighter shared/protobuf/code/types regex \b(${types})\b 0:type - add-highlighter shared/protobuf/code/values regex \b(${values})\b 0:value + add-highlighter shared/protobuf/code/keywords regex \b($(join "${keywords}" '|'))\b 0:keyword + add-highlighter shared/protobuf/code/attributes regex \b($(join "${attributes}" '|'))\b 0:attribute + add-highlighter shared/protobuf/code/types regex \b($(join "${types}" '|'))\b 0:type + add-highlighter shared/protobuf/code/values regex \b($(join "${values}" '|'))\b 0:value " } # Commands # ‾‾‾‾‾‾‾‾ - define-command -hidden protobuf-indent-on-newline %~ evaluate-commands -draft -itersel %[ # preserve previous line indent @@ -74,20 +89,4 @@ define-command -hidden protobuf-indent-on-closing-curly-brace %[ try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group protobuf-highlight global WinSetOption filetype=protobuf %{ - add-highlighter window/protobuf ref protobuf - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/protobuf } -} - -hook global WinSetOption filetype=protobuf %[ - hook -group protobuf-indent window InsertChar \n protobuf-indent-on-newline - hook -group protobuf-indent window InsertChar \{ protobuf-indent-on-opening-curly-brace - hook -group protobuf-indent window InsertChar \} protobuf-indent-on-closing-curly-brace - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window protobuf-.+ } -] - ] diff --git a/rc/filetype/pug.kak b/rc/filetype/pug.kak index 121b0b37..c4a30511 100644 --- a/rc/filetype/pug.kak +++ b/rc/filetype/pug.kak @@ -12,10 +12,24 @@ hook global BufCreate .*[.](pug|jade) %{ set-option buffer filetype pug } -hook -once global BufSetOption filetype=pug %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=pug %{ require-module pug + + hook window ModeChange insert:.* -group pug-trim-indent pug-trim-indent + hook window InsertChar \n -group pug-indent pug-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pug-.+ } } +hook -group pug-highlight global WinSetOption filetype=pug %{ + add-highlighter window/pug ref pug + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/pug } +} + + provide-module pug %{ # Highlighters @@ -64,19 +78,4 @@ define-command -hidden pug-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group pug-highlight global WinSetOption filetype=pug %{ - add-highlighter window/pug ref pug - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/pug } -} - -hook global WinSetOption filetype=pug %{ - hook window ModeChange insert:.* -group pug-trim-indent pug-trim-indent - hook window InsertChar \n -group pug-indent pug-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pug-.+ } -} - } diff --git a/rc/filetype/python.kak b/rc/filetype/python.kak index 82fe9971..7c4472a3 100644 --- a/rc/filetype/python.kak +++ b/rc/filetype/python.kak @@ -8,8 +8,23 @@ hook global BufCreate .*[.](py) %{ set-option buffer filetype python } -hook -once global BufSetOption filetype=python %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=python %{ require-module python + + set-option window static_words %opt{python_static_words} + + hook window InsertChar \n -group python-indent python-indent-on-new-line + # cleanup trailing whitespaces on current line insert end + hook window ModeChange insert:.* -group python-trim-indent %{ try %{ execute-keys -draft \; s ^\h+$ d } } + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window python-.+ } +} + +hook -group python-highlight global WinSetOption filetype=python %{ + add-highlighter window/python ref python + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/python } } provide-module python %{ @@ -42,79 +57,79 @@ add-highlighter shared/python/docstring/ region '\.\.\. \K' '\z' ref python evaluate-commands %sh{ # Grammar - values="True|False|None|self|inf" - meta="import|from" + values="True False None self inf" + meta="import from" # attributes and methods list based on https://docs.python.org/3/reference/datamodel.html - attributes="__annotations__|__closure__|__code__|__defaults__|__dict__|__doc__" - attributes="${attributes}|__globals__|__kwdefaults__|__module__|__name__|__qualname__" - methods="__abs__|__add__|__aenter__|__aexit__|__aiter__|__and__|__anext__" - methods="${methods}|__await__|__bool__|__bytes__|__call__|__complex__|__contains__" - methods="${methods}|__del__|__delattr__|__delete__|__delitem__|__dir__|__divmod__" - methods="${methods}|__enter__|__eq__|__exit__|__float__|__floordiv__|__format__" - methods="${methods}|__ge__|__get__|__getattr__|__getattribute__|__getitem__" - methods="${methods}|__gt__|__hash__|__iadd__|__iand__|__ifloordiv__|__ilshift__" - methods="${methods}|__imatmul__|__imod__|__imul__|__index__|__init__" - methods="${methods}|__init_subclass__|__int__|__invert__|__ior__|__ipow__" - methods="${methods}|__irshift__|__isub__|__iter__|__itruediv__|__ixor__|__le__" - methods="${methods}|__len__|__length_hint__|__lshift__|__lt__|__matmul__" - methods="${methods}|__missing__|__mod__|__mul__|__ne__|__neg__|__new__|__or__" - methods="${methods}|__pos__|__pow__|__radd__|__rand__|__rdivmod__|__repr__" - methods="${methods}|__reversed__|__rfloordiv__|__rlshift__|__rmatmul__|__rmod__" - methods="${methods}|__rmul__|__ror__|__round__|__rpow__|__rrshift__|__rshift__" - methods="${methods}|__rsub__|__rtruediv__|__rxor__|__set__|__setattr__" - methods="${methods}|__setitem__|__set_name__|__slots__|__str__|__sub__" - methods="${methods}|__truediv__|__xor__" + attributes="__annotations__ __closure__ __code__ __defaults__ __dict__ __doc__ + __globals__ __kwdefaults__ __module__ __name__ __qualname__" + methods="__abs__ __add__ __aenter__ __aexit__ __aiter__ __and__ __anext__ + __await__ __bool__ __bytes__ __call__ __complex__ __contains__ + __del__ __delattr__ __delete__ __delitem__ __dir__ __divmod__ + __enter__ __eq__ __exit__ __float__ __floordiv__ __format__ + __ge__ __get__ __getattr__ __getattribute__ __getitem__ + __gt__ __hash__ __iadd__ __iand__ __ifloordiv__ __ilshift__ + __imatmul__ __imod__ __imul__ __index__ __init__ + __init_subclass__ __int__ __invert__ __ior__ __ipow__ + __irshift__ __isub__ __iter__ __itruediv__ __ixor__ __le__ + __len__ __length_hint__ __lshift__ __lt__ __matmul__ + __missing__ __mod__ __mul__ __ne__ __neg__ __new__ __or__ + __pos__ __pow__ __radd__ __rand__ __rdivmod__ __repr__ + __reversed__ __rfloordiv__ __rlshift__ __rmatmul__ __rmod__ + __rmul__ __ror__ __round__ __rpow__ __rrshift__ __rshift__ + __rsub__ __rtruediv__ __rxor__ __set__ __setattr__ + __setitem__ __set_name__ __slots__ __str__ __sub__ + __truediv__ __xor__" # built-in exceptions https://docs.python.org/3/library/exceptions.html - exceptions="ArithmeticError|AssertionError|AttributeError|BaseException|BlockingIOError" - exceptions="${exceptions}|BrokenPipeError|BufferError|BytesWarning|ChildProcessError" - exceptions="${exceptions}|ConnectionAbortedError|ConnectionError|ConnectionRefusedError" - exceptions="${exceptions}|ConnectionResetError|DeprecationWarning|EOFError|Exception" - exceptions="${exceptions}|FileExistsError|FileNotFoundError|FloatingPointError|FutureWarning" - exceptions="${exceptions}|GeneratorExit|ImportError|ImportWarning|IndentationError" - exceptions="${exceptions}|IndexError|InterruptedError|IsADirectoryError|KeyboardInterrupt" - exceptions="${exceptions}|KeyError|LookupError|MemoryError|ModuleNotFoundError|NameError" - exceptions="${exceptions}|NotADirectoryError|NotImplementedError|OSError|OverflowError" - exceptions="${exceptions}|PendingDeprecationWarning|PermissionError|ProcessLookupError" - exceptions="${exceptions}|RecursionError|ReferenceError|ResourceWarning|RuntimeError" - exceptions="${exceptions}|RuntimeWarning|StopAsyncIteration|StopIteration|SyntaxError" - exceptions="${exceptions}|SyntaxWarning|SystemError|SystemExit|TabError|TimeoutError|TypeError" - exceptions="${exceptions}|UnboundLocalError|UnicodeDecodeError|UnicodeEncodeError|UnicodeError" - exceptions="${exceptions}|UnicodeTranslateError|UnicodeWarning|UserWarning|ValueError|Warning" - exceptions="${exceptions}|ZeroDivisionError" + exceptions="ArithmeticError AssertionError AttributeError BaseException BlockingIOError + BrokenPipeError BufferError BytesWarning ChildProcessError + ConnectionAbortedError ConnectionError ConnectionRefusedError + ConnectionResetError DeprecationWarning EOFError Exception + FileExistsError FileNotFoundError FloatingPointError FutureWarning + GeneratorExit ImportError ImportWarning IndentationError + IndexError InterruptedError IsADirectoryError KeyboardInterrupt + KeyError LookupError MemoryError ModuleNotFoundError NameError + NotADirectoryError NotImplementedError OSError OverflowError + PendingDeprecationWarning PermissionError ProcessLookupError + RecursionError ReferenceError ResourceWarning RuntimeError + RuntimeWarning StopAsyncIteration StopIteration SyntaxError + SyntaxWarning SystemError SystemExit TabError TimeoutError TypeError + UnboundLocalError UnicodeDecodeError UnicodeEncodeError UnicodeError + UnicodeTranslateError UnicodeWarning UserWarning ValueError Warning + ZeroDivisionError" # Keyword list is collected using `keyword.kwlist` from `keyword` - keywords="and|as|assert|async|await|break|class|continue|def|del|elif|else|except|exec" - keywords="${keywords}|finally|for|global|if|in|is|lambda|nonlocal|not|or|pass|print" - keywords="${keywords}|raise|return|try|while|with|yield" + keywords="and as assert async await break class continue def del elif else except exec + finally for global if in is lambda nonlocal not or pass print + raise return try while with yield" - types="bool|buffer|bytearray|bytes|complex|dict|file|float|frozenset|int" - types="${types}|list|long|memoryview|object|set|str|tuple|unicode|xrange" + types="bool buffer bytearray bytes complex dict file float frozenset int + list long memoryview object set str tuple unicode xrange" - functions="abs|all|any|ascii|bin|breakpoint|callable|chr|classmethod|compile|complex" - functions="${functions}|delattr|dict|dir|divmod|enumerate|eval|exec|filter" - functions="${functions}|format|frozenset|getattr|globals|hasattr|hash|help" - functions="${functions}|hex|id|__import__|input|isinstance|issubclass|iter" - functions="${functions}|len|locals|map|max|memoryview|min|next|oct|open|ord" - functions="${functions}|pow|print|property|range|repr|reversed|round" - functions="${functions}|setattr|slice|sorted|staticmethod|sum|super|type|vars|zip" + functions="abs all any ascii bin breakpoint callable chr classmethod compile complex + delattr dict dir divmod enumerate eval exec filter + format frozenset getattr globals hasattr hash help + hex id __import__ input isinstance issubclass iter + len locals map max memoryview min next oct open ord + pow print property range repr reversed round + setattr slice sorted staticmethod sum super type vars zip" + + join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } # Add the language's grammar to the static completion list - printf %s\\n "hook global WinSetOption filetype=python %{ - set-option window static_words ${values} ${meta} ${attributes} ${methods} ${exceptions} ${keywords} ${types} ${functions} - }" | tr '|' ' ' + printf %s\\n "declare-option str-list python_static_words $(join "${values} ${meta} ${attributes} ${methods} ${exceptions} ${keywords} ${types} ${functions}" ' ')" # Highlight keywords printf %s " - add-highlighter shared/python/code/ regex '\b(${values})\b' 0:value - add-highlighter shared/python/code/ regex '\b(${meta})\b' 0:meta - add-highlighter shared/python/code/ regex '\b(${attribute})\b' 0:attribute - add-highlighter shared/python/code/ regex '\bdef\s+(${methods})\b' 1:function - add-highlighter shared/python/code/ regex '\b(${exceptions})\b' 0:function - add-highlighter shared/python/code/ regex '\b(${keywords})\b' 0:keyword - add-highlighter shared/python/code/ regex '\b(${functions})\b\(' 1:builtin - add-highlighter shared/python/code/ regex '\b(${types})\b' 0:type + add-highlighter shared/python/code/ regex '\b($(join "${values}" '|'))\b' 0:value + add-highlighter shared/python/code/ regex '\b($(join "${meta}" '|'))\b' 0:meta + add-highlighter shared/python/code/ regex '\b($(join "${attribute}" '|'))\b' 0:attribute + add-highlighter shared/python/code/ regex '\bdef\s+($(join "${methods}" '|'))\b' 1:function + add-highlighter shared/python/code/ regex '\b($(join "${exceptions}" '|'))\b' 0:function + add-highlighter shared/python/code/ regex '\b($(join "${keywords}" '|'))\b' 0:keyword + add-highlighter shared/python/code/ regex '\b($(join "${functions}" '|'))\b\(' 1:builtin + add-highlighter shared/python/code/ regex '\b($(join "${types}" '|'))\b' 0:type add-highlighter shared/python/code/ regex '@[\w_]+\b' 0:attribute " } @@ -138,19 +153,4 @@ define-command -hidden python-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group python-highlight global WinSetOption filetype=python %{ - add-highlighter window/python ref python - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/python } -} - -hook global WinSetOption filetype=python %{ - hook window InsertChar \n -group python-indent python-indent-on-new-line - # cleanup trailing whitespaces on current line insert end - hook window ModeChange insert:.* -group python-trim-indent %{ try %{ execute-keys -draft \; s ^\h+$ d } } - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window python-.+ } -} - } diff --git a/rc/filetype/ragel.kak b/rc/filetype/ragel.kak index 0aa6ad03..696bc85d 100644 --- a/rc/filetype/ragel.kak +++ b/rc/filetype/ragel.kak @@ -10,8 +10,22 @@ hook global BufCreate .*[.](ragel|rl) %{ set-option buffer filetype ragel } -hook -once global BufSetOption filetype=ragel %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=ragel %{ require-module ragel + + hook window ModeChange insert:.* -group ragel-trim-indent ragel-trim-indent + hook window InsertChar .* -group ragel-indent ragel-indent-on-char + hook window InsertChar \n -group ragel-indent ragel-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window ragel-.+ } +} + +hook -group ragel-highlight global WinSetOption filetype=ragel %{ + add-highlighter window/ragel ref ragel + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ragel } } provide-module ragel %🦀 @@ -59,20 +73,4 @@ define-command -hidden ragel-indent-on-new-line %< > > -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group ragel-highlight global WinSetOption filetype=ragel %{ - add-highlighter window/ragel ref ragel - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ragel } -} - -hook global WinSetOption filetype=ragel %{ - hook window ModeChange insert:.* -group ragel-trim-indent ragel-trim-indent - hook window InsertChar .* -group ragel-indent ragel-indent-on-char - hook window InsertChar \n -group ragel-indent ragel-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window ragel-.+ } -} - 🦀 diff --git a/rc/filetype/ruby.kak b/rc/filetype/ruby.kak index d9bdcfe6..7996b089 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -8,8 +8,29 @@ hook global BufCreate .*(([.](rb))|(irbrc)|(pryrc)|(Brewfile)|(Capfile|[.]cap)|( set-option buffer filetype ruby } -hook -once global BufSetOption filetype=ruby %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=ruby %{ require-module ruby + + set-option window static_words %opt{ruby_static_words} + + hook window InsertChar .* -group ruby-indent ruby-indent-on-char + hook window InsertChar \n -group ruby-insert ruby-insert-on-new-line + hook window InsertChar \n -group ruby-indent ruby-indent-on-new-line + + alias window alt ruby-alternative-file + + hook -once -always window WinSetOption filetype=.* %{ + remove-hooks window ruby-.+ + unalias window alt ruby-alternative-file + } +} + +hook -group ruby-highlight global WinSetOption filetype=ruby %{ + add-highlighter window/ruby ref ruby + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ruby } } provide-module ruby %[ @@ -61,9 +82,7 @@ evaluate-commands %sh{ meta="require|include|extend" # Add the language's grammar to the static completion list - printf %s\\n "hook global WinSetOption filetype=ruby %{ - set-option window static_words ${keywords} ${attributes} ${values} ${meta} - }" | tr '|' ' ' + printf %s\\n "declare-option str-list ruby_static_words ${keywords} ${attributes} ${values} ${meta}" | tr '|' ' ' # Highlight keywords printf %s " @@ -152,25 +171,4 @@ define-command -hidden ruby-insert-on-new-line %[ ] ] -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group ruby-highlight global WinSetOption filetype=ruby %{ - add-highlighter window/ruby ref ruby - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ruby } -} - -hook global WinSetOption filetype=ruby %{ - hook window InsertChar .* -group ruby-indent ruby-indent-on-char - hook window InsertChar \n -group ruby-insert ruby-insert-on-new-line - hook window InsertChar \n -group ruby-indent ruby-indent-on-new-line - - alias window alt ruby-alternative-file - - hook -once -always window WinSetOption filetype=.* %{ - remove-hooks window ruby-.+ - unalias window alt ruby-alternative-file - } -} - ] diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index 7018ff31..0a3a6dbd 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -8,10 +8,32 @@ hook global BufCreate .*[.](rust|rs) %{ set-option buffer filetype rust } -hook -once global BufSetOption filetype=rust %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=rust %[ require-module rust + + hook window ModeChange insert:.* -group rust-trim-indent rust-trim-indent + hook window InsertChar \n -group rust-indent rust-indent-on-new-line + hook window InsertChar \{ -group rust-indent rust-indent-on-opening-curly-brace + hook window InsertChar [)}] -group rust-indent rust-indent-on-closing + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window rust-.+ } +] + +hook -group rust-highlight global WinSetOption filetype=rust %{ + add-highlighter window/rust ref rust + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/rust } } +# Configuration +# ‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=rust %[ + set window formatcmd 'rustfmt' +] + + provide-module rust %🦀 # Highlighters @@ -77,27 +99,4 @@ define-command -hidden rust-indent-on-closing %[ _ ] -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group rust-highlight global WinSetOption filetype=rust %{ - add-highlighter window/rust ref rust - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/rust } -} - -hook global WinSetOption filetype=rust %[ - hook window ModeChange insert:.* -group rust-trim-indent rust-trim-indent - hook window InsertChar \n -group rust-indent rust-indent-on-new-line - hook window InsertChar \{ -group rust-indent rust-indent-on-opening-curly-brace - hook window InsertChar [)}] -group rust-indent rust-indent-on-closing - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window rust-.+ } -] - -# Configuration -# ‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook global WinSetOption filetype=rust %[ - set window formatcmd 'rustfmt' -] - 🦀 diff --git a/rc/filetype/scheme.kak b/rc/filetype/scheme.kak index 20d2f35f..b130127b 100644 --- a/rc/filetype/scheme.kak +++ b/rc/filetype/scheme.kak @@ -8,8 +8,24 @@ hook global BufCreate (.*/)?(.*\.(scm|ss|sld)) %{ set-option buffer filetype scheme } -hook -once global BufSetOption filetype=scheme %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=scheme %{ require-module scheme + + set-option window static_words %opt{scheme_static_words} + + set-option buffer extra_word_chars '_' '-' '!' '%' '?' '<' '>' '=' + hook window InsertEnd .* -group scheme-trim-indent lisp-trim-indent + hook window InsertChar \n -group scheme-indent lisp-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scheme-.+ } +} + +hook -group scheme-highlight global WinSetOption filetype=scheme %{ + add-highlighter window/scheme ref scheme + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scheme } } provide-module scheme %{ @@ -105,9 +121,9 @@ evaluate-commands %sh{ exec awk -f - <<'EOF' } BEGIN { - printf("hook global WinSetOption filetype=scheme %%{ set-option window static_words "); + printf("declare-option str-list scheme_static_words "); print_words(keywords); print_words(meta); print_words(operators); print_words(builtins); - printf(" }\n") + printf("\n"); add_word_highlighter(keywords, "keyword"); add_word_highlighter(meta, "meta"); @@ -121,21 +137,4 @@ evaluate-commands %sh{ exec awk -f - <<'EOF' EOF } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group scheme-highlight global WinSetOption filetype=scheme %{ - add-highlighter window/scheme ref scheme - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scheme } -} - - -hook global WinSetOption filetype=scheme %{ - set-option buffer extra_word_chars '_' '-' '!' '%' '?' '<' '>' '=' - hook window InsertEnd .* -group scheme-trim-indent lisp-trim-indent - hook window InsertChar \n -group scheme-indent lisp-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scheme-.+ } -} - } diff --git a/rc/filetype/scss.kak b/rc/filetype/scss.kak index de5e4acc..7cb15e52 100644 --- a/rc/filetype/scss.kak +++ b/rc/filetype/scss.kak @@ -8,10 +8,26 @@ hook global BufCreate .*[.](scss) %{ set-option buffer filetype scss } -hook -once global BufSetOption filetype=scss %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=scss %[ require-module scss + + hook window ModeChange insert:.* -group scss-trim-indent scss-trim-indent + hook window InsertChar \n -group scss-indent scss-indent-on-new-line + hook window InsertChar \} -group scss-indent scss-indent-on-closing-curly-brace + set-option buffer extra_word_chars '_' '-' + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scss-.+ } +] + +hook -group scss-highlight global WinSetOption filetype=scss %{ + add-highlighter window/scss ref scss + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scss } } + provide-module scss %[ require-module css @@ -33,21 +49,4 @@ define-command -hidden scss-trim-indent css-trim-indent define-command -hidden scss-indent-on-new-line css-indent-on-new-line define-command -hidden scss-indent-on-closing-curly-brace css-indent-on-closing-curly-brace -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group scss-highlight global WinSetOption filetype=scss %{ - add-highlighter window/scss ref scss - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scss } -} - -hook global WinSetOption filetype=scss %[ - hook window ModeChange insert:.* -group scss-trim-indent scss-trim-indent - hook window InsertChar \n -group scss-indent scss-indent-on-new-line - hook window InsertChar \} -group scss-indent scss-indent-on-closing-curly-brace - set-option buffer extra_word_chars '_' '-' - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scss-.+ } -] - ] diff --git a/rc/filetype/sh.kak b/rc/filetype/sh.kak index b7468520..ae09183f 100644 --- a/rc/filetype/sh.kak +++ b/rc/filetype/sh.kak @@ -2,8 +2,14 @@ hook global BufCreate .*\.(z|ba|c|k|mk)?sh(rc|_profile)? %{ set-option buffer filetype sh } -hook -once global BufSetOption filetype=sh %{ +hook global WinSetOption filetype=sh %{ require-module sh + set-option window static_words %opt{sh_static_words} +} + +hook -group sh-highlight global WinSetOption filetype=sh %{ + add-highlighter window/sh ref sh + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/sh } } provide-module sh %[ @@ -29,9 +35,7 @@ evaluate-commands %sh{ join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } # Add the language's grammar to the static completion list - printf %s\\n "hook global WinSetOption filetype=sh %{ - set-option window static_words $(join "${keywords}" ' ') - }" + printf %s\\n "declare-option str-list sh_static_words $(join "${keywords}" ' ')" # Highlight keywords printf %s "add-highlighter shared/sh/code/ regex \b($(join "${keywords}" '|'))\b 0:keyword" @@ -44,9 +48,4 @@ add-highlighter shared/sh/code/function regex ^\h*(\w+)\h*\(\) 1:function add-highlighter shared/sh/code/unscoped_expansion regex \$(\w+|#|@|\?|\$|!|-|\*) 0:value add-highlighter shared/sh/double_string/expansion regex \$(\w+|\{.+?\}) 0:value -hook -group sh-highlight global WinSetOption filetype=sh %{ - add-highlighter window/sh ref sh - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/sh } -} - ] diff --git a/rc/filetype/sql.kak b/rc/filetype/sql.kak index 44ea7729..9ce82e67 100644 --- a/rc/filetype/sql.kak +++ b/rc/filetype/sql.kak @@ -8,10 +8,20 @@ hook global BufCreate .*/?(?i)sql %{ set-option buffer filetype sql } -hook -once global BufSetOption filetype=sql %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=sql %{ require-module sql + set-option window static_words %opt{sql_static_words} } +hook -group sql-highlight global WinSetOption filetype=sql %{ + add-highlighter window/sql ref sql + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/sql } +} + + provide-module sql %{ # Highlighters @@ -86,9 +96,7 @@ evaluate-commands %sh{ data_types="${data_types}|Time|Ole Object|Hyperlink|Lookup Wizard" # Add the language's grammar to the static completion list - printf %s\\n "hook global WinSetOption filetype=sql %{ - set-option window static_words ${keywords} ${operators} ${functions} ${data_types} ${data_types_fn} NULL - }" | tr '|' ' ' + printf %s\\n "declare-option str-list sql_static_words ${keywords} ${operators} ${functions} ${data_types} ${data_types_fn} NULL" | tr '|' ' ' # Highlight keywords printf %s " @@ -104,12 +112,4 @@ add-highlighter shared/sql/code/ regex '\+|-|\*|/|%|&|\||^|=|>|<|>=|<=|<>|\+=|-= add-highlighter shared/sql/code/ regex \bNULL\b 0:value add-highlighter shared/sql/code/ regex \b\d+(?:\.\d+)?\b 0:value -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group sql-highlight global WinSetOption filetype=sql %{ - add-highlighter window/sql ref sql - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/sql } -} - } diff --git a/rc/filetype/swift.kak b/rc/filetype/swift.kak index 4cf71613..e1f6d9af 100644 --- a/rc/filetype/swift.kak +++ b/rc/filetype/swift.kak @@ -2,10 +2,16 @@ hook global BufCreate .*\.(swift) %{ set-option buffer filetype swift } -hook -once global BufSetOption filetype=swift %{ +hook global WinSetOption filetype=swift %{ require-module swift } +hook -group swift-highlight global WinSetOption filetype=swift %{ + add-highlighter window/swift ref swift + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/swift } +} + + provide-module swift %{ add-highlighter shared/swift regions @@ -28,9 +34,4 @@ add-highlighter shared/swift/code/ regex "\b(Bool|String|UInt|UInt16|UInt32|UInt add-highlighter shared/swift/code/ regex "\b(IBAction|IBOutlet)\b" 0:attribute add-highlighter shared/swift/code/ regex "@\w+\b" 0:attribute -hook -group swift-highlight global WinSetOption filetype=swift %{ - add-highlighter window/swift ref swift - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/swift } -} - } diff --git a/rc/filetype/troff.kak b/rc/filetype/troff.kak index 73170675..44645010 100644 --- a/rc/filetype/troff.kak +++ b/rc/filetype/troff.kak @@ -5,10 +5,18 @@ hook global BufCreate .*\.\d+ %{ set-option buffer filetype troff } -hook -once global BufSetOption filetype=troff %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=troff %{ require-module troff } +hook -group troff-highlight global WinSetOption filetype=troff %{ + add-highlighter window/troff ref troff + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/troff } +} + provide-module troff %{ # Highlighters @@ -27,12 +35,4 @@ add-highlighter shared/troff/ regex '^\.BR\s+(\S+)' 1:+b add-highlighter shared/troff/ regex '^\.I\s+([^\n]+)' 1:+i add-highlighter shared/troff/ regex '^\.B\s+([^\n]+)' 1:+b -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group troff-highlight global WinSetOption filetype=troff %{ - add-highlighter window/troff ref troff - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/troff } -} - } diff --git a/rc/filetype/tupfile.kak b/rc/filetype/tupfile.kak index a21b6408..33e570d6 100644 --- a/rc/filetype/tupfile.kak +++ b/rc/filetype/tupfile.kak @@ -8,10 +8,17 @@ hook global BufCreate .*/?Tup(file|rules)(\.\w+)?$ %{ set-option buffer filetype tupfile } -hook -once global BufSetOption filetype=tupfile %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook -group tupfile-highlight global WinSetOption filetype=tupfile %{ require-module tupfile + + add-highlighter window/tupfile ref tupfile + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/tupfile } } + provide-module tupfile %{ # Highlighters @@ -30,12 +37,4 @@ add-highlighter shared/tupfile/code/ regex '^\h*\b(ifn?eq|ifn?def|else|endif|err add-highlighter shared/tupfile/code/ regex '^\h*\b(&?[\w_]+)\s*[:+]?=' 1:keyword add-highlighter shared/tupfile/code/ regex '`[^`\n]+`' 0:meta -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group tupfile-highlight global WinSetOption filetype=tupfile %{ - add-highlighter window/tupfile ref tupfile - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/tupfile } -} - } From e959b99050492e820e2cf39154b87e5f4696defa Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Wed, 10 Apr 2019 16:48:46 -0700 Subject: [PATCH 14/18] Fixed several more support files. --- rc/filetype/etc.kak | 83 ++++++++++++++++---------------------- rc/filetype/fish.kak | 31 +++++++------- rc/filetype/git.kak | 56 ++++++++++++------------- rc/filetype/javascript.kak | 4 -- rc/filetype/json.kak | 3 -- rc/filetype/mail.kak | 13 +++--- rc/filetype/sass.kak | 33 ++++++++------- rc/filetype/scala.kak | 35 ++++++++-------- 8 files changed, 117 insertions(+), 141 deletions(-) diff --git a/rc/filetype/etc.kak b/rc/filetype/etc.kak index 29c6296d..b04b7b47 100644 --- a/rc/filetype/etc.kak +++ b/rc/filetype/etc.kak @@ -12,27 +12,40 @@ hook global BufCreate .*/etc/profile(\.(csh|env))? %{ set-option buffer fil hook global BufCreate .*/etc/profile\.d/.* %{ set-option buffer filetype sh } -hook -once global BufSetOption filetype=etc-hosts %{ - require-module etc-hosts +hook global WinSetOption filetype=etc-(hosts|resolv-conf|shadow|passwd|gshadow|group|fstab) %{ + require-module "etc-%val{hook_param_capture_1}" } -hook -once global BufSetOption filetype=etc-resolv-conf %{ - require-module etc-resolv-conf + + +hook -group etc-resolv-conf-highlight global WinSetOption filetype=etc-resolv-conf %{ + add-highlighter window/etc-resolv-conf ref etc-resolv-conf + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-resolv-conf } } -hook -once global BufSetOption filetype=etc-shadow %{ - require-module etc-shadow +hook -group etc-hosts-highlight global WinSetOption filetype=etc-hosts %{ + add-highlighter window/etc-hosts ref etc-hosts + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-hosts } } -hook -once global BufSetOption filetype=etc-passwd %{ - require-module etc-passwd +hook -group etc-fstab-highlight global WinSetOption filetype=etc-fstab %{ + add-highlighter window/etc-fstab ref etc-fstab + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-fstab } } -hook -once global BufSetOption filetype=etc-gshadow %{ - require-module etc-gshadow +hook -group etc-group-highlight global WinSetOption filetype=etc-group %{ + add-highlighter window/etc-group ref etc-group + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-group } } -hook -once global BufSetOption filetype=etc-group %{ - require-module etc-group +hook -group etc-gshadow-highlight global WinSetOption filetype=etc-gshadow %{ + add-highlighter window/etc-gshadow ref etc-gshadow + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-gshadow } } -hook -once global BufSetOption filetype=etc-fstab %{ - require-module etc-fstab +hook -group etc-shadow-highlight global WinSetOption filetype=etc-shadow %{ + add-highlighter window/etc-shadow ref etc-shadow + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-shadow } } +hook -group etc-passwd-highlight global WinSetOption filetype=etc-passwd %{ + add-highlighter window/etc-passwd ref etc-passwd + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-passwd } +} + # Highlighters @@ -41,70 +54,42 @@ provide-module etc-resolv-conf %{ add-highlighter shared/etc-resolv-conf group add-highlighter shared/etc-resolv-conf/ regex ^#.*?$ 0:comment add-highlighter shared/etc-resolv-conf/ regex ^(nameserver|server|domain|sortlist|options)[\s\t]+(.*?)$ 1:type 2:attribute - -hook -group etc-resolv-conf-highlight global WinSetOption filetype=etc-resolv-conf %{ - add-highlighter window/etc-resolv-conf ref etc-resolv-conf - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-resolv-conf } -}} +} provide-module etc-hosts %{ ## /etc/hosts add-highlighter shared/etc-hosts group add-highlighter shared/etc-hosts/ regex ^(.+?)[\s\t]+?(.*?)$ 1:type 2:attribute add-highlighter shared/etc-hosts/ regex '#.*?$' 0:comment - -hook -group etc-hosts-highlight global WinSetOption filetype=etc-hosts %{ - add-highlighter window/etc-hosts ref etc-hosts - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-hosts } -}} +} provide-module etc-fstab %{ ## /etc/fstab add-highlighter shared/etc-fstab group add-highlighter shared/etc-fstab/ regex ^(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})(?:\s+)?$ 1:keyword 2:value 3:type 4:string 5:attribute 6:attribute add-highlighter shared/etc-fstab/ regex '#.*?$' 0:comment - -hook -group etc-fstab-highlight global WinSetOption filetype=etc-fstab %{ - add-highlighter window/etc-fstab ref etc-fstab - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-fstab } -}} +} provide-module etc-group %{ ## /etc/group add-highlighter shared/etc-group group add-highlighter shared/etc-group/ regex ^(\S+?):(\S+?)?:(\S+?)?:(\S+?)?$ 1:keyword 2:type 3:value 4:string - -hook -group etc-group-highlight global WinSetOption filetype=etc-group %{ - add-highlighter window/etc-group ref etc-group - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-group } -}} +} provide-module etc-gshadow %{ ## /etc/gshadow add-highlighter shared/etc-gshadow group add-highlighter shared/etc-gshadow/ regex ^(\S+?):(\S+?)?:(\S+?)?:(\S+?)?$ 1:keyword 2:type 3:value 4:string - -hook -group etc-gshadow-highlight global WinSetOption filetype=etc-gshadow %{ - add-highlighter window/etc-gshadow ref etc-gshadow - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-gshadow } -}} +} provide-module etc-shadow %{ ## /etc/shadow add-highlighter shared/etc-shadow group add-highlighter shared/etc-shadow/ regex ^(\S+?):(\S+?):([0-9]+?):([0-9]+?)?:([0-9]+?)?:([0-9]+?)?:([0-9]+?)?:([0-9]+?)?:(.*?)?$ 1:keyword 2:type 3:value 4:value 5:value 6:value 7:value 8:value - -hook -group etc-shadow-highlight global WinSetOption filetype=etc-shadow %{ - add-highlighter window/etc-shadow ref etc-shadow - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-shadow } -}} +} provide-module etc-passwd %{ ## /etc/passwd add-highlighter shared/etc-passwd group add-highlighter shared/etc-passwd/ regex ^(\S+?):(\S+?):([0-9]+?):([0-9]+?):(.*?)?:(.+?):(.+?)$ 1:keyword 2:type 3:value 4:value 5:string 6:attribute 7:attribute - -hook -group etc-passwd-highlight global WinSetOption filetype=etc-passwd %{ - add-highlighter window/etc-passwd ref etc-passwd - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-passwd } -}} +} diff --git a/rc/filetype/fish.kak b/rc/filetype/fish.kak index db62a354..49d0c9f8 100644 --- a/rc/filetype/fish.kak +++ b/rc/filetype/fish.kak @@ -8,10 +8,24 @@ hook global BufCreate .*[.](fish) %{ set-option buffer filetype fish } -hook -once global BufSetOption filetype=fish %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=fish %{ require-module fish + + hook window InsertChar .* -group fish-indent fish-indent-on-char + hook window InsertChar \n -group fish-indent fish-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window fish-.+ } } +hook -group fish-highlight global WinSetOption filetype=fish %{ + add-highlighter window/fish ref fish + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/fish } +} + + provide-module fish %{ # Highlighters @@ -63,19 +77,4 @@ define-command -hidden fish-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group fish-highlight global WinSetOption filetype=fish %{ - add-highlighter window/fish ref fish - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/fish } -} - -hook global WinSetOption filetype=fish %{ - hook window InsertChar .* -group fish-indent fish-indent-on-char - hook window InsertChar \n -group fish-indent fish-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window fish-.+ } -} - } diff --git a/rc/filetype/git.kak b/rc/filetype/git.kak index 155d666c..3a39ab37 100644 --- a/rc/filetype/git.kak +++ b/rc/filetype/git.kak @@ -14,40 +14,40 @@ hook global BufCreate .*git-rebase-todo %{ set-option buffer filetype git-rebase } -hook -once global BufSetOption filetype=git-commit %{ - require-module git-commit +hook global WinSetOption filetype=git-(commit|notes|rebase) %{ + require-module "git-%val{hook_param_capture_1}" } -hook -once global BufSetOption filetype=git-notes %{ - require-module git-notes + +hook -group git-commit-highlight global WinSetOption filetype=git-commit %{ + add-highlighter window/git-commit ref git-commit + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-commit } } -hook -once global BufSetOption filetype=git-rebase %{ - require-module git-rebase + +hook -group git-notes-highlight global WinSetOption filetype=git-notes %{ + add-highlighter window/git-notes ref git-notes + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-notes } } +hook -group git-rebase-highlight global WinSetOption filetype=git-rebase %{ + add-highlighter window/git-rebase ref git-rebase + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-rebase } +} + + provide-module git-commit %{ -hook -group git-commit-highlight global WinSetOption filetype=git-commit %{ - add-highlighter window/git-commit-highlight regions - add-highlighter window/git-commit-highlight/diff region '^diff --git' '^(?=diff --git)' ref diff # highlight potential diffs from the -v option - add-highlighter window/git-commit-highlight/comments region '^\h*#' '$' group - add-highlighter window/git-commit-highlight/comments/ fill comment - add-highlighter window/git-commit-highlight/comments/ regex "\b(?:(modified)|(deleted)|(new file)|(renamed|copied)):([^\n]*)$" 1:yellow 2:red 3:green 4:blue 5:magenta - - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-commit-highlight } -}} +add-highlighter shared/git-commit regions +add-highlighter shared/git-commit/diff region '^diff --git' '^(?=diff --git)' ref diff # highlight potential diffs from the -v option +add-highlighter shared/git-commit/comments region '^\h*#' '$' group +add-highlighter shared/git-commit/comments/ fill comment +add-highlighter shared/git-commit/comments/ regex "\b(?:(modified)|(deleted)|(new file)|(renamed|copied)):([^\n]*)$" 1:yellow 2:red 3:green 4:blue 5:magenta +} provide-module git-notes %{ -hook -group git-commit-highlight global WinSetOption filetype=git-notes %{ - add-highlighter window/git-notes-highlight regex '^\h*#[^\n]*$' 0:comment - - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-notes-highlight } -}} - +add-highlighter shared/git-notes regex '^\h*#[^\n]*$' 0:comment +} provide-module git-rebase %{ -hook -group git-rebase-highlight global WinSetOption filetype=git-rebase %{ - add-highlighter window/git-rebase-highlight group - add-highlighter window/git-rebase-highlight/ regex "#[^\n]*\n" 0:comment - add-highlighter window/git-rebase-highlight/ regex "^(pick|edit|reword|squash|fixup|exec|break|drop|label|reset|merge|[persfxbdltm]) (\w+)" 1:keyword 2:meta - - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-rebase-highlight } -}} +add-highlighter shared/git-rebase group +add-highlighter shared/git-rebase/ regex "#[^\n]*\n" 0:comment +add-highlighter shared/git-rebase/ regex "^(pick|edit|reword|squash|fixup|exec|break|drop|label|reset|merge|[persfxbdltm]) (\w+)" 1:keyword 2:meta +} diff --git a/rc/filetype/javascript.kak b/rc/filetype/javascript.kak index d45cf3b1..3f794506 100644 --- a/rc/filetype/javascript.kak +++ b/rc/filetype/javascript.kak @@ -9,10 +9,6 @@ hook global BufCreate .*[.](ts)x? %{ set-option buffer filetype typescript } -hook -once global BufSetOption filetype=(java|type)script %{ - require-module javascript -} - # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ diff --git a/rc/filetype/json.kak b/rc/filetype/json.kak index 9af3d6b9..094c3652 100644 --- a/rc/filetype/json.kak +++ b/rc/filetype/json.kak @@ -8,9 +8,6 @@ hook global BufCreate .*[.](json) %{ set-option buffer filetype json } -hook -once global BufSetOption filetype=json %{ -} - # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ diff --git a/rc/filetype/mail.kak b/rc/filetype/mail.kak index 73998d90..95b7d88a 100644 --- a/rc/filetype/mail.kak +++ b/rc/filetype/mail.kak @@ -2,10 +2,16 @@ hook global BufCreate .+\.eml %{ set-option buffer filetype mail } -hook -once global BufSetOption filetype=mail %{ +hook global WinSetOption filetype=mail %{ require-module mail } +hook -group mail-highlight global WinSetOption filetype=mail %{ + add-highlighter window/mail ref mail + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/mail } +} + + provide-module mail %{ add-highlighter shared/mail group @@ -13,9 +19,4 @@ add-highlighter shared/mail/ regex ^(From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To add-highlighter shared/mail/ regex <[^@>]+@.*?> 0:string add-highlighter shared/mail/ regex ^>.*?$ 0:comment -hook -group mail-highlight global WinSetOption filetype=mail %{ - add-highlighter window/mail ref mail - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/mail } -} - } diff --git a/rc/filetype/sass.kak b/rc/filetype/sass.kak index 46145f7c..c5872253 100644 --- a/rc/filetype/sass.kak +++ b/rc/filetype/sass.kak @@ -8,10 +8,25 @@ hook global BufCreate .*[.](sass) %{ set-option buffer filetype sass } -hook -once global BufSetOption filetype=sass %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=sass %{ require-module sass + + hook window ModeChange insert:.* -group sass-trim-indent sass-trim-indent + hook window InsertChar \n -group sass-indent sass-indent-on-new-line + set-option buffer extra_word_chars '_' '-' + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window sass-.+ } } +hook -group sass-highlight global WinSetOption filetype=sass %{ + add-highlighter window/sass ref sass + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/sass } +} + + provide-module sass %{ # Highlighters @@ -51,20 +66,4 @@ define-command -hidden sass-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group sass-highlight global WinSetOption filetype=sass %{ - add-highlighter window/sass ref sass - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/sass } -} - -hook global WinSetOption filetype=sass %{ - hook window ModeChange insert:.* -group sass-trim-indent sass-trim-indent - hook window InsertChar \n -group sass-indent sass-indent-on-new-line - set-option buffer extra_word_chars '_' '-' - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window sass-.+ } -} - } diff --git a/rc/filetype/scala.kak b/rc/filetype/scala.kak index ce890058..73f086b5 100644 --- a/rc/filetype/scala.kak +++ b/rc/filetype/scala.kak @@ -8,11 +8,26 @@ hook global BufCreate .*[.](scala) %{ set-option buffer filetype scala } -hook -once global BufSetOption filetype=scala %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=scala %[ require-module scala + + hook window ModeChange insert:.* -group scala-trim-indent scala-trim-indent + hook window InsertChar \n -group scala-indent scala-indent-on-new-line + hook window InsertChar \} -group scala-indent scala-indent-on-closing-curly-brace + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scala-.+ } +] + +hook -group scala-highlight global WinSetOption filetype=scala %{ + add-highlighter window/scala ref scala + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scala } } -provide-module scala %{ + +provide-module scala %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -64,20 +79,4 @@ define-command -hidden scala-indent-on-closing-curly-brace %[ ] ] -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group scala-highlight global WinSetOption filetype=scala %{ - add-highlighter window/scala ref scala - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scala } -} - -hook global WinSetOption filetype=scala %[ - hook window ModeChange insert:.* -group scala-trim-indent scala-trim-indent - hook window InsertChar \n -group scala-indent scala-indent-on-new-line - hook window InsertChar \} -group scala-indent scala-indent-on-closing-curly-brace - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scala-.+ } ] - -} From c2b32ebaa77aed64a0b27d199e4f3dd5907014c6 Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Wed, 10 Apr 2019 17:08:05 -0700 Subject: [PATCH 15/18] Clean up javascript file a bit --- rc/filetype/javascript.kak | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/rc/filetype/javascript.kak b/rc/filetype/javascript.kak index 3f794506..67ef45b7 100644 --- a/rc/filetype/javascript.kak +++ b/rc/filetype/javascript.kak @@ -15,9 +15,9 @@ hook global BufCreate .*[.](ts)x? %{ hook global WinSetOption filetype=(javascript|typescript) %{ require-module javascript - hook window ModeChange insert:.* -group "%val{hook_param_capture_1}-trim-indent javascript-trim-indent" - hook window InsertChar .* -group "%val{hook_param_capture_1}-indent javascript-indent-on-char" - hook window InsertChar \n -group "%val{hook_param_capture_1}-indent javascript-indent-on-new-line" + hook window ModeChange insert:.* -group "%val{hook_param_capture_1}-trim-indent" javascript-trim-indent + hook window InsertChar .* -group "%val{hook_param_capture_1}-indent" javascript-indent-on-char + hook window InsertChar \n -group "%val{hook_param_capture_1}-indent" javascript-indent-on-new-line hook -once -always window WinSetOption filetype=.* " remove-hooks window %val{hook_param_capture_1}-.+ @@ -26,13 +26,11 @@ hook global WinSetOption filetype=(javascript|typescript) %{ hook -group javascript-highlight global WinSetOption filetype=javascript %{ add-highlighter window/javascript ref javascript - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/javascript } } hook -group typescript-highlight global WinSetOption filetype=typescript %{ add-highlighter window/typescript ref typescript - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/typescript } } From 6512eafa6006976bd65336ab94d6f1ebd54022e4 Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Thu, 11 Apr 2019 15:54:58 -0700 Subject: [PATCH 16/18] Update remaining files to new provide/require format --- rc/filetype/cabal.kak | 36 +++++++------ rc/filetype/cmake.kak | 12 ++--- rc/filetype/coffee.kak | 31 ++++++------ rc/filetype/cucumber.kak | 31 ++++++------ rc/filetype/elm.kak | 30 +++++------ rc/filetype/exherbo.kak | 87 ++++++++++++++++---------------- rc/filetype/gas.kak | 21 ++++---- rc/filetype/haml.kak | 31 ++++++------ rc/filetype/hbs.kak | 33 ++++++------ rc/filetype/i3.kak | 37 +++++++------- rc/filetype/ini.kak | 13 ++--- rc/filetype/java.kak | 37 +++++++------- rc/filetype/julia.kak | 19 +++---- rc/filetype/just.kak | 21 ++++---- rc/filetype/kickstart.kak | 14 ++--- rc/filetype/markdown.kak | 27 +++++----- rc/filetype/mercurial.kak | 14 ++--- rc/filetype/moon.kak | 43 ++++++++-------- rc/filetype/restructuredtext.kak | 18 +++---- rc/filetype/taskpaper.kak | 27 +++++----- rc/filetype/toml.kak | 31 ++++++------ rc/filetype/yaml.kak | 29 +++++------ 22 files changed, 314 insertions(+), 328 deletions(-) diff --git a/rc/filetype/cabal.kak b/rc/filetype/cabal.kak index daff0bff..a376a2f7 100644 --- a/rc/filetype/cabal.kak +++ b/rc/filetype/cabal.kak @@ -8,10 +8,26 @@ hook global BufCreate .*[.](cabal) %{ set-option buffer filetype cabal } -hook -once global BufSetOption filetype=cabal %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=cabal %[ require-module cabal + + hook window ModeChange insert:.* -group cabal-trim-indent cabal-trim-indent + hook window InsertChar \n -group cabal-indent cabal-indent-on-new-line + hook window InsertChar \{ -group cabal-indent cabal-indent-on-opening-curly-brace + hook window InsertChar \} -group cabal-indent cabal-indent-on-closing-curly-brace + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window cabal-.+ } +] + +hook -group cabal-highlight global WinSetOption filetype=cabal %{ + add-highlighter window/cabal ref cabal + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cabal } } + provide-module cabal %[ # Highlighters @@ -61,22 +77,4 @@ define-command -hidden cabal-indent-on-closing-curly-brace %[ ] ] -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group cabal-highlight global WinSetOption filetype=cabal %{ - add-highlighter window/cabal ref cabal - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cabal } - -} - -hook global WinSetOption filetype=cabal %[ - hook window ModeChange insert:.* -group cabal-trim-indent cabal-trim-indent - hook window InsertChar \n -group cabal-indent cabal-indent-on-new-line - hook window InsertChar \{ -group cabal-indent cabal-indent-on-opening-curly-brace - hook window InsertChar \} -group cabal-indent cabal-indent-on-closing-curly-brace - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window cabal-.+ } -] - ] diff --git a/rc/filetype/cmake.kak b/rc/filetype/cmake.kak index c0c3bb2c..cb5c65db 100644 --- a/rc/filetype/cmake.kak +++ b/rc/filetype/cmake.kak @@ -6,10 +6,15 @@ hook global BufCreate .*/CMakeCache.txt %{ set-option buffer filetype ini } -hook -once global BufSetOption filetype=cmake %{ +hook global WinSetOption filetype=cmake %{ require-module cmake } +hook -group cmake-highlight global WinSetOption filetype=cmake %{ + add-highlighter window/cmake ref cmake + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cmake } +} + provide-module cmake %{ add-highlighter shared/cmake regions @@ -27,9 +32,4 @@ add-highlighter shared/cmake/argument/quoted/ fill string add-highlighter shared/cmake/argument/quoted/ regex '\$\{\w+\}' 0:variable add-highlighter shared/cmake/argument/quoted/ regex '\w+\h*(?=\()' 0:function -hook -group cmake-highlight global WinSetOption filetype=cmake %{ - add-highlighter window/cmake ref cmake - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cmake } -} - } diff --git a/rc/filetype/coffee.kak b/rc/filetype/coffee.kak index f0b5ac58..a4b2fab6 100644 --- a/rc/filetype/coffee.kak +++ b/rc/filetype/coffee.kak @@ -8,10 +8,24 @@ hook global BufCreate .*[.](coffee) %{ set-option buffer filetype coffee } -hook -once global BufSetOption filetype=coffee %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=coffee %{ require-module coffee + + hook window ModeChange insert:.* -group coffee-trim-indent coffee-trim-indent + hook window InsertChar \n -group coffee-indent coffee-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window coffee-.+ } } +hook -group coffee-highlight global WinSetOption filetype=coffee %{ + add-highlighter window/coffee ref coffee + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/coffee } +} + + provide-module coffee %[ # Highlighters @@ -69,19 +83,4 @@ define-command -hidden coffee-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group coffee-highlight global WinSetOption filetype=coffee %{ - add-highlighter window/coffee ref coffee - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/coffee } -} - -hook global WinSetOption filetype=coffee %{ - hook window ModeChange insert:.* -group coffee-trim-indent coffee-trim-indent - hook window InsertChar \n -group coffee-indent coffee-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window coffee-.+ } -} - ] diff --git a/rc/filetype/cucumber.kak b/rc/filetype/cucumber.kak index 55fe892a..aa24423c 100644 --- a/rc/filetype/cucumber.kak +++ b/rc/filetype/cucumber.kak @@ -8,10 +8,24 @@ hook global BufCreate .*[.](feature|story) %{ set-option buffer filetype cucumber } -hook -once global BufSetOption filetype=cucumber %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=cucumber %{ require-module cucumber + + hook window ModeChange insert:.* -group cucumber-trim-indent cucumber-trim-indent + hook window InsertChar \n -group cucumber-indent cucumber-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window cucumber-.+ } } +hook -group cucumber-highlight global WinSetOption filetype=cucumber %{ + add-highlighter window/cucumber ref cucumber + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cucumber } +} + + provide-module cucumber %{ # Highlighters @@ -79,19 +93,4 @@ define-command -hidden cucumber-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group cucumber-highlight global WinSetOption filetype=cucumber %{ - add-highlighter window/cucumber ref cucumber - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cucumber } -} - -hook global WinSetOption filetype=cucumber %{ - hook window ModeChange insert:.* -group cucumber-trim-indent cucumber-trim-indent - hook window InsertChar \n -group cucumber-indent cucumber-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window cucumber-.+ } -} - } diff --git a/rc/filetype/elm.kak b/rc/filetype/elm.kak index 8b97ff22..88057428 100644 --- a/rc/filetype/elm.kak +++ b/rc/filetype/elm.kak @@ -8,8 +8,21 @@ hook global BufCreate .*[.](elm) %{ set-option buffer filetype elm } -hook -once global BufSetOption filetype=elm %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=elm %{ require-module elm + + hook window ModeChange insert:.* -group elm-trim-indent elm-trim-indent + hook window InsertChar \n -group elm-indent elm-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elm-.+ } +} + +hook -group elm-highlight global WinSetOption filetype=elm %{ + add-highlighter window/elm ref elm + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/elm } } provide-module elm %[ @@ -57,19 +70,4 @@ define-command -hidden elm-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group elm-highlight global WinSetOption filetype=elm %{ - add-highlighter window/elm ref elm - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/elm } -} - -hook global WinSetOption filetype=elm %{ - hook window ModeChange insert:.* -group elm-trim-indent elm-trim-indent - hook window InsertChar \n -group elm-indent elm-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elm-.+ } -} - ] diff --git a/rc/filetype/exherbo.kak b/rc/filetype/exherbo.kak index b0f73929..72714255 100644 --- a/rc/filetype/exherbo.kak +++ b/rc/filetype/exherbo.kak @@ -25,16 +25,23 @@ hook global BufCreate .*/etc/paludis(-.*)?/repository_defaults\.conf hook global BufCreate .*/etc/paludis(-.*)?/specpath\.conf %{ set-option buffer filetype paludis-key-value-conf } hook global BufCreate .*/etc/paludis(-.*)?/suggestions(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-specs-conf } -hook -once global BufSetOption filetype=exheres-0-(licence-groups|metadata) %{ +hook global WinSetOption filetype=exheres-0-(metadata|options-descriptions|licence-groups) %{ require-module exheres } -hook -once global BufSetOption filetype=paludis-(key-value|options|mirrors|specs)-conf %{ - require-module paludis +hook -group exheres-0-metadata-highlight global WinSetOption filetype=exheres-0-metadata %{ + add-highlighter window/exheres-0-metadata ref exheres-0-metadata + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/exheres-0-metadata } } -hook -once global BufSetOption filetype=glep42 %{ - require-module glep42 +hook -group exheres-0-options-descriptions-highlight global WinSetOption filetype=exheres-0-options-descriptions %{ + add-highlighter window/exheres-0-options-descriptions ref exheres-0-options-descriptions + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/exheres-0-options-descriptions } +} + +hook -group exheres-0-licence-groups-highlight global WinSetOption filetype=exheres-0-licence-groups %{ + add-highlighter window/exheres-0-licence-groups ref exheres-0-licence-groups + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/exheres-0-licence-groups } } provide-module exheres %{ @@ -47,11 +54,6 @@ add-highlighter shared/exheres-0-metadata/ regex ^(?:[\s\t]+)?[\S]+[\s\t]+=[\s\t add-highlighter shared/exheres-0-metadata/ regex ^(?:[\s\t]+)?(\S+)\s\[\[$ 0:type add-highlighter shared/exheres-0-metadata/ regex ^(?:[\s\t]+)?\]\]$ 0:type -hook -group exheres-0-metadata-highlight global WinSetOption filetype=exheres-0-metadata %{ - add-highlighter window/exheres-0-metadata ref exheres-0-metadata - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/exheres-0-metadata } -} - ## exheres-0 options descriptions add-highlighter shared/exheres-0-options-descriptions group add-highlighter shared/exheres-0-options-descriptions/ regex ^#.*?$ 0:comment @@ -59,23 +61,36 @@ add-highlighter shared/exheres-0-options-descriptions/ regex ^(?:[\s\t]+)?[\S]+[ add-highlighter shared/exheres-0-options-descriptions/ regex ^(?:[\s\t]+)?(\S+)\s\[\[$ 0:type add-highlighter shared/exheres-0-options-descriptions/ regex ^(?:[\s\t]+)?\]\]$ 0:type -hook -group exheres-0-options-descriptions-highlight global WinSetOption filetype=exheres-0-options-descriptions %{ - add-highlighter window/exheres-0-options-descriptions ref exheres-0-options-descriptions - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/exheres-0-options-descriptions } -} - ## metadata/licence_groups.conf add-highlighter shared/exheres-0-licence-groups group add-highlighter shared/exheres-0-licence-groups/ regex [\s\t]+(\S+(?:[\s\t]+))*$ 0:attribute add-highlighter shared/exheres-0-licence-groups/ regex ^(\S+) 0:type add-highlighter shared/exheres-0-licence-groups/ regex ^#.*?$ 0:comment - -hook -group exheres-0-licence-groups-highlight global WinSetOption filetype=exheres-0-licence-groups %{ - add-highlighter window/exheres-0-licence-groups ref exheres-0-licence-groups - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/exheres-0-licence-groups } -} } +hook global WinSetOption filetype=paludis-(key-value|options|mirrors|specs)-conf %{ + require-module paludis +} + +hook -group paludis-options-conf-highlight global WinSetOption filetype=paludis-options-conf %{ + add-highlighter window/paludis-options-conf ref paludis-options-conf + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-options-conf } +} + +hook -group paludis-key-value-conf-highlight global WinSetOption filetype=paludis-key-value-conf %{ + add-highlighter window/paludis-key-value-conf ref paludis-key-value-conf + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-key-value-conf } +} + +hook -group paludis-mirrors-conf-highlight global WinSetOption filetype=paludis-mirrors-conf %{ + add-highlighter window/paludis-mirrors-conf ref paludis-mirrors-conf + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-mirrors-conf } +} + +hook -group paludis-specs-conf-highlight global WinSetOption filetype=paludis-specs-conf %{ + add-highlighter window/paludis-specs-conf ref paludis-specs-conf + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-specs-conf } +} provide-module paludis %{ ## Paludis configurations ### options.conf @@ -88,41 +103,30 @@ add-highlighter shared/paludis-options-conf/ regex [\s\t](-\S+)(.*?) 1:red add-highlighter shared/paludis-options-conf/ regex ^(\S+/\S+) 0:type add-highlighter shared/paludis-options-conf/ regex ^#.*?$ 0:comment -hook -group paludis-options-conf-highlight global WinSetOption filetype=paludis-options-conf %{ - add-highlighter window/paludis-options-conf ref paludis-options-conf - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-options-conf } -} - ## general.conf, repository.template add-highlighter shared/paludis-key-value-conf group add-highlighter shared/paludis-key-value-conf/ regex ^[\s\t]?(\S+)[\s\t+]=[\s\t+](.*?)$ 1:attribute 2:value add-highlighter shared/paludis-key-value-conf/ regex ^#.*?$ 0:comment -hook -group paludis-key-value-conf-highlight global WinSetOption filetype=paludis-key-value-conf %{ - add-highlighter window/paludis-key-value-conf ref paludis-key-value-conf - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-key-value-conf } -} - ## mirrors.conf add-highlighter shared/paludis-mirrors-conf group add-highlighter shared/paludis-mirrors-conf/ regex ^[\s\t+]?(\S+)[\s\t+](.*?)$ 1:type 2:value add-highlighter shared/paludis-mirrors-conf/ regex ^#.*?$ 0:comment -hook -group paludis-mirrors-conf-highlight global WinSetOption filetype=paludis-mirrors-conf %{ - add-highlighter window/paludis-mirrors-conf ref paludis-mirrors-conf - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-mirrors-conf } -} - ## package_(unmask|mask).conf, platforms.conf add-highlighter shared/paludis-specs-conf group add-highlighter shared/paludis-specs-conf/ regex [\s\t]+(\S+(?:[\s\t]+))*$ 0:attribute add-highlighter shared/paludis-specs-conf/ regex ^(\S+/\S+) 0:type add-highlighter shared/paludis-specs-conf/ regex ^#.*?$ 0:comment - -hook -group paludis-specs-conf-highlight global WinSetOption filetype=paludis-specs-conf %{ - add-highlighter window/paludis-specs-conf ref paludis-specs-conf - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-specs-conf } } + +hook global WinSetOption filetype=glep42 %{ + require-module glep42 +} + +hook -group glep42-highlight global WinSetOption filetype=glep42 %{ + add-highlighter window/glep42 ref glep42 + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/glep42 } } provide-module glep42 %{ @@ -131,9 +135,4 @@ add-highlighter shared/glep42 group add-highlighter shared/glep42/ regex ^(Title|Author|Translator|Content-Type|Posted|Revision|News-Item-Format|Display-If-Installed|Display-If-Keyword|Display-If-Profile):([^\n]*(?:\n\h+[^\n]+)*)$ 1:keyword 2:attribute add-highlighter shared/glep42/ regex <[^@>]+@.*?> 0:string add-highlighter shared/glep42/ regex ^>.*?$ 0:comment - -hook -group glep42-highlight global WinSetOption filetype=glep42 %{ - add-highlighter window/glep42 ref glep42 - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/glep42 } -} } diff --git a/rc/filetype/gas.kak b/rc/filetype/gas.kak index ba32472a..67c25a85 100644 --- a/rc/filetype/gas.kak +++ b/rc/filetype/gas.kak @@ -4,10 +4,19 @@ hook global BufCreate .*\.(s|S|asm)$ %{ set-option buffer filetype gas } -hook -once global BufSetOption filetype=gas %{ +hook global WinSetOption filetype=gas %{ require-module gas + + hook window InsertChar \n -group gas-indent gas-indent-on-new-line + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window gas-.+ } } +hook -group gas-highlight global WinSetOption filetype=gas %{ + add-highlighter window/gas ref gas + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/gas } +} + + provide-module gas %{ add-highlighter shared/gas regions @@ -86,14 +95,4 @@ define-command -hidden gas-indent-on-new-line %~ > ~ -hook -group gas-highlight global WinSetOption filetype=gas %{ - add-highlighter window/gas ref gas - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/gas } -} - -hook global WinSetOption filetype=gas %{ - hook window InsertChar \n -group gas-indent gas-indent-on-new-line - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window gas-.+ } -} - } diff --git a/rc/filetype/haml.kak b/rc/filetype/haml.kak index c802e1ff..f13c8764 100644 --- a/rc/filetype/haml.kak +++ b/rc/filetype/haml.kak @@ -8,10 +8,24 @@ hook global BufCreate .*[.](haml) %{ set-option buffer filetype haml } -hook -once global BufSetOption filetype=haml %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=haml %{ require-module haml + + hook window ModeChange insert:.* -group haml-trim-indent haml-trim-indent + hook window InsertChar \n -group haml-indent haml-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window haml-.+ } } +hook -group haml-highlight global WinSetOption filetype=haml %{ + add-highlighter window/haml ref haml + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/haml } +} + + provide-module haml %[ require-module ruby require-module coffee @@ -55,19 +69,4 @@ define-command -hidden haml-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group haml-highlight global WinSetOption filetype=haml %{ - add-highlighter window/haml ref haml - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/haml } -} - -hook global WinSetOption filetype=haml %{ - hook window ModeChange insert:.* -group haml-trim-indent haml-trim-indent - hook window InsertChar \n -group haml-indent haml-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window haml-.+ } -} - ] diff --git a/rc/filetype/hbs.kak b/rc/filetype/hbs.kak index d21f8d52..2474baf3 100644 --- a/rc/filetype/hbs.kak +++ b/rc/filetype/hbs.kak @@ -8,10 +8,25 @@ hook global BufCreate .*[.](hbs) %{ set-option buffer filetype hbs } -hook -once global BufSetOption filetype=hbs %{ +hook global WinSetOption filetype=hbs %{ require-module hbs + + hook window ModeChange insert:.* -group hbs-trim-indent hbs-trim-indent + hook window InsertChar \n -group hbs-indent hbs-indent-on-new-line + hook window InsertChar .* -group hbs-indent hbs-indent-on-char + hook window InsertChar '>' -group hbs-indent html-indent-on-greater-than + hook window InsertChar \n -group hbs-indent html-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window hbs-.+ } } +hook -group hbs-highlight global WinSetOption filetype=hbs %{ + maybe-add-hbs-to-html + add-highlighter window/hbs-file ref hbs-file + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/hbs-file } +} + + provide-module hbs %[ # Highlighters @@ -86,20 +101,4 @@ define-command -hidden maybe-add-hbs-to-html %{ evaluate-commands %sh{ fi } } -hook -group hbs-highlight global WinSetOption filetype=hbs %{ - maybe-add-hbs-to-html - add-highlighter window/hbs-file ref hbs-file - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/hbs-file } -} - -hook global WinSetOption filetype=hbs %{ - hook window ModeChange insert:.* -group hbs-trim-indent hbs-trim-indent - hook window InsertChar \n -group hbs-indent hbs-indent-on-new-line - hook window InsertChar .* -group hbs-indent hbs-indent-on-char - hook window InsertChar '>' -group hbs-indent html-indent-on-greater-than - hook window InsertChar \n -group hbs-indent html-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window hbs-.+ } -} - ] diff --git a/rc/filetype/i3.kak b/rc/filetype/i3.kak index 16819cf7..b46a2388 100644 --- a/rc/filetype/i3.kak +++ b/rc/filetype/i3.kak @@ -2,11 +2,27 @@ hook global BufCreate .*(sway|i3)/config %{ set buffer filetype i3 } -hook -once global BufSetOption filetype=i3 %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=i3 %[ require-module i3 + + # cleanup trailing whitespaces when exiting insert mode + hook window ModeChange insert:.* -group i3-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } + hook window InsertChar \n -group i3-indent i3-indent-on-new-line + hook window InsertChar \} -group i3-indent i3-indent-on-closing-curly-brace + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window i3-.+ } +] + +hook -group i3-highlight global WinSetOption filetype=i3 %{ + add-highlighter window/i3 ref i3 + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/i3 } } -provide-module i3 %{ + +provide-module i3 %[ add-highlighter shared/i3 regions add-highlighter shared/i3/code default-region group @@ -69,21 +85,4 @@ define-command -hidden i3-indent-on-closing-curly-brace %[ try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group i3-highlight global WinSetOption filetype=i3 %{ - add-highlighter window/i3 ref i3 - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/i3 } -} - -hook global WinSetOption filetype=i3 %[ - # cleanup trailing whitespaces when exiting insert mode - hook window ModeChange insert:.* -group i3-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } - hook window InsertChar \n -group i3-indent i3-indent-on-new-line - hook window InsertChar \} -group i3-indent i3-indent-on-closing-curly-brace - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window i3-.+ } ] - -} diff --git a/rc/filetype/ini.kak b/rc/filetype/ini.kak index 24bae58d..7e070176 100644 --- a/rc/filetype/ini.kak +++ b/rc/filetype/ini.kak @@ -2,10 +2,16 @@ hook global BufCreate .+\.(repo|ini|cfg|properties) %{ set-option buffer filetype ini } -hook -once global BufSetOption filetype=ini %{ +hook global WinSetOption filetype=ini %{ require-module ini } +hook -group ini-highlight global WinSetOption filetype=ini %{ + add-highlighter window/ini ref ini + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ini } +} + + provide-module ini %{ add-highlighter shared/ini regions @@ -15,9 +21,4 @@ add-highlighter shared/ini/comment region '(^|\h)\K[#;]' $ fill comment add-highlighter shared/ini/code/ regex "^\h*\[[^\]]*\]" 0:title add-highlighter shared/ini/code/ regex "^\h*([^\[][^=\n]*)=([^\n]*)" 1:variable 2:value -hook -group ini-highlight global WinSetOption filetype=ini %{ - add-highlighter window/ini ref ini - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ini } -} - } diff --git a/rc/filetype/java.kak b/rc/filetype/java.kak index 21c28858..36d4e3ba 100644 --- a/rc/filetype/java.kak +++ b/rc/filetype/java.kak @@ -2,10 +2,27 @@ hook global BufCreate .*\.java %{ set-option buffer filetype java } -hook -once global BufSetOption filetype=java %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=java %{ require-module java + + # cleanup trailing whitespaces when exiting insert mode + hook window ModeChange insert:.* -group java-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } + hook window InsertChar \n -group java-indent java-indent-on-new-line + hook window InsertChar \{ -group java-indent java-indent-on-opening-curly-brace + hook window InsertChar \} -group java-indent java-indent-on-closing-curly-brace + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window java-.+ } } +hook -group java-highlight global WinSetOption filetype=java %{ + add-highlighter window/java ref java + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/java } +} + + provide-module java %🦀 add-highlighter shared/java regions @@ -52,22 +69,4 @@ define-command -hidden java-indent-on-closing-curly-brace %[ try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group java-highlight global WinSetOption filetype=java %{ - add-highlighter window/java ref java - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/java } -} - -hook global WinSetOption filetype=java %{ - # cleanup trailing whitespaces when exiting insert mode - hook window ModeChange insert:.* -group java-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } - hook window InsertChar \n -group java-indent java-indent-on-new-line - hook window InsertChar \{ -group java-indent java-indent-on-opening-curly-brace - hook window InsertChar \} -group java-indent java-indent-on-closing-curly-brace - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window java-.+ } -} - 🦀 diff --git a/rc/filetype/julia.kak b/rc/filetype/julia.kak index ade63480..10edb743 100644 --- a/rc/filetype/julia.kak +++ b/rc/filetype/julia.kak @@ -8,10 +8,19 @@ hook global BufCreate .*\.(jl) %{ set-option buffer filetype julia } -hook -once global BufSetOption filetype=julia %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=julia %{ require-module julia } +hook -group julia-highlight global WinSetOption filetype=julia %{ + add-highlighter window/julia ref julia + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/julia } +} + + provide-module julia %{ # Highlighters @@ -27,12 +36,4 @@ add-highlighter shared/julia/code/ regex %{\b(true|false|C_NULL|Inf|NaN|Inf32|Na add-highlighter shared/julia/code/ regex \b(if|else|elseif|while|for|begin|end|quote|try|catch|return|local|abstract|function|macro|ccall|finally|typealias|break|continue|type|global|module|using|import|export|const|let|bitstype|do|in|baremodule|importall|immutable)\b 0:keyword add-highlighter shared/julia/code/ regex \b(Number|Real|BigInt|Integer|UInt|UInt8|UInt16|UInt32|UInt64|UInt128|Int|Int8|Int16|Int32|Int64|Int128|BigFloat|FloatingPoint|Float16|Float32|Float64|Complex128|Complex64|Bool|Cuchar|Cshort|Cushort|Cint|Cuint|Clonglong|Culonglong|Cintmax_t|Cuintmax_t|Cfloat|Cdouble|Cptrdiff_t|Cssize_t|Csize_t|Cchar|Clong|Culong|Cwchar_t|Char|ASCIIString|UTF8String|ByteString|SubString|AbstractString|Array|DArray|AbstractArray|AbstractVector|AbstractMatrix|AbstractSparseMatrix|SubArray|StridedArray|StridedVector|StridedMatrix|VecOrMat|StridedVecOrMat|DenseArray|SparseMatrixCSC|BitArray|Range|OrdinalRange|StepRange|UnitRange|FloatRange|Tuple|NTuple|Vararg|DataType|Symbol|Function|Vector|Matrix|Union|Type|Any|Complex|String|Ptr|Void|Exception|Task|Signed|Unsigned|Associative|Dict|IO|IOStream|Rational|Regex|RegexMatch|Set|IntSet|Expr|WeakRef|ObjectIdDict|AbstractRNG|MersenneTwister)\b 0:type -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group julia-highlight global WinSetOption filetype=julia %{ - add-highlighter window/julia ref julia - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/julia } -} - } diff --git a/rc/filetype/just.kak b/rc/filetype/just.kak index 63a847d7..f81f0b58 100644 --- a/rc/filetype/just.kak +++ b/rc/filetype/just.kak @@ -5,10 +5,19 @@ hook global BufCreate .*/?[jJ]ustfile %{ set-option buffer filetype justfile } -hook -once global BufSetOption filetype=justfile %{ +hook global WinSetOption filetype=justfile %{ require-module justfile + + hook window InsertChar \n -group justfile-indent just-indent-on-new-line + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window justfile-.+ } } +hook -group justfile-highlight global WinSetOption filetype=justfile %{ + add-highlighter window/justfile ref justfile + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/justfile } +} + + provide-module justfile %{ # Indentation @@ -43,14 +52,4 @@ add-highlighter shared/justfile/content/ regex '^(@)?([\w-]+)(?:\s(.+))?\s?(:)(. add-highlighter shared/justfile/content/ regex '([=+])' 1:operator add-highlighter shared/justfile/content/ regex '^([\w-]+)\s=' 1:value -hook -group justfile-highlight global WinSetOption filetype=justfile %{ - add-highlighter window/justfile ref justfile - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/justfile } -} - -hook global WinSetOption filetype=justfile %{ - hook window InsertChar \n -group justfile-indent just-indent-on-new-line - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window justfile-.+ } -} - } diff --git a/rc/filetype/kickstart.kak b/rc/filetype/kickstart.kak index c939a252..0e7441b1 100644 --- a/rc/filetype/kickstart.kak +++ b/rc/filetype/kickstart.kak @@ -2,10 +2,16 @@ hook global BufCreate .*\.ks %{ set-option buffer filetype kickstart } -hook -once global BufSetOption filetype=kickstart %{ +hook global WinSetOption filetype=kickstart %{ require-module kickstart } +hook -group kickstart-highlight global WinSetOption filetype=kickstart %{ + add-highlighter window/kickstart ref kickstart + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/kickstart } +} + + provide-module kickstart %{ add-highlighter shared/kickstart regions @@ -29,10 +35,4 @@ add-highlighter shared/kickstart/shell/ regex '\A\h*\K%(pre-install|pre|post)\b' add-highlighter shared/kickstart/shell/ regex '^\h*%end\b' 0:type add-highlighter shared/kickstart/shell/ ref sh - -hook -group kickstart-highlight global WinSetOption filetype=kickstart %{ - add-highlighter window/kickstart ref kickstart - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/kickstart } -} - } diff --git a/rc/filetype/markdown.kak b/rc/filetype/markdown.kak index be193269..ab380b7f 100644 --- a/rc/filetype/markdown.kak +++ b/rc/filetype/markdown.kak @@ -8,10 +8,22 @@ hook global BufCreate .*[.](markdown|md|mkd) %{ set-option buffer filetype markdown } -hook -once global BufSetOption filetype=markdown %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=markdown %{ require-module markdown + + hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } } +hook -group markdown-highlight global WinSetOption filetype=markdown %{ + add-highlighter window/markdown ref markdown + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/markdown } +} + + provide-module markdown %{ # Highlighters @@ -77,17 +89,4 @@ define-command -hidden markdown-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group markdown-highlight global WinSetOption filetype=markdown %{ - add-highlighter window/markdown ref markdown - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/markdown } -} - -hook global WinSetOption filetype=markdown %{ - hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } -} - } diff --git a/rc/filetype/mercurial.kak b/rc/filetype/mercurial.kak index 5c014ee7..f21cd202 100644 --- a/rc/filetype/mercurial.kak +++ b/rc/filetype/mercurial.kak @@ -8,10 +8,15 @@ hook global BufCreate .*hg-editor-\w+\.txt$ %{ set-option buffer filetype hg-commit } -hook -once global BufSetOption filetype=hg-commit %{ +hook global WinSetOption filetype=hg-commit %{ require-module hg-commit } +hook -group hg-commit-highlight global WinSetOption filetype=hg-commit %{ + add-highlighter window/hg-commit ref hg-commit + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/hg-commit-highlight } +} + provide-module hg-commit %{ # Faces @@ -22,10 +27,7 @@ set-face global MercurialCommitComment cyan # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ -hook -group hg-commit-highlight global WinSetOption filetype=hg-commit %{ - add-highlighter window/ group hg-commit-highlight - add-highlighter window/hg-commit-highlight regex '^HG:[^\n]*' 0:comment - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/hg-commit-highlight } -} +add-highlighter shared/hg-commit group +add-highlighter shared/hg-commit/ regex '^HG:[^\n]*' 0:comment } diff --git a/rc/filetype/moon.kak b/rc/filetype/moon.kak index 1963905b..1ff48f38 100644 --- a/rc/filetype/moon.kak +++ b/rc/filetype/moon.kak @@ -8,10 +8,30 @@ hook global BufCreate .*[.](moon) %{ set-option buffer filetype moon } -hook -once global BufSetOption filetype=moon %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=moon %{ require-module moon + + hook window ModeChange insert:.* -group moon-trim-indent moon-trim-indent + hook window InsertChar .* -group moon-indent moon-indent-on-char + hook window InsertChar \n -group moon-indent moon-indent-on-new-line + + alias window alt moon-alternative-file + + hook -once -always window WinSetOption filetype=.* %{ + remove-hooks window moon-.+ + unalias window alt moon-alternative-file + } } +hook -group moon-highlight global WinSetOption filetype=moon %{ + add-highlighter window/moon ref moon + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/moon } +} + + provide-module moon %[ # Highlighters @@ -91,25 +111,4 @@ define-command -hidden moon-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group moon-highlight global WinSetOption filetype=moon %{ - add-highlighter window/moon ref moon - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/moon } -} - -hook global WinSetOption filetype=moon %{ - hook window ModeChange insert:.* -group moon-trim-indent moon-trim-indent - hook window InsertChar .* -group moon-indent moon-indent-on-char - hook window InsertChar \n -group moon-indent moon-indent-on-new-line - - alias window alt moon-alternative-file - - hook -once -always window WinSetOption filetype=.* %{ - remove-hooks window moon-.+ - unalias window alt moon-alternative-file - } -} - ] diff --git a/rc/filetype/restructuredtext.kak b/rc/filetype/restructuredtext.kak index 362c9806..29fc32a9 100644 --- a/rc/filetype/restructuredtext.kak +++ b/rc/filetype/restructuredtext.kak @@ -5,10 +5,18 @@ hook global BufCreate .*[.](rst) %{ set-option buffer filetype restructuredtext } -hook -once global BufSetOption filetype=restructuredtext %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=restructuredtext %{ require-module restructuredtext } +hook -group restructuredtext-highlight global WinSetOption filetype=restructuredtext %{ + add-highlighter window/restructuredtext ref restructuredtext + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/restructuredtext } +} + provide-module restructuredtext %{ # Highlighters @@ -71,12 +79,4 @@ add-highlighter shared/restructuredtext/content/ regex [^*](\*\*([^\s*]|([^\s*][ add-highlighter shared/restructuredtext/content/ regex [^*](\*([^\s*]|([^\s*][^*]*[^\s*]))\*)[^*] 1:italic add-highlighter shared/restructuredtext/content/ regex [^`](``([^\s`]|([^\s`][^`]*[^\s`]))``)[^`] 1:mono -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group restructuredtext-highlight global WinSetOption filetype=restructuredtext %{ - add-highlighter window/restructuredtext ref restructuredtext - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/restructuredtext } -} - } diff --git a/rc/filetype/taskpaper.kak b/rc/filetype/taskpaper.kak index 1e5cb321..3cd97808 100644 --- a/rc/filetype/taskpaper.kak +++ b/rc/filetype/taskpaper.kak @@ -8,10 +8,22 @@ hook global BufCreate .*\.taskpaper %{ set-option buffer filetype taskpaper } -hook -once global BufSetOption filetype=taskpaper %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=taskpaper %{ require-module taskpaper + + hook window InsertChar \n -group taskpaper-indent taskpaper-indent-on-new-line + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window taskpaper-.+ } } +hook -group taskpaper-highlight global WinSetOption filetype=taskpaper %{ + add-highlighter window/taskpaper ref taskpaper + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/taskpaper } +} + + provide-module taskpaper %{ # Highlighters @@ -39,17 +51,4 @@ define-command -hidden taskpaper-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group taskpaper-highlight global WinSetOption filetype=taskpaper %{ - add-highlighter window/taskpaper ref taskpaper - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/taskpaper } -} - -hook global WinSetOption filetype=taskpaper %{ - hook window InsertChar \n -group taskpaper-indent taskpaper-indent-on-new-line - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window taskpaper-.+ } -} - } diff --git a/rc/filetype/toml.kak b/rc/filetype/toml.kak index 141a21fd..4a7ad81c 100644 --- a/rc/filetype/toml.kak +++ b/rc/filetype/toml.kak @@ -8,10 +8,24 @@ hook global BufCreate .*\.(toml) %{ set-option buffer filetype toml } -hook -once global BufSetOption filetype=toml %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=toml %{ require-module toml + + hook window ModeChange insert:.* -group toml-trim-indent toml-trim-indent + hook window InsertChar \n -group toml-indent toml-indent-on-new-line + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window toml-.+ } } +hook -group toml-highlight global WinSetOption filetype=toml %{ + add-highlighter window/toml ref toml + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/toml } +} + + provide-module toml %{ # Highlighters @@ -53,19 +67,4 @@ define-command -hidden toml-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group toml-highlight global WinSetOption filetype=toml %{ - add-highlighter window/toml ref toml - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/toml } -} - -hook global WinSetOption filetype=toml %{ - hook window ModeChange insert:.* -group toml-trim-indent toml-trim-indent - hook window InsertChar \n -group toml-indent toml-indent-on-new-line - - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window toml-.+ } -} - } diff --git a/rc/filetype/yaml.kak b/rc/filetype/yaml.kak index 8e0f3487..ac8a9823 100644 --- a/rc/filetype/yaml.kak +++ b/rc/filetype/yaml.kak @@ -8,10 +8,23 @@ hook global BufCreate .*[.](ya?ml) %{ set-option buffer filetype yaml } -hook -once global BufSetOption filetype=yaml %{ +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=yaml %{ require-module yaml + + hook window ModeChange insert:.* -group yaml-trim-indent yaml-trim-indent + hook window InsertChar \n -group yaml-indent yaml-indent-on-new-line + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window yaml-.+ } } +hook -group yaml-highlight global WinSetOption filetype=yaml %{ + add-highlighter window/yaml ref yaml + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/yaml } +} + + provide-module yaml %{ # Highlighters @@ -49,18 +62,4 @@ define-command -hidden yaml-indent-on-new-line %{ } } -# Initialization -# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ - -hook -group yaml-highlight global WinSetOption filetype=yaml %{ - add-highlighter window/yaml ref yaml - hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/yaml } -} - -hook global WinSetOption filetype=yaml %{ - hook window ModeChange insert:.* -group yaml-trim-indent yaml-trim-indent - hook window InsertChar \n -group yaml-indent yaml-indent-on-new-line - hook -once -always window WinSetOption filetype=.* %{ remove-hooks window yaml-.+ } -} - } From 48abc3cbf3f4fca560fc9e7e02ae4d23cedf144a Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Sat, 13 Apr 2019 12:57:57 -0700 Subject: [PATCH 17/18] =?UTF-8?q?Changed=20'=F0=9F=A6=80'=20to=20'=C2=A7'?= =?UTF-8?q?=20for=20complex=20module=20quoting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rc/filetype/c-family.kak | 4 ++-- rc/filetype/d.kak | 4 ++-- rc/filetype/dart.kak | 5 +++-- rc/filetype/go.kak | 4 ++-- rc/filetype/java.kak | 4 ++-- rc/filetype/javascript.kak | 4 ++-- rc/filetype/kakrc.kak | 4 ++-- rc/filetype/perl.kak | 4 ++-- rc/filetype/ragel.kak | 4 ++-- rc/filetype/rust.kak | 4 ++-- 10 files changed, 21 insertions(+), 20 deletions(-) diff --git a/rc/filetype/c-family.kak b/rc/filetype/c-family.kak index 9e30e200..e4217a0b 100644 --- a/rc/filetype/c-family.kak +++ b/rc/filetype/c-family.kak @@ -59,7 +59,7 @@ hook -group objc-highlight global WinSetOption filetype=objc %{ } -provide-module c-family %🦀 +provide-module c-family %§ define-command -hidden c-family-trim-indent %{ # remove the line if it's empty when leaving the insert mode @@ -443,4 +443,4 @@ define-command objc-alternative-file -docstring "Jump to the alternate objc file c-family-alternative-file } -🦀 +§ diff --git a/rc/filetype/d.kak b/rc/filetype/d.kak index 3772ff8b..16c6d8d1 100644 --- a/rc/filetype/d.kak +++ b/rc/filetype/d.kak @@ -30,7 +30,7 @@ hook -group d-highlight global WinSetOption filetype=d %{ hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/d } } -provide-module d %🦀 +provide-module d %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -135,4 +135,4 @@ define-command -hidden d-indent-on-closing-curly-brace %[ try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] -🦀 +§ diff --git a/rc/filetype/dart.kak b/rc/filetype/dart.kak index 660c550e..f61dd365 100644 --- a/rc/filetype/dart.kak +++ b/rc/filetype/dart.kak @@ -30,7 +30,8 @@ hook -group dart-highlight global WinSetOption filetype=dart %{ hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dart } } -provide-module dart %🦀 + +provide-module dart %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -109,4 +110,4 @@ define-command -hidden dart-indent-on-closing-curly-brace %[ try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] -🦀 +§ diff --git a/rc/filetype/go.kak b/rc/filetype/go.kak index d697c574..fccb563b 100644 --- a/rc/filetype/go.kak +++ b/rc/filetype/go.kak @@ -30,7 +30,7 @@ hook -group go-highlight global WinSetOption filetype=go %{ hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/go } } -provide-module go %🦀 +provide-module go %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -102,4 +102,4 @@ define-command -hidden go-indent-on-closing-curly-brace %[ try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] -🦀 +§ diff --git a/rc/filetype/java.kak b/rc/filetype/java.kak index 36d4e3ba..0fd2bec9 100644 --- a/rc/filetype/java.kak +++ b/rc/filetype/java.kak @@ -23,7 +23,7 @@ hook -group java-highlight global WinSetOption filetype=java %{ } -provide-module java %🦀 +provide-module java %§ add-highlighter shared/java regions add-highlighter shared/java/code default-region group @@ -69,4 +69,4 @@ define-command -hidden java-indent-on-closing-curly-brace %[ try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] -🦀 +§ diff --git a/rc/filetype/javascript.kak b/rc/filetype/javascript.kak index 67ef45b7..23a176da 100644 --- a/rc/filetype/javascript.kak +++ b/rc/filetype/javascript.kak @@ -35,7 +35,7 @@ hook -group typescript-highlight global WinSetOption filetype=typescript %{ } -provide-module javascript %🦀 +provide-module javascript %§ # Commands # ‾‾‾‾‾‾‾‾ @@ -127,4 +127,4 @@ add-highlighter shared/typescript/code/ regex \b(array|boolean|date|number|objec # Keywords grabbed from https://github.com/Microsoft/TypeScript/issues/2536 add-highlighter shared/typescript/code/ regex \b(as|constructor|declare|enum|from|implements|interface|module|namespace|package|private|protected|public|readonly|static|type)\b 0:keyword -🦀 +§ diff --git a/rc/filetype/kakrc.kak b/rc/filetype/kakrc.kak index fcfd6e82..898d5788 100644 --- a/rc/filetype/kakrc.kak +++ b/rc/filetype/kakrc.kak @@ -31,7 +31,7 @@ hook -group kak-highlight global WinSetOption filetype=kak %{ hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/kakrc } } -provide-module kak %🦀 +provide-module kak %§ require-module sh @@ -114,4 +114,4 @@ define-command -hidden kak-indent-on-closing-char %{ try %{ execute-keys -draft -itersel ^\h*\Q %val{hook_param} \E$gi %val{hook_param} %\w*\Q %val{hook_param} \E$ s \A|.\z gi 1 } } -🦀 +§ diff --git a/rc/filetype/perl.kak b/rc/filetype/perl.kak index 242485c3..92d9825c 100644 --- a/rc/filetype/perl.kak +++ b/rc/filetype/perl.kak @@ -30,7 +30,7 @@ hook -group perl-highlight global WinSetOption filetype=perl %{ hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/perl } } -provide-module perl %🦀 +provide-module perl %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -119,4 +119,4 @@ define-command -hidden perl-indent-on-closing-curly-brace %[ try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] -🦀 +§ diff --git a/rc/filetype/ragel.kak b/rc/filetype/ragel.kak index 696bc85d..8f3d448f 100644 --- a/rc/filetype/ragel.kak +++ b/rc/filetype/ragel.kak @@ -28,7 +28,7 @@ hook -group ragel-highlight global WinSetOption filetype=ragel %{ hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ragel } } -provide-module ragel %🦀 +provide-module ragel %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -73,4 +73,4 @@ define-command -hidden ragel-indent-on-new-line %< > > -🦀 +§ diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index 0a3a6dbd..e83caf4f 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -34,7 +34,7 @@ hook global WinSetOption filetype=rust %[ ] -provide-module rust %🦀 +provide-module rust %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -99,4 +99,4 @@ define-command -hidden rust-indent-on-closing %[ _ ] -🦀 +§ From f49644e8ee8b2450f28b82d74fcf823d81f2ae1c Mon Sep 17 00:00:00 2001 From: Justin Frank Date: Mon, 15 Apr 2019 12:53:45 -0700 Subject: [PATCH 18/18] Fix typo in documentation and clarify override behaviour --- doc/pages/commands.asciidoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/pages/commands.asciidoc b/doc/pages/commands.asciidoc index c9c84b96..50b235f7 100644 --- a/doc/pages/commands.asciidoc +++ b/doc/pages/commands.asciidoc @@ -319,7 +319,8 @@ but not really useful in that context. evaluated as if by source the first time *require-module * is run. *-override*::: - allow the module to replace and existing one with the same name + allow the module to replace an existing one with the same name. Fails if + the module has already been evaluated. *require-module* :: guarantees the commands associated with *name* have been evaluated before