Commit Graph

10096 Commits

Author SHA1 Message Date
Charles Gueunet
11c9984f26 Charles Gueunet Copyright Waiver
I dedicate any and all copyright interest in this software to the
public domain.  I make this dedication for the benefit of the public at
large and to the detriment of my heirs and successors.  I intend this
dedication to be an overt act of relinquishment in perpetuity of all
present and future rights to this software under copyright law.
2022-03-18 09:01:04 +01:00
Charles Gueunet
2f1cb11194 CMake: fix comment highlight 2022-03-18 09:01:02 +01:00
in0ni
719f78349a
Update rc/filetype/twig.kak
fix typo

Co-authored-by: Screwtapello <thristian@gmail.com>
2022-03-17 08:57:58 -05:00
in0ni
e226c7ea2b
Update rc/filetype/twig.kak
fix typo

Co-authored-by: Screwtapello <thristian@gmail.com>
2022-03-17 08:57:40 -05:00
Andrés González
a05151dd23 Andrés González Copyright Waiver
I dedicate any and all copyright interest in this software to the
  public domain.  I make this dedication for the benefit of the public at
  large and to the detriment of my heirs and successors.  I intend this
  dedication to be an overt act of relinquishment in perpetuity of all
  present and future rights to this software under copyright law.``
2022-03-16 22:09:54 -05:00
Andrés González
9ac6669e50 basic support for twig 2022-03-16 21:55:44 -05:00
Andrés González
eaea1d20f3 Improved indentation, keywords, and variables for scss 2022-03-16 21:55:29 -05:00
Andrés González
f2c11c0123 Improved support for commenting, mainly pulled from c-family.kak 2022-03-16 21:54:05 -05:00
Andrés González
ca68f73a36 Much better support for CSS, tested using varied examples from spec 2022-03-16 21:53:33 -05:00
Maxime Coste
13b1681593 Merge remote-tracking branch 'krobelus/doc-complete-command-args' 2022-03-15 20:24:00 +11:00
Johannes Altmanninger
0f0f2b126d doc commands: fix names of complete-command's completion_type arguments 2022-03-08 22:10:28 +01:00
Johannes Altmanninger
13948ecb94 rc diff: pass diff to diff-jump via stdin instead of env
Passing large diff buffers via the environment can quickly result in
the error "execve failed: Argument list too long". Use a pipe like
in format.kak

When running | (or <a-|>), Kakoune does not use %arg{@} to populate
"$@" (missing feature?). Work around this by moving %arg{@} to a
temporary register. Apparently $kak_quoted_reg_a will never be an
empty list, so work around that too.

When diff parsing fails, we take care to run "fail" in the calling
client, unlike :format (probably a bug in format.kak).

(This patch is best viewed while ignoring whitespace changes (diff -w))
2022-03-08 20:30:06 +01:00
tomKPZ
f709ba6390 Fix buffer overflow in parse_quoted
This fixes a crash when using kak-lsp with bash-language-server.  The
issue is that the second read() in parse_quoted may read past the end of
the string.  If this happens and the condition on line 126 is false,
then the loop on line 119 will continue to read past the end of the
buffer since it checks for state.pos != end instead of state.pos < end,
which will likely result in a crash.  The fix is to add a check for the
buffer end before the second read. The added test fails without the
change and passes with the change.
2022-03-08 09:05:10 -08:00
tomKPZ
82db91c58c Thomas Anderson Copyright Waiver
I dedicate any and all copyright interest in this software to the
public domain.  I make this dedication for the benefit of the public at
large and to the detriment of my heirs and successors.  I intend this
dedication to be an overt act of relinquishment in perpetuity of all
present and future rights to this software under copyright law.
2022-03-08 09:04:41 -08:00
Johannes Altmanninger
eaaf562ed1 rc diff: support absolute paths in diff-jump
Quick repro:

	diff /dev/null $PWD/README.asciidoc -u | kak -e 'set-option buffer filetype diff'

Fixes #4531
2022-03-06 09:49:55 +01:00
Johannes Altmanninger
49de2b91c4 rc diff: bind diff-jump in all filetype=diff buffers, not just *.diff or *.patch files
Mapping in the filetype hook matches others like grep.kak and man.kak.
Since we map in buffer scope, git diff buffers will override diff-jump
with git-diff-goto-source.

This means that the diff-jump binding applies here:

	diff -u "$1" "$2" | kak -e 'set buffer filetype diff'

Reported in: https://github.com/mawww/kakoune/issues/153#issuecomment-1030643854
2022-03-06 09:49:55 +01:00
Johannes Altmanninger
1c2e1e1090 rc diff: fix style
This line was unindented by accident (I was rushing..)
2022-03-06 09:49:55 +01:00
Maxime Coste
1d6476d329 Document the GCC >= 10.3 instead of just >= 10 requirement 2022-03-06 10:13:14 +11:00
Maxime Coste
d95d351cbe Document ! and <a-!> breaking change 2022-03-06 10:13:14 +11:00
Frank LENORMAND
85b78dda2e src: Select the data inserted by ! and <a-!>
Closes #1468
2022-03-06 10:13:14 +11:00
Maxime Coste
7061001728 Add a complete-command command to configure command completion
This makes it possible to change command completion in hooks and
paves the way to more flexibility in how custom commands can be
completed
2022-03-06 10:13:14 +11:00
Maxime Coste
b915e4e11b Close MappedFile fd using on_scope_end to handle all return paths 2022-03-06 10:13:14 +11:00
Luis Alfonso Buelvas Betancourt
d6392e37c9
fennel filetype now highlights accumulate keyword 2022-02-22 17:13:38 -05:00
Maxime Coste
30c05e83f8 Remove unnecessary workaround in Buffer::insert 2022-02-22 08:28:33 +11:00
Maxime Coste
3f856d4e30 Merge remote-tracking branch 'SolitudeSF/elvish' 2022-02-22 08:12:15 +11:00
Johannes Altmanninger
3a856ef57b rc conf: treat ini files as conf if they contain a #-comment
*.ini files traditionally use ; but for example the "foot" terminal's
foot.ini uses #. Add a hack to treat ini files as "conf" filetype
if they contain a #-comment (very slim chance of false positives).
This requires to explicitly set comment_line to the default #,
because we set the "ini" filetype earlier.
2022-02-19 17:31:55 +01:00
Johannes Altmanninger
cc6fe5ae61 Add conf filetype, for generic Unix configuration files
We set the "ini" filetype for files ending in one of "repo", "ini",
"cfg", "properties" or "desktop".  Most of these actually use Unix
style comments (#) instead of DOS INI comments (;).

Introduce filetype "conf" which is similar to "ini" except it uses the
default # as comment_line string.  Both Vim and Emacs have a filetype
(or Major mode) named "conf" (hence modeline-parse of "vim ft=conf"
will work).

Here are references that show that the new "conf" files use #-comments:
*.repo -- search for # in
    https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/sec-configuring_yum_and_yum_repositories
*.cfg: don't know much about this one, but at least the motivating file uses #
    https://github.com/buildout/buildout/blob/master/buildout.cfg
*.properties files:
    https://en.wikipedia.org/wiki/.properties
*.desktop: per spec
    https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s03.html#comments
2022-02-19 17:31:16 +01:00
SolitudeSF
1dc0a2eaf2
Fix elvish highlighter 2022-02-18 18:19:21 +02:00
Maxime Coste
0e572589f3 Do not keep MappedFile fd opened
According to the mmap man page this is not necessary, and this avoids
exposing the fd.
2022-02-18 20:24:23 +11:00
Maxime Coste
e04a14cf73 Merge branch 'patch-1' of http://github.com/Rosuavio/kakoune 2022-02-16 07:55:56 +11:00
Maxime Coste
a52b867dba Merge remote-tracking branch 'dontlaugh/patch-1' 2022-02-15 21:01:50 +11:00
Maxime Coste
0d1136474f Merge remote-tracking branch 'xiaq/master' 2022-02-15 20:56:21 +11:00
Maxime Coste
f150bbd54a Merge remote-tracking branch 'm-kru/vhdl_end_protected_body' 2022-02-15 20:51:45 +11:00
Maxime Coste
ffb02222c3 Merge remote-tracking branch 'krobelus/c-n-autocomplete' 2022-02-15 20:51:11 +11:00
Maxime Coste
17237fb887 Merge remote-tracking branch 'krobelus/different-select-cmd-no-dupe' 2022-02-15 20:46:38 +11:00
Maxime Coste
b6a9fd6e3a Merge remote-tracking branch 'c7skasku/fix-c-comments-whitespace' 2022-02-15 20:45:40 +11:00
Maxime Coste
d3f9358fdb Merge remote-tracking branch 'Qeole/pr/crash-colors' 2022-02-15 20:44:41 +11:00
Maxime Coste
b030fc4c07 Merge remote-tracking branch 'Screwtapello/validate_alpha-is-constexpr' 2022-02-15 20:43:43 +11:00
Coleman McFarland
0b5ed7613f Update module description in response to code review 2022-02-14 10:20:10 -05:00
Coleman McFarland
f206640abc Grammar correction options.asciidoc 2022-02-13 21:27:31 -05:00
Coleman McFarland
c682f30ab6 Change "edition" to "editing" in keys.asciidoc 2022-02-13 21:18:35 -05:00
Coleman McFarland
db0ceb90ff Coleman McFarland <dontlaugh> Copyright Waiver
I dedicate any and all copyright interest in this software to the
public domain.  I make this dedication for the benefit of the public at
large and to the detriment of my heirs and successors.  I intend this
dedication to be an overt act of relinquishment in perpetuity of all
present and future rights to this software under copyright law.
2022-02-13 15:17:46 -05:00
Coleman McFarland
11f98dc0f1
Add brief modules explanation
In lieu of adding a whole docs page for modules, a brief introduction can
be added above the provide-module and require-module command docs.
2022-02-13 15:15:07 -05:00
Tim Allen
d1ea2ffa60 Make Color::validate_alpha() a constexpr function.
We call it from a constexpr constructor, so it needs to be constexpr itself.

Fixes #4544.
2022-02-12 21:35:33 +11:00
Johannes Altmanninger
e6d0ff1bc8 Filter duplicate completions only if they have the same select cmd
Given a completer option with two applicable completions

	text|select-cmd1|menu-text1
	text|select-cmd2|menu-text2

Kakoune will only show one of them, because they will insert the
same text.

Some language servers send completions like this, for example if
two different importable modules provide the same name. This can be
reproduced using intelephense in this PHP file (cursor is %())

	<?php
	namespace namespace1;
	class sometype {}
	?>
	<?php
	namespace namespace2;
	class sometype {}
	?>

	<?php
	namespace test;
	some%()
	?>

Both completions insert "sometype". The import statement will be
added in an InsertCompletionHide hook by kak-lsp (it uses select-cmd
to determine which completion was selected).

To support this use case, refine the duplicate detection to not filter
out completions with different select-cmd values.
2022-02-11 16:51:29 +01:00
Qeole
3abf2b8260 Faces: Check that underline colour comes before base/attributes markers
Parsing a (non-valid) font with a comma in the name of the base colour
makes Kakoune crash. It is not a valid face, but Kakoune should just
return an error message instead.

Reproducer:

    :set-face global foo ,red@,blue

Note the comma "," after the "@". This is not a valid base name, and it
leads to a crash. Let's see what happens.

At the beginning of parse_face(), we have the following code:

    auto bg_it = find(facedesc, ',');
    auto underline_it = bg_it == facedesc.end() ? bg_it : std::find(bg_it+1, facedesc.end(), ',');
    auto attr_it = find(facedesc, '+');
    auto base_it = find(facedesc, '@');
    [...]
    auto colors_end = std::min(attr_it, base_it);

After this:

- bg_it points to ",red@,blue"
- bg_it != facedesc.end(), so we have underline_it pointing to the first
  comma after bg_it. This means that underline_it points to ",blue"
- base_it points to "@,blue"
- attr_it points to the end of facedesc (no "+" marker), so colors_end
  points to base_it, "@,blue"

Later in the code, just after parsing the foreground and background
colours, we have:

    if (underline_it != facedesc.end())
        face.underline = parse_color({underline_it+1, colors_end});

When passing {underline_it+1, colors_end} to parse_color(), we pass in
fact iterators pointing to {",blue", "@,blue"}. Because the second one
starts _before_ the first one in the string, this means that the
resulting string is considered to have a _negative_ length.
parse_color() passes the string to str_to_color(), who fails to turn up
the colour, and attempts to throw:

    throw runtime_error(format("unable to parse color: '{}'", color));

The variable "color" still has this negative length, and this goes all
the way down to an assert in src/units.hh where we expect that string to
be >= 0, and we crash on the assertion failure.

For similar reasons, we also get a crash if the comma comes after the
marker for the face attributes:

    :set-face global foo ,red+,a

To fix both cases, let's add a check to make sure that the underline_it,
marked with a comma, never gets detected as present and pointing after
colors_end, be it "@" or "+".
2022-02-11 09:35:49 +00:00
Cormac Stephenson
ed9d99c7b3 c-family: fix whitespace trimming in comments 2022-02-10 00:49:46 +00:00
Michał Kruszewski
8b6221e97f VHDL filetype: Wisely add "end protected body;". 2022-02-09 11:08:45 +01:00
Johannes Altmanninger
43fc5b0078 Make <c-n> show completion menu again when autocomplete is off
As pointed out in [1], when insert mode autocomplete is disabled,
<c-n> could be used to activate insert mode completions temporarily
[2].  This regressed in 6f7c5aed (Do not show custom completions when
autocomplete is off, 2022-01-03). Fix this by enabling completions
on <c-n>/<c-p>. This allows us to remove a special case for explicit
completers.

Alternative behavior (future?): make <c-n> toggle completion like
<c-o>.  This can be done today, as suggested by Screwtape on IRC:

	map global insert <c-n> %{<c-o><c-n><a-;>:toggle-ctrl-n<ret>}
	define-command toggle-ctrl-n %{
		hook global InsertCompletionShow .* %{ map window insert <c-n> <c-n> }
		hook global InsertCompletionHide .* %{ unmap window insert <c-n> <c-n> }
	}

[1] https://github.com/mawww/kakoune/pull/4493#issuecomment-1031189823
[2] <c-n> completion only lives for the lifetime of the completion
    menu, whereas <c-o> lasts until you exit insert mode. This means
    that autocompletion is much more convenient than <c-n> or <c-x>f,
    because those require an explicit completion request for each
    path component.
2022-02-07 14:52:51 +01:00
Johannes Altmanninger
a4953c59ce Enable test/regression/0-autocomplete-overrules-completers
test/run skips directories without the "cmd" file, so it doesn't run
this test.  Fix this by adding an empty "cmd", like elsewhere.
2022-02-07 14:52:51 +01:00