1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-09-21 09:59:08 +03:00
Commit Graph

9715 Commits

Author SHA1 Message Date
Maxime Coste
9fb7d90449 Change HashMap not to support multiple identical keys by default
We do not seem to have any uses for this remaining, and this is
better opt-in with MultiHashMap
2022-08-05 19:20:00 +10:00
Maxime Coste
31e9fc3cef Merge remote-tracking branch 'krobelus/history-in-mappings' 2022-08-03 20:37:44 +10:00
Maxime Coste
fa209a9a97 Merge remote-tracking branch 'krobelus/document-history-registers' 2022-08-03 19:51:22 +10:00
Maxime Coste
4361a7e120 Merge remote-tracking branch 'krobelus/no-switches-after-ddash' 2022-08-03 19:50:00 +10:00
Johannes Altmanninger
e13b435783 Do not complete command switches after --
Recently, switch completion were given the menu behavior.
Unfortunately this breaks cases like

	:echo -- -mark<ret>

where the hypothetical user wanted to actually display "-mark", not
"-markup".

Simply bail if there is a double-dash. This is not fully correct,
for example it wrongly disables switch completion on

	echo -to-file -- -

but that's minor, we can fix it later.

In future, we should reuse the ParametersParser when computing completions,
which will obsolete this workaround.
2022-08-01 12:34:22 +02:00
Johannes Altmanninger
c335712e4e doc registers: document prompt history registers
So far they have only been talked about in source code
(HistoryRegister), not in documentation.

Let's give them an official name so users can find them better;
"prompt history register" seems better than "history register" since
the former gives more context. OTOH, in future other registers (like @)
could grow into history registers, so I'm not sure.

State that the history registers are only changed by _interactive_
prompts; that's not quite true yet for user modes but I'll push a
separate fix for that.
2022-08-01 10:15:52 +02:00
Johannes Altmanninger
395f438378 Remove unnecessary leading space in prompt from mappings
We often use the pattern «map global normal ": foo"».  The space
after the colon is unnecessary since execution of the mapping won't
add to history anyway, since 217dd6a1d (Disable history when executing
maps, 2015-11-10).
With the parent commit, the space is no longer necessary for user
mappings, so there is no reason to continue the cargo-cult.

Remove the space from mappings to set a good example.
2022-08-01 07:37:02 +02:00
Johannes Altmanninger
a36473f4bb Do not record prompt history when executing user mode mappings
Commit 217dd6a1d (Disable history when executing maps, 2015-11-10)
made it so with

	map global normal X %{:echo 123<ret>}

X does not add to prompt history (%reg{:}).

Unfortunately this behavior was not extended to mappings in the "user"
keymap, nor to mappings in custom user modes.
In my experience, not adding to history is almost always the expected
behavior for mappings. Most users achieve this by adding a leading space:

	map global user X %{: echo 123<ret>}

but that's awkward. We should have good defaults (no nnoremap)
and map should work the same way across all modes.

Fix this by also disabling history when executing user mappings. This
is a breaking change but I think it only breaks hypothetical scenarios.

I found some uses where user mappings add to history but none of them
looks intentional.

f702a641d1/.config/kak/kakrc (L169)
604ef1c1c2/kakrc (L96)
d22e7d6f68/kak/kakrc (L71)
https://grep.app/search?q=map%20%28global%7Cbuffer%7Cwindow%29%20user%20.%2A%5B%21%3A/%5D%5B%5E%20%5D.%2A%3Cret%3E&regexp=true
2022-08-01 07:37:02 +02:00
Johannes Altmanninger
253b13281e Show the default values for -save-regs in autoinfo of exec/eval
They are documented in ":doc execeval" but it seems like a good idea
to make this info more prominent.
2022-08-01 07:15:08 +02:00
Johannes Altmanninger
d999a00b0c Fix typo in eval/exec code
Will touch similar code
2022-08-01 07:15:08 +02:00
Johannes Altmanninger
f435b2b70a doc execeval: mention that the colon register is saved by default 2022-08-01 07:15:08 +02:00
Johannes Altmanninger
487056daf7 doc registers: fix asciidoc syntax for <a-*>
GitHub renders this as

	*, <a->*, s

while :doc renders it as

	*, <a->, *s

with this fix it's

	*, <a-*>, s
2022-07-30 22:18:37 +02:00
Johannes Altmanninger
545c8429e0 doc keys: avoid pleonasm 2022-07-30 22:18:37 +02:00
Maxime Coste
e83dbdcd2c Merge remote-tracking branch 'krobelus/embrace-menu-2' 2022-07-28 21:34:31 +10:00
Maxime Coste
79ff3c29e5 Merge remote-tracking branch 'krobelus/support-prompt-menu' 2022-07-28 21:33:07 +10:00
Maxime Coste
99874a1e25 Merge remote-tracking branch 'krobelus/prompt-completion-cut-at-cursor' 2022-07-28 21:29:21 +10:00
Maxime Coste
ab20fa9360 Merge remote-tracking branch 'krobelus/tmux-repl-completion' 2022-07-28 21:23:30 +10:00
Maxime Coste
935261c8be Merge remote-tracking branch 'krobelus/support-shift-backspace' 2022-07-28 21:23:03 +10:00
Maxime Coste
5fb858d0c5 Merge remote-tracking branch 'jeroendehaas/iterm-fix-spaces' 2022-07-28 21:21:04 +10:00
Maxime Coste
f137ee6595 Merge remote-tracking branch 'Pound-Hash/docs_faces' 2022-07-28 21:19:52 +10:00
Maxime Coste
de683fea3b Merge remote-tracking branch 'Pound-Hash/execeval' 2022-07-28 21:18:39 +10:00
Pound_Hash
12c2b53105 Made changes suggested by krobelus 2022-07-26 13:42:28 -07:00
Maxime Coste
08f5bc3959 Merge remote-tracking branch 'krobelus/startup-info' 2022-07-24 10:12:58 +10:00
Maxime Coste
b2bdaf8288 Merge remote-tracking branch 'krobelus/complete-expansions-in-double-quotes' 2022-07-24 10:12:22 +10:00
Maxime Coste
626e1fec43 Merge remote-tracking branch 'krobelus/no-redundant-menu' 2022-07-24 10:10:51 +10:00
Johannes Altmanninger
6e4b0d8859 Support "prompt -menu" to mark completions as authoritative
This gives the "prompt" command the same "-menu" switch as
"complete-command" and "define-command". I don't think anyone has
asked for it but it seems like a good idea?
2022-07-22 21:14:23 +02:00
Johannes Altmanninger
aa8f29eff1 Extract function for parsing completion switches
Both "define-command" and "prompt" use the same logic, so share
it. This will make it easy to implement "prompt -menu".

This reveals a problem with PromptCompleterAdapter: when converting
it to std::function and then to bool, it always evaluates to true
because it has an operator().  However, it should evaluate to false
if the adaptee holds no valid function (e.g. is a default-constructed
std::function). Otherwise we try to call a non-existant function. Tweak
PromptCompleterAdapter to work for empty inputs.
2022-07-22 21:06:33 +02:00
Johannes Altmanninger
47329260da Move input completer when constructing PromptCompleterAdapter
I think we usually do this when passing completers.
2022-07-22 20:56:20 +02:00
Johannes Altmanninger
3e9ca0e5c3 rc windowing: use menu behavior for focus
We can complete every possible client argument.
2022-07-21 16:48:44 +02:00
Johannes Altmanninger
19fccc1587 Compute prompt completion only from characters left of the cursor
If I type

	:echo -mx

I get no completions, even when I move the cursor on the x.
If I replace the x  with a k, I get a completion "-markup".
The odd thing is that if I accept the completion while the cursor is
on the k, then the commandline will be

	:echo markupk

Evidently, the characters under cursor (x/k) influence the completion
(actually all letters right of the cursor do), but they are not
incorporated in the final result, which is weird.

I think there are two consistent behaviors:
1. Compute completions only from characters left of the cursor. We already
   do this in insert mode completion, and when completing the command name
   in a prompt.
2. Compute completions from the whole token, and when accepting a completion,
   replace the whole token.

Most readline-style completion systems out there implement 1. A
notable exception is fish's tab-completion. I think we should stick
to 1 because it's more predictable and familiar. Do that.

This allows us to get rid of a special case for completing command
names, because the new behavior subsumes it.

In fact, I think this would allow us to get rid of most "pos_in_token"
or "cursor_pos" completer parameters. I believe the only place where we
it's actually different from the end of the query is in "shell-script"
completers, where we expose "$kak_pos_in_token". I think we can still
remove that parameter and just cut the commandline at the cursor
position before passing it to a "shell-script" completer. Then we
also don't need "$kak_token_to_complete" (but we can still keep
expose them for backwards compatibility).
2022-07-21 16:48:44 +02:00
Johannes Altmanninger
9190fa9b5f rc repl: complete tmux-repl with shell commands, not Kakoune commands 2022-07-21 16:48:44 +02:00
Johannes Altmanninger
19d2de41c0 Update startup info with p/P breaking change 2022-07-21 16:48:44 +02:00
Johannes Altmanninger
59dd3eaf15 Complete double-quoted expansions in prompt mode
This adds completions for

	:echo "%val{
2022-07-21 16:48:44 +02:00
Johannes Altmanninger
34c489170f Elide temporary vector when completing register names
Just like in the parent commit, this requires us to use a non-owning
type. Technically, these strings all benefit from SSO, so there is
no lifetime issue, but we can't deduce that from the types.
I guess we could use InplaceString just as well.
2022-07-21 16:48:44 +02:00
Johannes Altmanninger
7f08ac3de2 Use menu behavior for add-highlighter/remove-highlighter completion
This means that typing

	:add-highlighter g c 80

results in

	:add-highlighter global/ column 80

Paths for add-highlighter do not get the menu behavior because we
want to be able to type "global/foo" even if "global/foobar" exists.
2022-07-21 16:48:44 +02:00
Johannes Altmanninger
b2f45a29e4 Elide temporary vector when completing keymap modes (user modes)
complete() merely iterates over its input, so we can pass it a range
instead of a vector.  For some reason, this requires specifying the
type of the static array, or else its elements become String which
triggers this assertion:

    static_assert(not std::is_same<decltype(*begin(container)), String>::value,
                  "complete require long lived strings, not temporaries");

Specify the type with an explicit Array<StringView, 8>. This is
pretty ugly but the alternative of appending "_sv" to every single
array element seems worse?

If we modify the vector of user modes while complete() is iterating
over, we could crash -- but that scenario is impossible since both
only happen inside the single-threaded server process.
2022-07-21 16:48:44 +02:00
Johannes Altmanninger
8fac31ba76 Use menu behavior for completion of switches
We already use the menu behavior in complete_command_name(); let's do
the same for switches, since we can complete all valid inputs and
it can save a Tab key in some scenarios.

CommandManager::complete is fairly complex. We can't expect callers
to add the menu bit when appropriate, so we currently do it here.
2022-07-21 16:48:44 +02:00
Johannes Altmanninger
ba557e90a2 Offer "--" as completion when completing switches
The next commit will give switch completions the menu behavior, so this
is necessary so we can still type "echo --" without an auto-expansion
to "echo -to-file".
2022-07-21 16:48:44 +02:00
Johannes Altmanninger
1358fc3cef Deduplicate functions for completing alias names
"complete_alias_name" is a better name then "complete_alias" because
it's consistent with more similar names, which are:

	complete_client_name
	complete_command_name
	complete_module_name
	complete_option_name
	complete_register_name
	complete_scope
	complete_face
2022-07-21 16:48:44 +02:00
Johannes Altmanninger
57a98880ab Make completers take "StringView" instead of "const String&" for compatibility with PromptCompleter
We define

	using PromptCompleter = std::function<Completions (const Context&, CompletionFlags,
	                                                   StringView, ByteCount)>;

Some command completers are *almost* convertible to PromptCompleter;
the only difference is the string type of the prefix argument.
The later commits in this series want to use menu() on the
completers. Enable this by harmonizing the types.
2022-07-21 16:48:44 +02:00
Johannes Altmanninger
a4696eb33a Remove redundant check for menu bit
can_auto_insert_completion already requires the menu bit.
2022-07-21 16:43:54 +02:00
Maxime Coste
559af669c7 Remove out-of-date column computation in show-whitespaces
Now that we compute display buffer on whole lines, it does not make
sense to compute the tab padding based off the window column position

Fixes #4674
2022-07-19 22:47:39 +10:00
Maxime Coste
9ebd0cd9c1 Improve readability of debug memory command output
Group memory usage digits with commas to make it easier to
read those numbers.
2022-07-18 17:39:19 +10:00
Jeroen de Haas
67d9dd3043 Jeroen de Haas 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. 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-07-16 16:07:42 +02:00
Jeroen de Haas
5a1b0ac2cb Also escape path and tmpdir in iterm.kak
This fixes an issue with where paths containing spaces would
break iterm support
2022-07-16 16:07:42 +02:00
Pound_Hash
9364796033 [faces.asciidoc] Amended English mechanics and styling for correctness
and clarity.
2022-07-15 19:12:57 -07:00
Alan
f5763aaeff
Update doc/pages/execeval.asciidoc
Co-authored-by: Screwtapello <thristian@gmail.com>
2022-07-13 23:22:55 -07:00
Pound_Hash
0bbab694be Amended the documentation for grammatical correctness, neatness, uniformity,
and clarity.
2022-07-13 19:41:42 -07:00
Maxime Coste
c7fbf1f390 Re-work line trimming to fix issues with column highighters
Instead of triming only buffer ranges, add a trim_from method to
display line to keep the initial N columns, we know how many columns
are used by non-trimable widgets in DisplaySetup::widget_columns so
we can just pass this.

Also restore the previous logic for face merging

Fixes #4670
2022-07-13 12:24:14 +10:00
Maxime Coste
195fe8fd29 Fix past-the-eol column highlighter getting highlighted as buffer range
Make the column highlighter faces final, and change final logic to
give precedence to the base face when both the base and new face are
final.

Fixes #4669
2022-07-12 21:11:53 +10:00