1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-25 21:16:38 +03:00
kakoune/rc/filetype
Chris Webb ca50379771 Avoid semantically significant comments in kak files
Kakoune's balanced strings require that delimiter characters nested inside
them are also paired, so for example in %{ }, each nested { must occur
before a corresponding } to balance it out.

In general this will automatically be the case for code in common scripting
languages, but sometimes regular expressions used for syntax highlighting
do end up containing an unbalanced bracket of one type or another.

This problem is easily solved because there is a free choice of balanced
delimiter characters. However, it can also be worked around by adding
a comment which itself contains an unbalanced delimiter character, to
'balance out' the unpaired one in the regular expression.

These unbalanced comments are not ideal as the semantic role they perform
is easy for a casual reader to overlook. A good example is

    catch %{
        # indent after lines with an unclosed { or (
        try %< execute-keys -draft [c[({],[)}] <ret> <a-k> \A[({][^\n]*\n[^\n]*\n?\z <ret> j<a- gt> >
        # indent after a switch's case/default statements
        try %[ execute-keys -draft kx <a-k> ^\h*(case|default).*:$ <ret> j<a-gt> ]
        # deindent closing brace(s) when after cursor
        try %[ execute-keys -draft x <a-k> ^\h*[})] <ret> gh / [})] <ret> m <a-S> 1<a-&> ]
    }

in rc/filetype/go/kak. Here, it is not instantly obvious that the comment
containing an unmatched { is required for correctness. If you change the
comment, delete it or rearrange the contents of the catch block, go.kak
will fail to load, and if you cut-and-paste this code as the basis for
a new filetype, it is a loaded gun pointing at your feet.

Luckily, a careful audit of the standard kakoune library turned up only
three such instances, in go.kak, hare.kak and markdown.kak.

The examples in go.kak and hare.kak are easily made robust by replacing
a %{ } with %< > or %[ ] respectively. The example in markdown.kak is
least-intrusively fixed by rewriting the affected regular expression
slightly so it has balanced { and } anyway.
2023-12-13 16:40:48 +00:00
..
apl.kak rc: move remaining comment insertion hooks to *-insert group 2023-05-03 19:36:50 +02:00
arch-linux.kak Add categories in rc/ 2019-03-21 01:06:16 +01:00
asciidoc.kak Fix AsciiDoc blocks 2021-10-17 00:19:53 +02:00
awk.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
c-family.kak Improve c-family highlighting of preprocessor directives 2023-12-10 13:50:29 +00:00
cabal.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
clojure.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
cmake.kak CMake: fix comment highlight 2022-03-18 09:01:02 +01:00
coffee.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
conf.kak rc conf: treat ini files as conf if they contain a #-comment 2022-02-19 17:31:55 +01:00
coq.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
crystal.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
css.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
cucumber.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
cue.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
d.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
dart.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
dhall.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
diff.kak Remove unnecessary leading space in prompt from mappings 2022-08-01 07:37:02 +02:00
dockerfile.kak rc/filetype/dockerfile: detect filenames that contain special characters 2022-08-16 11:50:30 -04:00
elixir.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
elm.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
elvish.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
erlang.kak Erlang syntax highlighting: Improved support for numeric literals, refs, ports and pids 2021-10-28 12:43:00 +05:30
eruby.kak Add missing eRuby indent group 2021-06-15 14:30:35 +02:00
etc.kak Fixed several more support files. 2019-04-10 16:48:46 -07:00
exherbo.kak Update remaining files to new provide/require format 2019-04-11 15:54:58 -07:00
fennel.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
fidl.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
fish.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
fsharp.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
gas.kak Fix gas palign2 directive highlight 2022-12-06 17:47:32 +11:00
gdscript.kak fix improper set/get = highlight for Godot v4.x GDScript 2023-03-25 07:14:34 +02:00
gentoo-linux.kak Add gentoo linux ebuild filetype detection. 2021-08-06 11:30:06 -07:00
git.kak Merge remote-tracking branch 'adamchristiansen/gitignore-highlighting' 2022-05-10 22:36:44 +10:00
github.kak Add highlighting for CODEOWNERS 2022-01-10 08:27:07 -05:00
gluon.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
go.kak Avoid semantically significant comments in kak files 2023-12-13 16:40:48 +00:00
graphql.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
gren.kak Gren highlighting 2023-10-29 20:51:42 +00:00
groovy.kak add groovy filetype 2023-09-07 09:52:00 +08:00
haml.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
hare.kak Avoid semantically significant comments in kak files 2023-12-13 16:40:48 +00:00
haskell.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
hbs.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
html.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
i3.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
ini.kak Add conf filetype, for generic Unix configuration files 2022-02-19 17:31:16 +01:00
janet.kak janet: syntax improvements and trailing whitespace cleaning 2023-10-31 11:15:38 +04:00
java.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
javascript.kak switch from using '&' to '<a-&>' when indenting javascript comments to allow the 2022-11-17 13:52:22 -07:00
jinja.kak rc jinja: Highlight Jinja statements/expressions 2020-01-08 12:22:34 +01:00
json.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
julia.kak @macro! 2023-11-01 17:23:03 -04:00
just.kak rc: move remaining comment insertion hooks to *-insert group 2023-05-03 19:36:50 +02:00
kakrc.kak rc tools menu: replace menu builtin with a prompt-based implementation 2023-11-20 20:47:22 +01:00
kickstart.kak Update remaining files to new provide/require format 2019-04-11 15:54:58 -07:00
kotlin.kak rc:filetype:kotlin.kak add-highlighter fun_tests prohibited tokens added :/ with face attributes changed to +iuf 2022-09-10 10:20:27 +02:00
latex.kak rc: move remaining comment insertion hooks to *-insert group 2023-05-03 19:36:50 +02:00
ledger.kak rc ledger: don't use region highlighter for simple keywords 2022-08-28 08:21:57 +02:00
lisp.kak Fixed lisp highlighter marking everything as variable 2023-07-01 15:27:13 +08:00
lua.kak Add highlighting of Lua variables, labels, and self keyword 2023-09-30 11:57:30 -06:00
mail.kak Highlight inline patches and signatures in mail.kak 2023-12-10 11:42:32 +00:00
makefile.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
markdown.kak Avoid semantically significant comments in kak files 2023-12-13 16:40:48 +00:00
mercurial.kak filetype/mercurial: Improve highlighting of Mercurial commit messages 2023-11-16 11:33:07 +01:00
mercury.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
meson.kak meson: improve highlighting, add static words 2021-01-13 15:44:38 +01:00
mlb.kak Add highlighters for Standard ML 2020-06-23 19:22:35 +01:00
moon.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
nim.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
ninja.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
nix.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
ocaml.kak Detect .mll and .mly files as OCaml sources 2023-07-26 17:15:06 +09:00
odin.kak Added odinlang support 2023-09-24 17:03:07 -06:00
pascal.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
perl.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
php.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
pony.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
protobuf.kak rc: move remaining comment insertion hooks to *-insert group 2023-05-03 19:36:50 +02:00
pug.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
purescript.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
python.kak Delete commenting prefix on empty lines in Python 2023-04-02 21:09:57 +09:00
r.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
ragel.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
restructuredtext.kak rc restructuredtext: only add language highlighters for actual code blocks in buffer 2022-09-10 07:35:29 +02:00
ruby.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
rust.kak Add "union" as a keyword for Rust syntax 2022-11-01 21:29:07 +00:00
sass.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
scala.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
scheme.kak rc filetype: fix double space in trim-indent hooks 2022-05-26 17:08:15 +02:00
scss.kak rc filetype: fix double space in trim-indent hooks 2022-05-26 17:08:15 +02:00
sh.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
sml.kak Add highlighters for Standard ML 2020-06-23 19:22:35 +01:00
sql.kak Fix function highlighting by adding lazy instead of greedy regexp quantifier 2020-10-14 14:54:43 -06:00
svelte.kak rc/filetype/svelte.kak: Set buffer rather than window filetype 2023-03-14 23:02:53 -07:00
swift.kak rc swift: Add open and internal keywords 2021-06-24 14:29:10 +03:00
systemd.kak Add categories in rc/ 2019-03-21 01:06:16 +01:00
taskpaper.kak rc markdown taskpaper: require bare URL to start at word boundary 2022-10-16 19:49:43 +02:00
terraform.kak Add filetype for terraform files with syntax hl 2019-11-18 20:41:42 +00:00
toml.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
troff.kak troff: Highlight .pdfhref and links 2023-11-25 19:45:20 +01:00
tupfile.kak Fixed many of the filetype support modules to not use BufSetOption to load 2019-04-09 20:54:19 -07:00
twig.kak Make x just select the full lines 2022-07-05 08:43:40 +10:00
vhdl.kak Merge remote-tracking branch 'm-kru/vhdl_time_vector' 2022-09-09 15:42:37 +02:00
void-linux.kak Add categories in rc/ 2019-03-21 01:06:16 +01:00
yaml.kak Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
zig.kak rc/filetype/zig: remove align builtin and add f80 type 2023-11-02 12:13:41 +09:00