pax_global_header00006660000000000000000000000064137234221400014510gustar00rootroot0000000000000052 comment=e0d2602e6a924c9a4067fa9ff23f034b906dd56d kakoune-2020.09.01/000077500000000000000000000000001372342214000135405ustar00rootroot00000000000000kakoune-2020.09.01/.cirrus.yml000066400000000000000000000022471372342214000156550ustar00rootroot00000000000000freebsd_task: freebsd_instance: image_family: freebsd-12-1 gmake_script: pkg install -y gmake matrix: - name: freebsd_clang env: CXX: clang++ - name: freebsd_gcc gcc_script: pkg install -y gcc env: CXX: g++ test_script: gmake -j4 test env: LC_ALL: en_US.UTF-8 linux_task: locales_script: - apt-get update && apt-get -y install locales - echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen - locale-gen en_US.UTF-8 matrix: - name: linux_clang container: image: silkeh/clang:6 clang_script: - apt-get -y install pkg-config libncursesw5-dev env: CXX: clang++ - name: linux_gcc container: image: gcc:7 test_script: make -j4 test env: LC_ALL: en_US.UTF-8 macos_task: osx_instance: image: mojave-base matrix: - name: macos_clang env: CXX: clang++ - name: macos_gcc gcc_script: brew install gcc@7 env: CXX: g++-7 test_script: make -j4 test kakoune-2020.09.01/.github/000077500000000000000000000000001372342214000151005ustar00rootroot00000000000000kakoune-2020.09.01/.github/ISSUE_TEMPLATE/000077500000000000000000000000001372342214000172635ustar00rootroot00000000000000kakoune-2020.09.01/.github/ISSUE_TEMPLATE/bug_report.md000066400000000000000000000004241372342214000217550ustar00rootroot00000000000000--- name: Bug report about: Report an unexpected behaviour with the editor labels: bug --- ### Steps ### Outcome ### Expected kakoune-2020.09.01/.github/ISSUE_TEMPLATE/config.yml000066400000000000000000000000331372342214000212470ustar00rootroot00000000000000blank_issues_enabled: true kakoune-2020.09.01/.github/ISSUE_TEMPLATE/crash_report.md000066400000000000000000000007371372342214000223070ustar00rootroot00000000000000--- name: Crash report about: Report a crash of the editor while in-use labels: bug, crash --- ### Steps ### Outcome/Stacktrace kakoune-2020.09.01/.github/ISSUE_TEMPLATE/feature_request.md000066400000000000000000000012531372342214000230110ustar00rootroot00000000000000--- name: Feature request about: Ask for a feature to be implemented and included in the next release labels: feature request --- ### Feature ### Usecase kakoune-2020.09.01/.github/ISSUE_TEMPLATE/question.md000066400000000000000000000005471372342214000214620ustar00rootroot00000000000000--- name: Question about: Couldn't find an answer in the documentation? Ask away! labels: question --- kakoune-2020.09.01/.github/PULL_REQUEST_TEMPLATE/000077500000000000000000000000001372342214000203575ustar00rootroot00000000000000kakoune-2020.09.01/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md000066400000000000000000000003531372342214000253210ustar00rootroot00000000000000 kakoune-2020.09.01/.gitignore000066400000000000000000000002211372342214000155230ustar00rootroot00000000000000*.o .*.d *.pyc *.1-r .*.kak.* src/kak src/kak.debug src/kak.opt src/.version* src/.*.json doc/kak.1.gz doc/manpages/*.gz tags GPATH GRTAGS GTAGS kakoune-2020.09.01/.travis.yml000066400000000000000000000015341372342214000156540ustar00rootroot00000000000000language: cpp sudo: false os: - linux - osx osx_image: xcode10.1 compiler: - clang - gcc env: global: - secure: "R+NxqtytOslIcQ/eCbLoZhImsgYdJnljfjANdieFQGune9ACPPQL0YanXkF49c9SWGBSxrAcute0egQzv2CU2+ivSQIX/xnMebKHiOmSPYBoxX+VgxLT3U1itUYlpYwixo9rF8UnGdlgXid6oENSiCvfWtNKoM2qOL0Ttw31J9E=" before_install: if [ "$CXX" = "g++" ]; then export CXX=g++-7; fi addons: apt: sources: - ubuntu-toolchain-r-test packages: - libstdc++-7-dev - g++-7 - libncursesw5-dev homebrew: update: true packages: gcc@7 coverity_scan: project: name: "mawww/kakoune" description: "Build submitted via Travis CI" notification_email: frrrwww@gmail.com build_command_prepend: "cd src && make clean" build_command: "make -j4" branch_pattern: coverity-scan script: cd src && make && make test kakoune-2020.09.01/CHANGELOG000077700000000000000000000000001372342214000222402doc/pages/changelog.asciidocustar00rootroot00000000000000kakoune-2020.09.01/CONTRIBUTING000066400000000000000000000014101372342214000153660ustar00rootroot00000000000000The preferred way to contribute would be through GitHub pull requests, as an alternative patches can be discussed on the IRC channel. When contributing your first changes, please include an empty commit for copyright waiver using the following message (replace 'John Doe' with your name or nickname): John Doe 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. The command to create an empty commit from the command-line is: git commit --allow-empty kakoune-2020.09.01/Makefile000066400000000000000000000001101372342214000151700ustar00rootroot00000000000000all: $(MAKE) -C src $@ %: FORCE $(MAKE) -C src $@ .PHONY: all FORCE kakoune-2020.09.01/README.asciidoc000066400000000000000000000673241372342214000162110ustar00rootroot00000000000000= image:{logo}[K,30,30,link="{website}",title="Kakoune logo by p0nce"] Kakoune image:{travis-img}[link="{travis-url}"] image:{cirrus-img}[link="{cirrus-url}"] image:{irc-img}[link="{irc-url}"] ifdef::env-github,env-browser[:outfilesuffix: .asciidoc] :logo: https://rawgit.com/mawww/kakoune/master/doc/kakoune_logo.svg :website: https://kakoune.org :travis-img: https://travis-ci.org/mawww/kakoune.svg?branch=master :travis-url: https://travis-ci.org/mawww/kakoune :cirrus-img: https://api.cirrus-ci.com/github/mawww/kakoune.svg :cirrus-url: https://cirrus-ci.com/github/mawww/kakoune :irc-img: https://img.shields.io/badge/IRC-%23kakoune-blue.svg :irc-url: https://webchat.freenode.net/?channels=kakoune :icons: font :toc: right :pp: ++ TL;DR ----- {website} *Modal editor* -- *Faster as in fewer keystrokes* -- *Multiple selections* -- *Orthogonal design* --------------------------------------------- git clone https://github.com/mawww/kakoune.git cd kakoune/src make ./kak --------------------------------------------- See https://github.com/mawww/golf for Kakoune solutions to vimgolf challenges, regularly beating the best Vim solution. See the link:doc/design.asciidoc[design document] for more information on Kakoune philosophy and design. :numbered: Introduction ------------ Kakoune is a code editor that implements Vi's "keystrokes as a text editing language" model. As it's also a modal editor, it is somewhat similar to the Vim editor (after which Kakoune was originally inspired). Kakoune can operate in two modes, normal and insertion. In insertion mode, keys are directly inserted into the current buffer. In normal mode, keys are used to manipulate the current selection and to enter insertion mode. Kakoune has a strong focus on interactivity, most commands provide immediate and incremental results, while still being competitive (as in keystroke count) with Vim. Kakoune works on selections, which are oriented, inclusive range of characters, selections have an anchor and a cursor character. Most commands move both of them, except when extending selection where the anchor character stays fixed and the cursor one moves around. See https://vimeo.com/82711574 Join us on freenode IRC `#Kakoune` Features ~~~~~~~~ * Multiple selections as a central way of interacting * Powerful selection manipulation primitives - Select all regex matches in current selections - Keep selections containing/not containing a match for a given regex - Split current selections with a regex - Text objects (paragraph, sentence, nestable blocks) * Powerful text manipulation primitives - Align selections - Rotate selection contents - Case manipulation - Indentation - Piping each selection to external filter * Client-Server architecture - Multiple clients on the same editing session - Use tmux or your X11 window manager to manage windows * Simple interaction with external programs * Automatic contextual help * Automatic as you type completion * Macros * Hooks * Syntax Highlighting - Supports multiple languages in the same buffer - Highlight a buffer differently in different windows Screenshots ~~~~~~~~~~~ [[screenshot-i3]] .Kakoune in i3 image::doc/screenshot-i3.gif[Kakoune in i3] [[screenshot-tmux]] .Kakoune in tmux image::doc/screenshot-tmux.gif[Kakoune in tmux] Getting started --------------- Building ~~~~~~~~ Kakoune dependencies are: * A {cpp}17 compliant compiler (GCC >= 7 or clang >= 6) along with its associated {cpp} standard library (libstdc{pp} or libc{pp}) * ncurses with wide-characters support (>= 5.3, generally referred to as libncursesw) To build, just type *make* in the src directory. To generate man pages, type *make man* in the src directory. Kakoune can be built on Linux, MacOS, and Cygwin. Due to Kakoune relying heavily on being in a Unix-like environment, no native Windows version is planned. Installing ~~~~~~~~~~ In order to install kak on your system, rather than running it directly from its source directory, type *make install*, you can specify the `PREFIX` and `DESTDIR` if needed. [TIP] .Homebrew (macOS) or Linuxbrew ==== --------------------------------- brew install kakoune --------------------------------- ==== [TIP] .Fedora supported versions and Rawhide ==== --------------------------------- dnf install kakoune --------------------------------- ==== [TIP] .Fedora daily builds ==== Use the https://copr.fedoraproject.org/coprs/jkonecny/kakoune/[copr] repository. --------------------------------- dnf copr enable jkonecny/kakoune dnf install kakoune --------------------------------- ==== [TIP] .RHEL/CentOS 8 ==== Kakoune can be found in the https://src.fedoraproject.org/rpms/kakoune/tree/epel8[EPEL8 repositories]. --------------------------------- dnf install kakoune --------------------------------- ==== [TIP] .Arch Linux ==== Kakoune is found in the https://www.archlinux.org/packages/community/x86_64/kakoune/[repositories]. -------------------------------------------------- pacman -S kakoune -------------------------------------------------- ==== [TIP] .Gentoo ==== Kakoune is found in portage as https://packages.gentoo.org/packages/app-editors/kakoune[app-editors/kakoune] ==== [TIP] .Exherbo ==== -------------------------------- cave resolve -x repository/mawww cave resolve -x kakoune -------------------------------- ==== [TIP] .openSUSE ==== Kakoune can be found in the https://software.opensuse.org/package/kakoune[repositories]. --------------------------- sudo zypper install kakoune --------------------------- ==== [TIP] .Ubuntu ==== Building on Ubuntu 16.04 and 18.04. Make sure you have .local/bin in your path to make the kak binary available from your shell. ---------------------------------------------------------------- sudo apt install libncursesw5-dev pkg-config git clone https://github.com/mawww/kakoune.git && cd kakoune/src make PREFIX=$HOME/.local make install ---------------------------------------------------------------- ==== [TIP] .Debian ==== Kakoune can be found in Debian 9 (Stretch) and later releases. --------------------------- sudo apt install kakoune --------------------------- ==== [TIP] .FreeBSD ==== Kakoune is available in the official ports tree as https://www.freshports.org/editors/kakoune[editors/kakoune]. A binary package is also available and can be installed with -------------------------------------------------- pkg install kakoune -------------------------------------------------- ==== [TIP] .OpenBSD ==== Building on OpenBSD 6.7 amd64. -------------------------------------------------- # pkg_add git gmake # git clone https://github.com/mawww/kakoune # cd kakoune # export CXX=clang++ # gmake install -------------------------------------------------- Kakoune is available in the 6.7-current port tree as http://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/editors/kakoune/[editors/kakoune] A binary package is also available for -current snapshot and can be installed with -------------------------------------------------- # pkg_add kakoune -------------------------------------------------- Running with support for plugins. -------------------------------------------------- # pkg_add dash $ export KAKOUNE_POSIX_SHELL=/usr/local/bin/dash $ kak -------------------------------------------------- ==== [TIP] .Solus ==== Kakoune is available in the Solus stable repository. It can be installed with --------------------- eopkg install kakoune --------------------- ==== [TIP] .Void ==== Kakoune is available in the repositories. It can be installed with ----------------------- xbps-install -S kakoune ----------------------- ==== [TIP] .Termux ==== Kakoune is available in the repositories. It can be installed with ------------------- pkg install kakoune ------------------- ==== Running ~~~~~~~ Just running *kak* launches a new kak session with a client on local terminal. Run *kak -help* to discover the valid command line flags. Configuration ^^^^^^^^^^^^^ There are two directories containing Kakoune's scripts: * `runtime`: located in `../share/kak/` relative to the `kak` binary contains the system scripts, installed with Kakoune. * `userconf`: located in `$XDG_CONFIG_HOME/kak/`, which will fallback to `$HOME/.config/kak/` if `$XDG_CONFIG_HOME` is not set, containing the user configuration. Unless `-n` is specified, Kakoune will load its startup script located at `${runtime}/kakrc` relative to the `kak` binary. This startup script is responsible for loading the user configuration. First, Kakoune will search recursively for `.kak` files in the `autoload` directory. It will first look for an `autoload` directory at `${userconf}/autoload` and will fallback to `${runtime}/autoload` if it does not exist. Once all those files are loaded, Kakoune will try to source `${runtime}/kakrc.local` which is expected to contain distribution provided configuration. And finally, the user configuration will be loaded from `${userconf}/kakrc`. NOTE: If you create a user `autoload` directory in `${userconf}/autoload`, the system one at `${runtime}/autoload` will not be loaded anymore. You can add a symbolic link to it (or to individual scripts) inside `${userconf}/autoload` to keep loading system scripts. Basic Interaction ----------------- Selections ~~~~~~~~~~ The main concept in Kakoune is the selection. A selection is an inclusive, directed range of characters. A selection has two ends, the anchor and the cursor. There is always at least one selection, and a selection is always at least one character (in which case the anchor and cursor of the selections are on the same character). Normal Mode ~~~~~~~~~~~ In normal mode, keys are not inserted directly inside the buffer, but are editing commands. These commands provide ways to manipulate either the selections themselves, or the selected text. Insert Mode ~~~~~~~~~~~ When entering insert mode, keys are now directly inserted before each selection's cursor. Some additional keys are recognised in insert mode: * ``: leave insert mode * ``: delete characters before cursors * ``: delete characters under cursors * `, , , `: move the cursors in given direction * ``: move cursors to line begin * ``: move cursors to end of line * ``: select next completion candidate * ``: select previous completion candidate * ``: explicit insert completion query, followed by: - `f`: explicit file completion - `w`: explicit word completion - `l`: explicit line completion * ``: disable automatic completion for this insert session * ``: insert contents of the register given by next key * ``: insert next keystroke directly into the buffer, without interpreting it. * ``: commit changes up to now as a single undo group. * ``: escape to normal mode for a single command Movement ~~~~~~~~ See <> below for instructions on extending (appending to) the current selection, in order to select more text in multiple steps. * `h`: select the character on the left of selection end * `j`: select the character below the selection end * `k`: select the character above the selection end * `l`: select the character on the right of selection end * `w`: select the word and following whitespaces on the right of selection end * `b`: select preceding whitespaces and the word on the left of selection end * `e`: select preceding whitespaces and the word on the right of selection end * ``: same as [wbe] but select WORD instead of word * `f`: select to (including) the next occurrence of the given character * `t`: select until (excluding) the next occurrence of the given character * ``: same as [ft] but in the other direction * `m`: select to matching character * `M`: extend selection to matching character * `x`: select line on which selection end lies (or next line when end lies on an end-of-line) * `X`: similar to `x`, except the current selection is extended * ``: expand selections to contain full lines (including end-of-lines) * ``: trim selections to only contain full lines (not including last end-of-line) * `%`: select whole buffer * ``: select to line begin * ``: select to line end * `/`: search (select next match) * ``: search (select previous match) * `?`: search (extend to next match) * ``: search (extend to previous match) * `n`: select next match * `N`: add a new selection with next match * ``: select previous match * ``: add a new selection with previous match * `pageup, `: scroll one page up * `pagedown, `: scroll one page down * ``: scroll half a page up * ``: scroll half a page down * `)`: rotate selections (the main selection becomes the next one) * `(`: rotate selections backwards * `;`: reduce selections to their cursor * ``: flip the selections' direction * ``: ensure selections are in forward direction (cursor after anchor) * ``: repeat last object or `f`/`t` selection command. * `_`: trim selections A word is a sequence of alphanumeric characters or underscore, a WORD is a sequence of non whitespace characters. Appending ~~~~~~~~~ For most <> commands, using `Shift` extends the current selection instead of replacing it. Examples: * `wWW` selects 3 consecutive words: first `w` selects a word, then `WW` extends the selection two words further. * `f/F/` selects up to and including the second `/` character forward. Using Counts ~~~~~~~~~~~~ Most selection commands also support counts, which are entered before the command itself. For example, `3W` selects 3 consecutive words and `3w` select the third word on the right of selection end. Disabling Hooks ~~~~~~~~~~~~~~~ Any normal mode command can be prefixed with `\` which will disable hook execution for the duration for the command (including the duration of modes the command could move to, so `\i` will disable hooks for the whole insert session). As autoindentation is implemented in terms of hooks, this can be used to disable it when pasting text. Changes ~~~~~~~ * `i`: enter insert mode before current selection * `a`: enter insert mode after current selection * `d`: yank and delete current selection * `c`: yank and delete current selection and enter insert mode * `.`: repeat last insert mode change (`i`, `a`, or `c`, including the inserted text) * ``: delete current selection * ``: delete current selection and enter insert mode * `I`: enter insert mode at current selection begin line start * `A`: enter insert mode at current selection end line end * `o`: enter insert mode in one (or given count) new lines below current selection end * `O`: enter insert mode in one (or given count) new lines above current selection begin * ``: add an empty line below cursor * ``: add an empty line above cursor * `y`: yank selections * `p`: paste after current selection end * `P`: paste before current selection begin * ``: paste all after current selection end, and select each pasted string. * ``: paste all before current selection begin, and select each pasted string. * `R`: replace current selection with yanked text * ``: replace current selection with every yanked text * `r`: replace each character with the next entered one * ``: join selected lines * ``: join selected lines and select spaces inserted in place of line breaks * ``: merge contiguous selections together (works across lines as well) * ` (>)`: indent selected lines * ``: indent selected lines, including empty lines * ` (<)`: deindent selected lines * ``: deindent selected lines, do not remove incomplete indent (3 leading spaces when indent is 4) * `|`: pipe each selection through the given external filter program and replace the selection with it's output. * ``: pipe each selection through the given external filter program and ignore its output * `!`: insert command output before selection * ``: append command output after selection * `u`: undo last change * ``: move backward in history * `U`: redo last change * ``: move forward in history * `&`: align selection, align the cursor of selections by inserting spaces before the first character of the selection * ``: copy indent, copy the indentation of the main selection (or the count one if a count is given) to all other ones * ```: to lower case * `~`: to upper case * ````: swap case * `@`: convert tabs to spaces in current selections, uses the buffer tabstop option or the count parameter for tabstop. * ``: convert spaces to tabs in current selections, uses the buffer tabstop option or the count parameter for tabstop. * ``: rotate selections content, if specified, the count groups selections, so `3` rotate (1, 2, 3) and (3, 4, 6) independently. * ``: rotate selections content backwards Goto Commands ~~~~~~~~~~~~~ Commands beginning with `g` are used to goto certain position and or buffer. If a count is given prior to hitting `g`, `g` will jump to the given line. Using `G` will extend the selection rather than jump. See <>. View commands ~~~~~~~~~~~~~ Commands beginning with `v` permit to center or scroll the current view. Using `V` will lock view mode until `` is hit See <>. Marks ~~~~~ Current selections position can be saved in a register and restored later on. See <>. Jump list ~~~~~~~~~ Some commands, like the goto commands, buffer switch or search commands, push the previous selections to the client's jump list. See <>. Multi Selection ~~~~~~~~~~~~~~~ Kak was designed from the start to handle multiple selections. One way to get a multiselection is via the `s` key. For example, to change all occurrences of word 'roger' to word 'marcel' in a paragraph, here is what can be done: * select the paragraph with enough `X` * press `s` and enter roger, then enter * now paragraph selection was replaced with multiselection of each roger in the paragraph * press `c` and marcel to replace rogers with marcels A multiselection can also be obtained with `S`, which splits the current selection according to the regex entered. To split a comma separated list, use `S` then ', *' The regex syntax supported by Kakoune is the based on the ECMAScript script syntax and is described at <>. `s` and `S` share the search pattern with `/`, and hence entering an empty pattern uses the last one. As a convenience, `` allows you to split the current selections on line boundaries. To clear multiple selections, use `space`. To keep only the nth selection use `n` followed by `space`, in order to remove a selection, use ``. `` allows you to enter a regex and keep only the selections that contains a match for this regex. Using `` you can keep the selections not containing a match. `C` copies the current selection to the next line (or lines if a count is given) `` does the same to previous lines. `$` allows you to enter a shell command and pipe each selection to it. Selections whose shell command returns 0 will be kept, other will be dropped. Object Selection ~~~~~~~~~~~~~~~~ Objects are specific portions of text, like sentences, paragraphs, numbers… Kakoune offers many keys allowing you to select various text objects. See <>. Commands -------- When pressing `:` in normal mode, Kakoune will open a prompt to enter a command. Commands are used for non editing tasks, such as opening a buffer, writing the current one, quitting, etc. See <>. Basic Commands ~~~~~~~~~~~~~~ Some commands take an exclamation mark (`!`), which can be used to force the execution of the command (i.e. to quit a modified buffer, the command `q!` has to be used). Commands starting with horizontal whitespace (e.g. a space) will not be saved in the command history. * `cd []`: change the current directory to ``, or the home directory if unspecified * `doc `: display documentation about a topic. The completion list displays the available topics. * `e[dit][!] [ []]`: open buffer on file, go to given line and column. If file is already opened, just switch to this file. Use edit! to force reloading. * `w[rite][!] []`: write buffer to or use its name if filename is not given. If the file is write-protected, its permissions are temporarily changed to allow saving the buffer and restored afterwards when the write! command is used. * `w[rite]a[ll]`: write all buffers that are associated to a file. * `q[uit][!] []`: exit Kakoune, use quit! to force quitting even if there is some unsaved buffers remaining. If specified, the client exit status will be set to . * `w[a]q[!] []`: write the current buffer (or all buffers when `waq` is used) and quit. If specified, the client exit status will be set to . * `kill[!]`: terminate the current session, all the clients as well as the server, use kill! to ignore unsaved buffers * `b[uffer] `: switch to buffer * `b[uffer]n[ext]`: switch to the next buffer * `b[uffer]p[rev]`: switch to the previous buffer * `d[el]b[uf][!] []`: delete the buffer * `source `: execute commands in * `colorscheme `: load named colorscheme. * `rename-client `: set current client name * `rename-buffer `: set current buffer name * `rename-session `: set current session name * `echo [options] `: show in status line, with the following options: ** `-markup`: expand the markup strings in ** `-debug`: print the given text to the `\*debug*` buffer * `nop`: does nothing, but as with every other commands, arguments may be evaluated. So nop can be used for example to execute a shell command while being sure that it's output will not be interpreted by kak. `:%sh{ echo echo tchou }` will echo tchou in Kakoune, whereas `:nop %sh{ echo echo tchou }` will not, but both will execute the shell command. * `fail `: raise an error, uses as its description Multiple commands ~~~~~~~~~~~~~~~~~ Multiple commands can be separated either by new lines or by semicolons, as such a semicolon must be escaped with `\;` to be considered as a literal semicolon argument. String syntax and expansions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Values, options and shell context can be interpolated in strings. See <>. Configuration & Autoloading --------------------------- Kakrc ~~~~~ If not launched with the `-n` switch, Kakoune will source the `../share/kak/kakrc` file relative to the `kak` binary, which will source additional files: If the `$XDG_CONFIG_HOME/kak/autoload` directory exists, load every `*.kak` files in it, and load recursively any subdirectory. If it does not exist, falls back to the site wide autoload directory in `../share/kak/autoload/`. After that, if it exists, source the `$XDG_CONFIG_HOME/kak/kakrc` file which should be used for user configuration. In order to continue autoloading site-wide files with a local autoload directory, just add a symbolic link to `../share/kak/autoload/` into your local autoload directory. Color Schemes ~~~~~~~~~~~~~ Kakoune ships with some color schemes that are installed to `../share/kak/colors/`. If `$XDG_CONFIG_HOME/kak/colors/` is present the builtin command `colorscheme` will offer completion for those color schemes. If a scheme is duplicated in userspace, it will take precedence. Options ------- Kakoune can store named and typed values that can be used both to customize the core editor behaviour, and to keep data used by extension scripts. See <>. Advanced topics --------------- Faces ~~~~~ Faces describe how characters are displayed on the screen: color, bold, italic... See <>. Registers ~~~~~~~~~ Registers are named lists of text. They are used for various purposes, like storing the last yanked text, or the captured groups associated with the selections. See <>. Macros ~~~~~~ Kakoune can record and replay a sequence of key presses. See <>. Search selection ~~~~~~~~~~~~~~~~ Using the `*` key, you can set the search pattern to the current selection. See <>. Regex syntax ~~~~~~~~~~~~ Kakoune regex syntax is based on the ECMAScript syntax (ECMA-262 standard). It always runs on Unicode codepoint sequences, not on bytes. See <>. Exec and Eval ~~~~~~~~~~~~~ The `execute-keys` and `evaluate-commands` are useful for scripting in non interactive contexts. See <>. Insert mode completion ~~~~~~~~~~~~~~~~~~~~~~ Kakoune can propose completions while inserting text: filenames, words, lines… See <>. Escape to normal mode ~~~~~~~~~~~~~~~~~~~~~ From insert mode, pressing `` allows you to execute a single normal mode command. This provides a few advantages: * The selections are not modified: when leaving insert mode using `` the selections can change, for example when insert mode was entered with `a` the cursor will go back one char. Or if on an end of line the cursor will go back left (if possible). * The modes are nested: that means the normal mode can enter prompt (with `:`), or any other modes (using `:on-key` or `:menu` for example), and these modes will get back to the insert mode afterwards. This feature is tailored for scripting/macros, as it provides a more predictable behaviour than leaving insert mode with ``, executing normal mode command and entering back insert mode (with which binding ?) See <>. Highlighters ~~~~~~~~~~~~ Manipulation of the displayed text, such as syntax coloration and wrapping is done through highlighters. See <>. Hooks ~~~~~ Commands can be registered to be executed when certain events arise with hooks. See <>. Key Mapping ~~~~~~~~~~~ Custom key shortcuts can be registered through mappings. See <>. Defining Commands and Aliases ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ New commands can be created using `:define-command`. See <>. They can be given additional short names depending of the scope with `:alias`. See <>. Some helper commands are available to define composite commands. See <>. FIFO Buffers ~~~~~~~~~~~ FIFO buffers are very useful for running some commands asynchronously while progressively displaying their result in Kakoune. See <>. Menus ~~~~~ When a menu is displayed, you can use `j`, `` or `` to select the next entry, and `k`, `` or `` to select the previous one. Using the `/` key, you can enter some regex in order to restrict available choices to the matching ones. Credits ------- Thanks to https://github.com/p0nce[p0nce] for designing the https://github.com/mawww/kakoune/blob/master/doc/kakoune_logo.svg[Kakoune logo]. And thanks to all the https://github.com/mawww/kakoune/graphs/contributors[contributors] who help move the project forward! kakoune-2020.09.01/UNLICENSE000066400000000000000000000022741372342214000150150ustar00rootroot00000000000000This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. For more information, please refer to kakoune-2020.09.01/VIMTOKAK000066400000000000000000000043401372342214000147110ustar00rootroot00000000000000Vi(m) to Kakoune: ================= Kakoune is inspired heavily by Vim, it strives to be as efficient as Vim, more consistent and simpler. A big difference is that a lot of special features in Vim just become regular interactions of basic features in Kakoune. Operations and moves are reversed in Kakoune. First select whatever text you want to operate on, and then use an modifying operation. That makes things more consistent (Vim needs a separate x and d operation because of the operator -> move order, Kakoune only needs the d operation). That also allows more complex selections. delete a word: * vim: dw * kak: wd delete a character: * vim: x * kak: d or ;d (; reduces the selection to a single char) copy a line: * vim: yy * kak: xy global replace: * vim: :%s/word/replacement * kak: %swordcreplacement Explanation: '%' selects the entire buffer, 's' opens a prompt for a regex, validates the regex and replace the selection with one per matches (hence, all occurences of word are selected). 'c' deletes the selection contents and enter insert mode, replacement is typed and goes back to normal mode. Note that the Kakoune version is one key less, and is not a special feature per se, but just a nice way Kakoune features work together. replace in current curly braces block: * vim: viB:s/word/replacement * kak: Bswordcreplacement Here again, we need to rely on another Vim special feature, visual mode. join line with next: * vim: J * kak: alt-J delete to line end: * vim: d$ * kak: alt-ld or Gld some classic vim moves are not bound to the same key, this is due to Kakoune using shifted moves to append to selection, so moves that were bound to non alphabetic chars had to change. * % become m (for matching), however m will replace selection with the next block, if you want to get a selection from current point to next block end, you should use M ( clears the selection to one character) * 0 and $ became alt-h and alt-l. Another binding is gh and gl. :[gv]/re/cmd to emulate :g or :v, use % to select the whole buffer, alt-s to get one selection by line, and then alt-k or alt-K in order to keep only the selections matching (or not matching) the entered regex. kakoune-2020.09.01/colors/000077500000000000000000000000001372342214000150415ustar00rootroot00000000000000kakoune-2020.09.01/colors/base16.kak000066400000000000000000000050641372342214000166170ustar00rootroot00000000000000## ## base16.kak by lenormf ## evaluate-commands %sh{ black_lighterer='rgb:383838' black_lighter='rgb:2D2D2D' black_light='rgb:1C1C1C' cyan_light='rgb:7CB0FF' green_dark='rgb:A1B56C' grey_dark='rgb:585858' grey_light='rgb:D8D8D8' magenta_dark='rgb:AB4642' magenta_light='rgb:AB4434' orange_dark='rgb:DC9656' orange_light='rgb:F7CA88' purple_dark='rgb:BA8BAF' ## code echo " face global value ${orange_dark}+b face global type ${orange_light} face global variable ${magenta_dark} face global module ${green_dark} face global function ${cyan_light} face global string ${green_dark} face global keyword ${purple_dark}+b face global operator ${cyan_light} face global attribute ${orange_dark} face global comment ${grey_dark} face global documentation comment face global meta ${orange_light} face global builtin default+b " ## markup echo " face global title blue face global header ${cyan_light} face global mono ${green_dark} face global block ${orange_dark} face global link blue face global bullet ${magenta_light} face global list ${magenta_dark} " ## builtin echo " face global Default ${grey_light},${black_lighter} face global PrimarySelection white,blue+fg face global SecondarySelection black,blue+fg face global PrimaryCursor black,white+fg face global SecondaryCursor black,white+fg face global PrimaryCursorEol black,${cyan_light}+fg face global SecondaryCursorEol black,${cyan_light}+fg face global LineNumbers ${grey_light},${black_lighter} face global LineNumberCursor ${grey_light},rgb:282828+b face global MenuForeground ${grey_light},blue face global MenuBackground blue,${grey_light} face global MenuInfo ${cyan_light} face global Information ${black_light},${cyan_light} face global Error ${grey_light},${magenta_light} face global StatusLine ${grey_light},${black_lighterer} face global StatusLineMode ${orange_dark} face global StatusLineInfo ${cyan_light} face global StatusLineValue ${green_dark} face global StatusCursor ${black_lighterer},${cyan_light} face global Prompt ${black_light},${cyan_light} face global MatchingChar ${cyan_light},${black_light}+b face global BufferPadding ${cyan_light},${black_lighter} face global Whitespace ${grey_dark}+f " } kakoune-2020.09.01/colors/default.kak000066400000000000000000000027211372342214000171570ustar00rootroot00000000000000# Kakoune default color scheme # For Code face global value red face global type yellow face global variable green face global module green face global function cyan face global string magenta face global keyword blue face global operator yellow face global attribute green face global comment cyan face global documentation comment face global meta magenta face global builtin default+b # For markup face global title blue face global header cyan face global mono green face global block magenta face global link cyan face global bullet cyan face global list yellow # builtin faces face global Default default,default face global PrimarySelection white,blue+fg face global SecondarySelection black,blue+fg face global PrimaryCursor black,white+fg face global SecondaryCursor black,white+fg face global PrimaryCursorEol black,cyan+fg face global SecondaryCursorEol black,cyan+fg face global LineNumbers default,default face global LineNumberCursor default,default+r face global MenuForeground white,blue face global MenuBackground blue,white face global MenuInfo cyan face global Information black,yellow face global Error black,red face global StatusLine cyan,default face global StatusLineMode yellow,default face global StatusLineInfo blue,default face global StatusLineValue green,default face global StatusCursor black,cyan face global Prompt yellow,default face global MatchingChar default,default+b face global Whitespace default,default+f face global BufferPadding blue,default kakoune-2020.09.01/colors/desertex.kak000066400000000000000000000037071372342214000173630ustar00rootroot00000000000000# desertex theme # Code face global value rgb:fa8072 face global type rgb:dfdfbf face global identifier rgb:87ceeb face global string rgb:fa8072 face global error rgb:c3bf9f+b face global keyword rgb:eedc82 face global operator rgb:87ceeb face global attribute rgb:eedc82 face global comment rgb:7ccd7c+i face global documentation comment # #include <...> face global meta rgb:ee799f # Markup face global title blue face global header cyan face global mono green face global block magenta face global link cyan face global bullet cyan face global list yellow # Builtin # fg,bg+attributes # face global Default default,rgb:262626 <- change the terminal bg color instead face global Default default,default face global PrimarySelection white,blue+fg face global SecondarySelection black,blue+fg face global PrimaryCursor black,white+fg face global SecondaryCursor black,white+fg face global PrimaryCursorEol black,rgb:7ccd7c+fg face global SecondaryCursorEol black,rgb:7ccd7c+fg face global LineNumbers rgb:605958 face global LineNumberCursor yellow,default+b # Bottom menu: # text + background face global MenuBackground black,rgb:c2bfa5+b # selected entry in the menu (use 302028 when true color support is fixed) face global MenuForeground rgb:f0a0c0,magenta # completion menu info face global MenuInfo white,rgb:445599 # assistant, [+] face global Information black,yellow face global Error white,red face global StatusLine cyan,default # Status line modes and prompts: # insert, prompt, enter key... face global StatusLineMode rgb:ffd75f,default # 1 sel face global StatusLineInfo blue,default # param=value, reg=value. ex: "ey face global StatusLineValue green,default face global StatusCursor black,cyan # : face global Prompt blue # (), {} face global MatchingChar cyan+b # EOF tildas (~) face global BufferPadding blue,default # Whitespace characters face global Whitespace default+f kakoune-2020.09.01/colors/github.kak000066400000000000000000000030631372342214000170150ustar00rootroot00000000000000## ## github.kak by lenormf ## v1.0 ## ## code face global value rgb:0086B3+b face global type rgb:795DA3 face global variable rgb:0086B3 face global module rgb:0086B3 face global function rgb:A71D5D face global string rgb:183691 face global keyword rgb:A71D5D+b face global operator yellow face global attribute rgb:A71D5D face global comment rgb:AAAAAA face global documentation comment face global meta rgb:183691 face global builtin default+b ## markup face global title blue face global header cyan face global mono green face global block magenta face global link cyan face global bullet cyan face global list yellow ## builtin face global Default rgb:121213,rgb:F8F8FF face global PrimarySelection rgb:121213,rgb:A6F3A6+fg face global SecondarySelection rgb:121213,rgb:DBFFDB+fg face global PrimaryCursor rgb:121213,rgb:888888+fg face global SecondaryCursor rgb:121213,rgb:AAAAAA+fg face global PrimaryCursorEol rgb:121213,rgb:A71D5D+fg face global SecondaryCursorEol rgb:121213,rgb:A71D5D+fg face global LineNumbers rgb:A0A0A0,rgb:ECECEC face global LineNumberCursor rgb:434343,rgb:DDDDDD face global MenuForeground rgb:434343,rgb:CDCDFD face global MenuBackground rgb:F8F8FF,rgb:808080 face global Information rgb:F8F8FF,rgb:4078C0 face global Error rgb:F8F8FF,rgb:BD2C00 face global StatusLine rgb:434343,rgb:DDDDDD face global StatusCursor rgb:434343,rgb:CDCDFD face global Prompt rgb:F8F8FF,rgb:4078C0 face global MatchingChar rgb:F8F8FF,rgb:4078C0+b face global Search default,default+u face global BufferPadding rgb:A0A0A0,rgb:F8F8FF face global Whitespace rgb:A0A0A0+f kakoune-2020.09.01/colors/greyscale.kak000066400000000000000000000053451372342214000175160ustar00rootroot00000000000000# Greyscale: monochromatic grey-based light colorscheme evaluate-commands %sh{ grey_light_5="rgb:fafafa" grey_light_4="rgb:f5f5f5" grey_light_3="rgb:eeeeee" grey_light_2="rgb:e0e0e0" grey_light_1="rgb:bdbdbd" grey="rgb:9e9e9e" grey_dark_1="rgb:757575" grey_dark_2="rgb:616161" grey_dark_3="rgb:424242" grey_dark_4="rgb:212121" cat <<- EOF # For Code set-face global keyword ${grey_dark_2} set-face global attribute ${grey_dark_2} set-face global type ${grey_dark_2} set-face global string ${grey_dark_1} set-face global value ${grey_dark_1}+b set-face global meta ${grey_dark_1} set-face global builtin ${grey}+b set-face global module ${grey_dark_1} set-face global comment ${grey}+i set-face global documentation comment set-face global function Default set-face global operator Default set-face global variable Default # For markup set-face global title ${grey_dark_2}+b set-face global header ${grey_dark_2} set-face global block ${grey_dark_1} set-face global mono ${grey_dark_1} set-face global link ${grey}+u set-face global list Default set-face global bullet +b # Built-in faces set-face global Default ${grey},${grey_light_2} set-face global PrimarySelection ${grey_light_3},${grey_dark_4}+fg set-face global SecondarySelection ${grey_light_2},${grey_dark_3}+fg set-face global PrimaryCursor ${grey_light_3},${grey_dark_1}+fg set-face global SecondaryCursor ${grey_light_3},${grey}+fg set-face global PrimaryCursorEol ${grey_light_1},${grey_dark_2}+fg set-face global SecondaryCursorEol ${grey_light_2},${grey_dark_1}+fg set-face global StatusLine ${grey_dark_3},${grey_light_1} set-face global StatusLineMode ${grey_light_2},${grey_dark_3} set-face global StatusLineInfo ${grey_light_2},${grey_dark_2} set-face global StatusLineValue ${grey_light_3},${grey_dark_2}+b set-face global StatusCursor ${grey_light_3},${grey} set-face global Prompt ${grey_light_2},${grey_dark_3} set-face global MenuForeground ${grey_light_4},${grey} set-face global MenuBackground ${grey_dark_2},${grey_light_3} set-face global MenuInfo ${grey}+i set-face global LineNumbers ${grey_light_5},${grey_dark_1} set-face global LineNumbersWrapped ${grey_light_2},${grey_dark_2}+i set-face global LineNumberCursor ${grey_light_2},${grey_dark_3}+b set-face global MatchingChar ${grey_dark_4},${grey_light_1} set-face global Whitespace ${grey_light_1}+f set-face global WrapMarker ${grey_light_1}+f set-face global Information ${grey_light_2},${grey_dark_2} set-face global Error ${grey_light_2},${grey_dark_3} set-face global BufferPadding ${grey_light_1} EOF } kakoune-2020.09.01/colors/gruvbox.kak000066400000000000000000000051201372342214000172230ustar00rootroot00000000000000# gruvbox theme evaluate-commands %sh{ gray="rgb:928374" red="rgb:fb4934" green="rgb:b8bb26" yellow="rgb:fabd2f" blue="rgb:83a598" purple="rgb:d3869b" aqua="rgb:8ec07c" orange="rgb:fe8019" bg="rgb:282828" bg_alpha="rgba:282828a0" bg1="rgb:3c3836" bg2="rgb:504945" bg3="rgb:665c54" bg4="rgb:7c6f64" fg="rgb:ebdbb2" fg_alpha="rgba:ebdbb2a0" fg0="rgb:fbf1c7" fg2="rgb:d5c4a1" fg3="rgb:bdae93" fg4="rgb:a89984" echo " # Code highlighting face global value ${purple} face global type ${yellow} face global variable ${blue} face global module ${green} face global function ${fg} face global string ${green} face global keyword ${red} face global operator ${fg} face global attribute ${orange} face global comment ${gray}+i face global documentation comment face global meta ${aqua} face global builtin ${fg}+b # Markdown highlighting face global title ${green}+b face global header ${orange} face global mono ${fg4} face global block ${aqua} face global link ${blue}+u face global bullet ${yellow} face global list ${fg} face global Default ${fg},${bg} face global PrimarySelection ${fg_alpha},${blue}+g face global SecondarySelection ${bg_alpha},${blue}+g face global PrimaryCursor ${bg},${fg}+fg face global SecondaryCursor ${bg},${bg4}+fg face global PrimaryCursorEol ${bg},${fg4}+fg face global SecondaryCursorEol ${bg},${bg2}+fg face global LineNumbers ${bg4} face global LineNumberCursor ${yellow},${bg1} face global LineNumbersWrapped ${bg1} face global MenuForeground ${bg2},${blue} face global MenuBackground ${fg},${bg2} face global MenuInfo ${bg} face global Information ${bg},${fg} face global Error ${bg},${red} face global StatusLine ${fg},${bg} face global StatusLineMode ${yellow}+b face global StatusLineInfo ${purple} face global StatusLineValue ${red} face global StatusCursor ${bg},${fg} face global Prompt ${yellow} face global MatchingChar ${fg},${bg3}+b face global BufferPadding ${bg2},${bg} face global Whitespace ${bg2}+f " } kakoune-2020.09.01/colors/kaleidoscope-dark.kak000066400000000000000000000103501372342214000211110ustar00rootroot00000000000000# Kaleidoscope: colorblind-friendly dark colorscheme # https://personal.sron.nl/~pault/ evaluate-commands %sh{ # NOTE: tone down black and white for aesthetics, # ideally those should be pure #000 and #FFF black="rgb:303030" white="rgb:FDFDFD" # Regular text bright_blue="rgb:4477AA" bright_cyan="rgb:66CCEE" bright_green="rgb:228833" bright_yellow="rgb:CCBB44" bright_red="rgb:EE6677" bright_purple="rgb:AA3377" bright_grey="rgb:BBBBBB" # Emphasis high_contrast_blue="rgb:004488" high_contrast_yellow="rgb:DDAA33" high_contrast_red="rgb:BB5566" # High contrast alternative text vibrant_orange="rgb:EE7733" vibrant_blue="rgb:0077BB" vibrant_cyan="rgb:33BBEE" vibrant_magenta="rgb:EE3377" vibrant_red="rgb:CC3311" vibrant_teal="rgb:009988" vibrant_grey="rgb:BBBBBB" # Darker text with no red muted_rose="rgb:CC6677" muted_indigo="rgb:332288" muted_sand="rgb:DDCC77" muted_green="rgb:117733" muted_cyan="rgb:88CCEE" muted_wine="rgb:882255" muted_teal="rgb:44AA99" muted_olive="rgb:999933" muted_purple="rgb:AA4499" muted_pale_grey="rgb:DDDDDD" # Low contrast background colors light_blue="rgb:77AADD" light_orange="rgb:EE8866" light_yellow="rgb:EEDD88" light_pink="rgb:FFAABB" light_cyan="rgb:99DDFF" light_mint="rgb:44BB99" light_pear="rgb:BBCC33" light_olive="rgb:AAAA00" light_grey="rgb:DDDDDD" # Pale background colors, black foreground pale_blue="rgb:BBCCEE" pale_cyan="rgb:CCEEFF" pale_green="rgb:CCDDAA" pale_yellow="rgb:EEEEBB" pale_red="rgb:FFCCCC" pale_grey="rgb:DDDDDD" # Dark background colors, white foreground dark_blue="rgb:222255" dark_cyan="rgb:225555" dark_green="rgb:225522" dark_yellow="rgb:666633" dark_red="rgb:663333" dark_grey="rgb:555555" # NOTE: Do not use any color that hasn't been defined above (no hardcoding) cat <<- EOF # For Code set-face global keyword ${vibrant_blue} set-face global attribute ${muted_purple} set-face global type ${vibrant_blue} set-face global string ${muted_rose} set-face global value ${light_pink} set-face global meta ${light_olive} set-face global builtin ${vibrant_blue}+b set-face global module ${vibrant_orange} set-face global comment ${bright_green}+i set-face global documentation comment set-face global function Default set-face global operator Default set-face global variable Default # For markup set-face global title ${vibrant_blue}+b set-face global header ${muted_cyan} set-face global block ${vibrant_magenta} set-face global mono ${vibrant_magenta} set-face global link ${bright_cyan}+u set-face global list Default set-face global bullet +b # Built-in faces set-face global Default ${white},${black} set-face global PrimarySelection ${black},${pale_blue}+fg set-face global SecondarySelection ${black},${pale_cyan}+fg set-face global PrimaryCursor ${white},${high_contrast_blue}+fg set-face global SecondaryCursor ${white},${dark_cyan}+fg set-face global PrimaryCursorEol ${black},${vibrant_grey}+fg set-face global SecondaryCursorEol ${black},${pale_grey}+fg set-face global StatusLine ${black},${vibrant_grey} set-face global StatusLineMode ${black},${light_blue} set-face global StatusLineInfo ${black},${light_yellow} set-face global StatusLineValue ${high_contrast_red},${light_yellow}+b set-face global StatusCursor ${black},${light_orange} set-face global Prompt ${black},${light_yellow} set-face global MenuForeground ${black},${light_yellow} set-face global MenuBackground ${black},${pale_grey} set-face global MenuInfo ${vibrant_blue}+i set-face global LineNumbers ${white},${dark_grey} set-face global LineNumbersWrapped ${black},${vibrant_grey}+i set-face global LineNumberCursor ${black},${pale_grey}+b set-face global MatchingChar ${black},${vibrant_grey} set-face global Whitespace ${dark_grey}+f set-face global WrapMarker ${dark_grey}+f set-face global Information ${black},${light_yellow} set-face global Error ${white},${vibrant_red} set-face global BufferPadding ${dark_grey} EOF } kakoune-2020.09.01/colors/kaleidoscope-light.kak000066400000000000000000000103471372342214000213050ustar00rootroot00000000000000# Kaleidoscope: colorblind-friendly light colorscheme # https://personal.sron.nl/~pault/ evaluate-commands %sh{ # NOTE: tone down black and white for aesthetics, # ideally those should be pure #000 and #FFF black="rgb:1C1C1C" white="rgb:FDFDFD" # Regular text bright_blue="rgb:4477AA" bright_cyan="rgb:66CCEE" bright_green="rgb:228833" bright_yellow="rgb:CCBB44" bright_red="rgb:EE6677" bright_purple="rgb:AA3377" bright_grey="rgb:BBBBBB" # Emphasis high_contrast_blue="rgb:004488" high_contrast_yellow="rgb:DDAA33" high_contrast_red="rgb:BB5566" # High contrast alternative text vibrant_orange="rgb:EE7733" vibrant_blue="rgb:0077BB" vibrant_cyan="rgb:33BBEE" vibrant_magenta="rgb:EE3377" vibrant_red="rgb:CC3311" vibrant_teal="rgb:009988" vibrant_grey="rgb:BBBBBB" # Darker text with no red muted_rose="rgb:CC6677" muted_indigo="rgb:332288" muted_sand="rgb:DDCC77" muted_green="rgb:117733" muted_cyan="rgb:88CCEE" muted_wine="rgb:882255" muted_teal="rgb:44AA99" muted_olive="rgb:999933" muted_purple="rgb:AA4499" muted_pale_grey="rgb:DDDDDD" # Low contrast background colors light_blue="rgb:77AADD" light_orange="rgb:EE8866" light_yellow="rgb:EEDD88" light_pink="rgb:FFAABB" light_cyan="rgb:99DDFF" light_mint="rgb:44BB99" light_pear="rgb:BBCC33" light_olive="rgb:AAAA00" light_grey="rgb:DDDDDD" # Pale background colors, black foreground pale_blue="rgb:BBCCEE" pale_cyan="rgb:CCEEFF" pale_green="rgb:CCDDAA" pale_yellow="rgb:EEEEBB" pale_red="rgb:FFCCCC" pale_grey="rgb:DDDDDD" # Dark background colors, white foreground dark_blue="rgb:222255" dark_cyan="rgb:225555" dark_green="rgb:225522" dark_yellow="rgb:666633" dark_red="rgb:663333" dark_grey="rgb:555555" # NOTE: Do not use any color that hasn't been defined above (no hardcoding) cat <<- EOF # For Code set-face global keyword ${muted_indigo} set-face global attribute ${muted_purple} set-face global type ${vibrant_blue} set-face global string ${muted_wine} set-face global value ${muted_rose} set-face global meta ${muted_olive} set-face global builtin ${muted_indigo}+b set-face global module ${vibrant_orange} set-face global comment ${muted_green}+i set-face global documentation comment set-face global function Default set-face global operator Default set-face global variable Default # For markup set-face global title ${muted_indigo}+b set-face global header ${high_contrast_blue} set-face global block ${vibrant_magenta} set-face global mono ${vibrant_red} set-face global link ${vibrant_blue}+u set-face global list Default set-face global bullet +b # Built-in faces set-face global Default ${black},${white} set-face global PrimarySelection ${black},${pale_blue}+fg set-face global SecondarySelection ${black},${pale_cyan}+fg set-face global PrimaryCursor ${white},${dark_blue}+fg set-face global SecondaryCursor ${white},${dark_cyan}+fg set-face global PrimaryCursorEol ${white},${dark_grey}+fg set-face global SecondaryCursorEol ${white},${vibrant_grey}+fg set-face global StatusLine ${white},${dark_grey} set-face global StatusLineMode ${black},${pale_blue} set-face global StatusLineInfo ${black},${muted_sand} set-face global StatusLineValue ${vibrant_orange},${muted_sand}+b set-face global StatusCursor ${black},${high_contrast_yellow} set-face global Prompt ${black},${muted_sand} set-face global MenuForeground ${black},${muted_sand} set-face global MenuBackground ${black},${pale_grey} set-face global MenuInfo ${high_contrast_blue}+i set-face global LineNumbers ${black},${pale_grey} set-face global LineNumbersWrapped ${black},${vibrant_grey}+i set-face global LineNumberCursor ${white},${dark_grey}+b set-face global MatchingChar ${white},${dark_grey} set-face global Whitespace ${vibrant_grey}+f set-face global WrapMarker ${vibrant_grey}+f set-face global Information ${black},${muted_sand} set-face global Error ${white},${vibrant_red} set-face global BufferPadding ${vibrant_grey} EOF } kakoune-2020.09.01/colors/lucius.kak000066400000000000000000000063311372342214000170400ustar00rootroot00000000000000# lucius theme evaluate-commands %sh{ # first we define the lucius colors as named colors lucius_darker_grey="rgb:303030" lucius_dark_grey="rgb:444444" lucius_grey="rgb:808080" lucius_light_grey="rgb:b2b2b2" lucius_lighter_grey="rgb:d7d7d7" lucius_dark_red="rgb:870000" lucius_light_red="rgb:ff8787" lucius_orange="rgb:d78700" lucius_purple="rgb:d7afd7" lucius_dark_green="rgb:5f875f" lucius_bright_green="rgb:87af00" lucius_green="rgb:afd787" lucius_light_green="rgb:d7d7af" lucius_dark_blue="rgb:005f87" lucius_blue="rgb:87afd7" lucius_light_blue="rgb:87d7ff" echo " # then we map them to code face global value ${lucius_light_green} face global type ${lucius_blue} face global variable ${lucius_green} face global module ${lucius_green} face global function ${lucius_light_blue} face global string ${lucius_light_green} face global keyword ${lucius_light_blue} face global operator ${lucius_green} face global attribute ${lucius_light_blue} face global comment ${lucius_grey} face global documentation comment face global meta ${lucius_purple} face global builtin default+b # and markup face global title ${lucius_light_blue} face global header ${lucius_light_green} face global mono ${lucius_light_green} face global block ${lucius_light_blue} face global link ${lucius_light_green} face global bullet ${lucius_green} face global list ${lucius_blue} # and built in faces face global Default ${lucius_lighter_grey},${lucius_darker_grey} face global PrimarySelection ${lucius_darker_grey},${lucius_orange}+fg face global SecondarySelection ${lucius_lighter_grey},${lucius_dark_blue}+fg face global PrimaryCursor ${lucius_darker_grey},${lucius_lighter_grey}+fg face global SecondaryCursor ${lucius_darker_grey},${lucius_lighter_grey}+fg face global PrimaryCursorEol ${lucius_darker_grey},${lucius_dark_green}+fg face global SecondaryCursorEol ${lucius_darker_grey},${lucius_dark_green}+fg face global LineNumbers ${lucius_grey},${lucius_dark_grey} face global LineNumberCursor ${lucius_grey},${lucius_dark_grey}+b face global MenuForeground ${lucius_blue},${lucius_dark_blue} face global MenuBackground ${lucius_darker_grey},${lucius_light_grey} face global MenuInfo ${lucius_grey} face global Information ${lucius_lighter_grey},${lucius_dark_green} face global Error ${lucius_light_red},${lucius_dark_red} face global StatusLine ${lucius_lighter_grey},${lucius_dark_grey} face global StatusLineMode ${lucius_lighter_grey},${lucius_dark_green}+b face global StatusLineInfo ${lucius_dark_grey},${lucius_lighter_grey} face global StatusLineValue ${lucius_lighter_grey} face global StatusCursor default,${lucius_blue} face global Prompt ${lucius_lighter_grey} face global MatchingChar ${lucius_lighter_grey},${lucius_bright_green} face global BufferPadding ${lucius_green},${lucius_darker_grey} face global Whitespace ${lucius_grey}+f " } kakoune-2020.09.01/colors/palenight.kak000066400000000000000000000054271372342214000175140ustar00rootroot00000000000000# palenight theme # This was ported from https://github.com/drewtempelmeyer/palenight.vim evaluate-commands %sh{ red=rgb:ff5370 light_red=rgb:ff869a dark_red=rgb:be5046 green=rgb:c3e88d yellow=rgb:ffcb6b dark_yellow=rgb:f78c6c blue=rgb:82b1ff purple=rgb:c792ea cyan=rgb:89ddff white=rgb:bfc7d5 black=rgb:292d3e comment_grey=rgb:697098 gutter_fg_grey=rgb:4b5263 cursor_grey=rgb:2c323c visual_grey=rgb:3e4452 menu_grey=rgb:697098 special_grey=rgb:3b4048 vertsplit=rgb:181a1f visual_black=default printf "%s\n" " # Code face global value $dark_yellow face global type $yellow face global function $blue face global variable $blue face global identifier $blue face global string $green face global error rgb:c3bf9f+b face global keyword $purple face global operator $cyan face global attribute rgb:eedc82 face global comment $comment_grey+i face global documentation comment # #include <...> face global meta $yellow # Markup face global title $blue face global header $cyan face global mono $green face global block $purple face global link $cyan face global bullet $cyan face global list $yellow # Builtin face global Default $white,$black face global PrimarySelection $black,$white+bfg face global SecondarySelection $black,$white+fg face global PrimaryCursor white,$purple+bfg face global SecondaryCursor $black,$purple+fg face global PrimaryCursorEol $black,$green+fg face global SecondaryCursorEol $black,$green+fg face global LineNumbers $gutter_fg_grey face global LineNumberCursor $yellow,default+b # Bottom menu: # text + background face global MenuBackground $black,$white face global MenuForeground $black,$purple # completion menu info face global MenuInfo $menu_grey,default+i # assistant, [+] face global Information $white,$visual_grey face global Error $white,$red face global StatusLine $white,$black # Status line face global StatusLineMode $black,$purple # insert, prompt, enter key ... face global StatusLineInfo $white,$visual_grey # 1 sel face global StatusLineValue $visual_grey,$green # param=value, reg=value. ex: \"ey face global StatusCursor white,$purple+bg face global Prompt $purple,$black # : face global MatchingChar $red+b # (), {} face global BufferPadding $gutter_fg_grey,$black # EOF tildas (~) # Whitespace characters face global Whitespace $gutter_fg_grey,$black+fg " } kakoune-2020.09.01/colors/plain.kak000066400000000000000000000024701372342214000166370ustar00rootroot00000000000000# Kakoune simple colors, mostly default # For default face global value default face global type default face global identifier default face global string blue face global keyword default face global operator default face global attribute default face global comment blue face global documentation comment face global meta default face global builtin default # For default face global title default face global header default face global mono default face global block default face global link blue face global bullet default face global list default # builtin default face global Default default,default face global PrimarySelection white,blue face global SecondarySelection black,blue face global PrimaryCursor black,white face global SecondaryCursor white,blue face global PrimaryCursorEol default face global SecondaryCursorEol default face global LineNumbers default face global LineNumberCursor default face global MenuForeground default face global MenuBackground default face global MenuInfo default face global Information default face global Error default face global StatusLine default face global StatusLineMode default face global StatusLineInfo default face global StatusLineValue default face global StatusCursor default+r face global Prompt default face global MatchingChar default face global BufferPadding default kakoune-2020.09.01/colors/red-phoenix.kak000066400000000000000000000051771372342214000177650ustar00rootroot00000000000000## ## Red Phoenix (dkeg) - adapted by boj ## evaluate-commands %sh{ black="rgb:000000" blue="rgb:81a2be" orange1="rgb:F2361E" orange2="rgb:ED4B19" orange3="rgb:FA390F" light_orange1="rgb:DF9767" white1="rgb:EDEDED" white2="rgb:E1E1E1" gray1="rgb:6F6F6F" gray2="rgb:D1D1D1" gray3="rgb:2D2D2D" gray4="rgb:909090" tan1="rgb:D2C3AD" tan2="rgb:AAA998" tan3="rgb:DF9767" yellow1="rgb:AAA998" purple1="rgb:4C3A3D" foreground=${white1} background=${black} selection=${purple1} window=${gray3} text=${white2} text_light=${white1} line=${tan1} comment=${gray1} ## code echo " face global value ${orange2} face global type ${gray2} face global variable ${orange1} face global module ${gray2} face global function ${yellow1} face global string ${tan2} face global keyword ${light_orange1} face global operator ${yellow1} face global attribute ${tan1} face global comment ${gray1} face global documentation comment face global meta ${gray2} face global builtin ${tan1} " ## markup echo " face global title blue face global header ${orange1} face global mono ${yellow1} face global block ${tan1} face global link blue face global bullet ${gray1} face global list ${gray1} " ## builtin echo " face global Default ${text},${background} face global PrimarySelection default,${selection}+fg face global SecondarySelection default,${selection}+fg face global PrimaryCursor black,${tan1}+fg face global SecondaryCursor black,${tan2}+fg face global PrimaryCursorEol black,${orange1}+fg face global SecondaryCursorEol black,${orange2}+fg face global LineNumbers ${text_light},${background} face global LineNumberCursor ${text},${gray1}+b face global MenuForeground ${text_light},blue face global MenuBackground ${orange1},${window} face global MenuInfo ${gray1} face global Information white,${window} face global Error white,${gray1} face global StatusLine ${text},${window} face global StatusLineMode ${yellow1}+b face global StatusLineInfo ${orange2} face global StatusLineValue ${orange2} face global StatusCursor ${window},${orange2} face global Prompt ${background},${orange2} face global MatchingChar ${orange3},${background}+b face global BufferPadding ${orange2},${background} face global Whitespace default+f " } kakoune-2020.09.01/colors/reeder.kak000066400000000000000000000055451372342214000170100ustar00rootroot00000000000000## ## reeder theme ## a light theme inspired after https://github.com/hyspace/st2-reeder-theme ## evaluate-commands %sh{ white="rgb:f9f8f6" white_light="rgb:f6f5f0" black="rgb:383838" black_light="rgb:635240" grey_dark="rgb:c6b0a4" grey_light="rgb:e8e8e8" brown_dark="rgb:af4609" brown_light="rgb:baa188" brown_lighter="rgb:f0e7df" orange="rgb:fc7302" orange_light="rgb:f88e3b" green="rgb:438047" green_light="rgb:7ba84d" red="rgb:f03c3c" # Base color definitions echo " # then we map them to code face global value ${orange_light}+b face global type ${orange} face global variable default face global module ${green} face global function default face global string ${green} face global keyword ${brown_dark} face global operator default face global attribute ${green} face global comment ${brown_light} face global documentation comment face global meta ${brown_dark} face global builtin default+b # and markup face global title ${orange}+b face global header ${orange}+b face global mono ${green_light} face global block ${green} face global link ${orange} face global bullet ${brown_dark} face global list ${black} # and built in faces face global Default ${black_light},${white} face global PrimarySelection ${black},${brown_lighter}+fg face global SecondarySelection ${black_light},${grey_light}+fg face global PrimaryCursor ${black},${grey_dark}+fg face global SecondaryCursor ${black},${grey_dark}+fg face global PrimaryCursorEol ${black},${brown_dark}+fg face global SecondaryCursorEol ${black},${brown_dark}+fg face global LineNumbers ${grey_dark},${white} face global LineNumberCursor ${grey_dark},${brown_lighter} face global MenuForeground ${orange},${brown_lighter} face global MenuBackground ${black_light},${brown_lighter} face global MenuInfo default,${black} face global Information ${black_light},${brown_lighter} face global Error default,${red} face global StatusLine ${black},${grey_light} face global StatusLineMode ${orange} face global StatusLineInfo ${black}+b face global StatusLineValue ${green_light} face global StatusCursor ${orange},${white_light} face global Prompt ${black_light} face global MatchingChar default+b face global BufferPadding ${grey_dark},${white} face global Whitespace ${grey_dark}+f " } kakoune-2020.09.01/colors/solarized-dark-termcolors.kak000066400000000000000000000040631372342214000226360ustar00rootroot00000000000000# Solarized Dark (with termcolors) # Useful if you've set up your terminal with the exact Solarized colors # code face global value cyan face global type yellow face global variable blue face global module cyan face global function blue face global string cyan face global keyword green face global operator green face global attribute bright-magenta face global comment bright-green face global documentation comment face global meta bright-red face global builtin default+b # markup face global title blue+b face global header blue face global mono bright-cyan face global block cyan face global link bright-cyan face global bullet yellow face global list green # builtin face global Default bright-blue,bright-black face global PrimarySelection bright-black,blue+fg face global SecondarySelection bright-green,bright-cyan+fg face global PrimaryCursor bright-black,bright-blue+fg face global SecondaryCursor bright-black,bright-green+fg face global PrimaryCursorEol bright-black,white+fg face global SecondaryCursorEol bright-black,bright-white+fg face global LineNumbers bright-green,black face global LineNumberCursor bright-cyan,black face global LineNumbersWrapped black,black face global MenuForeground bright-black,yellow face global MenuBackground bright-cyan,black face global MenuInfo bright-green face global Information black,bright-cyan face global Error red,default+b face global StatusLine bright-cyan,black+b face global StatusLineMode bright-red face global StatusLineInfo cyan face global StatusLineValue green face global StatusCursor bright-yellow,bright-white face global Prompt yellow+b face global MatchingChar red,bright-green+b face global BufferPadding bright-green,bright-black face global Whitespace blue+f kakoune-2020.09.01/colors/solarized-dark.kak000066400000000000000000000053031372342214000204450ustar00rootroot00000000000000# Solarized Dark evaluate-commands %sh{ base03='rgb:002b36' base02='rgb:073642' base01='rgb:586e75' base00='rgb:657b83' base0='rgb:839496' base1='rgb:93a1a1' base2='rgb:eee8d5' base3='rgb:fdf6e3' yellow='rgb:b58900' orange='rgb:cb4b16' red='rgb:dc322f' magenta='rgb:d33682' violet='rgb:6c71c4' blue='rgb:268bd2' cyan='rgb:2aa198' green='rgb:859900' echo " # code face global value ${cyan} face global type ${red} face global variable ${blue} face global module ${cyan} face global function ${blue} face global string ${cyan} face global keyword ${green} face global operator ${yellow} face global attribute ${violet} face global comment ${base01} face global documentation comment face global meta ${orange} face global builtin default+b # markup face global title ${blue}+b face global header ${blue} face global mono ${base1} face global block ${cyan} face global link ${base1} face global bullet ${yellow} face global list ${green} # builtin face global Default ${base0},${base03} face global PrimarySelection ${base03},${blue}+fg face global SecondarySelection ${base01},${base1}+fg face global PrimaryCursor ${base03},${base0}+fg face global SecondaryCursor ${base03},${base01}+fg face global PrimaryCursorEol ${base03},${base2}+fg face global SecondaryCursorEol ${base03},${base3}+fg face global LineNumbers ${base01},${base02} face global LineNumberCursor ${base1},${base02} face global LineNumbersWrapped ${base02},${base02} face global MenuForeground ${base03},${yellow} face global MenuBackground ${base1},${base02} face global MenuInfo ${base01} face global Information ${base02},${base1} face global Error ${red},default+b face global StatusLine ${base1},${base02}+b face global StatusLineMode ${orange} face global StatusLineInfo ${cyan} face global StatusLineValue ${green} face global StatusCursor ${base00},${base3} face global Prompt ${yellow}+b face global MatchingChar ${red},${base01}+b face global BufferPadding ${base01},${base03} face global Whitespace ${base01}+f " } kakoune-2020.09.01/colors/solarized-light-termcolors.kak000066400000000000000000000040551372342214000230250ustar00rootroot00000000000000# Solarized Light (with termcolors) # Useful if you've set up your terminal with the exact Solarized colors # code face global value cyan face global type red face global variable blue face global module cyan face global function blue face global string cyan face global keyword green face global operator yellow face global attribute bright-magenta face global comment bright-cyan face global documentation comment face global meta bright-red face global builtin default+b # markup face global title blue+b face global header blue face global mono bright-cyan face global block cyan face global link bright-green face global bullet yellow face global list green # builtin face global Default bright-yellow,bright-white face global PrimarySelection bright-white,blue+fg face global SecondarySelection bright-cyan,bright-green+fg face global PrimaryCursor bright-white,bright-yellow+fg face global SecondaryCursor bright-white,bright-cyan+fg face global PrimaryCursorEol bright-white,yellow+fg face global SecondaryCursorEol bright-white,bright-red+fg face global LineNumbers bright-cyan,white face global LineNumberCursor bright-green,white face global LineNumbersWrapped white,white face global MenuForeground bright-white,yellow face global MenuBackground bright-green,white face global MenuInfo bright-cyan face global Information white,bright-cyan face global Error red,default+b face global StatusLine bright-green,white+b face global StatusLineMode bright-red face global StatusLineInfo cyan face global StatusLineValue green face global StatusCursor bright-blue,bright-black face global Prompt yellow+b face global MatchingChar red,white+b face global BufferPadding bright-cyan,bright-white face global Whitespace yellow+f kakoune-2020.09.01/colors/solarized-light.kak000066400000000000000000000052671372342214000206440ustar00rootroot00000000000000# Solarized Light evaluate-commands %sh{ base03='rgb:002b36' base02='rgb:073642' base01='rgb:586e75' base00='rgb:657b83' base0='rgb:839496' base1='rgb:93a1a1' base2='rgb:eee8d5' base3='rgb:fdf6e3' yellow='rgb:b58900' orange='rgb:cb4b16' red='rgb:dc322f' magenta='rgb:d33682' violet='rgb:6c71c4' blue='rgb:268bd2' cyan='rgb:2aa198' green='rgb:859900' echo " # code face global value ${cyan} face global type ${red} face global variable ${blue} face global module ${cyan} face global function ${blue} face global string ${cyan} face global keyword ${green} face global operator ${yellow} face global attribute ${violet} face global comment ${base1} face global documentation comment face global meta ${orange} face global builtin default+b # markup face global title ${blue}+b face global header ${blue} face global mono ${base1} face global block ${cyan} face global link ${base01} face global bullet ${yellow} face global list ${green} # builtin face global Default ${base00},${base3} face global PrimarySelection ${base3},${blue}+fg face global SecondarySelection ${base1},${base01}+fg face global PrimaryCursor ${base3},${base00}+fg face global SecondaryCursor ${base3},${base1}+fg face global PrimaryCursorEol ${base3},${yellow}+fg face global SecondaryCursorEol ${base3},${orange}+fg face global LineNumbers ${base1},${base2} face global LineNumberCursor ${base01},${base2} face global LineNumbersWrapped ${base2},${base2} face global MenuForeground ${base3},${yellow} face global MenuBackground ${base01},${base2} face global MenuInfo ${base1} face global Information ${base2},${base1} face global Error ${red},default+b face global StatusLine ${base01},${base2}+b face global StatusLineMode ${orange} face global StatusLineInfo ${cyan} face global StatusLineValue ${green} face global StatusCursor ${base0},${base03} face global Prompt ${yellow}+b face global MatchingChar ${red},${base2}+b face global BufferPadding ${base1},${base3} face global Whitespace ${base1}+f " } kakoune-2020.09.01/colors/tomorrow-night.kak000066400000000000000000000050361372342214000205340ustar00rootroot00000000000000# ## Tomorrow-night, adapted by nicholastmosher ## evaluate-commands %sh{ foreground="rgb:c5c8c6" # gui05 background="rgb:1d1f21" # gui00 selection="rgb:373b41" # gui02 window="rgb:282a2e" # gui01 comment="rgb:969896" # gui03 red="rgb:cc6666" # gui08 orange="rgb:de935f" # gui09 yellow="rgb:f0c674" # gui0A green="rgb:b5bd68" # gui0B blue="rgb:81a2be" # gui0D aqua="rgb:8abeb7" # gui0C purple="rgb:b294bb" # gui0E ## code echo " face global value ${orange} face global type ${yellow} face global variable ${red} face global module ${blue} face global function ${blue} face global string ${green} face global keyword ${purple} face global operator ${aqua} face global attribute ${purple} face global comment ${comment} face global documentation comment face global meta ${purple} face global builtin ${yellow} " ## markup echo " face global title ${blue} face global header ${aqua} face global mono ${green} face global block ${orange} face global link ${blue} face global bullet ${red} face global list ${red} " ## builtin echo " face global Default ${foreground},${background} face global PrimarySelection ${foreground},${selection}+fg face global SecondarySelection ${foreground},${window}+fg face global PrimaryCursor ${background},${foreground}+fg face global SecondaryCursor ${background},${aqua}+fg face global PrimaryCursorEol ${background},${green}+fg face global SecondaryCursorEol ${background},${green}+fg face global LineNumbers ${comment},${window} face global LineNumberCursor ${yellow},${window}+b face global MenuForeground ${window},${foreground} face global MenuBackground ${foreground},${window} face global MenuInfo ${red} face global Information ${foreground},${window} face global Error ${foreground},${red} face global StatusLine ${foreground},${selection} face global StatusLineMode ${yellow}+b face global StatusLineInfo ${aqua} face global StatusLineValue ${green} face global StatusCursor ${window},${aqua} face global Prompt ${background},${aqua} face global MatchingChar ${yellow},${background}+b face global BufferPadding ${aqua},${background} face global Whitespace ${comment}+f " } kakoune-2020.09.01/colors/zenburn.kak000066400000000000000000000056711372342214000172250ustar00rootroot00000000000000# zenburn theme evaluate-commands %sh{ # define some named colors zentext="rgb:cfcfcf" zenselectionbg="rgb:3f7fcc" zencursor="rgb:2a2a2a,rgb:dfdfbf" zencursoreol="rgb:2a2a2a,rgb:cc9393" zensecondaryfg="rgb:2a2a2a" zendefault="${zentext},rgb:3f3f3f" zenstatus="rgb:efdcbc,rgb:2a2a2a" zenstatuscursor="${zentext},rgb:7f9f7f" zeninfo="rgb:cc9393,rgb:2a2a2a" zenmenubg="rgb:7f9f7f,rgb:4a4a4a" zenmenufg="rgb:8cd0d3,rgb:5b5b5b" zenkeyword="rgb:f0dfaf+b" zenstorageClass="rgb:c3bf9f+b" zennumber="rgb:8cd0d3" zencomment="rgb:7f9f7f" zenconstant="rgb:dca3a3+b" zenspecial="rgb:cfbfaf" zenfunction="rgb:efef8f" zenstatement="rgb:e3ceab" zenvariable="rgb:efdcbc" zentype="rgb:dfdfbf" zenstring="rgb:cc9393" zenmodule="${zenstring}" zenexception="rgb:c3bf9f+b" zenmatching="rgb:3f3f3f,rgb:8cd0d3" zenpadding="rgb:f0dfaf,rgb:343434+b" echo " # then we map them to code face global value ${zenconstant} face global type ${zentype} face global variable ${zenvariable} face global module ${zenstring} face global function ${zenfunction} face global string ${zenstring} face global keyword ${zenkeyword} face global operator ${zenfunction} face global attribute ${zenstatement} face global comment ${zencomment} face global documentation comment face global meta ${zenspecial} face global builtin default+b # and markup face global title ${zenkeyword} face global header ${zenconstant} face global mono ${zennumber} face global block ${zenstatement} face global link ${zenstring} face global bullet ${zenvariable} face global list ${zentype} # and built in faces face global Default ${zendefault} face global PrimarySelection ${zentext},${zenselectionbg}+fg face global SecondarySelection ${zensecondaryfg},${zenselectionbg}+fg face global PrimaryCursor ${zencursor}+fg face global SecondaryCursor ${zencursor}+fg face global PrimaryCursorEol ${zencursoreol}+fg face global SecondaryCursorEol ${zencursoreol}+fg face global LineNumbers ${zendefault} face global LineNumberCursor ${zenstatus} face global MenuForeground ${zenmenufg} face global MenuBackground ${zenmenubg} face global MenuInfo rgb:cc9393 face global Information ${zeninfo} face global Error default,red face global StatusLine ${zenstatus} face global StatusLineMode ${zencomment} face global StatusLineInfo ${zenspecial} face global StatusLineValue ${zennumber} face global StatusCursor ${zenstatuscursor} face global Prompt ${zenconstant} face global MatchingChar default+b face global BufferPadding ${zenpadding} face global Whitespace ${zensecondaryfg}+f " } kakoune-2020.09.01/contrib/000077500000000000000000000000001372342214000152005ustar00rootroot00000000000000kakoune-2020.09.01/contrib/TRAMPOLINE000066400000000000000000000635641372342214000166130ustar00rootroot00000000000000+=----------------------------------------------------------------------------=+ _ _ | | | | | | __ __ _ | | __ ___ _ _ _ __ ___ | |/ / / _` | | |/ / / _ \ | | | | | '_ \ / _ \ | < | (_| | | < | (_) | | |_| | | | | | | __/ |_|\_\ \__,_| |_|\_\ \___/ \__,_| |_| |_| \___| Mawww's experiment for a better code editor +=----------------------------------------------------------------------------=+ This walk-through is an introduction to Kakoune's basic editing capabilities to help new users transition over easily from another editor, or simply learn how to write and edit documents with style. During the learning period it is useful to activate an automatically displayed contextual help for commands in normal mode: `:set -add global autoinfo normal` In the first section, you will learn about the primitives of the editing language to be able to get to a level of knowledge of the editor that guarantees that you can work with it efficiently. In the second section, for users who've gone through the basics and want to move on to more advanced functionalities, we explain other primitives whose role has a less dominant place in an everyday editing session, but still prove themselves powerful when used on the right occasion. Finally, as this document is in no way an exhaustive list of features, don't hesitate to check out the official documentation to compliment your tool-set, ask questions to more seasoned users on IRC, and check the documentation using the built-in `:doc` command. +=--------------------------------=+ BASICS +=--------------------------------=+ =[ MODES Kakoune uses a paradigm called "modal editing" to allow .---, users to either have every single key they type inserted | i | into the file being edited (called "insert mode"), `---' or execute commands that are triggered by the keys hit (the "normal mode"). Aside from arrow keys, most keys .---, described in this document are "editing primitives" that |esc| have to be hit in normal mode, which is the default mode `---' when you start the editor. To enter insert mode, hit the `i` key, and to leave it and return to normal mode, hit the escape key. =[ MOVEMENT .---, | ↑ | Movement in a buffer (the representation of the contents .---'---'---, of a file opened by Kakoune) can be achieved using the arrow | ← | ↓ | → | keys, which will move the cursor up one column/row into `---'---'---` a given direction. However, furthering the tradition of mode-based editors, .---,---,---,---, the `h`, `j`, `k` and `l` keys can be used for the same | h | j | k | l | purpose, and will respectively move the cursor to the `---'---'---'---` left, down, up, right by one, when hit. Using those keys | | | | is the recommended way of moving around in a buffer. .---,---,---,---, If you're not familiar with this concept, the proximity | ← | ↓ | ↑ | → | of those four keys with the rest of the lettered keys `---'---'---'---` on a `qwerty` layout allows faster interaction with the primitives than if the user had to moves their hand to .---, reach the arrow keys. | g |_. `---' |`.---, Another way of moving the cursor is the "goto" utility, | | g | invoked by hitting the `g` key. A menu will pop up with a | `---' summary of all the possible keys that can be hit, along with `.---, the location where they will move the cursor to, but the | e | most used ones that we are interested in, for now, are `g` `---' and `e`. The first one will jump to the beginning of the buffer, and the second one to its end. =[ VIEW .---, Displacing the cursor can sometimes move the view into an | v |_. inconvenient configuration, leaving some necessary context `---' |`.---, off screen, or simply feel uncomfortable to type into. | | t | Kakoune provides a menu (similar to the `goto` menu | `---' mentioned in the previous section) that allows users to |`.---, move the current view in relation with the position of the | | b | cursor. Upon hitting the `v` key, a short menu appears | `---' which allows us to hit a second key according to how the `.---, view should be centered vertically: to leave the cursor | v | respectively on top, at the bottom or in the middle of the `---' current view, hit the `t`, `b` or `v` keys. =[ SEARCH In order to move the cursor to a specific word, the search command is the way to go. This functionality allows .---, the user to jump to the next occurrence of a piece of text. | / | Upon hitting the `/` key, a prompt reading "search" `---' will pop up in the status bar in which you can type your text and validate using the `` (return) key. .---, .---, You'll notice that as you type, the cursor changes location |alt|+| / | to automatically give you a preview of where the cursor `---' `---' would be displaced to if you validated the search. However, this behavior is only a preview, exiting prompt mode with the `` (escape) key will leave the current position .---, of the cursor unchanged. Note that you can also use a | n | regular expression as input. By default the search `---' function will look for results forward, starting from the current location of the cursor, but you can search .---, .---, backwards using `` (alt + `/`). |alt|+| n | `---' `---' Jumping from one match to the other forward can be achieved using the `n` key, and backwards using the `` (alt + `n`) key combination. =[ SELECTIONS You have certainly noticed that when searching for .---, text, the cursor extends to highlight the entire match. | ; | In fact, what we know in other editors as a "cursor" is `---' actually a single character wide selection in Kakoune, and can be expanded using primitives. When "expanded", .---, .---, the selection is an area whose beginning is the "anchor" |alt|+| ; | and the end the "secondary cursor". To switch anchor and `---' `---' cursor, use ``, and to collapse the selection onto its anchor, use `;`. Moreover, not only Kakoune expands the principle of "cursor" by introducing selections, but it also allows .---, multiple selections within the same buffer. This makes | % | it very convenient to modify text in multiple locations `---' at once, as editing primitives apply to all the currently selected text. .---, | s | Example: to remove all occurrences of the word "foo", one `---' would select the entire buffer (`%`), select occurrences of the word (`s`, "\bfoo\b", ``), then remove it (`d`). ==[ SELECTING OBJECTS In addition to allowing text selection using regular .---, .---, expressions, certain objects are defined by default to |alt|+| i | allow easy selection of text. Objects are bits of text `---' `---' in the buffer that are identified according to their structure, rather than their contents, e.g. a paragraph, .---, .---, a sentence, or a word. When the cursor is located within |alt|+| a | the boundaries of an object you want to interact with, `---' `---' several options are available: selecting the contents of an object without its boundaries (``), a part of it (from .---, the anchor to its end or to its beginning, respectively `]` | ] | and `[`), or the entire object (``). Those "selection `---' ranges" are the first part of a two stages shortcut, as once you've used the key that dictates what part of .---, the object is to be selected, a menu with a description | [ | of all the object types select-able will be displayed, `---' giving a summary of all the keys you can hit to complete the selection procedure. Example: to select the paragraph in which the anchor lies, invoke the "inner object selection" shortcut (``), locate "paragraph" in the information box that pops up and .---, hit the according key (`p`). The entire two steps sequence | [ |_. is thus: ` p`. `---' |`.---, | | ( | Example: to select everything between the anchor and the | `---' beginning of the current parenthesis pair, use the selection `.---, sequence is: `[ (`. Note that common objects that use | r | pairs of opening/closing punctuation signs (brackets, `---' braces, quotes etc) have an alternative second key that is displayed in the information menu that you can use to minimize finger gymnastics. The previous shortcut could thus also be written: `[ b`. ==[ MOVEMENT SELECTIONS If objects are an easy way to select content-agnostic .---, data in a buffer, they can also be seen as a way to move | [ |_. about the buffer. As selecting objects will displace the `---' `.---, anchor into a given direction, you can wrap or move around | p | particular chunks of text without using the conventional `---' means (e.g. arrow keys or jumps), turning them partially into movement primitives. .---, | ] |_. Example: one of the most used object selection combination `---' `.---, is the "object end/begin paragraph" one: using `[` or | p | `]` will displace the anchor into a given direction, and `---' applying that to the paragraph object allows "jumping" from one newline separated block of text to another. The resulting shortcut is thus: `] p` to move forward, or `[ p` to move backward. =[ FILTERING A SELECTION Selecting an entire buffer (`%`) or parts of it (`s`) is a natural and basic operation in a typical editing session, .---, .---, however there are some cases where we need to be able to |alt|+| k | drop some selections arbitrarily, as opposed to trying `---' `---' to select the ones we need directly. This concept becomes very useful when coming up with a regular expression for .---, .---, the basic selection primitive (`s`) is too tedious (if |alt|+| K | even possible), that's why the editor provides us with a `---' `---' "keep matching" and a "keep not matching" operations, in order to respectively keep exclusively the selections who match or do not match a given regular expression. Example: when parsing a log file whose lines follow the usual log pattern (e.g. "[1484383442] ERROR: some data"), we want to be able to select all the lines individually .---, .---, (`%`, `` to split all the lines), keep those that |alt|+| s | start with a bracketed time-stamp (`^\[`), but `---' `---' exclude the debug messages (`DEBUG`). Of course, it's possible to come up with a regular expression to match those simple requirements, but it would take more work to write it than to organically apply filters on a general selection, individually. =[ SELECTION DUPLICATION .---, Duplicating content can be achieved using a widely | y | implemented concept: yanking and pasting. Yanking the `---' current selection (`y`) into the copy register allows the .---, user to subsequently insert the copied text in the buffer | p | (`p`). `---' .---, Note that the default "paste" primitive will insert the | P | contents of the copy register after the current selection, `---' if you want copied test to be inserted before the current selection then you can use the `P` key. =[ DELETING / REPLACING SELECTIONS Text replacement is a two step process in Kakoune, which .---, involves selecting text to be replaced, and then erasing it | d | to insert the replacement text. After selections have been `---' made, you can simply hit the deletion primitive (`d`), then .---, either enter insert mode to write down the replacement text | c | (`i`), or stay in command mode to paste the replacement `---' text stored in the copy register. As deleting and entering .---, insert mode can be redundant, a primitive that implements | R | deletion followed by insert mode entrance was implemented: `---' `c`. You can also directly replace the current selection with the content of the copy register using a primitive also implemented for that purpose: `R`. =[ UNDO / REDO Mistakes or wrong decisions can happen while editing. .---, To go back to earlier states of the buffer, you can press | u | the `u` key several times. On the contrary, pressing `U` `---' allows traveling forward in the history tree. +=-------------------------------=+ ADVANCED +=-------------------------------=+ =[ SPLITTING The selection primitive (`s`) is a powerful tool to select chunks of data, but sometimes the format of said data isn't .---, uniform enough to allow creating clear cut selections. In | S | order to avoid having to write overly complicated regular `---' expressions that select precisely the wanted text, the splitting primitive (`S`) allows applying a delimiter to the current selection, splitting it into separate chunks. Example: selecting the items in a CSV-style list (e.g. "1,2,3,4") is as simple as selecting the line, then splitting it using the comma separator (`S,`). Note that more advanced splitting is possible, since the delimiter passed to this primitive is a regular expression. =[ ROTATING Often used in conjunction with the splitting primitive (`S`), the rotation primitive (``) shifts all the selections clock-wise. Note that a count (described after) allows the rotation to take place in sub-groups whose size .---, .---, is given by the count parameter. |alt|+| ) | `---' `---' Example: in a numbered list where all the numbers are selected (e.g. `1 2 3 4 5 6 7 8 9 0`), a rotation using this primitive will shift all the numbers by one selection forward, while leaving the original multiple selection untouched (e.g. `0 1 2 3 4 5 6 7 8 9`). =[ COUNTS .---, In order to pass a count to a primitive, simply type the |0-9|_. number out before hitting the primitive key/combination. `---' |`.---, Counts allow primitives to specialize or extend their | | g | original functionality by using it as a parameter, | `---' acting on their side effect. |`.---, | | G | Example: in order to respectively jump or select up to a | `---' particular line, pass the line number to the `g` or `G` |`.---, primitives (e.g. `42g` or `7G`). | | o | | `---' Example: creating an arbitrary amount of new lines `.---, above or below the current line and spawning a new selection | O | for each of them is achieved by passing the amount of lines `---' as a count respectively to the `o` and `O` primitives. =[ REGISTERS Similarly to counts, registers influence the behavior of .---, certain primitives. They are storage structures identified | " |_. by a single character, and are populated by primitives as a `---' `.---, result of a side effect. Although primitives populate a |a-z| specific register by default, it's possible to modify which `---' is going to be populated upon execution using the double quote (`"`) primitive, and subsequently hitting a key that .---, will serve as identifier. | * | `---' Example: the smart search primitive (`*`) uses the current selection as a search pattern, which will be saved to the .---, `/` register. In order to use this primitive to execute a | " |_. .---, temporary search, one could make this primitive save the `---' `| _ | pattern to a different register, to preserve the default one `---' e.g. `"m*` to save the pattern to the `m` register, or even `"_*` to save the pattern to a "null" register, which not store anything written to it. ==[ CAPTURE GROUPS Although registers can pass as mere buffer metadata, .---, .---, they are an integral part of an editing session. The |ctl|+| r | `` key combination allows to insert into the buffer `---' `---' the value of a register, whose identifier is typed right after the combination. .---, .---, Example: inserting the name of the current buffer in insert |ctl|+| r |_. mode can be achieved using the `%` register, which holds `---' `---' `.---, this information: `%`. | % | `---' Another kind of registers that is set automatically are the numbered registers, which hold the values of the groups matched in the last search or select operation (`/` and .---, .---, `s` primitives). |ctl|+| r |_. `---' `---' `.---, Example: when using the search primitive (`/`) with a |0-9| regular expression containing groups to match a list of `---' first and last names (e.g. `(\w+) (\w+)` on `John Doe`), issuing `1` would insert the first name (`John`), and `2` the last name (`Doe`). =[ CUSTOM SELECTIONS Despite the ability to select bits of data using regular expressions, there are times when using them isn't enough, and additional manual editing of the selections is .---, needed. In order to loop through all the selections and | ) | remove the current one, two primitives are available: `---' respectively the parenthesis (`)`), and the alt/space key combination (``). .---, .---, |alt|+|spc| Example: given a list of three numbers all selected `---' `---' individually, (e.g. `1 2 3`), deselecting the second selection would be done by hitting the parenthesis primitive (`)`) until the according selection is the current one, then hitting `` to end up with only the first and third number selected. However, being able to trim out some selections out .---, of a bigger set isn't always convenient, as it doesn't | ^ | allow more advanced constructs such as combining sets of `---' multiple-selections that result from different regular .---, expressions. To allow that, the save mark (`Z`) and append | Z | mark (``) come in handy, as they respectively save `---' the current selection to the mark register (`^`), and show a menu that allows appending the current selection .---, .---, to the mark register upon hitting the `a` key. That way, |alt|+| z |_. it becomes possible to chain and save (append) several `---' `---' `.---, selections made using completely different methods | a | (select, split etc) without being forced to preserve `---' them at all times. .---, | z | Restoring a mark saved to the mark register using those `---' primitives can be achieved by using the restore mark primitive (`z`). =[ LEVERAGING SHELL COMMANDS UNIX systems provide with some tools whose purpose is to interact with raw data, and being a UNIX compliant .---, aspiring tool itself, Kakoune allows leveraging those | | | tools to modify a buffer's contents. Upon invoking the pipe `---' primitive (`|`), an input field pops up which prompts for a shell command, to which the selections will individually be sent through the command's standard input. Example: wrapping a selection can be achieved by invoking the `fold` utility, e.g. `|fold -w80`. You could also want to see a patch of all the modifications made to the buffer since it was last saved: `%|diff -u % -`. Note that the `%` has to be typed interactively, as it will insert the name name of the buffer into the command. Another equally useful primitive that doesn't depend on .---, the contents of the current selections is the exclamation | ! | mark primitive (`!`), which simply insert the output of `---' the given shell command before each selection. Example: in order to insert the date of the day at the beginning of the current buffer, one could use `gg` followed with `!date`. But not all shell-related primitives insert data into the current buffer, the `$` key is in fact a way to .---, apply a predicate to all selections, in order to filter | $ | them out. The command passed to this primitive will be `---' executed in a new shell using each individual selection for context, which will either be kept if the command returned a successful exit code (zero) or dropped otherwise (any non-zero value). Example: after selecting all the lines in a buffer and splitting them individually (`%`, ``), keeping every odd numbered line can be achieved with the following sequence: `$` `[ $((kak_reg_hash)) -ne 0 ]`. =[ REPEATING ACTIONS ==[ PUNCTUAL INTERACTIONS In order to modify text efficiently or insert redundant bits of data, two primitives are available. The dot `.` .---, primitive repeats the last change that was made in insert | . | mode (e.g. writing down text after hitting the insert `---' primitive `i`). Similarly, repeating the last selection (make with e.g. the find primitive `f`) can be achieved using the `` primitive. Example: to select a paragraph to append a newline .---, .---, character to it and cycle through the following paragraphs |alt|+| . | to repeat the same insertion an arbitrary amount of times, `---' `---' one would first select the paragraph with `]p`, append a newline to it `a`, then repeat both operations as needed with `` and `.` respectively. ==[ COMPLEX CHANGES Transforming successive chunks of formatted data can .---, be cumbersome when done manually, and lack hindsight | q | when writing a script for that particular purpose `---' non-interactively. The middle ground between the two .---, solutions is to record the modifications made to one | Q | chunk interactively, and replay the sequence of keys `---' at will. The sequence in question is a macro: the `Q` primitive will create a new one (i.e. record all the keys .---, .---, hit henceforth until the escape key `` is hit), and |ctl|+| r |_. the `q` primitive will replay the keys saved in the macro. `---' `---' `.---, | @ | Notes: macros can easily be translated into a proper `---' script, as they are saved in the `@` register, which you can insert into a buffer using `@`. kakoune-2020.09.01/contrib/Tupfile000066400000000000000000000025731372342214000165420ustar00rootroot00000000000000## ## Tupfile for kakoune ## by lenormf ## ## How to use: ## Initialize a tup database in the main directory with `tup init` ## Create a symlink from `contrib/Tupfile` to `src/Tupfile` ## Start the build with the `tup` command ## .gitignore debug = yes static = no suffix = .opt CXX = g++ CXXFLAGS = -pedantic -std=gnu++14 -Wall -Wno-unused-parameter -Wno-reorder -Wno-sign-compare -Wno-address -Wno-noexcept-type -Wno-unknown-attributes -Wno-unknown-warning-option CPPFLAGS = LDFLAGS = LIBS = ifeq ($(debug),yes) CXXFLAGS += -g CPPFLAGS += -DKAK_DEBUG suffix = .debug else CXXFLAGS += -O3 endif ifeq ($(static),yes) LIBS += -ltinfo -lgpm LDFLAGS += -static -pthread endif ifeq (@(TUP_PLATFORM),macosx) LIBS += -lncurses CPPFLAGS += -I/usr/local/opt/ncurses/include LDFLAGS += -L/usr/local/opt/ncurses/lib else ifeq (@(TUP_PLATFORM),win32) LIBS += -lncursesw -ldbghelp CPPFLAGS += -D_XOPEN_SOURCE=700 else LIBS += `pkg-config --libs ncursesw` CPPFLAGS += `pkg-config --cflags ncursesw` ifeq ($(CXX),g++) LDFLAGS += -rdynamic endif endif endif ifeq ($(CXX),clang++) CXXFLAGS += -Wno-unknown-attributes endif !cxx = |> $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c %f -o %o |> !ld = |> $(CXX) $(LDFLAGS) $(LIBS) %f -o %o |> !ln = |> ln -sf %f %o |> :foreach *.cc |> !cxx |> .%B$(suffix).o {objects} :{objects} |> !ld |> kak$(suffix) :kak$(suffix) |> !ln |> kak kakoune-2020.09.01/contrib/describe_sessions.sh000077500000000000000000000047331372342214000212540ustar00rootroot00000000000000#!/bin/sh ## ## describe_sessions.sh for kakoune ## by lenormf ## readonly KAK_SCRIPT=' { echo printf "Session: %s\n" "${kak_session}" printf "Current working directory: %s\n" "${PWD}" eval set -- "${kak_buflist}" printf "Buffers (%d):\n" $# for bufname in "$@"; do printf "\t%s\n" "${bufname}" done eval set -- "${kak_client_list}" printf "Clients (%d):\n" $# for clientname in "$@"; do printf "\t%s\n" "${clientname}" done } >>{{outfile}} rm -rf {{sentinel}} ' main() { outfile=$(mktemp "${TMPDIR:-/tmp}"/kak-describe_sessions.XXXXXXXX) nb_sessions=0 nb_dead_sessions=0 nb_suspended_sessions=0 if ! command -v socat >/dev/null 2>&1; then echo "Unmet dependency: socat" >&2 exit 1 fi script=$(printf 'nop %%sh{ %s }' "${KAK_SCRIPT}" | sed "s,{{outfile}},\"${outfile}\",g") sessions_dir="${TMPDIR:-/tmp}/kakoune/${USER}" if [ -n "${XDG_RUNTIME_DIR}" ]; then sessions_dir="${XDG_RUNTIME_DIR}/kakoune" fi for session in "${sessions_dir}"/*; do name_session="${session##*/}" if printf '' | socat - UNIX-CONNECT:"${session}",connect-timeout=1 2>/dev/null; then sentinel=$(mktemp -d "${TMPDIR:-/tmp}"/kak-sentinel.XXXXXXXX) script_session=$(printf %s "${script}" | sed "s,{{sentinel}},\"${sentinel}\",g") if ! printf %s "${script_session}" | kak -p "${name_session}"; then printf '\nSession "%s" dead\n' "${name_session}" >> "${outfile}" nb_dead_sessions=$((nb_dead_sessions + 1)) continue fi wait_limit=2 while ! mkdir "${sentinel}" 2>/dev/null && [ "${wait_limit}" -gt 0 ]; do wait_limit=$((wait_limit - 1)) sleep 1 done rm -rf "${sentinel}" if [ "${wait_limit}" -gt 0 ]; then nb_sessions=$((nb_sessions + 1)) else printf '\nSession "%s" suspended\n' "${name_session}" >> "${outfile}" nb_suspended_sessions=$((nb_suspended_sessions + 1)) fi else nb_dead_sessions=$((nb_dead_sessions + 1)) fi done printf 'Running sessions: %d\nSuspended sessions: %d\nDead sessions: %d\n' \ "${nb_sessions}" "${nb_suspended_sessions}" "${nb_dead_sessions}" cat "${outfile}" rm -f "${outfile}" } main "$@" kakoune-2020.09.01/contrib/kakmap.rb000077500000000000000000000034551372342214000170030ustar00rootroot00000000000000#!/usr/bin/env ruby # Generate a reference sheet for Kakoune's normal mode # Use: ./kakmap.rb ../src/normal.cc require 'markaby' # Relies on the keymap HashMap assignment ending with }; raw = ARGF.read.split( /const\s+HashMap\s+keymap\s*{/ ).last.split( /^};$/ ).first commands = {} raw.split( /\n+/ ).each{ |line| # skip empty or comment line line = line.strip if line.empty? or /^\/\// =~ line next end # match key mapping line /^\{\s*\{(?[^}]+)\}\s*,\s*\{\s*"(?[^"]+)"/.match(line) do |m| modAndKey = m['mdky'] des = m['dsc'] modAndKey.gsub!(/\s*\/\*[^*]+\*\/\s*/, '') # remove comment in key definition # match key and modifier /Key::(?\w+)|(?alt|ctrl)\('\\?(?.+?)'\)|'\\?(?.+?)'$/.match(modAndKey) do |sm| key = sm['key'] mod = (sm['mod'] || 'none').to_sym key = 'Space' if key == ' ' commands[key] ||= {} commands[key][mod] = des end end } # sort, showing single characters first, symbols next and spelled out keys last commands = commands.sort_by{ |key, _| case key when /^\w$/ key.upcase + key.swapcase when /^\W$/ '_' + key else '~~' + key end } puts Markaby::Builder.new { html do head do title "Kakoune default keymap" end body do table :style => "border-collapse: collapse" do thead do tr do th "Key" th "Description" th "ALT + key" th "CTRL + key" end end tbody do for key, binding in commands tr :style => "border-bottom: 1px solid #fbfbfb" do th key td binding[:none] td binding[:alt] td binding[:ctrl] end end end end end end } kakoune-2020.09.01/contrib/kakoune.spec000066400000000000000000000067531372342214000175240ustar00rootroot00000000000000%bcond_without tests # Enable LTO. Profit ~8% %global optflags %{optflags} -flto %global build_ldflags %{build_ldflags} -flto Name: kakoune Version: 2020.08.04 Release: 1%{?dist} Summary: Code editor heavily inspired by Vim License: Unlicense URL: https://kakoune.org/ Source0: https://github.com/mawww/kakoune/archive/v%{version}/%{name}-%{version}.tar.gz BuildRequires: asciidoc BuildRequires: gcc-c++ >= 7 BuildRequires: glibc-langpack-en BuildRequires: pkgconfig(ncurses) >= 5.3 %description - Modal editor - Faster as in fewer keystrokes  - Multiple selections - Orthogonal design Kakoune is a code editor that implements Vi’s "keystrokes as a text editing language" model. As it’s also a modal editor, it is somewhat similar to the Vim editor (after which Kakoune was originally inspired). Kakoune can operate in two modes, normal and insertion. In insertion mode, keys are directly inserted into the current buffer. In normal mode, keys are used to manipulate the current selection and to enter insertion mode. Kakoune has a strong focus on interactivity, most commands provide immediate and incremental results, while still being competitive (as in keystroke count) with Vim. Kakoune works on selections, which are oriented, inclusive range of characters, selections have an anchor and a cursor character. Most commands move both of them, except when extending selection where the anchor character stays fixed and the cursor one moves around. %prep %autosetup -p1 # Use default Fedora build flags sed -i '/CXXFLAGS += -O3/d' src/Makefile # Install doc files in proper location sed -i 's|$(PREFIX)/share/doc/kak|$(PREFIX)/share/doc/%{name}|' src/Makefile %build %set_build_flags pushd src %make_build popd %install pushd src %make_install PREFIX=%{_prefix} popd %if %{with tests} %check %set_build_flags pushd src LANG=en_US.utf8 %make_build test popd %endif %files %license UNLICENSE %doc README.asciidoc CONTRIBUTING VIMTOKAK %{_bindir}/kak %{_datadir}/kak/ %{_mandir}/man1/* %changelog * Tue Aug 4 2020 Jiri Konecny - 2020.08.04-1 - Update to 2020.08.04 * Thu Jan 16 2020 Artem Polishchuk - 2020.01.16-1 - Update to 2020.01.16 * Tue Dec 10 2019 Artem Polishchuk - 2019.12.10-1 - Update to 2019.12.10 * Tue Nov 26 2019 Artem Polishchuk - 2019.07.01-4 - Add patch to pass tests with default Fedora build flags * Fri Nov 22 2019 Artem Polishchuk - 2019.07.01-2 - Packaging fixes * Wed Apr 24 2019 Jiri Konecny - v2019.01.20-1 - Add a new build dependency (glibc-langpack-en) required for Fedora 30 and later - Update version * Fri Oct 12 2018 Jiri Konecny - v2018.09.04-1 - Update spec file to a new release * Sat May 5 2018 Łukasz Jendrysik - v2018.04.13 - Use tagged release * Wed May 11 2016 jkonecny - 0-208.20160511git84f62e6f - Add LANG=en_US.UTF-8 to fix tests - Update to git: 84f62e6f * Thu Feb 11 2016 jkonecny - 0-158.20160210git050484eb - Add new build requires asciidoc - Use new man pages * Sat Mar 28 2015 jkonecny - 0-5.20150328gitd1b81c8f - Automated git update by dgroc script new hash: d1b81c8f * Tue Mar 24 2015 Jiri Konecny 0-1.7eaa697git - Add tests * Tue Mar 17 2015 Jiri Konecny 0-1.12a732dgit - Create first rpm for kakoune kakoune-2020.09.01/contrib/tmux-256color.terminfo000066400000000000000000000053151372342214000213170ustar00rootroot00000000000000tmux-256color|tmux with 256 color and palette setting, am, hs, km, mir, msgr, xenl, colors#256, cols#80, it#8, lines#24, pairs#32767, acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~, bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, ccc, civis=\E[?25l, clear=\E[H\E[J, cnorm=\E[34h\E[?25h, cr=^M, csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\EM, cvvis=\E[34l, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, dsl=\E]0;\007, ed=\E[J, el=\E[K, el1=\E[1K, enacs=\E(B\E)0, flash=\Eg, fsl=^G, home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L, ind=\n, indn=\E[%p1%dS, initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\, invis=\E[8m, is2=\E)0, kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~, kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\E[1;2C, kbs=^H, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kdch1=\E[3~, kend=\E[4~, kf1=\EOP, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf13=\E[1;2P, kf14=\E[1;2Q, kf15=\E[1;2R, kf16=\E[1;2S, kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, kf25=\E[1;5P, kf26=\E[1;5Q, kf27=\E[1;5R, kf28=\E[1;5S, kf29=\E[15;5~, kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~, kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~, kf36=\E[24;5~, kf37=\E[1;6P, kf38=\E[1;6Q, kf39=\E[1;6R, kf4=\EOS, kf40=\E[1;6S, kf41=\E[15;6~, kf42=\E[17;6~, kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~, kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf49=\E[1;3P, kf5=\E[15~, kf50=\E[1;3Q, kf51=\E[1;3R, kf52=\E[1;3S, kf53=\E[15;3~, kf54=\E[17;3~, kf55=\E[18;3~, kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~, kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\E[1;4P, kf62=\E[1;4Q, kf63=\E[1;4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kich1=\E[2~, kind=\E[1;2B, kmous=\E[M, knp=\E[6~, kpp=\E[5~, kri=\E[1;2A, nel=\EE, op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, ritm=\E[23m, rmacs=^O, rmcup=\E[?1049l, rmir=\E[4l, rmkx=\E[?1l\E>, rmso=\E[27m, rmul=\E[24m, rs2=\Ec\E[?1000l\E[?25h, sc=\E7, setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m, setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m, sgr=\E[0%?%p6%t;1%;%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t; 5%;%?%p5%t;2%;m%?%p9%t\016%e\017%;, sgr0=\E[m\017, sitm=\E[3m, smacs=^N, smcup=\E[?1049h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m, smul=\E[4m, tbc=\E[3g, tsl=\E]0;, vpa=\E[%i%p1%dd, kakoune-2020.09.01/doc/000077500000000000000000000000001372342214000143055ustar00rootroot00000000000000kakoune-2020.09.01/doc/autoedit.asciidoc000066400000000000000000000074371372342214000176360ustar00rootroot00000000000000Edition auto insertion in Kakoune ================================= It is a quite common feature for a code editor to help the programmer by automatically inserting some text in certain contexts. This document goal is to explain how this is done in Kakoune. There is no special support in Kakoune for this task, hooks are expected to be used in order to manage that, and the normal Kakoune editing command are expected to be expressive enough so that relatively complex indentation can be written concisely. The main hook is *InsertChar*, which gets called immediately _after_ a character has been inserted in insertion mode due to the user pressing the corresponding key. Previous line indentation ------------------------- Let's see a simple indent hook: preserving the previous line indentation. Here is the Kakoune normal mode key list in order to do that: ---------------------------------------------------------------- k # 1. go to previous line and select it s^\h+y # 2. select the leading spaces and copy them jP # 3. go back to next line start and paste the spaces ---------------------------------------------------------------- Note that if nothing gets selected on phase *2.*, an error will be raised. We want to do that each time the user jumps a line, just after the new line is inserted. So the hook would be: -------------------------------------------------------- :hook InsertChar \n %{ exec k s^\h+y jP } -------------------------------------------------------- (exec concatenates the keys for all argument, so the spaces will be ignored, allowing for clearer separation. either use or quote the argument to use a space key) That works, however if the phase *2.* raises an error, the +:exec+ will stop and the user will get its selections on the previous line. The solution is to use a *draft* context, instead of the one the user is interacting with. --------------------------------------------------------------- :hook InsertChar \n %{ exec -draft k s^\h+y jP } --------------------------------------------------------------- That way, exec is executed in a *copy* of the user's context, which means it manipulates a *copy* of the user's selections. Increasing indentation ---------------------- A little bit more complicated is to increase indentation whenever we insert a new line after a +{+ or a +(+. The complexity arises from the presence of a condition. We want to increase the indentation *only* if the previous line ends with +{+ or +(+. Fortunately, Kakoune provides us with a command for that: the ++ command, which keeps selections where a certain regex can be found. Here is how we can do that: ------------------------------------------------------------------------------- k # 1. select the previous line [{(]\h*$ # 2. keep selections that end with { or ( followed by blanks j # 3. go back to next line and indent it even if it is empty ------------------------------------------------------------------------------- Note that if no previous line ends with a +{+ or +(+, the ++ command will raise an error, and stop the execution. This is what we want: it is similar to what would happen if we would continue with no selections; the following commands would have no effects. However, the error would end up being caught by the hook execution code, and it will write information about it in the debug buffer, which we do not want, as this is actually expected. In order to prevent that, the exec should be wrapped in a try command. So we would have: ------------------------------------------------------------------------------- :hook InsertChar \n %[ try %[ exec -draft k [{(]\h*$ j ] ] ------------------------------------------------------------------------------- kakoune-2020.09.01/doc/coding-style.asciidoc000066400000000000000000000021151372342214000204050ustar00rootroot00000000000000C++ Coding Style ================ Kakoune is written in C++14, here are the main coding style points: * Avoid external dependencies besides posix/stdc++/ncurses * 4 spaces for indentation, no tabs * public interface before private methods/data when defining a class * use +override+ keyword for overridden virtual methods * opening brackets on their own lines by default, except when declaring an object where the opening bracket follows the equal sign. * use alternative logical operator names (and, or, not instead of &&, ||, !) ----- int func() { if (condition) { ... } else statement; } int array[] = { ... }; ----- * End lines with an operator when continuing on the next line ---- if (condition1 or condition2) ---- * Try to keep under 80 columns, even though this is not a strict limit. * CamelCase for types, snake_case for variables/function names * prefix fields with m_, static ones with ms_ except for dumb structs (struct with every field public) where these prefixes can be dropped. * use const and constexpr liberally kakoune-2020.09.01/doc/design.asciidoc000066400000000000000000000142511372342214000172610ustar00rootroot00000000000000Kakoune design ============== This document describes the design goals for Kakoune, including rationales. Interactivity ------------- Unlike Vim, Kakoune does not have an underlying line-oriented editor, and is always expected to be used in an interactive (i.e. with the edited text being displayed in real time) fashion. That should not prevent Kakoune from being used non interactively (executing macro for example), but priority should be given to ease of interactive use. Limited scope ------------- Kakoune is a code editor. It is not an IDE, not a file browser, not a word processor and not a window manager. It should be very efficient at editing code, and should, as a side effect, be very efficient at editing text in general. Composability ------------- Being limited in scope to code edition should not isolate Kakoune from its environment. On the contrary, Kakoune is expected to run on a Unix-like system, along with a lot of text-based tools, and should make it easy to interact with these tools. For example, sorting lines should be done using the Unix sort command, not with an internal implementation. Kakoune should make it easy to do that, hence the +|+ command for piping selected text through a filter. The modern Unix environment is not limited to text filters, most people use a graphical interface nowadays, and Kakoune should be able to take advantage of that, without hindering text mode support. For example Kakoune supports multiple clients on the same editing session, so that multiple windows can be used, letting the system window manager handle its responsibilities such as tiling or tabbing. Orthogonality ------------- Kakoune features should be as orthogonal as possible, for example, in Vim, there are multiple ways for modifying the buffer: Through normal/insert mode, command mode, and Vim scripts. In Kakoune, modifying the buffer is the normal/insert mode job. That means there should be clear separation of concerns between modes: * normal mode is for manipulating the selection and the selection contents. * insert mode is for interactive insertion into the buffer. * command mode is for non-editing features (opening a file, setting options...). Orthogonality is an ideal, and should not prevent common sense pragmatism, the +gf+ and +ga+ commands are not strictly selection manipulation ones, but fit nicely with other +goto+ commands, and hence are acceptable in normal mode even though they could arguably be moved to command mode. Modes should be orthogonal, and commands in modes should be as well. For example, Vim uses +d+ and +x+ for very similar things: deleting text. In Kakoune only +d+ exists, and the design ensures that +x+ is not needed. Speed ----- Kakoune should be fast, fast to use, as in a lot of editing in a few keystrokes, and fast to execute. * Vim is the benchmark here, most editing tasks should be doable in less or the same number of keys. * Kakoune be designed with asynchronicity in mind, launching a background process and using its result when available should not block the editor. * Kakoune should be implemented with speed in mind, a slow editor is a useless one. Simplicity ---------- Simplicity is nice, simplicity correlates with orthogonality and speed, and makes things easier to understand, bugs easier to fix, and code easier to change. * *No threading*: multithreading is a hard problem, and is not well suited to a text editor: - Either we want a direct result, and we need to be synchronous with the user, so getting a 4x speed up is meaningless, we need to have an algorithm which appears instantaneous the user. - Or we want an asynchronous result, and then the processing is best left to a helper command which can be reused with other Unix tools. * *No binary plugins*: shared object by themselves add a lot of complexity. Plugins add another interface to Kakoune, and goes against orthogonality. The +%sh{ ... }+ and socket interface should be made good enough for most plugin use cases. - It is better to write Kakoune-independent helper tools (intelligent code completer, source code navigation programs) that can interact with Kakoune through the shell than write them in a plugin. * *No integrated scripting language*: for the same reason as binary plugins. * *Limited smartness*: Kakoune should not try to be too smart, being smart is often unpredictable for the user, and makes things context dependent. When Kakoune tries to be smart, it should provide the alternative, 'non smart' version (+\*+ tries to detect word boundaries on the selection, but +alt-*+ permits to avoid this behavior). Unified interactive use and scripting ------------------------------------- As both an effect of Orthogonality and Simplicity, normal mode is *not* a layer on top of a text editing language layer (normal mode keys are *not* bound to text editing commands), normal mode *is* the text editing language. That means there is no +delete-selected-text+ command that +d+ is bound to, +d+ *is* the +delete selected text+ command. This permits to have scripting use case and interactive use cases share the same text editing language. Both use normal mode to express complex edition. Besides promoting simplicity by avoiding the introduction of another layer, this helps ensure the interactive editing language is as expressive as possible as we need to make it able to handle complex use cases, such as indentation hooks. Language agnostic ----------------- Kakoune should not be tailored for writing in a specific programming language. Support for different languages should be provided by a kak script file, built-in language support should be avoided. Self documenting ---------------- Kakoune should be able to document its features, live documentation along with an extensive suggestion/completion system provides the discoverability which is often lacking in non GUI tools. Documentation should as much as possible be integrated with the code so that it stays up to date. Vim compatibility ----------------- Kakoune is inspired by Vim, and should try to keep its commands close to Vim's if there are no compelling reasons to change. However self-consistency is more important than Vim compatibility. kakoune-2020.09.01/doc/interfacing.asciidoc000066400000000000000000000116021372342214000202760ustar00rootroot00000000000000Interfacing Kakoune with external programs ========================================== In order to interact with the external world, Kakoune uses the shell, mainly through the +%sh{ ... }+ string type, and its control socket. Basic interaction ----------------- For synchronous operations, +%sh{ ... }+ blocks are easy to use, they behave similarly to +$( ... )+ shell construct. For example, one can echo the current time in Kakoune's status line using: [source,bash] ---- :echo %sh{ date } ---- For asynchronous operations, the Kakoune Unix stream socket can be used. This is the same socket that Kakoune clients connect to. It is available through the +kak_session+ environment variable: the socket is +/tmp/kakoune/${username}/${kak_session}+ For example, we can echo a message in Kakoune in 10 seconds with: [source,bash] ---- :nop %sh{ { sleep 10 echo "eval -client '$kak_client' 'echo sleep ended'" | kak -p ${kak_session} } > /dev/null 2>&1 < /dev/null & } ---- * The +nop+ command is used so that any eventual output from the +%sh{ ... }+ is not interpreted by Kakoune * When writing to the socket, Kakoune has no way to guess in which client's context the command should be evaluated. A temporary context is used, which does not have any user interface, so if we want to interact with the user, we need to use the +eval+ command, with its +-client+ option to send commands to a specific client. * For the command to run asynchronously, we wrap it in a sub shell with braces, redirect its +std{in,err,out}+ to +/dev/null+, and run it in background with +&+. Using this pattern, the shell does not wait for this sub shell to finish before quitting. Interactive output ------------------ It is a frequent interaction mode to run a program and display its output in a Kakoune buffer. The common pattern to do that is to use a fifo buffer: [source,bash] ----- evaluate-commands %sh{ # Create a temporary fifo for communication output=$(mktemp -d -t kak-temp-XXXXXXXX)/fifo mkfifo ${output} # run command detached from the shell { run command here > ${output} } > /dev/null 2>&1 < /dev/null & # Open the file in Kakoune and add a hook to remove the fifo echo "edit! -fifo ${output} *buffer-name* hook buffer BufClose .* %{ nop %sh{ rm -r $(dirname ${output})} }" } ----- This is a very simple example, most of the time, the echo command will as well contain ----- set buffer filetype <...> ----- and some hooks for this filetype will have been written Completion candidates --------------------- Filetype specific completion should be provided by external programs. External completions are provided using an option to store completion, which have the following format. ---- line.column[+len]@timestamp candidate1|select1|menu1 candidate2|select2|menu2 ... ---- the first element of this string list specify where and when this completion applies, the others are a triplet `||` candidates, except for the first element which follows the `.[+]@` format to define where the completion apply in the buffer. Select commands are arbitrary Kakoune commands that will be executed each time the element is selected in the menu. The common use case is to display element specific documentation. Markup can be used in the menu text. (see <>) `set -add` adds a new completion to the list *enum(value1|value2|...)*:: an enum, taking one of the given values Cannot be used with `declare-option` *flags(value1|value2|...)*:: a set of flags, taking a combination of the given values joined by a '|' character. `set -add` adds the new flag to the combination Cannot be used with `declare-option` *-to--map*:: a list of `key=value` pairs. `set -add` adds the new pair to the hashmap or replace an already existing key. Only `str-to-str-map` options can be created with `declare-option`. == Builtin options *tabstop* `int`:: _default_ 8 + width of a tab character *indentwidth* `int`:: _default_ 4 + width (in spaces) used for indentation, 0 means a tab character *scrolloff* `coord`:: _default_ 0,0 + number of lines, columns to keep visible around the cursor when scrolling *eolformat* `enum(lf|crlf)`:: _default_ lf + the format of end of lines when writing a buffer, this is autodetected on load; values of this option assigned to the `window` scope are ignored *BOM* `enum(none|utf8)`:: _default_ none + define if the file should be written with a unicode byte order mark; values of this option assigned to the `window` scope are ignored *readonly* `bool`:: _default_ false + prevent modifications from being saved to disk, all buffers if set to `true` in the `global` scope, or current buffer if set in the `buffer` scope; values of this option assigned to the `window` scope are ignored *incsearch* `bool`:: _default_ true + execute search as it is typed *aligntab* `bool`:: _default_ false + use tabs for alignment command *autoinfo* `flags(command|onkey|normal)`:: _default_ command|onkey + display automatic information box in the enabled contexts *autocomplete* `flags(insert|prompt)`:: _default_ insert|prompt + automatically display possible completions in the enabled modes. *ignored_files* `regex`:: filenames matching this regex won't be considered as candidates on filename completion (except if the text being completed already matches it) *disabled_hooks* `regex`:: hooks whose group matches this regex won't be executed. For example indentation hooks can be disabled with `.*-indent`. (See <>) *filetype* `str`:: arbitrary string defining the type of the file. Filetype dependent actions should hook on this option changing for activation/deactivation *path* `str-list`:: _default_ ./ %/ /usr/include + directories to search for *gf* command and filenames completion `%/` represents the current buffer directory *completers* `completer-list`:: _default_ filename word=all + completion engines to use for insert mode completion (they are tried in order until one generates candidates). Existing completers are: *word=all*, *word=buffer*::: which complete using words in all buffers (*word=all*) or only the current one (*word=buffer*) *filename*::: which tries to detect when a filename is being entered and provides completion based on local filesystem *line=all*, *line=buffer*::: which complete using lines in all buffers (*line=all*) or only the current one (*line=buffer*) *option=*::: where *opt-name* is an option of type 'completions' whose contents will be used *static_words* `str-list`:: list of words that are always added to completion candidates when completing words in insert mode *extra_word_chars* `codepoint-list`:: a list of all additional codepoints that should be considered as word character. This must be set on the buffer, not the window, for word completion to offer words containing these codepoints. *matching_pairs* `codepoint-list`:: _default_ ( ) { } [ ] < > + a list of codepoints that are to be treated as matching pairs for the *m* command. *autoreload* `enum(yes|no|ask)`:: _default_ ask + auto reload the buffers when an external modification is detected *writemethod* `enum(overwrite|replace)`:: _default_ overwrite + method used to write buffers to file, `overwrite` will open the existing file and write on top of the previous data, `replace` will open a temporary file next to the target file, write it and then rename it to the target file. *debug* `flags(hooks|shell|profile|keys|commands)`:: dump various debug information in the '\*debug*' buffer *idle_timeout* `int`:: _default_ 50 + timeout, in milliseconds, with no user input that will trigger the *PromptIdle*, *InsertIdle* and *NormalIdle* hooks, and autocompletion. *fs_check_timeout* `int`:: _default_ 500 + timeout, in milliseconds, between checks in normal mode of modifications of the file associated with the current buffer on the filesystem. *modelinefmt* `string`:: A format string used to generate the mode line, that string is first expanded as a command line would be (expanding '%...{...}' strings), then markup tags are applied (see <>) Two special atoms are available as markup: *`{{mode_info}}`*::: Information about the current mode, such as `insert 3 sel` or `prompt`. The faces used are StatusLineMode, StatusLineInfo, and StatusLineValue. *`{{context_info}}`*::: Information such as `[+][recording (@)][no-hooks][new file][fifo]`, in face Information. The default value is '%val{bufname} %val{cursor_line}:%val{cursor_char_column} {{context_info}} {{mode_info}} - %val{client}@[%val{session}]' *ui_options* `str-to-str-map`:: a list of `key=value` pairs that are forwarded to the user interface implementation. The NCurses UI support the following options: *ncurses_set_title*::: if *yes* or *true*, the terminal emulator title will be changed *ncurses_status_on_top*::: if *yes*, or *true* the status line will be placed at the top of the terminal rather than at the bottom *ncurses_assistant*::: specify the nice assistant displayed in info boxes, can be *clippy* (the default), *cat*, *dilbert* or *none* *ncurses_enable_mouse*::: boolean option that enables mouse support *ncurses_change_colors*::: boolean option that can disable color palette changing if the terminfo enables it but the terminal does not support it. *ncurses_wheel_down_button*, *ncurses_wheel_up_button*::: specify which button send for wheel down/up events *ncurses_shift_function_key*::: Function key from which shifted function key start, if the terminal sends F13 for , this should be set to 12. [[startup-info]] *startup_info_version* `int`:: _default_ 0 + Controls which messages will be displayed in the startup info box, only messages relating to a Kakoune version greater than this value will be displayed. Versions are written as a single number: Like `20180413` for version `2018.04.13` == Current values The current value for an option can be viewed using <>. For example, the current value of the `BOM` option can be displayed in the status line using the `echo` command: -------------- echo %opt{BOM} -------------- The current values for all options can be dumped to the *\*debug*\* buffer using the following command: ------------- debug options ------------- kakoune-2020.09.01/doc/pages/regex.asciidoc000066400000000000000000000163241372342214000202240ustar00rootroot00000000000000= Regex == Regex Syntax Kakoune regex syntax is based on the ECMAScript syntax, as defined by the ECMA-262 standard (see <>). Kakoune's regex always run on Unicode codepoint sequences, not on bytes. == Literals Every character except the syntax characters `\^$.*+?[]{}|().` match themselves. Syntax characters can be escaped with a backslash so `\$` will match a literal `$` and `\\` will match a literal `\`. Some literals are available as escape sequences: * `\f` matches the form feed character. * `\n` matches the line feed character. * `\r` matches the carriage return character. * `\t` matches the tabulation character. * `\v` matches the vertical tabulation character. * `\0` matches the null character. * `\cX` matches the control-X character (X can be in `[A-Za-z]`). * `\xXX` matches the character whose codepoint is XX (in hexadecimal). * `\uXXXXXX` matches the character whose codepoint is XXXXXX (in hexadecimal). == Character classes The `[` character introduces a character class, matching one character from a set of characters. A character class contains a list of literals, character ranges, and character class escapes surrounded by `[` and `]`. If the first character inside a character class is `^`, then the character class is negated, meaning that it matches every character not specified in the character class. Literals match themselves, including syntax characters, so `^` does not need to be escaped in a character class. `[\*+]` matches both the `\*` character and the `+` character. Literal escape sequences are supported, so `[\n\r]` matches both the line feed and carriage return characters. The `]` character needs to be escaped for it to match a literal `]` instead of closing the character class. Character ranges are written as `-`, so `[A-Z]` matches all upper case basic letters. `[A-Z0-9]` will match all upper cases basic letters and all basic digits. The `-` characters in a character class that are not specifying a range are treated as literal `-`, so `[A-Z-+]` matches all upper case characters, the `-` character, and the `+` character. Supported character class escapes are: * `\d` which matches all digits. * `\w` which matches all word characters. * `\s` which matches all whitespace characters. * `\h` which matches all horizontal whitespace characters. Using an upper case letter instead of a lower case one will negate the character class, meaning for example that `\D` will match every non-digit character. Character class escapes can be used outside of a character class, `\d` is equivalent to `[\d]`. == Any character `.` matches any character, including new lines. == Groups Regex atoms can be grouped using `(` and `)` or `(?:` and `)`. If `(` is used, the group will be a capturing group, which means the positions from the subject strings that matched between `(` and `)` will be recorded. Capture groups are numbered starting at 1. They are numbered in the order of appearance of their `(` in the regex. A special capture group 0 is for the whole sequence that matched. * `(?:` introduces a non capturing group, which will not record the matching positions. * `(?` introduces a named capturing group, which, in addition to being referred by number, can be, in certain contexts, referred by the given name. == Alternations The `|` character introduces an alternation, which will either match its left-hand side, or its right-hand side (preferring the left-hand side) For example, `foo|bar` matches either `foo` or `bar`, `foo(bar|baz|qux)` matches `foo` followed by either `bar`, `baz` or `qux`. == Quantifier Literals, Character classes, Any characters and groups can be followed by a quantifier, which specifies the number of times they can match. * `?` matches zero or one times. * `*` matches zero or more times. * `+` matches one or more times. * `{n}` matches exactly n times. * `{n,}` matches n or more times. * `{n,m}` matches n to m times. * `{,m}` matches zero to m times. By default, quantifiers are *greedy*, which means they will prefer to match more characters if possible. Suffixing a quantifier with `?` will make it non-greedy, meaning it will prefer to match as few characters as possible. == Zero width assertions Assertions do not consume any character, but will prevent the regex from matching if they are not fulfilled. * `^` matches at the start of a line, that is just after a new line character, or at the subject begin (except if specified that the subject begin is not a start of line). * `$` matches at the end of a line, that is just before a new line, or at the subject end (except if specified that the subject's end is not an end of line). * `\b` matches at a word boundary, when one of the previous character and current character is a word character, and the other is not. * `\B` matches at a non word boundary, when both the previous character and the current character are word, or are not. * `\A` matches at the subject string begin. * `\z` matches at the subject string end. * `\K` matches anything, and resets the start position of the capture group 0 to the current position. More complex assertions can be expressed with lookarounds: * `(?=...)` is a lookahead, it will match if its content matches the text following the current position * `(?!...)` is a negative lookahead, it will match if its content does not match the text following the current position * `(?<=...)` is a lookbehind, it will match if its content matches the text preceding the current position * `(?*:: when in insert mode or in a prompt, insert the value stored in the *c* register (single character) *"*:: in normal mode, select the ** register (single character) == Alternate names Non alphanumeric registers have an alternative name that can be used in contexts where only alphanumeric identifiers are possible. == Default registers All normal-mode commands using a register default to a specific one if not specified: *"* (dquote):: default delete / copy / paste / replace register, used by: *c*, *d*, *y*, *p*, **, *

*, **, *R* and ** (see <>) */* (slash):: default search / regex register, used by: */*, **, *?*, **, *n*, **, *N*, **, ***, **, *s*, *S*, ** and ** (see <>) *@* (arobase):: default macro register, used by: *q* and *Q* (see <>) *^* (caret):: default mark register, used by: *z*, **, *Z* and ** (see <> and <>) *|* (pipe):: default shell command register, used by commands that spawn a subshell: *|*, **, *!* and ** (see <>) == Special registers Some registers are not general purposes, they cannot be written to, but they contain some special data *%* (percent):: current buffer name *.* (dot):: current selection contents *#* (hash):: selection indices (first selection has 1, second has 2, ...) *_* (underscore):: null register, always empty *:* (colon):: last entered command == Integer registers Registers *1* to *9* hold the grouped sub-matches of the regular expression used to make the last selection. Example: applying the following regular expression to the date of the day would put the day of the week in register *1*, the month in register *2*, and the day of the month in register *3*, but select the entire date: -------------------- (\w+) (\w+) (\d+) .+ -------------------- == Marks When a register is used to store a set of selections with the *Z* key (see <>), the selections are stored as a list of spans, in a format similar to `%val{selections_desc}` (see <>). However, the very first item of the list is of the form: ------------------------------------------ @@

------------------------------------------ with: *buffer name*:: `%val{buffile}` of the buffer selections relate to *timestamp*:: `%val{timestamp}` at which the selection applies to *main sel index*:: 0-based index of the main selection kakoune-2020.09.01/doc/pages/scopes.asciidoc000066400000000000000000000060521372342214000204030ustar00rootroot00000000000000= Scopes == Description Scopes are groups in which a particular Kakoune object can have different values depending on the group the value was declared in. These scoped objects are: - aliases (See <>) - faces (See <>) - highlighters (See <>) - hooks (See <>) - keymaps (See <>) - options (See <>) == Names and hierarchy Scopes are named as follows: *window*:: context linked to the window displaying a buffer. In Kakoune, the concept of a *window* must not be confused with the concept of a window at the OS level. In other terms, a window is *not* a client (like a terminal or GUI) but one of many 'views' into a buffer. There is a N:1 relationship between windows and buffers; once a window is linked to a buffer, the window's buffer never changes. Windows store a set of selections and the scroll position. *buffer*:: context linked directly to the buffer *global*:: global context linked to the instance of Kakoune The following order of priority applies to the above scopes: -------------------------- window ]> buffer ]> global -------------------------- The above priority line implies that objects can have individual values that will be resolved first in the *window* scope (highest priority), then in the *buffer* scope, and finally in the *global* scope (lowest priority). Normally, the *buffer* scope keyword means the scope associated with the currently active buffer, but it's possible to specify any existing buffer by adding an `=` and the value of `%val{buffile}` for that buffer (See <>). For example, to set the `indentwidth` option for the `/etc/fstab` buffer:: ---- set-option buffer=/etc/fstab indentwidth 8 ---- The `set-option` and `unset-option` commands also accept *current* as a valid scope name. It refers to the narrowest scope the option is set in. == Uses The scope paradigm is very useful as it allows the user to customize the behavior of the editor without modifying the configuration globally, as is the case with other editors who only have a single *global* scope by default. Examples: *filetype*:: A single buffer opened in two separate windows can have different filetypes declared in the *window* scope with 'set-option'. (See <>) *status line*:: All the buffers of the current session can have the same information displayed in the status line, except for a specific buffer (the 'modelinefmt' option can be declared in the *global* scope, and customized in the *buffer* scope with 'set-option'. (See <>) == Execution context Some commands work in a specific context that might exclude one or several scopes altogether, consequently ignoring some values of a given object. Example: the *window* scope is never considered when resolving the values of options when writing a buffer (e.g. 'BOM', 'eolformat'). kakoune-2020.09.01/doc/screenshot-i3.gif000066400000000000000000001060061372342214000174650ustar00rootroot00000000000000GIF89aP     "!&#2'"""%$$,++)(&2-(63,333543<<;:95.1. !C8)C=9S=0>A;FE:QG5kP:>>@C>A(Uw>AALLKGGDRMJNQMRRMYTIHNPNMQXXVPPQfXIc]Yu]F^a\fd[vhS_gj^aafeekjgslivtjzyvopoa^a[*^1b-d4j5l:g9r=u;k;pWzZwj}wzl|h]LwXtBzE|KyJ}RvL}c~z]{{yoilvsyzل]MYSX[Ȉi׈dɕmהkɗvԙuˍregihwssפxˤxxwpLxAi.~ќѬ騇곐η콬坄ŨǸηūȳɳг᾿!! ImageMagickgamma=0,PAH*\ȰÇ#JHŋ3jȱǏ CIɓ(S\ɲ˗0cʜ)R͛8sɳϟ@ JѣH*]ʴӧPJJիXʵׯ`ÊKٳhӪ]˶۷pʝKݻx˷٬ LÈ+^̸1R#KL˘3k̹s[ǠCӒiKO&ͺװ=˞Mjͭ۶ﶼ!M8\؁U4]:j }T:6C?}zv˻GO]{wzξ{]{OWݑߕo 7 Zי8m>!vx \ަኑ^Se'x@wQ6&u8O>Tdz:ި{L6$a}8afMaYT%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&3LS1 (SL#N\S7ͨS=C㓌9˜#Ps DC̕ĸ%PZߦMk{߰HH'dRG-r $Ȉ kmcѮ[o\uk-&R ڌmGйEw[H_5BSMF5YV>/It]zw[Ua'yS}{|ˏgշkůY '76ne[BG%[+@isp⋝m}cx8K[e%5n-,rK\.jQB "PBtBG#2z0Ld 0\^mǽЎ_!>/Kps8:äa:r$[%\a8EI1[XT>f%/xG/}Ό+^ r+ۚ(GЗ؜EQ\TeH>n3U$98ύF$Fppw? %U3)ƶhhgIj`LpSL<HLb3C*?ƍ~ӡ$3^ i7G8?QA֫OTγ \=yJ}*%$a f_7}7>>G,u>eg %ikTцD%i:Ѿ5M=,6Hڸ.*X͚ <[)Vv]`ܞ k KCM[EڽQm'm[D=.)M67e!vw Z}!3;ڍI,nX^FR`L9K7Juz*ce)~Z4kH,sE{#--P;%lhP`.x MNO8UEMz{koƌm&czòqbuuoeg=DJ}bЁ/khEc ϊZPҕt|MRK&rAjQԥ6QjUխvakYϚֵqk]׽la6le/׋cmiOնmmomAq/r ]b[r\=xo}]U[)(#n7MpW; 7;-mާ8Ar%7Qrbܩ[qc~9[~ #8/q ʑt/Mwӡt4'zƏ^t,:׷>HB˞su[Qwwϝu'"׭un5N{S78n}ݐx-]myo;_'/x[_z\wpoP 00R&]a0e000V{PoӍX0 g 0 p _O岐obosBĜ ٰ 0 !0p6 1q!1%qd)-115q9=A1EqIMQ1UqY]a1eqimq1uqy}1q1q1q!-;kakoune-2020.09.01/doc/writing_scripts.asciidoc000066400000000000000000000115561372342214000212470ustar00rootroot00000000000000Writing kak scripts =================== Interaction with external tools from a Kakoune session is supported through the use of scripts. Once loaded by the editor (either automatically or manually), they allow extending the functionalities provided by default through commands and hooks. Their implementation should be kept as simple as possible, as they are not meant to be generic tools themselves but a mere API to actual software. --------------------------------------------------- +------+ +--> | tmux | | +------+ | +---------+ | +------+ | Kakoune | <-------> scripts +-+--> | X11 | +---------+ | +------+ | | +------+ +--> | ... | +------+ --------------------------------------------------- Dependencies ------------ The amount of dependencies of a given script should be kept to a minimum for practicality reasons, and have to be reasonable and expected considering the purpose of the script itself. Examples: * the `clang.kak` script provides with code completion using the `clang` compiler * the `tmux.kak` script provides with terminal splitting using the `tmux` multiplexer * the `ctags.kak` script provides with symbol lookups using the `readtags` utility provided by some `ctags` implementations Naming convention ----------------- All options and commands declared in a Kakoune script have to be prefixed with the name of the script, or a one word description of the purpose of the script. Examples: * in `tmux.kak`: command `tmux-new-window` * in `comment.kak`: option `comment_line` The following conventions apply as well: * *options*: if a separator is needed to separate a multiple word option name, an underscore should be used to allow shell scopes to use them * *commands*: if a separator is needed, a hyphen is usually used to differentiate a command name from an option's Documentation ------------- Non-hidden commands and options should always be declared with a documentation string, so that their purpose is clearly described whenever completed upon interactively from the prompt. POSIX shell ----------- Shell expansions are a useful tool to interact with an external utility, and the shell code that they contain should be as portable as possible. As such, scripts that rely on those expansions have to be implemented with POSIX in mind, most shells follow this standard nowadays which somewhat guarantees that the script will be portable across the most common systems. Common shell patterns --------------------- Printing variables ~~~~~~~~~~~~~~~~~~ In order to print a string that contains a variable expansion, prefer `printf` to `echo`, as the latter is implementation defined and may interpret some characters differently depending on the shell (e.g. flags, backslashes). ---------------------------------- printf %s\\n "${var}" printf "value: %s\\n" "${var}" ---------------------------------- The following won't cause any issues, as the string to print doesn't contain ambiguous characters: ------------------------------------- echo "set global scrolloff 999,0" ------------------------------------- For more information about portability issues related to `echo`, refer to https://www.etalabs.net/sh_tricks.html[Rich's sh tricks]. Variable base name ~~~~~~~~~~~~~~~~~~ Replace `$(basename "${var}")` with `"${var##*/}"`. Testing ~~~~~~~ The `[[` keyword is provided by `bash`, and should be replaced with `[`. Standard error redirection ~~~~~~~~~~~~~~~~~~~~~~~~~~ Redirecting both standard and error streams is simplified in the `bash` shell with the `&>` operator, however this syntax is not portable and has to be replaced with the following: `>/dev/null 2>&1`. Regular expression ~~~~~~~~~~~~~~~~~~ The `bash` shell provides with a `[[` keyword that supports the `=~` operator to match a regular expression against a variable. This functionality can be implemented with the `expr` utility: * `expr "${var}" : '[a-z]*' >/dev/null` returns successfully when the variable is empty or only contains lowercase characters, otherwise a non-zero exit code is returned * `expr "${var}" : '\([a-z]*\)'` prints the variable when empty or only contains lowercase characters Note that the regular expression matches the whole string, using the `^` and `$` anchors is an undefined behavior. Running a process in the background ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In order to get a process running in the background without having it quit when the shell scope that spawns it terminates, use the following syntax: -------------------------------- { command } /dev/null 2>&1 & -------------------------------- kakoune-2020.09.01/gdb/000077500000000000000000000000001372342214000142745ustar00rootroot00000000000000kakoune-2020.09.01/gdb/kakoune.py000066400000000000000000000136071372342214000163120ustar00rootroot00000000000000import gdb.printing class ArrayIterator: def __init__(self, data, count): self.data = data self.count = count self.index = 0 def __iter__(self): return self def next(self): if self.index == self.count: raise StopIteration index = self.index self.index = self.index + 1 return ('[%d]' % index, (self.data + index).dereference()) def __next__(self): return self.next() class ArrayView: """Print a ArrayView""" def __init__(self, val): self.val = val def display_hint(self): return 'array' def children(self): return ArrayIterator(self.val['m_pointer'], self.val['m_size']) def to_string(self): type = self.val.type.template_argument(0).unqualified().strip_typedefs() return "ArrayView<%s>" % (type) class LineAndColumn: """Print a LineAndColumn""" def __init__(self, val): self.val = val def to_string(self): value_type = self.val.type.unqualified() return "%s(%s, %s)" % (value_type, self.val['line'], self.val['column']) class BufferCoordAndTarget: """Print a BufferCoordAndTarget""" def __init__(self, val): self.val = val def to_string(self): value_type = self.val.type.unqualified() return "%s(%s, %s, %s)" % (value_type, self.val['line'], self.val['column'], self.val['target']) class BufferIterator: """ Print a BufferIterator""" def __init__(self, val): self.val = val def to_string(self): line = self.val['m_coord']['line'] column = self.val['m_coord']['column'] if self.val['m_buffer']['m_ptr'] != 0: buf = self.val['m_buffer']['m_ptr'].dereference()['m_name'] return "buffer<%s>@(%s, %s)" % (buf, line, column) else: return "buffer@(%s, %s)" % (line, column) class String: """ Print a String""" def __init__(self, val): self.val = val def to_string(self): data = self.val["m_data"] if (data["s"]["size"] & 1) != 1: ptr = data["l"]["ptr"] len = data["l"]["size"] else: ptr = data["s"]["string"] len = data["s"]["size"] >> 1 return "\"%s\"" % (ptr.string("utf-8", "ignore", len)) class StringView: """ Print a StringView""" def __init__(self, val): self.val = val def to_string(self): len = self.val['m_length']['m_value'] return "\"%s\"" % (self.val['m_data'].string("utf-8", "ignore", len)) class StringDataPtr: """ Print a RefPtr""" def __init__(self, val): self.val = val def to_string(self): ptr = self.val['m_ptr'] str_type = gdb.lookup_type("char").pointer() len = ptr.dereference()['length'] refcount = ptr.dereference()['refcount'] content = (ptr + 1).cast(str_type).string("utf-8", "ignore", len) return "\"%s\" (ref:%d)" % (content.replace("\n", "\\n"), refcount) class RefPtr: """ Print a RefPtr""" def __init__(self, val): self.val = val def to_string(self): ptr = self.val['m_ptr'] return "\"refptr %s\"" % (ptr) class Option: """ Print a Option""" def __init__(self, val): self.val = val def to_string(self): return self.val["m_value"] class CharCount: """Print a CharCount""" def __init__(self, val): self.val = val def to_string(self): return self.val["m_value"] class ColumnCount: """Print a ColumnCount""" def __init__(self, val): self.val = val def to_string(self): return self.val["m_value"] class ByteCount: """Print a ByteCount""" def __init__(self, val): self.val = val def to_string(self): return self.val["m_value"] class LineCount: """Print a LineCount""" def __init__(self, val): self.val = val def to_string(self): return self.val["m_value"] class Color: """Print a Color""" def __init__(self, val): self.val = val def to_string(self): named_color = gdb.lookup_type("Kakoune::Color::NamedColor") if self.val["color"] == named_color["Kakoune::Color::RGB"].enumval: return "%s #%02x%02x%02x" % (self.val["color"], self.val["r"], self.val["g"], self.val["b"]) else: return self.val["color"] class Regex: """Print a Regex""" def __init__(self, val): self.val = val def to_string(self): return "regex%s" % (self.val["m_str"]) def build_pretty_printer(): pp = gdb.printing.RegexpCollectionPrettyPrinter("kakoune") pp.add_printer('ArrayView', '^Kakoune::(Const)?ArrayView<.*>$', ArrayView) pp.add_printer('LineAndColumn', '^Kakoune::(Buffer|Display)Coord$', LineAndColumn) pp.add_printer('BufferCoordAndTarget', '^Kakoune::BufferCoordAndTarget$', BufferCoordAndTarget) pp.add_printer('BufferIterator', '^Kakoune::BufferIterator$', BufferIterator) pp.add_printer('String', '^Kakoune::String$', String) pp.add_printer('StringView', '^Kakoune::(StringView|SharedString)$', StringView) pp.add_printer('StringDataPtr', '^Kakoune::StringDataPtr$', StringDataPtr) pp.add_printer('StringDataPtr', '^Kakoune::RefPtr$', StringDataPtr) pp.add_printer('RefPtr', '^Kakoune::RefPtr<.*>$', RefPtr) pp.add_printer('Option', '^Kakoune::Option$', Option) pp.add_printer('LineCount', '^Kakoune::LineCount$', LineCount) pp.add_printer('CharCount', '^Kakoune::CharCount$', CharCount) pp.add_printer('ColumnCount', '^Kakoune::ColumnCount$', ColumnCount) pp.add_printer('ByteCount', '^Kakoune::ByteCount$', ByteCount) pp.add_printer('Color', '^Kakoune::Color$', Color) pp.add_printer('Regex', '^Kakoune::Regex$', Regex) return pp kakoune-2020.09.01/rc/000077500000000000000000000000001372342214000141445ustar00rootroot00000000000000kakoune-2020.09.01/rc/detection/000077500000000000000000000000001372342214000161225ustar00rootroot00000000000000kakoune-2020.09.01/rc/detection/editorconfig.kak000066400000000000000000000063051372342214000212720ustar00rootroot00000000000000# http://editorconfig.org/#file-format-details # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](editorconfig) %{ set-option buffer filetype ini set-option buffer static_words indent_style indent_size tab_width \ end_of_line charset insert_final_newline trim_trailing_whitespace root \ latin1 utf-8 utf-8-bom utf-16be utf-16le lf cr crlf unset space tab max_line_length } define-command editorconfig-load -params ..1 -docstring "editorconfig-load [file]: set formatting behavior according to editorconfig" %{ evaluate-commands %sh{ command -v editorconfig >/dev/null 2>&1 || { echo "fail editorconfig could not be found"; exit 1; } file="${1:-$kak_buffile}" case $file in /*) # $kak_buffile is a full path that starts with a '/' printf %s\\n "remove-hooks buffer editorconfig-hooks" editorconfig "$file" | awk -v file="$file" -F= -- ' /indent_style=/ { indent_style = $2 } /indent_size=/ { indent_size = $2 == "tab" ? 4 : $2 } /tab_width=/ { tab_width = $2 } /end_of_line=/ { end_of_line = $2 } /charset=/ { charset = $2 } /trim_trailing_whitespace=/ { trim_trailing_whitespace = $2 } /max_line_length=/ { max_line_length = $2 } END { if (indent_style == "tab") { print "set-option buffer indentwidth 0" print "set-option buffer aligntab true" } if (indent_style == "space") { print "set-option buffer indentwidth " (indent_size == "tab" ? 4 : indent_size) print "set-option buffer aligntab false" } if (indent_size || tab_width) { print "set-option buffer tabstop " (tab_width ? tab_width : indent_size) } if (end_of_line == "lf" || end_of_line == "crlf") { print "set-option buffer eolformat " end_of_line } if (charset == "utf-8-bom") { print "set-option buffer BOM utf8" } if (trim_trailing_whitespace == "true") { print "hook buffer BufWritePre \"" file "\" -group editorconfig-hooks %{ try %{ execute-keys -draft %{ %s\\h+$d } } }" } if (max_line_length && max_line_length != "off") { print "set window autowrap_column " max_line_length print "autowrap-enable" print "add-highlighter window/ column %sh{ echo $((" max_line_length "+1)) } default,bright-black" } } ' ;; esac } } kakoune-2020.09.01/rc/detection/file.kak000066400000000000000000000015001372342214000175250ustar00rootroot00000000000000hook global BufOpenFile .* %{ evaluate-commands %sh{ if [ -z "${kak_opt_filetype}" ]; then mime=$(file -b --mime-type -L "${kak_buffile}") mime=${mime%;*} case "${mime}" in application/*+xml) filetype="xml" ;; image/*+xml) filetype="xml" ;; #SVG message/rfc822) filetype="mail" ;; text/x-shellscript) filetype="sh" ;; text/x-script.*) filetype="${mime#text/x-script.}" ;; text/x-*) filetype="${mime#text/x-}" ;; text/*) filetype="${mime#text/}" ;; application/x-*) filetype="${mime#application/x-}" ;; application/*) filetype="${mime#application/}" ;; esac if [ -n "${filetype}" ]; then printf "set-option buffer filetype '%s'\n" "${filetype}" fi fi } } kakoune-2020.09.01/rc/detection/modeline.kak000066400000000000000000000104631372342214000204120ustar00rootroot00000000000000## ## modeline.kak by lenormf ## ## Currently supported modeline format: vim ## Also supports kakoune options with a 'kak' or 'kakoune' prefix ## Only a few options are supported, in order to prevent the ## buffers from poking around the configuration too much declare-option -docstring "amount of lines that will be checked at the beginning and the end of the buffer" \ int modelines 5 define-command -hidden modeline-parse-impl %{ evaluate-commands %sh{ # Translate a vim option into the corresponding kakoune one translate_opt_vim() { readonly key="$1" readonly value="$2" tr="" case "${key}" in so|scrolloff) tr="scrolloff ${value},${kak_opt_scrolloff##*,}";; siso|sidescrolloff) tr="scrolloff ${kak_opt_scrolloff%%,*},${value}";; ts|tabstop) tr="tabstop ${value}";; sw|shiftwidth) tr="indentwidth ${value}";; tw|textwidth) tr="autowrap_column ${value}";; ff|fileformat) case "${value}" in unix) tr="eolformat lf";; dos) tr="eolformat crlf";; *) printf %s\\n "echo -debug 'Unsupported file format: ${value}'";; esac ;; ft|filetype) tr="filetype ${value}";; bomb) tr="BOM utf8";; nobomb) tr="BOM none";; spelllang|spl) tr="spell_lang ${value%%,*}";; *) printf %s\\n "echo -debug 'Unsupported vim variable: ${key}'";; esac [ -n "${tr}" ] && printf %s\\n "set-option buffer ${tr}" } # Pass a few whitelisted options to kakoune directly translate_opt_kakoune() { readonly key="$1" readonly value="$2" case "${key}" in scrolloff|tabstop|indentwidth|autowrap_column|eolformat|filetype|BOM|spell_lang);; *) printf %s\\n "echo -debug 'Unsupported kakoune variable: ${key}'" return;; esac printf %s\\n "set-option buffer ${key} ${value}" } case "${kak_selection}" in *vi:*|*vim:*) type_selection="vim";; *kak:*|*kakoune:*) type_selection="kakoune";; *) echo "echo -debug Unsupported modeline format"; exit 1 ;; esac # The following subshell will keep the actual options of the modeline, and strip: # - the text that leads the first option, according to the official vim modeline format # - the trailing text after the last option, and an optional ':' sign before it # It will also convert the ':' seperators beween the option=value pairs # More info: http://vimdoc.sourceforge.net/htmldoc/options.html#modeline printf %s "${kak_selection}" | sed \ -e 's/^[^:]\{1,\}://' \ -e 's/[ \t]*set\{0,1\}[ \t]//' \ -e 's/:[^a-zA-Z0-9_=-]*$//' \ -e 's/:/ /g' \ | tr ' ' '\n' \ | while read -r option; do name_option="${option%%=*}" value_option="${option#*=}" [ -z "${option}" ] && continue case "${type_selection}" in vim) tr=$(translate_opt_vim "${name_option}" "${value_option}");; kakoune) tr=$(translate_opt_kakoune "${name_option}" "${value_option}");; *) tr="";; esac [ -n "${tr}" ] && printf %s\\n "${tr}" done } } # Add the following function to a hook on BufOpenFile to automatically parse modelines # Select the first and last `modelines` lines in the buffer, only keep modelines # ref. options.txt (in vim `:help options`) : 2 forms of modelines: # [text]{white}{vi:|vim:|ex:}[white]{options} # [text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text] define-command modeline-parse -docstring "Read and interpret vi-format modelines at the beginning/end of the buffer" %{ try %{ evaluate-commands -draft %{ execute-keys s\A|.\z %opt{modelines}k %opt{modelines}X \ s^\S*?\s+?(vim?|kak(oune)?):\s?[^\n]+ evaluate-commands -draft -itersel modeline-parse-impl } } } kakoune-2020.09.01/rc/filetype/000077500000000000000000000000001372342214000157655ustar00rootroot00000000000000kakoune-2020.09.01/rc/filetype/arch-linux.kak000066400000000000000000000001551372342214000205300ustar00rootroot00000000000000# package build description file hook global BufCreate (.*/)?PKGBUILD %{ set-option buffer filetype sh } kakoune-2020.09.01/rc/filetype/asciidoc.kak000066400000000000000000000065201372342214000202360ustar00rootroot00000000000000# http://asciidoc.org/ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .+\.(a(scii)?doc|asc) %{ set-option buffer filetype asciidoc } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook -group asciidoc-highlight global WinSetOption filetype=asciidoc %{ require-module asciidoc add-highlighter window/asciidoc ref asciidoc hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/asciidoc } } provide-module asciidoc %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/asciidoc group # Titles and headers (multi-line style) add-highlighter shared/asciidoc/ regex (\A|\n\n)[^\n]+\n={2,}\h*$ 0:title add-highlighter shared/asciidoc/ regex (\A|\n\n)[^\n]+\n-{2,}\h*$ 0:header add-highlighter shared/asciidoc/ regex (\A|\n\n)[^\n]+\n~{2,}\h*$ 0:header add-highlighter shared/asciidoc/ regex (\A|\n\n)[^\n]+\n\^{2,}\h*$ 0:header # Titles and headerss (one-line style) add-highlighter shared/asciidoc/ regex (\A|\n\n)=\h+[^\n]+$ 0:title add-highlighter shared/asciidoc/ regex (\A|\n\n)={2,}\h+[^\n]+$ 0:header # Comments add-highlighter shared/asciidoc/ regex ^//(?:[^\n/][^\n]*|)$ 0:comment add-highlighter shared/asciidoc/ regex ^(/{4,}).*?\n(/{4,})$ 0:comment # List titles add-highlighter shared/asciidoc/ regex ^\.[^\h\W][^\n]*$ 0:title # Bulleted lists add-highlighter shared/asciidoc/ regex ^\h*(?[-\*])\h+[^\n]+$ 0:list bullet:bullet add-highlighter shared/asciidoc/ regex ^\h*(?[-\*]+)\h+[^\n]+(\n\h+[^-\*\n]*)?$ 0:list bullet:bullet # Blocks add-highlighter shared/asciidoc/ regex ^(-{3,})\n[^\n\h].*?\n(-{3,})$ 0:block add-highlighter shared/asciidoc/ regex ^(={3,})\n[^\n\h].*?\n(={3,})$ 0:block add-highlighter shared/asciidoc/ regex ^(~{3,})\n[^\n\h].*?\n(~{3,})$ 0:block add-highlighter shared/asciidoc/ regex ^(\*{3,})\n[^\n\h].*?\n(\*{3,})$ 0:block # Monospaced text add-highlighter shared/asciidoc/ regex \B(?:\+[^\n]+?\+|`[^\n]+?`)\B 0:mono # Bolded text add-highlighter shared/asciidoc/ regex \s\*[^\n\*]+\*\B 0:+b add-highlighter shared/asciidoc/ regex \h\*[^\n\*]+\*\B 0:+b add-highlighter shared/asciidoc/ regex \*{2}(?!\h)[^\n\*]+\*{2} 0:+b add-highlighter shared/asciidoc/ regex \h\*{2}[^\n\*]+\*{2} 0:+b # Italicized text # (these are simpler since they aren't able to _also_ be bullet characters.) add-highlighter shared/asciidoc/ regex \b_[^\n]+?_\b 0:+i add-highlighter shared/asciidoc/ regex __[^\n]+?__ 0:+i # Attributes add-highlighter shared/asciidoc/ regex ^:(?:(?!?)[-\w]+|[-\w]+(?!?)): 0:meta neg:operator add-highlighter shared/asciidoc/ regex [^\\](\{[-\w]+\})[^\\]? 1:meta # Options add-highlighter shared/asciidoc/ regex ^\[[^\n]+\]$ 0:operator # Admonition pargraphs add-highlighter shared/asciidoc/ regex ^(NOTE|TIP|IMPORTANT|CAUTION|WARNING): 0:block add-highlighter shared/asciidoc/ regex ^\[(NOTE|TIP|IMPORTANT|CAUTION|WARNING)\]$ 0:block # Links, inline macros add-highlighter shared/asciidoc/ regex \b((?:https?|ftp|irc://)[^\h\[]+)\[([^\n]*)?\] 1:link 2:+i add-highlighter shared/asciidoc/ regex (link|mailto):([^\n]+)(?:\[([^\n]*)\]) 1:keyword 2:link 3:+i add-highlighter shared/asciidoc/ regex (xref):([^\n]+)(?:\[([^\n]*)\]) 1:keyword 2:meta 3:+i add-highlighter shared/asciidoc/ regex (<<([^\n><]+)>>) 1:link 2:meta # Commands # ‾‾‾‾‾‾‾‾ } kakoune-2020.09.01/rc/filetype/awk.kak000066400000000000000000000066661372342214000172550ustar00rootroot00000000000000# Detection # --------- hook global BufCreate .*\.awk %{ set-option buffer filetype awk } # Initialization # -------------- hook global WinSetOption filetype=awk %{ require-module awk hook window InsertChar \n -group awk-indent awk-indent-on-new-line hook window ModeChange pop:insert:.* -group awk-trim-indent awk-trim-indent hook -once -always window WinSetOption filetype=.* %{ remove-hooks window awk-.+ } } hook -group awk-highlight global WinSetOption filetype=awk %{ add-highlighter window/awk ref awk hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/awk } } provide-module awk %@ # Highlighters # ------------ add-highlighter shared/awk regions add-highlighter shared/awk/code default-region group add-highlighter shared/awk/comment region '#' '$' fill comment add-highlighter shared/awk/string region '"' (?|\?|~ 0:operator evaluate-commands %sh{ # Grammar patterns="BEGIN END BEGINFILE ENDFILE" variables="BINMODE CONVFMT FIELDWIDTHS FPAT FS IGNORECASE LINT OFMT OFS ORS PREC ROUNDMODE RS SUBSEP TEXTDOMAIN ARGC ARGV ARGIND ENVIRON ERRNO FILENAME FNR NF FUNCTAB NR PROCINFO RLENGTH RSTART RT SYMTAB" keywords="break continue delete exit function getline next print printf return switch nextfile func if else while for do" functions="atan2 cos exp int intdiv log rand sin sqrt srand asort asort1 gensub gsub index length match patsplit split sprintf strtonum sub substr tolower toupper close fflush system mktime strftime systime and compl lshift or rshift xor isarray typeof bindtextdomain dcgettext dcngetext" join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } # Add the language's grammar to the static completion list printf %s\\n "hook global WinSetOption filetype=awk %{ set-option window static_words $(join "${patterns} ${variables} ${keywords} ${functions}" ' ') }" # Highlight keywords printf %s\\n "add-highlighter shared/awk/code/ regex \b($(join "${patterns}" '|'))\b 0:type" printf %s\\n "add-highlighter shared/awk/code/ regex \b($(join "${variables}" '|'))\b 0:meta" printf %s\\n "add-highlighter shared/awk/code/ regex \b($(join "${keywords}" '|'))\b 0:keyword" printf %s\\n "add-highlighter shared/awk/code/ regex \b($(join "${functions}" '|'))\b 0:function" } # Commands # -------- define-command -hidden awk-indent-on-new-line %[ evaluate-commands -draft -itersel %[ # preserve previous line indent try %[ execute-keys -draft K ] # cleanup trailing whitespaces from previous line try %[ execute-keys -draft k s \h+$ d ] # indent after line ending in opening curly brace try %[ execute-keys -draft k \{\h*(#.*)?$ j ] # deindent closing brace when after cursor try %[ execute-keys -draft ^\h*\} gh / \} m 1 ] ] ] define-command -hidden awk-trim-indent %{ try %{ execute-keys -draft s ^\h+$ d } } @ kakoune-2020.09.01/rc/filetype/c-family.kak000066400000000000000000000615541372342214000201710ustar00rootroot00000000000000# Detection hook global BufCreate .*\.(cc|cpp|cxx|C|hh|hpp|hxx|H)$ %{ set-option buffer filetype cpp } hook global BufSetOption filetype=c\+\+ %{ hook -once buffer NormalIdle '' "set-option buffer filetype cpp" } hook global BufCreate .*\.c$ %{ set-option buffer filetype c } hook global BufCreate .*\.h$ %{ try %{ execute-keys -draft %{%s\b::\b|\btemplate\h*|\bclass\h+\w+|\b(typename|namespace)\b|\b(public|private|protected)\h*:} set-option buffer filetype cpp } catch %{ set-option buffer filetype c } } hook global BufCreate .*\.m %{ set-option buffer filetype objc } hook global WinSetOption filetype=(c|cpp|objc) %[ require-module c-family evaluate-commands "set-option window static_words %%opt{%val{hook_param_capture_1}_static_words}" hook -group "%val{hook_param_capture_1}-trim-indent" window ModeChange pop:insert:.* c-family-trim-indent hook -group "%val{hook_param_capture_1}-insert" window InsertChar \n c-family-insert-on-newline hook -group "%val{hook_param_capture_1}-indent" window InsertChar \n c-family-indent-on-newline hook -group "%val{hook_param_capture_1}-indent" window InsertChar \{ c-family-indent-on-opening-curly-brace hook -group "%val{hook_param_capture_1}-indent" window InsertChar \} c-family-indent-on-closing-curly-brace hook -group "%val{hook_param_capture_1}-insert" window InsertChar \} c-family-insert-on-closing-curly-brace alias window alt "%val{hook_param_capture_1}-alternative-file" hook -once -always window WinSetOption filetype=.* " remove-hooks window %val{hook_param_capture_1}-.+ unalias window alt %val{hook_param_capture_1}-alternative-file " ] hook -group c-highlight global WinSetOption filetype=c %{ add-highlighter window/c ref c hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/c } } hook -group cpp-highlight global WinSetOption filetype=cpp %{ add-highlighter window/cpp ref cpp hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cpp } } hook -group objc-highlight global WinSetOption filetype=objc %{ add-highlighter window/objc ref objc hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/objc } } provide-module c-family %§ define-command -hidden c-family-trim-indent %{ # remove the line if it's empty when leaving the insert mode try %{ execute-keys -draft 1s^(\h+)$ d } } define-command -hidden c-family-indent-on-newline %< evaluate-commands -draft -itersel %< execute-keys try %< # if previous line is part of a comment, do nothing execute-keys -draft /\* ^\h*[^/*\h] > catch %< # else if previous line closed a paren (possibly followed by words and a comment), # copy indent of the opening paren line execute-keys -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?(?://[^\n]+)?\n\z mJ 1 > catch %< # else indent new lines with the same level as the previous one execute-keys -draft K > # remove previous empty lines resulting from the automatic indent try %< execute-keys -draft k ^\h+$ Hd > # indent after an opening brace or parenthesis at end of line try %< execute-keys -draft k [{(]\h*$ j > # indent after a label try %< execute-keys -draft k s[a-zA-Z0-9_-]+:\h*$ j > # indent after a statement not followed by an opening brace try %< execute-keys -draft k s\)\h*(?://[^\n]+)?\n\z \ mB \A\b(if|for|while)\b j > try %< execute-keys -draft k s \belse\b\h*(?://[^\n]+)?\n\z \ j > # deindent after a single line statement end try %< execute-keys -draft K \;\h*(//[^\n]+)?$ \ K s\)(\h+\w+)*\h*(//[^\n]+)?\n([^\n]*\n){2}\z \ MB \A\b(if|for|while)\b 1 > try %< execute-keys -draft K \;\h*(//[^\n]+)?$ \ K s \belse\b\h*(?://[^\n]+)?\n([^\n]*\n){2}\z \ 1 > # deindent closing brace(s) when after cursor try %< execute-keys -draft ^\h*[})] gh / [})] m 1 > # align to the opening parenthesis or opening brace (whichever is first) # on a previous line if its followed by text on the same line try %< evaluate-commands -draft %< # Go to opening parenthesis and opening brace, then select the most nested one try %< execute-keys [c [({],[)}] > # Validate selection and get first and last char execute-keys \A[{(](\h*\S+)+\n "(([^"]*"){2})* '(([^']*'){2})* L # Remove possibly incorrect indent from new line which was copied from previous line try %< execute-keys -draft s\h+ d > # Now indent and align that new line with the opening parenthesis/brace execute-keys 1 & > > > > define-command -hidden c-family-indent-on-opening-curly-brace %[ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft -itersel h)M \A\(.*\)\h*\n\h*\{\z 1 ] # align indent with opening paren when { is entered on a new line after the else try %[ execute-keys -draft -itersel hK s \belse\b\h*(?://[^\n]+)?\n\h*\{ 1 ] ] define-command -hidden c-family-indent-on-closing-curly-brace %[ # align to opening curly brace when alone on a line try %[ # in case open curly brace follows a closing paren, align indent with opening paren execute-keys -itersel -draft ^\h+\}$hm )M \A\(.*\)\h\{.*\}\z 1 ] catch %[ # otherwise align with open curly brace execute-keys -itersel -draft ^\h+\}$hm1 ] catch %[] ] define-command -hidden c-family-insert-on-closing-curly-brace %[ # add a semicolon after a closing brace if part of a class, union or struct definition try %[ execute-keys -itersel -draft hmB\A\h*(class|struct|union|enum) ';i;' ] ] define-command -hidden c-family-insert-on-newline %[ evaluate-commands -itersel -draft %[ execute-keys try %[ evaluate-commands -draft -save-regs '/"' %[ # copy the commenting prefix execute-keys -save-regs '' k 1s^\h*(//+\h*) y try %[ # if the previous comment isn't empty, create a new one execute-keys ^\h*//+\h*$ js^\h*P ] catch %[ # if there is no text in the previous comment, remove it completely execute-keys d ] ] ] try %[ # if the previous line isn't within a comment scope, break execute-keys -draft k ^(\h*/\*|\h+\*(?!/)) # find comment opening, validate it was not closed, and check its using star prefixes execute-keys -draft /\* \*/ \A\h*/\*([^\n]*\n\h*\*)*[^\n]*\n\h*.\z try %[ # if the previous line is opening the comment, insert star preceeded by space execute-keys -draft k^\h*/\* execute-keys -draft i* ] catch %[ try %[ # if the next line is a comment line insert a star execute-keys -draft j^\h+\* execute-keys -draft i* ] catch %[ try %[ # if the previous line is an empty comment line, close the comment scope execute-keys -draft k^\h+\*\h+$ 1s\*(\h*)c/ ] catch %[ # if the previous line is a non-empty comment line, add a star execute-keys -draft i* ] ] ] # trim trailing whitespace on the previous line try %[ execute-keys -draft s\h+$ d ] # align the new star with the previous one execute-keys K1s^[^*]*(\*)& ] ] ] # Regions definition are the same between c++ and objective-c evaluate-commands %sh{ for ft in c cpp objc; do if [ "${ft}" = "objc" ]; then maybe_at='@?' else maybe_at='' fi cat <<-EOF add-highlighter shared/$ft regions add-highlighter shared/$ft/code default-region group add-highlighter shared/$ft/string region %{$maybe_at(?%ggxs\.c_A_INCLUDEDggxyppI#ifndefjI#definejI#endif//O' ;; pragma) echo 'execute-keys ggi#pragmaonce' ;; *);; esac } } hook -group c-family-insert global BufNewFile .*\.(h|hh|hpp|hxx|H) c-family-insert-include-guards declare-option -docstring "colon separated list of path in which header files will be looked for" \ str-list alt_dirs '.' '..' define-command -hidden c-family-alternative-file %{ evaluate-commands %sh{ file="${kak_buffile##*/}" file_noext="${file%.*}" dir=$(dirname "${kak_buffile}") # Set $@ to alt_dirs eval "set -- ${kak_quoted_opt_alt_dirs}" case ${file} in *.c|*.cc|*.cpp|*.cxx|*.C|*.inl|*.m) for alt_dir in "$@"; do for ext in h hh hpp hxx H; do altname="${dir}/${alt_dir}/${file_noext}.${ext}" if [ -f ${altname} ]; then printf 'edit %%{%s}\n' "${altname}" exit fi done done ;; *.h|*.hh|*.hpp|*.hxx|*.H) for alt_dir in "$@"; do for ext in c cc cpp cxx C m; do altname="${dir}/${alt_dir}/${file_noext}.${ext}" if [ -f ${altname} ]; then printf 'edit %%{%s}\n' "${altname}" exit fi done done ;; *) echo "fail 'extension not recognized'" exit ;; esac echo "fail 'alternative file not found'" } } define-command c-alternative-file -docstring "Jump to the alternate c file (header/implementation)" %{ c-family-alternative-file } define-command cpp-alternative-file -docstring "Jump to the alternate cpp file (header/implementation)" %{ c-family-alternative-file } define-command objc-alternative-file -docstring "Jump to the alternate objc file (header/implementation)" %{ c-family-alternative-file } § # Module aliases provide-module c %{ require-module c-family } provide-module cpp %{ require-module c-family } provide-module objc %{ require-module c-family } kakoune-2020.09.01/rc/filetype/cabal.kak000066400000000000000000000056761372342214000175350ustar00rootroot00000000000000# http://haskell.org/cabal # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](cabal) %{ set-option buffer filetype cabal } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=cabal %[ require-module cabal hook window ModeChange pop:insert:.* -group cabal-trim-indent cabal-trim-indent hook window InsertChar \n -group cabal-indent cabal-indent-on-new-line hook window InsertChar \{ -group cabal-indent cabal-indent-on-opening-curly-brace hook window InsertChar \} -group cabal-indent cabal-indent-on-closing-curly-brace hook -once -always window WinSetOption filetype=.* %{ remove-hooks window cabal-.+ } ] hook -group cabal-highlight global WinSetOption filetype=cabal %{ add-highlighter window/cabal ref cabal hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cabal } } provide-module cabal %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/cabal regions add-highlighter shared/cabal/code default-region group add-highlighter shared/cabal/line_comment region (--) $ fill comment add-highlighter shared/cabal/comment region -recurse \{- \{- -\} fill comment add-highlighter shared/cabal/code/ regex \b(true|false)\b|(([<>]?=?)?\d+(\.\d+)+) 0:value add-highlighter shared/cabal/code/ regex \b(if|else)\b 0:keyword add-highlighter shared/cabal/code/ regex ^\h*([A-Za-z][A-Za-z0-9_-]*)\h*: 1:variable # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden cabal-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden cabal-indent-on-new-line %[ evaluate-commands -draft -itersel %[ # copy '--' comment prefix and following white spaces try %[ execute-keys -draft k s ^\h*\K--\h* y gh j P ] # preserve previous line indent try %[ execute-keys -draft K ] # filter previous line try %[ execute-keys -draft k : cabal-trim-indent ] # indent after lines ending with { or : try %[ execute-keys -draft k [:{]$ j ] # deindent closing brace when after cursor try %[ execute-keys -draft \h*\} gh / \} m 1 ] ] ] define-command -hidden cabal-indent-on-opening-curly-brace %[ evaluate-commands -draft -itersel %[ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft h ) M \A\(.*\)\h*\n\h*\{\z s \A|.\z 1 ] ] ] define-command -hidden cabal-indent-on-closing-curly-brace %[ evaluate-commands -draft -itersel %[ # align to opening curly brace when alone on a line try %[ execute-keys -draft ^\h+\}$ h m s \A|.\z 1 ] ] ] ] kakoune-2020.09.01/rc/filetype/clojure.kak000066400000000000000000000304131372342214000201210ustar00rootroot00000000000000# http://clojure.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](clj|cljc|cljs|cljx|edn) %{ set-option buffer filetype clojure } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=clojure %{ require-module clojure clojure-configure-window } hook -group clojure-highlight global WinSetOption filetype=clojure %{ add-highlighter window/clojure ref clojure hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/clojure } } hook -group clojure-insert global BufNewFile .*[.](clj|cljc|cljs|cljx) %{ require-module clojure clojure-insert-ns } provide-module clojure %{ require-module lisp # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/clojure regions add-highlighter shared/clojure/code default-region group add-highlighter shared/clojure/comment region '(? cond->> def definline definterface defmacro defmethod "\ "defmulti defn defn- defonce defprotocol defrecord defstruct deftype fn if "\ "if-let if-not if-some let letfn new ns when when-first when-let when-not "\ "when-some . ..", keywords); split( \ "* *' + +' - -' -> ->> ->ArrayChunk ->Eduction ->Vec ->VecNode ->VecSeq / < "\ "<= = == > >= StackTraceElement->vec Throwable->map accessor aclone "\ "add-classpath add-watch agent agent-error agent-errors aget alength alias "\ "all-ns alter alter-meta! alter-var-root amap ancestors and any? apply "\ "areduce array-map as-> aset aset-boolean aset-byte aset-char aset-double "\ "aset-float aset-int aset-long aset-short assert assoc assoc! assoc-in "\ "associative? atom await await-for bases bean bigdec bigint biginteger "\ "binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set "\ "bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array "\ "boolean? booleans bound-fn bound-fn* bound? bounded-count butlast byte "\ "byte-array bytes bytes? cast cat catch char char-array char-escape-string "\ "char-name-string char? chars class class? clear-agent-errors "\ "clojure-version coll? comment commute comp comparator compare "\ "compare-and-set! compile complement completing concat conj conj! cons "\ "constantly construct-proxy contains? count counted? create-ns "\ "create-struct cycle dec dec' decimal? declare dedupe default-data-readers "\ "delay delay? deliver denominator deref derive descendants disj disj! "\ "dissoc dissoc! distinct distinct? do doall dorun doseq dosync dotimes doto "\ "double double-array double? doubles drop drop-last drop-while eduction "\ "empty empty? ensure ensure-reduced enumeration-seq error-handler "\ "error-mode eval even? every-pred every? ex-data ex-info extend "\ "extend-protocol extend-type extenders extends? false? ffirst file-seq "\ "filter filterv finally find find-keyword find-ns find-var first flatten "\ "float float-array float? floats flush fn? fnext fnil for force format "\ "frequencies future future-call future-cancel future-cancelled? "\ "future-done? future? gen-class gen-interface gensym get get-in get-method "\ "get-proxy-class get-thread-bindings get-validator group-by halt-when hash "\ "hash-map hash-ordered-coll hash-set hash-unordered-coll ident? identical? "\ "identity ifn? import in-ns inc inc' indexed? init-proxy inst-ms inst? "\ "instance? int int-array int? integer? interleave intern interpose into "\ "into-array ints io! isa? iterate iterator-seq juxt keep keep-indexed key "\ "keys keyword keyword? last lazy-cat lazy-seq line-seq list list* list? "\ "load load-file load-reader load-string loaded-libs locking long long-array "\ "longs loop macroexpand macroexpand-1 make-array make-hierarchy map "\ "map-entry? map-indexed map? mapcat mapv max max-key memfn memoize merge "\ "merge-with meta methods min min-key mix-collection-hash mod monitor-enter "\ "monitor-exit name namespace namespace-munge nat-int? neg-int? neg? newline "\ "next nfirst nil? nnext not not-any? not-empty not-every? not= ns-aliases "\ "ns-imports ns-interns ns-map ns-name ns-publics ns-refers ns-resolve "\ "ns-unalias ns-unmap nth nthnext nthrest num number? numerator object-array "\ "odd? or parents partial partition partition-all partition-by pcalls peek "\ "persistent! pmap pop pop! pop-thread-bindings pos-int? pos? pr pr-str "\ "prefer-method prefers print print-str printf println println-str prn "\ "prn-str promise proxy proxy-mappings proxy-super push-thread-bindings "\ "pvalues qualified-ident? qualified-keyword? qualified-symbol? quot quote "\ "rand rand-int rand-nth random-sample range ratio? rational? rationalize "\ "re-find re-groups re-matcher re-matches re-pattern re-seq read read-line "\ "read-string reader-conditional reader-conditional? realized? record? recur "\ "reduce reduce-kv reduced reduced? reductions ref ref-history-count "\ "ref-max-history ref-min-history ref-set refer refer-clojure reify "\ "release-pending-sends rem remove remove-all-methods remove-method "\ "remove-ns remove-watch repeat repeatedly replace replicate require reset! "\ "reset-meta! reset-vals! resolve rest restart-agent resultset-seq reverse "\ "reversible? rseq rsubseq run! satisfies? second select-keys send send-off "\ "send-via seq seq? seqable? seque sequence sequential? set set! "\ "set-agent-send-executor! set-agent-send-off-executor! set-error-handler! "\ "set-error-mode! set-validator! set? short short-array shorts shuffle "\ "shutdown-agents simple-ident? simple-keyword? simple-symbol? slurp some "\ "some-> some->> some-fn some? sort sort-by sorted-map sorted-map-by "\ "sorted-set sorted-set-by sorted? special-symbol? spit split-at split-with "\ "str string? struct struct-map subs subseq subvec supers swap! swap-vals! "\ "symbol symbol? sync tagged-literal tagged-literal? take take-last take-nth "\ "take-while test the-ns thread-bound? throw time to-array to-array-2d "\ "trampoline transduce transient tree-seq true? try type unchecked-add "\ "unchecked-add-int unchecked-byte unchecked-char unchecked-dec "\ "unchecked-dec-int unchecked-divide-int unchecked-double unchecked-float "\ "unchecked-inc unchecked-inc-int unchecked-int unchecked-long "\ "unchecked-multiply unchecked-multiply-int unchecked-negate "\ "unchecked-negate-int unchecked-remainder-int unchecked-short "\ "unchecked-subtract unchecked-subtract-int underive unreduced "\ "unsigned-bit-shift-right update update-in update-proxy uri? use uuid? val "\ "vals var var-get var-set var? vary-meta vec vector vector-of vector? "\ "volatile! volatile? vreset! vswap! while with-bindings with-bindings* "\ "with-in-str with-local-vars with-meta with-open with-out-str "\ "with-precision with-redefs with-redefs-fn xml-seq zero? zipmap", core_fns); split( \ "*1 *2 *3 *agent* *clojure-version* *command-line-args* *compile-files* "\ "*compile-path* *compiler-options* *data-readers* *default-data-reader-fn* "\ "*e *err* *file* *flush-on-newline* *in* *ns* *out* *print-dup* "\ "*print-length* *print-level* *print-meta* *print-namespace-maps* "\ "*print-readably* *read-eval* *unchecked-math* *warn-on-reflection*", core_vars); } function print_word_highlighter(words, face, first) { printf("add-highlighter shared/clojure/code/ regex (? ! : "'" hook -once -always window WinSetOption filetype=.* %{ remove-hooks window clojure-.+ } } define-command -hidden clojure-trim-indent lisp-trim-indent declare-option \ -docstring 'regex matching the head of forms which have options *and* indented bodies' \ regex clojure_special_indent_forms \ '(?:def.*|doseq|for|fn\*?|if(-.*|)|let.*|loop|ns|testing|with-.*|when(-.*|))' define-command -hidden clojure-indent-on-new-line %{ # registers: i = best align point so far; w = start of first word of form evaluate-commands -draft -save-regs '/"|^@iw' -itersel %{ execute-keys -draft 'gk"iZ' try %{ execute-keys -draft '[bl"i"wZ' try %{ # If a special form, indent another (indentwidth - 1) spaces execute-keys -draft '"wze[\s()\[\]\{\}]\A' %opt{clojure_special_indent_forms} '\z' execute-keys -draft '"wzes.{' %sh{printf $(( kak_opt_indentwidth - 1 ))} '}\K.*;"i' } catch %{ # If not special and parameter appears on line 1, indent to parameter execute-keys -draft '"wz[()[\]{}]e[\s()\[\]\{\}]s\h\K[^\s].*;"i' } } try %{ execute-keys -draft '[rl"i' } try %{ execute-keys -draft '[Bl"i' } execute-keys -draft ';"ia&' } } declare-option -docstring %{ top-level directories which can contain clojure files e.g. '(src|test|dev)' } regex clojure_source_directories '(src|test|dev)' define-command -docstring %{clojure-insert-ns: Insert namespace directive at top of Clojure source file} \ clojure-insert-ns %{ evaluate-commands -draft %{ execute-keys -save-regs '' 'gk\O' "%val{bufname}" 'giZ' try %{ execute-keys 'zs\.clj[csx]?$' } try %{ execute-keys 'zs^' "%opt{clojure_source_directories}" '/' } try %{ execute-keys 'zs/r.' } try %{ execute-keys 'zs_r-' } execute-keys 'z\c(ns ")' } } } kakoune-2020.09.01/rc/filetype/cmake.kak000066400000000000000000000024071372342214000175400ustar00rootroot00000000000000hook global BufCreate .+\.cmake|.*/CMakeLists.txt %{ set-option buffer filetype cmake } hook global BufCreate .*/CMakeCache.txt %{ set-option buffer filetype ini } hook global WinSetOption filetype=cmake %{ require-module cmake } hook -group cmake-highlight global WinSetOption filetype=cmake %{ add-highlighter window/cmake ref cmake hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cmake } } provide-module cmake %{ add-highlighter shared/cmake regions add-highlighter shared/cmake/code default-region group add-highlighter shared/cmake/comment region '#' '$' fill comment add-highlighter shared/cmake/argument region -recurse '\(' '\w+\h*\(\K' '(?=\))' regions add-highlighter shared/cmake/code/ regex '\w+\h*(?=\()' 0:meta add-highlighter shared/cmake/argument/args default-region regex '\$\{\w+\}' 0:variable add-highlighter shared/cmake/argument/quoted region '"' '(? # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } } define-command -hidden coffee-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s '^\h*\K#\h*' y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : coffee-trim-indent } # indent after start structure try %{ execute-keys -draft k ^ \h * (case|catch|class|else|finally|for|function|if|switch|try|while|with) \b | (=|->) $ j } } } ] kakoune-2020.09.01/rc/filetype/coq.kak000066400000000000000000000127321372342214000172440ustar00rootroot00000000000000 # Detection # -------- hook global BufCreate .*\.v %{ set-option buffer filetype coq } # Initialization # -------------- hook global WinSetOption filetype=coq %{ require-module coq hook window InsertChar \n -group coq-indent coq-copy-indent-on-newline set-option window static_words %opt{coq_static_words} add-highlighter window/coq ref coq hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/coq remove-hooks window coq-indent } } provide-module coq %{ # Syntax # ------ # This is a `looks sensible' keyword syntax highlighting, far from being correct. # Note that only the core language and the proof language is supported, # the Ltac language is not (for now). add-highlighter shared/coq regions add-highlighter shared/coq/comment region -recurse \Q(* \Q(* \Q*) fill comment add-highlighter shared/coq/string region (?/]+ 0:operator add-highlighter shared/coq/command/ regex \(dfs\)|\(bfs\) 0:operator add-highlighter shared/coq/command/ regex [()\[\]{}] 0:operator # numeral literals add-highlighter shared/coq/command/ regex [-]?[0-9][0-9_]*(\.[0-9_]+)?([eE][+-][0-9_]+)? 0:value evaluate-commands %sh{ # These are builtin keywords of the Gallina language (without tactics) keywords="_ IF Prop SProp Set Type as at by cofix discriminated else end exists exists2 fix for" keywords="${keywords} forall fun if in lazymatch let match multimatch return then using where with" keywords="${keywords} inside outside" # These are (part of) coq top level commands commands="Abort About Add Admitted All Arguments Axiom Back BackTo" commands="${commands} Canonical Cd Check Coercion CoFixpoint Collection Compute Conjecture Context Contextual Corollary" commands="${commands} Declare Defined Definition Delimit Drop End Eval Example Existential Export" commands="${commands} Fact Fail File Fixpoint Focus From Function Generalizable Global Goal Grab" commands="${commands} Hint Hypotheses Hypothesis Immediate Implicit Import Include Inductive" commands="${commands} Lemma Let Library Load LoadPath Local Locate Module No Notation Opaque" commands="${commands} Parameter Parameters Primitive Print Proof Property Proposition Pwd Qed Quit" commands="${commands} Rec Record Redirect Register Remark Remove Require Reset" commands="${commands} Section Search SearchAbout SearchHead SearchPattern SearchRewrite Show Strategy" commands="${commands} Test Theorem Time Timeout Transparent Types Universes Undo Unfocus Unfocused Unset Variable Variables" # These are (part of) coq's builtin tactics tactics="abstract absurd admit all apply assert assert_fails" tactics="${tactics} assert_succeeds assumption auto autoapply" tactics="${tactics} autorewrite autounfold btauto by case cbn" tactics="${tactics} cbv change clear clearbody cofix compare" tactics="${tactics} compute congr congruence constructor contradict" tactics="${tactics} cut cutrewrite cycle decide decompose dependent" tactics="${tactics} destruct discriminate do done double" tactics="${tactics} eapply eassert eauto eexact elim elimtype exact exfalso" tactics="${tactics} fail field first firstorder fix fold functional" tactics="${tactics} generalize guard have hnf idtac induction injection" tactics="${tactics} instantiate intro intros intuition inversion" tactics="${tactics} inversion_clear lapply lazy last move omega" tactics="${tactics} pattern pose progress red refine reflexivity" tactics="${tactics} remember rename repeat replace rewrite right ring" tactics="${tactics} set setoid_reflexivity setoid_replace setoid_rewrite" tactics="${tactics} setoid_symmetry setoid_transitivity simpl simple" tactics="${tactics} simplify_eq solve specialize split start stop" tactics="${tactics} subst symmetry tauto transitivity trivial try" tactics="${tactics} under unfold unify unlock" echo declare-option str-list coq_static_words ${keywords} ${commands} ${tactics} keywords_regex=$(echo ${keywords} | tr ' ' '|') printf %s " add-highlighter shared/coq/command/ regex \b(${keywords_regex})\b 0:keyword " commands_regex=$(echo ${commands} | tr ' ' '|') printf %s " add-highlighter shared/coq/command/ regex ^[\h\n]*(${commands_regex})\b 0:variable " tactics_regex=$(echo ${tactics} | tr ' ' '|') printf %s " add-highlighter shared/coq/command/ regex \b(${tactics_regex})\b 0:keyword " } # Indentation # ----------- # Coq's syntax is based heavily on keywords and program structure, # not based on explicit, unique delimiters, like braces in C-family. # So it is difficult to properly indent using only regex... # Hence here only a simple mechanism of copying indent is done. define-command -hidden coq-copy-indent-on-newline %{ evaluate-commands -draft -itersel %{ try %{ execute-keys -draft k s ^\h+ y gh j P } } } } kakoune-2020.09.01/rc/filetype/crystal.kak000066400000000000000000000330031372342214000201350ustar00rootroot00000000000000# Crystal # https://crystal-lang.org # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate '.*\.cr' %{ set-option buffer filetype crystal } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=crystal %{ require-module crystal add-highlighter window/crystal ref crystal evaluate-commands set-option window static_words %opt{crystal_keywords} %opt{crystal_attributes} %opt{crystal_objects} hook window InsertChar .* -group crystal-indent crystal-indent-on-char hook window InsertChar '\n' -group crystal-indent crystal-indent-on-new-line hook window InsertChar '\n' -group crystal-insert crystal-insert-on-new-line hook -always -once window WinSetOption filetype=.* %{ remove-highlighter window/crystal remove-hooks window crystal-.+ } } provide-module crystal %§ declare-option -hidden str-list crystal_keywords 'abstract' 'alias' 'annotation' 'as' 'asm' 'begin' 'break' 'case' 'class' 'def' 'do' 'else' 'elsif' 'end' 'ensure' 'enum' 'extend' 'false' 'for' 'fun' 'if' 'include' 'instance_sizeof' 'is_a?' 'lib' 'macro' 'module' 'next' 'nil' 'nil?' 'of' 'offsetof' 'out' 'pointerof' 'private' 'protected' 'require' 'rescue' 'responds_to?' 'return' 'select' 'self' 'sizeof' 'struct' 'super' 'then' 'true' 'type' 'typeof' 'uninitialized' 'union' 'unless' 'until' 'verbatim' 'when' 'while' 'with' 'yield' # https://crystal-lang.org/reference/syntax_and_semantics/methods_and_instance_variables.html#getters-and-setters declare-option -hidden str-list crystal_attributes 'getter' 'setter' 'property' declare-option -hidden str-list crystal_operators '+' '-' '*' '/' '//' '%' '|' '&' '^' '~' '**' '<<' '<' '<=' '==' '!=' '=~' '!~' '>>' '>' '>=' '<=>' '===' '[]' '[]=' '[]?' '[' '&+' '&-' '&*' '&**' declare-option -hidden str-list crystal_objects 'Adler32' 'ArgumentError' 'Array' 'Atomic' 'Base64' 'Benchmark' 'BigDecimal' 'BigFloat' 'BigInt' 'BigRational' 'BitArray' 'Bool' 'Box' 'Bytes' 'Channel' 'Char' 'Class' 'Colorize' 'Comparable' 'Complex' 'Concurrent' 'ConcurrentExecutionException' 'CRC32' 'Crypto' 'Crystal' 'CSV' 'Debug' 'Deprecated' 'Deque' 'Digest' 'Dir' 'DivisionByZeroError' 'DL' 'ECR' 'Enum' 'Enumerable' 'ENV' 'Errno' 'Exception' 'Fiber' 'File' 'FileUtils' 'Flags' 'Flate' 'Float' 'Float32' 'Float64' 'GC' 'Gzip' 'Hash' 'HTML' 'HTTP' 'Indexable' 'IndexError' 'INI' 'Int' 'Int128' 'Int16' 'Int32' 'Int64' 'Int8' 'InvalidBigDecimalException' 'InvalidByteSequenceError' 'IO' 'IPSocket' 'Iterable' 'Iterator' 'JSON' 'KeyError' 'Levenshtein' 'Link' 'LLVM' 'Logger' 'Markdown' 'Math' 'MIME' 'Mutex' 'NamedTuple' 'Nil' 'NilAssertionError' 'NotImplementedError' 'Number' 'OAuth' 'OAuth2' 'Object' 'OpenSSL' 'OptionParser' 'OverflowError' 'PartialComparable' 'Path' 'Pointer' 'PrettyPrint' 'Proc' 'Process' 'Random' 'Range' 'Readline' 'Reference' 'Reflect' 'Regex' 'SemanticVersion' 'Set' 'Signal' 'Slice' 'Socket' 'Spec' 'StaticArray' 'String' 'StringPool' 'StringScanner' 'Struct' 'Symbol' 'System' 'TCPServer' 'TCPSocket' 'Termios' 'Time' 'Tuple' 'TypeCastError' 'UDPSocket' 'UInt128' 'UInt16' 'UInt32' 'UInt64' 'UInt8' 'Unicode' 'Union' 'UNIXServer' 'UNIXSocket' 'URI' 'UUID' 'VaList' 'Value' 'WeakRef' 'XML' 'YAML' 'Zip' 'Zlib' # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/crystal regions add-highlighter shared/crystal/code default-region group # Comments # https://crystal-lang.org/reference/syntax_and_semantics/comments.html # Avoid string literals with interpolation add-highlighter shared/crystal/comment region '#(?!\{)' '$' fill comment # String # https://crystal-lang.org/reference/syntax_and_semantics/literals/string.html add-highlighter shared/crystal/string region '"' '(?' regions add-highlighter shared/crystal/pipe-string region '%Q?\|' '\|' regions # Raw # https://crystal-lang.org/reference/syntax_and_semantics/literals/string.html#percent-string-literals # https://crystal-lang.org/reference/syntax_and_semantics/literals/string.html#percent-string-array-literal # https://crystal-lang.org/reference/syntax_and_semantics/literals/symbol.html#percent-symbol-array-literal add-highlighter shared/crystal/raw-parenthesis-string region -recurse '\(' '%[qwi]\(' '\)' fill string add-highlighter shared/crystal/raw-bracket-string region -recurse '\[' '%[qwi]\[' '\]' fill string add-highlighter shared/crystal/raw-brace-string region -recurse '\{' '%[qwi]\{' '\}' fill string add-highlighter shared/crystal/raw-angle-string region -recurse '<' '%[qwi]<' '>' fill string add-highlighter shared/crystal/raw-pipe-string region '%[qwi]\|' '\|' fill string # Here document # https://crystal-lang.org/reference/syntax_and_semantics/literals/string.html#heredoc add-highlighter shared/crystal/heredoc region -match-capture '<<-(\w+)' '^\h*(\w+)$' regions # Raw add-highlighter shared/crystal/raw-heredoc region -match-capture "<<-'(\w+)'" '^\h*(\w+)$' regions add-highlighter shared/crystal/raw-heredoc/fill default-region fill string add-highlighter shared/crystal/raw-heredoc/interpolation region -recurse '\{' '#\{' '\}' fill meta # Symbol # https://crystal-lang.org/reference/syntax_and_semantics/literals/symbol.html add-highlighter shared/crystal/quoted-symbol region ':"' '(?[imx]*' regions add-highlighter shared/crystal/pipe-regex region '%r?\|' '\|[imx]*' regions # Command # https://crystal-lang.org/reference/syntax_and_semantics/literals/command.html add-highlighter shared/crystal/command region '`' '(?' regions add-highlighter shared/crystal/pipe-command region '%x?\|' '\|' regions evaluate-commands %sh[ # Keywords eval "set -- $kak_quoted_opt_crystal_keywords" regex="\\b(?:\\Q$1\\E" shift for keyword do regex="$regex|\\Q$keyword\\E" done regex="$regex)\\b" printf 'add-highlighter shared/crystal/code/keywords regex %s 0:keyword\n' "$regex" # Attributes eval "set -- $kak_quoted_opt_crystal_attributes" regex="\\b(?:\\Q$1\\E" shift for attribute do regex="$regex|\\Q$attribute\\E" done regex="$regex)\\b" printf 'add-highlighter shared/crystal/code/attributes regex %s 0:attribute\n' "$regex" # Symbols eval "set -- $kak_quoted_opt_crystal_operators" # Avoid to match modules regex="(? # remove trailing white spaces try %{ execute-keys -draft s \h+$ d } } } define-command -hidden crystal-indent-on-char %{ evaluate-commands -no-hooks -draft -itersel %{ # align 'else' to 'if/case' try %{ execute-keys -draft ^\h*else$ i ^\h*(?:if|case) 1 } # align 'elsif' to 'if' try %{ execute-keys -draft ^\h*elsif$ i ^\h*(?:if) 1 } # align 'when' to 'case' try %{ execute-keys -draft ^\h*when$ i ^\h*(?:case) 1 } # align 'rescue' to 'begin/def' try %{ execute-keys -draft ^\h*rescue$ i ^\h*(?:begin|def) 1 } # align 'end' to opening structure try %{ execute-keys -draft ^\h*end$ i ^\h*(?:begin|case|class|def|for|if|module|unless|until|while) 1 } } } define-command -hidden crystal-indent-on-new-line %{ evaluate-commands -no-hooks -draft -itersel %{ # Copy previous line indent try %{ execute-keys -draft K } # Remove previous line's trailing spaces try %{ execute-keys -draft k :ruby-trim-indent } # Indent after start structure/opening statement try %{ execute-keys -draft k ^\h*(?:begin|case|class|def|else|elsif|ensure|for|if|module|rescue|unless|until|when|while|.+\bdo$|.+\bdo\h\|.+(?=\|))[^0-9A-Za-z_!?] j } } } define-command -hidden crystal-insert-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # copy _#_ comment prefix and following white spaces try %{ execute-keys -draft k s '^\h*\K#\h*' y j P } # wisely add end structure evaluate-commands -save-regs x %[ try %{ execute-keys -draft k s ^ \h + \" x y } catch %{ reg x '' } try %[ evaluate-commands -draft %[ # Check if previous line opens a block execute-keys -draft k ^x(?:begin|case|class|def|for|if|module|unless|until|while|.+\bdo$|.+\bdo\h\|.+(?=\|))[^0-9A-Za-z_!?] # Check that we do not already have an end for this indent level which is first set via `crystal-indent-on-new-line` hook execute-keys -draft }i J ^x(?:end|else|elsif|rescue|when)[^0-9A-Za-z_!?] ] execute-keys -draft oxend # insert a new line with containing end ] ] ] ] define-command -hidden crystal-fetch-keywords %{ set-register dquote %sh{ curl --location https://github.com/crystal-lang/crystal/raw/master/src/compiler/crystal/syntax/lexer.cr | kak -f '%1scheck_ident_or_keyword\(:(\w+\??), \w+\)y%aa|sort' } } define-command -hidden crystal-fetch-operators %{ set-register dquote %sh{ curl --location https://github.com/crystal-lang/crystal/raw/master/src/compiler/crystal/syntax/parser.cr | kak -f '/AtomicWithMethodCheck =x1s:"([^"]+)"y%i''a''a' } } define-command -hidden crystal-fetch-objects %{ set-register dquote %sh{ curl --location https://crystal-lang.org/api/ | # Remove Top Level Namespace kak -f '%1sdata-id="github.com/crystal-lang/crystal/(\w+)")y%aa' } } § kakoune-2020.09.01/rc/filetype/css.kak000066400000000000000000000061601372342214000172500ustar00rootroot00000000000000# http://w3.org/Style/CSS # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](css) %{ set-option buffer filetype css } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=css %[ require-module css hook window ModeChange pop:insert:.* -group css-trim-indent css-trim-indent hook window InsertChar \n -group css-indent css-indent-on-new-line hook window InsertChar \} -group css-indent css-indent-on-closing-curly-brace set-option buffer extra_word_chars '_' '-' hook -once -always window WinSetOption filetype=.* %{ remove-hooks window css-.+ } ] hook -group css-highlight global WinSetOption filetype=css %{ add-highlighter window/css ref css hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/css } } provide-module css %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/css regions add-highlighter shared/css/selector default-region group add-highlighter shared/css/declaration region [{] [}] regions add-highlighter shared/css/comment region /[*] [*]/ fill comment add-highlighter shared/css/declaration/base default-region group add-highlighter shared/css/declaration/double_string region '"' (? s \h+$ d } } define-command -hidden css-indent-on-new-line %[ evaluate-commands -draft -itersel %[ # preserve previous line indent try %[ execute-keys -draft K ] # filter previous line try %[ execute-keys -draft k : css-trim-indent ] # indent after lines ending with with { try %[ execute-keys -draft k \{$ j ] # deindent closing brace when after cursor try %[ execute-keys -draft ^\h*\} gh / \} m 1 ] ] ] define-command -hidden css-indent-on-closing-curly-brace %[ evaluate-commands -draft -itersel %[ # align to opening curly brace when alone on a line try %[ execute-keys -draft ^\h+\}$ m s \A|.\z 1 ] ] ] ] kakoune-2020.09.01/rc/filetype/cucumber.kak000066400000000000000000000060621372342214000202660ustar00rootroot00000000000000# http://cukes.info # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](feature|story) %{ set-option buffer filetype cucumber } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=cucumber %{ require-module cucumber hook window ModeChange pop:insert:.* -group cucumber-trim-indent cucumber-trim-indent hook window InsertChar \n -group cucumber-indent cucumber-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window cucumber-.+ } } hook -group cucumber-highlight global WinSetOption filetype=cucumber %{ add-highlighter window/cucumber ref cucumber hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cucumber } } provide-module cucumber %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/cucumber regions add-highlighter shared/cucumber/code default-region group add-highlighter shared/cucumber/language region ^\h*#\h*language: $ group add-highlighter shared/cucumber/comment region ^\h*# $ fill comment add-highlighter shared/cucumber/language/ fill meta add-highlighter shared/cucumber/language/ regex \S+$ 0:value # Spoken languages # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # https://github.com/cucumber/cucumber/wiki/Spoken-languages # # curl --location https://github.com/cucumber/gherkin/raw/master/lib/gherkin/i18n.json # # { # "en": { # "name": "English", # "native": "English", # "feature": "Feature|Business Need|Ability", # "background": "Background", # "scenario": "Scenario", # "scenario_outline": "Scenario Outline|Scenario Template", # "examples": "Examples|Scenarios", # "given": "*|Given", # "when": "*|When", # "then": "*|Then", # "and": "*|And", # "but": "*|But" # }, # … # } # # jq 'with_entries({ key: .key, value: .value | del(.name) | del(.native) | join("|") })' # # { # "en": "Feature|Business Need|Ability|Background|Scenario|Scenario Outline|Scenario Template|Examples|Scenarios|*|Given|*|When|*|Then|*|And|*|But", # … # } add-highlighter shared/cucumber/code/ regex \b(Feature|Business\h+Need|Ability|Background|Scenario|Scenario\h+Outline|Scenario\h+Template|Examples|Scenarios|Given|When|Then|And|But)\b 0:keyword # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden cucumber-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden cucumber-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : cucumber-trim-indent } # indent after lines containing : try %{ execute-keys -draft k x : j } } } } kakoune-2020.09.01/rc/filetype/cue.kak000066400000000000000000000141751372342214000172410ustar00rootroot00000000000000# https://cuelang.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](cue) %{ set-option buffer filetype cue } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=cue %[ require-module cue # cleanup trailing whitespaces when exiting insert mode hook window ModeChange pop:insert:.* -group cue-trim-indent cue-trim-indent hook window InsertChar \n -group cue-indent cue-indent-on-new-line hook window InsertChar \{ -group cue-indent cue-indent-on-opening-curly-brace hook window InsertChar [)}] -group cue-indent cue-indent-on-closing hook -once -always window WinSetOption filetype=.* %{ remove-hooks window cue-.+ } ] hook -group cue-highlight global WinSetOption filetype=cue %{ add-highlighter window/cue ref cue hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/cue } } provide-module cue %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ # https://cuelang.org/docs/references/spec/ add-highlighter shared/cue regions add-highlighter shared/cue/code default-region group add-highlighter shared/cue/simple_string region '"' (?|<=|>=)" punctuation="(_\|_|:|::|,|\.|\.\.\.|\(|\{|\[|\)|\}|\])" function_calls="\w+(?=\()" identifier="(?!\d)[\w_$]+" reserved="\b__${identifier}" preamble="^(package|import)\b" functions="len close and or" keywords="for in if let" operators="div mod quo rem" types=" bool string bytes rune number uint uint8 uint16 uint32 uint64 uint128 int int8 int16 int32 int64 int128 float float32 float64 " values="null true false" join() { sep=$2; set -- $1; IFS="$sep"; echo "$*"; } static_words="$(join "package import ${functions} ${keywords} ${operators} ${types} ${values}" ' ')" # Add the language's grammar to the static completion list printf %s\\n "declare-option str-list cue_static_words ${static_words}" functions="$(join "${functions}" '|')" keywords="$(join "${keywords}" '|')" operators="$(join "${operators}" '|')" types="$(join "${types}" '|')" values="$(join "${values}" '|')" # Highlight keywords printf %s " add-highlighter shared/cue/code/ regex ${float_lit} 0:value add-highlighter shared/cue/code/ regex ${function_calls} 0:function add-highlighter shared/cue/code/ regex ${int_lit} 0:value add-highlighter shared/cue/code/ regex ${operator_chars} 0:operator add-highlighter shared/cue/code/ regex ${preamble} 0:keyword add-highlighter shared/cue/code/ regex ${punctuation} 0:operator add-highlighter shared/cue/code/ regex ${reserved} 0:keyword add-highlighter shared/cue/code/ regex \b(${functions})\b 0:builtin add-highlighter shared/cue/code/ regex \b(${keywords})\b 0:keyword add-highlighter shared/cue/code/ regex \b(${operators})\b 0:operator add-highlighter shared/cue/code/ regex \b(${types})\b 0:type add-highlighter shared/cue/code/ regex \b(${values})\b 0:value " } # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden cue-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden cue-indent-on-new-line %~ evaluate-commands -draft -itersel %< # copy // comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K//[!/]?\h* y gh j P } catch %| # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with { or ( try %[ execute-keys -draft k [{(]\h*$ j ] # indent after lines ending with [{(].+ and move first parameter to own line try %< execute-keys -draft [c[({],[)}] \A[({][^\n]+\n[^\n]*\n?\z L i > # deindent closing brace(s) when after cursor try %< execute-keys -draft ^\h*[})] gh / [})] m 1 > | # filter previous line try %{ execute-keys -draft k : cue-trim-indent } > ~ define-command -hidden cue-indent-on-opening-curly-brace %[ evaluate-commands -draft -itersel %_ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft h ) M \A\(.*\)\h*\n\h*\{\z s \A|.\z 1 ] _ ] define-command -hidden cue-indent-on-closing %[ evaluate-commands -draft -itersel %_ # align to opening curly brace or paren when alone on a line try %< execute-keys -draft ^\h*[)}]$ h m 1 > _ ] § kakoune-2020.09.01/rc/filetype/d.kak000066400000000000000000000155411372342214000167060ustar00rootroot00000000000000# http://dlang.org/ # # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.di? %{ set-option buffer filetype d } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=d %{ require-module d set-option window static_words %opt{d_static_words} # cleanup trailing whitespaces when exiting insert mode hook window ModeChange pop:insert:.* -group d-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } hook window InsertChar \n -group d-indent d-indent-on-new-line hook window InsertChar \{ -group d-indent d-indent-on-opening-curly-brace hook window InsertChar \} -group d-indent d-indent-on-closing-curly-brace hook -once -always window WinSetOption filetype=.* %{ remove-hooks window d-.+ } } hook -group d-highlight global WinSetOption filetype=d %{ add-highlighter window/d ref d hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/d } } provide-module d %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/d regions add-highlighter shared/d/code default-region group add-highlighter shared/d/string region %{(?K } # indent after lines ending with { or ( try %[ execute-keys -draft k [{(]\h*$ j ] # cleanup trailing white spaces on the previous line try %{ execute-keys -draft k s \h+$ d } # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # copy // comments prefix try %{ execute-keys -draft k s ^\h*\K/{2,} yP } # indent after a switch's case/default statements try %[ execute-keys -draft k ^\h*(case|default).*:$ j ] # indent after if|else|while|for try %[ execute-keys -draft )MB \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] # deindent closing brace(s) when after cursor try %[ execute-keys -draft ^\h*[})] gh / [})] m 1 ] = ~ define-command -hidden d-indent-on-opening-curly-brace %[ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft -itersel h)M \A\(.*\)\h*\n\h*\{\z s \A|.\z 1 ] ] define-command -hidden d-indent-on-closing-curly-brace %[ # align to opening curly brace when alone on a line try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] § kakoune-2020.09.01/rc/filetype/dart.kak000066400000000000000000000115421372342214000174120ustar00rootroot00000000000000# https://dartlang.org/ # # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.dart %{ set-option buffer filetype dart } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=dart %{ require-module dart set-option window static_words %opt{dart_static_words} # cleanup trailing whitespaces when exiting insert mode hook window ModeChange pop:insert:.* -group dart-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } hook window InsertChar \n -group dart-indent dart-indent-on-new-line hook window InsertChar \{ -group dart-indent dart-indent-on-opening-curly-brace hook window InsertChar \} -group dart-indent dart-indent-on-closing-curly-brace hook -once -always window WinSetOption filetype=.* %{ remove-hooks window dart-.+ } } hook -group dart-highlight global WinSetOption filetype=dart %{ add-highlighter window/dart ref dart hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dart } } provide-module dart %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/dart regions add-highlighter shared/dart/code default-region group add-highlighter shared/dart/back_string region '`' '`' fill string add-highlighter shared/dart/double_string region '"' (?)" classes="_?[A-Z][a-zA-Z0-9]*" # Add the language's grammar to the static completion list printf %s\\n "declare-option str-list dart_static_words ${keywords} ${attributes} ${types} ${values}" | tr '|' ' ' # Highlight keywords printf %s " add-highlighter shared/dart/code/ regex \b(${keywords})\b 0:keyword add-highlighter shared/dart/code/ regex \b(${generator_keywords}) 0:keyword add-highlighter shared/dart/code/ regex \b(${attributes})\b 0:attribute add-highlighter shared/dart/code/ regex \b(${types})\b 0:type add-highlighter shared/dart/code/ regex \b(${values})\b 0:value add-highlighter shared/dart/code/ regex \b(${functions}) 2:function add-highlighter shared/dart/code/ regex (${annotations})\b 0:meta add-highlighter shared/dart/code/ regex \b(${classes})\b 0:module " } # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden dart-indent-on-new-line %~ evaluate-commands -draft -itersel %= # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with { or ( try %[ execute-keys -draft k [{(]\h*$ j ] # cleanup trailing white spaces on the previous line try %{ execute-keys -draft k s \h+$ d } # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # copy // comments prefix try %{ execute-keys -draft k s ^\h*\K/{2,} yP } # indent after a switch's case/default statements try %[ execute-keys -draft k ^\h*(case|default).*:$ j ] # indent after if|else|while|for try %[ execute-keys -draft )MB \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] # deindent closing brace when after cursor try %[ execute-keys -draft ^\h*\} gh / \} m 1 ] = ~ define-command -hidden dart-indent-on-opening-curly-brace %[ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft -itersel h)M \A\(.*\)\h*\n\h*\{\z s \A|.\z 1 ] ] define-command -hidden dart-indent-on-closing-curly-brace %[ # align to opening curly brace when alone on a line try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] § kakoune-2020.09.01/rc/filetype/dhall.kak000066400000000000000000000072171372342214000175500ustar00rootroot00000000000000# https://dhall-lang.org # # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](dhall) %{ set-option buffer filetype dhall } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=dhall %{ require-module dhall hook window ModeChange insert:.* -group dhall-trim-indent dhall-trim-indent hook window InsertChar \n -group dhall-indent dhall-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window dhall-.+ } } hook -group dhall-highlight global WinSetOption filetype=dhall %{ add-highlighter window/dhall ref dhall hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dhall } } provide-module dhall %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/dhall regions add-highlighter shared/dhall/code default-region group add-highlighter shared/dhall/string region '"' (?|\?|λ|\\|\^|⫽|//|\[|\]|\{|\}) 0:operator # Matches built-in functions add-highlighter shared/dhall/code/ regex \b(Natural-fold|Natural-build|Natural-isZero|Natural-even|Natural-odd|Natural-toInteger|Natural-show|Integer-toDouble|Integer-show|Natural-subtract|Double-show|List-build|List-fold|List-length|List-head|List-last|List-indexed|List-reverse|Optional-fold|Optional-build|Text-show)\b 0:keyword # Matches http[s] imports add-highlighter shared/dhall/code/ regex \b(http[s]://\S+)\b(\s+sha256:[a-f0-9]{64}\b)? 0:meta # Matches local imports add-highlighter shared/dhall/code/ regex (~|\.|\.\.|/)\S+ 0:meta # Matches number (natural, integer, double) literals add-highlighter shared/dhall/code/ regex \b(\+|-)?\d+(\.\d+)?(e(\+|-)?\d+)?\b 0:value # Matches union syntax add-highlighter shared/dhall/union region -recurse < < > group add-highlighter shared/dhall/union/sep regex (<|\|)\s*((?:_|[A-Z])(?:[a-zA-Z0-9-/_]*))\s*(?:(:)([^|>]*))? 1:operator 2:attribute 3:operator 4:type add-highlighter shared/dhall/union/end regex > 0:operator # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden dhall-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden dhall-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K--\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft \; K } # filter previous line try %{ execute-keys -draft k : dhall-trim-indent } # indent after lines ending with let, : or = try %{ execute-keys -draft \; k x (\blet|:|=)$ j } } } ] kakoune-2020.09.01/rc/filetype/diff.kak000066400000000000000000000027171372342214000173740ustar00rootroot00000000000000hook global BufCreate .*\.(diff|patch) %{ set-option buffer filetype diff } add-highlighter shared/diff group add-highlighter shared/diff/ regex "^\+[^\n]*\n" 0:green,default add-highlighter shared/diff/ regex "^-[^\n]*\n" 0:red,default add-highlighter shared/diff/ regex "^@@[^\n]*@@" 0:cyan,default hook -group diff-highlight global WinSetOption filetype=diff %{ add-highlighter window/diff ref diff hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/diff } } define-command \ -docstring %{diff-select-file: Select surrounding patch file} \ -params 0 \ diff-select-file %{ evaluate-commands -itersel -save-regs 'ose/' %{ try %{ execute-keys '"oZgl^diff ;"sZ' 'Ge"eZ' try %{ execute-keys '"sz?\n(?=diff )"e' } execute-keys '"ez' } catch %{ execute-keys '"oz' fail 'Not in a diff file' } } } define-command \ -docstring %{diff-select-hunk: Select surrounding patch hunk} \ -params 0 \ diff-select-hunk %{ evaluate-commands -itersel -save-regs 'ose/' %{ try %{ execute-keys '"oZgl^@@ ;"sZ' 'Ge"eZ' try %{ execute-keys '"sz?\n(?=diff )"e' } try %{ execute-keys '"sz?\n(?=@@ )"e' } execute-keys '"ez' } catch %{ execute-keys '"oz' fail 'Not in a diff hunk' } } } kakoune-2020.09.01/rc/filetype/dockerfile.kak000066400000000000000000000035061372342214000205700ustar00rootroot00000000000000# http://docker.com # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # See https://docs.docker.com/reference/builder # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*/?Dockerfile(\.\w+)?$ %{ set-option buffer filetype dockerfile } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=dockerfile %{ require-module dockerfile set-option window static_words %opt{dockerfile_static_words} } hook -group dockerfile-highlight global WinSetOption filetype=dockerfile %{ add-highlighter window/dockerfile ref dockerfile hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/dockerfile } } provide-module dockerfile %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/dockerfile regions add-highlighter shared/dockerfile/code default-region group add-highlighter shared/dockerfile/double_string region '"' '(?' fill comment add-highlighter shared/eex/quote region '<%%' '%>' ref html add-highlighter shared/eex/code region '<%=?' '%>' ref elixir } provide-module elixir %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/elixir regions add-highlighter shared/elixir/code default-region group add-highlighter shared/elixir/double_string region -match-capture ("""|") (?|<-|<<|>>|=>) 0:builtin add-highlighter shared/elixir/code/ regex \b(require|alias|use|import)\b 0:keyword add-highlighter shared/elixir/code/ regex \b(__MODULE__|__DIR__|__ENV__|__CALLER__)\b 0:value add-highlighter shared/elixir/code/ regex \b(def|defp|defmacro|defmacrop|defstruct|defmodule|defimpl|defprotocol|defoverridable)\b 0:keyword add-highlighter shared/elixir/code/ regex \b(fn|do|end|when|case|if|else|unless|var!|for|cond|quote|unquote|receive|with|raise|reraise|try|catch)\b 0:keyword add-highlighter shared/elixir/code/ regex '@[\w_]+\b' 0:attribute add-highlighter shared/elixir/code/ regex '\b\d+[\d_]*\b' 0:value # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden elixir-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden elixir-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K--\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # indent after line ending with: # try %{ execute-keys -draft k x (\bdo|\belse|->)$ & } # filter previous line try %{ execute-keys -draft k : elixir-trim-indent } # indent after lines ending with do or -> try %{ execute-keys -draft k x ^.+(\bdo|->)$ j } } } ] kakoune-2020.09.01/rc/filetype/elm.kak000066400000000000000000000064741372342214000172450ustar00rootroot00000000000000# http://elm-lang.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](elm) %{ set-option buffer filetype elm } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=elm %{ require-module elm hook window ModeChange pop:insert:.* -group elm-trim-indent elm-trim-indent hook window InsertChar \n -group elm-indent elm-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elm-.+ } } hook -group elm-highlight global WinSetOption filetype=elm %{ add-highlighter window/elm ref elm hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/elm } } provide-module elm %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/elm regions add-highlighter shared/elm/code default-region group add-highlighter shared/elm/multiline_string region '"""' '"""' fill string add-highlighter shared/elm/string region '"' (?!@#$%^&*=:/\\|]+\B 0:operator add-highlighter shared/elm/code/ regex \b(import|exposing|as|module|port)\b 0:meta add-highlighter shared/elm/code/ regex \b(type|alias|if|then|else|case|of|let|in|infix|_)\b) 0:keyword add-highlighter shared/elm/code/ regex (?!@#$%^&*=:/\\|])(->|:|=|\|)(?![-+<>!@#$%^&*=:/\\|]) 0:keyword # Commands # ‾‾‾‾‾‾‾‾ # http://elm-lang.org/docs/style-guide define-command -hidden elm-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden elm-indent-after " execute-keys -draft k x ^\\h*if|[=(]$|\\b(case\\h+[\\w']+\\h+of|let|in)$|(\\{\\h+\\w+|\\w+\\h+->)$ j " define-command -hidden elm-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K--\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # align to first clause try %{ execute-keys -draft k x X s ^\h*(if|then|else)?\h*(([\w']+\h+)+=)?\h*(case\h+[\w']+\h+of|let)\h+\K.* s \A|.\z & } # filter previous line try %{ execute-keys -draft k : elm-trim-indent } # indent after lines beginning with condition or ending with expression or =( try %{ elm-indent-after } } } ] kakoune-2020.09.01/rc/filetype/eruby.kak000066400000000000000000000015201372342214000176010ustar00rootroot00000000000000# eRuby # http://www2a.biglobe.ne.jp/~seki/ruby/erb.html hook global BufCreate '.*\.html\.erb' %{ set-option buffer filetype eruby } hook global WinSetOption filetype=eruby %{ require-module eruby add-highlighter window/eruby ref eruby hook -group eruby window InsertChar '\n' html-indent-on-new-line hook -always -once window WinSetOption filetype=.* %{ remove-highlighter window/eruby remove-hooks window eruby } } provide-module eruby %{ require-module ruby require-module html add-highlighter shared/eruby regions add-highlighter shared/eruby/html default-region ref html add-highlighter shared/eruby/simple-expression-tag region '<%=' '%>' ref ruby add-highlighter shared/eruby/simple-execution-tag region '<%' '%>' ref ruby add-highlighter shared/eruby/simple-comment-tag region '<%#' '%>' fill comment } kakoune-2020.09.01/rc/filetype/etc.kak000066400000000000000000000110261372342214000172300ustar00rootroot00000000000000# Highlighting for common files in /etc hook global BufCreate .*/etc/(hosts|networks|services) %{ set-option buffer filetype etc-hosts } hook global BufCreate .*/etc/resolv.conf %{ set-option buffer filetype etc-resolv-conf } hook global BufCreate .*/etc/shadow %{ set-option buffer filetype etc-shadow } hook global BufCreate .*/etc/passwd %{ set-option buffer filetype etc-passwd } hook global BufCreate .*/etc/gshadow %{ set-option buffer filetype etc-gshadow } hook global BufCreate .*/etc/group %{ set-option buffer filetype etc-group } hook global BufCreate .*/etc/(fs|m)tab %{ set-option buffer filetype etc-fstab } hook global BufCreate .*/etc/environment %{ set-option buffer filetype sh } hook global BufCreate .*/etc/env.d/.* %{ set-option buffer filetype sh } hook global BufCreate .*/etc/profile(\.(csh|env))? %{ set-option buffer filetype sh } hook global BufCreate .*/etc/profile\.d/.* %{ set-option buffer filetype sh } hook global WinSetOption filetype=etc-(hosts|resolv-conf|shadow|passwd|gshadow|group|fstab) %{ require-module "etc-%val{hook_param_capture_1}" } hook -group etc-resolv-conf-highlight global WinSetOption filetype=etc-resolv-conf %{ add-highlighter window/etc-resolv-conf ref etc-resolv-conf hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-resolv-conf } } hook -group etc-hosts-highlight global WinSetOption filetype=etc-hosts %{ add-highlighter window/etc-hosts ref etc-hosts hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-hosts } } hook -group etc-fstab-highlight global WinSetOption filetype=etc-fstab %{ add-highlighter window/etc-fstab ref etc-fstab hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-fstab } } hook -group etc-group-highlight global WinSetOption filetype=etc-group %{ add-highlighter window/etc-group ref etc-group hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-group } } hook -group etc-gshadow-highlight global WinSetOption filetype=etc-gshadow %{ add-highlighter window/etc-gshadow ref etc-gshadow hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-gshadow } } hook -group etc-shadow-highlight global WinSetOption filetype=etc-shadow %{ add-highlighter window/etc-shadow ref etc-shadow hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-shadow } } hook -group etc-passwd-highlight global WinSetOption filetype=etc-passwd %{ add-highlighter window/etc-passwd ref etc-passwd hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/etc-passwd } } # Highlighters provide-module etc-resolv-conf %{ ## /etc/resolv.conf add-highlighter shared/etc-resolv-conf group add-highlighter shared/etc-resolv-conf/ regex ^#.*?$ 0:comment add-highlighter shared/etc-resolv-conf/ regex ^(nameserver|server|domain|sortlist|options)[\s\t]+(.*?)$ 1:type 2:attribute } provide-module etc-hosts %{ ## /etc/hosts add-highlighter shared/etc-hosts group add-highlighter shared/etc-hosts/ regex ^(.+?)[\s\t]+?(.*?)$ 1:type 2:attribute add-highlighter shared/etc-hosts/ regex '#.*?$' 0:comment } provide-module etc-fstab %{ ## /etc/fstab add-highlighter shared/etc-fstab group add-highlighter shared/etc-fstab/ regex ^(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})\s+?(\S{1,})(?:\s+)?$ 1:keyword 2:value 3:type 4:string 5:attribute 6:attribute add-highlighter shared/etc-fstab/ regex '#.*?$' 0:comment } provide-module etc-group %{ ## /etc/group add-highlighter shared/etc-group group add-highlighter shared/etc-group/ regex ^(\S+?):(\S+?)?:(\S+?)?:(\S+?)?$ 1:keyword 2:type 3:value 4:string } provide-module etc-gshadow %{ ## /etc/gshadow add-highlighter shared/etc-gshadow group add-highlighter shared/etc-gshadow/ regex ^(\S+?):(\S+?)?:(\S+?)?:(\S+?)?$ 1:keyword 2:type 3:value 4:string } provide-module etc-shadow %{ ## /etc/shadow add-highlighter shared/etc-shadow group add-highlighter shared/etc-shadow/ regex ^(\S+?):(\S+?):([0-9]+?):([0-9]+?)?:([0-9]+?)?:([0-9]+?)?:([0-9]+?)?:([0-9]+?)?:(.*?)?$ 1:keyword 2:type 3:value 4:value 5:value 6:value 7:value 8:value } provide-module etc-passwd %{ ## /etc/passwd add-highlighter shared/etc-passwd group add-highlighter shared/etc-passwd/ regex ^(\S+?):(\S+?):([0-9]+?):([0-9]+?):(.*?)?:(.+?):(.+?)$ 1:keyword 2:type 3:value 4:value 5:string 6:attribute 7:attribute } kakoune-2020.09.01/rc/filetype/exherbo.kak000066400000000000000000000201061372342214000201100ustar00rootroot00000000000000## Repository metadata files hook global BufCreate .*/metadata/mirrors\.conf %{ set-option buffer filetype paludis-mirrors-conf } hook global BufCreate .*/metadata/licence_groups.conf %{ set-option buffer filetype exheres-0-licence-groups } hook global BufCreate .*/metadata/options/descriptions/.*\.conf %{ set-option buffer filetype exheres-0-licence-groups } hook global BufCreate .*/metadata/.*\.conf %{ set-option buffer filetype exheres-0-metadata } ## News items hook global BufCreate .*/metadata/news/.*/.*\.txt %{ set-option buffer filetype glep42 } ## exheres-0, exlib hook global BufCreate .*\.(exheres-0|exlib) %{ set-option buffer filetype sh } # Paludis configurations hook global BufCreate .*/etc/paludis(-.*)?/bashrc %{ set-option buffer filetype sh } hook global BufCreate .*/etc/paludis(-.*)?/general(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-key-value-conf } hook global BufCreate .*/etc/paludis(-.*)?/licences(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-options-conf } hook global BufCreate .*/etc/paludis(-.*)?/mirrors(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-mirrors-conf } hook global BufCreate .*/etc/paludis(-.*)?/options(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-options-conf } hook global BufCreate .*/etc/paludis(-.*)?/output(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-key-value-conf } hook global BufCreate .*/etc/paludis(-.*)?/package_(unmask|mask)(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-specs-conf } hook global BufCreate .*/etc/paludis(-.*)?/platforms(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-specs-conf } hook global BufCreate .*/etc/paludis(-.*)?/repositories/.*\.conf %{ set-option buffer filetype paludis-key-value-conf } hook global BufCreate .*/etc/paludis(-.*)?/repository\.template %{ set-option buffer filetype paludis-key-value-conf } hook global BufCreate .*/etc/paludis(-.*)?/repository_defaults\.conf %{ set-option buffer filetype paludis-key-value-conf } hook global BufCreate .*/etc/paludis(-.*)?/specpath\.conf %{ set-option buffer filetype paludis-key-value-conf } hook global BufCreate .*/etc/paludis(-.*)?/suggestions(\.conf.d/.*.conf|\.conf) %{ set-option buffer filetype paludis-specs-conf } hook global WinSetOption filetype=exheres-0-(metadata|options-descriptions|licence-groups) %{ require-module exheres } hook -group exheres-0-metadata-highlight global WinSetOption filetype=exheres-0-metadata %{ add-highlighter window/exheres-0-metadata ref exheres-0-metadata hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/exheres-0-metadata } } hook -group exheres-0-options-descriptions-highlight global WinSetOption filetype=exheres-0-options-descriptions %{ add-highlighter window/exheres-0-options-descriptions ref exheres-0-options-descriptions hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/exheres-0-options-descriptions } } hook -group exheres-0-licence-groups-highlight global WinSetOption filetype=exheres-0-licence-groups %{ add-highlighter window/exheres-0-licence-groups ref exheres-0-licence-groups hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/exheres-0-licence-groups } } provide-module exheres %{ # Highlighters ## exheres-0 Repository metadata files add-highlighter shared/exheres-0-metadata group add-highlighter shared/exheres-0-metadata/ regex ^#.*?$ 0:comment add-highlighter shared/exheres-0-metadata/ regex ^(?:[\s\t]+)?(\*)?(\S+)(?:[\s\t]+)?=(?:[\s\t]+)?(.+?)?$ 1:type 2:attribute 3:string add-highlighter shared/exheres-0-metadata/ regex ^(?:[\s\t]+)?[\S]+[\s\t]+=[\s\t]+\[.+?[\s\t]+\] 0:string add-highlighter shared/exheres-0-metadata/ regex ^(?:[\s\t]+)?(\S+)\s\[\[$ 0:type add-highlighter shared/exheres-0-metadata/ regex ^(?:[\s\t]+)?\]\]$ 0:type ## exheres-0 options descriptions add-highlighter shared/exheres-0-options-descriptions group add-highlighter shared/exheres-0-options-descriptions/ regex ^#.*?$ 0:comment add-highlighter shared/exheres-0-options-descriptions/ regex ^(?:[\s\t]+)?[\S]+[\s\t]+-[\s\t]+\[.+?[\s\t]+\] 0:string add-highlighter shared/exheres-0-options-descriptions/ regex ^(?:[\s\t]+)?(\S+)\s\[\[$ 0:type add-highlighter shared/exheres-0-options-descriptions/ regex ^(?:[\s\t]+)?\]\]$ 0:type ## metadata/licence_groups.conf add-highlighter shared/exheres-0-licence-groups group add-highlighter shared/exheres-0-licence-groups/ regex [\s\t]+(\S+(?:[\s\t]+))*$ 0:attribute add-highlighter shared/exheres-0-licence-groups/ regex ^(\S+) 0:type add-highlighter shared/exheres-0-licence-groups/ regex ^#.*?$ 0:comment } hook global WinSetOption filetype=paludis-(key-value|options|mirrors|specs)-conf %{ require-module paludis } hook -group paludis-options-conf-highlight global WinSetOption filetype=paludis-options-conf %{ add-highlighter window/paludis-options-conf ref paludis-options-conf hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-options-conf } } hook -group paludis-key-value-conf-highlight global WinSetOption filetype=paludis-key-value-conf %{ add-highlighter window/paludis-key-value-conf ref paludis-key-value-conf hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-key-value-conf } } hook -group paludis-mirrors-conf-highlight global WinSetOption filetype=paludis-mirrors-conf %{ add-highlighter window/paludis-mirrors-conf ref paludis-mirrors-conf hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-mirrors-conf } } hook -group paludis-specs-conf-highlight global WinSetOption filetype=paludis-specs-conf %{ add-highlighter window/paludis-specs-conf ref paludis-specs-conf hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/paludis-specs-conf } } provide-module paludis %{ ## Paludis configurations ### options.conf add-highlighter shared/paludis-options-conf group add-highlighter shared/paludis-options-conf/ regex [\s\t]+(\S+(?:[\s\t]+))*$ 0:attribute add-highlighter shared/paludis-options-conf/ regex (?::)(?:[\s\t]+)(.*?$) 1:attribute add-highlighter shared/paludis-options-conf/ regex [\s\t]+(\S+=)(\S+) 1:attribute 2:value add-highlighter shared/paludis-options-conf/ regex [\s\t](\S+:) 0:keyword add-highlighter shared/paludis-options-conf/ regex [\s\t](-\S+)(.*?) 1:red add-highlighter shared/paludis-options-conf/ regex ^(\S+/\S+) 0:type add-highlighter shared/paludis-options-conf/ regex ^#.*?$ 0:comment ## general.conf, repository.template add-highlighter shared/paludis-key-value-conf group add-highlighter shared/paludis-key-value-conf/ regex ^[\s\t]?(\S+)[\s\t+]=[\s\t+](.*?)$ 1:attribute 2:value add-highlighter shared/paludis-key-value-conf/ regex ^#.*?$ 0:comment ## mirrors.conf add-highlighter shared/paludis-mirrors-conf group add-highlighter shared/paludis-mirrors-conf/ regex ^[\s\t+]?(\S+)[\s\t+](.*?)$ 1:type 2:value add-highlighter shared/paludis-mirrors-conf/ regex ^#.*?$ 0:comment ## package_(unmask|mask).conf, platforms.conf add-highlighter shared/paludis-specs-conf group add-highlighter shared/paludis-specs-conf/ regex [\s\t]+(\S+(?:[\s\t]+))*$ 0:attribute add-highlighter shared/paludis-specs-conf/ regex ^(\S+/\S+) 0:type add-highlighter shared/paludis-specs-conf/ regex ^#.*?$ 0:comment } hook global WinSetOption filetype=glep42 %{ require-module glep42 } hook -group glep42-highlight global WinSetOption filetype=glep42 %{ add-highlighter window/glep42 ref glep42 hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/glep42 } } provide-module glep42 %{ ## News items (GLEP42) add-highlighter shared/glep42 group add-highlighter shared/glep42/ regex ^(Title|Author|Translator|Content-Type|Posted|Revision|News-Item-Format|Display-If-Installed|Display-If-Keyword|Display-If-Profile):([^\n]*(?:\n\h+[^\n]+)*)$ 1:keyword 2:attribute add-highlighter shared/glep42/ regex <[^@>]+@.*?> 0:string add-highlighter shared/glep42/ regex ^>.*?$ 0:comment } kakoune-2020.09.01/rc/filetype/fish.kak000066400000000000000000000063171372342214000174150ustar00rootroot00000000000000# http://fishshell.com # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](fish) %{ set-option buffer filetype fish } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=fish %{ require-module fish hook window InsertChar .* -group fish-indent fish-indent-on-char hook window InsertChar \n -group fish-indent fish-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window fish-.+ } } hook -group fish-highlight global WinSetOption filetype=fish %{ add-highlighter window/fish ref fish hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/fish } } provide-module fish %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/fish regions add-highlighter shared/fish/code default-region group add-highlighter shared/fish/double_string region (? 1s^(\h+)$ d } } } define-command -hidden fish-indent-on-char %{ evaluate-commands -no-hooks -draft -itersel %{ # align middle and end structures to start and indent when necessary try %{ execute-keys -draft ^\h*(else)$^\h*(if)s\A|.\z1 } try %{ execute-keys -draft ^\h*(end)$^\h*(begin|for|function|if|switch|while)s\A|.\z1 } try %{ execute-keys -draft ^\h*(case)$^\h*(switch)s\A|.\z1 } } } define-command -hidden fish-indent-on-new-line %{ evaluate-commands -no-hooks -draft -itersel %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*#\h* y jgh P } # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line try %{ execute-keys -draft k s \h+$ d } # indent after start structure try %{ execute-keys -draft k^\h*(begin|case|else|for|function|if|while)\bj } } } } kakoune-2020.09.01/rc/filetype/fsharp.kak000066400000000000000000000160141372342214000177420ustar00rootroot00000000000000# https://fsharp.org/ # # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](fs|fsx|fsi) %{ set-option buffer filetype fsharp } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=fsharp %{ require-module fsharp # indent on newline hook window InsertChar \n -group fsharp-indent fsharp-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window fsharp-.+ } } hook -group fsharp-highlight global WinSetOption filetype=fsharp %{ add-highlighter window/fsharp ref fsharp hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/fsharp } } provide-module fsharp %§ # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/fsharp regions add-highlighter shared/fsharp/code default-region group add-highlighter shared/fsharp/docstring region \(\*(?!\)) (\*\)) regions add-highlighter shared/fsharp/double_string region @?(?\]" fill meta add-highlighter shared/fsharp/docstring/ default-region fill comment # ability to write highlighted code inside docstring: add-highlighter shared/fsharp/docstring/ region '>>> \K' '\z' ref fsharp add-highlighter shared/fsharp/docstring/ region '\.\.\. \K' '\z' ref fsharp evaluate-commands %sh{ # Grammar meta="open" # exceptions taken from fsharp.vim colors (https://github.com/fsharp/vim-fsharp) exceptions="try|failwith|failwithf|finally|invalid_arg|raise|rethrow" # keywords taken from fsharp.vim colors (https://github.com/fsharp/vim-fsharp) keywords="abstract|as|assert|base|begin|class|default|delegate" keywords="${keywords}|do|done|downcast|downto|elif|else|end|exception" keywords="${keywords}|extern|for|fun|function|global|if|in|inherit|inline" keywords="${keywords}|interface|lazy|let|match|member|module|mutable" keywords="${keywords}|namespace|new|of|override|rec|static|struct|then" keywords="${keywords}|to|type|upcast|use|val|void|when|while|with" keywords="${keywords}|async|atomic|break|checked|component|const|constraint" keywords="${keywords}|constructor|continue|decimal|eager|event|external" keywords="${keywords}|fixed|functor|include|method|mixin|object|parallel" keywords="${keywords}|process|pure|return|seq|tailcall|trait|yield" # additional operator keywords (Microsoft.FSharp.Core.Operators) keywords="${keywords}|box|hash|sizeof|nameof|typeof|typedefof|unbox|ref|fst|snd" keywords="${keywords}|stdin|stdout|stderr" # math operators (Microsoft.FSharp.Core.Operators) keywords="${keywords}|abs|acos|asin|atan|atan2|ceil|cos|cosh|exp|floor|log" keywords="${keywords}|log10|pown|round|sign|sin|sinh|sqrt|tan|tanh" types="array|bool|byte|char|decimal|double|enum|exn|float" types="${types}|float32|int|int16|int32|int64|lazy_t|list|nativeint" types="${types}|obj|option|sbyte|single|string|uint|uint32|uint64" types="${types}|uint16|unativeint|unit" fsharpCoreMethod="printf|printfn|sprintf|eprintf|eprintfn|fprintf|fprintfn" # Add the language's grammar to the static completion list printf '%s\n' "hook global WinSetOption filetype=fsharp %{ set-option window static_words ${values} ${meta} ${exceptions} ${keywords} ${types} }" | tr '|' ' ' # Highlight keywords printf '%s\n' " add-highlighter shared/fsharp/code/ regex '\b(${meta})\b' 0:meta add-highlighter shared/fsharp/code/ regex '\b(${exceptions})\b' 0:function add-highlighter shared/fsharp/code/ regex '\b(${fsharpCoreMethod})\b' 0:function add-highlighter shared/fsharp/code/ regex '\b(${keywords})\b' 0:keyword " } # computation expression keywords prefixed with ! add-highlighter shared/fsharp/code/ regex "\w+!" 0:keyword # brackets add-highlighter shared/fsharp/code/ regex "[\[\]\(\){}]" 0:bracket # accomodate typically overloaded operators add-highlighter shared/fsharp/code/ regex "\B(<<>>|<\|\|>)\B" 0:operator # fsharp operators add-highlighter shared/fsharp/code/ regex "\B(->|<-|<=|>=)\B" 0:operator add-highlighter shared/fsharp/code/ regex "(\b(not)\b|\b(and)\b)" 0:operator add-highlighter shared/fsharp/code/ regex (?<=[\w\s\d'"_])((\?)([><+-/*%=]{1,2})(\??)|(\??)([><+-/*%=]{1,2})(\?)) 0:operator add-highlighter shared/fsharp/code/ regex (?<=[\w\s\d'"_])((\|)+>|<(\|)+|<@|@>|<@@|@@>|:>|:\?|:=|(!|#)(?=\w)|:\?>|\?|~([-+]|(~){0,2})) 0:operator add-highlighter shared/fsharp/code/ regex (?<=[\w\s\d'"_])(<>|::|\h\|\h|(\|\|)+|@|\.\.|<=|>=|(<)+|(>)+|!=|==|\|\|\||(\^)+|(&)+|\+|-|(\*)+|//|/|%+|=) 0:operator add-highlighter shared/fsharp/code/ regex (?<=[\w\s\d'"_])((?!])=(?![=])|[+*-]=) 0:builtin # integer literals add-highlighter shared/fsharp/code/ regex %{(? s ^\h*//\h* y jgh P } # preserve previous line indent try %{ execute-keys -draft \; K } # cleanup trailing whitespaces from previous line try %{ execute-keys -draft k s \h+$ d } # indent after line ending with = try %{ execute-keys -draft k =$ j } # indent after line ending with "do" try %{ execute-keys -draft k \bdo$ j } } } § kakoune-2020.09.01/rc/filetype/gas.kak000066400000000000000000000113631372342214000172330ustar00rootroot00000000000000# Detection # --------- hook global BufCreate .*\.(s|S|asm)$ %{ set-option buffer filetype gas } hook global WinSetOption filetype=gas %{ require-module gas hook window InsertChar \n -group gas-indent gas-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window gas-.+ } } hook -group gas-highlight global WinSetOption filetype=gas %{ add-highlighter window/gas ref gas hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/gas } } provide-module gas %{ add-highlighter shared/gas regions add-highlighter shared/gas/code default-region group add-highlighter shared/gas/string region '"' (? # remove trailing white spaces try %{ execute-keys -draft s \h+$ d } } } define-command -hidden gas-indent-on-new-line %~ evaluate-commands -draft -itersel %< # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : gas-trim-indent } # indent after label try %[ execute-keys -draft k :$ j ] > ~ } kakoune-2020.09.01/rc/filetype/git.kak000066400000000000000000000037751372342214000172540ustar00rootroot00000000000000hook global BufCreate .*(COMMIT_EDITMSG|MERGE_MSG) %{ set-option buffer filetype git-commit } hook global BufCreate .*/NOTES_EDITMSG %{ set-option buffer filetype git-notes } hook global BufCreate .*(\.gitconfig|git/config) %{ set-option buffer filetype ini } hook global BufCreate .*git-rebase-todo %{ set-option buffer filetype git-rebase } hook global WinSetOption filetype=git-(commit|notes|rebase) %{ require-module "git-%val{hook_param_capture_1}" } hook -group git-commit-highlight global WinSetOption filetype=git-commit %{ add-highlighter window/git-commit ref git-commit hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-commit } } hook -group git-notes-highlight global WinSetOption filetype=git-notes %{ add-highlighter window/git-notes ref git-notes hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-notes } } hook -group git-rebase-highlight global WinSetOption filetype=git-rebase %{ add-highlighter window/git-rebase ref git-rebase hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-rebase } } provide-module git-commit %{ add-highlighter shared/git-commit regions add-highlighter shared/git-commit/diff region '^diff --git' '^(?=diff --git)' ref diff # highlight potential diffs from the -v option add-highlighter shared/git-commit/comments region '^\h*#' '$' group add-highlighter shared/git-commit/comments/ fill comment add-highlighter shared/git-commit/comments/ regex "\b(?:(modified)|(deleted)|(new file)|(renamed|copied)):([^\n]*)$" 1:yellow 2:red 3:green 4:blue 5:magenta } provide-module git-notes %{ add-highlighter shared/git-notes regex '^\h*#[^\n]*$' 0:comment } provide-module git-rebase %{ add-highlighter shared/git-rebase group add-highlighter shared/git-rebase/ regex "#[^\n]*\n" 0:comment add-highlighter shared/git-rebase/ regex "^(?:(pick|p)|(edit|reword|squash|fixup|exec|break|drop|label|reset|merge|[ersfxbdltm])) (\w+)" 1:keyword 2:value 3:meta } kakoune-2020.09.01/rc/filetype/gluon.kak000066400000000000000000000064121372342214000176040ustar00rootroot00000000000000# http://gluon-lang.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](glu) %{ set-option buffer filetype gluon } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=gluon %{ require-module gluon set-option window extra_word_chars '_' "'" hook window ModeChange insert:.* -group gluon-trim-indent gluon-trim-indent hook window InsertChar \n -group gluon-indent gluon-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window gluon-.+ } } hook -group gluon-highlight global WinSetOption filetype=gluon %{ add-highlighter window/gluon ref gluon hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/gluon } } provide-module gluon %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/gluon regions add-highlighter shared/gluon/code default-region group add-highlighter shared/gluon/string region (? < <= ^ <*> <$> etc # matches dot: . # matches keywords: @ : -> add-highlighter shared/gluon/code/ regex (?|:!?/.@$*&#%+\^\-\\])[~<=>|:!?/.@$*&#%+\^\-\\]+ 0:operator # matches 'x' '\\' '\'' '\n' '\0' # not incomplete literals: '\' add-highlighter shared/gluon/code/ regex \B'([^\\]|[\\]['"\w\d\\])' 0:string # this has to come after operators so '-' etc is correct # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden gluon-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden gluon-indent-on-new-line %~ evaluate-commands -draft -itersel %_ # copy // and /// comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K///?\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft \; K } # filter previous line try %{ execute-keys -draft k : gluon-trim-indent } # indent after lines ending with (open) braces, =, ->, condition, rec, # or in try %{ execute-keys -draft \; k x (\(|\{|\[|=|->|\b(?:then|else|rec|in))$ j } # deindent closing brace(s) when after cursor try %< execute-keys -draft ^\h*[})\]] gh / \})\]] m 1 > _ ~ § kakoune-2020.09.01/rc/filetype/go.kak000066400000000000000000000110531372342214000170620ustar00rootroot00000000000000# https://golang.org/ # # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.go %{ set-option buffer filetype go } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=go %{ require-module go set-option window static_words %opt{go_static_words} # cleanup trailing whitespaces when exiting insert mode hook window ModeChange pop:insert:.* -group go-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } hook window InsertChar \n -group go-indent go-indent-on-new-line hook window InsertChar \{ -group go-indent go-indent-on-opening-curly-brace hook window InsertChar \} -group go-indent go-indent-on-closing-curly-brace hook -once -always window WinSetOption filetype=.* %{ remove-hooks window go-.+ } } hook -group go-highlight global WinSetOption filetype=go %{ add-highlighter window/go ref go hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/go } } provide-module go %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/go regions add-highlighter shared/go/code default-region group add-highlighter shared/go/back_string region '`' '`' fill string add-highlighter shared/go/double_string region '"' (?K } # indent after lines ending with { or ( try %[ execute-keys -draft k [{(]\h*$ j ] # cleanup trailing white spaces on the previous line try %{ execute-keys -draft k s \h+$ d } # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # copy // comments prefix try %{ execute-keys -draft k s ^\h*\K/{2,} yP } # indent after a switch's case/default statements try %[ execute-keys -draft k ^\h*(case|default).*:$ j ] # indent after if|else|while|for try %[ execute-keys -draft )MB \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] # deindent closing brace(s) when after cursor try %[ execute-keys -draft ^\h*[})] gh / [})] m 1 ] = ~ define-command -hidden go-indent-on-opening-curly-brace %[ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft -itersel h)M \A\(.*\)\h*\n\h*\{\z s \A|.\z 1 ] ] define-command -hidden go-indent-on-closing-curly-brace %[ # align to opening curly brace when alone on a line try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] § kakoune-2020.09.01/rc/filetype/haml.kak000066400000000000000000000046521372342214000174050ustar00rootroot00000000000000# http://haml.info # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](haml) %{ set-option buffer filetype haml } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=haml %{ require-module haml hook window ModeChange pop:insert:.* -group haml-trim-indent haml-trim-indent hook window InsertChar \n -group haml-indent haml-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window haml-.+ } } hook -group haml-highlight global WinSetOption filetype=haml %{ add-highlighter window/haml ref haml hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/haml } } provide-module haml %[ require-module ruby require-module coffee require-module sass # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/haml regions add-highlighter shared/haml/code default-region group add-highlighter shared/haml/comment region ^\h*/ $ fill comment # Filters # http://haml.info/docs/yardoc/file.REFERENCE.html#filters add-highlighter shared/haml/eval1 region -recurse \{ ^\h*%([A-Za-z][A-Za-z0-9_-]*)([#.][A-Za-z][A-Za-z0-9_-]*)?\{\K|#\{\K (?=\}) ref ruby add-highlighter shared/haml/eval2 region ^\h*[=-]\K (? s \h+$ d } } define-command -hidden haml-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '/' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K/\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : haml-trim-indent } # indent after lines beginning with : or - try %{ execute-keys -draft k ^\h*[:-] j } } } ] kakoune-2020.09.01/rc/filetype/haskell.kak000066400000000000000000000133661372342214000201110ustar00rootroot00000000000000# http://haskell.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](hs) %{ set-option buffer filetype haskell } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=haskell %{ require-module haskell set-option buffer extra_word_chars '_' "'" hook window ModeChange pop:insert:.* -group haskell-trim-indent haskell-trim-indent hook window InsertChar \n -group haskell-indent haskell-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window haskell-.+ } } hook -group haskell-highlight global WinSetOption filetype=haskell %{ add-highlighter window/haskell ref haskell hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/haskell } } provide-module haskell %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/haskell regions add-highlighter shared/haskell/code default-region group add-highlighter shared/haskell/string region (??@\\\^|~=]|$) $ fill comment add-highlighter shared/haskell/quasiquote region \[\b[_a-z]['\w]*#?\| \|\] regex \[\b[_a-z]['\w]*#?\|(.*?)\|\] 1:string add-highlighter shared/haskell/code/ regex (?" # Quantifier separator in "forall a . [a] -> [a]" # Enum comprehensions like "[1..]" and "[a..b]" (making ".." and "Module..." illegal) # matches uppercase identifiers: Monad Control.Monad # not non-space separated dot: Just.const add-highlighter shared/haskell/code/ regex \b([A-Z]['\w]*\.)*[A-Z]['\w]*(?!['\w])(?![.a-z]) 0:variable # matches infix identifier: `mod` `Apa._T'M` add-highlighter shared/haskell/code/ regex `\b([A-Z]['\w]*\.)*[\w]['\w]*` 0:operator # matches imported operators: M.! M.. Control.Monad.>> # not operator keywords: M... M.-> add-highlighter shared/haskell/code/ regex \b[A-Z]['\w]*\.[~<=>|:!?/.@$*&#%+\^\-\\]+ 0:operator # matches dot: . # not possibly incomplete import: a. # not other operators: !. .! add-highlighter shared/haskell/code/ regex (?|:!?/.@$*&#%+\^\-\\])\.(?![~<=>|:!?/.@$*&#%+\^\-\\]) 0:operator # matches other operators: ... > < <= ^ <*> <$> etc # not dot: . # not operator keywords: @ .. -> :: ~ add-highlighter shared/haskell/code/ regex (?|:!?/.@$*&#%+\^\-\\])[~<=>|:!?/.@$*&#%+\^\-\\]+ 0:operator # matches operator keywords: @ -> add-highlighter shared/haskell/code/ regex (?|:!?/.@$*&#%+\^\-\\])(@|~|<-|->|=>|::|=|:|[|])(?![~<=>|:!?/.@$*&#%+\^\-\\]) 1:keyword # matches: forall [..variables..] . # not the variables add-highlighter shared/haskell/code/ regex \b(forall|∀)\b[^.\n]*?(\.) 1:keyword 2:keyword # matches 'x' '\\' '\'' '\n' '\0' # not incomplete literals: '\' # not valid identifiers: w' _' add-highlighter shared/haskell/code/ regex \B'([^\\]|[\\]['"\w\d\\])' 0:string # this has to come after operators so '-' etc is correct # matches function names in type signatures add-highlighter shared/haskell/code/ regex ^\s*(?:where\s+|let\s+|default\s+)?([_a-z]['\w]*#?(?:,\s*[_a-z]['\w]*#?)*)\s+::\s 1:meta # matches deriving strategies add-highlighter shared/haskell/code/ regex \bderiving\s+\b(stock|newtype|anyclass|via)\b 1:keyword add-highlighter shared/haskell/code/ regex \bderiving\b\s+(?:[A-Z]['\w]+|\([',\w\s]+?\))\s+\b(via)\b 1:keyword # Commands # ‾‾‾‾‾‾‾‾ # http://en.wikibooks.org/wiki/Haskell/Indentation define-command -hidden haskell-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden haskell-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K--\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # align to first clause try %{ execute-keys -draft k x X s ^\h*(if|then|else)?\h*(([\w']+\h+)+=)?\h*(case\h+[\w']+\h+of|do|let|where)\h+\K.* s \A|.\z & } # filter previous line try %{ execute-keys -draft k : haskell-trim-indent } # indent after lines beginning with condition or ending with expression or =( try %{ execute-keys -draft k x ^\h*if|[=(]$|\b(case\h+[\w']+\h+of|do|let|where)$ j } } } ] kakoune-2020.09.01/rc/filetype/hbs.kak000066400000000000000000000076431372342214000172430ustar00rootroot00000000000000# http://handlebarsjs.com/ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](hbs) %{ set-option buffer filetype hbs } hook global WinSetOption filetype=hbs %{ require-module hbs hook window ModeChange pop:insert:.* -group hbs-trim-indent hbs-trim-indent hook window InsertChar \n -group hbs-indent hbs-indent-on-new-line hook window InsertChar .* -group hbs-indent hbs-indent-on-char hook window InsertChar '>' -group hbs-indent html-indent-on-greater-than hook window InsertChar \n -group hbs-indent html-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window hbs-.+ } } hook -group hbs-highlight global WinSetOption filetype=hbs %{ maybe-add-hbs-to-html add-highlighter window/hbs-file ref hbs-file hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/hbs-file } } provide-module hbs %[ require-module html # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/hbs regions add-highlighter shared/hbs/comment region \{\{!-- --\}\} fill comment add-highlighter shared/hbs/comment_alt region \{\{! \}\} fill comment add-highlighter shared/hbs/block-expression region \{\{[#/] \}\} regions add-highlighter shared/hbs/expression region \{\{ \}\} regions define-command -hidden add-mutual-highlighters -params 1 %~ add-highlighter "shared/hbs/%arg{1}/code" default-region group add-highlighter "shared/hbs/%arg{1}/single-quote" region '"' (? s \h+$ d } } define-command -hidden hbs-indent-on-char %[ evaluate-commands -draft -itersel %[ # de-indent after closing a yielded block tag try %[ execute-keys -draft s ^\h+\{\{/([\w-.]+(?:/[\w-.]+)*)\}\}$ {c\{\{#1,\{\{/1\}\} s \A|.\z 1 ] ] ] define-command -hidden hbs-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '/' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K/\h* y j p } # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : hbs-trim-indent } # indent after lines beginning with : or - try %{ execute-keys -draft k ^\h*[:-] j } } } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ declare-option bool hbs_highlighters_enabled false define-command -hidden maybe-add-hbs-to-html %{ evaluate-commands %sh{ if [ "$kak_opt_hbs_highlighters_enabled" == "false" ]; then printf %s " add-highlighter shared/html/hbs region '\{\{' '\}\}' ref hbs add-highlighter shared/html/tag/hbs region '\{\{' '\}\}' ref hbs set-option global hbs_highlighters_enabled true " fi } } ] kakoune-2020.09.01/rc/filetype/html.kak000066400000000000000000000061611372342214000174250ustar00rootroot00000000000000# http://w3.org/html # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.html %{ set-option buffer filetype html } hook global BufCreate .*\.xml %{ set-option buffer filetype xml } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=(html|xml) %{ require-module html hook window ModeChange pop:insert:.* -group "%val{hook_param_capture_1}-trim-indent" html-trim-indent hook window InsertChar '>' -group "%val{hook_param_capture_1}-indent" html-indent-on-greater-than hook window InsertChar \n -group "%val{hook_param_capture_1}-indent" html-indent-on-new-line hook -once -always window WinSetOption "filetype=.*" " remove-hooks window ""%val{hook_param_capture_1}-.+"" " } hook -group html-highlight global WinSetOption filetype=(html|xml) %{ add-highlighter "window/%val{hook_param_capture_1}" ref html hook -once -always window WinSetOption "filetype=.*" " remove-highlighter ""window/%val{hook_param_capture_1}"" " } provide-module html %[ try %{ require-module css require-module javascript } # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/html regions add-highlighter shared/html/comment region fill comment add-highlighter shared/html/tag region < > regions add-highlighter shared/html/style region \K (?=) ref css add-highlighter shared/html/script region \K (?=) ref javascript add-highlighter shared/html/tag/base default-region group add-highlighter shared/html/tag/ region '"' (? s \h+$ d } } define-command -hidden html-indent-on-greater-than %[ evaluate-commands -draft -itersel %[ # align closing tag to opening when alone on a line try %[ execute-keys -draft s ^\h+/(\w+)$ {c1,/1 s \A|.\z 1 ] ] ] define-command -hidden html-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : html-trim-indent } # indent after lines ending with opening tag except when it starts with a closing tag try %{ execute-keys -draft k (?!area)(?!base)(?!br)(?!col)(?!command)(?!embed)(?!hr)(?!img)(?!input)(?!keygen)(?!link)(?!menuitem)(?!meta)(?!param)(?!source)(?!track)(?!wbr)(?!/)(?!>)[a-zA-Z0-9_-]+[^>]*?>$ j^\s*/ } } } ] kakoune-2020.09.01/rc/filetype/i3.kak000066400000000000000000000111721372342214000167720ustar00rootroot00000000000000hook global BufCreate .*(sway|i3)/config %{ set buffer filetype i3 } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=i3 %[ require-module i3 # cleanup trailing whitespaces when exiting insert mode hook window ModeChange pop:insert:.* -group i3-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } hook window InsertChar \n -group i3-indent i3-indent-on-new-line hook window InsertChar \} -group i3-indent i3-indent-on-closing-curly-brace hook -once -always window WinSetOption filetype=.* %{ remove-hooks window i3-.+ } ] hook -group i3-highlight global WinSetOption filetype=i3 %{ add-highlighter window/i3 ref i3 hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/i3 } } provide-module i3 %[ add-highlighter shared/i3 regions add-highlighter shared/i3/code default-region group add-highlighter shared/i3/double_string region %{"} %{"} group add-highlighter shared/i3/single_string region %{'} %{'} group add-highlighter shared/i3/exec region %{((?<=exec )|(?<=--no-startup-id ))(?!--no-startup-id)} "$" fill string add-highlighter shared/i3/comment region "#" "$" fill comment add-highlighter shared/i3/double_string/ fill string add-highlighter shared/i3/single_string/ fill string # Symbols add-highlighter shared/i3/code/ regex "[+|→]" 0:operator add-highlighter shared/i3/code/ regex "\$\w+" 0:variable # keys add-highlighter shared/i3/code/ regex "\b(Shift|Control|Ctrl|Mod1|Mod2|Mod3|Mod4|Mod5|Mode_switch|Return|Escape|Print)\b" 0:value # keywords add-highlighter shared/i3/code/ regex "\b(bind|bindcode|bindsym|assign|new_window|default_(floating_)?border|popup_during_fullscreen|font|floating_modifier|default_orientation|workspace_layout|for_window|focus_follows_mouse|bar|position|colors|output|tray_output|workspace_buttons|workspace_auto_back_and_forth|binding_mode_indicator|debuglog|floating_minimum_size|floating_maximum_size|force_focus_wrapping|force_xinerama|force_display_urgency_hint|hidden_state|modifier|new_float|shmlog|socket_path|verbose|mouse_warping|strip_workspace_numbers|focus_on_window_activation|no_focus|set|mode|set_from_resource)\b" 0:keyword # function keywords add-highlighter shared/i3/code/ regex "\b(exit|reload|restart|kill|fullscreen|global|layout|border|focus|move|open|split|append_layout|mark|unmark|resize|grow|shrink|show|nop|rename|title_format|sticky)\b" 0:function add-highlighter shared/i3/code/ regex "\b(exec|exec_always|i3bar_command|status_command)\b" 0:function # " these are not keywords but we add them for consistency add-highlighter shared/i3/code/ regex "\b(no|false|inactive)\b" 0:value # values add-highlighter shared/i3/code/ regex "\b(1pixel|default|stacked|tabbed|normal|none|tiling|stacking|floating|enable|disable|up|down|horizontal|vertical|auto|up|down|left|right|parent|child|px|or|ppt|leave_fullscreen|toggle|mode_toggle|scratchpad|width|height|top|bottom|client|hide|primary|yes|all|active|window|container|to|absolute|center|on|off|ms|smart|ignore|pixel|splith|splitv|output|true)\b" 0:value add-highlighter shared/i3/code/ regex "\b(next|prev|next_on_output|prev_on_output|back_and_forth|current|number|none|vertical|horizontal|both|dock|hide|invisible|gaps|smart_gaps|smart_borders|inner|outer|current|all|plus|minus|no_gaps)\b" 0:value # double-dash arguments add-highlighter shared/i3/code/ regex "--(release|border|whole-window|toggle|no-startup-id)" 0:attribute # color add-highlighter shared/i3/double_string/ regex "#[0-9a-fA-F]{6}" 0:value add-highlighter shared/i3/single_string/ regex "#[0-9a-fA-F]{6}" 0:value # attributes add-highlighter shared/i3/code/ regex "client\.(background|statusline|background|separator|statusline)" 1:attribute add-highlighter shared/i3/code/ regex "client\.(focused_inactive|focused|unfocused|urgent|inactive_workspace|urgent_workspace|focused_workspace|active_workspace|placeholder)" 1:attribute # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden i3-indent-on-new-line %~ evaluate-commands -draft -itersel %= # copy # comments prefix try %{ execute-keys -draft k s ^\h*#\h* y jgh P } # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with { try %[ execute-keys -draft k \{\h*$ j ] # cleanup trailing white spaces on the previous line try %{ execute-keys -draft k s \h+$ d } = ~ define-command -hidden i3-indent-on-closing-curly-brace %[ # align to opening curly brace when alone on a line try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] ] kakoune-2020.09.01/rc/filetype/ini.kak000066400000000000000000000013051372342214000172330ustar00rootroot00000000000000hook global BufCreate .+\.(repo|ini|cfg|properties|desktop) %{ set-option buffer filetype ini } hook global WinSetOption filetype=ini %{ require-module ini } hook -group ini-highlight global WinSetOption filetype=ini %{ add-highlighter window/ini ref ini hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ini } } provide-module ini %{ add-highlighter shared/ini regions add-highlighter shared/ini/code default-region group add-highlighter shared/ini/comment region '(^|\h)\K[#;]' $ fill comment add-highlighter shared/ini/code/ regex "(?S)^\h*(\[.+?\])\h*$" 1:title add-highlighter shared/ini/code/ regex "^\h*([^\[][^=\n]*)=([^\n]*)" 1:variable 2:value } kakoune-2020.09.01/rc/filetype/java.kak000066400000000000000000000070761372342214000174100ustar00rootroot00000000000000hook global BufCreate .*\.java %{ set-option buffer filetype java } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=java %{ require-module java # cleanup trailing whitespaces when exiting insert mode hook window ModeChange pop:insert:.* -group java-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } hook window InsertChar \n -group java-indent java-indent-on-new-line hook window InsertChar \{ -group java-indent java-indent-on-opening-curly-brace hook window InsertChar \} -group java-indent java-indent-on-closing-curly-brace hook -once -always window WinSetOption filetype=.* %{ remove-hooks window java-.+ } } hook -group java-highlight global WinSetOption filetype=java %{ add-highlighter window/java ref java hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/java } } provide-module java %§ add-highlighter shared/java regions add-highlighter shared/java/code default-region group add-highlighter shared/java/string region %{(?K } # indent after lines ending with { or ( try %[ execute-keys -draft k [{(]\h*$ j ] # cleanup trailing white spaces on the previous line try %{ execute-keys -draft k s \h+$ d } # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # copy // comments prefix try %{ execute-keys -draft k s ^\h*\K/{2,} yP } # indent after a switch's case/default statements try %[ execute-keys -draft k ^\h*(case|default).*:$ j ] # indent after keywords try %[ execute-keys -draft )MB \A(if|else|while|for|try|catch)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] # deindent closing brace(s) when after cursor try %[ execute-keys -draft ^\h*[})] gh / [})] m 1 ] = ~ define-command -hidden java-indent-on-opening-curly-brace %[ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft -itersel h)M \A\(.*\)\h*\n\h*\{\z s \A|.\z 1 ] ] define-command -hidden java-indent-on-closing-curly-brace %[ # align to opening curly brace when alone on a line try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] § kakoune-2020.09.01/rc/filetype/javascript.kak000066400000000000000000000156751372342214000206410ustar00rootroot00000000000000# Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.]m?(js)x? %{ set-option buffer filetype javascript } hook global BufCreate .*[.](ts)x? %{ set-option buffer filetype typescript } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=(javascript|typescript) %{ require-module javascript hook window ModeChange pop:insert:.* -group "%val{hook_param_capture_1}-trim-indent" javascript-trim-indent hook window InsertChar .* -group "%val{hook_param_capture_1}-indent" javascript-indent-on-char hook window InsertChar \n -group "%val{hook_param_capture_1}-indent" javascript-indent-on-new-line hook -once -always window WinSetOption filetype=.* " remove-hooks window %val{hook_param_capture_1}-.+ " } hook -group javascript-highlight global WinSetOption filetype=javascript %{ add-highlighter window/javascript ref javascript hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/javascript } } hook -group typescript-highlight global WinSetOption filetype=typescript %{ add-highlighter window/typescript ref typescript hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/typescript } } provide-module javascript %§ # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden javascript-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden javascript-indent-on-char %< evaluate-commands -draft -itersel %< # align closer token to its opener when alone on a line try %/ execute-keys -draft ^\h+[\]}]$ m s \A|.\z 1 / > > define-command -hidden javascript-indent-on-new-line %< evaluate-commands -draft -itersel %< # copy // comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : javascript-trim-indent } # indent after lines beginning / ending with opener token try %_ execute-keys -draft k s [[({] [\])}] j _ # deindent closing token(s) when after cursor try %_ execute-keys -draft ^\h*[})\]] gh / [})\]] m 1 _ > > # Highlighting and hooks bulder for JavaScript and TypeScript # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ define-command -hidden init-javascript-filetype -params 1 %~ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter "shared/%arg{1}" regions add-highlighter "shared/%arg{1}/code" default-region group add-highlighter "shared/%arg{1}/double_string" region '"' (?][\w:.-]* (?][\w:.-]*(?!\hextends)(?=[\s/>])(?!>\()) (|/>) regions add-highlighter "shared/%arg{1}/division" region '[\w\)\]]\K(/|(\h+/\h+))' '(?=\w)' group # Help Kakoune to better detect /…/ literals # Regular expression flags are: g → global match, i → ignore case, m → multi-lines, u → unicode, y → sticky # https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp add-highlighter "shared/%arg{1}/literal/" fill string add-highlighter "shared/%arg{1}/literal/" regex \$\{.*?\} 0:value add-highlighter "shared/%arg{1}/code/" regex [^$_]\b(document|false|null|parent|self|this|true|undefined|window)\b 1:value add-highlighter "shared/%arg{1}/code/" regex "-?\b[0-9]*\.?[0-9]+" 0:value add-highlighter "shared/%arg{1}/code/" regex \b(Array|Boolean|Date|Function|Number|Object|RegExp|String|Symbol)\b 0:type # jsx: In well-formed xml the number of opening and closing tags match up regardless of tag name. # # We inline a small XML highlighter here since it anyway need to recurse back up to the starting highlighter. # To make things simple we assume that jsx is always enabled. add-highlighter "shared/%arg{1}/jsx/tag" region -recurse < <(?=[/a-zA-Z>]) (? regions add-highlighter "shared/%arg{1}/jsx/expr" region -recurse \{ \{ \} ref %arg{1} add-highlighter "shared/%arg{1}/jsx/tag/base" default-region group add-highlighter "shared/%arg{1}/jsx/tag/double_string" region =\K" (?) 0:meta add-highlighter "shared/%arg{1}/jsx/tag/expr/" ref %arg{1} # Keywords are collected at # https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords # https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get # https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set add-highlighter "shared/%arg{1}/code/" regex \b(async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|export|extends|finally|for|function|get|if|import|in|instanceof|let|new|of|return|set|static|super|switch|throw|try|typeof|var|void|while|with|yield)\b 0:keyword ~ init-javascript-filetype javascript init-javascript-filetype typescript # Highlighting specific to TypeScript # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/typescript/code/ regex \b(array|boolean|date|number|object|regexp|string|symbol)\b 0:type # Keywords grabbed from https://github.com/Microsoft/TypeScript/issues/2536 add-highlighter shared/typescript/code/ regex \b(as|constructor|declare|enum|from|implements|interface|module|namespace|package|private|protected|public|readonly|static|type)\b 0:keyword § # Aliases # ‾‾‾‾‾‾‾ provide-module typescript %{ require-module javascript } kakoune-2020.09.01/rc/filetype/jinja.kak000066400000000000000000000050451372342214000175540ustar00rootroot00000000000000# https://palletsprojects.com/p/jinja/ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ provide-module jinja %[ require-module python # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/jinja regions add-highlighter shared/jinja/comment region '\{#' '#\}' fill comment # TODO: line statements # … add-highlighter shared/jinja/statement region '\{%' '%\}' group add-highlighter shared/jinja/statement/ ref python add-highlighter shared/jinja/statement/ regex \{%[+-]?|[+-]?%\} 0:value add-highlighter shared/jinja/statement/tests regex \b(callable|even|le|none|string|defined|ge|lower|number|undefined|divisibleby|gt|lt|odd|upper|eq|in|mapping|sameas|escaped|iterable|ne|sequence)\b 0:builtin add-highlighter shared/jinja/statement/functions regex \b(range|lipsum)\b 0:function add-highlighter shared/jinja/statement/macro regex \b(((end)?(call|macro)))\b 0:keyword add-highlighter shared/jinja/statement/extensions regex \b(((end)?(block|trans))|(pluralize))\b 0:keyword add-highlighter shared/jinja/statement/control regex \b(((end)?(if|for|with))|(break|continue))\b 0:keyword add-highlighter shared/jinja/statement/filters regex \b(?:(?:(filter)\s+|\|\s*)(abs|attr|batch|capitalize|center|default|dictsort|e|escape|filesizeformat|first|float|forceescape|format|groupby|indent|int|join|last|length|list|lower|map|max|min|pprint|random|reject|rejectattr|replace|reverse|round|safe|select|selectattr|slice|sort|string|striptags|sum|title|tojson|trim|truncate|unique|upper|urlencode|urlize|wordcount|wordwrap|xmlattr)|(endfilter))\b 1:keyword 3:keyword 2:builtin add-highlighter shared/jinja/statement/ regex \b((end)?(autoescape|raw|set))\b 0:keyword add-highlighter shared/jinja/statement/ regex \b(do|extends|include)\b 0:keyword add-highlighter shared/jinja/statement/ regex \bignore\s+missing\b 0:meta add-highlighter shared/jinja/statement/ regex \bwith(out)?\s+context\b 0:meta add-highlighter shared/jinja/expression region '\{\{' '\}\}' group add-highlighter shared/jinja/expression/ ref python add-highlighter shared/jinja/expression/ regex \{\{|\}\} 0:value add-highlighter shared/jinja/expression/filters regex \|\s*(abs|attr|batch|capitalize|center|default|dictsort|e|escape|filesizeformat|first|float|forceescape|format|groupby|indent|int|join|last|length|list|lower|map|max|min|pprint|random|reject|rejectattr|replace|reverse|round|safe|select|selectattr|slice|sort|string|striptags|sum|title|tojson|trim|truncate|unique|upper|urlencode|urlize|wordcount|wordwrap|xmlattr)\b 1:builtin ] kakoune-2020.09.01/rc/filetype/json.kak000066400000000000000000000042001372342214000174220ustar00rootroot00000000000000# http://json.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](json) %{ set-option buffer filetype json } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=json %{ require-module json hook window ModeChange pop:insert:.* -group json-trim-indent json-trim-indent hook window InsertChar .* -group json-indent json-indent-on-char hook window InsertChar \n -group json-indent json-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window json-.+ } } hook -group json-highlight global WinSetOption filetype=json %{ add-highlighter window/json ref json hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/json } } provide-module json %( # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/json regions add-highlighter shared/json/code default-region group add-highlighter shared/json/string region '"' (? s \h+$ d } } define-command -hidden json-indent-on-char %< evaluate-commands -draft -itersel %< # align closer token to its opener when alone on a line try %< execute-keys -draft ^\h+[\]}]$ m 1 > > > define-command -hidden json-indent-on-new-line %< evaluate-commands -draft -itersel %< # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : json-trim-indent } # indent after lines ending with opener token try %< execute-keys -draft k [[{]\h*$ j > # deindent closer token(s) when after cursor try %< execute-keys -draft ^\h*[}\]] gh / [}\]] m 1 > > > ) kakoune-2020.09.01/rc/filetype/julia.kak000066400000000000000000000044051372342214000175640ustar00rootroot00000000000000# http://julialang.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.(jl) %{ set-option buffer filetype julia } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=julia %{ require-module julia } hook -group julia-highlight global WinSetOption filetype=julia %{ add-highlighter window/julia ref julia hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/julia } } provide-module julia %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/julia regions add-highlighter shared/julia/code default-region group add-highlighter shared/julia/string region '"' (?K } # cleanup trailing white spaces on previous line try %{ execute-keys -draft k s \h+$ "_d } # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*//\h* y jgh P } } } # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/justfile regions add-highlighter shared/justfile/content default-region group add-highlighter shared/justfile/comment region '#' '$' fill comment add-highlighter shared/justfile/double_string region '"' (?)}\]] -group kak-indent kak-indent-on-closing-matching hook window InsertChar (?![[{(<>)}\]])[^\s\w] -group kak-indent kak-indent-on-closing-char # cleanup trailing whitespaces on current line insert end hook window ModeChange pop:insert:.* -group kak-trim-indent %{ try %{ execute-keys -draft s ^\h+$ d } } set-option buffer extra_word_chars '_' '-' hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kak-.+ } ~ hook -group kak-highlight global WinSetOption filetype=kak %{ add-highlighter window/kakrc ref kakrc hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/kakrc } } provide-module kak %§ require-module sh # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/kakrc regions add-highlighter shared/kakrc/code default-region group add-highlighter shared/kakrc/comment region (^|\h)\K# $ fill comment add-highlighter shared/kakrc/double_string region -recurse %{(?' ref sh add-highlighter shared/kakrc/shell5 region -recurse '\{' '(^|\h)\K-shell-script-(completion|candidates)\h+%\{' '\}' ref sh add-highlighter shared/kakrc/shell6 region -recurse '\(' '(^|\h)\K-shell-script-(completion|candidates)\h+%\(' '\)' ref sh add-highlighter shared/kakrc/shell7 region -recurse '\[' '(^|\h)\K-shell-script-(completion|candidates)\h+%\[' '\]' ref sh add-highlighter shared/kakrc/shell8 region -recurse '<' '(^|\h)\K-shell-script-(completion|candidates)\h+%<' '>' ref sh evaluate-commands %sh{ # Grammar keywords="edit write write-all kill quit write-quit write-all-quit map unmap alias unalias buffer buffer-next buffer-previous delete-buffer add-highlighter remove-highlighter hook trigger-user-hook remove-hooks define-command echo debug source try catch fail nop set-option unset-option update-option declare-option execute-keys evaluate-commands prompt menu on-key info set-face unset-face rename-client set-register select change-directory rename-session colorscheme declare-user-mode enter-user-mode edit! write! kill! quit! write-quit! delete-buffer! provide-module require-module" attributes="global buffer window current normal insert menu prompt goto view user object number-lines show-matching show-whitespaces fill regex dynregex group flag-lines ranges line column wrap ref regions region default-region replace-ranges" types="int bool str regex int-list str-list completions line-specs range-specs" values="default black red green yellow blue magenta cyan white yes no false true" join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } # Add the language's grammar to the static completion list printf %s\\n "declare-option str-list kak_static_words $(join "${keywords} ${attributes} ${types} ${values}" ' ')'" # Highlight keywords (which are always surrounded by whitespace) printf '%s\n' "add-highlighter shared/kakrc/code/keywords regex (?:\s|\A)\K($(join "${keywords}" '|'))(?:(?=\s)|\z) 0:keyword add-highlighter shared/kakrc/code/attributes regex (?:\s|\A)\K($(join "${attributes}" '|'))(?:(?=\s)|\z) 0:attribute add-highlighter shared/kakrc/code/types regex (?:\s|\A)\K($(join "${types}" '|'))(?:(?=\s)|\z) 0:type add-highlighter shared/kakrc/code/values regex (?:\s|\A)\K($(join "${values}" '|'))(?:(?=\s)|\z) 0:value" } add-highlighter shared/kakrc/code/colors regex \b(rgb:[0-9a-fA-F]{6}|rgba:[0-9a-fA-F]{8})\b 0:value add-highlighter shared/kakrc/double_string/fill fill string add-highlighter shared/kakrc/double_string/escape regex '""' 0:default+b add-highlighter shared/kakrc/single_string/fill fill string add-highlighter shared/kakrc/single_string/escape regex "''" 0:default+b # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden kak-insert-on-new-line %~ evaluate-commands -draft -itersel %= # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*#\h* y jgh P } = ~ define-command -hidden kak-indent-on-new-line %~ evaluate-commands -draft -itersel %= # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line try %{ execute-keys -draft k s \h+$ d } # indent after line ending with %\w*[^\s\w] try %{ execute-keys -draft k \%\w*[^\s\w]$ j } # deindent closing brace when after cursor try %_ execute-keys -draft -itersel ^\h*([>)}\]]) gh / 1 m 1 _ # deindent closing char(s) try %{ execute-keys -draft -itersel ^\h*([^\s\w]) gh / 1 1 % \w*1$ 1 } = ~ define-command -hidden kak-indent-on-closing-matching %~ # align to opening matching brace when alone on a line try %= execute-keys -draft -itersel ^\h*\Q %val{hook_param} \E$ mGi s \A|.\z 1 = ~ define-command -hidden kak-indent-on-closing-char %{ # align to opening matching character when alone on a line try %{ execute-keys -draft -itersel ^\h*\Q %val{hook_param} \E$gi %val{hook_param} %\w*\Q %val{hook_param} \E$ s \A|.\z gi 1 } } § kakoune-2020.09.01/rc/filetype/kickstart.kak000066400000000000000000000042441372342214000204600ustar00rootroot00000000000000hook global BufCreate .*\.ks %{ set-option buffer filetype kickstart } hook global WinSetOption filetype=kickstart %{ require-module kickstart } hook -group kickstart-highlight global WinSetOption filetype=kickstart %{ add-highlighter window/kickstart ref kickstart hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/kickstart } } provide-module kickstart %{ add-highlighter shared/kickstart regions add-highlighter shared/kickstart/code default-region group add-highlighter shared/kickstart/comment region '(^|\h)\K#' $ fill comment add-highlighter shared/kickstart/double_string region '"' (? 1s^(\h+)$ d } } } define-command -hidden latex-indent-newline %( evaluate-commands -no-hooks -draft -itersel %( # copy '%' comment prefix and following white spaces try %{ execute-keys -draft k s^\h*%\h* y jgh P } # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line try %{ execute-keys -draft k s\h+$ d } # indent after line ending with { try %( execute-keys -draft k \{$ j ) # deindent closing brace(s) when after cursor try %( execute-keys -draft ^\h*\} gh / \} m 1 ) # indent after line ending with \begin{...}[...]{...}, with multiple # sets of arguments possible try %( execute-keys -draft \ k \ \\begin\h*\{[^\}]+\}(\h|\[.*\]|\{.*\})*$ \ j ) ) ) define-command -hidden latex-indent-closing-brace %( evaluate-commands -no-hooks -draft -itersel %( # Align lone } with matching bracket try %( execute-keys -draft _ \A\}\z m1 ) # Align \end{...} with corresponding \begin{...} try %( execute-keys -draft h 1s\\end\h*\{([^\}]+)\}\z \ \\begin\s*\{.\} 1 ) ) ) ~ kakoune-2020.09.01/rc/filetype/ledger.kak000066400000000000000000000134371372342214000177270ustar00rootroot00000000000000# Detection # --------- # The .ledger suffix is not required by ledger, but the best I can do. hook global BufCreate .*\.ledger %{ set-option buffer filetype ledger } # Initialization # -------------- hook global WinSetOption filetype=ledger %{ require-module ledger hook window InsertChar \n -group ledger-indent ledger-indent-on-new-line hook window ModeChange pop:insert:.* -group ledger-trim-indent ledger-trim-indent hook -once -always window WinSetOption filetype=.* %{ remove-hooks window ledger-.+ unset-option window static_words # Remove static completion } } hook -group ledger-highlight global WinSetOption filetype=ledger %{ add-highlighter window/ledger ref ledger hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ledger } } # Completion # ---------- hook -group ledger-complete global WinSetOption filetype=ledger %{ set-option window static_words account note alias payee check assert eval \ default apply fixed bucket capture comment commodity format nomarket \ define end include tag test year } provide-module ledger %[ # Highlighters # ------------ # # TODO: highlight tag comments add-highlighter shared/ledger regions # The following highlighters implement # https://www.ledger-cli.org/3.0/doc/ledger3.html#Transactions-and-Comments add-highlighter shared/ledger/transaction region '^[0-9]' '^(?=\H)' group add-highlighter shared/ledger/transaction/first_line regex \ '^([0-9].*?)\h.*?(( +|\t+);.*?)?$' 1:function 2:string add-highlighter shared/ledger/transaction/posting regex \ '^\h+([^\h;].*?)(( +|\t+).*?)?(( +|\t+);.*?)?$' 1:type 2:value 4:string add-highlighter shared/ledger/transaction/note regex '^\h+;[^$]*?$' 0:string add-highlighter shared/ledger/comment region '^(;|#|%|\||\*)' '$' fill comment # TODO: Improve add-highlighter shared/ledger/other region '^(P|=|~)' '$' fill meta # The following highlighters implement # https://www.ledger-cli.org/3.0/doc/ledger3.html#Command-Directives # Add highlighters for simple one-line command directives evaluate-commands %sh{ # TODO: Is `expr` also a command directive? The documentation confuses me. for cmd in 'apply account' 'apply fixed' 'assert' 'bucket' 'check' 'end' \ 'include' 'apply tag' 'test' 'year'; do echo "add-highlighter shared/ledger/ region '^${cmd}' '.' fill function" done } add-highlighter shared/ledger/account region '^account' '^(?=\H)' group add-highlighter shared/ledger/account/first_line regex '^account' 0:function add-highlighter shared/ledger/account/note regex '^\h*note' 0:function add-highlighter shared/ledger/account/alias regex '^\h*alias' 0:function add-highlighter shared/ledger/account/payee regex '^\h*payee' 0:function add-highlighter shared/ledger/account/check regex '^\h*check' 0:function add-highlighter shared/ledger/account/assert regex '^\h*assert' 0:function add-highlighter shared/ledger/account/eval regex '^\h*eval' 0:function add-highlighter shared/ledger/account/default regex '^\h*default' 0:function add-highlighter shared/ledger/alias region '^alias' '$' group add-highlighter shared/ledger/alias/keyword regex '^alias' 0:function add-highlighter shared/ledger/alias/key regex '^alias\h([^$=]*)=?' 1:variable add-highlighter shared/ledger/alias/value regex '^alias\h.*?=(.*?)$' 1:value add-highlighter shared/ledger/capture region '^capture' '$' group add-highlighter shared/ledger/capture/keyword regex '^capture' 0:function add-highlighter shared/ledger/capture/account regex \ '^capture\h+(.*?)( +|\t+|$)' 1:type add-highlighter shared/ledger/capture/regex regex \ '^capture\h+.*?( +|\t+)(.*?)$' 2:value add-highlighter shared/ledger/comment_block region '^comment' '^end comment' \ fill comment add-highlighter shared/ledger/commodity region '^commodity' '^(?=\H)' group add-highlighter shared/ledger/commodity/first_line regex '^commodity' 0:function add-highlighter shared/ledger/commodity/note regex '^\h*note' 0:function add-highlighter shared/ledger/commodity/format regex '^\h*format' 0:function add-highlighter shared/ledger/commodity/nomarket regex '^\h*nomarket' 0:function add-highlighter shared/ledger/commodity/alias regex '^\h*alias' 0:function add-highlighter shared/ledger/commodity/default regex '^\h*default' 0:function add-highlighter shared/ledger/define region '^define' '$' group add-highlighter shared/ledger/define/keyword regex '^define' 0:function add-highlighter shared/ledger/define/key regex '^define\h([^$=]*)=?' 1:variable add-highlighter shared/ledger/define/value regex '^define\h.*?=(.*?)$' 1:value add-highlighter shared/ledger/payee region '^payee' '^(?=\H)' group add-highlighter shared/ledger/payee/first_line regex '^payee' 0:function add-highlighter shared/ledger/payee/alias regex '^\h*alias' 0:function add-highlighter shared/ledger/payee/uuid regex '^\h*uuid' 0:function add-highlighter shared/ledger/tag region '^tag' '^(?=\H)' group add-highlighter shared/ledger/tag/first_line regex '^tag' 0:function add-highlighter shared/ledger/tag/check regex '^\h*check' 0:function add-highlighter shared/ledger/tag/assert regex '^\h*assert' 0:function # Commands # -------- define-command -hidden ledger-indent-on-new-line %[ evaluate-commands -draft -itersel %[ # preserve previous line indent try %[ execute-keys -draft K ] # cleanup trailing whitespaces from previous line try %[ execute-keys -draft k s \h+$ d ] # indent after the first line of a transaction try %[ execute-keys -draft k ^[0-9] j ] ] ] define-command -hidden ledger-trim-indent %{ try %{ execute-keys -draft s ^\h+$ d } } ] kakoune-2020.09.01/rc/filetype/lisp.kak000066400000000000000000000063501372342214000174300ustar00rootroot00000000000000# http://common-lisp.net # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](lisp) %{ set-option buffer filetype lisp } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=lisp %{ require-module lisp hook window ModeChange pop:insert:.* -group lisp-trim-indent lisp-trim-indent hook window InsertChar \n -group lisp-indent lisp-indent-on-new-line set-option buffer extra_word_chars '_' '+' '-' '*' '/' '@' '$' '%' '^' '&' '_' '=' '<' '>' '~' '.' hook -once -always window WinSetOption filetype=.* %{ remove-hooks window lisp-.+ } } hook -group lisp-highlight global WinSetOption filetype=lisp %{ add-highlighter window/lisp ref lisp hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/lisp } } provide-module lisp %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/lisp regions add-highlighter shared/lisp/code default-region group add-highlighter shared/lisp/string region '"' (?|<=|=|>=) 0:operator add-highlighter shared/lisp/code/ regex \b(def[a-z]+|if|do|let|lambda|catch|and|assert|while|def|do|fn|finally|let|loop|new|quote|recur|set!|throw|try|var|case|if-let|if-not|when|when-first|when-let|when-not|(cond(->|->>)?))\b 0:keyword add-highlighter shared/lisp/code/ regex (#?(['`:]|,@?))?\b[a-zA-Z][\w!$%&*+./:<=>?@^_~-]* 0:variable add-highlighter shared/lisp/code/ regex \*[a-zA-Z][\w!$%&*+./:<=>?@^_~-]*\* 0:variable add-highlighter shared/lisp/code/ regex (\b\d+)?\.\d+([eEsSfFdDlL]\d+)?\b 0:value # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden lisp-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } declare-option \ -docstring 'regex matching the head of forms which have options *and* indented bodies' \ regex lisp_special_indent_forms \ '(?:def.*|if(-.*|)|let.*|lambda|with-.*|when(-.*|))' define-command -hidden lisp-indent-on-new-line %{ # registers: i = best align point so far; w = start of first word of form evaluate-commands -draft -save-regs '/"|^@iw' -itersel %{ execute-keys -draft 'gk"iZ' try %{ execute-keys -draft '[bl"i"wZ' try %{ # If a special form, indent another (indentwidth - 1) spaces execute-keys -draft '"wze\A' %opt{lisp_special_indent_forms} '\z' execute-keys -draft '"wzes.{' %sh{printf $(( kak_opt_indentwidth - 1 ))} '}\K.*;"i' } catch %{ # If not "special" form and parameter appears on line 1, indent to parameter execute-keys -draft '"wz[()\[\]{}]es\h\K[^\s].*;"i' } } try %{ execute-keys -draft '[rl"i' } try %{ execute-keys -draft '[Bl"i' } execute-keys -draft ';"ia&' } } } kakoune-2020.09.01/rc/filetype/lua.kak000066400000000000000000000123501372342214000172370ustar00rootroot00000000000000# http://lua.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](lua) %{ set-option buffer filetype lua } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=lua %{ require-module lua hook window ModeChange pop:insert:.* -group lua-indent lua-trim-indent hook window InsertChar .* -group lua-indent lua-indent-on-char hook window InsertChar \n -group lua-indent lua-indent-on-new-line hook window InsertChar \n -group lua-insert lua-insert-on-new-line alias window alt lua-alternative-file hook -once -always window WinSetOption filetype=.* %{ remove-hooks window lua-.+ unalias window alt lua-alternative-file } } hook -group lua-highlight global WinSetOption filetype=lua %{ add-highlighter window/lua ref lua hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/lua } } provide-module lua %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/lua regions add-highlighter shared/lua/code default-region group add-highlighter shared/lua/raw_string region -match-capture '\[(=*)\[' '\](=*)\]' fill string add-highlighter shared/lua/raw_comment region -match-capture '--\[(=*)\[' '\](=*)\]' fill comment add-highlighter shared/lua/double_string region '"' (?=?|\.\.|\.\.\.|#) 0:operator add-highlighter shared/lua/code/builtin regex \b(_G|_E)\b 0:builtin add-highlighter shared/lua/code/module regex \b(_G|_E)\b 0:module add-highlighter shared/lua/code/attribute regex \b(local)\b 0:attribute add-highlighter shared/lua/code/function_declaration regex \b(?:function\h+)(?:\w+\h*\.\h*)*([a-zA-Z_]\w*)\( 1:function add-highlighter shared/lua/code/function_call regex \b([a-zA-Z_]\w*)\h*(?=[\(\{]) 1:function # Commands # ‾‾‾‾‾‾‾‾ define-command lua-alternative-file -docstring 'Jump to the alternate file (implementation ↔ test)' %{ evaluate-commands %sh{ case $kak_buffile in *spec/*_spec.lua) altfile=$(eval printf %s\\n $(printf %s\\n $kak_buffile | sed s+spec/+'*'/+';'s/_spec//)) [ ! -f $altfile ] && echo "fail 'implementation file not found'" && exit ;; *.lua) altfile="" altdir="" path=$kak_buffile dirs=$(while [ $path ]; do printf %s\\n $path; path=${path%/*}; done | tail -n +2) for dir in $dirs; do altdir=$dir/spec if [ -d $altdir ]; then altfile=$altdir/$(realpath $kak_buffile --relative-to $dir | sed s+[^/]'*'/++';'s/.lua$/_spec.lua/) break fi done [ ! -d "$altdir" ] && echo "fail 'spec/ not found'" && exit ;; *) echo "fail 'alternative file not found'" && exit ;; esac printf %s\\n "edit $altfile" }} define-command -hidden lua-trim-indent %{ # remove trailing whitespaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden lua-indent-on-char %{ evaluate-commands -no-hooks -draft -itersel %{ # align middle and end structures to start and indent when necessary, elseif is already covered by else try %{ execute-keys -draft ^\h*(else)$^\h*(if)s\A|.\z) } try %{ execute-keys -draft ^\h*(end)$^\h*(for|function|if|while)s\A|.\z) } } } define-command -hidden lua-indent-on-new-line %{ evaluate-commands -no-hooks -draft -itersel %{ # preserve previous non-empty line indent try %{ execute-keys -draft ^[^\n]+$s\A|.\z) } # remove trailing white spaces from previous line try %{ execute-keys -draft ks\h+$d } # indent after start structure try %{ execute-keys -draft ^[^\n]*\w+[^\n]*$^\h*(else|elseif|for|function|if|while)\b } } } define-command -hidden lua-insert-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # copy -- comment prefix and following white spaces try %{ execute-keys -draft ks^\h*\K--\h*yghjP } # wisely add end structure evaluate-commands -save-regs x %[ try %{ execute-keys -draft ks^\h+"xy } catch %{ reg x '' } # Save previous line indent in register x try %[ execute-keys -draft k ^x(for|function|if|while) J}iJ ^x(else|end|elseif)$ # Validate previous line and that it is not closed yet execute-keys -draft oxend ] # auto insert end ] ] ] ] kakoune-2020.09.01/rc/filetype/mail.kak000066400000000000000000000012211372342214000173730ustar00rootroot00000000000000hook global BufCreate .+\.eml %{ set-option buffer filetype mail } hook global WinSetOption filetype=mail %{ require-module mail } hook -group mail-highlight global WinSetOption filetype=mail %{ add-highlighter window/mail ref mail hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/mail } } provide-module mail %{ add-highlighter shared/mail group add-highlighter shared/mail/ regex ^(From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To|References|Date):([^\n]*(?:\n\h+[^\n]+)*)$ 1:keyword 2:attribute add-highlighter shared/mail/ regex <[^@>]+@.*?> 0:string add-highlighter shared/mail/ regex ^>.*?$ 0:comment } kakoune-2020.09.01/rc/filetype/makefile.kak000066400000000000000000000043341372342214000202360ustar00rootroot00000000000000# Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*(/?[mM]akefile|\.mk|\.make) %{ set-option buffer filetype makefile } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=makefile %{ require-module makefile set-option window static_words %opt{makefile_static_words} hook window InsertChar \n -group makefile-indent makefile-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window makefile-.+ } } hook -group makefile-highlight global WinSetOption filetype=makefile %{ add-highlighter window/makefile ref makefile hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/makefile } } provide-module makefile %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/makefile regions add-highlighter shared/makefile/content default-region group add-highlighter shared/makefile/comment region (?K } ## If the line above is a target indent with a tab try %{ execute-keys -draft Z k ^\S.*?(::|:|!)\s z i } # cleanup trailing white space son previous line try %{ execute-keys -draft k s \h+$ d } # indent after some keywords try %{ execute-keys -draft Z k ^\h*(ifeq|ifneq|ifdef|ifndef|else|define)\b z } } } } kakoune-2020.09.01/rc/filetype/markdown.kak000066400000000000000000000105751372342214000203070ustar00rootroot00000000000000# http://daringfireball.net/projects/markdown # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](markdown|md|mkd) %{ set-option buffer filetype markdown } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=markdown %{ require-module markdown hook window InsertChar \n -group markdown-indent markdown-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window markdown-.+ } } hook -group markdown-load-languages global WinSetOption filetype=markdown %{ hook -group markdown-load-languages window NormalIdle .* markdown-load-languages hook -group markdown-load-languages window InsertIdle .* markdown-load-languages } hook -group markdown-highlight global WinSetOption filetype=markdown %{ add-highlighter window/markdown ref markdown hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/markdown } } provide-module markdown %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/markdown regions add-highlighter shared/markdown/inline default-region regions add-highlighter shared/markdown/inline/text default-region group evaluate-commands %sh{ languages=" awk c cabal clojure coffee cpp css cucumber d diff dockerfile fish gas go haml haskell html ini java javascript json julia kak kickstart latex lisp lua makefile markdown moon objc perl pug python ragel ruby rust sass scala scss sh swift toml tupfile typescript yaml sql " for lang in ${languages}; do printf 'add-highlighter shared/markdown/%s region -match-capture ^(\h*)```\h*%s\\b ^(\h*)``` regions\n' "${lang}" "${lang}" printf 'add-highlighter shared/markdown/%s/ default-region fill meta\n' "${lang}" [ "${lang}" = kak ] && ref=kakrc || ref="${lang}" printf 'add-highlighter shared/markdown/%s/inner region \A```[^\\n]*\K (?=```) ref %s\n' "${lang}" "${ref}" done } add-highlighter shared/markdown/codeblock region -match-capture \ ^(\h*)```\h* \ ^(\h*)```\h*$ \ fill meta add-highlighter shared/markdown/listblock region ^\h*[-*]\s ^\h*((?=[-*])|$) regions add-highlighter shared/markdown/listblock/marker region \A [-*]\s fill bullet add-highlighter shared/markdown/listblock/content default-region ref markdown/inline add-highlighter shared/markdown/inline/code region -match-capture (`+) (`+) fill mono # Setext-style header add-highlighter shared/markdown/inline/text/ regex (\A|^\n)[^\n]+\n={2,}\h*\n\h*$ 0:title add-highlighter shared/markdown/inline/text/ regex (\A|^\n)[^\n]+\n-{2,}\h*\n\h*$ 0:header # Atx-style header add-highlighter shared/markdown/inline/text/ regex ^#[^\n]* 0:header add-highlighter shared/markdown/inline/text/ regex (? 0:link add-highlighter shared/markdown/inline/text/ regex ^\[[^\]\n]*\]:\h*([^\n]*) 1:link add-highlighter shared/markdown/inline/text/ regex ^\h*(>\h*)+ 0:comment add-highlighter shared/markdown/inline/text/ regex "\H( {2,})$" 1:+r@meta # Inline code add-highlighter shared/markdown/inline/text/ regex "^ [^\n]*" 0:meta # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden markdown-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # copy block quote(s), list item prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # remove trailing white spaces try %{ execute-keys -draft -itersel %{ k s \h+$ d } } } } define-command -hidden markdown-load-languages %{ evaluate-commands -draft %{ try %{ execute-keys 'gtGbGls```\h*\K[^\s]+' evaluate-commands -itersel %{ require-module %val{selection} } }} } } kakoune-2020.09.01/rc/filetype/mercurial.kak000066400000000000000000000015031372342214000204370ustar00rootroot00000000000000# https://www.mercurial-scm.org/ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*hg-editor-\w+\.txt$ %{ set-option buffer filetype hg-commit } hook global WinSetOption filetype=hg-commit %{ require-module hg-commit } hook -group hg-commit-highlight global WinSetOption filetype=hg-commit %{ add-highlighter window/hg-commit ref hg-commit hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/hg-commit-highlight } } provide-module hg-commit %{ # Faces # ‾‾‾‾‾ set-face global MercurialCommitComment cyan # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/hg-commit group add-highlighter shared/hg-commit/ regex '^HG:[^\n]*' 0:comment } kakoune-2020.09.01/rc/filetype/meson.kak000066400000000000000000000043361372342214000176040ustar00rootroot00000000000000# meson syntax highlighting for kakoune (https://mesonbuild.com) # # For reference see: # https://mesonbuild.com/Syntax.html # https://github.com/mesonbuild/meson/blob/master/data/syntax-highlighting/vim/syntax/meson.vim ## Detection hook global BufCreate (.*/|^)(meson\.build|meson_options\.txt) %{ set-option buffer filetype meson } ## Initialization hook -group meson-highlight global WinSetOption filetype=meson %{ require-module meson add-highlighter window/meson ref meson hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/meson } } provide-module meson %§ ## Highlighters add-highlighter shared/meson regions add-highlighter shared/meson/code default-region group add-highlighter shared/meson/comment region '(\h|^)#' '$' fill comment # TODO: highlight escape sequences within strings add-highlighter shared/meson/string_multiline region "'''" "'''" fill string add-highlighter shared/meson/string_single region "'" (?|\?|:)' 0:operator add-highlighter shared/meson/code/ regex '\b(?:and|not|or|in)\b' 0:operator # functions add-highlighter shared/meson/code/ regex "(?:add_global_arguments|add_global_link_arguments|add_languages|add_project_arguments|add_project_link_arguments|add_test_setup|alias_target|assert|benchmark|both_libraries|build_machine|build_target|configuration_data|configure_file|custom_target|declare_dependency|dependency|disabler|environment|error|executable|files|find_library|find_program|generator|get_option|get_variable|gettext|host_machine|import|include_directories|install_data|install_headers|install_man|install_subdir|is_disabler|is_variable|jar|join_paths|library|meson|message|option|project|run_command|run_target|set_variable|shared_library|shared_module|static_library|subdir|subdir_done|subproject|summary|target_machine|test|vcs_tag|warning)\b" 0:function § kakoune-2020.09.01/rc/filetype/mlb.kak000066400000000000000000000032771372342214000172400ustar00rootroot00000000000000# http://mlton.org/MLBasis # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.mlb %{ set-option buffer filetype mlb } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=mlb %{ require-module mlb set-option buffer extra_word_chars '_' '-' '.' set-option window static_words %opt{mlb_static_words} } hook -group mlb-highlight global WinSetOption filetype=mlb %{ add-highlighter window/mlb ref mlb hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/mlb } } provide-module mlb %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/mlb regions add-highlighter shared/mlb/code default-region group add-highlighter shared/mlb/string region '"' '(? # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } } define-command -hidden moon-indent-on-char %{ evaluate-commands -draft -itersel %{ # align _else_ statements to start try %{ execute-keys -draft ^ \h * (else(if)?) $ ^ \h * (if|unless|when) s \A | \z ) } # align _when_ to _switch_ then indent try %{ execute-keys -draft ^ \h * (when) $ ^ \h * (switch) s \A | \z ) ) } # align _catch_ and _finally_ to _try_ try %{ execute-keys -draft ^ \h * (catch|finally) $ ^ \h * (try) s \A | \z ) } } } define-command -hidden moon-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comment prefix and following white spaces try %{ execute-keys -draft k s ^ \h * \K -- \h * y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : moon-trim-indent } # indent after start structure try %{ execute-keys -draft k ^ \h * (class|else(if)?|for|if|switch|unless|when|while|with) \b | ([:=]|[-=]>) $ j } # deindent after return statements try %{ execute-keys -draft k ^ \h * (break|return) \b j } } } ] kakoune-2020.09.01/rc/filetype/nim.kak000066400000000000000000000121351372342214000172420ustar00rootroot00000000000000# https://nim-lang.org/ # # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.nim(s|ble)? %{ set-option buffer filetype nim } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=nim %{ require-module nim set-option window static_words %opt{nim_static_words} hook window InsertChar \n -group nim-indent nim-indent-on-new-line # cleanup trailing whitespaces on current line insert end hook window ModeChange pop:insert:.* -group nim-trim-indent %{ try %{ exec -draft s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window nim-.+ } } hook -group nim-highlight global WinSetOption filetype=nim %{ add-highlighter window/nim ref nim hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/nim } } provide-module nim %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/nim regions add-highlighter shared/nim/code default-region group add-highlighter shared/nim/triple_string region '([A-Za-z](_?\w)*)?"""' '"""(?!")' fill string add-highlighter shared/nim/raw_string region [A-Za-z](_?[A-Za-z])*" (?@$~&%|!?^.:\\*]' opnocol='[=+-/<>@$~&%|!?^.\\*]' suffix="('?([iIuU](8|16|32|64)|[fF](32|64)?|[dDuU]|[fF]))?" floatsuffix="('?([fF](32|64)?|[dD]|[fF]))?" hexdigit='[0-9a-fA-F]' octdigit='[0-7]' bindigit='[01]' hexlit="0[xX]${hexdigit}(_?${hexdigit})*" declit="\d(_?\d)*" octlit="0o${octdigit}(_?${octdigit})*" binlit="0[bB]${bindigit}(_?${bindigit})*" intlit="\b(${declit}|${hexlit}|${octlit}|${binlit})${suffix}\b" exponent="([eE][+-]?${declit})" floatlit="\b${declit}(\.${declit}${exponent}?|${exponent})${floatsuffix}\b" keywords="addr asm bind block break case cast concept const continue converter defer discard distinct do elif else end enum except export finally for func if import include interface iterator let macro method mixin nil out proc ptr raise ref return static template try type unsafeAddr using var when while yield with without atomic generic" operators="or xor and is isnot in notin of div mod shl shr not as from" types="int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float float32 float64 bool char object seq array cstring string tuple varargs typedesc pointer byte set typed untyped void auto" values="false true on off" join() { sep=$2; set -- $1; IFS="$sep"; echo "$*"; } static_words="$(join "${keywords} ${types} ${operator} ${values}" ' ')" # Add the language's grammar to the static completion list printf %s\\n "declare-option str-list nim_static_words ${static_words}" keywords="$(join "${keywords}" '|')" operators="$(join "${operators}" '|')" types="$(join "${types}" '|')" values="$(join "${values}" '|')" # Highlight keywords printf %s " add-highlighter shared/nim/code/ regex ${opchars}+ 0:operator add-highlighter shared/nim/code/ regex (? s ^\h*#\h* y jgh P } # preserve previous line indent try %{ exec -draft K } # cleanup trailing whitespaces from previous line try %{ exec -draft k s \h+$ d } # indent after line ending with enum, tuple, object, type, import, export, const, let, var, ':' or '=' try %{ exec -draft k (:|=|\b(?:enum|tuple|object|const|let|var|import|export|type))$ j } } } } kakoune-2020.09.01/rc/filetype/nix.kak000066400000000000000000000122761372342214000172630ustar00rootroot00000000000000# Nix package manager language # https://nixos.org/nix/manual/ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](nix) %{ set-option buffer filetype nix } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=nix %{ require-module nix hook window ModeChange pop:insert:.* -group nix-trim-indent nix-trim-indent hook window InsertChar .* -group nix-indent nix-indent-on-char hook window InsertChar \n -group nix-indent nix-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window nix-.+ } } hook -group nix-highlight global WinSetOption filetype=nix %{ add-highlighter window/nix ref nix hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/nix } } provide-module nix %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/nix regions add-highlighter shared/nix/code default-region group # Define strings. They can contain interpolated nix code, # which itself can contain strings. # Note that we currently cannot properly support nesting of the same-delimiter strings # because of https://github.com/mawww/kakoune/issues/1670 add-highlighter shared/nix/double_string region '"' (?]=?\??' 0:operator add-highlighter shared/nix/code/ regex '(==|!=)' 0:operator add-highlighter shared/nix/code/ regex '(&&|\|\|)' 0:operator add-highlighter shared/nix/code/ regex '->' 0:operator add-highlighter shared/nix/code/ regex \bor\b 0:operator # override any operators matched before # path: add-highlighter shared/nix/code/ regex '\s\(*(\.?\.?/[-A-Za-z0-9/_+.]+)[;?]?' 1:meta # imported path: add-highlighter shared/nix/code/ regex <[-A-Za-z0-9/_+.]+> 0:meta # RFC 2396 URIs can be used without quoting. Strangely, "string" ends URL but ''indented'' one doesn't # List of prohibited characters was tested manually in nix-repl as it is not properly documented. add-highlighter shared/nix/code/ regex '([^:/?#\s]+):([^#(){}\[\]";`|\s\\]+)' 0:string # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden nix-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden nix-indent-on-char %< evaluate-commands -draft -itersel %< # align closer token to its opener when alone on a line try %/ execute-keys -draft ^\h+[\]}]$ m s \A|.\z 1 / > > define-command -hidden nix-indent-on-new-line %< evaluate-commands -draft -itersel %< # copy // comments prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : nix-trim-indent } # indent after lines beginning / ending with opener token try %_ execute-keys -draft k ^\h*[[{]|[[{]$ j _ # deindent closer token(s) when after cursor try %_ execute-keys -draft ^\h*[}\]] gh / [}\]] m 1 _ > > § kakoune-2020.09.01/rc/filetype/ocaml.kak000066400000000000000000000070221372342214000175510ustar00rootroot00000000000000# http://ocaml.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.mli? %{ set-option buffer filetype ocaml } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=ocaml %{ require-module ocaml set-option window static_words %opt{ocaml_static_words} } hook -group ocaml-highlight global WinSetOption filetype=ocaml %{ add-highlighter window/ocaml ref ocaml hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ocaml } } provide-module ocaml %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/ocaml regions add-highlighter shared/ocaml/code default-region group add-highlighter shared/ocaml/string region (?/?]+ 0:operator # Macro # ‾‾‾‾‾ evaluate-commands %sh{ keywords="and|as|asr|assert|begin|class|constraint|do|done|downto|else|end|exception|external|false" keywords="${keywords}|for|fun|function|functor|if|in|include|inherit|initializer|land|lazy|let|lor" keywords="${keywords}|lsl|lsr|lxor|match|method|mod|module|mutable|new|nonrec|object|of|open|or" keywords="${keywords}|private|rec|sig|struct|then|to|true|try|type|val|virtual|when|while|with" printf %s\\n "declare-option str-list ocaml_static_words ${keywords}" | tr '|' ' ' # must be put at last, since we have highlighted some keywords ('type' in 'module type') to other things printf %s " add-highlighter shared/ocaml/code/ regex \b(${keywords})\b 0:keyword " } } kakoune-2020.09.01/rc/filetype/perl.kak000066400000000000000000000207301372342214000174210ustar00rootroot00000000000000# https://www.perl.org/ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.(t|p[lm])$ %{ set-option buffer filetype perl } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=perl %{ require-module perl set-option window static_words %opt{perl_static_words} # cleanup trailing whitespaces when exiting insert mode hook window ModeChange pop:insert:.* -group perl-trim-indent %{ try %{ execute-keys -draft s^\h+$d } } hook window InsertChar \n -group perl-indent perl-indent-on-new-line hook window InsertChar \{ -group perl-indent perl-indent-on-opening-curly-brace hook window InsertChar \} -group perl-indent perl-indent-on-closing-curly-brace hook -once -always window WinSetOption filetype=.* %{ remove-hooks window perl-.+ } } hook -group perl-highlight global WinSetOption filetype=perl %{ add-highlighter window/perl ref perl hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/perl } } provide-module perl %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/perl regions add-highlighter shared/perl/code default-region group add-highlighter shared/perl/command region (?|\$\?|\$@|\$\[|\$\\|\$\]|\$\^|\$\||\$~|%!|@\+|@-|@_} 0:value add-highlighter shared/perl/code/ regex (%ENV|%INC|%OVERLOAD|%SIG|@ARGV|@INC|@LAST_MATCH_START) 0:value add-highlighter shared/perl/code/ regex %{%\^(H)\b} 0:value add-highlighter shared/perl/code/ regex \$\^(S|T|V|W|X|A|C|D|E|F|H|I|L|M|N|O|P|R)\b 0:value add-highlighter shared/perl/code/ regex \$\^(RE_TRIE_MAXBUF|TAINT|UNICODE|UTF8LOCALE|WARNING_BITS|WIDE_SYSTEM_CALLS|CHILD_ERROR_NATIVE|ENCODING|OPEN|RE_DEBUG_FLAGS)\b 0:value add-highlighter shared/perl/code/ regex \$[0-9]+ 0:attribute add-highlighter shared/perl/code/ regex \b-(B|b|C|c|d|e|f|g|k|l|M|O|o|p|r|R|S|s|T|t|u|w|W|X|x|z)\b 0:attribute add-highlighter shared/perl/code/ regex \$[a-zA-Z_][a-zA-Z0-9_]* 0:variable add-highlighter shared/perl/code/ regex \$(a|b|LAST_REGEXP_CODE_RESULT|LIST_SEPARATOR|MATCH|MULTILINE_MATCHING|NR|OFMT|OFS|ORS|OS_ERROR|OSNAME|OUTPUT_AUTO_FLUSH|OUTPUT_FIELD_SEPARATOR|OUTPUT_RECORD_SEPARATOR)\b 0:value add-highlighter shared/perl/code/ regex \$(LAST_REGEXP_CODE_RESULT|LIST_SEPARATOR|MATCH|MULTILINE_MATCHING|NR|OFMT|OFS|ORS|OS_ERROR|OSNAME|OUTPUT_AUTO_FLUSH|OUTPUT_FIELD_SEPARATOR|OUTPUT_RECORD_SEPARATOR|PERL_VERSION|ACCUMULATOR|PERLDB|ARG|PID|ARGV|POSTMATCH|PREMATCH|BASETIME|PROCESS_ID|CHILD_ERROR|PROGRAM_NAME|COMPILING|REAL_GROUP_ID|DEBUGGING|REAL_USER_ID|EFFECTIVE_GROUP_ID|RS|EFFECTIVE_USER_ID|SUBSCRIPT_SEPARATOR|EGID|SUBSEP|ERRNO|SYSTEM_FD_MAX|EUID|UID|EVAL_ERROR|WARNING|EXCEPTIONS_BEING_CAUGHT|EXECUTABLE_NAME|EXTENDED_OS_ERROR|FORMAT_FORMFEED|FORMAT_LINE_BREAK_CHARACTERS|FORMAT_LINES_LEFT|FORMAT_LINES_PER_PAGE|FORMAT_NAME|FORMAT_PAGE_NUMBER|FORMAT_TOP_NAME|GID|INPLACE_EDIT|INPUT_LINE_NUMBER|INPUT_RECORD_SEPARATOR|LAST_MATCH_END|LAST_PAREN_MATCH)\b 0:value # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden perl-indent-on-new-line %~ evaluate-commands -draft -itersel %= # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with { or ( try %[ execute-keys -draft k [{(]\h*$ j ] # cleanup trailing white spaces on the previous line try %{ execute-keys -draft k s \h+$ d } # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # copy # comments prefix try %{ execute-keys -draft k s ^\h*\K# yP } # indent after a switch's case/default statements try %[ execute-keys -draft k ^\h*(case|default).*:$ j ] # indent after if|else|while|for try %[ execute-keys -draft )MB \A(if|else|while|for)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] # deindent closing brace(s) when after cursor try %[ execute-keys -draft ^\h*[})] gh / [})] m 1 ] = ~ define-command -hidden perl-indent-on-opening-curly-brace %[ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft -itersel h)M \A\(.*\)\h*\n\h*\{) s \A|.\z 1 ] ] define-command -hidden perl-indent-on-closing-curly-brace %[ # align to opening curly brace when alone on a line try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] § kakoune-2020.09.01/rc/filetype/php.kak000066400000000000000000000111361372342214000172460ustar00rootroot00000000000000# Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](php) %{ set-option buffer filetype php } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=php %{ require-module php hook window ModeChange pop:insert:.* -group php-trim-indent php-trim-indent hook window InsertChar .* -group php-indent php-indent-on-char hook window InsertChar \n -group php-indent php-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window php-.+ } } hook -group php-highlight global WinSetOption filetype=php %{ add-highlighter window/php-file ref php-file hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/php-file } } provide-module php %§ require-module html # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/php regions add-highlighter shared/php/code default-region group add-highlighter shared/php/double_string region '"' (?' 0:meta add-highlighter shared/php/double_string/ fill string add-highlighter shared/php/double_string/ regex (?\w+)* 0:variable add-highlighter shared/php/double_string/ regex \{(?\w+)*\} 0:variable # Highlight doc comments add-highlighter shared/php/doc_comment/ fill string add-highlighter shared/php/doc_comment/ regex '`.*`' 0:module add-highlighter shared/php/doc_comment/ regex '@\w+' 0:meta # Keywords are collected at # http://php.net/manual/en/reserved.keywords.php add-highlighter shared/php/code/ regex \b(__halt_compiler|abstract|and|array|as|break|callable|case|catch|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|final|finally|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|new|or|print|private|protected|public|require|require_once|return|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__CLASS__|__DIR__|__FILE__|__FUNCTION__|__LINE__|__METHOD__|__NAMESPACE__|__TRAIT__)\b 0:keyword # Highlighter for html with php tags in it, i.e. the structure of conventional php files add-highlighter shared/php-file regions add-highlighter shared/php-file/html default-region ref html add-highlighter shared/php-file/php region '<\?(php)?' '\?>' ref php # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden php-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden php-indent-on-char %< evaluate-commands -draft -itersel %< # align closer token to its opener when alone on a line try %/ execute-keys -draft ^\h+[\]}]$ m s \A|.\z 1 / > > define-command -hidden php-indent-on-new-line %< evaluate-commands -draft -itersel %< # copy // comments or docblock * prefix and following white spaces try %{ execute-keys -draft s [^/] k s ^\h*\K(?://|[*][^/])\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : php-trim-indent } # indent after lines beginning / ending with opener token try %_ execute-keys -draft k ^\h*[[{]|[[{]$ j _ # append " * " on lines starting a multiline /** or /* comment try %{ execute-keys -draft k s ^\h*/[*][* ]? j gi i * } # deindent closer token(s) when after cursor try %_ execute-keys -draft ^\h*[})] gh / [})] m 1 _ > > § kakoune-2020.09.01/rc/filetype/pony.kak000066400000000000000000000076271372342214000174560ustar00rootroot00000000000000# http://ponylang.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](pony) %{ set-option buffer filetype pony } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=pony %{ require-module pony set-option window static_words %opt{pony_static_words} hook window InsertChar \n -group pony-indent pony-indent-on-new-line # cleanup trailing whitespaces on current line insert end hook window ModeChange pop:insert:.* -group pony-trim-indent %{ try %{ execute-keys -draft s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pony-.+ } } hook -group pony-highlight global WinSetOption filetype=pony %{ add-highlighter window/pony ref pony hook -once -always window WinSetOption filetype=.* %{ remove-highlighter pony } } provide-module pony %{ # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/pony regions add-highlighter shared/pony/code default-region group add-highlighter shared/pony/triple_string region '"""' '"""' fill string add-highlighter shared/pony/double_string region '"' (?' 0:type add-highlighter shared/pony/code/ regex '\b(${keywords})\b' 0:keyword add-highlighter shared/pony/code/ regex ';' 0:keyword add-highlighter shared/pony/code/ regex '^\s*|' 0:keyword add-highlighter shared/pony/code/ regex '\b(${struct})\b' 0:variable add-highlighter shared/pony/code/ regex '\b(${capabilities})\b(!|^)?' 1:builtin 2:builtin " # Highlight types and attributes printf %s " add-highlighter shared/pony/code/ regex '@[\w_]+\b' 0:attribute " } # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden pony-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line try %{ execute-keys -draft k s \h+$ d } # copy '//' comment prefix and following white spaces # try %{ execute-keys -draft k x s ^\h*//\h* y jgh P } # indent after line ending with : try %{ execute-keys -draft k x (\b(?:do|try|then|else)|:|=>)$ j } # else, end are always de-indented try %{ execute-keys -draft k x \b(else|end):$ k x s ^\h* y j x ^" J } } } } kakoune-2020.09.01/rc/filetype/protobuf.kak000066400000000000000000000072011372342214000203150ustar00rootroot00000000000000# https://developers.google.com/protocol-buffers/ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.proto$ %{ set-option buffer filetype protobuf } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=protobuf %[ require-module protobuf set-option window static_words %opt{protobuf_static_words} hook -group protobuf-indent window InsertChar \n protobuf-indent-on-newline hook -group protobuf-indent window InsertChar \{ protobuf-indent-on-opening-curly-brace hook -group protobuf-indent window InsertChar \} protobuf-indent-on-closing-curly-brace hook -once -always window WinSetOption filetype=.* %{ remove-hooks window protobuf-.+ } ] hook -group protobuf-highlight global WinSetOption filetype=protobuf %{ add-highlighter window/protobuf ref protobuf hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/protobuf } } provide-module protobuf %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/protobuf regions add-highlighter shared/protobuf/code default-region group add-highlighter shared/protobuf/double_string region '"' (?K } # indent after lines ending with { try %[ execute-keys -draft k \{\h*$ j ] # cleanup trailing white spaces on the previous line try %{ execute-keys -draft k s \h+$ d } # copy // comments prefix try %{ execute-keys -draft k s ^\h*\K/{2,}(\h*(?=\S))? yP } # deindent closing brace(s) when after cursor try %[ execute-keys -draft ^\h*\} gh / \} m 1 ] ] ~ define-command -hidden protobuf-indent-on-opening-curly-brace %[ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft -itersel h)M \A\(.*\)\h*\n\h*\{\z s \A|.\z 1 ] ] define-command -hidden protobuf-indent-on-closing-curly-brace %[ # align to opening curly brace when alone on a line try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] ] kakoune-2020.09.01/rc/filetype/pug.kak000066400000000000000000000072041372342214000172530ustar00rootroot00000000000000# Note: jade is changing its name to pug (https://github.com/pugjs/pug/issues/2184) # This appears to be a work in progress -- the pug-lang domain is parked, while # the jade-lang one is active. This highlighter will recognize .pug and .jade extensions, # http://jade-lang.com (will be http://pug-lang.com) # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](pug|jade) %{ set-option buffer filetype pug } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=pug %{ require-module pug hook window ModeChange pop:insert:.* -group pug-trim-indent pug-trim-indent hook window InsertChar \n -group pug-indent pug-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pug-.+ } } hook -group pug-highlight global WinSetOption filetype=pug %{ add-highlighter window/pug ref pug hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/pug } } provide-module pug %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/pug regions add-highlighter shared/pug/code default-region group add-highlighter shared/pug/text region ^\h*\|\s $ regex \h*(\|) 1:meta add-highlighter shared/pug/text2 region '^\h*([A-Za-z][A-Za-z0-9_-]*)?(#[A-Za-z][A-Za-z0-9_-]*)?((?:\.[A-Za-z][A-Za-z0-9_-]*)*)?(? s \h+$ d } } define-command -hidden pug-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : pug-trim-indent } # copy '//', '|', '-' or '(!)=' prefix and following whitespace try %{ execute-keys -draft k s ^\h*\K[/|!=-]{1,2}\h* y gh j P } # indent unless we copied something above try %{ execute-keys -draft b s \S g l } } } } kakoune-2020.09.01/rc/filetype/python.kak000066400000000000000000000207411372342214000200020ustar00rootroot00000000000000# http://python.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](py) %{ set-option buffer filetype python } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=python %{ require-module python set-option window static_words %opt{python_static_words} hook window InsertChar \n -group python-insert python-insert-on-new-line hook window InsertChar \n -group python-indent python-indent-on-new-line # cleanup trailing whitespaces on current line insert end hook window ModeChange pop:insert:.* -group python-trim-indent %{ try %{ execute-keys -draft s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window python-.+ } } hook -group python-highlight global WinSetOption filetype=python %{ add-highlighter window/python ref python hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/python } } provide-module python %§ # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/python regions add-highlighter shared/python/code default-region group add-highlighter shared/python/docstring region -match-capture ("""|''') ("""|''') regions add-highlighter shared/python/double_string region '"' (?>> \K' '\z' ref python add-highlighter shared/python/docstring/ region '\.\.\. \K' '\z' ref python evaluate-commands %sh{ # Grammar values="True False None self inf" meta="import from" # attributes and methods list based on https://docs.python.org/3/reference/datamodel.html attributes="__annotations__ __closure__ __code__ __defaults__ __dict__ __doc__ __globals__ __kwdefaults__ __module__ __name__ __qualname__" methods="__abs__ __add__ __aenter__ __aexit__ __aiter__ __and__ __anext__ __await__ __bool__ __bytes__ __call__ __complex__ __contains__ __del__ __delattr__ __delete__ __delitem__ __dir__ __divmod__ __enter__ __eq__ __exit__ __float__ __floordiv__ __format__ __ge__ __get__ __getattr__ __getattribute__ __getitem__ __gt__ __hash__ __iadd__ __iand__ __ifloordiv__ __ilshift__ __imatmul__ __imod__ __imul__ __index__ __init__ __init_subclass__ __int__ __invert__ __ior__ __ipow__ __irshift__ __isub__ __iter__ __itruediv__ __ixor__ __le__ __len__ __length_hint__ __lshift__ __lt__ __matmul__ __missing__ __mod__ __mul__ __ne__ __neg__ __new__ __or__ __pos__ __pow__ __radd__ __rand__ __rdivmod__ __repr__ __reversed__ __rfloordiv__ __rlshift__ __rmatmul__ __rmod__ __rmul__ __ror__ __round__ __rpow__ __rrshift__ __rshift__ __rsub__ __rtruediv__ __rxor__ __set__ __setattr__ __setitem__ __set_name__ __slots__ __str__ __sub__ __truediv__ __xor__" # built-in exceptions https://docs.python.org/3/library/exceptions.html exceptions="ArithmeticError AssertionError AttributeError BaseException BlockingIOError BrokenPipeError BufferError BytesWarning ChildProcessError ConnectionAbortedError ConnectionError ConnectionRefusedError ConnectionResetError DeprecationWarning EOFError Exception FileExistsError FileNotFoundError FloatingPointError FutureWarning GeneratorExit ImportError ImportWarning IndentationError IndexError InterruptedError IsADirectoryError KeyboardInterrupt KeyError LookupError MemoryError ModuleNotFoundError NameError NotADirectoryError NotImplementedError OSError OverflowError PendingDeprecationWarning PermissionError ProcessLookupError RecursionError ReferenceError ResourceWarning RuntimeError RuntimeWarning StopAsyncIteration StopIteration SyntaxError SyntaxWarning SystemError SystemExit TabError TimeoutError TypeError UnboundLocalError UnicodeDecodeError UnicodeEncodeError UnicodeError UnicodeTranslateError UnicodeWarning UserWarning ValueError Warning ZeroDivisionError" # Keyword list is collected using `keyword.kwlist` from `keyword` keywords="and as assert async await break class continue def del elif else except exec finally for global if in is lambda nonlocal not or pass print raise return try while with yield" types="bool buffer bytearray bytes complex dict file float frozenset int list long memoryview object set str tuple unicode xrange" functions="abs all any ascii bin breakpoint callable chr classmethod compile complex delattr dict dir divmod enumerate eval exec filter format frozenset getattr globals hasattr hash help hex id __import__ input isinstance issubclass iter len locals map max memoryview min next oct open ord pow print property range repr reversed round setattr slice sorted staticmethod sum super type vars zip" join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } # Add the language's grammar to the static completion list printf %s\\n "declare-option str-list python_static_words $(join "${values} ${meta} ${attributes} ${methods} ${exceptions} ${keywords} ${types} ${functions}" ' ')" # Highlight keywords printf %s " add-highlighter shared/python/code/ regex '\b($(join "${values}" '|'))\b' 0:value add-highlighter shared/python/code/ regex '\b($(join "${meta}" '|'))\b' 0:meta add-highlighter shared/python/code/ regex '\b($(join "${attributes}" '|'))\b' 0:attribute add-highlighter shared/python/code/ regex '\bdef\s+($(join "${methods}" '|'))\b' 1:function add-highlighter shared/python/code/ regex '\b($(join "${exceptions}" '|'))\b' 0:function add-highlighter shared/python/code/ regex '\b($(join "${keywords}" '|'))\b' 0:keyword add-highlighter shared/python/code/ regex '\b($(join "${functions}" '|'))\b\(' 1:builtin add-highlighter shared/python/code/ regex '\b($(join "${types}" '|'))\b' 0:type add-highlighter shared/python/code/ regex '^\h*(@[\w_.]+))' 1:attribute " } add-highlighter shared/python/code/ regex (?<=[\w\s\d\)\]'"_])(<=|<<|>>|>=|<>?|>|!=|==|\||\^|&|\+|-|\*\*?|//?|%|~) 0:operator add-highlighter shared/python/code/ regex (?<=[\w\s\d'"_])((?!]):?=(?![=])|[+*-]=) 0:builtin add-highlighter shared/python/code/ regex ^\h*(?:from|import)\h+(\S+) 1:module # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden python-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*#\h* y jgh P } } } define-command -hidden python-indent-on-new-line %< evaluate-commands -draft -itersel %< # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line try %{ execute-keys -draft k s \h+$ d } # indent after line ending with : try %{ execute-keys -draft k :$ j } # deindent closing brace/bracket when after cursor (for arrays and dictionaries) try %< execute-keys -draft ^\h*[}\]] gh / [}\]] m 1 > > > § kakoune-2020.09.01/rc/filetype/r.kak000066400000000000000000000146141372342214000167240ustar00rootroot00000000000000# http://kakoune.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate (.*/)?(\.Rprofile|.*\.[rR]) %{ set-option buffer filetype r } provide-module r %§ # Highlighters & Completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/r regions add-highlighter shared/r/code default-region group add-highlighter shared/r/double_string region '"' (?])>|<=|>=|==|!=|!|&{1,2}|\|{1,2}|~|\?) 0:operator # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden r-trim-indent %{ # remove the line if it's empty when leaving the insert mode try %{ execute-keys -draft 1s^(\h+)$ d } } define-command -hidden r-indent-on-newline %< evaluate-commands -draft -itersel %< execute-keys try %< # if previous line closed a paren (possibly followed by words and a comment), # copy indent of the opening paren line execute-keys -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?(?:#[^\n]+)?\n\z mJ 1 > catch %< # else indent new lines with the same level as the previous one execute-keys -draft K > # remove previous empty lines resulting from the automatic indent try %< execute-keys -draft k ^\h+$ Hd > # indent after an opening brace or parenthesis at end of line try %< execute-keys -draft k s[{(]\h*$ j > # indent after a statement not followed by an opening brace try %< execute-keys -draft k s\)\h*(?:#[^\n]+)?\n\z \ mB \A\b(if|for|while)\b j > try %< execute-keys -draft k s \belse\b\h*(?:#[^\n]+)?\n\z \ j > # deindent after a single line statement end try %< execute-keys -draft K \;\h*(#[^\n]+)?$ \ K s\)(\h+\w+)*\h*(#[^\n]+)?\n([^\n]*\n){2}\z \ MB \A\b(if|for|while)\b 1 > try %< execute-keys -draft K \;\h*(#[^\n]+)?$ \ K s \belse\b\h*(?:#[^\n]+)?\n([^\n]*\n){2}\z \ 1 > # align to the opening parenthesis or opening brace (whichever is first) # on a previous line if its followed by text on the same line try %< evaluate-commands -draft %< # Go to opening parenthesis and opening brace, then select the most nested one try %< execute-keys [c [({],[)}] > # Validate selection and get first and last char execute-keys \A[{(](\h*\S+)+\n "(([^"]*"){2})* '(([^']*'){2})* L # Remove possibly incorrect indent from new line which was copied from previous line try %< execute-keys -draft s\h+ d > # Now indent and align that new line with the opening parenthesis/brace execute-keys 1 & > > > > define-command -hidden r-indent-on-opening-curly-brace %[ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft -itersel h)M \A\(.*\)\h*\n\h*\{\z 1 ] ] define-command -hidden r-indent-on-closing-curly-brace %[ # align to opening curly brace when alone on a line try %[ # in case open curly brace follows a closing paren, align indent with opening paren execute-keys -itersel -draft ^\h+\}$hm )M \A\(.*\)\h\{.*\}\z 1 ] catch %[ # otherwise align with open curly brace execute-keys -itersel -draft ^\h+\}$hm1 ] catch %[] ] define-command -hidden r-insert-on-newline %[ evaluate-commands -itersel -draft %[ execute-keys try %[ evaluate-commands -draft -save-regs '/"' %[ # copy the commenting prefix execute-keys -save-regs '' k 1s^\h*(#+\h*) y try %[ # if the previous comment isn't empty, create a new one execute-keys ^\h*#+\h*$ js^\h*P ] catch %[ # if there is no text in the previous comment, remove it completely execute-keys d ] ] ] ] ] § # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook -group r-highlight global WinSetOption filetype=r %{ require-module r add-highlighter window/r ref r hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/r } } hook global WinSetOption filetype=r %~ require-module r hook window ModeChange pop:insert:.* r-trim-indent hook window InsertChar \n r-insert-on-newline hook window InsertChar \n r-indent-on-newline hook window InsertChar \{ r-indent-on-opening-curly-brace hook window InsertChar \} r-indent-on-closing-curly-brace hook -once -always window WinSetOption filetype=.* %{ remove-hooks window r-.+ } ~ kakoune-2020.09.01/rc/filetype/ragel.kak000066400000000000000000000063641372342214000175600ustar00rootroot00000000000000# http://complang.org/ragel # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # ragel.kak does not try to detect host language. # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](ragel|rl) %{ set-option buffer filetype ragel } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=ragel %{ require-module ragel hook window ModeChange pop:insert:.* -group ragel-trim-indent ragel-trim-indent hook window InsertChar .* -group ragel-indent ragel-indent-on-char hook window InsertChar \n -group ragel-indent ragel-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window ragel-.+ } } hook -group ragel-highlight global WinSetOption filetype=ragel %{ add-highlighter window/ragel ref ragel hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ragel } } provide-module ragel %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/ragel regions add-highlighter shared/ragel/code default-region group add-highlighter shared/ragel/double_string region '"' (?' 0:variable add-highlighter shared/ragel/code/ regex :=|=>|->|:>|:>>|<: 0:operator add-highlighter shared/ragel/code/ regex \b(action|alnum|alpha|any|ascii|case|cntrl|contained|context|data|digit|empty|eof|err|error|exec|export|exports|extend|fblen|fbreak|fbuf|fc|fcall|fcurs|fentry|fexec|fgoto|fhold|first_final|fnext|fpc|fret|from|fstack|ftargs|graph|import|include|init|inwhen|lerr|lower|machine|nocs|noend|noerror|nofinal|noprefix|outwhen|postpop|prepush|print|punct|range|space|start|to|upper|when|write|xdigit|zlen)\b 0:keyword # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden ragel-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden ragel-indent-on-char %< evaluate-commands -draft -itersel %< # align closer token to its opener when alone on a line try %< execute-keys -draft ^\h+[\]})]$ m s \A|.\z 1 > try %< execute-keys -draft ^\h+ [*]$ [*]$ s \A|.\z 1 > > > define-command -hidden ragel-indent-on-new-line %< evaluate-commands -draft -itersel %< # copy _#_ comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : ragel-trim-indent } # indent after lines ending with opener token try %< execute-keys -draft k [[{(*]$ j > # align closer token to its opener when after cursor try %< execute-keys -draft ^\h*[})\]] gh / [})\]] m 1 > > > § kakoune-2020.09.01/rc/filetype/restructuredtext.kak000066400000000000000000000117011372342214000221150ustar00rootroot00000000000000# Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](rst) %{ set-option buffer filetype restructuredtext } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=restructuredtext %{ require-module restructuredtext } hook -group restructuredtext-highlight global WinSetOption filetype=restructuredtext %{ add-highlighter window/restructuredtext ref restructuredtext hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/restructuredtext } } provide-module restructuredtext %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/restructuredtext regions add-highlighter shared/restructuredtext/content default-region group add-highlighter shared/restructuredtext/code region ::\h*\n ^[^\s] fill meta evaluate-commands %sh{ for ft in c cabal clojure coffee cpp css cucumber ddiff dockerfile \ fish gas go haml haskell html ini java javascript json \ julia kak kickstart latex lisp lua makefile moon objc \ perl pug python ragel ruby rust sass scala scss sh swift \ tupfile yaml; do if [ "$ft" = kak ]; then ref="kakrc"; else ref="$ft"; fi printf 'add-highlighter shared/restructuredtext/%s region %s %s ref %s\n' "$ft" '\.\.\h*'$ft'::\h*c\h*\n' '^\S' "$ref" done } # Setext-style header # Valid header characters: # # ! " $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(#{3,}\n)?[^\n]+\n(#{3,})$ 0:title add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(!{3,}\n)?[^\n]+\n(!{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)("{3,}\n)?[^\n]+\n("{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\${3,}\n)?[^\n]+\n(\${3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(%{3,}\n)?[^\n]+\n(%{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(&{3,}\n)?[^\n]+\n(&{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)('{3,}\n)?[^\n]+\n('{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\({3,}\n)?[^\n]+\n(\({3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\){3,}\n)?[^\n]+\n(\){3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\*{3,}\n)?[^\n]+\n(\*{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\+{3,}\n)?[^\n]+\n(\+{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(,{3,}\n)?[^\n]+\n(,{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(-{3,}\n)?[^\n]+\n(-{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\.{3,}\n)?[^\n]+\n(\.{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(/{3,}\n)?[^\n]+\n(/{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(:{3,}\n)?[^\n]+\n(:{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\;{3,}\n)?[^\n]+\n(\;{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(<{3,}\n)?[^\n]+\n(<{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(={3,}\n)?[^\n]+\n(={3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(>{3,}\n)?[^\n]+\n(>{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\?{3,}\n)?[^\n]+\n(\?{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(@{3,}\n)?[^\n]+\n(@{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\[{3,}\n)?[^\n]+\n(\[{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\\{3,}\n)?[^\n]+\n(\\{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\]{3,}\n)?[^\n]+\n(\]{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\^{3,}\n)?[^\n]+\n(\^{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(_{3,}\n)?[^\n]+\n(_{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(`{3,}\n)?[^\n]+\n(`{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\{{3,}\n)?[^\n]+\n(\{{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\|{3,}\n)?[^\n]+\n(\|{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(\}{3,}\n)?[^\n]+\n(\}{3,})$ 0:header add-highlighter shared/restructuredtext/content/ regex (\A|\n\n)(~{3,}\n)?[^\n]+\n(~{3,})$ 0:header # Inline markup add-highlighter shared/restructuredtext/content/ regex [^*](\*\*([^\s*]|([^\s*][^*]*[^\s*]))\*\*)[^*] 1:+b add-highlighter shared/restructuredtext/content/ regex [^*](\*([^\s*]|([^\s*][^*]*[^\s*]))\*)[^*] 1:+i add-highlighter shared/restructuredtext/content/ regex [^`](``([^\s`]|([^\s`][^`]*[^\s`]))``)[^`] 1:mono } kakoune-2020.09.01/rc/filetype/ruby.kak000066400000000000000000000243241372342214000174430ustar00rootroot00000000000000# http://ruby-lang.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*(([.](rb))|(irbrc)|(pryrc)|(Brewfile)|(Capfile|[.]cap)|(Gemfile|[.]gemspec)|(Guardfile)|(Rakefile|[.]rake)|(Thorfile|[.]thor)|(Vagrantfile)) %{ set-option buffer filetype ruby } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=ruby %{ require-module ruby set-option window static_words %opt{ruby_static_words} hook window InsertChar .* -group ruby-indent ruby-indent-on-char hook window InsertChar \n -group ruby-indent ruby-indent-on-new-line hook window InsertChar \n -group ruby-insert ruby-insert-on-new-line alias window alt ruby-alternative-file hook -once -always window WinSetOption filetype=.* %{ remove-hooks window ruby-.+ unalias window alt ruby-alternative-file } } hook -group ruby-highlight global WinSetOption filetype=ruby %{ add-highlighter window/ruby ref ruby hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ruby } } provide-module ruby %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/ruby regions add-highlighter shared/ruby/code default-region group add-highlighter shared/ruby/double_symbol region ':"' (? fill string add-highlighter shared/ruby/ region -recurse \( '%[isIS]\(' \) fill variable add-highlighter shared/ruby/ region -recurse \{ '%[isIS]\{' \} fill variable add-highlighter shared/ruby/ region -recurse \[ '%[isIS]\[' \] fill variable add-highlighter shared/ruby/ region -recurse < '%[isIS]<' > fill variable add-highlighter shared/ruby/ region -recurse \( '%[rxRX]\(' \) fill meta add-highlighter shared/ruby/ region -recurse \{ '%[rxRX]\{' \} fill meta add-highlighter shared/ruby/ region -recurse \[ '%[rxRX]\[' \] fill meta add-highlighter shared/ruby/ region -recurse < '%[rxRX]<' > fill meta add-highlighter shared/ruby/ region -match-capture '%[qwQW]?([^0-9A-Za-z\(\{\[<>\]\}\)])' ([^0-9A-Za-z\(\{\[<>\]\}\)]) fill string add-highlighter shared/ruby/ region -match-capture '%[isIS]([^0-9A-Za-z\(\{\[<>\]\}\)])' ([^0-9A-Za-z\(\{\[<>\]\}\)]) fill variable add-highlighter shared/ruby/ region -match-capture '%[rxRX]([^0-9A-Za-z\(\{\[<>\]\}\)])' ([^0-9A-Za-z\(\{\[<>\]\}\)]) fill meta add-highlighter shared/ruby/heredoc region '<<[-~]?(?!self)(\w+)' '^\h*(\w+)$' fill string add-highlighter shared/ruby/division region '[\w\)\]]\K(/|(\h+/\h+))' '\w' group # Help Kakoune to better detect /…/ literals # Regular expression flags are: i → ignore case, m → multi-lines, o → only interpolate #{} blocks once, x → extended mode (ignore white spaces) # Literals are: i → array of symbols, q → string, r → regular expression, s → symbol, w → array of words, x → capture shell result add-highlighter shared/ruby/double_string/ default-region fill string add-highlighter shared/ruby/double_string/interpolation region -recurse \{ \Q#{ \} fill meta add-highlighter shared/ruby/double_symbol/ default-region fill variable add-highlighter shared/ruby/double_symbol/interpolation region -recurse \{ \Q#{ \} fill meta add-highlighter shared/ruby/backtick/ default-region fill meta add-highlighter shared/ruby/backtick/interpolation region -recurse \{ \Q#{ \} fill meta add-highlighter shared/ruby/regex/ default-region fill meta add-highlighter shared/ruby/regex/interpolation region -recurse \{ \Q#{ \} fill meta evaluate-commands %sh{ # Grammar # Keywords are collected searching for keywords at # https://github.com/ruby/ruby/blob/trunk/parse.y keywords="alias|and|begin|break|case|class|def|defined|do|else|elsif|end" keywords="${keywords}|ensure|false|for|if|in|module|next|nil|not|or|private|protected|public|redo" keywords="${keywords}|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield" attributes="attr_reader|attr_writer|attr_accessor" values="false|true|nil" meta="require|include|extend" # Add the language's grammar to the static completion list printf %s\\n "declare-option str-list ruby_static_words ${keywords} ${attributes} ${values} ${meta}" | tr '|' ' ' # Highlight keywords printf %s " add-highlighter shared/ruby/code/ regex \b(${keywords})[^0-9A-Za-z_!?] 1:keyword add-highlighter shared/ruby/code/ regex \b(${attributes})\b 0:attribute add-highlighter shared/ruby/code/ regex \b(${values})\b 0:value add-highlighter shared/ruby/code/ regex \b(${meta})\b 0:meta " } add-highlighter shared/ruby/code/ regex \b(\w+:(?!:))|(:?(\$(-[0FIKWadilpvw]|["'`/~&+=!$*,:.\;<>?@\\])|(\$|@@?)\w+))|((?[=>]?|<((=>?)|<)?|[+\-]@?|\*\*?|===?|[/`%&!^|~]|(\w+[=?!]?)|(\[\]=?)))|([A-Z]\w*|^|\h)\K::(?=[A-Z]) 0:variable # Commands # ‾‾‾‾‾‾‾‾ define-command ruby-alternative-file -docstring 'Jump to the alternate file (implementation ↔ test)' %{ evaluate-commands %sh{ case $kak_buffile in *spec/*_spec.rb) altfile=$(eval echo $(echo $kak_buffile | sed s+spec/+'*'/+';'s/_spec//)) [ ! -f $altfile ] && echo "fail 'implementation file not found'" && exit ;; *test/*_test.rb) altfile=$(eval echo $(echo $kak_buffile | sed s+test/+'*'/+';'s/_test//)) [ ! -f $altfile ] && echo "fail 'implementation file not found'" && exit ;; *.rb) altfile="" altdir="" path=$kak_buffile dirs=$(while [ $path ]; do echo $path; path=${path%/*}; done | tail -n +2) for dir in $dirs; do altdir=$dir/spec && suffix=spec [ ! -d $altdir ] && altdir=$dir/test && suffix=test if [ -d $altdir ]; then altfile=$altdir/$(realpath $kak_buffile --relative-to $dir | sed s+[^/]'*'/++';'s/.rb$/_${suffix}.rb/) break fi done [ ! -d "$altdir" ] && echo "fail 'spec/ and test/ not found'" && exit ;; *) echo "fail 'alternative file not found'" && exit ;; esac echo "edit $altfile" }} define-command -hidden ruby-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ execute-keys # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } } define-command -hidden ruby-indent-on-char %{ evaluate-commands -no-hooks -draft -itersel %{ # align middle and end structures to start try %{ execute-keys -draft ^ \h * (else) $ i ^ \h * (if|case) 1 } try %{ execute-keys -draft ^ \h * (elsif) $ i ^ \h * (if) 1 } try %{ execute-keys -draft ^ \h * (when) $ i ^ \h * (case) 1 } try %{ execute-keys -draft ^ \h * (rescue) $ i ^ \h * (begin|def) 1 } try %{ execute-keys -draft ^ \h * (end) $ i ^ \h * (begin|case|class|def|for|if|module|unless|until|while) 1 } } } define-command -hidden ruby-indent-on-new-line %{ evaluate-commands -no-hooks -draft -itersel %{ # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : ruby-trim-indent } # indent after start structure try %{ execute-keys -draft k ^ \h * (begin|case|class|def|else|elsif|ensure|for|if|module|rescue|unless|until|when|while|.+\bdo$|.+\bdo\h\|.+(?=\|)) [^0-9A-Za-z_!?] j } } } define-command -hidden ruby-insert-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # copy _#_ comment prefix and following white spaces try %{ execute-keys -draft k s '^\h*\K#\h*' y j P } # wisely add end structure evaluate-commands -save-regs x %[ try %{ execute-keys -draft k s ^ \h + \" x y } catch %{ reg x '' } try %[ evaluate-commands -draft %[ # Check if previous line opens a block execute-keys -draft k ^x(begin|case|class|def|for|if|module|unless|until|while|.+\bdo$|.+\bdo\h\|.+(?=\|))[^0-9A-Za-z_!?] # Check that we do not already have an end for this indent level which is first set via `ruby-indent-on-new-line` hook execute-keys -draft }i J ^x(end|else|elsif|rescue|when)[^0-9A-Za-z_!?] ] execute-keys -draft oxend # insert a new line with containing end ] ] ] ] § kakoune-2020.09.01/rc/filetype/rust.kak000066400000000000000000000256501372342214000174620ustar00rootroot00000000000000# http://rust-lang.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](rust|rs) %{ set-option buffer filetype rust } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=rust %[ require-module rust hook window ModeChange pop:insert:.* -group rust-trim-indent rust-trim-indent hook window InsertChar \n -group rust-indent rust-indent-on-new-line hook window InsertChar \{ -group rust-indent rust-indent-on-opening-curly-brace hook window InsertChar [)}] -group rust-indent rust-indent-on-closing hook -once -always window WinSetOption filetype=.* %{ remove-hooks window rust-.+ } ] hook -group rust-highlight global WinSetOption filetype=rust %{ add-highlighter window/rust ref rust hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/rust } } provide-module rust %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/rust regions add-highlighter shared/rust/code default-region group add-highlighter shared/rust/string region %{(?]+?>)?\( 1:function add-highlighter shared/rust/code/variable_declaration regex (?:let\h+(?:mut\h+)?)(_?\w+) 1:variable add-highlighter shared/rust/code/macro regex \b[A-z0-9_]+! 0:meta # the number literals syntax is defined here: # https://doc.rust-lang.org/reference/tokens.html#numbers add-highlighter shared/rust/code/values regex \b(?:self|true|false|[0-9][_0-9]*(?:\.[0-9][_0-9]*|(?:\.[0-9][_0-9]*)?E[\+\-][_0-9]+)(?:f(?:32|64))?|(?:0x[_0-9a-fA-F]+|0o[_0-7]+|0b[_01]+|[0-9][_0-9]*)(?:(?:i|u|f)(?:8|16|32|64|128|size))?)\b 0:value add-highlighter shared/rust/code/attributes regex \b(?:trait|struct|enum|union|type|mut|ref|static|const|default)\b 0:attribute # the language keywords are defined here, but many of them are reserved and unused yet: # https://doc.rust-lang.org/reference/keywords.html add-highlighter shared/rust/code/keywords regex \b(?:let|as|fn|return|match|if|else|loop|for|in|while|break|continue|move|box|where|impl|dyn|pub|unsafe|async|await|mod|crate|use|extern)\b 0:keyword add-highlighter shared/rust/code/char_character regex "'([^\\]|\\(.|x[0-9a-fA-F]{2}|u\{[0-9a-fA-F]{1,6}\}))'" 0:green # TODO highlight error for unicode or single escape byte character add-highlighter shared/rust/code/byte_character regex b'([\x00-\x5B\x5D-\x7F]|\\(.|x[0-9a-fA-F]{2}))' 0:yellow add-highlighter shared/rust/code/builtin_types regex \b(?:u8|u16|u32|u64|u128|usize|i8|i16|i32|i64|i128|isize|f32|f64|bool|char|str|Self)\b 0:type add-highlighter shared/rust/code/return regex \breturn\b 0:meta # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden rust-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden rust-indent-on-new-line %~ evaluate-commands -draft -itersel %< try %{ try %[ # line comment evaluate-commands -draft -save-regs '/"' %[ # copy the commenting prefix execute-keys -save-regs '' k s ^\h*//[!/]{0,2}\h* y try %[ # if the previous comment isn't empty, create a new one execute-keys ^\h*//[!/]{0,2}$ js^\h*P ] catch %[ # TODO figure out a way to not delete empty comment in current line # if there is no space and text in the previous comment, remove it completely execute-keys s //.* d ] ] ] catch %[ # block comment # if the previous line isn't within a comment scope, break execute-keys -draft k ^(\h*/\*|\h+\*(?!/)) # find comment opening, validate it was not closed, and check its using star prefixes execute-keys -draft /\* \*/ \A\h*/\*([^\n]*\n\h*\*)*[^\n]*\n\h*.\z try %[ # if the previous line is opening the comment, insert star preceeded by space execute-keys -draft k^\h*/\* execute-keys -draft i* ] catch %[ try %[ # if the next line is a comment line insert a star execute-keys -draft j^\h+\* execute-keys -draft i* ] catch %[ try %[ # if the previous line is an empty comment line, close the comment scope execute-keys -draft k^\h+\*\h+$ 1s\*(\h*)c/ ] catch %[ # if the previous line is a non-empty comment line, add a star execute-keys -draft i* ] ] ] # trim trailing whitespace on the previous line try %[ execute-keys -draft s\h+$ d ] # align the new star with the previous one execute-keys K1s^[^*]*(\*)& ] } catch %` # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with { or ( try %[ execute-keys -draft k [{(]\h*$ j ] # indent after lines ending with [{(].+ and move first parameter to own line try %< execute-keys -draft [c[({],[)}] \A[({][^\n]+\n[^\n]*\n?\z L i > # indent lines with a standalone where try %+ execute-keys -draft k ^\h*where\h*$ j + # dedent after lines starting with . and ending with , or ; try %_ execute-keys -draft k ^\h*\..*[,]\h*$ j _ # deindent closing brace(s) when after cursor try %= execute-keys -draft ^\h*[})] gh / [})] m 1 = # todo dedent additional unmatched parenthesis # try %& execute-keys -draft k s \((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*\) l Gl s\) %sh{ # count previous selections length # printf "j $(echo $kak_selections_length | wc -w) " # } & ` # filter previous line try %{ execute-keys -draft k : rust-trim-indent } > ~ define-command -hidden rust-indent-on-opening-curly-brace %[ evaluate-commands -draft -itersel %_ # align indent with opening paren when { is entered on a new line after the closing paren try %[ execute-keys -draft h ) M \A\(.*\)\h*\n\h*\{\z s \A|.\z 1 ] # dedent standalone { after impl and related block without any { in between try %< execute-keys -draft hh impl|fn|struct|enum|union \{ ll ^\h*\{$ > _ ] define-command -hidden rust-indent-on-closing %[ evaluate-commands -draft -itersel %_ # align to opening curly brace or paren when alone on a line try %< execute-keys -draft ^\h*[)}]$ h m 1 > _ ] § kakoune-2020.09.01/rc/filetype/sass.kak000066400000000000000000000055651372342214000174410ustar00rootroot00000000000000# http://sass-lang.com # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](sass) %{ set-option buffer filetype sass } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=sass %< require-module sass hook window ModeChange pop:insert:.* -group sass-trim-indent sass-trim-indent hook window InsertChar \} -group sass-indent sass-indent-on-closing-brace hook window InsertChar \n -group sass-indent sass-indent-on-new-line set-option buffer extra_word_chars '_' '-' hook -once -always window WinSetOption filetype=.* %{ remove-hooks window sass-.+ } > hook -group sass-highlight global WinSetOption filetype=sass %{ add-highlighter window/sass ref sass hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/sass } } provide-module sass %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/sass regions add-highlighter shared/sass/code default-region group add-highlighter shared/sass/single_string region '"' (? s \h+$ d } } define-command -hidden sass-indent-on-closing-brace %< evaluate-commands -draft -itersel %< # align closing brace to same indentation as the line that the opening brace resides on try %[ execute-keys -draft ^\h+\}$ m 1 ] > > define-command -hidden sass-indent-on-new-line %< evaluate-commands -draft -itersel %< # copy '/' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K/\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : sass-trim-indent } # avoid indent after properties and comments try %{ execute-keys -draft k [:/] j } # deindent closing brace when after cursor try %[ execute-keys -draft ^\h*\} gh / \} m 1 ] > > § kakoune-2020.09.01/rc/filetype/scala.kak000066400000000000000000000066401372342214000175460ustar00rootroot00000000000000# http://scala-lang.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](scala) %{ set-option buffer filetype scala } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=scala %[ require-module scala hook window ModeChange pop:insert:.* -group scala-trim-indent scala-trim-indent hook window InsertChar \n -group scala-indent scala-indent-on-new-line hook window InsertChar \} -group scala-indent scala-indent-on-closing-curly-brace hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scala-.+ } ] hook -group scala-highlight global WinSetOption filetype=scala %{ add-highlighter window/scala ref scala hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scala } } provide-module scala %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/scala regions add-highlighter shared/scala/code default-region group add-highlighter shared/scala/string region '"' (?|<:|:>|=:=|::|&&|\|\|) 0:operator # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden scala-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden scala-indent-on-new-line %[ evaluate-commands -draft -itersel %[ # copy // comments prefix and following white spaces try %[ execute-keys -draft k s ^\h*\K#\h* y gh j P ] # preserve previous line indent try %[ execute-keys -draft K ] # filter previous line try %[ execute-keys -draft k : scala-trim-indent ] # indent after lines ending with { try %[ execute-keys -draft k \{$ j ] # deindent closing brace when after cursor try %[ execute-keys -draft ^\h*\} gh / \} m 1 ] ] ] define-command -hidden scala-indent-on-closing-curly-brace %[ evaluate-commands -draft -itersel %[ # align to opening curly brace when alone on a line try %[ execute-keys -draft ^\h+\}$ m s \A|.\z 1 ] ] ] ] kakoune-2020.09.01/rc/filetype/scheme.kak000066400000000000000000000212521372342214000177230ustar00rootroot00000000000000# http://www.scheme-reports.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate (.*/)?(.*\.(scm|ss|sld)) %{ set-option buffer filetype scheme } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=scheme %{ require-module scheme set-option window static_words %opt{scheme_static_words} set-option buffer extra_word_chars '!' '$' '%' '&' '*' '+' '-' '.' '/' ':' '<' '=' '>' '?' '@' '^' '_' '~' hook window ModeChange pop:insert:.* -group scheme-trim-indent lisp-trim-indent hook window InsertChar \n -group scheme-indent lisp-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window scheme-.+ } } hook -group scheme-highlight global WinSetOption filetype=scheme %{ add-highlighter window/scheme ref scheme hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/scheme } } provide-module scheme %{ require-module lisp # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/scheme regions add-highlighter shared/scheme/code default-region group add-highlighter shared/scheme/string region %{(? > >=", operators); # Procedures that create a base type and their predicates (for easier type checking) split("list vector bytevector cons string boolean? list? pair? vector? bytevector? "\ "string? char? complex? eof-object eof-object? input-port? null? number? "\ "output-port? port? procedure? symbol?", types); # R7RS available procedures split("abs acos angle append apply asin assoc assq assv atan boolean=? "\ "bytevector-append bytevector-copy bytevector-copy! bytevector-length "\ "bytevector-u8-ref bytevector-u8-set! caaaar caaadr caaar caadar caaddr caadr "\ "caar cadaar cadadr cadar caddar cadddr caddr cadr call-with-input-file "\ "call-with-output-file call-with-values car cdaaar cdaadr cdaar cdadar cdaddr "\ "cdadr cdar cddaar cddadr cddar cdddar cddddr cdddr cddr cdr ceiling "\ "char->integer char-alphabetic? char-ci<=? char-ci=? "\ "char-ci>? char-downcase char-foldcase char-lower-case? char-numeric? "\ "char-ready? char-upcase char-upper-case? char-whitespace? char<=? char=? char>? close-input-port close-output-port close-port cons cos "\ "current-input-port current-output-port denominator digit-value display "\ "dynamic-wind eq? equal? eqv? error error-object-irritants "\ "error-object-message error-object? eval even? exact exact->inexact "\ "exact-integer? exact-integer-sqrt exact? exp expt features file-error? "\ "finite? floor floor/ floor-quotient floor-remainder for-each force "\ "flush-output-port gcd get-output-bytevector get-output-string guard imag-part "\ "inexact->exact inexact inexact? infinite? input-port-open? integer->char "\ "integer? interaction-environment lcm length list list-copy list-set! "\ "list->string list->vector list-ref list-tail load log magnitude "\ "make-bytevector make-list make-parameter make-polar make-promise "\ "make-rectangular make-string make-vector map max member memq memv min modulo "\ "nan? negative? newline not null-environment number->string numerator odd? "\ "open-input-bytevector open-input-file open-input-string "\ "open-output-bytevector open-output-file open-output-string output-port-open? "\ "or parameterize peek-char peek-u8 positive? promise? quotient raise "\ "raise-continuable rational? rationalize read read-bytevector read-bytevector! "\ "read-char read-error? read-line read-string read-u8 real-part real? remainder "\ "reverse round scheme-report-environment set-car! set-cdr! sin square sqrt "\ "string->list string->number string->symbol string->utf8 string->vector "\ "string-append string-ci<=? string-ci=? string-ci>? "\ "string-copy string-copy! string-downcase string-fill! string-foldcase "\ "string-for-each string-length string-map string-ref string-set! string-upcase "\ "string<=? string=? string>? substring symbol=? "\ "symbol->string syntax-error tan textual-port? truncate truncate/ "\ "truncate-quotient truncate-remainder u8-ready? unless utf8->string values "\ "vector vector->list vector->string vector-append vector-copy vector-copy! "\ "vector-for-each vector-fill! vector-length vector-map vector-ref vector-set! "\ "when with-exception-handler with-input-from-file with-output-to-file write "\ "write-bytevector write-char write-string write-u8 zero?", builtins); non_word_chars="['\"\\s\\(\\)\\[\\]\\{\\};]"; normal_identifiers="-!$%&\\*\\+\\./:<=>\\?@\\^_~a-zA-Z0-9"; identifier_chars="[" normal_identifiers "][" normal_identifiers ",#]*"; } function kak_escape(s) { gsub(/'/, "''", s); return "'" s "'"; } function add_highlighter(regex, highlight) { printf("add-highlighter shared/scheme/code/ regex %s %s\n", kak_escape(regex), highlight); } function quoted_join(words, quoted, first) { first=1 for (i in words) { if (!first) { quoted=quoted "|"; } quoted=quoted "\\Q" words[i] "\\E"; first=0; } return quoted; } function add_word_highlighter(words, face, regex) { regex = "(? s \h+$ d } } # This is at best an approximation, since shell syntax is very complex. # Also note that this targets plain sh syntax, not bash - bash adds a whole # other level of complexity. If your bash code is fairly portable this will # probably work. # # Of necessity, this is also fairly opinionated about indentation styles. # Doing it "properly" would require far more context awareness than we can # bring to this kind of thing. define-command -hidden sh-insert-on-new-line %[ evaluate-commands -draft -itersel %[ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } ] ] define-command -hidden sh-indent-on-new-line %[ evaluate-commands -draft -itersel %[ # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : sh-trim-indent } # Indent loop syntax, e.g.: # for foo in bar; do # things # done # # or: # # while foo; do # things # done # # or equivalently: # # while foo # do # things # done # # indent after do try %{ execute-keys -draft k \bdo$ j } # deindent after done try %{ execute-keys -draft k \bdone$ K j j K } # Indent if/then/else syntax, e.g.: # if [ $foo = $bar ]; then # things # else # other_things # fi # # or equivalently: # if [ $foo = $bar ] # then # things # else # other_things # fi # # indent after then try %{ execute-keys -draft k \bthen$ j } # deindent after fi try %{ execute-keys -draft k \bfi$ K j j K } # deindent and reindent after else - deindent the else, then back # down and return to the previous indent level. try %{ execute-keys -draft k \belse$ j } # Indent case syntax, e.g.: # case "$foo" in # bar) thing1;; # baz) # things # ;; # *) # default_things # ;; # esac # # or equivalently: # case "$foo" # in # bar) thing1;; # esac # # indent after in try %{ execute-keys -draft k \bin$ j } # deindent after esac try %{ execute-keys -draft k \besac$ j K } # indent after ) try %{ execute-keys -draft k ^\s*\(?[^(]+[^)]\)$ j } # deindent after ;; try %{ execute-keys -draft k ^\s*\;\;$ j } # Indent compound commands as logical blocks, e.g.: # { # thing1 # thing2 # } # # or in a function definition: # foo () { # thing1 # thing2 # } # # We don't handle () delimited compond commands - these are technically very # similar, but the use cases are quite different and much less common. # # Note that in this context the '{' and '}' characters are reserved # words, and hence must be surrounded by a token separator - typically # white space (including a newline), though technically it can also be # ';'. Only vertical white space makes sense in this context, though, # since the syntax denotes a logical block, not a simple compound command. try %= execute-keys -draft k (\s|^)\{$ j = # deindent closing } try %= execute-keys -draft k ^\s*\}$ j K = # deindent closing } when after cursor try %= execute-keys -draft ^\h*\} gh / \} m 1 = ] ] ] kakoune-2020.09.01/rc/filetype/sml.kak000066400000000000000000000063571372342214000172630ustar00rootroot00000000000000# https://smlfamily.github.io # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.(sml|fun|sig) %{ set-option buffer filetype sml } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=sml %{ require-module sml set-option buffer extra_word_chars '_' "'" set-option window static_words %opt{sml_static_words} } hook -group sml-highlight global WinSetOption filetype=sml %{ add-highlighter window/sml ref sml hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/sml } } provide-module sml %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/sml regions add-highlighter shared/sml/code default-region group add-highlighter shared/sml/string region '#?"' '(?%%&$?`\\#:|]+" 0:operator # Record projection functions add-highlighter shared/sml/code/ regex "(?%%&$?`\\#:|])#([\w']+)?(?![!*/+\-~\^@=<>%%&$?`\\#:|])" 0:function # Symbolic keywords add-highlighter shared/sml/code/ regex "(?%%&$?`\\#:|])(=>|=|\*|->|:>|:|;|\.\.\.|\b_\b|\|)(?![!*/+\-~\^@=<>%%&$?`\\#:|])" 0:keyword # Type variables add-highlighter shared/sml/code/ regex "(?|<|>=|<=|<>|\+=|-=|\*=|/=|%=|&=|^-=|\|\*=' 0:operator add-highlighter shared/sql/code/ regex \bNULL\b 0:value add-highlighter shared/sql/code/ regex \b\d+(?:\.\d+)?\b 0:value } kakoune-2020.09.01/rc/filetype/swift.kak000066400000000000000000000033551372342214000176170ustar00rootroot00000000000000hook global BufCreate .*\.(swift) %{ set-option buffer filetype swift } hook global WinSetOption filetype=swift %{ require-module swift } hook -group swift-highlight global WinSetOption filetype=swift %{ add-highlighter window/swift ref swift hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/swift } } provide-module swift %{ add-highlighter shared/swift regions add-highlighter shared/swift/code default-region group add-highlighter shared/swift/string region %{(?K } ## If the line above is a project indent with a tab try %{ execute-keys -draft Z k ^\h*([^:\n]+): z i } # cleanup trailing white spaces on previous line try %{ execute-keys -draft k s \h+$ d } } } } kakoune-2020.09.01/rc/filetype/terraform.kak000066400000000000000000000107421372342214000204620ustar00rootroot00000000000000# Terraform configuration language # https://www.terraform.io/docs/configuration/ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](tf|tfvars) %{ set-option buffer filetype terraform } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=terraform %{ require-module terraform set-option window static_words %opt{terraform_static_words} hook -once -always window WinSetOption filetype=.* %{ remove-hooks window terraform-.+ } } hook -group terraform-highlight global WinSetOption filetype=terraform %{ add-highlighter window/terraform ref terraform hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/terraform } } provide-module terraform %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/terraform regions add-highlighter shared/terraform/code default-region group add-highlighter shared/terraform/comment1 region '#' '$' fill comment add-highlighter shared/terraform/comment2 region '\\' '$' fill comment add-highlighter shared/terraform/comment3 region /\* \*/ fill comment # Strings can contain interpolated terraform expressions, which can contain # strings. Currently, we cannot support nesting of the same type of delimiter, # so instead we render the full interpolation as a value (otherwise, it # looks bad). # See https://github.com/mawww/kakoune/issues/1670 add-highlighter shared/terraform/string region '"' '(? s \h+$ d } } define-command -hidden toml-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # copy comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : toml-trim-indent } } } } kakoune-2020.09.01/rc/filetype/troff.kak000066400000000000000000000022251372342214000175760ustar00rootroot00000000000000# Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.\d+ %{ set-option buffer filetype troff } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=troff %{ require-module troff } hook -group troff-highlight global WinSetOption filetype=troff %{ add-highlighter window/troff ref troff hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/troff } } provide-module troff %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/troff group add-highlighter shared/troff/ regex '\\f[A-Z]' 0:attribute add-highlighter shared/troff/ regex '\\fB(.+?)\\f[A-Z]' 1:+b add-highlighter shared/troff/ regex '\\fI(.+?)\\f[A-Z]' 1:+i add-highlighter shared/troff/ regex '^\.[a-zA-Z]{1,2}\b' 0:meta add-highlighter shared/troff/ regex '^\.TH\s+[^\n]+' 0:title add-highlighter shared/troff/ regex '^\.SH\s+[^\n]+' 0:header add-highlighter shared/troff/ regex '^\.IR\s+(\S+)' 1:+i add-highlighter shared/troff/ regex '^\.BR\s+(\S+)' 1:+b add-highlighter shared/troff/ regex '^\.I\s+([^\n]+)' 1:+i add-highlighter shared/troff/ regex '^\.B\s+([^\n]+)' 1:+b } kakoune-2020.09.01/rc/filetype/tupfile.kak000066400000000000000000000025231372342214000201270ustar00rootroot00000000000000# http://gittup.org/tup/ # # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*/?Tup(file|rules)(\.\w+)?$ %{ set-option buffer filetype tupfile } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook -group tupfile-highlight global WinSetOption filetype=tupfile %{ require-module tupfile add-highlighter window/tupfile ref tupfile hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/tupfile } } provide-module tupfile %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/tupfile regions add-highlighter shared/tupfile/code default-region group add-highlighter shared/tupfile/string region '"' (? s \h+$ d } } define-command -hidden yaml-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k s ^\h*\K#\h* y gh j P } # preserve previous line indent try %{ execute-keys -draft K } # filter previous line try %{ execute-keys -draft k : yaml-trim-indent } # indent after : try %{ execute-keys -draft k x :$ j } } } } kakoune-2020.09.01/rc/filetype/zig.kak000066400000000000000000000155051372342214000172540ustar00rootroot00000000000000# zig syntax highlighting for kakoune (https://ziglang.org) # # based off of https://github.com/ziglang/zig.vim/blob/master/syntax/zig.vim # as well as https://ziglang.org/documentation/master/#Grammar # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.]zig %{ set-option buffer filetype zig } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=zig %< require-module zig hook window ModeChange pop:insert:.* -group zig-trim-indent zig-trim-indent hook window InsertChar \n -group zig-indent zig-indent-on-new-line hook window InsertChar \} -group zig-indent zig-indent-on-closing hook -once -always window WinSetOption filetype=.* %< remove-hooks window zig-.+ > > hook -group zig-highlight global WinSetOption filetype=zig %{ require-module zig add-highlighter window/zig ref zig hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/zig } } provide-module zig %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/zig regions add-highlighter shared/zig/code default-region group add-highlighter shared/zig/doc_comment region '///[^/]' '$' fill documentation add-highlighter shared/zig/comment region '//' '$' fill comment # TODO: highlight escape sequences within strings add-highlighter shared/zig/string_double region '"' (?|&|\||\^|~|\?|!)' 0:operator # builtin functions add-highlighter shared/zig/code/ regex "@(?:addWithOverflow|ArgType|atomicLoad|atomicStore|bitCast|breakpoint)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:alignCast|alignOf|cDefine|cImport|cInclude)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:cUndef|canImplicitCast|clz|cmpxchgWeak|cmpxchgStrong|compileError)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:compileLog|ctz|popCount|divExact|divFloor|divTrunc)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:embedFile|export|tagName|TagType|errorName|call)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:errorReturnTrace|fence|fieldParentPtr|field|unionInit)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:frameAddress|import|newStackCall|asyncCall|intToPtr|IntType)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:memberCount|memberName|memberType|as)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:memcpy|memset|mod|mulWithOverflow|splat)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:bitOffsetOf|byteOffsetOf|OpaqueType|panic|ptrCast)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:ptrToInt|rem|returnAddress|setCold|Type|shuffle)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:setRuntimeSafety|setEvalBranchQuota|setFloatMode)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:setGlobalLinkage|setGlobalSection|shlExact|This|hasDecl|hasField)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:shlWithOverflow|shrExact|sizeOf|bitSizeOf|sqrt|byteSwap|subWithOverflow|intCast|floatCast|intToFloat|floatToInt|boolToInt|errSetCast)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:truncate|typeId|typeInfo|typeName|TypeOf|atomicRmw|bytesToSlice|sliceToBytes)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:intToError|errorToInt|intToEnum|enumToInt|setAlignStack|frame|Frame|frameSize|bitReverse|Vector)\b" 0:function add-highlighter shared/zig/code/ regex "@(?:sin|cos|exp|exp2|log|log2|log10|fabs|floor|ceil|trunc|round)\b" 0:function # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden zig-trim-indent %{ # delete trailing whitespace try %{ execute-keys -draft -itersel s \h+$ d } } define-command -hidden zig-indent-on-new-line %< evaluate-commands -draft -itersel %< try %< # copy // or /// comments prefix and following whitespace execute-keys -draft k s ^\h*\K///?\h* y gh j P # preserve indent level try %< execute-keys -draft K > > catch %< # preserve indent level try %< execute-keys -draft K > # indent after lines ending in { try %< execute-keys -draft k \{\h*$ j > # deindent closing } when after cursor try %< execute-keys -draft ^\h*\} gh / \} m 1 > > # filter previous line try %< execute-keys -draft k : zig-trim-indent > > > define-command -hidden zig-indent-on-closing %< # align lone } to indent level of opening line try %< execute-keys -draft -itersel ^\h*\}$ h m 1 > > § kakoune-2020.09.01/rc/tools/000077500000000000000000000000001372342214000153045ustar00rootroot00000000000000kakoune-2020.09.01/rc/tools/autorestore.kak000066400000000000000000000054361372342214000203600ustar00rootroot00000000000000declare-option -docstring "remove backups once they've been restored" \ bool autorestore_purge_restored true ## Insert the content of the backup file into the current buffer, if a suitable one is found define-command autorestore-restore-buffer -docstring "Restore the backup for the current file if it exists" %{ evaluate-commands %sh{ buffer_basename="${kak_buffile##*/}" buffer_dirname=$(dirname "${kak_buffile}") if [ -f "${kak_buffile}" ]; then newer=$(find "${buffer_dirname}"/".${buffer_basename}.kak."* -newer "${kak_buffile}" -exec ls -1t {} + 2>/dev/null | head -n 1) older=$(find "${buffer_dirname}"/".${buffer_basename}.kak."* \! -newer "${kak_buffile}" -exec ls -1t {} + 2>/dev/null | head -n 1) else # New buffers that were never written to disk. newer=$(ls -1t "${buffer_dirname}"/".${buffer_basename}.kak."* 2>/dev/null | head -n 1) older="" fi if [ -z "${newer}" ]; then if [ -n "${older}" ]; then printf %s\\n " echo -debug Old backup file(s) found: will not restore ${older} . " fi exit fi printf %s\\n " ## Replace the content of the buffer with the content of the backup file echo -debug Restoring file: ${newer} execute-keys -draft %{ %d!cat\"${newer}\"d } ## If the backup file has to be removed, issue the command once ## the current buffer has been saved ## If the autorestore_purge_restored option has been unset right after the ## buffer was restored, do not remove the backup hook -group autorestore buffer BufWritePost '${kak_buffile}' %{ nop %sh{ if [ \"\${kak_opt_autorestore_purge_restored}\" = true ]; then rm -f \"${buffer_dirname}/.${buffer_basename}.kak.\"* fi } } " } } ## Remove all the backups that have been created for the current buffer define-command autorestore-purge-backups -docstring "Remove all the backups of the current buffer" %{ evaluate-commands %sh{ [ ! -f "${kak_buffile}" ] && exit buffer_basename="${kak_bufname##*/}" buffer_dirname=$(dirname "${kak_bufname}") rm -f "${buffer_dirname}/.${buffer_basename}.kak."* printf %s\\n " echo -markup {Information}Backup files removed. " } } ## If for some reason, backup files need to be ignored define-command autorestore-disable -docstring "Disable automatic backup recovering" %{ remove-hooks global autorestore } hook -group autorestore global BufCreate .* %{ autorestore-restore-buffer } kakoune-2020.09.01/rc/tools/autowrap.kak000066400000000000000000000042621372342214000176420ustar00rootroot00000000000000declare-option -docstring "maximum amount of characters per line, after which a newline character will be inserted" \ int autowrap_column 80 declare-option -docstring %{ when enabled, paragraph formatting will reformat the whole paragraph in which characters are being inserted This can potentially break formatting of documents containing markup (e.g. markdown) } bool autowrap_format_paragraph no declare-option -docstring %{ command to which the paragraphs to wrap will be passed all occurences of '%c' are replaced with `autowrap_column` } str autowrap_fmtcmd 'fold -s -w %c' define-command -hidden autowrap-cursor %{ evaluate-commands -save-regs '/"|^@m' %{ try %{ ## if the line isn't too long, do nothing execute-keys -draft "^[^\n]{%opt{autowrap_column},}[^\n]" try %{ reg m "%val{selections_desc}" ## if we're adding characters past the limit, just wrap them around execute-keys -draft ".{%opt{autowrap_column}}\h*[^\s]*1s(\h+)[^\h]*\zc" } catch %{ ## if we're adding characters in the middle of a sentence, use ## the `fmtcmd` command to wrap the entire paragraph evaluate-commands %sh{ if [ "${kak_opt_autowrap_format_paragraph}" = true ] \ && [ -n "${kak_opt_autowrap_fmtcmd}" ]; then format_cmd=$(printf %s "${kak_opt_autowrap_fmtcmd}" \ | sed "s/%c/${kak_opt_autowrap_column}/g") printf %s " evaluate-commands -draft %{ execute-keys 'p|${format_cmd}' try %{ execute-keys s\h+$ d } } select '${kak_main_reg_m}' " fi } } } } } define-command autowrap-enable -docstring "Automatically wrap the lines in which characters are inserted" %{ hook -group autowrap window InsertChar [^\n] autowrap-cursor } define-command autowrap-disable -docstring "Disable automatic line wrapping" %{ remove-hooks window autowrap } kakoune-2020.09.01/rc/tools/clang.kak000066400000000000000000000214051372342214000170620ustar00rootroot00000000000000hook -once global BufSetOption filetype=(c|cpp) %{ require-module clang } provide-module clang %[ declare-option -docstring "options to pass to the `clang` shell command" \ str clang_options declare-option -docstring "directory from which to invoke clang" \ str clang_directory declare-option -hidden completions clang_completions declare-option -hidden line-specs clang_flags declare-option -hidden line-specs clang_errors define-command -params ..1 \ -docstring %{ Parse the contents of the current buffer The syntaxic errors detected during parsing are shown when auto-diagnostics are enabled } clang-parse %{ evaluate-commands %sh{ dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-clang.XXXXXXXX) mkfifo ${dir}/fifo printf %s\\n " evaluate-commands -no-hooks write -sync -atomic ${dir}/buf evaluate-commands -draft %{ edit! -fifo ${dir}/fifo -debug *clang-output* set-option buffer filetype make set-option buffer make_current_error_line 0 hook -once -always buffer BufCloseFifo .* %{ nop %sh{ rm -r ${dir} } } }" # this runs in a detached shell, asynchronously, so that kakoune does # not hang while clang is running. As completions references a cursor # position and a buffer timestamp, only valid completions should be # displayed. (( until [ -f ${dir}/buf ]; do :; done # wait for the buffer to be written if [ -n "$kak_opt_clang_directory" ]; then cd "$kak_opt_clang_directory" fi case ${kak_opt_filetype} in c) ft=c ;; cpp) ft=c++ ;; obj-c) ft=objective-c ;; *) ft=c++ ;; esac if [ "$1" = "-complete" ]; then pos=-:${kak_cursor_line}:${kak_cursor_column} header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}" compl=$(clang++ -x ${ft} -fsyntax-only ${kak_opt_clang_options} \ -Xclang -code-completion-brief-comments -Xclang -code-completion-at=${pos} - < ${dir}/buf 2> ${dir}/stderr | awk -F ': ' ' /^COMPLETION:/ && $2 !~ /[(,](Hidden|Inaccessible)[),]/ { candidate=$3 gsub(/[[<{]#[^#]*#[]>}]/, "", candidate) gsub(/~/, "~~", candidate) gsub(/\|/, "\\|", candidate) gsub(/[[{<]#|#[]}>]/, " ", $3) gsub(/:: /, "::", $3) gsub(/ ,/, ",", $3) gsub(/^ +| +$/, "", $3) docstring=$4 ? $3 "\n" $4 : $3 gsub(/~|!/, "&&", docstring) gsub(/\|/, "\\|", docstring) if (candidate in candidates) candidates[candidate]=candidates[candidate] "\n" docstring else candidates[candidate]=docstring } END { for (candidate in candidates) { menu=candidate gsub(/(^|[^[:alnum:]_])(operator|new|delete)($|[^{}_[:alnum:]]+)/, "{keyword}&{}", menu) gsub(/(^|[[:space:]])(int|size_t|bool|char|unsigned|signed|long)($|[[:space:]])/, "{type}&{}", menu) gsub(/[^{}_[:alnum:]]+/, "{operator}&{}", menu) printf "%%~%s|info -style menu %!%s!|%s~ ", candidate, candidates[candidate], menu } }') printf %s\\n "evaluate-commands -client ${kak_client} echo 'clang completion done' set-option 'buffer=${kak_buffile}' clang_completions ${header} ${compl}" | kak -p ${kak_session} else clang++ -x ${ft} -fsyntax-only ${kak_opt_clang_options} - < ${dir}/buf 2> ${dir}/stderr printf %s\\n "evaluate-commands -client ${kak_client} echo 'clang parsing done'" | kak -p ${kak_session} fi flags=$(cat ${dir}/stderr | sed -Ene " /^:[0-9]+:([0-9]+:)? (fatal )?error/ { s/^:([0-9]+):.*/'\1|{red}█'/; p } /^:[0-9]+:([0-9]+:)? warning/ { s/^:([0-9]+):.*/'\1|{yellow}█'/; p } " | paste -s -d ' ' -) errors=$(cat ${dir}/stderr | sed -Ene " /^:[0-9]+:([0-9]+:)? ((fatal )?error|warning)/ { s/'/''/g; s/^:([0-9]+):([0-9]+:)? (.*)/'\1|\3'/; p }" | sort -n | paste -s -d ' ' -) sed -e "s||${kak_bufname}|g" < ${dir}/stderr > ${dir}/fifo printf %s\\n "set-option 'buffer=${kak_buffile}' clang_flags ${kak_timestamp} ${flags} set-option 'buffer=${kak_buffile}' clang_errors ${kak_timestamp} ${errors}" | kak -p ${kak_session} ) & ) > /dev/null 2>&1 < /dev/null } } define-command clang-complete -docstring "Complete the current selection" %{ clang-parse -complete } define-command -hidden clang-show-completion-info %[ try %[ evaluate-commands -draft %[ execute-keys {( ^\( b \A\w+\z evaluate-commands %sh[ desc=$(printf %s\\n "${kak_opt_clang_completions}" | sed -e "{ s/\([^\\]\):/\1\n/g }" | sed -ne "/^${kak_selection}|/ { s/^[^|]\+|//; s/|.*$//; s/\\\:/:/g; p }") if [ -n "$desc" ]; then printf %s\\n "evaluate-commands -client $kak_client %{info -anchor ${kak_cursor_line}.${kak_cursor_column} -style above %{${desc}}}" fi ] ] ] ] define-command clang-enable-autocomplete -docstring "Enable automatic clang completion" %{ set-option window completers "option=clang_completions" %opt{completers} hook window -group clang-autocomplete InsertIdle .* %{ try %{ execute-keys -draft (\.|->|::).\z echo 'completing...' clang-complete } clang-show-completion-info } alias window complete clang-complete } define-command clang-disable-autocomplete -docstring "Disable automatic clang completion" %{ evaluate-commands %sh{ printf "set-option window completers %s\n" $(printf %s "${kak_opt_completers}" | sed -e "s/'option=clang_completions'//g") } remove-hooks window clang-autocomplete unalias window complete clang-complete } define-command -hidden clang-show-error-info %{ update-option buffer clang_errors # Ensure we are up to date with buffer changes evaluate-commands %sh{ eval "set -- ${kak_quoted_opt_clang_errors}" shift # skip timestamp desc=$(for error in "$@"; do if [ "${error%%|*}" = "$kak_cursor_line" ]; then printf '%s\n' "${error##*|}" fi done) if [ -n "$desc" ]; then desc=$(printf %s "${desc}" | sed "s/'/''/g") printf "info -anchor %d.%d '%s'\n" "${kak_cursor_line}" "${kak_cursor_column}" "${desc}" fi } } define-command clang-enable-diagnostics -docstring %{Activate automatic error reporting and diagnostics Information about the analysis are showned after the buffer has been parsed with the clang-parse function} \ %{ add-highlighter window/clang_flags flag-lines default clang_flags hook window -group clang-diagnostics NormalIdle .* %{ clang-show-error-info } hook window -group clang-diagnostics WinSetOption ^clang_errors=.* %{ info; clang-show-error-info } } define-command clang-disable-diagnostics -docstring "Disable automatic error reporting and diagnostics" %{ remove-highlighter window/clang_flags remove-hooks window clang-diagnostics } define-command clang-diagnostics-next -docstring "Jump to the next line that contains an error" %{ update-option buffer clang_errors # Ensure we are up to date with buffer changes evaluate-commands %sh{ eval "set -- ${kak_quoted_opt_clang_errors}" shift # skip timestamp unset line unset first_line for error in "$@"; do candidate=${error%%|*} first_line=${first_line-$candidate} if [ "$candidate" -gt $kak_cursor_line ]; then line=$candidate break fi done line=${line-$first_line} if [ -n "$line" ]; then printf %s\\n "execute-keys ${line} g" else echo "fail no next clang diagnostic" fi } } ] kakoune-2020.09.01/rc/tools/comment.kak000066400000000000000000000136351372342214000174460ustar00rootroot00000000000000# Line comments declare-option -docstring "characters inserted at the beginning of a commented line" \ str comment_line '#' # Block comments declare-option -docstring "characters inserted before a commented block" \ str comment_block_begin declare-option -docstring "characters inserted after a commented block" \ str comment_block_end # Default comments for all languages hook global BufSetOption filetype=asciidoc %{ set-option buffer comment_line '//' set-option buffer comment_block_begin '////' set-option buffer comment_block_end '////' } hook global BufSetOption filetype=(c|cpp|dart|gluon|go|java|javascript|objc|php|rust|sass|scala|scss|swift|typescript) %{ set-option buffer comment_line '//' set-option buffer comment_block_begin '/*' set-option buffer comment_block_end '*/' } hook global BufSetOption filetype=(cabal|haskell|moon|idris|elm|dhall) %{ set-option buffer comment_line '--' set-option buffer comment_block_begin '{-' set-option buffer comment_block_end '-}' } hook global BufSetOption filetype=clojure %{ set-option buffer comment_line '#_' set-option buffer comment_block_begin '(comment ' set-option buffer comment_block_end ')' } hook global BufSetOption filetype=coffee %{ set-option buffer comment_block_begin '###' set-option buffer comment_block_end '###' } hook global BufSetOption filetype=css %{ set-option buffer comment_line '' set-option buffer comment_block_begin '/*' set-option buffer comment_block_end '*/' } hook global BufSetOption filetype=d %{ set-option buffer comment_line '//' set-option buffer comment_block_begin '/+' set-option buffer comment_block_end '+/' } hook global BufSetOption filetype=(gas|ini) %{ set-option buffer comment_line ';' } hook global BufSetOption filetype=haml %{ set-option buffer comment_line '-#' } hook global BufSetOption filetype=(html|xml) %{ set-option buffer comment_line '' set-option buffer comment_block_begin '' } hook global BufSetOption filetype=latex %{ set-option buffer comment_line '%' } hook global BufSetOption filetype=ledger %{ set-option buffer comment_line ';' } hook global BufSetOption filetype=lisp %{ set-option buffer comment_line ';' set-option buffer comment_block_begin '#|' set-option buffer comment_block_end '|#' } hook global BufSetOption filetype=lua %{ set-option buffer comment_line '--' set-option buffer comment_block_begin '--[[' set-option buffer comment_block_end ']]' } hook global BufSetOption filetype=markdown %{ set-option buffer comment_line '' set-option buffer comment_block_begin '[//]: # "' set-option buffer comment_block_end '"' } hook global BufSetOption filetype=perl %{ set-option buffer comment_block_begin '#[' set-option buffer comment_block_end ']' } hook global BufSetOption filetype=(pug|zig) %{ set-option buffer comment_line '//' } hook global BufSetOption filetype=python %{ set-option buffer comment_block_begin "'''" set-option buffer comment_block_end "'''" } hook global BufSetOption filetype=ragel %{ set-option buffer comment_line '%%' set-option buffer comment_block_begin '%%{' set-option buffer comment_block_end '}%%' } hook global BufSetOption filetype=ruby %{ set-option buffer comment_block_begin '^begin=' set-option buffer comment_block_end '^=end' } define-command comment-block -docstring '(un)comment selections using block comments' %{ evaluate-commands %sh{ if [ -z "${kak_opt_comment_block_begin}" ] || [ -z "${kak_opt_comment_block_end}" ]; then echo "fail \"The 'comment_block' options are empty, could not comment the selection\"" fi } evaluate-commands -save-regs '"/' -draft %{ # Keep non-empty selections execute-keys \A\s*\z try %{ # Assert that the selection has been commented set-register / "\A\Q%opt{comment_block_begin}\E.*\Q%opt{comment_block_end}\E\n*\z" execute-keys "s" # Uncomment it set-register / "\A\Q%opt{comment_block_begin}\E|\Q%opt{comment_block_end}\E\n*\z" execute-keys sd } catch %{ # Comment the selection set-register '"' "%opt{comment_block_begin}" execute-keys P set-register '"' "%opt{comment_block_end}" execute-keys p } } } define-command comment-line -docstring '(un)comment selected lines using line comments' %{ evaluate-commands %sh{ if [ -z "${kak_opt_comment_line}" ]; then echo "fail \"The 'comment_line' option is empty, could not comment the line\"" fi } evaluate-commands -save-regs '"/' -draft %{ # Select the content of the lines, without indentation execute-keys gi try %{ # Keep non-empty lines execute-keys \A\s*\z } try %{ set-register / "\A\Q%opt{comment_line}\E\h?" try %{ # See if there are any uncommented lines in the selection execute-keys -draft # There are uncommented lines, so comment everything set-register '"' "%opt{comment_line} " align-selections-left execute-keys P } catch %{ # All lines were commented, so uncomment everything execute-keys sd } } } } define-command align-selections-left -docstring 'extend selections to the left to align with the leftmost selected column' %{ evaluate-commands %sh{ leftmost_column=$(echo "$kak_selections_desc" | tr ' ' '\n' | cut -d',' -f1 | cut -d'.' -f2 | sort -n | head -n1) aligned_selections=$(echo "$kak_selections_desc" | sed -E "s/\.[0-9]+,/.$leftmost_column,/g") echo "select $aligned_selections" } } kakoune-2020.09.01/rc/tools/ctags.kak000066400000000000000000000205741372342214000171050ustar00rootroot00000000000000# Kakoune CTags support script # # This script requires the readtags command available in universal-ctags declare-option -docstring "minimum characters before triggering autocomplete" \ int ctags_min_chars 3 declare-option -docstring "list of paths to tag files to parse when looking up a symbol" \ str-list ctagsfiles 'tags' declare-option -hidden completions ctags_completions declare-option -docstring "shell command to run" str readtagscmd "readtags" define-command -params ..1 \ -shell-script-candidates %{ realpath() { ( cd "$(dirname "$1")"; printf "%s/%s\n" "$(pwd -P)" "$(basename "$1")" ) } eval "set -- $kak_quoted_opt_ctagsfiles" for candidate in "$@"; do [ -f "$candidate" ] && realpath "$candidate" done | awk '!x[$0]++' | # remove duplicates while read -r tags; do namecache="${tags%/*}/.kak.${tags##*/}.namecache" if [ -z "$(find "$namecache" -prune -newer "$tags")" ]; then cut -f 1 "$tags" | grep -v '^!' | uniq > "$namecache" fi cat "$namecache" done} \ -docstring %{ ctags-search []: jump to a symbol's definition If no symbol is passed then the current selection is used as symbol name } \ ctags-search %[ evaluate-commands %sh[ realpath() { ( cd "$(dirname "$1")"; printf "%s/%s\n" "$(pwd -P)" "$(basename "$1")" ) } export tagname="${1:-${kak_selection}}" eval "set -- $kak_quoted_opt_ctagsfiles" for candidate in "$@"; do [ -f "$candidate" ] && realpath "$candidate" done | awk '!x[$0]++' | # remove duplicates while read -r tags; do printf '!TAGROOT\t%s\n' "$(realpath "${tags%/*}")/" ${kak_opt_readtagscmd} -t "$tags" "$tagname" done | awk -F '\t|\n' ' /^!TAGROOT\t/ { tagroot=$2 } /[^\t]+\t[^\t]+\t\/\^.*\$?\// { line = $0; sub(".*\t/\\^", "", line); sub("\\$?/$", "", line); menu_info = line; gsub("!", "!!", menu_info); gsub(/^[\t ]+/, "", menu_info); gsub(/\t/, " ", menu_info); keys = line; gsub(/", keys); gsub(/\t/, "", keys); gsub("!", "!!", keys); gsub("&", "&&", keys); gsub("#", "##", keys); gsub("\\|", "||", keys); gsub("\\\\/", "/", keys); menu_item = $2; gsub("!", "!!", menu_item); edit_path = path($2); gsub("&", "&&", edit_path); gsub("#", "##", edit_path); gsub("\\|", "||", edit_path); select = $1; gsub(/", select); gsub(/\t/, "", select); gsub("!", "!!", select); gsub("&", "&&", select); gsub("#", "##", select); gsub("\\|", "||", select); out = out "%!" menu_item ": {MenuInfo}{\\}" menu_info "! %!evaluate-commands %# try %& edit -existing %|" edit_path "|; execute-keys %|/\\Q" keys "vc| & catch %& fail unable to find tag &; try %& execute-keys %|s\\Q" select "| & # !" } /[^\t]+\t[^\t]+\t[0-9]+/ { menu_item = $2; gsub("!", "!!", menu_item); select = $1; gsub(/", select); gsub(/\t/, "", select); gsub("!", "!!", select); gsub("&", "&&", select); gsub("#", "##", select); gsub("\\|", "||", select); menu_info = $3; gsub("!", "!!", menu_info); edit_path = path($2); gsub("!", "!!", edit_path); gsub("#", "##", edit_path); gsub("&", "&&", edit_path); gsub("\\|", "||", edit_path); line_number = $3; out = out "%!" menu_item ": {MenuInfo}{\\}" menu_info "! %!evaluate-commands %# try %& edit -existing %|" edit_path "|; execute-keys %|" line_number "gx| & catch %& fail unable to find tag &; try %& execute-keys %|s\\Q" select "| & # !" } END { print ( length(out) == 0 ? "fail no such tag " ENVIRON["tagname"] : "menu -markup -auto-single " out ) } # Ensure x is an absolute file path, by prepending with tagroot function path(x) { return x ~/^\// ? x : tagroot x }' ]] define-command ctags-complete -docstring "Complete the current selection" %{ nop %sh{ ( header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}" compl=$( eval "set -- $kak_quoted_opt_ctagsfiles" for ctagsfile in "$@"; do ${kak_opt_readtagscmd} -p -t "$ctagsfile" ${kak_selection} done | awk '{ uniq[$1]++ } END { for (elem in uniq) printf " %1$s||%1$s", elem }' ) printf %s\\n "evaluate-commands -client ${kak_client} set-option buffer=${kak_bufname} ctags_completions ${header}${compl}" | \ kak -p ${kak_session} ) > /dev/null 2>&1 < /dev/null & } } define-command ctags-funcinfo -docstring "Display ctags information about a selected function" %{ evaluate-commands -draft %{ try %{ execute-keys '[(;B[a-zA-Z_]+\(' evaluate-commands %sh{ f=${kak_selection%?} sig='\tsignature:(.*)' csn='\t(class|struct|namespace):(\S+)' sigs=$(${kak_opt_readtagscmd} -e -Q '(eq? $kind "f")' "${f}" | sed -Ee "s/^.*${csn}.*${sig}$/\3 [\2::${f}]/ ;t ;s/^.*${sig}$/\1 [${f}]/") if [ -n "$sigs" ]; then printf %s\\n "evaluate-commands -client ${kak_client} %{info -anchor $kak_cursor_line.$kak_cursor_column -style above '$sigs'}" fi } } } } define-command ctags-enable-autoinfo -docstring "Automatically display ctags information about function" %{ hook window -group ctags-autoinfo NormalIdle .* ctags-funcinfo hook window -group ctags-autoinfo InsertIdle .* ctags-funcinfo } define-command ctags-disable-autoinfo -docstring "Disable automatic ctags information displaying" %{ remove-hooks window ctags-autoinfo } declare-option -docstring "shell command to run" \ str ctagscmd "ctags -R --fields=+S" declare-option -docstring "path to the directory in which the tags file will be generated" str ctagspaths "." define-command ctags-generate -docstring 'Generate tag file asynchronously' %{ echo -markup "{Information}launching tag generation in the background" nop %sh{ ( while ! mkdir .tags.kaklock 2>/dev/null; do sleep 1; done trap 'rmdir .tags.kaklock' EXIT if ${kak_opt_ctagscmd} -f .tags.kaktmp ${kak_opt_ctagspaths}; then mv .tags.kaktmp tags msg="tags generation complete" else msg="tags generation failed" fi printf %s\\n "evaluate-commands -client $kak_client echo -markup '{Information}${msg}'" | kak -p ${kak_session} ) > /dev/null 2>&1 < /dev/null & } } define-command ctags-update-tags -docstring 'Update tags for the given file' %{ nop %sh{ ( while ! mkdir .tags.kaklock 2>/dev/null; do sleep 1; done trap 'rmdir .tags.kaklock' EXIT if ${kak_opt_ctagscmd} -f .file_tags.kaktmp $kak_bufname; then export LC_COLLATE=C LC_ALL=C # ensure ASCII sorting order # merge the updated tags tags with the general tags (filtering out out of date tags from it) into the target file grep -Fv "$(printf '\t%s\t' "$kak_bufname")" tags | grep -v '^!' | sort --merge - .file_tags.kaktmp >> .tags.kaktmp rm .file_tags.kaktmp mv .tags.kaktmp tags msg="tags updated for $kak_bufname" else msg="tags update failed for $kak_bufname" fi printf %s\\n "evaluate-commands -client $kak_client echo -markup '{Information}${msg}'" | kak -p ${kak_session} ) > /dev/null 2>&1 < /dev/null & } } define-command ctags-enable-autocomplete -docstring "Enable automatic ctags completion" %{ set-option window completers "option=ctags_completions" %opt{completers} hook window -group ctags-autocomplete InsertIdle .* %{ try %{ evaluate-commands -draft %{ # select previous word >= ctags_min_chars execute-keys "b_.{%opt{ctags_min_chars},}" ctags-complete # run in draft context to preserve selection } } } } define-command ctags-disable-autocomplete -docstring "Disable automatic ctags completion" %{ evaluate-commands %sh{ printf "set-option window completers %s\n" $(printf %s "${kak_opt_completers}" | sed -e "s/'option=ctags_completions'//g") } remove-hooks window ctags-autocomplete } kakoune-2020.09.01/rc/tools/doc.kak000066400000000000000000000137051372342214000165470ustar00rootroot00000000000000declare-option -docstring "name of the client in which documentation is to be displayed" \ str docsclient declare-option -hidden range-specs doc_render_ranges declare-option -hidden range-specs doc_render_links declare-option -hidden range-specs doc_links declare-option -hidden range-specs doc_anchors define-command -hidden -params 4 doc-render-regex %{ evaluate-commands -draft %{ try %{ execute-keys s %arg{1} execute-keys -draft s %arg{2} d execute-keys "%arg{3}" evaluate-commands %sh{ face="$4" eval "set -- $kak_quoted_selections_desc" ranges="" for desc in "$@"; do ranges="$ranges '$desc|$face'"; done echo "update-option buffer doc_render_ranges" echo "set-option -add buffer doc_render_ranges $ranges" } } } } define-command -hidden doc-parse-links %{ evaluate-commands -draft %{ try %{ execute-keys s (.*?),.*? execute-keys -draft s .*,| d execute-keys H set-option buffer doc_links %val{timestamp} set-option buffer doc_render_links %val{timestamp} evaluate-commands -itersel %{ set-option -add buffer doc_links "%val{selection_desc}|%reg{1}" set-option -add buffer doc_render_links "%val{selection_desc}|default+u" } } } } define-command -hidden doc-parse-anchors %{ evaluate-commands -draft %{ try %{ set-option buffer doc_anchors %val{timestamp} # Find sections as add them as imlicit anchors execute-keys s ^={2,}\h+([^\n]+)$ evaluate-commands -itersel %{ set-option -add buffer doc_anchors "%val{selection_desc}|%sh{printf '%s' ""$kak_main_reg_1"" | tr '[A-Z ]' '[a-z-]'}" } # Parse explicit anchors and remove their text execute-keys s \[\[(.*?)\]\]\s* evaluate-commands -itersel %{ set-option -add buffer doc_anchors "%val{selection_desc}|%reg{1}" } execute-keys d update-option buffer doc_anchors } } } define-command doc-jump-to-anchor -params 1 %{ update-option buffer doc_anchors evaluate-commands %sh{ anchor="$1" eval "set -- $kak_quoted_opt_doc_anchors" shift for range in "$@"; do if [ "${range#*|}" = "$anchor" ]; then printf '%s\n' "select '${range%|*}'; execute-keys vv" exit fi done printf "fail No such anchor '%s'\n" "${anchor}" } } define-command doc-follow-link %{ update-option buffer doc_links evaluate-commands %sh{ eval "set -- $kak_quoted_opt_doc_links" for link in "$@"; do printf '%s\n' "$link" done | awk -v FS='[.,|#]' ' BEGIN { l=ENVIRON["kak_cursor_line"]; c=ENVIRON["kak_cursor_column"]; } l >= $1 && c >= $2 && l <= $3 && c <= $4 { if (NF == 6) { print "doc " $5 if ($6 != "") { print "doc-jump-to-anchor %{" $6 "}" } } else { print "doc-jump-to-anchor %{" $5 "}" } exit } ' } } define-command -params 1 -hidden doc-render %{ edit! -scratch "*doc-%sh{basename $1 .asciidoc}*" execute-keys "!cat %arg{1}gg" doc-parse-anchors # Join paragraphs together try %{ execute-keys -draft '%S\n{2,}|(?=\+)\n|^[^\n]+::\n|^\h*[*-]\h+' \ ^\h*-{2,}(\n|\z) S\n\z \n } # Remove some line end markers try %{ execute-keys -draft s \h*(\+|:{2,})$ d } # Setup the doc_render_ranges option set-option buffer doc_render_ranges %val{timestamp} doc-render-regex \B(? s \\((?=\*)|(?=`)) d } set-option buffer readonly true add-highlighter buffer/ ranges doc_render_ranges add-highlighter buffer/ ranges doc_render_links add-highlighter buffer/ wrap -word -indent map buffer normal ': doc-follow-link' } define-command -params 1..2 \ -shell-script-candidates %{ if [ "$kak_token_to_complete" -eq 0 ]; then find "${kak_runtime}/doc/" -type f -name "*.asciidoc" | sed 's,.*/,,; s/\.[^/]*$//' elif [ "$kak_token_to_complete" -eq 1 ]; then readonly page="${kak_runtime}/doc/${1}.asciidoc" if [ -f "${page}" ]; then awk ' /^==+ +/ { sub(/^==+ +/, ""); print } /^\[\[[^\]]+\]\]/ { sub(/^\[\[/, ""); sub(/\]\].*/, ""); print } ' < $page | tr '[A-Z ]' '[a-z-]' fi fi } \ doc -docstring %{ doc []: open a buffer containing documentation about a given topic An optional keyword argument can be passed to the function, which will be automatically selected in the documentation } %{ evaluate-commands %sh{ readonly page="${kak_runtime}/doc/${1}.asciidoc" if [ -f "${page}" ]; then jump_cmd="" if [ $# -eq 2 ]; then jump_cmd="doc-jump-to-anchor '$2'" fi printf %s\\n "evaluate-commands -try-client %opt{docsclient} %{ doc-render ${page}; ${jump_cmd} }" else printf 'fail No such doc file: %s\n' "${page}" fi } } alias global help doc kakoune-2020.09.01/rc/tools/format.kak000066400000000000000000000023501372342214000172640ustar00rootroot00000000000000declare-option -docstring "shell command used for the 'format-selections' and 'format-buffer' commands" \ str formatcmd define-command format-buffer -docstring "Format the contents of the buffer" %{ evaluate-commands -draft %{ execute-keys '%' format-selections } } define-command format-selections -docstring "Format the selections individually" %{ evaluate-commands %sh{ if [ -z "${kak_opt_formatcmd}" ]; then echo "fail 'The option ''formatcmd'' must be set'" fi } evaluate-commands -draft -no-hooks -save-regs '|' %{ set-register '|' %{ format_in="$(mktemp "${TMPDIR:-/tmp}"/kak-formatter-XXXXXX)" format_out="$(mktemp "${TMPDIR:-/tmp}"/kak-formatter-XXXXXX)" cat > "$format_in" eval "$kak_opt_formatcmd" < "$format_in" > "$format_out" if [ $? -eq 0 ]; then cat "$format_out" else printf 'eval -client %s %%{ fail formatter returned an error %s }\n' "$kak_client" "$?" | kak -p "$kak_session" cat "$format_in" fi rm -f "$format_in" "$format_out" } execute-keys '|' } } alias global format format-buffer kakoune-2020.09.01/rc/tools/git.kak000066400000000000000000000302741372342214000165650ustar00rootroot00000000000000declare-option -docstring "name of the client in which documentation is to be displayed" \ str docsclient hook -group git-log-highlight global WinSetOption filetype=git-log %{ add-highlighter window/git-log group add-highlighter window/git-log/ regex '^([*|\\ /_.-])*' 0:keyword add-highlighter window/git-log/ regex '^( ?[*|\\ /_.-])*\h{,3}(commit )?(\b[0-9a-f]{4,40}\b)' 2:keyword 3:comment add-highlighter window/git-log/ regex '^( ?[*|\\ /_.-])*\h{,3}([a-zA-Z_-]+:) (.*?)$' 2:variable 3:value add-highlighter window/git-log/ ref diff # highlight potential diffs from the -p option hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-log } } hook -group git-status-highlight global WinSetOption filetype=git-status %{ add-highlighter window/git-status group add-highlighter window/git-status/ regex '^## ' 0:comment add-highlighter window/git-status/ regex '^## (\S*[^\s\.@])' 1:green add-highlighter window/git-status/ regex '^## (\S*[^\s\.@])(\.\.+)(\S*[^\s\.@])' 1:green 2:comment 3:red add-highlighter window/git-status/ regex '^(##) (No commits yet on) (\S*[^\s\.@])' 1:comment 2:Default 3:green add-highlighter window/git-status/ regex '^## \S+ \[[^\n]*ahead (\d+)[^\n]*\]' 1:green add-highlighter window/git-status/ regex '^## \S+ \[[^\n]*behind (\d+)[^\n]*\]' 1:red add-highlighter window/git-status/ regex '^(?:([Aa])|([Cc])|([Dd!?])|([MUmu])|([Rr])|([Tt]))[ !\?ACDMRTUacdmrtu]\h' 1:green 2:blue 3:red 4:yellow 5:cyan 6:cyan add-highlighter window/git-status/ regex '^[ !\?ACDMRTUacdmrtu](?:([Aa])|([Cc])|([Dd!?])|([MUmu])|([Rr])|([Tt]))\h' 1:green 2:blue 3:red 4:yellow 5:cyan 6:cyan add-highlighter window/git-status/ regex '^R[ !\?ACDMRTUacdmrtu] [^\n]+( -> )' 1:cyan add-highlighter window/git-status/ regex '^\h+(?:((?:both )?modified:)|(added:|new file:)|(deleted(?: by \w+)?:)|(renamed:)|(copied:))(?:.*?)$' 1:yellow 2:green 3:red 4:cyan 5:blue 6:magenta hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-status } } declare-option -hidden line-specs git_blame_flags declare-option -hidden line-specs git_diff_flags declare-option -hidden int-list git_hunk_list define-command -params 1.. \ -docstring %{ git []: git wrapping helper All the optional arguments are forwarded to the git utility Available commands: add rm blame commit checkout diff hide-blame hide-diff init log next-hunk previous-hunk show show-diff status update-diff } -shell-script-candidates %{ if [ $kak_token_to_complete -eq 0 ]; then printf "add\nrm\nblame\ncommit\ncheckout\ndiff\nhide-blame\nhide-diff\nlog\nnext-hunk\nprev-hunk\nshow\nshow-diff\ninit\nstatus\nupdate-diff\n" else case "$1" in commit) printf -- "--amend\n--no-edit\n--all\n--reset-author\n--fixup\n--squash\n"; git ls-files -m ;; add) git ls-files -dmo --exclude-standard ;; rm) git ls-files -c ;; esac fi } \ git %{ evaluate-commands %sh{ cd_bufdir() { dirname_buffer="${kak_buffile%/*}" cd "${dirname_buffer}" 2>/dev/null || { printf 'fail Unable to change the current working directory to: %s\n' "${dirname_buffer}" exit 1 } } show_git_cmd_output() { local filetype case "$1" in diff) filetype=diff ;; log|show) filetype=git-log ;; status) filetype=git-status ;; esac output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-git.XXXXXXXX)/fifo mkfifo ${output} ( git "$@" > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null printf %s "evaluate-commands -try-client '$kak_opt_docsclient' %{ edit! -fifo ${output} *git* set-option buffer filetype '${filetype}' hook -always -once buffer BufCloseFifo .* %{ nop %sh{ rm -r $(dirname ${output}) } } }" } run_git_blame() { ( cd_bufdir printf %s "evaluate-commands -client '$kak_client' %{ try %{ add-highlighter window/git-blame flag-lines Information git_blame_flags } set-option buffer=$kak_bufname git_blame_flags '$kak_timestamp' }" | kak -p ${kak_session} git blame "$@" --incremental ${kak_buffile} | awk ' function send_flags(text, flag, i) { if (line == "") { return; } text=substr(sha,1,8) " " dates[sha] " " authors[sha] # gsub("|", "\\|", text) gsub("~", "~~", text) flag="%~" line "|" text "~" for ( i=1; i < count; i++ ) { flag=flag " %~" line+i "|" text "~" } cmd = "kak -p " ENVIRON["kak_session"] print "set-option -add buffer=" ENVIRON["kak_bufname"] " git_blame_flags " flag | cmd close(cmd) } /^([0-9a-f]+) ([0-9]+) ([0-9]+) ([0-9]+)/ { send_flags() sha=$1 line=$3 count=$4 } /^author / { authors[sha]=substr($0,8) } /^author-time ([0-9]*)/ { cmd = "date -d @" $2 " +\"%F %T\"" cmd | getline dates[sha] close(cmd) } END { send_flags(); }' ) > /dev/null 2>&1 < /dev/null & } run_git_cmd() { if git "${@}" > /dev/null 2>&1; then printf %s "echo -markup '{Information}git $1 succeeded'" else printf 'fail git %s failed\n' "$1" fi } update_diff() { ( cd_bufdir git --no-pager diff -U0 "$kak_buffile" | perl -e ' $flags = $ENV{"kak_timestamp"}; foreach $line () { if ($line =~ /@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))?/) { $from_line = $1; $from_count = ($2 eq "" ? 1 : $2); $to_line = $3; $to_count = ($4 eq "" ? 1 : $4); if ($from_count == 0 and $to_count > 0) { for $i (0..$to_count - 1) { $line = $to_line + $i; $flags .= " $line|\{green\}+"; } } elsif ($from_count > 0 and $to_count == 0) { if ($to_line == 0) { $flags .= " 1|\{red\}‾"; } else { $flags .= " $to_line|\{red\}_"; } } elsif ($from_count > 0 and $from_count == $to_count) { for $i (0..$to_count - 1) { $line = $to_line + $i; $flags .= " $line|\{blue\}~"; } } elsif ($from_count > 0 and $from_count < $to_count) { for $i (0..$from_count - 1) { $line = $to_line + $i; $flags .= " $line|\{blue\}~"; } for $i ($from_count..$to_count - 1) { $line = $to_line + $i; $flags .= " $line|\{green\}+"; } } elsif ($to_count > 0 and $from_count > $to_count) { for $i (0..$to_count - 2) { $line = $to_line + $i; $flags .= " $line|\{blue\}~"; } $last = $to_line + $to_count - 1; $flags .= " $last|\{blue+u\}~"; } } } print "set-option buffer git_diff_flags $flags" ' ) } jump_hunk() { direction=$1 set -- ${kak_opt_git_diff_flags} shift if [ $# -lt 1 ]; then echo "fail 'no git hunks found'" exit fi # Update hunk list if required if [ "$kak_timestamp" != "${kak_opt_git_hunk_list%% *}" ]; then hunks=$kak_timestamp prev_line="-1" for line in "$@"; do line="${line%%|*}" if [ "$((line - prev_line))" -gt 1 ]; then hunks="$hunks $line" fi prev_line="$line" done echo "set-option buffer git_hunk_list $hunks" hunks=${hunks#* } else hunks=${kak_opt_git_hunk_list#* } fi prev_hunk="" next_hunk="" for hunk in ${hunks}; do if [ "$hunk" -lt "$kak_cursor_line" ]; then prev_hunk=$hunk elif [ "$hunk" -gt "$kak_cursor_line" ]; then next_hunk=$hunk break fi done wrapped=false if [ "$direction" = "next" ]; then if [ -z "$next_hunk" ]; then next_hunk=${hunks%% *} wrapped=true fi if [ -n "$next_hunk" ]; then echo "select $next_hunk.1,$next_hunk.1" fi elif [ "$direction" = "prev" ]; then if [ -z "$prev_hunk" ]; then wrapped=true prev_hunk=${hunks##* } fi if [ -n "$prev_hunk" ]; then echo "select $prev_hunk.1,$prev_hunk.1" fi fi if [ "$wrapped" = true ]; then echo "echo -markup '{Information}git hunk search wrapped around buffer'" fi } commit() { # Handle case where message needs not to be edited if grep -E -q -e "-m|-F|-C|--message=.*|--file=.*|--reuse-message=.*|--no-edit|--fixup.*|--squash.*"; then if git commit "$@" > /dev/null 2>&1; then echo 'echo -markup "{Information}Commit succeeded"' else echo 'fail Commit failed' fi exit fi <<-EOF $@ EOF # fails, and generate COMMIT_EDITMSG GIT_EDITOR='' EDITOR='' git commit "$@" > /dev/null 2>&1 msgfile="$(git rev-parse --git-dir)/COMMIT_EDITMSG" printf %s "edit '$msgfile' hook buffer BufWritePost '.*\Q$msgfile\E' %{ evaluate-commands %sh{ if git commit -F '$msgfile' --cleanup=strip $* > /dev/null; then printf %s 'evaluate-commands -client $kak_client echo -markup %{{Information}Commit succeeded}; delete-buffer' else printf 'evaluate-commands -client %s fail Commit failed\n' "$kak_client" fi } }" } case "$1" in show|log|diff|status) show_git_cmd_output "$@" ;; blame) shift run_git_blame "$@" ;; hide-blame) printf %s "try %{ set-option buffer=$kak_bufname git_blame_flags $kak_timestamp remove-highlighter window/git-blame }" ;; show-diff) echo 'try %{ add-highlighter window/git-diff flag-lines Default git_diff_flags }' update_diff ;; hide-diff) echo 'try %{ remove-highlighter window/git-diff }' ;; update-diff) update_diff ;; next-hunk) jump_hunk next ;; prev-hunk) jump_hunk prev ;; commit) shift commit "$@" ;; init) shift git init "$@" > /dev/null 2>&1 ;; add|rm) cmd="$1" shift run_git_cmd $cmd "${@:-${kak_buffile}}" ;; reset|checkout) run_git_cmd "$@" ;; *) printf "fail unknown git command '%s'\n" "$1" exit ;; esac }} kakoune-2020.09.01/rc/tools/go/000077500000000000000000000000001372342214000157115ustar00rootroot00000000000000kakoune-2020.09.01/rc/tools/go/go-tools.kak000066400000000000000000000162201372342214000201450ustar00rootroot00000000000000# Provides integration of the following tools: # - gocode for code completion (github.com/nsf/gocode) # - goimports for code formatting on save # - gogetdoc for documentation display and source jump (needs jq) (github.com/zmb3/gogetdoc) # Needs the following tools in the path: # - jq for json deserializaton hook -once global BufSetOption filetype=go %{ require-module go-tools } provide-module go-tools %{ evaluate-commands %sh{ for dep in gocode goimports gogetdoc jq; do if ! command -v $dep > /dev/null 2>&1; then echo "echo -debug %{Dependency unmet: $dep, please install it to use go-tools}" fi done } # Auto-completion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ declare-option -hidden str go_complete_tmp_dir declare-option -hidden completions gocode_completions define-command go-complete -docstring "Complete the current selection with gocode" %{ evaluate-commands %sh{ dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX) printf %s\\n "set-option buffer go_complete_tmp_dir ${dir}" printf %s\\n "evaluate-commands -no-hooks write ${dir}/buf" } nop %sh{ dir=${kak_opt_go_complete_tmp_dir} ( gocode_data=$(gocode -f=godit --in=${dir}/buf autocomplete ${kak_cursor_byte_offset}) rm -r ${dir} column_offset=$(printf %s "${gocode_data}" | head -n1 | cut -d, -f1) header="${kak_cursor_line}.$((${kak_cursor_column} - $column_offset))@${kak_timestamp}" compl=$(echo "${gocode_data}" | sed 1d | awk -F ",," '{ gsub(/~/, "~~", $1) gsub(/~/, "~~", $2) print "%~" $2 "||" $1 "~" }' | paste -s -) printf %s\\n "evaluate-commands -client '${kak_client}' %{ set-option 'buffer=${kak_bufname}' gocode_completions ${header} ${compl} }" | kak -p ${kak_session} ) > /dev/null 2>&1 < /dev/null & } } define-command go-enable-autocomplete -docstring "Add gocode completion candidates to the completer" %{ set-option window completers "option=gocode_completions" %opt{completers} hook window -group go-autocomplete InsertIdle .* %{ try %{ execute-keys -draft [\w\.].\z go-complete } } alias window complete go-complete } define-command go-disable-autocomplete -docstring "Disable gocode completion" %{ set-option window completers %sh{ printf %s\\n "${kak_opt_completers}" | sed "s/'option=gocode_completions'//g" } remove-hooks window go-autocomplete unalias window complete go-complete } # Auto-format # ‾‾‾‾‾‾‾‾‾‾‾ declare-option -hidden str go_format_tmp_dir define-command -params ..1 go-format \ -docstring "go-format [-use-goimports]: custom formatter for go files" %{ evaluate-commands %sh{ dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX) printf %s\\n "set-option buffer go_format_tmp_dir ${dir}" printf %s\\n "evaluate-commands -no-hooks write ${dir}/buf" } evaluate-commands %sh{ dir=${kak_opt_go_format_tmp_dir} if [ "$1" = "-use-goimports" ]; then fmt_cmd="goimports -srcdir '${kak_buffile}'" else fmt_cmd="gofmt -s" fi eval "${fmt_cmd} -e -w ${dir}/buf 2> ${dir}/stderr" if [ $? ]; then cp ${dir}/buf "${kak_buffile}" else # we should report error if linting isn't active printf %s\\n "echo -debug '$(cat ${dir}/stderr)'" fi rm -r ${dir} } edit! } # Documentation # ‾‾‾‾‾‾‾‾‾‾‾‾‾ declare-option -hidden str go_doc_tmp_dir # FIXME text escaping define-command -hidden -params 1..2 gogetdoc-cmd %{ evaluate-commands %sh{ dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-go.XXXXXXXX) printf %s\\n "set-option buffer go_doc_tmp_dir ${dir}" printf %s\\n "evaluate-commands -no-hooks write ${dir}/buf" } evaluate-commands %sh{ dir=${kak_opt_go_doc_tmp_dir} ( printf %s\\n "${kak_buffile}" > ${dir}/modified cat ${dir}/buf | wc -c >> ${dir}/modified cat ${dir}/buf >> ${dir}/modified args="" if [ "$2" = "1" ]; then args="-json" fi output=$(cat ${dir}/modified \ | gogetdoc $args -pos "${kak_buffile}:#${kak_cursor_byte_offset}" -modified \ | sed 's/%/%%/g') rm -r ${dir} printf %s "${output}" | grep -v -q "^gogetdoc: " status=$? case "$1" in "info") if [ ${status} -eq 0 ]; then printf %s\\n "evaluate-commands -client '${kak_client}' %{ info -anchor ${kak_cursor_line}.${kak_cursor_column} %@${output}@ }" | kak -p ${kak_session} else msg=$(printf %s "${output}" | cut -d' ' -f2-) printf %s\\n "evaluate-commands -client '${kak_client}' %{ echo '${msg}' }" | kak -p ${kak_session} fi ;; "echo") if [ ${status} -eq 0 ]; then signature=$(printf %s "${output}" | sed -n 3p) printf %s\\n "evaluate-commands -client '${kak_client}' %{ echo '${signature}' }" | kak -p ${kak_session} fi ;; "jump") if [ ${status} -eq 0 ]; then pos=$(printf %s "${output}" | jq -r .pos) file=$(printf %s "${pos}" | cut -d: -f1) line=$(printf %s "${pos}" | cut -d: -f2) col=$(printf %s "${pos}" | cut -d: -f3) printf %s\\n "evaluate-commands -client '${kak_client}' %{ evaluate-commands -try-client '${kak_opt_jumpclient}' edit -existing ${file} ${line} ${col} try %{ focus '${kak_opt_jumpclient}' } }" | kak -p ${kak_session} fi ;; *) printf %s\\n "evaluate-commands -client '${kak_client}' %{ echo -error %{unkown command '$1'} }" | kak -p ${kak_session} ;; esac ) > /dev/null 2>&1 < /dev/null & } } define-command go-doc-info -docstring "Show the documention of the symbol under the cursor" %{ gogetdoc-cmd "info" } define-command go-print-signature -docstring "Print the signature of the symbol under the cursor" %{ gogetdoc-cmd "echo" } define-command go-jump -docstring "Jump to the symbol definition" %{ gogetdoc-cmd "jump" 1 } define-command go-share-selection -docstring "Share the selection using the Go Playground" %{ evaluate-commands %sh{ snippet_id=$(printf %s\\n "${kak_selection}" | curl -s https://play.golang.org/share --data-binary @-) printf "echo https://play.golang.org/p/%s" ${snippet_id} } } } kakoune-2020.09.01/rc/tools/grep.kak000066400000000000000000000062531372342214000167370ustar00rootroot00000000000000declare-option -docstring "shell command run to search for subtext in a file/directory" \ str grepcmd 'grep -RHn' declare-option -docstring "name of the client in which utilities display information" \ str toolsclient declare-option -hidden int grep_current_line 0 define-command -params .. -file-completion \ -docstring %{grep []: grep utility wrapper All the optional arguments are forwarded to the grep utility} \ grep %{ evaluate-commands %sh{ if [ $# -eq 0 ]; then set -- "${kak_selection}" fi output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-grep.XXXXXXXX)/fifo mkfifo ${output} ( ${kak_opt_grepcmd} "$@" | tr -d '\r' > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{ edit! -fifo ${output} *grep* set-option buffer filetype grep set-option buffer grep_current_line 0 hook -always -once buffer BufCloseFifo .* %{ nop %sh{ rm -r $(dirname ${output}) } } }" }} hook -group grep-highlight global WinSetOption filetype=grep %{ add-highlighter window/grep group add-highlighter window/grep/ regex "^((?:\w:)?[^:\n]+):(\d+):(\d+)?" 1:cyan 2:green 3:green add-highlighter window/grep/ line %{%opt{grep_current_line}} default+b hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/grep } } hook global WinSetOption filetype=grep %{ hook buffer -group grep-hooks NormalKey grep-jump hook -once -always window WinSetOption filetype=.* %{ remove-hooks buffer grep-hooks } } declare-option -docstring "name of the client in which all source code jumps will be executed" \ str jumpclient define-command -hidden grep-jump %{ evaluate-commands %{ # use evaluate-commands to ensure jumps are collapsed try %{ execute-keys 's^((?:\w:)?[^:]+):(\d+):(\d+)?' set-option buffer grep_current_line %val{cursor_line} evaluate-commands -try-client %opt{jumpclient} -verbatim -- edit -existing %reg{1} %reg{2} %reg{3} try %{ focus %opt{jumpclient} } } } } define-command grep-next-match -docstring 'Jump to the next grep match' %{ evaluate-commands -try-client %opt{jumpclient} %{ buffer '*grep*' # First jump to end of buffer so that if grep_current_line == 0 # 0g will be a no-op and we'll jump to the first result. # Yeah, thats ugly... execute-keys "ge %opt{grep_current_line}g /^[^:]+:\d+:" grep-jump } try %{ evaluate-commands -client %opt{toolsclient} %{ buffer '*grep*' execute-keys gg %opt{grep_current_line}g } } } define-command grep-previous-match -docstring 'Jump to the previous grep match' %{ evaluate-commands -try-client %opt{jumpclient} %{ buffer '*grep*' # See comment in grep-next-match execute-keys "ge %opt{grep_current_line}g ^[^:]+:\d+:" grep-jump } try %{ evaluate-commands -client %opt{toolsclient} %{ buffer '*grep*' execute-keys gg %opt{grep_current_line}g } } } kakoune-2020.09.01/rc/tools/lint.kak000066400000000000000000000365461372342214000167600ustar00rootroot00000000000000declare-option \ -docstring %{ The shell command used by lint-buffer and lint-selections. It will be given the path to a file containing the text to be linted, and must produce output in the format: {filename}:{line}:{column}: {kind}: {message} If the 'kind' field contains 'error', the message is treated as an error, otherwise it is assumed to be a warning. } \ str lintcmd declare-option -hidden line-specs lint_flags declare-option -hidden line-specs lint_messages declare-option -hidden int lint_error_count declare-option -hidden int lint_warning_count declare-option -docstring "name of the client in which utilities display information" \ str toolsclient define-command \ -hidden \ -params 1 \ -docstring %{ lint-cleaned-selections : Check each selection with . Assumes selections all have anchor before cursor, and that %val{selections} and %val{selections_desc} are in the same order. } \ lint-cleaned-selections \ %{ # Create a temporary directory to keep all our state. evaluate-commands %sh{ # This is going to come in handy later. kakquote() { printf "%s" "$*" | sed "s/'/''/g; 1s/^/'/; \$s/\$/'/"; } # Before we clobber our arguments, # let's record the lintcmd we were given. lintcmd="$1" # Some linters care about the name or extension # of the file being linted, so we'll store the text we want to lint # in a file with the same name as the original buffer. filename="${kak_buffile##*/}" # A directory to keep all our temporary data. dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-lint.XXXXXXXX) # A fifo to send the results back to a Kakoune buffer. mkfifo "$dir"/fifo printf '%s\n' "evaluate-commands -try-client '$kak_opt_toolsclient' %{ edit! -fifo $(kakquote "$dir/fifo") -debug *lint-output* set-option buffer filetype make set-option buffer make_current_error_line 0 }" # Write all the selection descriptions to files. eval set -- "$kak_selections_desc" i=0 for desc; do mkdir -p "$dir"/sel-"$i" printf "%s" "$desc" > "$dir"/sel-$i/desc i=$(( i + 1 )) done # Write all the selection contents to files. eval set -- "$kak_quoted_selections" i=0 for text; do # The selection text needs to be stored in a subdirectory, # so we can be sure the filename won't clash with one of ours. mkdir -p "$dir"/sel-"$i"/text/ printf "%s" "$text" > "$dir"/sel-$i/text/"$filename" i=$(( i + 1 )) done # We do redirection trickiness to record stderr from # this background task and route it back to Kakoune, # but shellcheck isn't a fan. # shellcheck disable=SC2094 ({ # do the parsing in the background and when ready send to the session for selpath in "$dir"/sel-*; do # Read in the line and column offset of this selection. IFS=".," read -r start_line start_byte _ < "$selpath"/desc # Run the linter, and record the exit-code. eval "$lintcmd '$selpath/text/$filename'" | sort -t: -k2,2 -n | awk \ -v line_offset=$(( start_line - 1 )) \ -v first_line_byte_offset=$(( start_byte - 1 )) \ ' BEGIN { OFS=":"; FS=":" } /:[1-9][0-9]*:[1-9][0-9]*:/ { $1 = ENVIRON["kak_bufname"] if ( $2 == 1 ) { $3 += first_line_byte_offset } $2 += line_offset print $0 } ' >>"$dir"/result done # Load all the linter messages into Kakoune options. # Inside this block, shellcheck warns us that the shell doesn't # need backslash-continuation chars in a single-quoted string, # but awk still needs them. # shellcheck disable=SC1004 awk -v file="$kak_buffile" -v stamp="$kak_timestamp" -v client="$kak_client" ' function kakquote(text) { # \x27 is apostrophe, escaped for shell-quoting reasons. gsub(/\x27/, "\x27\x27", text) return "\x27" text "\x27" } BEGIN { OFS=":" FS=":" error_count = 0 warning_count = 0 } /:[1-9][0-9]*:[1-9][0-9]*:/ { # Remember that an error or a warning occurs on this line.. if ($4 ~ /[Ee]rror/) { # We definitely have an error on this line. flags_by_line[$2] = "{Error}x" error_count++ } else if (flags_by_line[$2] ~ /Error/) { # We have a warning on this line, # but we already have an error, so do nothing. warning_count++ } else { # We have a warning on this line, # and no previous error. flags_by_line[$2] = "{Information}!" warning_count++ } # The message starts with the severity indicator. msg = substr($4, 2) # fix case where $5 is not the last field # because of extra colons in the message for (i=5; i<=NF; i++) msg = msg ":" $i # Mention the column where this problem occurs, # so that information is not lost. msg = msg "(col " $3 ")" # Messages will be stored in a line-specs option, # and each record in the option uses "|" # as a field delimiter, so we need to escape them. gsub(/\|/, "\\|", msg) if ($2 in messages_by_line) { # We already have a message on this line, # so append our new message. messages_by_line[$2] = messages_by_line[$2] "\n" msg } else { # A brand-new message on this line. messages_by_line[$2] = msg } } END { printf("set-option %s lint_flags %s", kakquote("buffer=" file), stamp); for (line in flags_by_line) { flag = flags_by_line[line] printf(" %s", kakquote(line "|" flag)); } printf("\n"); printf("set-option %s lint_messages %s", kakquote("buffer=" file), stamp); for (line in messages_by_line) { msg = messages_by_line[line] printf(" %s", kakquote(line "|" msg)); } printf("\n"); print "set-option " \ kakquote("buffer=" file) " " \ "lint_error_count " \ error_count print "set-option " \ kakquote("buffer=" file) " " \ "lint_warning_count " \ warning_count } ' "$dir"/result | kak -p "$kak_session" # Send any linting errors to the debug buffer, # for visibility. if [ -s "$dir"/stderr ]; then # Errors were detected!" printf "echo -debug Linter errors: <<<\n" while read -r LINE; do printf "echo -debug %s\n" "$(kakquote " $LINE")" done < "$dir"/stderr printf "echo -debug >>>\n" # FIXME: When #3254 is fixed, this can become a "fail" printf "eval -client %s echo -markup {Error}%s\n" \ "$kak_client" \ "lint failed, see *debug* for details" else # No errors detected, show the results. printf "eval -client %s 'lint-show-diagnostics; lint-show-counters'" \ "$kak_client" fi | kak -p "$kak_session" # We are done here. Send the results to Kakoune, # and clean up. cat "$dir"/result > "$dir"/fifo rm -rf "$dir" } & ) >"$dir"/stderr 2>&1 ]: Check each selection with a linter. Switches: -command Use the given linter. If not given, the lintcmd option is used. } \ lint-selections \ %{ evaluate-commands -draft %{ # Make sure all the selections are "forward" (anchor before cursor) execute-keys # Make sure the selections are in document order. evaluate-commands %sh{ printf "select " printf "%s\n" "$kak_selections_desc" | tr ' ' '\n' | sort -n -t. | tr '\n' ' ' } evaluate-commands %sh{ # This is going to come in handy later. kakquote() { printf "%s" "$*" | sed "s/'/''/g; 1s/^/'/; \$s/\$/'/"; } if [ "$1" = "-command" ]; then if [ -z "$2" ]; then echo 'fail -- -command option requires a value' exit 1 fi lintcmd="$2" elif [ -n "$1" ]; then echo "fail -- Unrecognised parameter $(kakquote "$1")" exit 1 elif [ -z "${kak_opt_lintcmd}" ]; then echo 'fail The lintcmd option is not set' exit 1 else lintcmd="$kak_opt_lintcmd" fi printf 'lint-cleaned-selections %s\n' "$(kakquote "$lintcmd")" } } } define-command \ -docstring %{ lint-buffer: Check the current buffer with a linter. Set the lintcmd option to control which linter is used. } \ lint-buffer \ %{ evaluate-commands %sh{ if [ -z "${kak_opt_lintcmd}" ]; then echo 'fail The lintcmd option is not set' exit 1 fi } evaluate-commands -draft %{ execute-keys '%' lint-cleaned-selections %opt{lintcmd} } } alias global lint lint-buffer define-command -hidden lint-show-current-line %{ update-option buffer lint_messages evaluate-commands %sh{ # This is going to come in handy later. kakquote() { printf "%s" "$*" | sed "s/'/''/g; 1s/^/'/; \$s/\$/'/"; } eval set -- "${kak_quoted_opt_lint_messages}" shift # skip the timestamp while [ $# -gt 0 ]; do lineno=${1%%|*} msg=${1#*|} if [ "$lineno" -eq "$kak_cursor_line" ]; then printf "info -anchor %d.%d %s\n" \ "$kak_cursor_line" \ "$kak_cursor_column" \ "$(kakquote "$msg")" break fi shift done } } define-command -hidden lint-show-counters %{ echo -markup "linting results: {Error} %opt{lint_error_count} error(s) {Information} %opt{lint_warning_count} warning(s) " } define-command -hidden lint-show-diagnostics %{ try %{ # Assume that if the highlighter is set, then hooks also are add-highlighter window/lint flag-lines default lint_flags hook window -group lint-diagnostics NormalIdle .* %{ lint-show-current-line } hook window -group lint-diagnostics WinSetOption lint_flags=.* %{ info; lint-show-current-line } } } define-command lint-hide-diagnostics -docstring "Hide line markers and disable automatic diagnostic displaying" %{ remove-highlighter window/lint remove-hooks window lint-diagnostics } # FIXME: Is there some way we can re-use make-next-error # instead of re-implementing it? define-command \ -docstring "Jump to the next line that contains a lint message" \ lint-next-message \ %{ update-option buffer lint_messages evaluate-commands %sh{ # This is going to come in handy later. kakquote() { printf "%s" "$*" | sed "s/'/''/g; 1s/^/'/; \$s/\$/'/"; } eval "set -- ${kak_quoted_opt_lint_messages}" shift if [ "$#" -eq 0 ]; then printf 'fail no lint messages' exit fi first_lineno="" first_msg="" for lint_message; do lineno="${lint_message%%|*}" msg="${lint_message#*|}" if [ -z "$first_lineno" ]; then first_lineno=$lineno first_msg=$msg fi if [ "$lineno" -gt "$kak_cursor_line" ]; then printf "execute-keys %dg\n" "$lineno" printf "info -anchor %d.%d %s\n" \ "$lineno" "1" "$(kakquote "$msg")" exit fi done # We didn't find any messages after the current line, # let's wrap around to the beginning. printf "execute-keys %dg\n" "$first_lineno" printf "info -anchor %d.%d %s\n" \ "$first_lineno" "1" "$(kakquote "$first_msg")" printf "echo -markup \ {Information}lint message search wrapped around buffer\n" } } # FIXME: Is there some way we can re-use make-previous-error # instead of re-implementing it? define-command \ -docstring "Jump to the previous line that contains a lint message" \ lint-previous-message \ %{ update-option buffer lint_messages evaluate-commands %sh{ # This is going to come in handy later. kakquote() { printf "%s" "$*" | sed "s/'/''/g; 1s/^/'/; \$s/\$/'/"; } eval "set -- ${kak_quoted_opt_lint_messages}" shift if [ "$#" -eq 0 ]; then printf 'fail no lint messages' exit fi prev_lineno="" prev_msg="" for lint_message; do lineno="${lint_message%%|*}" msg="${lint_message#*|}" # If this message comes on or after the cursor position... if [ "$lineno" -ge "${kak_cursor_line}" ]; then # ...and we had a previous message... if [ -n "$prev_lineno" ]; then # ...then go to the previous message and display it. printf "execute-keys %dg\n" "$prev_lineno" printf "info -anchor %d.%d %s\n" \ "$lineno" "1" "$(kakquote "$prev_msg")" exit # We are after the cursor position, but there has been # no previous message; we'll need to do something else. else break fi fi # We have not yet reached the cursor position, stash this message # and try the next. prev_lineno="$lineno" prev_msg="$msg" done # There is no message before the cursor position, # let's wrap around to the end. shift $(( $# - 1 )) last_lineno="${1%%|*}" last_msg="${1#*|}" printf "execute-keys %dg\n" "$last_lineno" printf "info -anchor %d.%d %s\n" \ "$last_lineno" "1" "$(kakquote "$last_msg")" printf "echo -markup \ {Information}lint message search wrapped around buffer\n" } } kakoune-2020.09.01/rc/tools/make.kak000066400000000000000000000074331372342214000167200ustar00rootroot00000000000000declare-option -docstring "shell command run to build the project" \ str makecmd make declare-option -docstring "pattern that describes lines containing information about errors in the output of the `makecmd` command" \ str make_error_pattern " (?:fatal )?error:" declare-option -docstring "name of the client in which utilities display information" \ str toolsclient declare-option -hidden int make_current_error_line define-command -params .. \ -docstring %{ make []: make utility wrapper All the optional arguments are forwarded to the make utility } make %{ evaluate-commands %sh{ output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-make.XXXXXXXX)/fifo mkfifo ${output} ( eval ${kak_opt_makecmd} "$@" > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{ edit! -fifo ${output} -scroll *make* set-option buffer filetype make set-option buffer make_current_error_line 0 hook -always -once buffer BufCloseFifo .* %{ nop %sh{ rm -r $(dirname ${output}) } } }" }} add-highlighter shared/make group add-highlighter shared/make/ regex "^((?:\w:)?[^:\n]+):(\d+):(?:(\d+):)?\h+(?:((?:fatal )?error)|(warning)|(note)|(required from(?: here)?))?.*?$" 1:cyan 2:green 3:green 4:red 5:yellow 6:blue 7:yellow add-highlighter shared/make/ regex "^\h*(~*(?:(\^)~*)?)$" 1:green 2:cyan+b add-highlighter shared/make/ line '%opt{make_current_error_line}' default+b hook -group make-highlight global WinSetOption filetype=make %{ add-highlighter window/make ref make hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/make } } hook global WinSetOption filetype=make %{ hook buffer -group make-hooks NormalKey make-jump hook -once -always window WinSetOption filetype=.* %{ remove-hooks buffer make-hooks } } declare-option -docstring "name of the client in which all source code jumps will be executed" \ str jumpclient define-command -hidden make-open-error -params 4 %{ evaluate-commands -try-client %opt{jumpclient} %{ edit -existing "%arg{1}" %arg{2} %arg{3} echo -markup "{Information}{\}%arg{4}" try %{ focus } } } define-command -hidden make-jump %{ evaluate-commands %{ try %{ execute-keys gl "Entering directory" # Try to parse the error into capture groups, failing on absolute paths execute-keys s "Entering directory [`']([^']+)'.*\n([^:/][^:]*):(\d+):(?:(\d+):)?([^\n]+)\z" l set-option buffer make_current_error_line %val{cursor_line} make-open-error "%reg{1}/%reg{2}" "%reg{3}" "%reg{4}" "%reg{5}" } catch %{ execute-keys s "((?:\w:)?[^:]+):(\d+):(?:(\d+):)?([^\n]+)\z" l set-option buffer make_current_error_line %val{cursor_line} make-open-error "%reg{1}" "%reg{2}" "%reg{3}" "%reg{4}" } } } define-command make-next-error -docstring 'Jump to the next make error' %{ evaluate-commands -try-client %opt{jumpclient} %{ buffer '*make*' execute-keys "%opt{make_current_error_line}ggl" "/^(?:\w:)?[^:\n]+:\d+:(?:\d+:)?%opt{make_error_pattern}" make-jump } try %{ evaluate-commands -client %opt{toolsclient} %{ execute-keys %opt{make_current_error_line}g } } } define-command make-previous-error -docstring 'Jump to the previous make error' %{ evaluate-commands -try-client %opt{jumpclient} %{ buffer '*make*' execute-keys "%opt{make_current_error_line}g" "^(?:\w:)?[^:\n]+:\d+:(?:\d+:)?%opt{make_error_pattern}" make-jump } try %{ evaluate-commands -client %opt{toolsclient} %{ execute-keys %opt{make_current_error_line}g } } } kakoune-2020.09.01/rc/tools/man.kak000066400000000000000000000120241372342214000165460ustar00rootroot00000000000000declare-option -docstring "name of the client in which documentation is to be displayed" \ str docsclient declare-option -hidden str-list manpage hook -group man-highlight global WinSetOption filetype=man %{ add-highlighter window/man-highlight group # Sections add-highlighter window/man-highlight/ regex ^\S.*?$ 0:title # Subsections add-highlighter window/man-highlight/ regex '^ {3}\S.*?$' 0:default+b # Command line options add-highlighter window/man-highlight/ regex '^ {7}-[^\s,]+(,\s+-[^\s,]+)*' 0:list # References to other manpages add-highlighter window/man-highlight/ regex [-a-zA-Z0-9_.]+\([a-z0-9]+\) 0:header map window normal ': man-jump' hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/man-highlight unmap window normal } } hook global WinSetOption filetype=man %{ hook -group man-hooks window WinResize .* %{ man-impl %opt{manpage} } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window man-hooks } } define-command -hidden -params ..3 man-impl %{ evaluate-commands %sh{ buffer_name="$1" if [ -z "${buffer_name}" ]; then exit fi shift manout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX) manerr=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX) colout=$(mktemp "${TMPDIR:-/tmp}"/kak-man-XXXXXX) env MANWIDTH=${kak_window_range##* } man "$@" > "$manout" 2> "$manerr" retval=$? col -b -x > ${colout} < ${manout} rm ${manout} if [ "${retval}" -eq 0 ]; then printf %s\\n " edit -scratch %{*$buffer_name ${*}*} execute-keys '%|cat${colout}gk' nop %sh{ rm ${colout}; rm ${manerr} } set-option buffer filetype man set-option window manpage $buffer_name $* " else printf ' fail %%{%s} nop %%sh{ rm "%s"; rm "%s" } ' "$(cat "$manerr")" "${colout}" "${manerr}" fi } } define-command -params ..1 \ -shell-script-candidates %{ find /usr/share/man/ $(printf %s "${MANPATH}" | sed 's/:/ /') -name '*.[1-8]*' | sed 's,^.*/\(.*\)\.\([1-8][a-zA-Z]*\).*$,\1(\2),' } \ -docstring %{ man []: manpage viewer wrapper If no argument is passed to the command, the selection will be used as page The page can be a word, or a word directly followed by a section number between parenthesis, e.g. kak(1) } man %{ evaluate-commands %sh{ subject=${1-$kak_selection} ## The completion suggestions display the page number, strip them if present case "${subject}" in *\([1-8]*\)) pagenum="${subject##*\(}" pagenum="${pagenum%\)}" subject="${subject%%\(*}" ;; *) pagenum="" ;; esac printf %s\\n "evaluate-commands -try-client %opt{docsclient} man-impl man $pagenum $subject" } } # The following section of code enables a user # to go to next or previous man page links and to follow man page links, # for example, apropos(1), that would normally appear in SEE ALSO sections. # The user would position the cursor on any character of the link # and then press to change to a buffer showing the man page. # Regex pattern defining a man page link. # Used for determining if a selection, which may just be a link, is a link. declare-option -hidden regex man_link1 \ [\w_.:-]+\(\d[a-z]*\) # Same as above but with lookbehind and lookahead patterns. # Used for searching for a man page link. declare-option -hidden regex man_link2 \ "(?:^|(?<=\W))%opt{man_link1}(?=\W)" # Define a useful command sequence for searching a given regex # and a given sequence of search keys. define-command man-search -params 2 %{ set-register / %arg[1] execute-keys %arg[2] } define-command -docstring 'Go to next man page link' \ man-link-next %{ man-search %opt[man_link2] n } define-command -docstring 'Go to previous man page link' \ man-link-prev %{ man-search %opt[man_link2] } # Expand backward and forward, and then try to search for a man page link define-command man-link-here %{ evaluate-commands -save-regs / %{ man-search %opt[man_link2] '\b\w?\)' }} -hidden # Search current selection for a man page link define-command man-link %{ evaluate-commands -save-regs / %{ man-search %opt[man_link1] s }} -hidden define-command -docstring 'Try to jump to a man page' \ man-jump %{ try %{ man-link } catch %{ man-link-here } catch %{ fail 'Not a valid man page link' } try %{ man } catch %{ fail 'No man page link to follow' } } # Suggested keymaps for a user mode declare-user-mode man-mode define-command man-mode-map -params 3 %{ map global man-mode %arg[1] %arg[2] -docstring %arg[3] } -hidden man-mode-map 'g' ': man-jump' 'Jump to a man page using selected man page link' man-mode-map 'j' ': try %{ man-link-next }' 'Go to next man page link' man-mode-map 'k' ': try %{ man-link-prev }' 'Go to previous man page link' man-mode-map 'm' ': man' 'Look up a man page' kakoune-2020.09.01/rc/tools/python/000077500000000000000000000000001372342214000166255ustar00rootroot00000000000000kakoune-2020.09.01/rc/tools/python/jedi.kak000066400000000000000000000045601372342214000202350ustar00rootroot00000000000000hook -once global BufSetOption filetype=python %{ require-module jedi } provide-module jedi %{ declare-option -hidden str jedi_tmp_dir declare-option -hidden completions jedi_completions declare-option -docstring "colon separated list of path added to `python`'s $PYTHONPATH environment variable" \ str jedi_python_path define-command jedi-complete -docstring "Complete the current selection" %{ evaluate-commands %sh{ dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-jedi.XXXXXXXX) mkfifo ${dir}/fifo printf %s\\n "set-option buffer jedi_tmp_dir ${dir}" printf %s\\n "evaluate-commands -no-hooks write -sync ${dir}/buf" } evaluate-commands %sh{ dir=${kak_opt_jedi_tmp_dir} printf %s\\n "evaluate-commands -draft %{ edit! -fifo ${dir}/fifo *jedi-output* }" (( cd $(dirname ${kak_buffile}) header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}" export PYTHONPATH="$kak_opt_jedi_python_path:$PYTHONPATH" compl=$(python 2> "${dir}/fifo" <<-END import jedi script=jedi.Script(open('$dir/buf', 'r').read(), $kak_cursor_line, $kak_cursor_column - 1, '$kak_buffile') print(' '.join(["'" + (str(c.name).replace("|", "\\|") + "|info -style menu %!" + str(c.docstring()).replace("|", "\\|").replace("!", "!!") + "!|" + str(c.name).replace("|", "\\|")).replace("~", "~~").replace("'", "''") + "'" for c in script.completions()])) END ) printf %s\\n "evaluate-commands -client ${kak_client} %~echo completed; set-option %{buffer=${kak_buffile}} jedi_completions ${header} ${compl}~" | kak -p ${kak_session} rm -r ${dir} ) & ) > /dev/null 2>&1 < /dev/null } } define-command jedi-enable-autocomplete -docstring "Add jedi completion candidates to the completer" %{ set-option window completers option=jedi_completions %opt{completers} hook window -group jedi-autocomplete InsertIdle .* %{ try %{ execute-keys -draft \..\z echo 'completing...' jedi-complete } } alias window complete jedi-complete } define-command jedi-disable-autocomplete -docstring "Disable jedi completion" %{ set-option window completers %sh{ printf %s\\n "'${kak_opt_completers}'" | sed -e 's/option=jedi_completions://g' } remove-hooks window jedi-autocomplete unalias window complete jedi-complete } } kakoune-2020.09.01/rc/tools/rust/000077500000000000000000000000001372342214000163015ustar00rootroot00000000000000kakoune-2020.09.01/rc/tools/rust/racer.kak000066400000000000000000000116471372342214000200760ustar00rootroot00000000000000hook -once global BufSetOption filetype=rust %{ require-module racer } provide-module racer %{ declare-option -hidden str racer_tmp_dir declare-option -hidden completions racer_completions define-command racer-complete -docstring "Complete the current selection with racer" %{ evaluate-commands %sh{ dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-racer.XXXXXXXX) printf %s\\n "set-option buffer racer_tmp_dir ${dir}" printf %s\\n "evaluate-commands -no-hooks %{ write ${dir}/buf }" } evaluate-commands %sh{ dir=${kak_opt_racer_tmp_dir} ( cursor="${kak_cursor_line} $((${kak_cursor_column} - 1))" racer_data=$(racer --interface tab-text complete-with-snippet ${cursor} ${kak_buffile} ${dir}/buf) compl=$(printf %s\\n "${racer_data}" | awk ' BEGIN { FS = "\t"; ORS = " " } /^PREFIX/ { column = ENVIRON["kak_cursor_column"] + $2 - $3 print ENVIRON["kak_cursor_line"] "." column "@@" ENVIRON["kak_timestamp"] } /^MATCH/ { word = $2 desc = substr($9, 2, length($9) - 2) gsub(/\|/, "\\|", desc) gsub(/\\n/, "\n", desc) gsub(/!/, "!!", desc) info = $8 gsub(/\|/, "\\|", info) candidate = word "|info -style menu %!" desc "!|" word " {MenuInfo}" info gsub(/@/, "@@", candidate) gsub(/~/, "~~", candidate) print "%~" candidate "~" }' ) printf %s\\n "evaluate-commands -client '${kak_client}' %@ set-option 'buffer=${kak_bufname}' racer_completions ${compl%?} @" | kak -p ${kak_session} rm -r ${dir} ) > /dev/null 2>&1 < /dev/null & } } define-command racer-enable-autocomplete -docstring "Add racer completion candidates to the completer" %{ set-option window completers option=racer_completions %opt{completers} hook window -group racer-autocomplete InsertIdle .* %{ try %{ execute-keys -draft ([\w\.]|::).\z racer-complete } } alias window complete racer-complete } define-command racer-disable-autocomplete -docstring "Disable racer completion" %{ evaluate-commands %sh{ printf "set-option window completers %s\n" $(printf %s "${kak_opt_completers}" | sed -e "s/'option=racer_completions'//g") } remove-hooks window racer-autocomplete unalias window complete racer-complete } define-command racer-go-definition -docstring "Jump to where the rust identifier below the cursor is defined" %{ evaluate-commands %sh{ dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-racer.XXXXXXXX) printf %s\\n "set-option buffer racer_tmp_dir ${dir}" printf %s\\n "evaluate-commands -no-hooks %{ write ${dir}/buf }" } evaluate-commands %sh{ dir=${kak_opt_racer_tmp_dir} cursor="${kak_cursor_line} $((${kak_cursor_column} - 1))" racer_data=$(racer --interface tab-text find-definition ${cursor} "${kak_buffile}" "${dir}/buf" | head -n 1) racer_match=$(printf %s\\n "$racer_data" | cut -f1 ) if [ "$racer_match" = "MATCH" ]; then racer_line=$(printf %s\\n "$racer_data" | cut -f3 ) racer_column=$(printf %s\\n "$racer_data" | cut -f4 ) racer_file=$(printf %s\\n "$racer_data" | cut -f5 ) printf %s\\n "edit -existing '$racer_file' $racer_line $racer_column" case ${racer_file} in "${RUST_SRC_PATH}"* | "${CARGO_HOME:-$HOME/.cargo}"/registry/src/*) printf %s\\n "set-option buffer readonly true";; esac else printf %s\\n "echo -debug 'racer could not find a definition'" fi } } define-command racer-show-doc -docstring "Show the documentation about the rust identifier below the cursor" %{ evaluate-commands %sh{ dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-racer.XXXXXXXX) printf %s\\n "set-option buffer racer_tmp_dir ${dir}" printf %s\\n "evaluate-commands -no-hooks %{ write ${dir}/buf }" } evaluate-commands %sh{ dir=${kak_opt_racer_tmp_dir} cursor="${kak_cursor_line} ${kak_cursor_column}" racer_data=$(racer --interface tab-text complete-with-snippet ${cursor} "${kak_buffile}" "${dir}/buf" | sed -n 2p ) racer_match=$(printf %s\\n "$racer_data" | cut -f1) if [ "$racer_match" = "MATCH" ]; then racer_doc=$( printf %s\\n "$racer_data" | cut -f9 | sed -e ' # Remove leading and trailing quotes s/^"\(.*\)"$/\1/g # Escape all @ so that it can be properly used in the string expansion s/@/\\@/g ') printf "info %%@$racer_doc@" else printf %s\\n "echo -debug 'racer could not find a definition'" fi } } } kakoune-2020.09.01/rc/tools/spell.kak000066400000000000000000000137361372342214000171250ustar00rootroot00000000000000declare-option -hidden range-specs spell_regions declare-option -hidden str spell_last_lang declare-option -hidden str spell_tmp_file declare-option -docstring "default language to use when none is passed to the spell-check command" str spell_lang define-command -params ..1 -docstring %{ spell []: spell check the current buffer The first optional argument is the language against which the check will be performed (overrides `spell_lang`) Formats of language supported: - ISO language code, e.g. 'en' - language code above followed by a dash or underscore with an ISO country code, e.g. 'en-US' } spell %{ try %{ add-highlighter window/ ranges 'spell_regions' } evaluate-commands %sh{ file=$(mktemp -d "${TMPDIR:-/tmp}"/kak-spell.XXXXXXXX)/buffer printf 'eval -no-hooks write -sync %s\n' "${file}" printf 'set-option buffer spell_tmp_file %s\n' "${file}" } evaluate-commands %sh{ use_lang() { if ! printf %s "$1" | grep -qE '^[a-z]{2,3}([_-][A-Z]{2})?$'; then echo "fail 'Invalid language code (examples of expected format: en, en_US, en-US)'" rm -rf "$(dirname "$kak_opt_spell_tmp_file")" exit 1 else options="-l '$1'" printf 'set-option buffer spell_last_lang %s\n' "$1" fi } if [ $# -ge 1 ]; then use_lang "$1" elif [ -n "${kak_opt_spell_lang}" ]; then use_lang "${kak_opt_spell_lang}" fi { sed 's/^/^/' "$kak_opt_spell_tmp_file" | eval "aspell --byte-offsets -a $options" 2>&1 | awk ' BEGIN { line_num = 1 regions = ENVIRON["kak_timestamp"] server_command = sprintf("kak -p \"%s\"", ENVIRON["kak_session"]) } { if (/^@\(#\)/) { # drop the identification message } else if (/^\*/) { # nothing } else if (/^$/) { line_num++ } else if (/^[#&]/) { word_len = length($2) word_pos = substr($0, 1, 1) == "&" ? substr($4, 1, length($4) - 1) : $3; regions = regions " " line_num "." word_pos "+" word_len "|Error" } else { line = $0 gsub(/"/, "&&", line) command = "fail \"" line "\"" exit } } END { if (!length(command)) command = "set-option \"buffer=" ENVIRON["kak_bufname"] "\" spell_regions " regions print command | server_command close(server_command) } ' rm -rf $(dirname "$kak_opt_spell_tmp_file") } /dev/null 2>&1 & } } define-command spell-clear %{ unset-option buffer spell_regions } define-command spell-next %{ evaluate-commands %sh{ anchor_line="${kak_selection_desc%%.*}" anchor_col="${kak_selection_desc%%,*}" anchor_col="${anchor_col##*.}" start_first="${kak_opt_spell_regions%%|*}" start_first="${start_first#* }" # Make sure properly formatted selection descriptions are in `%opt{spell_regions}` if ! printf %s "${start_first}" | grep -qE '^[0-9]+\.[0-9]+,[0-9]+\.[0-9]+$'; then exit fi printf %s "${kak_opt_spell_regions#* }" | awk -v start_first="${start_first}" \ -v anchor_line="${anchor_line}" \ -v anchor_col="${anchor_col}" ' BEGIN { anchor_line = int(anchor_line) anchor_col = int(anchor_col) } { for (i = 1; i <= NF; i++) { sel = $i sub(/\|.+$/, "", sel) start_line = sel sub(/\..+$/, "", start_line) start_line = int(start_line) start_col = sel sub(/,.+$/, "", start_col) sub(/^.+\./, "", start_col) start_col = int(start_col) if (start_line < anchor_line \ || (start_line == anchor_line && start_col <= anchor_col)) continue target_sel = sel break } } END { if (!target_sel) target_sel = start_first printf "select %s\n", target_sel }' } } define-command \ -docstring "Suggest replacement words for the current selection, against the last language used by the spell-check command" \ spell-replace %{ evaluate-commands %sh{ options="" if [ -n "$kak_opt_spell_last_lang" ]; then options="-l '$kak_opt_spell_last_lang'" fi suggestions=$(printf %s "$kak_selection" | eval "aspell -a $options" | grep '^&' | cut -d: -f2) menu=$(printf %s "${suggestions#?}" | awk -F', ' ' { for (i=1; i<=NF; i++) printf "%s", "%{"$i"}" "%{execute-keys -itersel %{c"$i"be}}" } ') printf 'try %%{ menu -auto-single %s }' "${menu}" } } define-command -params 0.. \ -docstring "Add the current selection to the dictionary" \ spell-add %{ evaluate-commands %sh{ options="" if [ -n "$kak_opt_spell_last_lang" ]; then options="-l '$kak_opt_spell_last_lang'" fi if [ $# -eq 0 ]; then # use selections eval set -- "$kak_quoted_selections" fi while [ $# -gt 0 ]; do word="$1" if ! printf '*%s\n#\n' "${word}" | eval "aspell -a $options" >/dev/null; then printf 'fail "Unable to add word: %s"' "$(printf %s "${word}" | sed 's/"/&&/g')" exit 1 fi shift done }} kakoune-2020.09.01/rc/windowing/000077500000000000000000000000001372342214000161515ustar00rootroot00000000000000kakoune-2020.09.01/rc/windowing/detection.kak000066400000000000000000000031021372342214000206130ustar00rootroot00000000000000# Attempt to detect the windowing environment we're operating in # # We try to load modules from the windowing_modules str-list option in order, # stopping when one of the modules loads successfully. This ensures that only # a single module is loaded by default. # # On load each module must attempt to detect the environment it's appropriate # for, and if the environment isn't appropriate it must fail with an error. # In addition, each module must check for the length of the windowing_modules # str-list option defined below, and must /not/ check for an appropriate # environment if the list is empty. An example of this test: # # evaluate-commands %sh{ # [ -z "${kak_opt_windowing_modules}" ] || [ -n "$TMUX" ] || echo 'fail tmux not detected' # } # # Each module is expected to define at least two aliases: # * terminal - create a new terminal with sensible defaults # * focus - focus the specified client, defaulting to the current client # declare-option -docstring \ "Ordered list of windowing modules to try and load. An empty list disables both automatic module loading and environment detection, enabling complete manual control of the module loading." \ str-list windowing_modules 'tmux' 'screen' 'kitty' 'iterm' 'x11' hook -group windowing global KakBegin .* %{ evaluate-commands %sh{ set -- ${kak_opt_windowing_modules} if [ $# -gt 0 ]; then echo 'try %{ ' while [ $# -gt 1 ]; do echo "require-module ${1} } catch %{ " shift done echo "require-module ${1} }" fi } } kakoune-2020.09.01/rc/windowing/iterm.kak000066400000000000000000000126561372342214000177730ustar00rootroot00000000000000# https://www.iterm2.com # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ provide-module iterm %{ # ensure that we're running on iTerm evaluate-commands %sh{ [ -z "${kak_opt_windowing_modules}" ] || [ "$TERM_PROGRAM" = "iTerm.app" ] || echo 'fail iTerm not detected' } define-command -hidden -params 2.. iterm-terminal-split-impl %{ nop %sh{ direction="$1" shift # join the arguments as one string for the shell execution (see x11.kak) args=$( for i in "$@"; do if [ "$i" = '' ]; then printf "'' " else printf %s "$i" | sed -e "s|'|'\\\\''|g; s|^|'|; s|$|' |" fi done ) # go through another round of escaping for osascript # \ -> \\ # " -> \" escaped=$(printf %s "$args" | sed -e 's|\\|\\\\|g; s|"|\\"|g') cmd="env PATH='${PATH}' TMPDIR='${TMPDIR}' $escaped" osascript \ -e "tell application \"iTerm\"" \ -e " tell current session of current window" \ -e " tell (split ${direction} with same profile command \"${cmd}\") to select" \ -e " end tell" \ -e "end tell" >/dev/null } } define-command iterm-terminal-vertical -params 1.. -shell-completion -docstring ' iterm-terminal-vertical []: create a new terminal as an iterm pane The current pane is split into two, left and right The program passed as argument will be executed in the new terminal'\ %{ iterm-terminal-split-impl 'vertically' %arg{@} } define-command iterm-terminal-horizontal -params 1.. -shell-completion -docstring ' iterm-terminal-horizontal []: create a new terminal as an iterm pane The current pane is split into two, top and bottom The program passed as argument will be executed in the new terminal'\ %{ iterm-terminal-split-impl 'horizontally' %arg{@} } define-command iterm-terminal-tab -params 1.. -shell-completion -docstring ' iterm-terminal-tab []: create a new terminal as an iterm tab The program passed as argument will be executed in the new terminal'\ %{ nop %sh{ # see above args=$( for i in "$@"; do if [ "$i" = '' ]; then printf "'' " else printf %s "$i" | sed -e "s|'|'\\\\''|g; s|^|'|; s|$|' |" fi done ) escaped=$(printf %s "$args" | sed -e 's|\\|\\\\|g; s|"|\\"|g') cmd="env PATH='${PATH}' TMPDIR='${TMPDIR}' $escaped" osascript \ -e "tell application \"iTerm\"" \ -e " tell current window" \ -e " create tab with default profile command \"${cmd}\"" \ -e " end tell" \ -e "end tell" >/dev/null } } define-command iterm-terminal-window -params 1.. -shell-completion -docstring ' iterm-terminal-window []: create a new terminal as an iterm window The program passed as argument will be executed in the new terminal'\ %{ nop %sh{ # see above args=$( for i in "$@"; do if [ "$i" = '' ]; then printf "'' " else printf %s "$i" | sed -e "s|'|'\\\\''|g; s|^|'|; s|$|' |" fi done ) escaped=$(printf %s "$args" | sed -e 's|\\|\\\\|g; s|"|\\"|g') cmd="env PATH='${PATH}' TMPDIR='${TMPDIR}' $escaped" osascript \ -e "tell application \"iTerm\"" \ -e " create window with default profile command \"${cmd}\"" \ -e "end tell" >/dev/null } } define-command iterm-focus -params ..1 -client-completion -docstring ' iterm-focus []: focus the given client If no client is passed then the current one is used' \ %{ evaluate-commands %sh{ if [ $# -eq 1 ]; then printf %s\\n "evaluate-commands -client '$1' focus" else session="${kak_client_env_ITERM_SESSION_ID#*:}" osascript \ -e "tell application \"iTerm\" to repeat with aWin in windows" \ -e " tell aWin to repeat with aTab in tabs" \ -e " tell aTab to repeat with aSession in sessions" \ -e " tell aSession" \ -e " if (unique id = \"${session}\") then" \ -e " select" \ -e " end if" \ -e " end tell" \ -e " end repeat" \ -e " end repeat" \ -e "end repeat" fi } } alias global focus iterm-focus alias global terminal iterm-terminal-vertical } kakoune-2020.09.01/rc/windowing/kitty.kak000066400000000000000000000033561372342214000200140ustar00rootroot00000000000000# https://sw.kovidgoyal.net/kitty/index.html # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ provide-module kitty %{ # ensure that we're running on kitty evaluate-commands %sh{ [ -z "${kak_opt_windowing_modules}" ] || [ "$TERM" = "xterm-kitty" ] || echo 'fail Kitty not detected' } declare-option -docstring %{window type that kitty creates on new and repl calls (kitty|os)} str kitty_window_type kitty define-command kitty-terminal -params 1.. -shell-completion -docstring ' kitty-terminal []: create a new terminal as a kitty window The program passed as argument will be executed in the new terminal' \ %{ nop %sh{ kitty @ new-window --no-response --window-type $kak_opt_kitty_window_type --cwd "$PWD" "$@" } } define-command kitty-terminal-tab -params 1.. -shell-completion -docstring ' kitty-terminal-tab []: create a new terminal as kitty tab The program passed as argument will be executed in the new terminal' \ %{ nop %sh{ kitty @ new-window --no-response --new-tab --cwd "$PWD" "$@" } } define-command kitty-focus -params ..1 -client-completion -docstring ' kitty-focus []: focus the given client If no client is passed then the current one is used' \ %{ evaluate-commands %sh{ if [ $# -eq 1 ]; then printf "evaluate-commands -client '%s' focus" "$1" else kitty @ focus-tab --no-response -m=id:$kak_client_env_KITTY_WINDOW_ID kitty @ focus-window --no-response -m=id:$kak_client_env_KITTY_WINDOW_ID fi } } alias global terminal kitty-terminal alias global terminal-tab kitty-terminal-tab alias global focus kitty-focus } kakoune-2020.09.01/rc/windowing/new-client.kak000066400000000000000000000006531372342214000207120ustar00rootroot00000000000000define-command new -params .. -command-completion -docstring ' new []: create a new kakoune client The ''terminal'' alias is being used to determine the user''s preferred terminal emulator The optional arguments are passed as commands to the new client' \ %{ try %{ terminal kak -c %val{session} -e "%arg{@}" } catch %{ fail "The 'terminal' alias must be defined to use this command" } } kakoune-2020.09.01/rc/windowing/repl/000077500000000000000000000000001372342214000171135ustar00rootroot00000000000000kakoune-2020.09.01/rc/windowing/repl/kitty.kak000066400000000000000000000020721372342214000207500ustar00rootroot00000000000000hook global ModuleLoaded kitty %{ require-module kitty-repl } provide-module kitty-repl %{ define-command -params .. -shell-completion \ -docstring %{ kitty-repl []: Create a new window for repl interaction. All optional parameters are forwarded to the new window. } \ kitty-repl %{ nop %sh{ if [ $# -eq 0 ]; then cmd="${SHELL:-/bin/sh}" else cmd="$*" fi kitty @ new-window --no-response --window-type $kak_opt_kitty_window_type --title kak_repl_window --cwd "$PWD" $cmd < /dev/null > /dev/null 2>&1 & } } define-command -hidden -params 0..1 \ -docstring %{ kitty-send-text [text]: Send text to the REPL window. If no text is passed, the selection is used. } \ kitty-send-text %{ nop %sh{ if [ $# -eq 0 ]; then text="$kak_selection" else text="$1" fi kitty @ send-text -m=title:kak_repl_window "$text" } } alias global repl kitty-repl alias global send-text kitty-send-text } kakoune-2020.09.01/rc/windowing/repl/tmux.kak000066400000000000000000000034171372342214000206050ustar00rootroot00000000000000# http://tmux.github.io/ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Tmux version >= 2 is required to use this module hook global ModuleLoaded tmux %{ require-module tmux-repl } provide-module tmux-repl %{ declare-option -docstring "tmux pane id in which the REPL is running" str tmux_repl_id define-command -hidden -params 1.. tmux-repl-impl %{ evaluate-commands %sh{ if [ -z "$TMUX" ]; then echo 'fail This command is only available in a tmux session' exit fi tmux_args="$1" shift tmux $tmux_args "$@" printf "set-option global tmux_repl_id '%s'" $(tmux display-message -p '#{session_id}:#{window_id}.#{pane_id}') } } define-command tmux-repl-vertical -params 0.. -command-completion -docstring "Create a new vertical pane for repl interaction" %{ tmux-repl-impl 'split-window -v' %arg{@} } define-command tmux-repl-horizontal -params 0.. -command-completion -docstring "Create a new horizontal pane for repl interaction" %{ tmux-repl-impl 'split-window -h' %arg{@} } define-command tmux-repl-window -params 0.. -command-completion -docstring "Create a new window for repl interaction" %{ tmux-repl-impl 'new-window' %arg{@} } define-command -hidden tmux-send-text -params 0..1 -docstring %{ tmux-send-text [text]: Send text(append new line) to the REPL pane. If no text is passed, then the selection is used } %{ nop %sh{ if [ $# -eq 0 ]; then tmux set-buffer -b kak_selection "${kak_selection}" else tmux set-buffer -b kak_selection "$1" fi tmux paste-buffer -b kak_selection -t "$kak_opt_tmux_repl_id" } } alias global repl tmux-repl-horizontal alias global send-text tmux-send-text } kakoune-2020.09.01/rc/windowing/repl/x11.kak000066400000000000000000000023771372342214000202250ustar00rootroot00000000000000hook global ModuleLoaded x11 %{ require-module x11-repl } provide-module x11-repl %{ # termcmd should already be set in x11.kak define-command -docstring %{ x11-repl []: create a new window for repl interaction All optional parameters are forwarded to the new window } \ -params .. \ -shell-completion \ x11-repl %{ evaluate-commands %sh{ if [ -z "${kak_opt_termcmd}" ]; then echo 'fail termcmd option is not set' exit fi if [ $# -eq 0 ]; then cmd="${SHELL:-sh}"; else cmd="$@"; fi # The escape sequence in the printf command sets the terminal's title: setsid ${kak_opt_termcmd} "printf '\e]2;kak_repl_window\a' \ && ${cmd}" < /dev/null > /dev/null 2>&1 & }} define-command x11-send-text -docstring "send the selected text to the repl window" %{ evaluate-commands %sh{ printf %s\\n "${kak_selection}" | xsel -i || echo 'fail x11-send-text: failed to run xsel, see *debug* buffer for details' && xdotool search --name kak_repl_window key --clearmodifiers Shift+Insert || echo 'fail x11-send-text: failed to run xdotool, see *debug* buffer for details' } } alias global repl x11-repl alias global send-text x11-send-text } kakoune-2020.09.01/rc/windowing/screen.kak000066400000000000000000000050511372342214000201210ustar00rootroot00000000000000# http://gnu.org/software/screen/ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ provide-module screen %{ # ensure that we're running under screen evaluate-commands %sh{ [ -z "${kak_opt_windowing_modules}" ] || [ -n "$STY" ] || echo 'fail screen not detected' } define-command screen-terminal-impl -hidden -params 3.. %{ nop %sh{ tty="$(ps -o tty ${kak_client_pid} | tail -n 1)" screen -X eval "$1" "$2" shift 2 # see x11.kak for what this achieves args=$( for i in "$@"; do if [ "$i" = '' ]; then printf "'' " else printf %s "$i" | sed -e "s|'|'\\\\''|g; s|^|'|; s|$|' |" fi done ) screen -X screen sh -c "${args} ; screen -X remove" < "/dev/$tty" } } define-command screen-terminal-vertical -params 1.. -shell-completion -docstring ' screen-terminal-vertical [] []: create a new terminal as a screen pane The current pane is split into two, left and right The program passed as argument will be executed in the new terminal' \ %{ screen-terminal-impl 'split -v' 'focus right' %arg{@} } define-command screen-terminal-horizontal -params 1.. -shell-completion -docstring ' screen-terminal-horizontal []: create a new terminal as a screen pane The current pane is split into two, top and bottom The program passed as argument will be executed in the new terminal' \ %{ screen-terminal-impl 'split -h' 'focus down' %arg{@} } define-command screen-terminal-window -params 1.. -shell-completion -docstring ' screen-terminal-window []: create a new terminal as a screen window The program passed as argument will be executed in the new terminal' \ %{ nop %sh{ tty="$(ps -o tty ${kak_client_pid} | tail -n 1)" screen -X screen "$@" < "/dev/$tty" } } define-command screen-focus -params ..1 -client-completion -docstring ' screen-focus []: focus the given client If no client is passed then the current one is used' \ %{ evaluate-commands %sh{ if [ $# -eq 1 ]; then printf %s\\n " evaluate-commands -client '$1' focus " elif [ -n "${kak_client_env_STY}" ]; then tty="$(ps -o tty ${kak_client_pid} | tail -n 1)" screen -X select "${kak_client_env_WINDOW}" < "/dev/$tty" fi } } alias global focus screen-focus alias global terminal screen-terminal-vertical } kakoune-2020.09.01/rc/windowing/tmux.kak000066400000000000000000000050041372342214000176350ustar00rootroot00000000000000# http://tmux.github.io/ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ provide-module tmux %{ # ensure we're running under tmux evaluate-commands %sh{ [ -z "${kak_opt_windowing_modules}" ] || [ -n "$TMUX" ] || echo 'fail tmux not detected' } define-command -hidden -params 2.. tmux-terminal-impl %{ evaluate-commands %sh{ tmux=${kak_client_env_TMUX:-$TMUX} if [ -z "$tmux" ]; then echo "fail 'This command is only available in a tmux session'" exit fi tmux_args="$1" if [ "${1%%-*}" = split ]; then tmux_args="$tmux_args -t ${kak_client_env_TMUX_PANE}" fi shift # ideally we should escape single ';' to stop tmux from interpreting it as a new command # but that's probably too rare to care TMUX=$tmux tmux $tmux_args env TMPDIR="$TMPDIR" "$@" < /dev/null > /dev/null 2>&1 & } } define-command tmux-terminal-vertical -params 1.. -shell-completion -docstring ' tmux-terminal-vertical []: create a new terminal as a tmux pane The current pane is split into two, top and bottom The program passed as argument will be executed in the new terminal' \ %{ tmux-terminal-impl 'split-window -v' %arg{@} } define-command tmux-terminal-horizontal -params 1.. -shell-completion -docstring ' tmux-terminal-horizontal []: create a new terminal as a tmux pane The current pane is split into two, left and right The program passed as argument will be executed in the new terminal' \ %{ tmux-terminal-impl 'split-window -h' %arg{@} } define-command tmux-terminal-window -params 1.. -shell-completion -docstring ' tmux-terminal-window [] []: create a new terminal as a tmux window The program passed as argument will be executed in the new terminal' \ %{ tmux-terminal-impl 'new-window' %arg{@} } define-command tmux-focus -params ..1 -client-completion -docstring ' tmux-focus []: focus the given client If no client is passed then the current one is used' \ %{ evaluate-commands %sh{ if [ $# -eq 1 ]; then printf "evaluate-commands -client '%s' focus" "$1" elif [ -n "${kak_client_env_TMUX}" ]; then TMUX="${kak_client_env_TMUX}" tmux select-pane -t "${kak_client_env_TMUX_PANE}" > /dev/null fi } } ## The default behaviour for the `new` command is to open an horizontal pane in a tmux session alias global focus tmux-focus alias global terminal tmux-terminal-horizontal } kakoune-2020.09.01/rc/windowing/x11.kak000066400000000000000000000045051372342214000172560ustar00rootroot00000000000000# x11 provide-module x11 %{ # ensure that we're running in the right environment evaluate-commands %sh{ [ -z "${kak_opt_windowing_modules}" ] || [ -n "$DISPLAY" ] || echo 'fail DISPLAY is not set' } # termcmd should be set such as the next argument is the whole # command line to execute declare-option -docstring %{shell command run to spawn a new terminal A shell command is appended to the one set in this option at runtime} \ str termcmd %sh{ for termcmd in 'alacritty -e sh -c' \ 'kitty sh -c' \ 'termite -e ' \ 'urxvt -e sh -c' \ 'rxvt -e sh -c' \ 'st -e sh -c' \ 'xterm -e sh -c' \ 'roxterm -e sh -c' \ 'mintty -e sh -c' \ 'sakura -x ' \ 'gnome-terminal -e ' \ 'xfce4-terminal -e ' \ 'konsole -e '; do terminal=${termcmd%% *} if command -v $terminal >/dev/null 2>&1; then printf %s\\n "$termcmd" exit fi done } define-command x11-terminal -params 1.. -shell-completion -docstring ' x11-terminal []: create a new terminal as an x11 window The program passed as argument will be executed in the new terminal' \ %{ evaluate-commands -save-regs 'a' %{ set-register a %arg{@} evaluate-commands %sh{ if [ -z "${kak_opt_termcmd}" ]; then echo "fail 'termcmd option is not set'" exit fi setsid ${kak_opt_termcmd} "$kak_quoted_reg_a" < /dev/null > /dev/null 2>&1 & } } } define-command x11-focus -params ..1 -client-completion -docstring ' x11-focus []: focus a given client''s window If no client is passed, then the current client is used' \ %{ evaluate-commands %sh{ if [ $# -eq 1 ]; then printf "evaluate-commands -client '%s' focus" "$1" else xdotool windowactivate $kak_client_env_WINDOWID > /dev/null || echo 'fail failed to run x11-focus, see *debug* buffer for details' fi } } alias global focus x11-focus alias global terminal x11-terminal } kakoune-2020.09.01/share/000077500000000000000000000000001372342214000146425ustar00rootroot00000000000000kakoune-2020.09.01/share/kak/000077500000000000000000000000001372342214000154105ustar00rootroot00000000000000kakoune-2020.09.01/share/kak/autoload000077700000000000000000000000001372342214000201132../../rcustar00rootroot00000000000000kakoune-2020.09.01/share/kak/colors000077700000000000000000000000001372342214000205012../../colorsustar00rootroot00000000000000kakoune-2020.09.01/share/kak/doc000077700000000000000000000000001372342214000203672../../doc/pages/ustar00rootroot00000000000000kakoune-2020.09.01/share/kak/gdb000077700000000000000000000000001372342214000172462../../gdb/ustar00rootroot00000000000000kakoune-2020.09.01/share/kak/kakrc000066400000000000000000000027231372342214000164320ustar00rootroot00000000000000def -params 1 -docstring "colorscheme : enable named colorscheme" \ -shell-script-candidates %{ find -L "${kak_runtime}/colors" "${kak_config}/colors" -type f -name '*\.kak' \ | while read -r filename; do basename="${filename##*/}" printf %s\\n "${basename%.*}" done | sort -u } \ colorscheme %{ evaluate-commands %sh{ find_colorscheme() { find -L "${1}" -type f -name "${2}".kak | head -n 1 } filename="" if [ -d "${kak_config}/colors" ]; then filename=$(find_colorscheme "${kak_config}/colors" "${1}") fi if [ -z "${filename}" ]; then filename=$(find_colorscheme "${kak_runtime}/colors" "${1}") fi if [ -n "${filename}" ]; then printf 'source %%{%s}' "${filename}" else echo "fail 'No such colorscheme'" fi }} evaluate-commands %sh{ autoload_directory() { find -L "$1" -type f -name '*\.kak' \ | sed 's/.*/try %{ source "&" } catch %{ echo -debug Autoload: could not load "&" }/' } echo "colorscheme default" if [ -d "${kak_config}/autoload" ]; then autoload_directory ${kak_config}/autoload elif [ -d "${kak_runtime}/autoload" ]; then autoload_directory ${kak_runtime}/autoload fi if [ -f "${kak_runtime}/kakrc.local" ]; then echo "source '${kak_runtime}/kakrc.local'" fi if [ -f "${kak_config}/kakrc" ]; then echo "source '${kak_config}/kakrc'" fi } kakoune-2020.09.01/share/kak/rc000077700000000000000000000000001372342214000167072../../rcustar00rootroot00000000000000kakoune-2020.09.01/src/000077500000000000000000000000001372342214000143275ustar00rootroot00000000000000kakoune-2020.09.01/src/.gdbinit000066400000000000000000000000611372342214000157450ustar00rootroot00000000000000set print pretty break Kakoune::on_assert_failed kakoune-2020.09.01/src/Makefile000066400000000000000000000124601372342214000157720ustar00rootroot00000000000000debug ?= no static ?= no gzip_man ?= yes # to get format compatible with GitHub archive use "gzip -S .gz" here compress_bin ?= bzip2 ifneq ($(gzip_man),yes) ifneq ($(gzip_man),no) $(error gzip_man should be either yes or no) endif endif ifeq ($(debug),yes) CPPFLAGS += -DKAK_DEBUG CXXFLAGS += -O0 suffix := .debug else ifeq ($(debug),no) CXXFLAGS += -O3 suffix := .opt else $(error debug should be either yes or no) endif endif ifneq (,$(findstring address,$(sanitize))) CXXFLAGS += -fsanitize=address LDFLAGS += -lasan sanitize_suffix := $(sanitize_suffix)a endif ifneq (,$(findstring undefined,$(sanitize))) CXXFLAGS += -fsanitize=undefined LDFLAGS += -lubsan sanitize_suffix := $(sanitize_suffix)u endif ifneq (,$(sanitize_suffix)) suffix := $(suffix).san_$(sanitize_suffix) endif version ?= $(shell if [ -f .version ]; then cat .version; elif [ -d ../.git ]; then git describe --tags HEAD; else echo "unknown"; fi) sources := $(sort $(wildcard *.cc)) objects := $(addprefix ., $(sources:.cc=$(suffix).o)) deps := $(addprefix ., $(sources:.cc=$(suffix).d)) PKG_CONFIG ?= $(shell command -v pkg-config 2>/dev/null) ifeq ($(static),yes) PKG_CONFIG_FLAGS += --static LDFLAGS += -static -pthread endif PREFIX ?= /usr/local DESTDIR ?= # root dir bindir := $(DESTDIR)$(PREFIX)/bin sharedir := $(DESTDIR)$(PREFIX)/share/kak docdir := $(DESTDIR)$(PREFIX)/share/doc/kak mandir := $(DESTDIR)$(PREFIX)/share/man/man1 os := $(shell uname) ifeq ($(os),Darwin) LIBS += -lncurses NCURSES_CFLAGS += -I$(PREFIX)/opt/ncurses/include CPPFLAGS += -I/opt/local/include LDFLAGS += -L$(PREFIX)/opt/ncurses/lib -L/opt/local/lib else ifeq ($(os),FreeBSD) LIBS += -ltinfow -lncursesw CPPFLAGS += -I/usr/local/include LDFLAGS += -L/usr/local/lib else ifeq ($(os),Haiku) LIBS += -lncursesw -lnetwork -lbe else ifeq ($(os),OpenBSD) LIBS += -lncursesw CPPFLAGS += -D'KAK_BIN_PATH="$(bindir)/kak"' -I/usr/local/include LDFLAGS += -L/usr/local/lib mandir := $(DESTDIR)$(PREFIX)/man/man1 else ifneq (,$(findstring CYGWIN,$(os))) CPPFLAGS += -D_XOPEN_SOURCE=700 LIBS += -lncursesw -ldbghelp else ifeq ($(PKG_CONFIG),) $(error "pkg-config not found in PATH") endif LIBS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs ncursesw) NCURSES_CFLAGS += $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags ncursesw) LDFLAGS += -rdynamic endif CXXFLAGS += -pedantic -std=c++17 -g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-address compiler := $(shell $(CXX) --version) ifneq (,$(findstring clang,$(compiler))) CXXFLAGS += -frelaxed-template-template-args else ifneq (,$(findstring g++,$(compiler))) CXXFLAGS += -Wno-init-list-lifetime endif all : kak kak : kak$(suffix) ln -sf $< $@ kak$(suffix) : $(objects) .version.o $(CXX) $(LDFLAGS) $(CXXFLAGS) $(objects) .version.o $(LIBS) -o $@ -include $(deps) .%$(suffix).o: %.cc $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF $(addprefix ., $(<:.cc=$(suffix).d)) -c -o $@ $< .ncurses_ui$(suffix).o: CPPFLAGS += $(NCURSES_CFLAGS) .version.o: .version.cc $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< .version.cc: FORCE @printf "%s" 'namespace Kakoune { const char* version = "$(version)"; }' > .version.cc.tmp @if cmp -s .version.cc.tmp .version.cc; then rm .version.cc.tmp; else mv .version.cc.tmp .version.cc; fi # Generate the man page ifeq ($(gzip_man),yes) ../doc/kak.1.gz: ../doc/kak.1 gzip -n -9 -f < $< > $@ man: ../doc/kak.1.gz else man: ../doc/kak.1 endif check: test test: kak cd ../test && ./run TAGS: tags tags: ctags -R clean: rm -f $(objects) $(deps) dist: @if ! [ -d ../.git ]; then echo "make dist can only run from a git repo"; false; fi @if git status -s | grep -qEv '^\?\?'; then echo "working tree is not clean"; false; fi cd ../; \ basename="kakoune-$$(echo "$(version)" | sed -e s/^v//)"; \ git archive --format=tar --prefix=$${basename}/ HEAD -o $${basename}.tar; \ echo "$(version)" > src/.version; \ tar --transform "s,^,$${basename}/," -rf $${basename}.tar src/.version; \ rm src/.version; \ $(compress_bin) $${basename}.tar; distclean: clean rm -f kak kak$(suffix) find ../doc -type f \( -name \*\\.gz -o -name \*\\.1 \) -exec rm -f '{}' + installdirs: install -d $(bindir) \ $(sharedir)/rc \ $(sharedir)/colors \ $(sharedir)/doc \ $(docdir) \ $(mandir) install: kak man installdirs install -m 0755 kak $(bindir) install -m 0644 ../share/kak/kakrc $(sharedir) install -m 0644 ../doc/pages/*.asciidoc $(sharedir)/doc cp -r ../rc/* $(sharedir)/rc find $(sharedir)/rc -type f -exec chmod 0644 {} + [ -e $(sharedir)/autoload ] || ln -s rc $(sharedir)/autoload install -m 0644 ../colors/* $(sharedir)/colors install -m 0644 ../README.asciidoc $(docdir) ifeq ($(gzip_man),yes) install -m 0644 ../doc/kak.1.gz $(mandir) else install -m 0644 ../doc/kak.1 $(mandir) endif install-strip: install strip -s $(bindir)/kak uninstall: rm -rf $(bindir)/kak \ $(sharedir) \ $(docdir) \ $(mandir)/kak.1.gz \ $(mandir)/kak.1 .PHONY: check TAGS clean dist distclean installdirs install install-strip uninstall .PHONY: tags test man kak FORCE kakoune-2020.09.01/src/alias_registry.cc000066400000000000000000000021251372342214000176570ustar00rootroot00000000000000#include "alias_registry.hh" #include "command_manager.hh" #include "ranges.hh" namespace Kakoune { void AliasRegistry::add_alias(String alias, String command) { kak_assert(not alias.empty()); kak_assert(CommandManager::instance().command_defined(command)); auto it = m_aliases.find(alias); if (it == m_aliases.end()) m_aliases.insert({std::move(alias), std::move(command) }); else it->value = std::move(command); } void AliasRegistry::remove_alias(StringView alias) { m_aliases.remove(alias); } StringView AliasRegistry::operator[](StringView alias) const { auto it = m_aliases.find(alias); if (it != m_aliases.end()) return it->value; else if (m_parent) return (*m_parent)[alias]; else return StringView{}; } Vector AliasRegistry::aliases_for(StringView command) const { Vector res; if (m_parent) res = m_parent->aliases_for(command); for (auto& alias : m_aliases) { if (alias.value == command) res.emplace_back(alias.key); } return res; } } kakoune-2020.09.01/src/alias_registry.hh000066400000000000000000000024711372342214000176750ustar00rootroot00000000000000#ifndef alias_registry_hh_INCLUDED #define alias_registry_hh_INCLUDED #include "safe_ptr.hh" #include "string.hh" #include "hash_map.hh" namespace Kakoune { class AliasRegistry : public SafeCountable { public: AliasRegistry(AliasRegistry& parent) : SafeCountable{}, m_parent(&parent) {} void add_alias(String alias, String command); void remove_alias(StringView alias); StringView operator[](StringView alias) const; Vector aliases_for(StringView command) const; auto flatten_aliases() const { auto merge = [](auto&& first, const AliasMap& second) { return concatenated(std::forward(first) | filter([&second](auto& i) { return not second.contains(i.key); }), second); }; static const AliasMap empty; auto& parent = m_parent ? m_parent->m_aliases : empty; auto& grand_parent = (m_parent and m_parent->m_parent) ? m_parent->m_parent->m_aliases : empty; return merge(merge(grand_parent, parent), m_aliases); } private: friend class Scope; AliasRegistry() = default; SafePtr m_parent; using AliasMap = HashMap; AliasMap m_aliases; }; } #endif // alias_registry_hh_INCLUDED kakoune-2020.09.01/src/array_view.hh000066400000000000000000000051221372342214000170200ustar00rootroot00000000000000#ifndef array_view_hh_INCLUDED #define array_view_hh_INCLUDED #include #include namespace Kakoune { // An ArrayView provides a typed, non owning view of a memory // range with an interface similar to std::vector. template class ArrayView { public: using size_t = std::size_t; constexpr ArrayView() : m_pointer(nullptr), m_size(0) {} constexpr ArrayView(T& oneval) : m_pointer(&oneval), m_size(1) {} constexpr ArrayView(T* pointer, size_t size) : m_pointer(pointer), m_size(size) {} constexpr ArrayView(T* begin, T* end) : m_pointer(begin), m_size(end - begin) {} template constexpr ArrayView(T(&array)[N]) : m_pointer(array), m_size(N) {} template().data())) == sizeof(T)>> constexpr ArrayView(Container&& c) : m_pointer(c.data()), m_size(c.size()) {} constexpr ArrayView(const std::initializer_list& v) : m_pointer(v.begin()), m_size(v.size()) {} constexpr T* pointer() const { return m_pointer; } constexpr size_t size() const { return m_size; } [[gnu::always_inline]] constexpr T& operator[](size_t n) const { return *(m_pointer + n); } constexpr T* begin() const { return m_pointer; } constexpr T* end() const { return m_pointer+m_size; } using reverse_iterator = std::reverse_iterator; constexpr reverse_iterator rbegin() const { return reverse_iterator(m_pointer+m_size); } constexpr reverse_iterator rend() const { return reverse_iterator(m_pointer); } constexpr T& front() const { return *m_pointer; } constexpr T& back() const { return *(m_pointer + m_size - 1); } constexpr bool empty() const { return m_size == 0; } constexpr ArrayView subrange(size_t first, size_t count = -1) const { auto min = [](size_t a, size_t b) { return a < b ? a : b; }; return ArrayView(m_pointer + min(first, m_size), min(count, m_size - min(first, m_size))); } private: T* m_pointer; size_t m_size; }; template using ConstArrayView = ArrayView; template bool operator==(ArrayView lhs, ArrayView rhs) { if (lhs.size() != rhs.size()) return false; for (int i = 0; i < lhs.size(); ++i) { if (lhs[i] != rhs[i]) return false; } return true; } template bool operator!=(ArrayView lhs, ArrayView rhs) { return not (lhs == rhs); } } #endif // array_view_hh_INCLUDED kakoune-2020.09.01/src/assert.cc000066400000000000000000000023301372342214000161350ustar00rootroot00000000000000#include "assert.hh" #include "backtrace.hh" #include "buffer_utils.hh" #include "exception.hh" #if defined(__CYGWIN__) #include #endif #include #include #include namespace Kakoune { struct assert_failed : logic_error { assert_failed(String message) : m_message(std::move(message)) {} StringView what() const override { return m_message; } private: String m_message; }; bool notify_fatal_error(StringView msg) { #if defined(__CYGWIN__) return MessageBox(NULL, msg.zstr(), "Kakoune: fatal error", MB_OKCANCEL | MB_ICONERROR) == IDOK; #elif defined(__linux__) auto cmd = format("xmessage -buttons 'quit:0,ignore:1' '{}'", msg); int status = system(cmd.c_str()); return (WIFEXITED(status)) ? (WEXITSTATUS(status)) == 1 : false; #else return false; #endif } void on_assert_failed(const char* message) { String debug_info = format("pid: {}\ncallstack:\n{}", getpid(), Backtrace{}.desc()); write_to_debug_buffer(format("assert failed: '{}'\n{}", message, debug_info)); const auto msg = format("{}\n[Debug Infos]\n{}", message, debug_info); if (not notify_fatal_error(msg)) throw assert_failed(msg); } } kakoune-2020.09.01/src/assert.hh000066400000000000000000000020321372342214000161460ustar00rootroot00000000000000#ifndef assert_hh_INCLUDED #define assert_hh_INCLUDED namespace Kakoune { class StringView; // return true if user asked to ignore the error bool notify_fatal_error(StringView message); void on_assert_failed(const char* message); } #define STRINGIFY(X) #X #define TOSTRING(X) STRINGIFY(X) #ifdef KAK_DEBUG #define kak_assert(...) do { \ if (not (__VA_ARGS__)) \ on_assert_failed("assert failed \"" #__VA_ARGS__ \ "\" at " __FILE__ ":" TOSTRING(__LINE__)); \ } while (false) #define kak_expect_throw(exception_type, ...) try {\ __VA_ARGS__; \ on_assert_failed("expression \"" #__VA_ARGS__ \ "\" did not throw \"" #exception_type \ "\" at " __FILE__ ":" TOSTRING(__LINE__)); \ } catch (exception_type &err) {} #else #define kak_assert(...) do { (void)sizeof(__VA_ARGS__); } while(false) #define kak_expect_throw(_, ...) do { (void)sizeof(__VA_ARGS__); } while(false) #endif #endif // assert_hh_INCLUDED kakoune-2020.09.01/src/backtrace.cc000066400000000000000000000035001372342214000165530ustar00rootroot00000000000000#include "backtrace.hh" #include "string.hh" #if defined(__GLIBC__) || defined(__APPLE__) # include #elif defined(__CYGWIN__) # include # include # include #endif #if defined(__linux__) || defined(__APPLE__) # include #endif namespace Kakoune { Backtrace::Backtrace() { #if defined(__GLIBC__) || defined(__APPLE__) num_frames = backtrace(stackframes, max_frames); #elif defined(__CYGWIN__) num_frames = CaptureStackBackTrace(0, max_frames, stackframes, nullptr); #endif } String Backtrace::desc() const { #if defined(__GLIBC__) || defined(__APPLE__) char** symbols = backtrace_symbols(stackframes, num_frames); ByteCount size = 0; for (int i = 0; i < num_frames; ++i) size += strlen(symbols[i]) + 1; String res; res.reserve(size); for (int i = 0; i < num_frames; ++i) { res += symbols[i]; res += "\n"; } free(symbols); return res; #elif defined(__CYGWIN__) HANDLE process = GetCurrentProcess(); static bool symbols_initialized = false; if (not symbols_initialized) { SymInitialize(process, nullptr, true); symbols_initialized = true; } alignas(SYMBOL_INFO) char symbol_info_buffer[sizeof(SYMBOL_INFO) + 256]; SYMBOL_INFO* symbol_info = reinterpret_cast(symbol_info_buffer); symbol_info->MaxNameLen = 255; symbol_info->SizeOfStruct = sizeof(SYMBOL_INFO); String res; // res.reserve(num_frames * 276); for (int i = 0; i < num_frames; ++i) { SymFromAddr(process, (DWORD64)stackframes[i], 0, symbol_info); char desc[276]; snprintf(desc, 276, "0x%0llx (%s)\n", symbol_info->Address, symbol_info->Name); res += desc; } return res; #else return ""; #endif } } kakoune-2020.09.01/src/backtrace.hh000066400000000000000000000004541372342214000165720ustar00rootroot00000000000000#ifndef backtrace_hh_INCLUDED #define backtrace_hh_INCLUDED namespace Kakoune { class String; struct Backtrace { static constexpr int max_frames = 16; void* stackframes[max_frames]; int num_frames = 0; Backtrace(); String desc() const; }; } #endif // backtrace_hh_INCLUDED kakoune-2020.09.01/src/buffer.cc000066400000000000000000000647541372342214000161270ustar00rootroot00000000000000#include "buffer.hh" #include "assert.hh" #include "buffer_manager.hh" #include "buffer_utils.hh" #include "client.hh" #include "context.hh" #include "diff.hh" #include "file.hh" #include "flags.hh" #include "option_types.hh" #include "ranges.hh" #include "shared_string.hh" #include "unit_tests.hh" #include "utils.hh" #include "window.hh" #include namespace Kakoune { struct ParsedLines { BufferLines lines; ByteOrderMark bom = ByteOrderMark::None; EolFormat eolformat = EolFormat::Lf; }; static ParsedLines parse_lines(StringView data) { ParsedLines res; const char* pos = data.begin(); if (data.substr(0, 3_byte) == "\xEF\xBB\xBF") { res.bom = ByteOrderMark::Utf8; pos = data.begin() + 3; } bool has_crlf = false, has_lf = false; for (auto it = pos; it != data.end(); ++it) { if (*it == '\n') ((it != pos and *(it-1) == '\r') ? has_crlf : has_lf) = true; } const bool crlf = has_crlf and not has_lf; res.eolformat = crlf ? EolFormat::Crlf : EolFormat::Lf; while (pos < data.end()) { const char* eol = std::find(pos, data.end(), '\n'); res.lines.emplace_back(StringData::create({{pos, eol - (crlf and eol != data.end() ? 1 : 0)}, "\n"})); pos = eol + 1; } if (res.lines.empty()) res.lines.emplace_back(StringData::create({"\n"})); return res; } static void apply_options(OptionManager& options, const ParsedLines& parsed_lines) { options.get_local_option("eolformat").set(parsed_lines.eolformat); options.get_local_option("BOM").set(parsed_lines.bom); } Buffer::HistoryNode::HistoryNode(HistoryId parent) : parent{parent}, committed{Clock::now()} {} Buffer::Buffer(String name, Flags flags, StringView data, timespec fs_timestamp) : Scope{GlobalScope::instance()}, m_name{(flags & Flags::File) ? real_path(parse_filename(name)) : std::move(name)}, m_display_name{(flags & Flags::File) ? compact_path(m_name) : m_name}, m_flags{flags | Flags::NoUndo}, m_history{{HistoryId::Invalid}}, m_history_id{HistoryId::First}, m_last_save_history_id{HistoryId::First}, m_fs_status{fs_timestamp, data.length(), hash_value(data)} { ParsedLines parsed_lines = parse_lines(data); #ifdef KAK_DEBUG for (auto& line : parsed_lines.lines) kak_assert(not (line->length == 0) and line->data()[line->length-1] == '\n'); #endif static_cast(m_lines) = std::move(parsed_lines.lines); m_changes.push_back({ Change::Insert, {0,0}, line_count() }); apply_options(options(), parsed_lines); // now we may begin to record undo data if (not (flags & Flags::NoUndo)) m_flags &= ~Flags::NoUndo; } void Buffer::on_registered() { // Ignore debug buffer, as it can be created in many // corner cases (including while destroying the BufferManager // if a BufClose hooks triggers writing to it). if (m_flags & Flags::Debug) return; options().register_watcher(*this); if (m_flags & Buffer::Flags::NoHooks) { on_option_changed(options()["readonly"]); return; } run_hook_in_own_context(Hook::BufCreate, m_name); if (m_flags & Flags::File) { if (m_flags & Buffer::Flags::New) run_hook_in_own_context(Hook::BufNewFile, m_name); else { kak_assert(m_fs_status.timestamp != InvalidTime); run_hook_in_own_context(Hook::BufOpenFile, m_name); } } for (auto& option : options().flatten_options() | transform(&std::unique_ptr