Commit Graph

2387 Commits

Author SHA1 Message Date
Maxime Coste
3667f8bb21 Merge branch 'master' of http://github.com/eko234/kakoune 2022-03-21 20:55:12 +11:00
Maxime Coste
5e7afdcd04 Merge remote-tracking branch 'CharlesGueunet/FixCMakeComment' 2022-03-21 20:49:42 +11:00
Charles Gueunet
2f1cb11194 CMake: fix comment highlight 2022-03-18 09:01:02 +01:00
Johannes Altmanninger
13948ecb94 rc diff: pass diff to diff-jump via stdin instead of env
Passing large diff buffers via the environment can quickly result in
the error "execve failed: Argument list too long". Use a pipe like
in format.kak

When running | (or <a-|>), Kakoune does not use %arg{@} to populate
"$@" (missing feature?). Work around this by moving %arg{@} to a
temporary register. Apparently $kak_quoted_reg_a will never be an
empty list, so work around that too.

When diff parsing fails, we take care to run "fail" in the calling
client, unlike :format (probably a bug in format.kak).

(This patch is best viewed while ignoring whitespace changes (diff -w))
2022-03-08 20:30:06 +01:00
Johannes Altmanninger
eaaf562ed1 rc diff: support absolute paths in diff-jump
Quick repro:

	diff /dev/null $PWD/README.asciidoc -u | kak -e 'set-option buffer filetype diff'

Fixes #4531
2022-03-06 09:49:55 +01:00
Johannes Altmanninger
49de2b91c4 rc diff: bind diff-jump in all filetype=diff buffers, not just *.diff or *.patch files
Mapping in the filetype hook matches others like grep.kak and man.kak.
Since we map in buffer scope, git diff buffers will override diff-jump
with git-diff-goto-source.

This means that the diff-jump binding applies here:

	diff -u "$1" "$2" | kak -e 'set buffer filetype diff'

Reported in: https://github.com/mawww/kakoune/issues/153#issuecomment-1030643854
2022-03-06 09:49:55 +01:00
Johannes Altmanninger
1c2e1e1090 rc diff: fix style
This line was unindented by accident (I was rushing..)
2022-03-06 09:49:55 +01:00
Maxime Coste
7061001728 Add a complete-command command to configure command completion
This makes it possible to change command completion in hooks and
paves the way to more flexibility in how custom commands can be
completed
2022-03-06 10:13:14 +11:00
Luis Alfonso Buelvas Betancourt
d6392e37c9
fennel filetype now highlights accumulate keyword 2022-02-22 17:13:38 -05:00
SolitudeSF
1dc0a2eaf2
Fix elvish highlighter 2022-02-18 18:19:21 +02: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
b6a9fd6e3a Merge remote-tracking branch 'c7skasku/fix-c-comments-whitespace' 2022-02-15 20:45:40 +11: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
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
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
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
4d864e76d4 Merge remote-tracking branch 'm-kru/vhdl_boolean_vector' 2022-01-24 22:00:15 +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
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
871782faaf Merge branch 'patch-3' of http://github.com/throwawayaccount12345-1/kakoune 2022-01-03 09:24:49 +11:00
throwawayaccount12345-1
74874aa4b7
modeline-parse: parse set and : correctly
When `set` or `se` is found at the start of the modeline, it should stop parsing options after `:`.

When `modeline-parse` is called in the following file, it should _not_ recognize `tabstop=4` and `invalid_option=3`.
```
# kak: set indentwidth=0 tabstop=16: tabstop=4 invalid_option=3
```

More info: http://vimdoc.sourceforge.net/htmldoc/options.html#modeline
2021-12-31 11:02:15 -03:00
Isaac Freund
007a137ac1
rc/filetype/zig: update for zig 0.9.0 release
- c_void has been renamed to anyopaque
- a few new builtins have been added.
2021-12-31 05:00:35 +00:00
Yerlan
a7676709cb
Change highlight of character literals
Better support themes where red can highlight strings and thus the difference between the first and subsequent characters can become invisible
2021-12-11 02:04:10 +01:00
Maxime Coste
36eebbce4f Merge remote-tracking branch 'sidkshatriya/erlang-syntax-highlighting-improvements' 2021-12-06 19:23:53 +11:00
Parasrah
7fc0f9d212
update sigil highlighter to be less error prone 2021-12-02 17:49:28 -07:00
Sidharth Kshatriya
2825ca5f73 When viewing :git diff or :git show within kakoune, this commit
adds the ability to press <ret> within a hunk and navigate to the original
source code. This can be useful because one often needs to go back and forth
between the diff and the full source code.

- You can press <ret> anywhere _within_ a hunk i.e. lines that start with
  ` `, `+`, `-`. You will be taken to the exact line in the source that corresponds
  to where you pressed <ret> in the hunk. It actually does not make sense
  to press <ret> on a `-` line because that does not exist anymore but
  in that case you are taken to a nearby line in the hope this is still useful.

- You can also press <ret> on a range line (lines that
  look like @@ ... @@). If you press <ret> on anywhere on a range line e.g.

  ```
  @@ -120,3 +123,4 @@ fn some_function {
  ```
  The code will try to navigate to the section heading "fn some_function {"
  Note that the section heading is _not_ necessarily located at the
  range line (in the above example the range line is 123).

- You can press <ret> on a +++ line also and you will be taken the first
   line of the file

Caveats:
- Navigation to the original source file will be accurate only if any edits to
  the original source file have been saved to disk, because otherwise
  they will not be detected by the `:git diff` or `:git show` commands
- This feature should work well for most typical uses e.g. `:git diff`, `:git diff HEAD^`
  `:git diff <some-sha1>`. In fact this feature should work in all scenarios when
  the *current files* on disk are being compared _with_ some arbitrary git revision/staging.
  It will be less useful in other scenarios when two arbitrary revisions are being
  compared to each other or when you are trying to compare staging to some revision.
  For example when you invoke `:git diff --staged` you are trying to compare staging
  with HEAD but are navigating to what is currently on disk (which may be different
  from staging).

Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>
2021-11-22 23:33:09 +05:30
Maxime Coste
0e2612f1ad Merge remote-tracking branch 'sidkshatriya/ocaml-switch-between-ml-and-mli' 2021-11-21 09:37:08 +11:00
Maxime Coste
e88852430b Merge remote-tracking branch 'sidkshatriya/markdown-highlight-erlang-and-elixir' 2021-11-21 09:33:17 +11:00
throwawayaccount12345-1
2a3509e560
sh filetype: do not highlight an empty array as a function
`x=` and `x+=` should not be highlighted as a function.
```
x=()
x+=()
```
2021-11-18 13:51:53 -03:00
Sidharth Kshatriya
b8981883ce markdown.kak: erlang, elixir and ocaml code should be highlighted in markdown 2021-11-17 20:38:12 +05:30
Sidharth Kshatriya
101425e289 OCaml: Add a command to shift between .ml and .mli files and vice versa
C has header and source files and you need to often switch between them.
Similarly OCaml has .ml (implementation) and .mli (interface files) and
one often needs to switch between them.

This commit provides a simple functionality that allows you to accomplish this.
2021-11-10 12:22:08 +05:30
Maxime Coste
960e7c7e6a Merge branch 'master' of http://github.com/throwawayaccount12345-1/kakoune 2021-11-07 15:39:25 +11:00
throwawayaccount12345-1
3e580b185c
rc/tools/make.kak: quote "${kak_opt_makecmd}"
As per man page eval(1p):
> The eval utility shall construct a command by concatenating arguments together,
> separating each with a `<space>` character.  The constructed command shall be
> read and executed by the shell.

When not quoting `$kak_opt_makecmd` in the eval, the variable is split by
newlines and spaces and then joined by spaces to form the command. If there
were newlines in `$kak_opt_makecmd`, the command would be malformed.


To reproduce:
```kak
set-option global makecmd "
echo foo
echo bar"
make a b c
```

Expected output in the `*make*` buffer:
```
foo
bar a b c
```

Actual output:
```
foo echo bar a b c
```

This patch fixes this.
2021-11-05 13:43:18 -03:00
Frank LENORMAND
6abcb891ea rc man: Gracefully fail link search 2021-11-04 07:31:43 +03:00
Frank LENORMAND
b7452f2c7e rc man: Keep user mode alias in the prompt history
The `m` user mode key is a prompt helper, it's helpful to keep it in
the history by default.
2021-11-04 07:28:06 +03:00
Frank LENORMAND
4cee8917ab rc man: Let mode commands fail
Commands in the `man` user mode shouldn't fail silently.
2021-11-04 07:20:10 +03:00