Commit Graph

2424 Commits

Author SHA1 Message Date
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
Frank LENORMAND
924ca6b43a rc man: Drop helper command
The mappings declaration code is not necessarily more readable and
the resulting command is shorter by a single flag.
2021-11-04 07:17:54 +03:00
Frank LENORMAND
28559bc1e7 rc man: Rename mode to man
The suffix seems redundant when entering the mode with the
`enter-user-mode` command.

Closes #3970
2021-11-04 07:15:43 +03:00
Sidharth Kshatriya
be8dd0eb3d Erlang syntax highlighting: Improved support for numeric literals, refs, ports and pids 2021-10-28 12:43:00 +05:30
Maxime Coste
946673850e Merge remote-tracking branch 'sidkshatriya/erlang-syntax-highlighting' 2021-10-28 09:09:46 +11:00
LXNN
ebcb47e096 Add new '_', 'case', and 'match' keywords to Python highlighter 2021-10-24 12:56:18 +01:00
Sidharth Kshatriya
a547e731f2 Add detection, intialization and basic syntax highlighting for Erlang 2021-10-24 11:47:55 +05:30
Taupiqueur
907cc576ea Fix AsciiDoc blocks
https://docs.asciidoctor.org/asciidoc/latest/blocks/delimited/
2021-10-17 00:19:53 +02:00
Evan Lloyd New-Schmidt
6b6577d8b9 Disable comment_line for ocaml/coq
OCaml does not have line comments, and as far as I can tell neither
does Coq. Setting it to '' (like markdown and html do) throws an error
that can be handled or displayed instead of inserting the default '#'.
2021-10-04 13:19:00 -04:00
Maxime Coste
85a1f78ca9 Merge remote-tracking branch 'Ordoviz/patch-2' 2021-09-29 20:31:30 +10:00
Maxime Coste
133cb9053a Merge remote-tracking branch 'hugomg/better-lua-indentation' 2021-09-29 20:25:15 +10:00
Lennard Hofmann
55b2b8c88d rc markdown: Fix fenced code blocks
The closing ``` in the following example was not detected because the
indented code block highlighter was higher up in the hierarchy than the
fenced code block highlighter:

```
    indented
```

The codeblock highlighter used to be inline so that it has an effect
inside listblocks. This commits adds a listblock/codeblock highlighter
as a replacement.

Fixes #4351
2021-09-27 17:34:31 +02:00
Hugo Musso Gualandi
c26fb65ed1 lua.kak: Add some test cases, and also fix a bug 2021-09-26 11:19:58 -03:00
Maxime Coste
fb734cb61b Merge remote-tracking branch 'lenormf/fix-4273' 2021-09-26 11:09:34 +10:00
Maxime Coste
14e820544a Merge remote-tracking branch 'SeerLite/latex-remove-hooks' 2021-09-26 11:09:34 +10:00
Maxime Coste
24f6660bfc Merge remote-tracking branch 'alexherbo2/fix-crystal-escape-string' 2021-09-26 11:03:50 +10:00
Maxime Coste
1456431951 Merge remote-tracking branch 'Screwtapello/add-diagnostic-faces' 2021-09-21 21:11:56 +10:00
kjduncan
3158c9c223 filetype:kotlin keywords to static word list, constants/generics regex improvement 2021-09-21 21:06:35 +10:00
Frank LENORMAND
1815a352f6 rc doc: Don't spawn processes unecessarily 2021-09-16 11:47:44 +03:00
Frank LENORMAND
ab1704ce10 rc doc: Hide errors on missing directories
Fixes #4273.
2021-09-16 11:46:18 +03:00
SeerLite
a39516e0dd rc latex: Add missing scope arg to remove-hooks 2021-09-12 17:31:12 -03:00
Hugo Musso Gualandi
aa1a280309 lua.kak: more accurate "end" insertion
- Also insert "end" after "do", "else" and "elseif"
- Do not insert "end" after strings or comments containing keywords
- Only insert "end" if the block is empty

An example of the last item is if we want to add a new line to the start
of an unclosed block that already contains statements. @ is the cursor.

    -- before
    if a then@
        x = 1
        y = 2

    -- after
    if a then
        @
    end
        x = 1
        y = 2

In this case, inserting the "end" before the statements is probably not
what the programmer wants. It might make more sense to insert the "end"
after the statements, but that is potentially confusing due to spooky
action at a distance. I think the least confusing thing to do in this
situation is to not insert the "end".
2021-09-11 01:29:01 -03:00
Hugo Musso Gualandi
8755fc679e lua.kak: improve the indentation logic
This commit makes several improvements to the Lua indentation logic.

- Don't indent if the keyword is inside a string or comment
- Indent inside "do end"
- Indent inside "repeat until"
- Indent after a line ending with "{" or "("
- More accurate un-indentation for the "end" keyword

For the last point, previously we tried to match the indentation of the
starting keyword of the block.  However, sometimes this guessed wrong
and produced the wrong indentation, as the following example shows. The
new logic is to indent the "end" by one less level than the contents of
the block.

   while true do
      if false then
      end
      end -- This was incorrectly matched with the "if"
2021-09-11 01:27:41 -03:00
Hugo Musso Gualandi
ffc69544db lua.kak: use %[] instead of %{}
We will want to use unbalanced "{" and "}" in some of the rules.
To support that, let's use "%[]" instead.
2021-09-11 01:19:17 -03:00
Hugo Musso Gualandi
94b35a4071 lua.kak: remove some extra spaces 2021-09-11 01:18:49 -03:00
Tim Allen
dc07c649de Add standard DiagnosticError and DiagnosticWarning faces.
kak-lsp uses these faces to mark errors inside the buffer, instead of the Error
face which is much more jarring, and which does not have an associated warning
face. Since the :spell command marks errors inside the buffer, it's also updated
to use this new face.

Adding these faces to Kakoune makes it more likely that colorschemes will
automatically do the right thing when used with kak-lsp, and makes it possible
to use a subtle appearance (like curly underlines) for in-buffer errors while
keeping Kakoune errors bold and jarring as they should be.
2021-09-07 17:46:50 +10:00
Taupiqueur
f37633277a Fix Crystal escape string 2021-09-04 23:50:12 +02:00
Maxime Coste
253dcde976 Merge remote-tracking branch 'TheDaemoness/patch-1' 2021-09-04 09:38:01 +10:00
ioh
b739ca4ca6 Fix unterminated string in rc/filetype/php.kak 2021-09-02 14:54:47 -07:00
TheDaemoness
330515154d Stop editorconfig.kak from setting aligntab 2021-08-29 11:55:33 -07:00
Maxime Coste
13eb5a677f Merge remote-tracking branch 'StatPal/master' into HEAD 2021-08-28 13:55:11 +10:00
Maxime Coste
b4c994c4ea Merge remote-tracking branch 'listentolist/x11-repl' into HEAD 2021-08-28 13:54:38 +10:00
notquiteamonad
b9c02d48ab
Fix regex for nix paths 2021-08-23 11:06:14 +01:00
Subrata
25ffbacb70 In the tmux-repl, it tackles the situations where there is already some other tmux pane open
and we want to send text (or do other works) in that specific pane.
2021-08-22 09:57:09 -05:00
Tilman List
0d74268451 add module dtach-repl 2021-08-21 18:42:29 +02:00
Maxime Coste
94388dc51e Merge remote-tracking branch 'alexherbo2/fix-typos' 2021-08-17 08:48:47 +10:00
Maxime Coste
e63ab10424 Merge remote-tracking branch 'gustavo-hms/master' 2021-08-17 08:43:25 +10:00
Maxime Coste
3a6ab49d5c Merge remote-tracking branch 'kkga/gdscript.kak' 2021-08-17 09:41:10 +10:00
Maxime Coste
d4d5a2f32c Merge http://github.com/mujo-hash/kakoune 2021-08-17 08:29:24 +10:00
Maxime Coste
74ae6469e3 Merge remote-tracking branch 'krobelus/fish-snowflakes' 2021-08-17 08:27:17 +10:00
Johannes Altmanninger
89229bab39 Teach :comment-line about the fennel language
Fixes #4292
2021-08-09 22:45:57 +02:00
Johannes Altmanninger
faba50d528 rc fish: fix keyword highlighting false positive
"command" is a built-in, but these are not:

	$command
	some-command
	command-some
2021-08-09 22:45:52 +02:00
ioh
4932aad623 Add gentoo linux ebuild filetype detection. 2021-08-06 11:30:06 -07:00
Maxime Coste
580869fd49 Merge remote-tracking branch 'StatPal/master' into HEAD 2021-08-05 11:00:30 +10:00
Hugo Musso Gualandi
4f0f3eefd0 Remove a duplicate highligher rule for _G/_ENV 2021-08-04 13:24:16 -03:00
Hugo Musso Gualandi
dc88220e4a Recognize and/or/not in a separate rule
This is the usual style
2021-08-04 13:24:16 -03:00
Hugo Musso Gualandi
be09ff4680 lua.kak: highlight and/or/not as operators 2021-08-04 13:24:16 -03:00
Hugo Musso Gualandi
d3d3c77ab9 lua.kak: highlight Lua 5.4 variable attributes 2021-08-04 13:24:16 -03:00
Hugo Musso Gualandi
3621a98170 lua.kak: Treat "local" as a normal keyword 2021-08-04 13:24:16 -03:00
Hugo Musso Gualandi
ceb3f55f3c lua.kak: the builtin is called _ENV, not _E
The Lua highlighting was highlighing `_E` instead of `_ENV`
2021-08-04 13:24:16 -03:00
Hugo Musso Gualandi
43d9f59fda lua.kak: keyword should have higher priority than function call
Currently, the "return" in `return {}` is highlighted as a function call, instead of being highlighted as a keyword
2021-08-04 13:24:16 -03:00
Subrata
8d27d8d581 R file highliight change. Merged into single highlighter for math, summary and complex functions. 2021-07-30 11:29:29 -05:00
Maxime Coste
52087a506d Merge remote-tracking branch 'hugomg/rockspec-highlighting' 2021-07-30 07:37:36 +10:00
Maxime Coste
8a7f8f67be Merge remote-tracking branch 'hugomg/lua-comment-insert-indent' 2021-07-30 07:37:01 +10:00
Hugo Musso Gualandi
52f7999705 Recognize ".rockspec" file extension as a Lua file
rockspec files are used by [Luarocks](https://luarocks.org/), the
most prominent package manager for Lua. Despite the different file
extension, these files are actually Lua files and should be syntax
highlighted as such.

For what it is worth, Neovim also does the same thing that I am doing in
this commit. They recognize both ".lua" and ".rockspec" as being Lua
files (and no other extensions, as far as I know).
2021-07-26 17:41:00 -03:00
Subrata
a466f2f6d0 R file highlights. Added :: etc, added new functions from base::Ops and method::Ops, tried to correct inconsistency with %any% case. Added indexing and assign operator. 2021-07-22 23:11:40 -05:00
Maxime Coste
9cf79bfd1e Merge remote-tracking branch 'listentolist/pascal-filetype' 2021-07-20 22:40:06 +10:00
Tilman List
807be115b2 make pascal filetype compatible with bash
When using bash, the whitespaces before the delimiting identifier `EOF`
cause an error as well as a missing `\` before `$`.
2021-07-17 20:01:12 +02:00
Robin Stumm
507e16ff23 comment.kak: add cue 2021-07-16 17:55:10 +02:00
Hugo Musso Gualandi
f440a1c109 Lua: insert comment prefix *after* the indent
This fixes a bug in how the Lua scripts handle new comment lines.
Currently if we have a comment that is indented, when we add a new line
it inserts the `--` prefix before the automatic indentation.

```
  --ABC
--  XYZ
```

After the fix, it correctly inserts the comment prefix after the
indentation:

```
  --ABC
  --XYZ
```

The solution I used is inspired by the ruby.kak script.
2021-07-13 13:28:30 -03:00
Maxime Coste
911edf6ea3 Merge branch 'patch-1' of http://github.com/catdevnull/kakoune 2021-07-12 10:16:01 +10:00
throwawayaccount12345-1
719b23c54f
Fix #3957
If the session wasn't valid anymore by the time the linter finishes,
writing to "$dir"/fifo would hang forever leaving temporary files in
/tmp/kak-lint.XXX and the process alive. This commit fixes that by
not writing to the fifo if the session was not valid.

throwawayaccount12345-1 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.
2021-07-09 22:18:25 -03:00
Nulo
b13e0598e2
Spawn a shell when using xfce4-terminal
Previously, commands like repl broke because of this
2021-07-08 01:44:17 +00:00
Maxime Coste
2b68b6737c Update spell.kak to use command/response fifo 2021-07-07 19:25:06 +10:00