Commit Graph

34 Commits

Author SHA1 Message Date
Johannes Altmanninger
79b2218754 rc detection editorconfig: use file completions for editorconfig-load 2022-10-16 09:57:46 +02:00
Maxime Coste
2d8456db10 Move user mappings to <space> and keep/remove selection to , 2022-07-05 08:43:40 +10:00
Maxime Coste
ef8a11b3db Make x just select the full lines
`x` is often criticized as hard to predict due to its slightly complex
behaviour of selecting next line if the current one is fully selected.

Change `x` to use the previous `<a-x>` behaviour, and change `<a-x>` to
trim to fully selected lines as `<a-X>` did.

Adapt existing indentation script to the new behaviour
2022-07-05 08:43:40 +10:00
throwawayaccount12345-1
3ab88f4b7c
rc file-detection hook group
Add a group to the `file-detection` hooks.

There's no way to remove hooks without a group. With this patch, you'll be able to remove those
`file-detection` hooks manually. There's no need for two separate groups since if you wanted to
remove only one, you could run `remove-hooks` and then only add one again.


Related: #3670
2022-04-20 23:11:10 -03: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
TheDaemoness
330515154d Stop editorconfig.kak from setting aligntab 2021-08-29 11:55:33 -07:00
Maxime Coste
40270a9c8b Merge remote-tracking branch 'Eluminae/master' 2021-04-25 20:23:10 +10:00
Samadi van Koten
057c532ba8 Fix editorconfig incorrectly matching properties with prefixes 2021-02-04 08:40:22 +00:00
jhalmen
33f44f6abc
editorconfig: fix trim_trailing_whitespace
also trim all superfluous newlines at end-of-file if `trim_trailing_whitespace` is set
2021-01-12 15:45:39 +01:00
codesoap
c9f07702f9 file.kak: Acknowledge mime type application/x-shellscript 2020-12-23 22:45:07 +01:00
Maxime Coste
c99731ebf1 Use stderr/fail to return errors in modeline.kak 2020-12-20 11:30:32 +11:00
Reed Wade
36631fc473
Detect filetype on buffer save too
This allow kaking a new file, add a shebang in the first line, and get
the right filetype detected automatically on save.
2020-11-17 22:32:09 +01:00
Frank LENORMAND
4025ac8167 rc modeline: Print the final command directly 2020-09-18 15:12:13 +03:00
Frank LENORMAND
2a51ebf105 rc modeline: Factorise the use of kakquote 2020-09-18 15:12:13 +03:00
Frank LENORMAND
2d78b0760d rc modeline: Error out on unsupported formats
This commit makes `:modeline-parse` grab all lines that look like
modelines, and lets the parser deal with invalid formats.

This allows actually printing an error on unsupported modelines
formats, instead of ignoring them upfront.
2020-09-18 14:54:57 +03:00
Frank LENORMAND
30ee97386d rc modeline: Use more idiomatic shell 2020-09-18 14:54:57 +03:00
Frank LENORMAND
7731fe4cb2 rc modeline: Print error messages correctly 2020-09-18 09:01:32 +03:00
Frank LENORMAND
6976b1dce4 rc modeline: Prevent command execution
This commit prevents specially crafted modelines from making the
editor execute arbitrary Kakoune commands.

By using a tabulation character as a separator, commands can be
injected in the value of the options listed in the modeline. For
example:

	# kak: tabstop=2;set-option	buffer	pwned	yes

Fixes #3735.
2020-09-18 09:01:32 +03:00
Frank LENORMAND
95c095f3fb rc modeline: Don't select more lines than configured
This commit addresses an off-by-one error that selected `modelines`+1
lines when looking for modelines in a buffer.

Note that setting `modelines` to 0 will still select one line.

Fixes #3733.
2020-09-16 11:00:15 +03:00
Johannes Altmanninger
407c72d90a Clear unwanted environment variable
This adds two things I forgot in
9a7d8df4 (Avoid accidentally using environment variables in sh scopes)

Mea culpa, the problem was that I was skipping matches with "filetype"
because that's usually just a hook parameter as in "WinSetOption filetype=.."

	rg --pcre2 '\b(?!filetype=)\w+=' rc/

So I missed these two cases where a shell variable is actually called "filetype".

The one in git.kak was not a problem because show_git_cmd_output is only
ever called with sane inputs.  However, file.kak does use the filetype
environment variable for many mime types, for example:

	filetype=somefiletype\''; echo -debug injection; nop '\' kak /dev/null

Will run the echo since /dev/null has mime type "inode/chardevice"
2020-09-02 06:54:19 +02:00
Johannes Altmanninger
9a7d8df447 Avoid accidentally using environment variables in sh scopes
On the instances with altfile this was already the case, but this makes it more obvious.

Closes #3673
2020-08-24 19:01:05 +02:00
Maxime Coste
f5127f8b22 Merge remote-tracking branch 'lenormf/key-percent' 2020-06-25 20:58:26 +10:00
Jason Felice
bdd7ea6a03 Detect text/x-script.* and application/x-* types 2020-06-12 11:29:55 -04:00
Frank LENORMAND
24c5169400 src: Introduce a <percent> named key
Similarly to the <semicolon> key, make it easier to write
`:execute-keys` commands by replacing <percent> with `%`.

Highlighters can keep escaping the sign when regular expressions are
not quoted, but built-in scripts that use `%` as an editing primitive
have been modified to use the named key, for clarity.
2020-06-03 15:42:38 +03:00
Matthias Margush
99c09daec3 Fix filetype detection
The -i flag on Mac OS means:
    ჻ man file | grep -i -- -i
    -i      If the file is a regular file, do not classify its contents.

The --mime-type option is (mostly) portable:
- Linux uses --mime-type
- macOS uses --mime-type
- FreeBSD uses --mime-type
- NetBSD uses --mime-type
- OpenBSD uses --mime-type and does not use the same implementation as everybody else
- Solaris does not support MIME types at all
2020-02-21 21:25:57 -08:00
Frank LENORMAND
5b1f9255a1 rc: Use the standard fail command to report errors
Merely using `echo` with markup doesn't log errors in the debug
buffers, and is also less readable.
2019-11-14 08:32:55 +01:00
Frank LENORMAND
a7bf625236 rc modeline: Support spelling language options 2019-11-08 17:56:36 +01:00
Michael Mogenson
37ded5e400 Check if buffile is path before loading editorconfig settings
Check if buffile is a full path by checking for the beginning
'/' character in editorconfig-load command. This avoids a parsing
error from feeding a *scratch*/*debug*/*grep*/etc. buffer name to the
editorcofig command. Don't clear editorconfig hooks until after checking
for a valid bufffile path. This way, opening the *debug* buffer will
not clear the hooks from a previously parsed .editorconfig file. If
trim_trailing_whitespace is true, print the hook directly from awk. This
removes the need to save a editorcofig_trim_trailing_whitespace option.

Note: Setting the max_line_length requires a window to be created.
Therefore, a global hook to load .editorconfig settings should be:

    hook global WinCreate .* %{editorconfig-load}
2019-08-20 14:55:17 -04:00
ath3
8c7d447574 max_line_length support for editorconfig 2019-06-13 00:03:45 +02:00
Maxime Coste
0cc89b2b9f Merge remote-tracking branch 'laelath/provides-requires' 2019-04-25 11:59:42 +01:00
Alex Leferry 2
ba1274f73c file.kak: Dereference symlinks 2019-04-17 12:37:54 +02:00
Alex Leferry 2
313c6eadc7 file.kak: Use -i POSIX option name
https://ss64.com/osx/file.html
https://freebsd.org/cgi/man.cgi?query=file
2019-04-17 12:37:17 +02:00
Justin Frank
aa6d19bee6 Added modules to extra files 2019-04-08 17:05:55 -07:00
Alex Leferry 2
c0dccdd90d Add categories in rc/
Closes #2783
2019-03-21 01:06:16 +01:00