Commit Graph

10417 Commits

Author SHA1 Message Date
Sidharth Kshatriya
be7e3ccc9e changelog: escape { as \\{ otherwise '%val{window_range}' appears as '%val' in version notes startup splash 2023-11-17 03:19:14 +05:30
Nico Sonack
befad73a30 filetype/mercurial: Improve highlighting of Mercurial commit messages
This highlights important commit metadata when editing mercurial
commit messages such as the user, the branch, bookmark etc. with
reasonable colours.
2023-11-16 11:33:07 +01:00
Nico Sonack
f19546a2bb filetype/mercurial: Fix file name regex
The regex for detecting Mercurial's file types was too strict and
didn't catch commit messages.

Relax it to make it detect the commit files properly.
2023-11-16 11:30:07 +01:00
Nico Sonack
6fb03b55a1 Nico Sonack aka. herrhotzenplotz 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.
2023-11-16 11:39:09 +01:00
Maxime Coste
b10a935b8c Drop last character for basename matching
If the candidate ends with a slash we still look at the previous
component as the basename.
2023-11-16 12:59:55 +11:00
Maxime Coste
a42aa1e47e Slight cleanup of RankedMatch code 2023-11-15 12:48:23 +11:00
Maxime Coste
1cfe5273f3 Do not use range adaptor to gather ranked matches
This ends up constructing RankedMatch twice, once when computing
the number of elements then once when actually filling the vector.
2023-11-15 12:46:28 +11:00
Maxime Coste
4a1a3ee06e Refactor fuzzy matcher ranking further
Remove FirstCharMatch which does not impact any of the test cases
and explicitely detect paths by using a BaseName flag when we match
the basename of the path.
2023-11-15 12:27:48 +11:00
Maxime Coste
11f0ace9b6 Make shell-script-candidates completer run in the background
Read output from the script as it comes and update the candidate
list progressively.

Disable updating of the list when a completion has been explicitely
selected.
2023-11-14 21:39:03 +11:00
Maxime Coste
719512b308 Use a separate copy of the command completer for each completion
This make the completer lifetime tied to the Prompt mode and removes
the need for the Start flag. It also makes it possible to cleanup
on completer destruction.
2023-11-14 21:39:03 +11:00
Maxime Coste
79f3f5b046 Merge remote-tracking branch 'krobelus/quote-regex-option-value-completions' 2023-11-14 21:38:26 +11:00
Johannes Altmanninger
cac2a32ba2 Fix completion pager not rendering after <a-semicolon> in prompt
Usually, the prompt resets "m_line_changed" after invoking the
change handler:

	if (m_line_changed)
	{
	    m_callback(m_line_editor.line(), PromptEvent::Change, context());
	    m_line_changed = false;
	}

but with

	prompt '' '' -on-change %{ execute-keys <a-semicolon>vl } -shell-script-candidates %{ seq 100 }

the change handler pushes a normal mode with "<a-semicolon>" and then
hands back control to the event loop. Later when the normal mode is
popped we run "Prompt::on_enabled()" but don't actually redraw the
completion pager.
Since the <a-semicolon> excursion by definition did not change our
prompt state, we don't need to recompute completions, only render them.
Do that.

This helps commands that use preview the selected completion via a
"prompt -on-change" handler.
2023-11-14 10:20:08 +01:00
Johannes Altmanninger
118459db59 Quote completions of regex options
Recent changes to `make_error_pattern` added a space to the default
value. This means that

	set g make_error_pattern <tab>

now produces an invalid command because regexes are not quoted.  We do
quote strings; regexes are not all that different so quote them too.
2023-11-13 23:42:39 +01:00
Johannes Altmanninger
70e96c272e Avoid unnecessary copy of completion candidates 2023-11-13 23:42:39 +01:00
Johannes Altmanninger
746e0d032f rc windowing: allow to configure windowing system and window placement in new/terminal commands
Today I can control "terminal" and "new" by changing the terminal
alias but I always need to choose a concrete implementation, like
"tmux-terminal-horizontal", even when there is otherwise no need to
mention tmux in my config.

Allow to configure windowing system and window placement independently
by introducing dedicated options.

This allows to create mappings that work in any windowing system like

	map global user c   %{:with-option windowing_placement window new<ret>}
	map global user '"' %{:with-option windowing_placement vertical new<ret>}
	map global user '%' %{:with-option windowing_placement horizontal new<ret>}

For windowing systems that don't support all placements, you can wrap
the above in try/catch to fall back on the "window" variant which is
defined for all windowing systems.

When using multiple (nested) windowing systems, you might want to
add mappings like

	map global user t %{:with-option windowing_module tmux new<ret>}
	map global user T %{:with-option windowing_module wayland new<ret>}

---

This changes the default "terminal" alias for some modules. In
particular, instead of delegating to

    iterm-terminal-vertical
    screen-terminal-vertical
    tmux-terminal-horizontal
    wezterm-terminal-vertical

it will now by default delegate to the respective "-window" variant.
We could maintain backwards compatiblity here by setting the
"windowing_placement" option accordingly, but the new behavior seems
more logical?

Also, this removes the "terminal-tab" alias which was only defined
by the kitty module.

We could try to keep the alias approach and implement a "with-alias"
command, however that approach can only capture both dimensions
(windowing system and placement) if we add tons of commands
like "terminal-horizontal" (with implied windowing system) and
"tmux-terminal" (with implied placement).

Side thought: we could also get rid of the "focus" alias and instead
define

    define-command focus %{
        "%opt{windowing_module}-focus"
    }

Closes #3943, #4425
2023-11-13 22:54:49 +01:00
Johannes Altmanninger
e7218ca301 rc windowing: fix docstrings 2023-11-13 22:54:49 +01:00
Johannes Altmanninger
4258f2d7b2 rc windowing sway: add sway-terminal-tab
Not sure about this one, the implementation seems hacky so I'm not
sure if it always does what the user expects.
2023-11-13 22:54:49 +01:00
Johannes Altmanninger
efdc57cef7 rc windowing sway: add sway-terminal-{vertical/horizontal} 2023-11-13 22:54:49 +01:00
Maxime Coste
ed1e2f2e08 Add missing include for std::array 2023-11-13 23:03:03 +11:00
Maxime Coste
fbf387f05c Merge remote-tracking branch 'krobelus/show-grep-errors' 2023-11-13 22:56:10 +11:00
Maxime Coste
c2fb0738d3 Merge remote-tracking branch 'krobelus/fix-noincsearch' 2023-11-13 22:56:06 +11:00
Maxime Coste
c7d887d9d1 Rename stdin/stdout/stderr in Shell a they conflicts with macros
Fixes #5023
2023-11-13 20:19:55 +11:00
Maxime Coste
fc7be678ed Change window_range to emit each element as a separate string 2023-11-13 19:22:33 +11:00
Johannes Altmanninger
f27f6fa2d5 rc git: fix "git blame" on macOS with perl rewrite
macOS awk doesn't have strftime().
2023-11-12 17:28:55 +01:00
Johannes Altmanninger
14b60ab912 rc grep: include stderr in grep buffer
Running an invalid command like "grep -abc" shows no output at all.
Let's give better feedback by showing the error message from grep.
We used to do this until an unrelated change, bd5955c73 (grep: remove
eventual \r, 2013-02-13).
2023-11-12 11:59:11 +01:00
Johannes Altmanninger
c597a056d0 Fix spurious incremental search when incsearch=false
Regressed in a2c41593a (Fix partial regex text being pushed in history,
2023-11-02).
2023-11-11 14:37:32 +01:00
Maxime Coste
2261b48e35 Fix SingleWord handling in RankedMatch
subsequence_match_smart_case does not necessarily find the word,
but we then check for a contiguous match in which case, if the query
is a word, we also have a single word match.
2023-11-11 18:59:11 +11:00
Maxime Coste
c45a1d435a small code cleanup 2023-11-11 18:46:15 +11:00
Maxime Coste
fbbced5ed0 Support building ArrayView from contigous iterators 2023-11-10 16:35:46 +11:00
Maxime Coste
feeacd8de9 Refactor spawn_shell to return the relevant FDs
This removes the need for the setup_child callback which is quite
tricky as it cannot touch any memory due to vfork, and removes the
Pipe abstraction in favor of a more general UniqueFd one.
2023-11-05 22:47:17 +11:00
Maxime Coste
6babba9bfa Merge remote-tracking branch 'stacyharper/git-log-ret' 2023-11-05 13:49:58 +11:00
Maxime Coste
7a130c89ce Merge remote-tracking branch 'jdugan6240/odin-support' 2023-11-05 13:48:57 +11:00
Maxime Coste
25a00bf2a9 Remove ignored packed attribute and static_assert on Node size
This static_assert is not necessary for the code to work and is
not valid on every platform.
2023-11-05 12:38:39 +11:00
Maxime Coste
0880399fbe Replace snprintf with format_to 2023-11-05 12:30:54 +11:00
Maxime Coste
465e0280d8 Merge remote-tracking branch 'Screwtapello/document-non-recursive-mappings' 2023-11-05 11:25:40 +11:00
Maxime Coste
1da8952e1f Merge remote-tracking branch 'lobre/git-edit' 2023-11-05 11:12:43 +11:00
Maxime Coste
cf6e18e3c1 Merge remote-tracking branch 'krobelus/stop-busy-polling-of-command-socket' 2023-11-05 11:11:02 +11:00
Maxime Coste
c0788f370b Merge remote-tracking branch 'krobelus/patch-selected-lines' 2023-11-05 11:09:41 +11:00
Johannes Altmanninger
b0ddbfc2df Do not poll command sockets while shell command is running
Accepter is a wrapper around a socket watcher. It always uses
EventMode::Urgent, so it will be included in pselect(2) (via
EventManager::handle_next_events()) even while we are waiting for a
(blocking) shell command.  However we will not execute the command
received on this socket until after the shell command is done.

This is implemented with an early return:

	void handle_available_input(EventMode mode)
	{
	    while (not m_reader.ready() and fd_readable(sock))
	        m_reader.read_available(sock);

	    if (mode != EventMode::Normal or not m_reader.ready())
	        return;

so we read available data but don't close the socket.
When using this reproducer

	{
		sleep 1 && echo 'nop' | kak -p session
	} &
	kak -n -s session -e '%sh{sleep 7}'

the first "m_reader.read_available(sock);" will read "nop".  Then
"m_reader.ready()" is true but the socket is still readable. This
means that pselect(2) will return it every time, without blocking.

This means that the shell manager runs a hot loop between pselect(2)
and waitpid(2).

Fix this problem demoting command socket watchers from
EventMode::Urgent. This means that we won't pselect(2) it when handling
only urgent events. Control-C still works, I'm not sure why.

Alternative fix: we could read the commands but then disable the
socket. I tried this but it seems too complex.

Closes #5014
2023-11-04 17:48:25 +01:00
Loric Brevet
83b7bbdc55
rc/tools/git: edit a git indexed file with git edit 2023-11-04 13:43:10 +01:00
Johannes Altmanninger
286dab11d4 rc tools git: "git apply" to apply selections in diffs
This adds a somewhat discoverable frontend for common uses of the
patch command.

Here are some frequently used commands

	# apply selected changes
	git apply 
	# revert selected changes
	git apply -R
	# stage selected changes
	git apply --cached
	# unstage selected changes
	git apply --cached -R
	# apply selected changes and stage them
	git apply --index

For everyday use that's a lot of typing so I recommend adding mappings.
2023-11-04 12:14:48 +01:00
Johannes Altmanninger
8c0424b521 rc tools patch: "patch" command to apply selections in diffs to file
One of the features I miss most from Magit/Fugitive/Tig is to
apply/revert/stage/unstage individual hunks or even exactly the
selected line(s).  This provides a much more convenient way of
splitting changes than "git add/restore -p".

Implement a "patch" command that applies the selected lines within
a diff by piping them to the "patch" program.
It can also feed other programs like "git apply" (see the next commit).

Original discussion: https://discuss.kakoune.com/t/atomic-commits-in-kakoune/1446

Interestingly, :patch is defined outside the "patch" module. This is
to make it readily available for interactive use.
Putting it into the module does not save any work.
I tentatively added a patch module anyway so we can explicitly declare
this dependency.. although there is the argument that this is not
really needed?
2023-11-04 12:14:48 +01:00
Maxime Coste
a8a53cc003 Merge remote-tracking branch 'phaazon/custom-diff-char' 2023-11-04 13:58:09 +11:00
Maxime Coste
0924401c50 Merge branch 'patch-1' of https://github.com/tomsaleeba/kakoune 2023-11-04 11:22:24 +11:00
Tom Saleeba
1e8d2dfe9b
remove "introduced..." fragments 2023-11-04 08:30:29 +11:00
Dimitri Sabadie
27f19fdd91
Rename diff_* into git_diff_*. 2023-11-03 22:04:22 +01:00
Dimitri Sabadie
da2cc1ac3c
Revert adding doc about git_diff_*. 2023-11-03 22:04:22 +01:00
Dimitri Sabadie
8e10822a87
Support setting diff characters in git diffs.
This commit adds `diff_add_char`, `diff_mod_char`, `diff_del_char` and `diff_top_char` as `str` options, with typical
defaults.

This commit also replaces the hard coded +, _, ≃, etc. hardcoded characters in `git update-diff` to use the options from
above.
2023-11-03 22:04:22 +01:00
Dimitri Sabadie
9e4dbdbe6c
Dimitri Sabadie 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.
2023-11-03 22:04:22 +01:00
Maxime Coste
6a39ac224b Merge remote-tracking branch 'krobelus/fix-quoted-vals-expand' 2023-11-03 21:51:36 +11:00