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
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>
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.
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.
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 '#'.
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
- 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".
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"
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.
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).
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.
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.
Correctly indentint on "end" keyword seems very hard,
it is simpler to remove it. And we already insert "end"
in ruby-insert-on-new-line hook, so the removal shouldn't
hurt too much.
currently focus client doesn't work if target pane of the client is in different tab or window from current one.
select window, select tab should be triggered in order to select a pane on a currently not focused tab or window.
1. Deleted back-tick strings which are not a valid Dart syntax
2. Added string interpolation for ${}
3. NOT adding string interpolation for $var as this is considered a bad practice
This commit adds highlighting characters other than the first with red color helping to get immediate feedback of the syntax error.
This helps those who come from languagles like JS where single quotes also denote multi-character strings.
Adding highlighting for string interpolation inside double-quoted strings and character literals inside single-quotes.
Avoiding string interpolation in the form of $var as this is considered bad practice.
The off-by-one was introduced by cd9b1e66 which changed `column-1` to `column`.
The refactoring solves some esoteric quoting errors: I think cases like
unbalanced braces in the bufname and client were not supported.
* bring colors more aligned with upstream solarized implementations
(e.g. vim, emacs)
* tweak rust syntax
* add more details, like operators, highlighting certain traits and
types from std, etc
* remove certain highlighters, like user types. This has the effect
of just highlighting almost the whole code base one color, and
wasn't really correct either. CamelCase for types is only convention
Updates to address these comments:
"I still dont quite see why we need to introduce all those options, especially with names that dont say anything about kotlin. I would expect a single kotlin_static_words option to be enough.
Similarly, a single highlighter should be enough here."
This should cover all filetypes that already auto-insert comments,
except for rust.kak, which is left for a follow-up.
Most of these are straightforward, some explanation for special cases:
rc/filetype/zig.kak rc/filetype/cue.kak
These indent hooks used their own logic to indent after "{" only if
no comment was inserted. Replace this logic by checking if a comment
was inserted. This works because these "*-insert" hooks are run
before their respective "*-indent" hooks.
rc/filetype/php.kak
This also has some logic to insert "*" after "/*" lines. Basic
usage seems to work still. In future this should borrow from the
c-family one, which works a bit better.
Function taking a parameter with a struct tag on the last line
before the opening { were wrongly treated as structs. Add some
additional regex logic to try to catch those cases.
Fixes#4136
The invalid regex `)\b` currently matches anything, so this didn't cause
any errors.
It is still invalid though, so I fixed it by moving the `\b` to the end
of the non-raw_attribute language name (like the original regex). The
raw_attribute one shouldn't need this because the `}` marks the end of
the language name anyway.
Fixes#4025
Current solution makes it difficult to use common Lua practices of having one-liner if statements and using anonymous functions.
New solution prevents auto-indentation and end insertion, if the previous line contains an "end" keyword.
It does not attempt to match each structure with corresponding end, since using multiple end keywords in single line is a very rare occurance in Lua.
Because the HTML highlighter was higher up in the hierarchy than the code
highlighter, it took precedence. I fixed it by making it an inline region.
Using my new knowledge of "inline" I was able to remove one line of code.
Fixes#4091
The X11 repl is unique in that it sends the selection (or parameter) with a
new line appended.
This patch removes that new line and thus, brings it into line with the tmux
and kitty versions.
This commit removes the default prompt value from the `spell-replace`
command.
Currently, running the command after selecting a misspelled word
might not allow the editor to propose alternative spellings because
it completes upon whatever is inserted into the prompt. If the words
returned by `aspell` are too different from the currently misspelled
word, no candidates are shown.
For example, selecting “unanymously” and running `:spell-replace`
will not show any candidates under the current implementation (the
‘y’ probably trips the fuzzy-matcher).
The user develops a habit of clearing the prompt every time, because
that's the only way to make sure all suggestions from `aspell` are
visible, so the editor might as well not have any default value for
`:spell-replace`.
If a line contains three slashes directly followed by a new line, the
next line is also erroneously highlighted as a doc comment currently.
Using a lookahead instead fixes this.
tmux-send-text allows sending an argument, when supplied the argument
will be sent to the REPL instead of the current selection.
tmux-send-text also keeps kak focussed, which does not happen in the x11
variant as it uses xdotool to switch window.
this patch allows:
* Passing an argument to x11-send-text, so that value will be sent
instead of the current selection.
* We capture the window id of the current (presumably kak window)
before we use xdotool to switch window. We can therefore switch back to
kak afterwards (which we do)
This highlighter (line 50 of markdown.kak) looks for the filetype
specified by the author at the top of the code fence, e.g.
``` python
print("hello")
```
and highlights the code within using Kakoune's relevant highlighter --
in this case Python.
Some flavours of markdown use curly braces and other characters in the
first line such as the following:
``` {=python}
print("hello")
```
Previously Kakoune recognised `{=python}` but not `{.python}`. The latter
is Pandoc's flavour of markdown. This patch adjusts the regex patterns
to recognise the dot notation as well.
When $1 or ${kak_selection} start with dash, like "-1", the command will fail, because tmux think it's an argument flag.
-- prevent this.
Also the doc (append new line) is no longer valid.
Other scripts uses a dot `.` to separate the seed from the rest of
the template, making that standard across the codebase allows running
cleanup commands like `rm -rf /tmp/kak-*.*`.
This commit is an attempt at mitigating stray processes and temporary
directories, which pile up in the process tree and `$TMPDIR` over time.
To reproduce the issue, run the `lint` command in rapid successions,
or simply run `:lint; lint; lint;` in the prompt (two consecutive
calls are enough to trigger the bug).
The first call creates a `\*lint-ouput*` buffer, bound to a named
pipe that will be populated later on in an asychronous shell
process. It's that same process that runs the linter afterward, and as
soon as it has been spawned, the following call to `:lint` is executed.
Each call to `:lint` overrides the path to the named pipe that was
assigned to `\*lint-output*` by the previous one, resulting in several
asynchronous processes (that write diagnostics to the pipe) hanging
forever — the pipe is never read, and so the process idles.
The command that removes the temporary directory follows the one that
writes to the named pipe, it's never called in the above scenario,
which additionally results in `kak-lint.XXXXXXXX` directories being
left behind in `$TMPDIR`.
(Also) Fixes#3681.
Triple strings are now distinct from docstrings, triple strings
only preceeded by blanks on the line are considered docstrings.
Avoid highlighting of the closing marker using a lookahead, this
is not fully correct as it will break on a double quote triple
docstring containing a single quote triple string but that seems
improbable enough; if we encounter this in the wild we can split
the two docstring formats into separate regions.
This commit prevents the lines following the one that holds the bullet
from being highlighted with the `bullet` face when they're indented:
- The bullet is highlighted properly, so is this sentence
but this line the ones that would follow are not
Fixes#3582
* fix multilines for declarations
* fix names with `-`, which Ninja allows
* fix few cases of `=` operators
* fix reserved keywords in `command = …` right-hand side
Co-authored-by: Frank LENORMAND <1379068+lenormf@users.noreply.github.com>