Commit Graph

9466 Commits

Author SHA1 Message Date
SolitudeSF
1dc0a2eaf2
Fix elvish highlighter 2022-02-18 18:19:21 +02: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
Rosario Pulella
67e5882875
Fix type-o 2022-02-03 21:59:15 -05:00
Maxime Coste
33e81af0f3 Fix regex alternation execution priority
The ThreadedRegexVM implementation does not execute split opcodes as
expected: on split the pending thread is pushed on top of the thread
stack, which means that when multiple splits are executed in a row
(such as with a disjunction with 3 or more branches) the last split
target gets on top of the thread stack and gets executed next (when the
thread from the first split target would be the expected one)

Fixing this in the ThreadedRegexVM would have a performance impact as
we would not be able to use a plain stack for current threads, so the
best solution at the moment is to reverse the order of splits generated
by a disjunction.

Fixes #4519
2022-02-02 14:51:17 +11:00
Johannes Altmanninger
0b29fcf32a rc diff: evaluate diff-highlight hook before loading module
A recent commit wrapped diff.kak into a module. The module includes the
hook that adds diff highlighting to filetype=diff buffers.  This means
that the hook is only loaded after opening the first diff buffer in a
Kakoune session, so it only actually fires for the second diff buffer.
Fix this by moving the hook out of the module.

Fixes #4525
2022-02-02 11:25:41 +11:00
Maxime Coste
4bd34caf4f Fix modified keys not being mappable in goto mode
The test was invalid, non-codepoint keys should be considered mappable.

Fixes #4521
2022-02-01 13:36:36 +11:00
Qi Xiao
9227b96939 Add filetype support for Elvish.
Loosely based on sh.kak and c-family.kak.

See https://elv.sh for information on the Elvish language. In particular,
see https://elv.sh/ref/language.html for the language syntax and
https://elv.sh/ref/builtin.html for builtin commands.
2022-01-31 12:04:02 +00:00
Qi Xiao
6756bab98b Qi Xiao 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-01-30 21:42:37 +00:00
kjduncan
d44d07bd80 rc:filetype:java refactored to shell block add-highligher with additional highlighter for module system, added static word list and the keywords var yield. 2022-01-29 10:25:16 +11:00
Maxime Coste
28ef698295 Merge remote-tracking branch 'sidkshatriya/php-syntax-heredoc' 2022-01-29 10:19:08 +11:00
Maxime Coste
6c8b7c954f Merge remote-tracking branch 'Qeole/pr/git-blame-flags' 2022-01-29 10:17:02 +11:00
Maxime Coste
49339749d1 Merge remote-tracking branch 'krobelus/mail-patch-goto-source' 2022-01-29 10:04:42 +11:00
Qeole
5650bf33fa rc git: Batch flags when passing commit info for "git blame"
The wrapper for "git blame" creates flags for each line of the buffer.
It parses the output from git and would send a flag (or a series of
flags) each time the commit to blame for a line differs from the
previous one. For files that were touched by a large number of commits,
this results in a high number of kakoune processes being launched, and
may take some time. This is visible in the session through the flags for
the different commits appearing on the lines one by one, possibly during
several seconds.

To speed up the process, batch flags before passing them to the kak
session. One solution could be to send all flags at once, but this might
delay the appearance of commit info for too long if "git blame" really
takes a long time. The alternative solution retained for this commit
consists in grouping as many flags as we can during one second
(roughly), to pass them to kakoune, and then to move on to the next
flags. This way, a new batch of commit information flags appears every
second or so in the client, until all information is added. This should
be much faster than lauching a kakoune process for each commit
reported by "git blame": tests have shown that blaming a large file in
the Linux repository goes 4.5 times faster when batching flags.

Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>
2022-01-27 23:15:32 +00:00
Johannes Altmanninger
3843163e2e rc mail: enable jumping from inline diff to source file
This allows to jump from a mail buffer that contains an inline diff
to the source files (most accurate when the patch has been applied
locally).

This makes the diff module a mandatory dependency; we could relax that.
2022-01-25 14:15:01 +01:00
Johannes Altmanninger
90b070034d rc diff: skip email quotes in diff-jump
When reading and writing emails that contain patches (possibly
email-quoted), it can be convenient to the jump to the source file.
Allow this by making diff-jump (bound to <ret> in git-diff
buffers) ignore leading email quotes ("> "). A line that starts with
"> " should not occur in a unified diff, so this won't affect other
use cases.

Observe that diff-jump even works around interleaved replies; they
will not affect the computed line numbers because we ignore lines
that don't match ^(> )*[ +-].
2022-01-25 14:15:01 +01:00
Johannes Altmanninger
bf239ba77a rc diff: introduce diff-jump, replacing git-diff-goto-source
git-diff-goto-source is specific to diffs produced by Git.  This patch
generalizes the logic and moves it to a new diff-jump in diff.kak.

The main differences are:
- diff-jump handles plain file diffs (i.e. without the -r option). These
  have no "diff" line. This means that it needs to parse +++/--- instead.
- diff-jump can go to the old file, not just the new one.
- diff-jump allows to override the base directory and the number of
  directory components to strip.

git-diff-goto-source was implemented with several nested try/catch
blocks.  Implementing the extra features would have added more
nesting, redundancy or hidden options. To avoid that, I ported the
parsing logic to Perl (which git.kak already depends on). Maybe
it's possible to do the same in awk.

Potential concerns:
- We could move diff-jump to a new rc/tools/diff.kak but then it's not
  obvious where the "diff" module belongs to.
- Should diff "diff-jump -1" be spelled "diff-jump -p1"?

In future, the diff parser could be reused to implement a vimdiff-style
feature: given a diff and the "old" line number, we can compute the
corresponding "new" line number. Perhaps diff-jump should get a -client
argument.
2022-01-25 14:15:01 +01:00
Johannes Altmanninger
b84abd57de rc diff: make it a module
We want to move git-diff-goto-source from rc/tools/git.kak
to rc/filetype/diff.kak (or should we could create
rc/tools/diff.kak?). Either way, create the diff module so we can
formalize this dependency.

Currently this module only provides highlighters, so require it
wherever we reference them.

Keep the diff-select-{file,hunk} commands outside the module because
people might already use them in git buffers.
2022-01-25 14:11:06 +01:00
Sidharth Kshatriya
c994f4f992 Review: remove a comment 2022-01-24 19:05:35 +05:30
Maxime Coste
bfbce2a1c1 Merge remote-tracking branch 'Screwtapello/fix-session-name-error' 2022-01-24 22:11:50 +11:00
Maxime Coste
4d864e76d4 Merge remote-tracking branch 'm-kru/vhdl_boolean_vector' 2022-01-24 22:00:15 +11:00
Maxime Coste
f8a86149e5 Use strerror to display execve failures
Fixes #4501
2022-01-24 21:59:16 +11:00
Maxime Coste
6f135c0c8e Do not insert any end-of-line when piping data out
This will unfortunately break some use case which will require
using wrapper scripts to add the necessary newline. It is however
harder to do the contrary, and it makes a lot of other use case
possible, such as checksuming.

Fixes #3669
2022-01-24 21:53:33 +11:00
Maxime Coste
00080f8337 Remove explicit fail in new command
That fail prevents the real error message from being displayed
2022-01-24 21:41:43 +11:00
Maxime Coste
a361020632 Recognize foot as a wayland terminal 2022-01-24 21:16:45 +11:00
Maxime Coste
f4ff59f8b2 Restore goto case insensitiveness, refuse to map upper case
After a while it seems clear changing this is much more ergonomic
and restoring it with pure config is impractical as we need to map
all lower case keys.
2022-01-23 21:00:45 +11:00
Tim Allen
4bfb0c6b93 When reporting an invalid session name, report the correct name.
At this point, the session name has already been moved from the `session_name`
parameter to the `m_session` member variable.
2022-01-18 14:44:09 +11:00
Michał Kruszewski
45539d5d9f VHDL filetype: Add boolean_vector to types.: 2022-01-16 10:28:13 +01:00
Sidharth Kshatriya
9b5040b3f2 .phpt (PHP Test) files should also receive PHP syntax highlighting 2022-01-13 23:24:26 +05:30
Sidharth Kshatriya
c7880932c4 Add support for PHP heredoc in syntax highlighting 2022-01-13 22:57:10 +05:30
Maxime Coste
9acd4e62dc Merge remote-tracking branch 'krobelus/autocomplete-overrules-completers' 2022-01-10 09:04:35 +11:00