summaryrefslogtreecommitdiff
path: root/rc/detection
AgeCommit message (Collapse)Author
2025-03-29Revert "editorconfig: fix trim_trailing_whitespace"Johannes Altmanninger
https://editorconfig.org says > trim_trailing_whitespace: set to true to remove any whitespace > characters preceding newline characters and false to ensure it > doesn't. We also trim trailing empty lines, which causes unnecessary formatting discrepancies when working with other tools that implement the specification only. This backs out commit 33f44f6abcd758977e346adb91b991c003725281. Cc: Jonathan Halmen <jonathan@halmen.org>
2023-06-02rc detection modeline: optimize modeline pre-filteringJohannes Altmanninger
modeline-parse leads by matching an expensive regex against the entire buffer, which can take a long time on huge files. Perl takes too long on this regex and it seems not even ripgrep optimizes the \z component $ ruby -e '10000.times { puts "a" * 10000 }' > big $ time rg --multiline --only-matching '\A(.+\n){1,5}|(.+\n){1,5}\z' big | wc -l 10 __________________________ Executed in 419.81 millis usr time 399.84 millis sys time 20.78 millis where $ time kak big -e q __________________________ Executed in 179.19 millis usr time 133.61 millis sys time 53.50 millis Let's lose the regex. Fixes #4911
2022-10-19Merge remote-tracking branch 'krobelus/file-completion'Maxime Coste
2022-10-17rc modeline: fix error trying to write readonly global variableJohannes Altmanninger
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-16rc detection editorconfig: use file completions for editorconfig-loadJohannes Altmanninger
2022-07-05Move user mappings to <space> and keep/remove selection to ,Maxime Coste
2022-07-05Make `x` just select the full linesMaxime Coste
`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-04-20rc file-detection hook groupthrowawayaccount12345-1
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
2021-12-31modeline-parse: parse `set` and `:` correctlythrowawayaccount12345-1
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-08-29Stop editorconfig.kak from setting aligntabTheDaemoness
2021-04-25Merge remote-tracking branch 'Eluminae/master'Maxime Coste
2021-02-04Fix editorconfig incorrectly matching properties with prefixesSamadi van Koten
2021-01-12editorconfig: fix trim_trailing_whitespacejhalmen
also trim all superfluous newlines at end-of-file if `trim_trailing_whitespace` is set
2020-12-23file.kak: Acknowledge mime type application/x-shellscriptcodesoap
2020-12-20Use stderr/fail to return errors in modeline.kakMaxime Coste
2020-11-17Detect filetype on buffer save tooReed Wade
This allow kaking a new file, add a shebang in the first line, and get the right filetype detected automatically on save.
2020-09-18rc modeline: Print the final command directlyFrank LENORMAND
2020-09-18rc modeline: Factorise the use of `kakquote`Frank LENORMAND
2020-09-18rc modeline: Error out on unsupported formatsFrank LENORMAND
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-18rc modeline: Use more idiomatic shellFrank LENORMAND
2020-09-18rc modeline: Print error messages correctlyFrank LENORMAND
2020-09-18rc modeline: Prevent command executionFrank LENORMAND
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-16rc modeline: Don't select more lines than configuredFrank LENORMAND
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-02Clear unwanted environment variableJohannes Altmanninger
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-08-24Avoid accidentally using environment variables in sh scopesJohannes Altmanninger
On the instances with altfile this was already the case, but this makes it more obvious. Closes #3673
2020-06-25Merge remote-tracking branch 'lenormf/key-percent'Maxime Coste
2020-06-12Detect text/x-script.* and application/x-* typesJason Felice
2020-06-03src: Introduce a <percent> named keyFrank LENORMAND
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-02-21Fix filetype detectionMatthias Margush
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
2019-11-14rc: Use the standard `fail` command to report errorsFrank LENORMAND
Merely using `echo` with markup doesn't log errors in the debug buffers, and is also less readable.
2019-11-08rc modeline: Support spelling language optionsFrank LENORMAND
2019-08-20Check if buffile is path before loading editorconfig settingsMichael Mogenson
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-06-13max_line_length support for editorconfigath3
2019-04-25Merge remote-tracking branch 'laelath/provides-requires'Maxime Coste
2019-04-17file.kak: Dereference symlinksAlex Leferry 2
2019-04-17file.kak: Use -i POSIX option nameAlex Leferry 2
https://ss64.com/osx/file.html https://freebsd.org/cgi/man.cgi?query=file
2019-04-08Added modules to extra filesJustin Frank
2019-03-21Add categories in rc/Alex Leferry 2
Closes #2783