1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-08-17 08:40:37 +03:00
Commit Graph

10258 Commits

Author SHA1 Message Date
Colin Yates
f8ad2e3726
Update TRAMPOLINE
added missing word "...which *does* not store anything written..."
2023-12-20 15:47:28 +00:00
Maxime Coste
83fb65aef5 Merge remote-tracking branch 'krobelus/generalize-windowing' 2023-12-12 21:29:31 +11:00
Maxime Coste
533f51c744 Merge remote-tracking branch 'krobelus/prefer-input-order-over-alphabet' 2023-12-12 21:27:31 +11:00
Maxime Coste
96b74d1ad6 Merge remote-tracking branch 'arachsys/hide-unmapped' 2023-12-12 21:24:47 +11:00
Maxime Coste
9cc9374375 Merge remote-tracking branch 'lobre/pl-not-executable' 2023-12-12 21:24:10 +11:00
Maxime Coste
065e0229a9 Fix stray semicolon 2023-12-12 21:23:57 +11:00
Maxime Coste
250ead2b7a Merge remote-tracking branch 'arachsys/c-family-pp' 2023-12-12 21:21:40 +11:00
Maxime Coste
fda67a7b08 Merge remote-tracking branch 'arachsys/mail-highlight' 2023-12-12 21:20:32 +11:00
Maxime Coste
5ed2433b9f Merge remote-tracking branch 'arachsys/unsigned-char' 2023-12-12 21:19:52 +11:00
Chris Webb
86979841b7 Improve c-family highlighting of preprocessor directives
The current handling of preprocessor directives in filetype/c-family.kak
leads to a wall of solid colour for more complicated #if or #define
directives, although #include is already nicely highlighted.

Instead of highlighting an entire directive with the meta face, highlight
just the #define, #if or #elif keyword as meta, treating the rest of the
directive as normal c-family expressions. This significantly improves
the readability of complex macro definitions.

For directives other than #define, #if and #elif, we treat the rest of
the directive as an opaque string in normal face rather than trying to
highlight it, covering cases like #error, #pragma, etc. where the rest
of the line is an error message string or other non-expression content.

This does the right thing for #ifdef and #ifndef too, as we don't highlight
identifiers in c-family text so their arguments should be normal face
anyway.
2023-12-10 13:50:29 +00:00
Chris Webb
8a14fbc15b Highlight inline patches and signatures in mail.kak
We already pull in the diff module in mail.kak to enable the nice
:diff-jump behaviour on inline patches. Also enable the shared/diff/
highlighter underneath our shared/mail/ highlighter for inline diffs,
listing it first so mail patterns take precedence over diff patterns.

De-emphasise signatures including the standard '^-- \n' separator in the
same way as quoted text in a reply.

Fixes: https://github.com/mawww/kakoune/issues/4998
2023-12-10 11:42:32 +00:00
Chris Webb
a8d5b8bd2c Fix compiler warnings when char is unsigned
In several places, we check for a control character with something like

  char c;
  [...]
  if (c >= 0 and c <= 0x1F)
    [...]

When char is signed (e.g. amd64) this is fine, but when char is unsigned
by default (e.g. arm32 and arm64) this generates warnings about the
tautologous check that an unsigned value is non-negative.

Write as

  if ((unsigned char) c <= 0x1F)
    [...]

which is both correct and not suspicious under both conventions.
2023-12-10 11:09:55 +00:00
Chris Webb
7b2772ef89 Change use of deprecated '->' operator on an iterator
In display_buffer.hh, the '->' operator is used on an iterator, but
(surprisingly) this is deprecated from C++20 because of x-value vs
l-value ambiguity. Now clang's -Wdeprecated-declarations warns about it
as we declare -std=c++2a. See

  https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1252r2.pdf

which was adopted for 2019-03.
2023-12-10 10:58:42 +00:00
Chris Webb
ee8c74c724 Add -Wno-stringop-overflow for g++
g++ 13.x is confused by the reinterpret_cast in Kakoune's memory.hh
allocator. Use -Wno-stringop-overflow to silence a large number of
verbose false alarms.
2023-12-10 10:26:37 +00:00
Chris Webb
a90d1d33f7 Mark refresh_ifn() implementation as an override in input_handler.cc
This was spotted by clang's -Winconsistent-missing-override in -Wall.
2023-12-10 09:58:40 +00:00
Chris Webb
7af2b99317 Hide empty and undocumented mappings from autoinfo
Users who rebind default keys and unmap the originals by binding them
to empty strings with empty docstrings end up with empty lines in the
autoinfo. For example, https://github.com/mawww/kakoune/issues/4918.

Hide completely null bindings which have both an empty mapping and an
empty docstring in the autoinfo, as an easy mechanism for these users to
eliminate the UI noise.

Fixes https://github.com/mawww/kakoune/issues/4918
2023-12-06 17:35:46 +00:00
Loric Brevet
a362c8a145
Perl files are not always executable 2023-12-04 14:19:15 +01:00
Maxime Coste
7f49395cf9 Fix basename prefix flag to use smartcase eq 2023-12-04 19:22:32 +11:00
Johannes Altmanninger
658c3385a9 ranked match: prefer input order over alphabetical order for user-specified completions
When using either of

	set-option g completers option=my_option
	prompt -shell-script-candidates ...

While the search text is empty, the completions will be sorted
alphabetically.
This is bad because it means the most important entries are not listed
first, making them harder to select or even spot.

Let's apply input order before resorting to sorting alphabetically.

In theory there is a more elegant solution: sort candidates (except
if they're user input) before passing them to RankedMatch, and then
always use stable sort. However that doesn't work because we use a
heap which doesn't support stable sort.

Closes #1709, #4813
2023-12-02 10:43:59 +01:00
Johannes Altmanninger
d6215dc25d Reuse for_n_best when sorting values from complete options
While at it, remove a needless reserve() call and reserve an extra slot
because "InsertCompleter::try_complete" might add one more element.
2023-12-02 09:57:15 +01:00
Maxime Coste
84ecd41da1 Merge remote-tracking branch 'herrhotzenplotz/feat/hg-highlight-keywords' 2023-12-02 11:05:27 +11:00
Maxime Coste
94d58b2e07 Merge remote-tracking branch 'sidkshatriya/escape-curly-bracket' 2023-12-02 11:03:56 +11:00
Maxime Coste
c93c57a46f Merge remote-tracking branch 'krobelus/fuzzy-menu' 2023-12-02 10:56:29 +11:00
Maxime Coste
42fefb16af Merge remote-tracking branch 'arachsys/write-replace' 2023-12-02 10:56:11 +11:00
Maxime Coste
8e2eacae83 Merge remote-tracking branch 'krobelus/fix-git-blame' 2023-12-02 10:48:49 +11:00
Maxime Coste
215aa0b2fb Fix single word detection when query is not single word 2023-12-02 10:39:23 +11:00
Maxime Coste
5b1da70adc Merge remote-tracking branch 'm-kru/troff' 2023-12-02 10:08:16 +11:00
Chris Webb
3ba3399f94 Set replacement file permissions before moving into place
When doing :write -method replace, make sure we've set the correct mode,
uid and gid on the replacement file before attempting to rename it on
top of the original. This means that the original file is left in place
with correct permissions if anything fails, rather than ending up with
0700 permissions from mkstemp().
2023-11-28 08:51:32 +00:00
Chris Webb
d3af9b57d4 Restore file ownership when editing with root privilege
When a privileged :write is used with -method replace, it silently resets
the ownership of files to root:root. Restore the original owner and group
in the same way we restore the original permissions. Ownership needs to
be restored before permissions to avoid setuid and setgid bits being set
while the file is still owned by root, and to avoid them being subsequently
lost again on chmod(2).
2023-11-26 18:12:52 +00:00
Chris Webb
05bbdb27c9 Fix crash when ':write -method replace' fails to create tempfile
If a user attempts to save a file without write permission for the
containing directory, with writemethod set as 'replace' or an explicit
':write -method replace' command, kak crashes with "terminating due to
uncaught exception of type Kakoune:runtime_error". (Note this doesn't
happen with a forced write, which fails earlier when it tries to enable
u+w permission.)

Don't raise another exception when already bailing out with a runtime
error for failing to create a temporary file or open the existing file.
Instead, make a best-efforts attempt to restore the file permissions
before raising the first exception, and only report the runtime chmod
exception if that step fails on the non-error path.
2023-11-26 17:50:32 +00:00
Michał Kruszewski
7910aff11d troff: Highlight .pdfhref and links 2023-11-25 19:45:20 +01:00
Chris Webb
32680e5d65 Skip output synchronization query when explicitly disabled
Some terminals misbehave when queried for output synchronization support,
such as Windows Terminal as reported in

  https://github.com/mawww/kakoune/issues/5032

The relatively long response from a terminal which does support output-sync
is also prone to getting torn over a slow link such as a serial console,
causing stray input to the editor.

In ui_options, the terminal_synchronized option controls the use of this
feature, but unfortunately the query is unconditionally sent at startup
even when this is set false.

Skip the query at startup when terminal_synchronized is explicitly false.

We query at most once per terminal in set_ui_options so the behaviour
is correct both when kakoune is started with terminal_synchronized unset
and when it is started with terminal_synchronized set false but this is
later unset.
2023-11-24 12:55:45 +00:00
Maxime Coste
990e92a5f3 Only set Prefix in RankedMatch if the full query matches 2023-11-23 17:16:24 +11:00
Maxime Coste
cad2f6fb66 Bump cirrus llvm to 13 in order to fix OSX builds
Debian stable is on llvm 14 so should be fine.
2023-11-21 21:05:56 +11:00
Maxime Coste
ac7b498c86 Merge remote-tracking branch 'krobelus/changelog' 2023-11-21 21:04:18 +11:00
Maxime Coste
5e4e23289b Fix completion menu not getting hidden on no matches 2023-11-21 17:16:38 +11:00
Johannes Altmanninger
d1037072b0 rc tools menu: add -on-abort switch
Along -select-cmds this is useful to implement preview functionality.
2023-11-20 20:47:22 +01:00
Johannes Altmanninger
1f11529837 rc tools menu: replace menu builtin with a prompt-based implementation
prompt has fuzzy filtering which is more discoverable than the menu
mode's regex filtering (because that one needs / to trigger it).
There are no important differences left, so replace the menu builtin
with a prompt-based command.

prompt does not support markup in the completion menu, so drop that
feature for now.
2023-11-20 20:47:22 +01:00
Johannes Altmanninger
4499b26ca4 Fix use after move in HashMap::insert
Apparently GCC builds worked fine but Clang builds started failing the
"(hash == hash_value(item_key(item)))" assertion.
2023-11-18 19:07:23 +01:00
Johannes Altmanninger
0bb5b28f7e Update changelog 2023-11-17 19:41:55 +01:00
Maxime Coste
296ab1a1ff Improve WordDB performance by precomputing hashes
Avoid multiple computation of string hashes by making it possible
to pre-compute and pass hashes to interned strings and hash maps.
2023-11-17 17:01:51 +11:00
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