Commit Graph

10124 Commits

Author SHA1 Message Date
Tim Allen
1b8381461d command-parsing: You *cannot* escape the delimiters of balanced strings.
Originally the page said:

> No other escaping takes place in balanced strings.

...but in the course of a general readability rewrite (56287da) this was
changed to:

> Characters may be escaped in the same manner as those for quoted strings.

...which is not actually true; probably this change made it in because there
were a lot of good changes in those commits and we didn't read them all closely
enough.

Now the documentation is correct again, and I've added some examples covering
the problems people occasionally ask about (see #2760).
2022-10-20 23:11:20 +11:00
Tim Allen
7b095a6465 command-parsing: Link to Balanced Strings when we mention that section. 2022-10-20 23:02:25 +11:00
Maxime Coste
cb33918fa2 Merge remote-tracking branch 'eraserhd/codeowners' 2022-10-19 20:39:11 +11:00
Maxime Coste
b42cb090ee Merge remote-tracking branch 'krobelus/fix-man-jump' 2022-10-19 20:37:19 +11:00
Maxime Coste
e43c7d6aba Use complete-command for the :doc command 2022-10-19 20:35:05 +11:00
Maxime Coste
d1bfc5ecdc Shell-highlight complete-command shell completion parameters 2022-10-19 20:34:35 +11:00
Maxime Coste
875668f1c2 Add regression test for #4750 2022-10-19 20:33:22 +11:00
Maxime Coste
65f4bf78e9 Merge remote-tracking branch 'krobelus/file-completion' 2022-10-19 20:23:39 +11:00
Maxime Coste
2cbcdf2fb4 Merge remote-tracking branch 'krobelus/write-autoinfo2' 2022-10-19 20:23:18 +11:00
Maxime Coste
5de90920d4 Merge remote-tracking branch 'krobelus/modeline-readonly-fix' 2022-10-19 20:22:25 +11:00
Maxime Coste
39fe2438f7 Merge remote-tracking branch 'krobelus/url-at-word-boundary' 2022-10-19 20:20:47 +11:00
Maxime Coste
e8eb1c8732 Merge branch 'typescript-filetype' of http://github.com/clarfonthey/kakoune 2022-10-19 20:20:07 +11:00
Maxime Coste
aa77078a2e Merge remote-tracking branch 'krobelus/select-make-buffer-at-last' 2022-10-19 20:19:03 +11:00
Maxime Coste
2dea0dfcb9 Merge remote-tracking branch 'krobelus/readme-updates' 2022-10-19 20:18:29 +11:00
Maxime Coste
bd23dbda00 Merge branch 'patch-4' of https://github.com/blaggacao/kakoune 2022-10-19 20:17:28 +11:00
Maxime Coste
ae6ee02cb2 Refactor insert_output command to avoid intermediate vector
This is like a paste with a different source, so the same logic
should work. This means we now correctly fix overflowing selections.

Fixes #4750
2022-10-19 20:16:09 +11:00
Maxime Coste
d1ac4dbff3 Remove unused History MemoryDomain 2022-10-19 20:16:09 +11:00
Johannes Altmanninger
62bd1af3f0 rc modeline: fix error trying to write readonly global variable
When running modeline-parse on this file:

	# kakoune: filetype=ledger:indentwidth=4

I get this error from dash (and a similar one from bash):

	sh: 53: readonly: key: is read only

This is because the readonly variable "key" is used elsewhere, both
times as global. Fix this by making both variables local. While
at it, remove an unused variable.

Fixes #4478
2022-10-17 19:23:30 +02:00
Maxime Coste
287217b987 Fix splitting of display atoms accross multi-columns codepoint
Honor the split request by inserting an empty atom to make sure
client code can assume splitting does replace one atom with two

Fixes #4753
2022-10-17 17:48:39 +11:00
ltdk
ab8b02720b Treat .cts and .mts as typescript 2022-10-16 20:23:05 -04:00
Johannes Altmanninger
daabb5da4e rc make: make-next-error to switch toolsclient to *make* buffer
This is equivalent to a change to grep.kak in 649e252f7 (bring *grep*
buffer to front in context of toolsclient, 2020-08-14).

If a toolsclient is set, make-next-error (and make-previous-error) will
jump to %opt{make_current_error_line}. This is wrong if the toolsclient
does not show the *make* buffer. In that case make_current_error_line
is undefined and we end up showing the goto menu. This has occasionally
been annoying me for a long time but I never bothered investigating.

Fix this by switching to the *make* buffer. The potential downside
is if make-next-error is run from the toolsclient, where we no longer
jump to the error but that's fine because we can use <ret>.

We can maybe improve this later by extending the logic, see
https://github.com/mawww/kakoune/pull/3656#pullrequestreview-472052285
2022-10-16 20:00:22 +02:00
Johannes Altmanninger
4f15f4179c README: clarify that change commands work on each selection
I think "current selection" could be misinterpreted as "main
selection", so let's use "each selection".
2022-10-16 20:00:22 +02:00
Johannes Altmanninger
4b3749c492 README: don't emphasize that <a-p> selects because now p does too
Note that these sentences talk about the "current" selection but
actually mean "each" selection. The next commit will change this.
2022-10-16 19:57:39 +02:00
Johannes Altmanninger
91c43c0f67 Allow to put switches after :write's positional argument
After a failed

	:write file-that-already-exists

a user might want to type ":<up> -f<ret>" to force-overwrite.
This doesn't work because :write's switches must precede the filename.
It's dual :edit does not have this restriction.

Some commands require switches to precede positional arguments for a
good reason; for example because positional arguments might start with
"-" (like ":echo 1 - 1").

There seems to be no reason for the :write restriction, so remove
it. Same for :enter-user-mode.

Thanks to alexherbo2 for reporting.
2022-10-16 19:49:43 +02:00
Johannes Altmanninger
f7c3faa2e1 rc markdown taskpaper: require bare URL to start at word boundary
I can't think of a case where a URL would not start at a word boundary.
Let's add that to the regex. In addition to correctness, this also
slightly improves performance because matching can stop earlier.

	$ HOME=$PWD hyperfine -w 1 'git checkout HEAD'{~,}' -- :/rc/filetype/markdown.kak && ./kak.opt big_markdown.md -e "hook global NormalIdle .* quit" -ui dummy'
	Benchmark 1: git checkout HEAD~ -- :/rc/filetype/markdown.kak && ./kak.opt big_markdown.md -e "hook global NormalIdle .* quit" -ui dummy
	  Time (mean ± σ):      1.123 s ±  0.022 s    [User: 1.100 s, System: 0.027 s]
	  Range (min … max):    1.093 s …  1.174 s    10 runs
	 
	Benchmark 2: git checkout HEAD -- :/rc/filetype/markdown.kak && ./kak.opt big_markdown.md -e "hook global NormalIdle .* quit" -ui dummy
	  Time (mean ± σ):      1.019 s ±  0.026 s    [User: 1.001 s, System: 0.021 s]
	  Range (min … max):    0.984 s …  1.051 s    10 runs
	 
	Summary
	  'git checkout HEAD -- :/rc/filetype/markdown.kak && ./kak.opt big_markdown.md -e "hook global NormalIdle .* quit" -ui dummy' ran
	    1.10 ± 0.04 times faster than 'git checkout HEAD~ -- :/rc/filetype/markdown.kak && ./kak.opt big_markdown.md -e "hook global NormalIdle .* quit" -ui dummy'
2022-10-16 19:49:43 +02:00
Johannes Altmanninger
5822e7e9f2 README: fix typos 2022-10-16 19:49:43 +02:00
Johannes Altmanninger
79b2218754 rc detection editorconfig: use file completions for editorconfig-load 2022-10-16 09:57:46 +02:00
Maxime Coste
360a6847be Merge remote-tracking branch 'vsyl/c_description' 2022-10-11 20:39:10 +11:00
Maxime Coste
32e5b0bd31 Merge remote-tracking branch 'Frojdholm/fix-clang12-debug-compilation' 2022-10-11 20:37:48 +11:00
Jakub Wasilewski
69f4d1261b Correct and unify descriptions of normal mode C key behavior
Fixes #4747
2022-10-11 08:39:34 +02:00
Caleb Heuer
10a90ad631 Fix slicing operator not being highlighted 2022-10-10 23:47:22 -06:00
Caleb Heuer
ca8cab0439 Fix function highlighting with numbers 2022-10-09 01:19:21 -06:00
Caleb Heuer
b0ac6c8eb4 Improve Hare syntax highlighting 2022-10-07 00:29:21 -06:00
Caleb Heuer
ead10d2f79 Caleb Heuer 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-10-07 00:16:11 -06:00
Jakub Wasilewski
62b2c0702c Jakub Wasilewski 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-10-06 14:24:02 +02:00
Hampus Fröjdholm
18a84c6b3c Fix compilation failure with clang 12 and debug=yes
The pointer type alias was missing from FlattenedView::Iterator causing
std::iterator_traits to be an empty class.
2022-10-02 14:04:07 +02:00
Maxime Coste
24d6072353 Merge remote-tracking branch 'krobelus/faster-update-matches' 2022-09-17 20:16:14 +02:00
Johannes Altmanninger
803873c91c Fix quadratic runtime when updating region highlighter matches
Running %sYeti<ret>casdf on file
[example.journal.txt](https://github.com/mawww/kakoune/issues/4685#issuecomment-1193243588)
can cause noticeable lag.  This is because we insert text at 6000
selections, which means we need to update highlighters in those lines.
The runtime for updating range highlighters is quadratic in the
number of selections: for each selection, we call on_new_range(),
which calls add_matches(), which calls std::rotate(), which needs
needs linear time.

Fix the quadratic runtime by calling std::inplace_merge() once instead
of repeatedly calling std::rotate().  This is works because ranges
are already sorted.

I used this script to benchmark the improvements.
(In hindsight I could have just used "-ui json" instead of tmux).

	#!/bin/sh
	set -ex
	N=${1:-100}
	kak=${2:-./kak.opt}
	for i in $(seq "$N")
	do
		echo -n "\
	2022-02-06 * Earth
	    expense:electronics:audio    116.7 USD
	    liability:card              -116.7 USD

	2022-02-06 * Blue Yeti USB Microphone
	    expense:electronics:audio    116.7 USD
	    liability:card              -116.7 USD

	"
	done > big-journal.ledger
	echo > .empty-tmux.conf 'set -sg escape-time 5'
	test_tmux() {
		tmux -S .tmux-socket -f .empty-tmux.conf "$@"
	}
	test_tmux new-session -d "$kak" big-journal.ledger
	test_tmux send-keys '%sYeti' Enter c 1234567890
	sleep .2
	test_tmux send-keys Escape
	while ! test_tmux capture-pane -p | grep 123
	do
		sleep .1
	done
	test_tmux send-keys ':wq' Enter
	while test_tmux ls
	do
		sleep .1
	done
	rm -f .tmux-socket .empty-tmux.conf

This script's runtime used to grow super-linearly but now it grows
linearly:

	         kak.old  kak.new
	N=10000    1.142    0.897
	N=20000    2.879    1.400

Detailed results:

	$ hyperfine -w 1 './bench.sh 10000 ./kak.opt.'{old,new}
	Benchmark 1: ./bench.sh 10000 ./kak.opt.old
	  Time (mean ± σ):      1.142 s ±  0.072 s    [User: 0.252 s, System: 0.059 s]
	  Range (min … max):    1.060 s …  1.242 s    10 runs

	Benchmark 2: ./bench.sh 10000 ./kak.opt.new
	  Time (mean ± σ):     897.2 ms ±  19.3 ms    [User: 241.6 ms, System: 57.4 ms]
	  Range (min … max):   853.9 ms … 923.6 ms    10 runs

	Summary
	  './bench.sh 10000 ./kak.opt.new' ran
	    1.27 ± 0.09 times faster than './bench.sh 10000 ./kak.opt.old'
	$ hyperfine -w 1 './bench.sh 20000 ./kak.opt.'{old,new}
	Benchmark 1: ./bench.sh 20000 ./kak.opt.old
	  Time (mean ± σ):      2.879 s ±  0.065 s    [User: 0.553 s, System: 0.126 s]
	  Range (min … max):    2.768 s …  2.963 s    10 runs

	Benchmark 2: ./bench.sh 20000 ./kak.opt.new
	  Time (mean ± σ):      1.400 s ±  0.018 s    [User: 0.428 s, System: 0.083 s]
	  Range (min … max):    1.374 s …  1.429 s    10 runs

	Summary
	  './bench.sh 20000 ./kak.opt.new' ran
	    2.06 ± 0.05 times faster than '../repro.sh 20000 ./kak.opt.old'
2022-09-17 06:44:57 -05:00
Johannes Altmanninger
a33ec8dc80 Avoid potentially quadratic runtime when updating selections after modification
LineRangeSet::add_range() calls Vector::erase() in a loop over the
same vector. This could cause performance problems when there are many
selections. Fix this by only calling Vector::erase() once.  I didn't
measure anything because my benchmark is dominated by another issue
(see next commit).

LineRangeSet::remove_range() also has a suspicious call to erase()
but that one is only used in test code, so it doesn't matter.
2022-09-17 06:44:57 -05:00
Maxime Coste
be5547ffd0 Merge remote-tracking branch 'arrufat/fix-crash-menu-small-window' 2022-09-17 12:02:33 +02:00
Adrià Arrufat
f50ee5bb5a Fix crash when trying to display the menu in a tiny window 2022-09-17 00:51:34 +09:00
Maxime Coste
8f7b1df9ab Merge remote-tracking branch 'krobelus/generic-language-highlighting' 2022-09-15 13:21:25 +02:00
Adrià Arrufat
f3126df641 Adrià Arrufat 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-09-11 00:19:52 +09:00
kjduncan
674053935d rc:filetype:kotlin.kak add-highlighter fun_tests prohibited tokens added :/ with face attributes changed to +iuf 2022-09-10 10:20:27 +02:00
Johannes Altmanninger
9fc62609b1 rc restructuredtext: only add language highlighters for actual code blocks in buffer
Analogous to markdown.kak.
2022-09-10 07:35:29 +02:00
Johannes Altmanninger
907ad84f46 rc markdown: only add language highlighters for actual code blocks in buffer
There have been proposals to add more language aliases to markdown.kak
(#4592) and allow users to add their own aliases (#4489).

To recap: various markdown implementations allow specifying aliases
for languages. For example, here is a code block that should be
highlighted as filetype "haskell" but isn't:

	```hs
	-- highlight as haskell
	```

There are lots of aliases out in the wild - "pygmentize -L" lists
some but I don't think there is a canonical list.

Today we have a hardcoded list of supported filetypes. This is hard
to mainta, extend, and it can impact performance.
This patch simply attempts to load the module "hs" and the shared
highlighter "hs". This means that users can use this (obvious?) snippet
to add their own aliases:

	provide-module hs %{
		require-module haskell
		add-highlighter shared/hs ref haskell
	}

Untrusted Markdown files can load arbitrary modules, but that was
already true before, and modules are assumed to be trusted anyway.

Since language highlighters are now loaded *after* the generic
code-block highlighter, we need to make sure the language highlighters
take precedence. Do this by making them sub-regions of the generic one.

Closes #4489

This improves performance on the [5MB Markdown
file](https://github.com/mawww/kakoune/issues/4685#issuecomment-1208129806).

	$ HOME=$PWD hyperfine -w 1 'git checkout HEAD'{~,}' -- :/rc/filetype/markdown.kak && ./kak.opt big_markdown.md -e "hook global NormalIdle .* quit" -ui dummy'
	Benchmark 1: git checkout HEAD~ -- :/rc/filetype/markdown.kak && ./kak.opt big_markdown.md -e "hook global NormalIdle .* quit" -ui dummy
	  Time (mean ± σ):      3.225 s ±  0.074 s    [User: 3.199 s, System: 0.027 s]
	  Range (min … max):    3.099 s …  3.362 s    10 runs
	 
	Benchmark 2: git checkout HEAD -- :/rc/filetype/markdown.kak && ./kak.opt big_markdown.md -e "hook global NormalIdle .* quit" -ui dummy
	  Time (mean ± σ):      1.181 s ±  0.030 s    [User: 1.162 s, System: 0.021 s]
	  Range (min … max):    1.149 s …  1.234 s    10 runs
	 
	Summary
	  'git checkout HEAD -- :/rc/filetype/markdown.kak && ./kak.opt big_markdown.md -e "hook global NormalIdle .* quit" -ui dummy' ran
	    2.73 ± 0.09 times faster than 'git checkout HEAD~ -- :/rc/filetype/markdown.kak && ./kak.opt big_markdown.md -e "hook global NormalIdle .* quit" -ui dummy'

(These numbers depend on another optimization.)
2022-09-10 07:35:29 +02:00
Johannes Altmanninger
647e568d3b rc kakrc: add kak=kakrc highlighter alias for markdown/restructuredtext
Filetypes markdown and restructuredtext reuse highlighters from other
filetypes to highlight code blocks. For example, to highlight a code
block of language foo they essentially do

	require-module foo
	add-highlighter [...] ref foo

This works great if the module name matches the shared
highlighter. This is the case almost all scripts in rc/filetype*.
The only exception is kakrc.kak: the highlighter is named "kakrc"
(just like the filetype) but the module is named "kak".

This requires weird hacks in markdown/restructuredtext.  Ideally we
could remove this inconsistency by renaming both the filetype and the
highlighter to "kak" but that's a breaking change.  Until we do that,
let's add an alias so we can treat filetypes uniformly.  This helps
the following commits, which otherwise would need to add ugly extra
code for kakrc highlighters.

The following commit will generalize this approach, allowing users
to add arbitrary aliases.
2022-09-10 07:35:29 +02:00
Maxime Coste
1a8f379a43 Merge remote-tracking branch 'krobelus/embrace-menu-3' 2022-09-09 17:10:53 +02:00
Maxime Coste
1b478c0ace Merge remote-tracking branch 'inahga/inahga-dockerfile-detection' 2022-09-09 17:05:33 +02:00
Maxime Coste
1831c4da4b Merge remote-tracking branch 'krobelus/to-string' 2022-09-09 17:03:59 +02:00