pax_global_header00006660000000000000000000000064143275725060014525gustar00rootroot0000000000000052 comment=98b84f2b05e8532703898a85abd06fc28c4e40ac kakoune-2022.10.31/000077500000000000000000000000001432757250600135525ustar00rootroot00000000000000kakoune-2022.10.31/.cirrus.yml000066400000000000000000000022351432757250600156640ustar00rootroot00000000000000freebsd_task: freebsd_instance: image_family: freebsd-13-0 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:10 env: CXX: clang++ - name: linux_gcc container: image: gcc:10 test_script: make -j4 test env: LC_ALL: en_US.UTF-8 macos_task: osx_instance: image: big-sur-base matrix: - name: macos_clang clang_script: brew install llvm@11 env: CXX: /usr/local/opt/llvm@11/bin/clang++ - name: macos_gcc gcc_script: brew install gcc@10 env: CXX: g++-10 test_script: make -j4 test kakoune-2022.10.31/.github/000077500000000000000000000000001432757250600151125ustar00rootroot00000000000000kakoune-2022.10.31/.github/ISSUE_TEMPLATE/000077500000000000000000000000001432757250600172755ustar00rootroot00000000000000kakoune-2022.10.31/.github/ISSUE_TEMPLATE/bug_report.yml000066400000000000000000000041661432757250600221770ustar00rootroot00000000000000name: Bug report description: Report an unexpected behaviour with the editor labels: bug title: "[BUG] " body: - type: markdown attributes: value: | Please make sure to [search issues](https://github.com/mawww/kakoune/issues?q=is%3Aissue) before creating a new one, to avoid duplicates and centralise conversations. If you need to have a question about the editor itself (options, behaviour, code…) answered, make sure to check the [documentation](https://github.com/mawww/kakoune/tree/master/doc/pages) (also available via the `doc` command in the editor) or drop by [IRC](https://web.libera.chat/?channels=#kakoune) to get instant feedback. - type: input attributes: label: "Version of Kakoune" description: "If unsure, use the output of command: `kak -version`" placeholder: "v2020.12.31" validations: required: true - type: textarea attributes: label: "Reproducer" description: "What are the steps to follow to reproduce the issue?" placeholder: | If any specific configuration or environment settings are required to reproduce the issue, also describe them here. validations: required: true - type: textarea attributes: label: "Outcome" description: "What is the outcome of the reproducing steps above?" validations: required: true - type: textarea attributes: label: "Expectations" description: "What was the expected outcome of the reproducing steps above?" validations: required: true - type: textarea attributes: label: "Additional information" description: "Any other information that may be relevant to diagnosing the issue should be documented here" placeholder: | Examples of relevant information: * What OS and distribution are you using? * Are you running an experimental branch (i.e. not `master`)? * Is the issue reproducible in other terminals? validations: required: false kakoune-2022.10.31/.github/ISSUE_TEMPLATE/config.yml000066400000000000000000000003111432757250600212600ustar00rootroot00000000000000blank_issues_enabled: true contact_links: - name: IRC channel url: https://web.libera.chat/?channels=#kakoune about: Ask your questions to get real time support on the official channel kakoune-2022.10.31/.github/ISSUE_TEMPLATE/crash_report.yml000066400000000000000000000053251432757250600225200ustar00rootroot00000000000000name: Crash report description: Report a crash of the editor while in-use labels: bug, crash title: "[BUG][CRASH] " body: - type: markdown attributes: value: | Please make sure to [search issues](https://github.com/mawww/kakoune/issues?q=is%3Aissue) before creating a new one, to avoid duplicates and centralise conversations. If you need to have a question about the editor itself (options, behaviour, code…) answered, make sure to check the [documentation](https://github.com/mawww/kakoune/tree/master/doc/pages) (also available via the `doc` command in the editor) or drop by [IRC](https://web.libera.chat/?channels=#kakoune) to get instant feedback. - type: input attributes: label: "Version of Kakoune" description: "If unsure, use the output of command: `kak -version`" placeholder: "v2020.12.31" validations: required: true - type: textarea attributes: label: "Reproducer" description: "What are the steps to follow to reproduce the issue?" placeholder: | If any specific configuration or environment settings are required to reproduce the issue, also describe them here. validations: required: true - type: textarea attributes: label: "Outcome" description: "What is the outcome of the reproducing steps above?" placeholder: | If the editor printed any error messages, or if you managed to obtain a backtrace, also document them here. Make sure to demangle the stacktrace by passing it to the `c++filt` command. Note that triggering the issue in the editor compiled in debug mode will produce more helpful messages, please consider re-building with `make debug=yes` to help us out. validations: required: true - type: textarea attributes: label: "Expectations" description: "What was the expected outcome of the reproducing steps above?" placeholder: | If the reproducing steps are self-evident, the expectations are simply “the editor should not crash”. In that case, you may ignore this field. validations: required: false - type: textarea attributes: label: "Additional information" description: "Any other information that may be relevant to diagnosing the issue should be documented here" placeholder: | Examples of relevant information: * What OS and distribution are you using? * Are you running an experimental branch (i.e. not `master`)? * Is the issue reproducible in other terminals? validations: required: false kakoune-2022.10.31/.github/ISSUE_TEMPLATE/feature_request.yml000066400000000000000000000024531432757250600232270ustar00rootroot00000000000000name: Feature request description: Ask for a feature to be implemented and included in the next release labels: feature request title: "[REQUEST] " body: - type: markdown attributes: value: | Please make sure to [search issues](https://github.com/mawww/kakoune/issues?q=is%3Aissue) before creating a new one, to avoid duplicates and centralise conversations. If you need to have a question about the editor itself (options, behaviour, code…) answered, make sure to check the [documentation](https://github.com/mawww/kakoune/tree/master/doc/pages) (also available via the `doc` command in the editor) or drop by [IRC](https://web.libera.chat/?channels=#kakoune) to get instant feedback. - type: textarea attributes: label: "Feature" description: "What do you want implemented that is not already available in the development version?" validations: required: true - type: textarea attributes: label: "Usecase" description: "What use do you have for the requested feature?" placeholder: | If the feature's usecase is self-evident, such as a hook or an option whose name hints at a functionality unequivocally, you may ignore this field. validations: required: false kakoune-2022.10.31/.github/ISSUE_TEMPLATE/question.yml000066400000000000000000000016011432757250600216650ustar00rootroot00000000000000name: Question description: Couldn't find an answer in the documentation? Ask away! labels: question title: "[QUESTION] " body: - type: markdown attributes: value: | Please make sure to [search issues](https://github.com/mawww/kakoune/issues?q=is%3Aissue) before creating a new one, to avoid duplicates and centralise conversations. If you need to have a question about the editor itself (options, behaviour, code…) answered, make sure to check the [documentation](https://github.com/mawww/kakoune/tree/master/doc/pages) (also available via the `doc` command in the editor) or drop by [IRC](https://web.libera.chat/?channels=#kakoune) to get instant feedback. - type: textarea attributes: label: "Question" description: "Couldn't find an answer in the documentation? Ask away!" validations: required: true kakoune-2022.10.31/.github/PULL_REQUEST_TEMPLATE/000077500000000000000000000000001432757250600203715ustar00rootroot00000000000000kakoune-2022.10.31/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md000066400000000000000000000003531432757250600253330ustar00rootroot00000000000000 kakoune-2022.10.31/.github/workflows/000077500000000000000000000000001432757250600171475ustar00rootroot00000000000000kakoune-2022.10.31/.github/workflows/build-releases-linux.yaml000066400000000000000000000017411432757250600240730ustar00rootroot00000000000000name: Build static binaries for Linux on: release: types: [published, edited] jobs: build: runs-on: ubuntu-latest container: image: alpine:latest steps: - name: Checkout uses: actions/checkout@v3 with: ref: ${{ github.event.release.tag_name }} - name: Prepare run: apk add --no-cache binutils bzip2 g++ git make tar - name: Build run: | mkdir -p kakoune-${{ github.event.release.tag_name }}-linux/ make -C src all static=yes make -C src install PREFIX=$(pwd)/kakoune-${{ github.event.release.tag_name }}-linux/ strip -s kakoune-${{ github.event.release.tag_name }}-linux/bin/kak tar cvjf kakoune-${{ github.event.release.tag_name }}-linux.tar.bz2 kakoune-${{ github.event.release.tag_name }}-linux/ - name: Upload uses: softprops/action-gh-release@v1 with: files: kakoune-${{ github.event.release.tag_name }}-linux.tar.bz2 kakoune-2022.10.31/.gitignore000066400000000000000000000002211432757250600155350ustar00rootroot00000000000000*.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-2022.10.31/CHANGELOG000077700000000000000000000000001432757250600222522doc/pages/changelog.asciidocustar00rootroot00000000000000kakoune-2022.10.31/CONTRIBUTING000066400000000000000000000014101432757250600154000ustar00rootroot00000000000000The 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-2022.10.31/Makefile000066400000000000000000000001101432757250600152020ustar00rootroot00000000000000all: $(MAKE) -C src $@ %: FORCE $(MAKE) -C src $@ .PHONY: all FORCE kakoune-2022.10.31/README.asciidoc000066400000000000000000000676151432757250600162260ustar00rootroot00000000000000= image:{logo}[K,30,30,link="{website}",title="Kakoune logo by p0nce"] Kakoune 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 :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://web.libera.chat/?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's philosophy and design. :numbered: Introduction ------------ Kakoune is a code editor that implements Vi's "keystrokes as a text editing language" model. As it is 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 being competitive with Vim in terms of keystroke count. Kakoune works on selections, which are oriented, inclusive ranges of characters. Selections have an anchor and a cursor. Most commands move both of them except when extending selections, where the anchor character stays fixed and the cursor moves around. See https://vimeo.com/82711574 Join us on libera 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's dependencies are: * A {cpp}20 compliant compiler (GCC >= 10.3 or clang >= 11) along with its associated {cpp} standard library (libstdc{pp} >= 10 or libc{pp}) 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] .MacPorts (macOS) ==== --------------------------------- sudo port selfupdate sudo port 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]. -------------------------------- emerge kakoune -------------------------------- https://wiki.gentoo.org/wiki/Kakoune[Installation and Gentoo specific documentation] is available. ==== [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 ==== Kakoune can be found in the Ubuntu repositories. ---------------------------- sudo apt install kakoune ---------------------------- If you want to compile from source on 20.04 or earlier, you must force the build to use GCC 10, which is not the default. Also, make sure you have .local/bin in your path so that kak is available after the installation. ---------------------------------------------------------------- git clone https://github.com/mawww/kakoune.git && cd kakoune/src CXX=g++-10 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 ------------------- ==== [TIP] .Nix ==== -------------------------------- nix-env -iA nixpkgs.kakoune -------------------------------- ==== Running ~~~~~~~ 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. Finally, the user configuration will load from `${userconf}/kakrc`. NOTE: If you create a user `autoload` directory in `${userconf}/autoload`, the system one at `${runtime}/autoload` will not load 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 selection 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 cursors in given direction * ``: move cursors to line beginning * ``: move cursors to line ending * ``: 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. * `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 each selection * `a`: enter insert mode after each selection * `d`: yank and delete each selection * `c`: yank and delete each selection and enter insert mode * `.`: repeat last insert mode change (`i`, `a`, or `c`, including the inserted text) * ``: delete each selection * ``: delete each selection and enter insert mode * `I`: enter insert mode at each selection begin line start * `A`: enter insert mode at each selection end line end * `o`: enter insert mode in one (or given count) new lines below each selection end * `O`: enter insert mode in one (or given count) new lines above each selection begin * ``: add an empty line below each cursor * ``: add an empty line above each cursor * `y`: yank selections * `p`: paste after each selection end * `P`: paste before each selection begin * ``: paste all after each selection end * ``: paste all before each selection begin * `R`: replace each selection with yanked text * ``: replace each 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 its output. * ``: pipe each selection through the given external filter program and ignore its output * `!`: insert command output before each selection * ``: append command output after each selection * `u`: undo last change * ``: move backward in history * `U`: redo last change * ``: move forward in history * `&`: align selections, 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 selected tabs to spaces, uses the buffer tabstop option or the count parameter for tabstop. * ``: convert selected spaces to tabs, 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 (4, 5, 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 `,`. To keep only the nth selection use `n` followed by `,`, 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` duplicates selections on the lines that follow them. `` does the same but on the preceding 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 its 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-2022.10.31/UNLICENSE000066400000000000000000000022741432757250600150270ustar00rootroot00000000000000This 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-2022.10.31/VIMTOKAK000066400000000000000000000043371432757250600147310ustar00rootroot00000000000000Vi(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 a modifying operation. That makes things more consistent: Vim needs separate x and d operations because of the operator -> move order, while Kakoune only needs the d operation. Selecting first 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 replaces the selection with one per match (hence all occurences of "word" are selected). 'c' deletes the selection contents and enters insert mode where "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 brace block: * vim: viB:s/word/replacement * kak: Bswordcreplacement Here again, Vim had to rely on a special feature, visual mode. join line with next: * vim: J * kak: delete to line end: * vim: d$ * kak: d or Gld Some classic Vim moves are not bound to the same key. Kakoune uses shifted moves to extend the selection, so Vim moves that were bound to shifted characters had to change. * % became m (for "matching"). However, m replaces the selection with the next block. If you want to get a selection from the current point to the next block's end, you should use ;M (; reduces the selection to one character). * 0 and $ became and . Equivalent bindings are gh and gl. :[gv]/re/cmd To emulate :g or :v, use % to select the whole buffer, to get one selection per line, and then or to keep only the selections matching (or not matching) the entered regex. kakoune-2022.10.31/colors/000077500000000000000000000000001432757250600150535ustar00rootroot00000000000000kakoune-2022.10.31/colors/base16.kak000066400000000000000000000052351432757250600166310ustar00rootroot00000000000000## ## 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 DiagnosticError ${magenta_light} face global DiagnosticWarning ${cyan_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-2022.10.31/colors/black-on-white.kak000066400000000000000000000034311432757250600203500ustar00rootroot00000000000000# Black-on-bright-white colorscheme for minimal distraction & maximal contrast. # Works well with e-ink screens. # For Code face global value black face global type black face global variable black face global module black face global function black face global string black face global keyword black face global operator black face global attribute black face global comment black face global documentation comment face global meta black face global builtin black # For markup face global title black face global header black face global mono black face global block black face global link black face global bullet black face global list black # builtin faces face global Default black,bright-white face global PrimarySelection black,rgb:cccccc+fg face global SecondarySelection black,rgb:e0e0e0+fg face global PrimaryCursor bright-white,black+fg face global SecondaryCursor bright-white,rgb:777777+fg face global PrimaryCursorEol black,rgb:777777+fg face global SecondaryCursorEol black,rgb:aaaaaa+fg face global LineNumbers black,bright-white face global LineNumberCursor bright-white,black face global MenuForeground bright-white,black+fg face global MenuBackground black,rgb:e0e0e0+fg face global MenuInfo black # Overridden by MenuForeground and MenuBackground face global Information black,rgb:e0e0e0 face global Error bright-white,black face global DiagnosticError black face global DiagnosticWarning black face global StatusLine black,bright-white face global StatusLineMode black,bright-white face global StatusLineInfo black,bright-white face global StatusLineValue black,bright-white face global StatusCursor bright-white,black face global Prompt bright-white,black face global MatchingChar black,bright-white+b face global Whitespace black,bright-white+fd face global BufferPadding black,bright-white kakoune-2022.10.31/colors/default.kak000066400000000000000000000030271432757250600171710ustar00rootroot00000000000000# 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 DiagnosticError red face global DiagnosticWarning yellow 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+fd face global BufferPadding blue,default kakoune-2022.10.31/colors/desertex.kak000066400000000000000000000040141432757250600173650ustar00rootroot00000000000000# 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 DiagnosticError red face global DiagnosticWarning yellow 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-2022.10.31/colors/github.kak000066400000000000000000000032031432757250600170230ustar00rootroot00000000000000## ## 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 DiagnosticError rgb:CF222E face global DiagnosticWarning rgb:9A6700 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-2022.10.31/colors/greyscale.kak000066400000000000000000000055131432757250600175250ustar00rootroot00000000000000# 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 < 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 DiagnosticError $red face global DiagnosticWarning $yellow 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-2022.10.31/colors/plain.kak000066400000000000000000000026171432757250600166540ustar00rootroot00000000000000 # 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 white,blue face global SecondaryCursorEol default face global LineNumbers default face global LineNumberCursor default face global MenuForeground black,blue face global MenuBackground blue,black face global MenuInfo default face global Information blue,black face global Error default face global DiagnosticError default face global DiagnosticWarning 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-2022.10.31/colors/red-phoenix.kak000066400000000000000000000053371432757250600177750ustar00rootroot00000000000000## ## 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 DiagnosticError ${orange1} face global DiagnosticWarning ${orange2} 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-2022.10.31/colors/reeder.kak000066400000000000000000000057041432757250600170170ustar00rootroot00000000000000## ## 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 DiagnosticError ${red} face global DiagnosticWarning ${orange} 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-2022.10.31/colors/solarized-dark-termcolors.kak000066400000000000000000000041741432757250600226530ustar00rootroot00000000000000# 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 DiagnosticError red face global DiagnosticWarning yellow 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-2022.10.31/colors/solarized-dark.kak000066400000000000000000000056241432757250600204650ustar00rootroot00000000000000# 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 ${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 ${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 DiagnosticError ${red} face global DiagnosticWarning ${yellow} 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-2022.10.31/colors/solarized-light-termcolors.kak000066400000000000000000000041661432757250600230420ustar00rootroot00000000000000# 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 DiagnosticError red face global DiagnosticWarning yellow 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-2022.10.31/colors/solarized-light.kak000066400000000000000000000054261432757250600206530ustar00rootroot00000000000000# 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 DiagnosticError ${red} face global DiagnosticWarning ${yellow} 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-2022.10.31/colors/tomorrow-night.kak000066400000000000000000000051711432757250600205460ustar00rootroot00000000000000# ## 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 DiagnosticError ${red} face global DiagnosticWarning ${yellow} 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-2022.10.31/colors/zenburn.kak000066400000000000000000000060161432757250600172310ustar00rootroot00000000000000# 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 DiagnosticError red face global DiagnosticWarning yellow 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-2022.10.31/contrib/000077500000000000000000000000001432757250600152125ustar00rootroot00000000000000kakoune-2022.10.31/contrib/TRAMPOLINE000066400000000000000000000635511432757250600166210ustar00rootroot00000000000000+=----------------------------------------------------------------------------=+ _ _ | | | | | | __ __ _ | | __ ___ _ _ _ __ ___ | |/ / / _` | | |/ / / _ \ | | | | | '_ \ / _ \ | < | (_| | | < | (_) | | |_| | | | | | | __/ |_|\_\ \__,_| |_|\_\ \___/ \__,_| |_| |_| \___| 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 complement 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 move 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 to 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 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: `[ (`. 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 text 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 selections 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 number 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 an 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: `%`. | % | `---' Other registers that are 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/comma key combination (``). .---, .---, |alt|+| , | 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 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 (e.g., make with 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-2022.10.31/contrib/Tupfile000066400000000000000000000034241432757250600165500ustar00rootroot00000000000000## ## 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 CXX = g++ CXXFLAGS = -pedantic -std=c++17 -g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-address CPPFLAGS = LDFLAGS = LIBS = ifeq ($(debug),yes) CPPFLAGS += -DKAK_DEBUG CXXFLAGS += -g suffix = .debug else ifeq ($(debug),no) CXXFLAGS += -O3 suffix = .opt else error debug should be either yes or no endif endif ifeq ($(static),yes) PKG_CONFIG_FLAGS += --static LDFLAGS += -static -pthread endif ifneq (@(TUP_PLATFORM),macosx) ifeq (@(TUP_PLATFORM),win32) LIBS += -lncursesw -ldbghelp CPPFLAGS += -D_XOPEN_SOURCE=700 else LDFLAGS += -rdynamic endif endif ifeq ($(CXX),clang++) CXXFLAGS += -frelaxed-template-template-args endif ifeq ($(CXX),g++) CXXFLAGS += -Wno-init-list-lifetime endif !cxx = |> ^ CC %f^ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF %O.d -c %f -o %o |> !ld = |> ^ LD %o^ $(CXX) $(LDFLAGS) %f $(LIBS) -o %o |> !ln = |> ^ LN %o^ ln -sf %f %o |> : foreach *.cc |> !cxx |> .%B$(suffix).o | .%B$(suffix).d {objs} : |> ^ MK %o^ printf "%%s" "namespace Kakoune { const char* version = \"`if [ -f .version ]; then cat .version; elif [ -d ../.git ]; then git describe --tags HEAD; else echo \"unknown\"; fi`\"; }" > .version.cc.tmp; if cmp -s .version.cc.tmp .version.cc; then rm .version.cc.tmp; else mv .version.cc.tmp .version.cc; fi |> .version.cc : .version.cc |> ^ CC %f^ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c %f -o %o |> %B.o : {objs} .version.o |> !ld |> kak$(suffix) : kak$(suffix) |> !ln |> kak kakoune-2022.10.31/contrib/describe_sessions.sh000077500000000000000000000047331432757250600212660ustar00rootroot00000000000000#!/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-2022.10.31/contrib/kakmap.rb000077500000000000000000000034551432757250600170150ustar00rootroot00000000000000#!/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-2022.10.31/contrib/kakoune.spec000066400000000000000000000072711432757250600175320ustar00rootroot00000000000000%bcond_without tests # Enable LTO. Profit ~8% %global optflags %{optflags} -flto %global build_ldflags %{build_ldflags} -flto Name: kakoune Version: 2020.09.01 Release: 2%{?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 ranges of characters. Selections have an anchor and a cursor. Most commands move both of them except when extending selections, where the anchor character stays fixed and the cursor 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/* %{_libexecdir}/kak/ %changelog * Fri Jan 1 2021 Jiri Konecny - 2020.09.01-2 - Add new libexec dir to the spec file * Wed Sep 2 2020 Jiri Konecny - 2020.09.01-1 - Update to 2020.09.01 * 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-2022.10.31/contrib/tmux-256color.terminfo000066400000000000000000000053151432757250600213310ustar00rootroot00000000000000tmux-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-2022.10.31/doc/000077500000000000000000000000001432757250600143175ustar00rootroot00000000000000kakoune-2022.10.31/doc/autoedit.asciidoc000066400000000000000000000074371432757250600176500ustar00rootroot00000000000000Edition 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-2022.10.31/doc/coding-style.asciidoc000066400000000000000000000021051432757250600204160ustar00rootroot00000000000000C++ Coding Style ================ Kakoune is written in C++14, here are the main coding style points: * Avoid external dependencies besides posix/stdc++ * 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-2022.10.31/doc/design.asciidoc000066400000000000000000000140711432757250600172730ustar00rootroot00000000000000Kakoune design ============== This document describes the design goals for Kakoune, including rationale. Interactivity ------------- Unlike Vim, Kakoune does not have an underlying line-oriented editor. It is always expected to be used in an interactive fashion, displaying edited text in real time. That should not prevent Kakoune from being used non-interactively (executing a 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. As a side effect, it should be very efficient at editing text in general. Composability ------------- Being limited in scope to code editing should not isolate Kakoune from its environment. On the contrary, Kakoune is expected to run on a Unix-like system alongside 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 enables multiple windows by supporting many clients on the same editing session, not by reimplementing tiling and tabbing. Those responsibilities are left to the system window manager. Orthogonality ------------- Kakoune features should be as orthogonal as possible. For example, in Vim, there are many ways to modify the buffer: Through normal/insert mode, command mode, and Vim scripts. In Kakoune, modifying the buffer is only the job of normal/insert mode. 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; it should not forbid common sense pragmatism. The +gf+ and +ga+ commands are not strictly selection manipulation commands, but they do fit nicely with other +goto+ commands, so they are acceptable in normal mode even though they could arguably be moved to command mode. Modes should be orthogonal, as should commands within modes. For example, Vim uses both +d+ and +x+ to delete text, with minor differences. 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 fewer or the same number of keystrokes as Vim. * Kakoune is 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. It 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: - When we want a direct result, we need to be synchronous with the user. A 4x speed improvement is meaningless; we need to have an algorithm which appears instantaneous the user. - When we want an asynchronous result, the processing is best left to a helper command which can be reused with other Unix tools. * *No binary plugins*: shared objects by themselves add a lot of complexity. Plugins add another interface to Kakoune and go against orthogonality. The +%sh{ ... }+ and socket interfaces should be made good enough for most plugin use cases. - Rather than writing a plugin for intelligent code completion or source code navigation, it is better to write an independent helper tool that can interact with Kakoune through the shell. * *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. For instance, +\*+ tries to detect word boundaries on the selection, but +alt-*+ opts out of this behavior. Unified interactive use and scripting ------------------------------------- As an effect of both Orthogonality and Simplicity, normal mode is not a layer of keys bound to a text editing language layer. 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 both scripting and interactive use cases to share the same text editing language. Both use normal mode to express complex editing. Besides promoting simplicity by avoiding the introduction of another layer, this helps ensure the interactive editing language is expressive enough 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. As much as possible, documentation should 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 similar to Vim's if there are no compelling reasons to deviate. However, self-consistency is more important than Vim compatibility. kakoune-2022.10.31/doc/interfacing.asciidoc000066400000000000000000000116021432757250600203100ustar00rootroot00000000000000Interfacing 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. Any `|` or `\` characters that occur within the ``, `` is executed. The common use case is to display element specific documentation. `set -add` adds given completions to the list. + `set -remove` removes given completions from 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 given flags to the combination. + `set -remove` removes the given flags to the combination. + Cannot be used with `declare-option` *-to--map*:: a list of `key=value` pairs. `set -add` adds the given pair to the hashmap or replace an already existing key. + `set -remove` removes the given pair from the hashmap, if only the key is provided it removes that entry regardless of the associated value. + 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 part of a word, for the purposes of the `w`, `b`, and `e` commands (See <>). If this option is empty, Kakoune pretends it contains an underscore, otherwise the value is used as-is. 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 supports the following options: *terminal_set_title*::: if *yes* or *true*, the terminal emulator title will be changed *terminal_status_on_top*::: if *yes*, or *true* the status line will be placed at the top of the terminal rather than at the bottom *terminal_assistant*::: specify the nice assistant displayed in info boxes, can be *clippy* (the default), *cat*, *dilbert* or *none* *terminal_enable_mouse*::: boolean option that enables mouse support *terminal_shift_function_key*::: Function key from which shifted function key start, if the terminal sends F13 for , this should be set to 12. *terminal_padding_char*::: character used to indicate the area out of the displayed buffer (defaults to '~') *terminal_padding_fill*::: if *yes* or *true*, fill the padding area with the padding character instead of displaying a single character at the beginning of the padding line (defaults to *false*) *terminal_synchronized*::: if *yes* or *true*, emit synchronized output escape sequences and reduce terminal output with sequences that could trigger flickering if unsynchronized (defaults to *false*) [[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-2022.10.31/doc/pages/regex.asciidoc000066400000000000000000000170201432757250600202300ustar00rootroot00000000000000= Regex == Regex syntax Kakoune's regex syntax is inspired by ECMAScript, as defined by the ECMA-262 standard (see <>). Kakoune's regex always runs 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 that `\$` 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 newline 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 newline 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 uppercase basic letters. `[A-Z0-9]` will match all uppercase 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 digits 0-9. * `\w` which matches word characters A-Z, a-z, 0-9 and underscore (ignoring the `extra_word_chars` option). * `\s` which matches all Unicode whitespace characters. * `\h` which matches whitespace except Vertical Tab and line-breaks. Using an upper case letter instead of a lower case one will negate the character class. For example, `\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 newlines, by default. (see <> on how to change it) == 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 time. * `*` 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 they will prevent the regex from matching if not fulfilled. * `^` matches at the start of a line; that is, just after a newline character, or at the subject's beginning (unless it is specified that the subject's beginning is not a start of line). * `$` matches at the end of a line; that is, just before a newline, or at the subject end (unless it is specified that the subject's end is not an end of line). * `\b` matches at a word boundary; which is to say that between the previous character and the current character, one is a word character, and the other is not. * `\B` matches at a non-word boundary; meaning, when both the previous character and the current character are word characters, or both are not. * `\A` matches at the subject string's beginning. * `\z` matches at the subject string's end. * `\K` matches anything, and resets the start position of 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. * `(?; some divergence exists for ease of use, or performance reasons: * Lookarounds are not arbitrary, but lookbehind is supported. * `\K`, `\Q..\E`, `\A`, `\h` and `\z` are added. * Stricter handling of escaping, as we introduce additional escapes; identity escapes like `\X` with `X` being a non-special character are not accepted, to avoid confusions between `\h` meaning literal `h` in ECMAScript, and horizontal blank in Kakoune. * `\uXXXXXX` uses 6 digits to cover all of Unicode, instead of relying on ECMAScript UTF-16 surrogate pairs with 4 digits. kakoune-2022.10.31/doc/pages/registers.asciidoc000066400000000000000000000067621432757250600211400ustar00rootroot00000000000000= Registers == Description Registers are named lists of text -instead of simply text- in order to interact well with multiselection. They are used for various purposes, like storing yanked text, the locations of selections in a buffer, or groups captured by a regular expression. == Interacting **:: 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 <>). This is a prompt history register, holding the last 100 commands entered at an interactive regex prompt. *@* (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 <>). This is a prompt history register, holding the last 100 commands entered at interactive shell command prompts, except for commands starting with a space. == 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):: prompt history register holding the last 100 commands entered at the interactive prompt, except for commands starting with a space. == 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-2022.10.31/doc/pages/scopes.asciidoc000066400000000000000000000060521432757250600204150ustar00rootroot00000000000000= 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-2022.10.31/doc/screenshot-i3.gif000066400000000000000000001060061432757250600174770ustar00rootroot00000000000000GIF89aP     "!&#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%QR-`]|d8_ h&I^ѩġXW [{|= UBKS;"hxޥ=HjcjZ9|U WI_Қf'zl:'r+:Zhv  ZvvArYӸbAQ\*mܒ7/{)K$z#GlXRҺ}ʩئJ[gq^| ZQ2ZƊ |e"˥ 'c,eF[K7=ժ|tgy^`ʮٚMpҫ$nw=b6y* jFGhBJ,P&P4I:dnlTNzR !A<=Shŝj];!K-Q33+O7mt̓u'^<5mm-p䈻m(t?i-? cCnKs%0~˝nZ/Ӻngr` ]nr9>kz{ZW:f:^ WeMYk yDZ {Ъ7ZeHSW\;2\i*Ex'(|3 7hwyQnX:2x|3t =7d&!y;1rętHJru^VW)M;^ĹY҆YYJၒL&Y14ץ}qXGFceѧ0w3`4mnE9d'ɫ d죵7 T%"YB..DB o2<?iOI;$ jZCUJJt3?tm4GG&<uHߨ/*~T(9~4%uxR/wiS5LR5ysCFg[ê FHt2H,JiB@SXI C"IArwVgXŚ׾&\˚ժiy.u0HJdKʒ&-xZhq\"!*+>K(uyYiWk˺lY PenilKV r:CtKVͮv&4 xKMzcb|K ؊MLN;'L [ΰ7{ ‡GL(NW0V n8αw-1L"HN ׸¤`L*[X氐,{`ް2L1h5p.ǐo<9xγ yπ4\fAk/)hE7ы iOzuC{Ӡ&r |I34jUKFa=`ZsŵLf:r?;uGilMm֥t)/@ͭhz[ܡv ~6dpㅇн_,o{>rO ics6I-SߐHygxmG.nZ69^]4xK~tTzsMt7K=N7u[YƝs_6#󶓸J8o^dwWzIgoIwg]Z<o]xg~C>~qo[5<9?n3سϼf;goaKzoMpkL_/'{C#GSɫܩGyď_w~}ʗȎړO־Grs3_Z'| wWxT|t}uv~gzwg~Gox~G{grrz~Wvd''ʀ2X`p'~{*{uF6B8>gz Wx}}<g}Kx'Ih~X؀/hfFCX7FUHhbv>xfׇ#8WVMxȀNׄ(w^|%`z0BȆL|_cƂׂ9V`|xv~urE'uvtu(?wTȋ{_t(F7ux`hnj7g{؃X_|h<&h|78{a8明chix|8x`y ِBȏ9Fy(o$a(T"6t`_1I`P5_7c3ya;):֓SfR&?9`FYbI`FXV耉a Vy0fn>I8:a@,֔WFE0jamqpXz)eZ93I=@&L_bccba 94fI7wp{9dy6Ipɕ)))`ii`9ٛ0) ٛHɜI )霷ٜ۩ٜIq䉛19)VgqΨpycY`ٕy0 ) ir9ZJٟI *ڕf Z *ږyZ+jƖ-z`0:/w7%V9D`z,L";JT z*:٢))aU2ʥ3gjN; Vh oiI]m;HAZz#:j*{ʧ鞐 uzOZ+fʨy;Y:oy*xZo:*ٚ$xZ7ZK:< 99&E:Ȧ꧝ڡکVժڦ*ڨʪꭳ*:~**ʣ*xJa}t :zzw +[*`1J !亦*I:})k*ZGHf8ZIIʠ﹫@kfꟘʫM۴[O˝Z VN{CIL[p*Z4 D I*qk9|d,}{76ekhy`7۸JI)Igx+P&w [4ȹf&S9 ˺;]gu +ͫ:6 pzӘaBM=J={Џ"Ԓ< [r h T#l `m6ڦ*R謲slˏ=Ī(a zǷm۷׵-hveMĭ`t&gܔb]aKs ꩤS,qZoΣl)mXR[C=n P,]GYqݤڝ\\܋Ȑ^a`N{^/נ=b !^tӯf*~#."@'6. <8}B~`ܻDMCmJ>DL$NZneGzka@[ɁX^joJ~m\],lF)}ع~椇~hzM=K^|@ȓ酗|zɘZ& Nܕ^p[9ܩX>'Ĝ pM\9]4H ~e͌wNٸʍ}ǾN9վK잞趮ٷ[ָ>׎܂ns\ݜ읢N]3Ys &e-~ f J?S&HEf:";C94l50ob|a>aYkϻb>V^L/%mQ.Kaҋ@A ^8 ]]MI=^JV(?%c_ه~_aj4dt7ҋ_=tH޽S|dթmޞÀoa3O~ʠ'~.<=٩MR OHO/j~>^ᝠ=չ?&{fa}_o߅@ DhR…6T1DR(PČ=R ȍMr$8Ő3$seI5CvI%ˍ)myR&ɜ9evĘN<UTU^ŚU֩7nhАṮˊVZmݾW\uśWUAP= 0Ǩ8-|R }dNo"i4ř%kܒihMKڙ磔Fz^ڵm - \pōG\}Eطe֗IGvYkǧ*]geKݎZ+iտ_4+ 8dA0B ksn($& J6RzCDU$:HDSdq6F !1=xpTģ`$Hi|i$F&JlKA+K/3L*JK1H4K[M7’-3ߤN;O23O?m2@$+p> eQG4=Z4RK/4SKTTSO?56'RUQWeյ8BdCB#\IVSP0[lX~.:Zo `{SU֭XwYfv8muUR JͭTE ]FtF|Hu1|pzvۂ̐`>̩5ޞ5b)N[p9f9A8!RC=}bwxՂFf69e'aEk˂خΒ+ߴD9[pneiz=&;OgNmys{w/-[~F#@:iƅ6Vőn`z\reMq}{;_v{{r 7eCws \Y1s֧bcsե+s*捡$&oG>FtI0$ǢfD*鳷H{F5?ćط[;s%o9 hr!XGy-b]*1mPx/MoW9 ^ЂZVHi* n`ØY%}ۙw3{!J^x(hoCvG<3R/n@tTd:"nT`Xd5daA&zƭ{ P&$!#81@Bҡ x!G.zU9PT*&1g%*c[9E-2]6VҫGLb~E+GR#xHGf6әJK ٸ>*/y;$h@*$C9I0q Br'd':tώ;d?ls(BT|*Igrbvj)9a$BգK1?)E>"Qc2w7ԧ"W's^m,MA u.&=5٭uZc$O9TN.,jw4wt#yJ.S)g\O$jK\2^hY/Z\SQY'X6vc>`T[x.gdwG6f2jaWejWgQ#֩]EM4C KRE+LV"+:Mp . Zʴǃw[+Jҝepyf0:sշx}!_7 f} p@<XI+0>'!)«~l1)l92\<%jZS^ߪ)CrL,{ %rZbiPЕfb1O[tw\7̋nmӦ.́ORϹUך7 ɟt}M̶[vuw{o$5 jJ{:wW~K5-K{?u읕9xO6sk|uo7j͙?/>iNԞ<;?绾!_胰{nN?p(I\AEF/?_lfԍ&( /k}K3/#%n0C9@k5CAܒL =:l4A#tA#D? 3$RC'$;ksY(ȸw+B(?XeZ@/$Cw;cS,-2|B0;3>8C;Cr5B+`C!CNcATsC1I)9H\Ѱ0ٞIE:%{b2VT6)!6ِb S(j.[\.@WBħBd̳Ft]rÏX[L+A[4#Eq.e@b:r3flG|ƌDE@[Ra-zFs?pl= @~HPALCi-ǍZ+EH Ǿӻȍ=DȐTxĽW$+RUCE&zɚd-Xd ŎFh0QEDLt{ SJDIBp{ʩI pIʯ"DFxG4KJe`˶d˳˪K˺ ?BqK˾$Ct 8|rqclKLɠsJ,̨hF,6J |LH >Lgr)Ĕ\M,ML!#TMlM F̖r,Y}IKMHMƤ u4ɮ.2T\ʔ HODMO4δσO POϘPOt{N:+ N ΥR;FEX)8J j]8+ODt֐_f \8yKC0M#0v^O7a# fᨀ]`Dc1H11+&nQԈw$J[bE:[[45N Cb\Փ=_:S*v#2c7fZ)ͪ;_#>$edIvl䲭\WVXPI ^]QSL>dMa60#GUePe0)+B>Tz+Fe)焪^kN 6idvxH:T]wK=@EnHB:HHAfde1z 2d x%U0Mj B݋nZm!nBdmQ[?a i nUn`9;i D@K8!9pgflv @ m eouQqeވΕΜ4˒:zcdFM ibeW,qiVېTQqU2ccy;kS::1"l&aߥo)*] l\a/>fNq>&\sl_m[/GQ? BLmT4=7scc*d8'veHq?S6iXt!GoP#H%?nF''tcLNoqb]%.7/'t@Mj. o3Qa7ꮳs;Ӧatl  ? '{hkXXvt0Qnscl&퇇VnQ{\xwx7Ky٣%M3toxxOfmsB8xL2m6IHyXO`?>8+hNs?vCO޷h{4mTNorCn]y`Tlwtam9g|sy!0vp[ǣF" Ȱ?ˏ>+W'wt",S&ƯqnJFʧ6}'ןOp m|eli ٗ"}R۽]}c?*j}`M}nWFI@~g۟\u}G}uRzZ痿'_`ԔI ,H`A&LaÇ #B9S9kΝm9Y.桛~JPu^:ΦR/R]5V1Ejl>jfq 7jf[]!kb첪Ψ9ӉF~yS5yݨ<`#WH=Fv2i{ ̼;Qņ~1QA/$ V.g _.=Єml!OR% \< ӽ A ^LL^V7ꐆa z"[,DO&R#Ԭh q2",$@aeF,cerҺ0.yObvSBz\c!ܶ-}0^itp9*ݰ5ts䉊 %w](#?Ml 付JRf([KVb4L88;rMB\E>*`iDȴCR31 4PB(̡%-)VG%W9 Q$e,a .Yr Tx6)O O<2?Pi4jrԚ3t'?M᳜P#R8s<%@TS.ɒLSdMS:Ius,gIAE3Lm"='G3) -*z3"B_Ӄ[F9͎5)׬NWo2\)[Nln%\Jp+)^I3,*W슩]r}r6[WWaՒUa++h9ȸ47k]ld۩wj/CJXթ=gOqs"Ej__[|^]^{;3m +Tq`|4uU`0 -x:NQfVF⯭\zC>\[ q+.ʷ^ٸ[F/~[عk ɦJXvazDde1cݣ]ظ /(GMOCSR4RN1>f< NMq)gN2efˌ&,mc>T J]{f1s!J&BG>mgƌnHFz&ѳ~A-k "C'-sli uȩ{ a1:?[z)ۑ ˣn&?;(~k@=eUs<;Ygg̭;;BՅ#֪ ]RdtL;t9]_y{{r,cL{)Tzxޠ=k7p[pv}~K߾T33<7%7MnOΩ[K .iyy|,]Hg 'eN͗JǠk;O6px{.7f-gPH/ R8:g}vq\c\g񺶤Luz&pQ]doew3$0Rџ'/S=e>/ϯ aAwWLI:IS ^^&N }TkI\%Β!Zy V-E E` VrLPb^P & _.NhqpY|=Tzaa|L$QR!֡6!_B8 !!"V_""v`JrTr͑xQ) Fb [ E͏$)Yٝ\J1W^]ZAqzL֮ ]R Ea1!> 4+b5: 4n>.lVKV/t`1և1%#9#J>r#?J4b665*`Cb?d !әl;Saڕi"C0R,E\B!6I*$^Z5P;֜:f$|ձ-crmFn}H#L6d@Z# fT:U_"*F#G{\ŝEQaMe-xڭ%DERR^%_b%JB f&U%b>%AY>#.exl͡T*1eb~&gg&ibZ_eZ`Dci^%mRj&oBk" fh2hq'rJaV2&Pso~e^2 gr^'vur{qLG!ID*:F&({*q#|s4T!#RL2V$_#Abz@6v2߁vV%AVzc_(&ƅc. p"gcgA(T%LI~p*heJh.m~&3z&_6i`R'&vt~cZ>kB&bc'/͖z&h{v)f(q*ih3ک.iNfgZ^τ%Wf=f\[_<*69*[NY݁!Q2*_瘒ꍑݝ*zj:Y_hݞRg jF%`>hA6i& rA>h( :+BJ)5>"46kazkVbkZ_(F뽺kjrka+aVE~FQLEE 1Fb_ #YB W%Z]v'j'Yj†/J"g߁$Rh*V%,B%VcJ$z.(V+bm)V,>-N+l,rm+b)}/R(.jlj.Z(́f.Vf ȢD$m-*rQEn&+-m^-dVm6J؆-6R)z.bmF%׮nZ.v*궢Bj.玭bi]P#ܺ*WO2dq1X*]}˶,MG*B".0훴'OV]d(hD.~m*nk,!.pn/3n@kʮB֮ή"pjpm\*B/[A^ 7m5[B$;=Kib& ^oR.^0n~nKR- ߬w(#R-Nmn0ڂv0,pڒ#UzijqԽy1"U$2f&n&^RMa>WO"lfp;?1KBi-*q..[Ϛ2_).{1qz 3ew&Z,N"ޝo8(\f0^\:Wze&yjYґ}{-.Q:M3vQTM [*jN%OT. v*@r精AkaNA3&Z+n4b(:hE-J0E+4ީ@O(tBϲ(QS#S8=sG6b3/7qv.5S7uVszT?FQ c 5SwWAV5YU3b a5[[MKuYjDc[^M_ /%$6O̢ AF5t:>R@C6b2_wz#) 20O#6 ֳ%QIJ+nnudO-g6^'L_D, N'ޫ)^`Fc.M#)n{m׬*f6wXcNtj*s2!Mm 7(ô2kA7G3pF/4FkH+R4ew7g7h$6-CV%bRrB=2s4'vdk3J~whS0C:5cG23owr& 2&&: #xSNb3*(vxzl'.A.oGv@2oyXO8xsɕK,dzirHXtɯdԚfcwZ2GtGRzn˹)wx9:yx89!lJ "+g0{[n2r פH 6Tx+nfج|zG>On??)D;1ײ-Ne?wWYNs;?sdzɳblݔ{v}7]csLhu84tCx J+&fwnȯ|o\69ucggϼG#?]}]&ϣRG}w"5_f|V/qK=؇}L=Ncgbvz-=}~g0U<g<ק;|=#>݋ӌ?~GG!Wws6~w>/FdX~BH9)cד0{=K{=s6[l~g~q.HG)>_%s`=}~MẊñ볱0f{'7dg;W C~5b#뫹K(R?B>@@J`AD8paC!.TbE1fԸcGA9dI'QTF (Qĉ(r!?PG54RN:ӟ,ZiԢ_;lYgѦUm[oƕ;nYnxiMo ̓paÇ'VqcǏ ٷM ) |8,Tc='%:4ѩWZEmWFaו=vm۷qֽ[ݼ{^;`!'WysϡGW.Yfb֌sjŒ5Ew=liǗ?~}ի/);([?LPlMΠk"@=pSM("1?FDq+Sd[GĊ9,i݉Z^*Z`+[咓Í&@-ΰt `_Ze*ۯyֵY{ZR/eg-xR7[4~wxێR42L3]ݬwD_ kp`sqS_wCMǜa xźM~$&xE ;'NTțE[Ib1vc<׾+uhˠϹ-2d[P(mse,W2Dݘ٣lo&i5zg4;l6tK2xAӥ&l~t]#*~ SwQ-aV\2Cs1dR$Ui]M[16ey`٧<2miOնmmonq6ѝnuvoxK.Fljmg˛p7ppe|%qQBúoo~Dǿqj#6Ý-waNnwhrxǤX*G xQsCvѕ#]fѡuw|mnq.&'>9T5>uc/{Ϯmw>c[W6[,YU1&E!I~2iK?Njlw|ғNyh|߼}{/}O͟ww^敤q_bjEsH_[H<<}哯p+}_}O}C>a~^#mdYg$oix3_9#ڪoƯ-0OȄ/PtBl$ (쏱!\npTly50 9>P, l$8BWТe )0P p'' P  . S0Р*p uPq0#&010E1jloSȈZČf NlMP@xNT/AQxM/ޒ|q1ѭj1w'n莑Q1Qѭ/%1ձC 1\Q r!#) 5c %'Έ! l _׬ SD"?e0b RSV"X^2Zb&"&!btj&t$2d'qbbv'ɀ2)uf*&)bEdl)Ed))R*('r!jz:G-3J-[-MRLr(W&A'iR/*%0W'R(2s0+!2*%&1-*Ť)'1L'C3Y%E.GK-C$r..Ue"@S7$l7)x~C8K/04S1(S/i!0SD43Ldr423;4osA^#+ 2H͉L0>k#k6i`Pr(J0r`22381)3'+R9s8C5T0s1?T4[2r4K 9b)+DJEEF4\$EJD$vsB21.TGC3"/r(A#1d爉0|O?TE6WHtHS4H%M;;-N+17C90EByDED3;5EOMYZtE+L$Q@uFQK"GDt2;;3:?o3B3I@_ӹV˶oI]-3e +6kJtL LN3zt2XYO'Z5ON7YUY3Z5!DomP?KFKW* #ːy5_a"V6ðOW7r*g9r{b}9y9y9y9y5~ckēgY ]$ d3%:9y:z ùRўsXJid>G=<rx֢K? v%8璁%@`imq:uzy}:z:z:z}_~Gœ0YzBK?Z`Y7k+[jFXZlaWn_;{ ;{!;%{)-1;5{9={d ,Vc`G5E::ut%쳁;{;{#;GHCωa-aI07aquPjv:j,W׭麵{{--;뻿<{;9Zкϸ{J-aMzֶV&G|I\O\S{c%V|e\MO{{QŅ|ȉȋi<yºk}Lv,z;ïv;N}| <5 |{I=}5{qˤm^UJ}+}zlW~ǶI\pۮ99 ٯ֛=~1ZI9s<]ν]͇}yߝYuIQ̓E^~艾'>&޹;ͽܩ^~݃^ >M<>Q]둝c]E~㍾~^oi]~e~_q׍]޹^cA?ӯ%f6}IY_٢=RuDKȩ }'G~=??q1=5>_޹E_Z] E9VC<#aS$nرס;^M_’5$hAK&,ȐC#Ja…9^qōI<)2%FlK(kڼ3Ν<{ 4СD=RRJ6eiSQN5֭\z 6Ԫb˚{6Wjۺ=-Ut뢵wn޽u`->x'/;~ 9ɔ+[f,5fV; hZZVOMzhϜlکOS*ڧYFnso&|wtmn\༗'w.v̱-r׏K= eRNIeV^dC'd^J#r%LE4Y=]٦o(}tWiʘnuHۈM.h:dX㞝aini~ꘖ|ejEj|}8(A2gFf\Hj/녖i\FI(iޗ, #u*;lUnKn枋nn oKoދoo pNjjb9k_*,lBggZ;1*~|+&G%Ƽvld tBMtFM*ҟ'\CzrTj{2<&CZ3ԀuX0ڮ=sbuÀ 1ٗ&t~ xNx_4ᡍy`q9ޡ9%3Z]?;_÷9n^qZpwnscNgV[f{$ߎ/|?}ו_0K=5XUo~~[OW׏Ͼ mf+Ԋ4۟](7rC|Y,w٪S9p$, OE1 s,&~ڌf|rQn&$GPB MЖ\Z5̙X yx%*/mr1 Ѐ /*WiJiQlnd&΄<$1:#檍ܦ9s6hlQ ="7Uzwͥ ({‰W]v-QT*dyp e uEEST T)?*!ԶODTZ;ڪ4Y -e&u-,ں36lpM.ϫѝd`QV5ca,;~LX̫P*'6ej]Qb6d bqV[v=m(רlc͸mfc ]N.x\hٴ4ͮlE+SQb\ڎ,m`w+Oȃ׫CPj9ik Ire:lܚ'ERvQu/ `͖pvrz[ b+_W_Ǿj:.\*:7V1dO>zb"Wy\2k0y bɌ4jnߌ80; t3}ٜcNb{!l (Vi?g ?Sk$+;'ള/MXJ6D]mMޘME(]T2/y2ԘǬ2zh6@Wmxr '<{u2~_L3R[F%&Zh YE״뺝oc0,ؼh/=ؐvq}3o)z=%b]UUͦGeZ<'7\gmp|; \s=٣M! ZpwsIjO MQunuҎyXQs˗'YӻP[Og%Y|[Zo?ۿ)׽R'R 9G֒Գ,eo|~:[&*plނr>6v'9/+V9oeyGxrtT$\mwdPuVtuqlD]m+o{JQowm|ǧ|-,|\]c}_E@:x]4l8U[ӁSyuv}Gcq3thtdU(6YAhw$# ZV)]XuZ jjFznvgYbH4%{gvrg(wOh;k]uヨLg7Z]5<5dsB?[Tx(wW{hXC]^XReRvHXuXzU7^6Tjx8zJ1˴w 'hǍ0r͸aer48T~"t&`G7H XytF[rhhnٓ_o~}W12ov a-~#p28D:}Cd7`~rP H#t7~7a*:I$=*[x4MqV s匑H4xsC^rSFIV=؊PPՄ`n9c SD=kG̓Mwד=A^Hy2f9ȉWYzqU߶;7XUGoz@e!s"i'D7iq*<~{x|w7ɗ7I`S5} W}Fa`[xETToCUoo(9y;FUy*3`iiTܹg'EuY8Չiɞyfٞi虞@5 }cji9kt( JѠg|49]Ibdžꓙmm@&<+ 1 4j)I86n7ɇr^2 EDI 4z78: eJZLFTYڙ'> 7K 8i'm_X qcYy]!Dƃ4V%nPxAS:{Z_-ꢐJ8CR(;TCy3\Sᨕʟz u:\BIvڎāSl̄=꠪J:Bwjɚ4I2 8JҗLA5١{Wt :ڪN.JJz תڨTσj'2ڭz8)˝hYqΚ+ICkE awiMG{g JW;fLKS+񊵽Uck>P4]{UqKG{EgJ[NǷ{GS$6t\u[V;_}z"[jbj%4+ʥ_痆㩺Ʃku㕷{kkKK4+Gy}NoЊer{X˼Ozw:Lpb Kt[{8ջtj;[}Rԯc#W+kqvz p@:=ṣ>"  ;a+[('31Oຳ+,7z8:= ˓DĢ?Kj~ૠL+Ul*iEKVT_w Aet*o'|o,3앛27yǶŻxypălȁǢ:{ ǍuRȕ \,w!|l[ ]-lʥe M/-̳ mMҎ'-üm~bxwN;?)r8*|^)ۘ匦7-S[lSkF>i[AͭGQ$LjQ_Q-Պ wd }Gx fGpyqw׸,{9pGZ*cM|8VlA5Y̻Ѹ;h9D8Cy؈}2P(T% N{YlӻUc;r-نN (y݀ӉQK{J}Y]ع ZФEخwۧx(6=mG[Sxur;y߳ Ie$ >C7kq ,nCz_-fRʿm<#..i6)M i6Mf4wE&Mj0U~#-+ұle^,:! ) \FuXl; 7xfw؛]p7O& ͌l}6^Am'>ުp'ǫ1b罖d_q;(Ȳ]NLzܲ~ָݥCݰn-DFܫ-GXn,۬uŎϮ垧!nT✳xM"8NtgG;;$d߬.8̳}> mnJ^bä6}~r-vZ!7JzTv-yJn:1C02O@}?9] RCcHe=u1Һ'rRb2&OoaZXk"^JZ{}ݷTGܥr*; ѧ<[_joᏏmޖbO\>5[[_ǥؐ֘M?aD-jSLix~[;ET)ğͮ\ݽvȔO{ 9މ:  $XA .dC%NXA 5\G!E$YI)Ud˂7HfM8ԉŸ{,ؓgQ-"ӦQd:iULfz+N^,&m֭aZ׮XyPf_&\aĉkcǏ!Ӕ|#2)yheʠwNUh?|PgC/u=76igdz,h[p붾[:x.^pcٵow|>ayѧ {Egf!TpAI"A +B 3@CCqċ#8STqE[Cg\Ӫ&J+*A =)٠MQh;OG 4J0ҹls7R[h>K-)OSSUu +A2ӮT,\{kNaX@cuYPeYhODT6iS[k)a_i qnBSiYy^%VdWEMWpG&;_voݕ_|3^;nN\xأ6VicY.]w=uTgXjQYtQ ֕r+~釁-qVKg;UWqѪ6ٳ9jT*xA| 7* |$Kq=3GIh@|L?SW]1^u3,cZWw{B߃;h`x+H @0.D$EoQ/ջ9ƹ'}-{~/OdYcQ&RY~Xh`@ f0$shַ)F ~CPf<-Rёs6} #&J˔svMngįo7]DddbaHS;""4 a[߹%3dVܚ길eZ{D(R v#,4<'*1FKDE59nZU89&c,SR%e A2K## vHFё 'ise\VD54XW 5u둏/;ɕXIjh*fJ>XN^'(LMz\gJ>RfA )ӟ5R(lfΪYsc$b8i6Zg2]O1(:9ҕa36Rn3 7"SLd=JDz407|st(QDe"7tW!)׶ fȥ0%+֠MNQ^*'a6qz'{MWO%fVb+>V=7W$v%Qd9Y{}M|fA{'5hGmji{۠,Iq 8%l[\⫲\TXe8ɥu<[]4%s+!j%/a[^H+ G vMo}u\MewDzWV ,%vW%Kl`r~Uˆ" xcqUXxLR]!X_e;cqsXX+H|ĜKEXea6닔Œ%YBe3tPd d&Y/ VY=#9Ds^Gi$wGf5%l~ggَτ΂:z[ {P}m7Փ1\¹i5RqÍV< jvJ5QK]Ul*^d\j3_T>ogXGLZ[LZN4ZQ] 5tIba؃(&Rbҁr9JY.|3yQy';}=Tw.O]Lj'Զv?^Nk"} y)\#mm*ojr󍬉.;!ijgH Nf׍Bl8_2Ŭgkn때BqT9c89QnĻEJ[mJnQtZsN׶].!3w ŘW|! q߽=IUW&<z񻑰OysTse|DPOOHUS|55oEz K6> E}-}Tcmfx̍>ԡnlx{.sח?k2Ü{k?LA.b[ T/@ˑ@A?KLA=SA?,8'[?׋jA9@ABA"d2#<#\#ö!:'<&BKBBA-$A,.* CB#C$B4?35\1|CA#<9ı81=| >dC5t@B=>LcD1DHCJ/:4Q* J@NTJEQORtQ S|U$V ŃņhEZUEX Y4^/KDJO9=`\EXFF`L eDTŅ^,mmgF FbL/c(;jFnt p4wTGqdxzlFN G_,CI,G5BxcuE`EnLEzEdƅd_GfEDHŅGGȈņWlȏDȑ$IS,I\IHl,Ȃɓ$.rGdȘEtIzFȢȄH%T85T%SS [7僶)[>ĸ3YӪG:\S?ʾR(;"ZKG*TKU,D;٣C4MMwiϛDS‡B=:=ֺc%^0|ϒVeSkuO#UM#WMs$sIDC-^30WU 8[2)Pc6]:@j⾸sӾzM*rVgڷV~=sWa XO]p={eU,[j%UVѽX]7|T؎6ɐWżr3%ӻِ#x:>zOCΓ#ыםū.EUS@OM>3j*/냿ZwO)tRcl-ڲ4}l!EDCS JYRǕ#ͻMO)U̵ܵ>RЅ=WJuUeI] $DUSxU]oTs .ᕯN]u]^ A2"RZM^aKvU E\N5^E\M_}]pއ^e_[_ٚ =-r=1=Y/%R< U^ 杭]60Z_ `U N8\vZa6(ȭ7\7a\fbBa"ޜ#^"T+Y'&XtbA2b-n-b(b1e2^*NXka651v6a<^,cD=2cc dC D DndZ_8dC ddL%M.(dqDQP.eƚcT`ѭCZ#F-[+:òA 4]v ?^vam3[ RU_\&IclU$ ߥTEbfmNGo+h.nVq^9ae^Dž}sWSpnqp>gIfydufW\X⵰ͪYR[U**?Z IQUT떊mFii&YUT U&Xh&ii]KiZՔ"~@=hX:c7m=[:5*`(e;sZ $=hqjSfb紱,j~moa\DZXQBݍ0R)dZ6@6IFZhOLye$:*`bU1ZjnjbI3)颕FW5(FPf1yc|J(⚫j9(dZmYia)+,Ҿj`9-曰:{WκwۮkЯ(>jjN{-Riw--< 9mHki{¦/qwfռ2u1Kz6\βbG[w i4ә󥴢,d[[sV5b/]kmDvO¦Yub=@v˝{6}fo8AݸC˄cydߍ柃zC+駣u޺뼑<8]fZN*ݾP)ѻ|a _4oW\T&=-Ƽ;cs lhZj ^_Vlv-U Xjz5+guJ"UYgٶh=-j:Z'QUV,n.$9Ѫoժb7nrc(e} Wnn5kj+[JwQu.z`յ+"_WoG<"[qaBlblmlaա?^qHW!>n 0-ilʴ5j?RzW s,`Nhq/V{5LNJ調~N3Qh9߫F&ː4$MKҘΕ{!5pα̩P }j"zӲgND&b-rCZ:D蚿T-`WKJX7;|Ӵs~VIU1٤6`YTc}.}e(۶-mvs\Hۋ'/,WǝO-݄+<B'=Q3En|9mksYqϪ^ wŶ6VZJ3~bx]*qt?­-rݫx'Jn=ytÝ],{c^uD~r9Յ[w6I 5Z?;=򆚻cw*ڱEz}-7ㄗjăWɣ^׏OG\l4a΁9}lܤ^4IBՇ쫏$[?LJ{?_?!ۏK? o??` `U"`*2`:B`JR`Zb`jr`z`` ` ` ` ` `fM@;kakoune-2022.10.31/doc/screenshot-tmux.gif000066400000000000000000001230211432757250600201550ustar00rootroot00000000000000GIF89aPAi;!,PI8ͻ`(dihlp,tmx|pH,Ȥrl:ШtJZ,zxaڕ1˘OL9U:3͠c֑ϪBjBy:sf+_ҚŲq<^4uËaXBXO}{Э>5iVrdvU9)r6`g@`I&YxCf!Ex,5 "xsg|8V|GAxx=w܂SS!IsM~'%iH6IaA 'cMF%nv.9QyT}:Hvz%qgEI~gWFG6*Œhh&^BD1BF槟IҘ!'~yƗ (zjbV>9(+9!8a [ K\yHV:Ykw4ʉ)A~;j{'l^[&o/KbKBi6zhk.g9z&LTM߱9.Jh*JiM>)UYmUenk6xkF+6!(+>4лz F{-CG8ڱ:@ '`mc[ߢL%IRרJ%I! ?F =#:|3 ] P1|9Yej 㕤art(,>B7Qx:d G+^r3;QnjC3NjrZc(Mw$1G:/E#GT!*4Er1l*,ϑ$g91\eh9%`j&*?S:S0e.O&-CIkΒ.l/LJU9`xK|%w3w#Pŵ=Y/0Q]M 7C؝aczǕ0_> PB:e\04C7mPGuhAC\(`Y+x|a/&Lde|*Eۙ7bYy:m??]=yC?Rl+0v}ylvN^beov7^^ZͪqyWV7񋿻]eU9]+ysK#1 Ġ J(\z/?ZOw`YU+!ϣg/@&<<Jym| }C+>q 0F'F2=DMFwvPnid[7~܅vANGmTyV&G:pؤtWg@2w}4vIRmw- Ȁ~RX$8s;npuHQuy:CwrMXoxm0Kǀ}Jn"6edNtWKstCJM8wFm}w8Nm&F`nqy؂?'_dKp*3@76CuenPU:eW?'Px~ӇFa#g_ta[si%`HP扤{s,;/GXsȨ^Zsɤsp0Ќ ֘.tHW(RȊ_*uc`pX&%nwPx_xwSxwih5F>y @@E, MU7)u7]kՔbǘ6nvIqQ#l)qTT+ZxNє?G9h(FQqvY9d~4:IUřǹy'?iE. ohgHIٚ؞81s3).~T!Gtڢ|(yp*T=WjѹOٔɕ$0Q#:q w4R,\XY]:kCϷp 6zA%eipyjs_ڍ`* D@uDŽ2ZxE`PRxmkZHC7):PږA]*%:J<ʢ%ĺғ(:uajD'% z :JJ4Pyew8Ɏ40U |8ɯMWbkw{z.F;$hȨ]p":[WhxR`z窮*p= ksSHg&z6$Xj(6,2Dw5gbbgd;>K$˄'+蚲Pj+&!}ᴆkY6ڃ:9h{W; )Si Kk{uBқʝи b۲,K!{uƶ% &B/;T17+2睭ⶩz1b ⰴɂ+6{<{D#yGpص;Xi5wg.jwKrcڷ *>Ƚo9`hۙ0ETƺX  A) Ij [y9kZ[^4ڕiaꚮ-;SOx4XzVZFm[Ay@fˎ,ˑR,P]f)B{Kg$[lXؽr3yʺnn ,jZtLfeȁr<ȌH׋rgHp4I ɪ[bXLBVo ڬ+쏐zw̚D ]ʋ&~>oJ봦ܤ˛J˨2{MR ZܛPxHzz'5#F`)pDͬ{7wZXؘ$z$n(̓=k^Z" K]̣odTv,<ЋHо N~Ҭ"lW}i >_x >K--҂J\CK)m&}le( uݺ v]bтA]^xlԵ6ۢ3Qf[-KFc! ICml}>!y։  J|x>y\ 2@}@ zԋ=ӍX-,yjE,ݕSz{-μneLLmS܃DV\ŹQz7i<l)&⽟p}ޥ\mG }߱qY-XF5-Z Sb˜R!] :`{ή=_rsȫ ̬}Msu!^Ż:K{L“Q=fgXx1KlUN-Q.5: 2UxK̞{̇L'zH*6-,Ԗ !oh.v-a癬W v`l"ZY|hܽ:L\L].(ޱܒ|[vi=Lqh8Aѭf;2Eܗ H{ћu⽗k[+6ڙVgi2˚-Չ~>;(՜h6=5|(.Jsr{ܗ '}Z߭}ӦnMP뜝ޗE>JN! Nۃ}݃/+U{j;~AnT~Nh,k[v9P=4 l_ Y>'KkM7&\*ooݮ< >r߷.~}E4 u[Go,ԚL.f߉<mB妾>_J=Lr/&Iy:9)8J/~_0 QM׆ 7A\r] ׿~9M"(/4Mf? 箯'NVV9up@%Z$ )ESQGROէvۊ9\cGղXhEu@~u W) _j}RaJ a4=ãFT1H͡7[Ch2 3bb 6Tp萦M4sjQ{'#5/ ʯv=#j=aŌKnIfZe|O~< V: ӴllA@\弍>±ۂ CB怋0B41)v* Xbh2lp-գqGsq0Y/>r ? I_$Rcф!m2F~Ľ/J̍20 ,DJ8|G=9c>OD/J>ea(]zמ5ζ{5|hyW}g}G?~,@s?_Cms3 `N'P 14 G#"r`Hb!KZ2`X؝pq;$tbD](FA":R^`P.@]*,aG̱jDK0B`:1xHpK)EKa`QL&Y Zg#@Jm TB/MQ[lj8rh8,K&ř-♄inHRc tx%EBԡ{>uJ/3m >ӣ? dS|;Q4n|](k'aRN GCaGgFy;#.!F24UP-1T y *}`6Em3kZZ7jK9G!YWtpl9Z~lKڎ:9 P%m*c I1"D:QRee)w%8ƨFmY;7utT?IyTPˬ\ն[z”3촊0& @`JІUmBbw@EU\RئAH+Z khdTBLD3b֮|fdhc@K^\jM \e-{Zmr8zw89ҸXx}|,u/:+YpʐﶺR"42oLJI::yy*XFlLiOO|(f7G"eLQ : Tdt_v8cN3H9_j5gg⼙w;]vstu7v+t]yAw >p'o\^>АxuvծtZbzƫ^L#=S8۬j[N%3Nt9ܩ-'^a+~x痿I]O1'ċ3 @LTs>S(ĕo*^C!7CV @a2&C$tsB@ "hS٦l/5 A5[\>`A,r[4uPg3 =I{ !ܙ"?SKc'D9(+'j{¾ur2iJQR-s00 &<<ˣ8DPu(8c#C,9A--4뫹3-Ñ"Rr+#'FDG\6O>[D4(5T* 7@7(ݢ;z ]@))a0Y0 >3 ;$?M8!BEhCLOOqOJ{OdO4ϋh@OO PP-P=PMP]PPO-PhP P P P=+CBK},Qo pQ P3AK#teO!5"B$U` 21rOІQ Rљ$]bq#eR%R8P7Q$mSB(eEˢO!- S ? ,3MRnSJ6S9SLMNO<>:$D2N̲ۺNb*N4M#NAT&Lj>^_U`E`pPcGPN3{*0sIc&# N_Sn]ҋV]V+rKbDDs=lNlmWM|T)I3ȿ7 <́0R5T:Tg2dʍXxUD֟,Ud̪AU][Vٕ]]75[e[Ծ]\ߍ]>ۖ ^]mO ZRK +Z_JHR/U;죾BR5Qڥ=0ŁY%^]]ޞ_^E-^m^SLe!\A Ws` Vm/Ee߻s:_[]5a_>>b]Y ˕sΆ3M J(eT=̝3M M+MA Z4`b,1I|E[#TwvnXEWWδW$dz[CYD.{DFVbR7!DJ5R>eTNe&}z,L+TXUnZe\e#YeOO_f]fb.fcnOfh`YRecfjUn`yidP)}EU9,].- pfS9E"3$UU4xgγה\?TcS'T]睵;]b.LYvrf[슭*%tF:nXqص(Sq&ԓ.SmhMbachFh^mAAwԓJ\j ̤ ju; gSsi雵iS陶PiF4S)(.3V32;gݐͻ߻[) _>!¾".VlѴA:U$H66$f*8LWoN$LI6muͯc?}bKlҥlZ}]\mT%˾3fs4۽+nj1V֚Wݩfilm6bޜb&ֆل~onP5U}.jc4ZbM'=)p4Xo~ϛnwnx^ʨޣ;CXTnRɡ"#>hvŪa$ oU7qRu8[FEt]L.; <n3lh({4(ɂtNH9ohoc#fo! u^vb3ՠ7I,hGK]Kޮ-6 g!uu,%Km*E:nhion?&oAC/tcbEoVGtiO<trZntH  GRST>q;kk?pG-sd=>jma'?__Gt^ERYb` ZF;>:v(*0.ghk@~i]!Ɣl/^snflT7sҲ#)Qlchacb;Z 롟"jsWخ8hu]AzBbdLdx e%~eUkDdTtX{bGWw he?|Oe/|W#nn|W |ʗ{|H ;|?p/}?y}Տ#:}8ǿ}wI\O:R>~S?D}~ܮvf˸s~}hKoZ7~*iCj/z?#Y'+ۺ/3]w8«l#2\2'4*m +6rJ3:^=7<.v/Y?``ߞ`!bb K"d$c%f&eg(^FjL g,k-S,LoiƐ0q a3*v6'0rp2,1Q9K<)Vt>|o8سG{ MI@cB2ʵ&M#h%caE dǥ@~)!HAcMe;Boɠ2ReåmE ZQfI>%3ۦb-QO ̀ޭEb SX̸ ^U-Vr Ӈ5/7/^ݞTբ[50t9=Qw\.^9a?uؽ3'sQ9oڞcַ}#>7]H#}GxRxz`Ugu܄]8Ȝ}!g^XiH]Ʊxb5"vՍhHX%^8c$H Wc)מ|9(Ad_~W!_Es0NefV ި{b* f;L:y9]iRId=U`kM.Imp(&;EWQ$bIyEe9~9}x>*[IVk*'xw9&g ӤV`fa .*LتoG[ߵuazcX튖R)-i>ia];V+bej0Y:'D룲@u70:[&o!.'j,Sn'K{#έ &R s"G|Iks\kMm,V/2-ӛ*hyNmelkŝ9)x†|խf#~ֺleMΪC-4cwjނUFc#0$?esg\Gթc *o4? T_ݳ>|\_諿G>?l?|Xn'0ng -rO T<=CBJ#ԡFӥ^;eAL*LF *Vխr^*X*Ve=+ֵn}+\*׹ҵv+^׽~+`zNei(ƪ2},c+R,f3@(Dv$6I[}-lc+[{\q;Ywm^}+nmnp)KuqjT1!cT3@+^,5{@HKl8jҷV%~Ņ+pW/MnYBG~X -Eib7]5VĪvׅ/c,cŢնepVe0uwCl{,`L(_ %ˆegb+ RxܱC cf5/mvsYg,9UD.pvc K^..94%, X{N|d;+Еf}gE:ї z=iJk.fؗM|ieq3̹7&5uVЄ,0Zxlr|b\n:jD&s ^@j0d=эns~kV*Փ&s R?p1oSդ4tz7'j qOV.k3u̞*٢BQ٢ymlK{b_{fmEX@t3qv:.5ꫮwp:m[bxտpjo;nŎoF!~?OF ,֬//_0("9Rι?;!ji aܚ1/t9L_Ѽ橳.ݭҩ^5c?{+\^/N|͇֗Owɱk/>aZTP.6  6Mb21EpdN[ݩo-] )߃׾5N]WyB:_j2u`M}-O ^F%>@\٠ \ ʟD2UٰG% U^*_ޑ`Z`ݝm]5ff\Z Yf{m  *"C!UFyQ d(]b}blZ]ZV+ڦ΢bb ZÁ`YrX,V.3*#fla"w]YXiX ^m@W\%bz:B#>"$TAc )#lMI?#@`<#BB#>6d $DFDN$EnA^RBf+8Gjd)(H#q|JIH\%OLdKMuX"ѐ=`OvOWHd7LW[և 9#hSr;X"Q*WL5VBXV٣WN]XfXUnt }R:YTB[% LLew+$'tb%&+ &d %^VBDNS# L~dVaN YX)N q(zb^'&V}&gfj[e" aMz1`1ˁֲi&cq>flBAIQvZtv^'a>a6g<.K +5&e#ҥ㹧 "S \y&e_eufgw.!x(&WdRx~u[Bl*8%g![zѧ!FeZcb[~hS㴁(&ij(s; !n(viFhx_z2bJ&BbMBV)ʩd܈Ω!i)bcNy _j)rBii6h(隲אMiv蓒~~g|橖褂 f&'n&('諪fhjj)i&ꜝ!rpJi.ko`qf\pnR+sc| kArJ~kv+cII&{녽ƫE'֫m+Z++=ګ ܥ$ҥ,CA*` xlԉ+Mjh n%F:Ic&;&iFM֋ÊkYߋ_cy,6l`pX, n⁰[g~^YZRe`Ɛ_#6+bҦ&&1^)=eq-QX}(5Ƣfƪgj>p&c5&V 1ݚ0QrDъZ&G "BUjڨjkߢ*ɂ򀢖i)&j6nakYe+ b H6ƭMn|#*UDNzubPeTPo)vflg2"k1o&\!h_0m)RxS:a/-. B!K硠"%!`(Bd"& 0< ]7zC. t"/@m§(&CڮS/BS kMelUo z'ְfs1!)'i'1 iNpbCLgr  ?}q%j&/z) Ϩ 1^Z^p . jY912rY-oJ4N#&.n *k&6nX=.;Fk uWFPq18bna!;sD[γN:gmD,H@R)%Il?sf4EsЮpFtFwHkEtA/Gcږ4JcC{Htt44L4$]:f_~l& ŎqA2Jt",!< 68P7"|XilW59(*DWYS;G@5ǡ:c"`Xy] 5JaURo+—aЬ`3 ᶦj3ONi2/V捒qƂ_5Ѻc3@D&.RrTfs1w jeu.@_ 1kc6.n6iB4\NB &*%)brR^at ?-?ZJ +T{# '.?!f5"D7h%{w&$psP+%Xb_bz{1p-f̆2!/Jn{Oqió jpFxp4(?x"/tx[8sx='tOF1HiOw.Cs3T.̎wrv#_;$%gwK8W't+xc)[ò:xI28CI.G{k׈w9| 8m^S{s ҬbXsN#?*u޹{7A38x㫟,cXPw0*Ÿ~#{9qDzZfE ӷ+I/kN2y&3CZv3ff+gkի/9yj1N݀nT6i\JE;OnKbrڙ 7!u0k3w>߻sk㾰9kؖ&moVFn̺2K5?ţp73SOSğ4|Xh̏~&y ոS=Ayk*nXhZiBki=篲_yOS ?4{OI\,LTͩT'3 >k5ğt+a?+p,7?Jk\R`(?? @gy ő,MՕMb`ng ~C!-MNUum3Z5$d|Vl.j},1ī KȇhD Q4Tt4U4 Mv-VOvmnOxx5Yyɳ3U&UbHH6c$<=]}w?__P0 !xYXaB 8ذ>)VbFdH#IoӪ82K߫*u+u פH85N-s2ExRM+P1 CY%m=T(%L)tN־36&$fz<-.XLjUG3atxC[f]9|ݗԺwG~ Ӄ^>}7Z'*^h=EM>Aӗ YmVR}}#gba.i*n^=QZYiY)\N>?w=U_oڻ'= ]xGș8' /n;+Sf?k.uS?ũNm'afߣ>`>mt(G Fm-Ⱦِ$pC+Zs(+dŏ&QX@ZQ3< ;u0}p/u1+ lZWfbA C-DHfO$וn=p"mĕ5r$,8I'RrThDvr!w/f04e)QGV`7 O>߹]=@Ћh1iZC$brq.I*lb6Enj&cٜ@iO!4*Ufя!/9Xe%P8] )a`2wrrQwm(&../!iΒ楠 U)<[Yxrm.aȥ-XǃKЖ$3-&5餢7KvӣVWœn_GJZUfZY Qց7'y ^K̅>;tQ{.0P]V Y^WMg}Y Lv]~kvخz;ޢewi=̿"^M@|[P7/kQy2$$Rw/SG`8Uo9ahHTr cTh<(). *'Qpi ΀""`SaGVr|'X)+X`GL[H0yFlSeŭCyK^AΆ^mUC: \!/9Wҥՠd (CNO G?ґ)]iK_ә9iOԡI]jSթVYjW֏_mnp!'3(O^zU^޺_#kq4jΘ#x%D>t/ ntJA+.D[_lT tf[AJv $=tg!9{~PY|+L>3?X-s2; ςP`'?+ťG=;_m $ߝү 8[7`8@$p(P,PFF@o/(0/Mc&DD O@T=/:P.4:?  A! QtP* Ҵp 0H\ @da,+<%"K)SD;]"d%؎V0"l"m̌Lwm:Q/Vo^+\ gp01^4.oooT#[/u utylnq=g_q0Qy/Q5 /jqq1SQQoW1qAEOt fD?Xd,WxW0!'W(SOT3-2:.Yj~spxM&$U0ErD.LL`rq L|v5@*!1P)))+R)(1+2)r,-r((2-,.2).- /o$=P QPZ"5r$2.03#?3H(> 3R%0=.fRCZRZ0Kp%9$6sM$7gDL2(//qo-O1|r*3*+p+20,)s0s;2./ӓ-r03<=2<>(.3>h&׌21p  3F }"124-%0WTBPC+MZ44U'I6M`%%?n#%MBODmnP'Kj8Yp,ɳH>Qk:*ٓ?QP+2?0a<39Ӕ>MM=TL;-۴/L09Z1 ]PEKt3-Q-/34wRTF 7=DO"5O7YrZ6%m8sVSdPBlWEOY*U3Zt\.=U.VX,{KU\e\+?ie;@ @  0 ag E[#,mB;n C/# S iE%OqLr1TQq.i#妍dpk, Ustn\N'Ue SJ/JtJ sOw wwqH[O/1\TSWxxuhH4kzwxe1zO92c"k*3b4Y1UI(7P~~Wv$WH US}%B~ p2.7eaV()$XXbOGPւ-΃I BxY{"U'ro3&-$`7w A),&PkGeq m w-#pWYUxV, |ShjsO׊Btx3aoX%8Dݕ]5)ʏc@)X Sf[ !%Dp‹/gmYjj [gӓjug5],U+]4V|moUzdEé2_y_w`/R:Ȳzbg吝{Sfg[VdG4wЫ%!c374Z%iVֱi#54 {V{i}V?Kh3{Xta`P@<1W[Z{3 U=2yaT'wmF!\Ts`ey?:+g\T\1;i}7S17"|#ʋѝ>4X:isLx# '3/?%7-,?5G!lx^T =tU9S< y=?8]Iۣym>Ln_ۃ^07OVcTE[\AGo C{ dQUϩ?m?kbzG m]zzꛛMZZ_R퉫'~WHwŇxU1Le0Z^DqNe %Q-+a1OGWs [< ^mpt֥&'R5G͂G&`?V[fFcFWwRQ)\4 "/hwAIP9e,j hU8 pbC[-IiV0WT%}hdS夝i9qr5F{,'l=tkJU+~fpRZVuYJCV))h~*aK":bgj:+xo/:*/VH=ɩ_0J륊ҋi ,Lb,H/BKjm*rjKFތsk m ?&% )I;:JET5EtҚ!G5qu4pfkWO+~3 p,+*p l h5! C ,K_xOy!7}0`䒲xv:p4 XT @1y%2R~BCkSn,jqaX8A{E6Z!ŨB3RHMJ#&z/? +&KysV`*ky˪#FƢK.y9C̼0c2˷]Ot8rcnz$?zkVtG VJk`7 )[:z MRԬ&VZ]dYM`:.O,c+^A?{sn6hO޲ jmݺB%nlݍAV5+-dTzȴ x1aL`o\{4JM[GVsc'N4!}ӕMg5tv Q6wXIQªmwCFr]'>z#I؇p|5M3ޚ{C*ڄeVj)C]a_ٛ~zDoӝGxY>S9%}ʃԋd2G{a.hn /4# }5Y_yWtz}Gzw}shkO |uR7[[ w2}{vx{r{ xR(|ubkn>Vht\UtOU:9k%.u]vYWvd%o'{@sܷOX*@qs`sfsFci]R'i!`uvyȇZĆ}b5='f\|>S%m@VLFp;؉qOdu<]p?|c4Z'7G|-8megr}ag* (c%Ȩr'& t(~vW'1Tp6;X9v]֌ΈGo73(pONJG"'x)Xe*IQGM%騎[T2(ȁq?1u2ysvb؂lD)s8xu$x)$\eK3'x-x)x({1n$(Y)-#Y(0ɌCI46}|xEPʵ(M$ex胏xaӮ<;>k@Kh*DL۞宫YZXO+7tź y㒶[jVY}r+㚱jd 7Ze=SJ4Iuყtwԁ u%;tT$zX]E=nIAՎP2Kqgbv!(XڭZ%ǃFYUXe<;*0[s }ؿ;LH |n4;Qy(B:6C܈ E$,`PN8ԝXI?7{99 A-#lk^.,|vqv@#E4ø:!lD,ٟrB2T%o**ŶCűҡ*5Dx0Z|:&t8#L!ᙋ9ڰe"%Ⱦ&'4Hj;qąv6Hv0¹%궭UZ~K[q,PLTZG!Αʀ(G_v^\Ô\\͑,i_=t̺G+Z9vȑӌΨț'M҅ >CL7vn#ڃ^!pF Уj_ncT(T(4Nn Aŭ3U/ ~ngt+ζ͠#J[rP`ÿ'-,j-c& J"o;>?>dx%63^rv=OqA2,/V=?F_Mm,inNoXN`1ɓ<ۤL |$! DgJD3Xʆ0ǑD|߃z隿IGz1/͟-o.^UL?[`5"|jk οZR wH༽Cpo`+rU8—h,ݟ"@Mָ:^iK^?]nਏߓgw>z\~zG-{7υ)MG] u6OEĆzQ-sZ>|1`;g1 jQk,z!ch`a1 a Kgb$f㰖}Rve5E0VPU CC"p}*go$-D=}>ʟ2'yY/ &XWⰈ2,_&7|GԚxQieRvEf!2׬5-biTZ9"S[vׄLvzxLP ǹaS%2+!H@U--R0ГӤ%9Kb2 C oe J7ڒRzJ &HJ2ї̤Δ1t3w(3@&6(No,ز}XA.Pw{MC%z:xkhPâћut+ԭ+&Z-N[LuJ&QxĨle|SUXI%z^B̠\+aG!TENq>sẔԬӞ#ꖵ+`7aJVrMk^V 8vE`ְX6ֱld%;YVֲlf5YvֳmhEXֲ5mjUZֵֶm;[w&V mnu[ַ-j;\׸-dRY4J ]jAv7mq]v׻.f^ƒwnzջ^·t.+0!A/G`r;`o<`/d{7>3$䦰](IW7,$ ! &H6G ?/EnӤ7TeFHY,-mrh>C± WLZ:ޟ:cMGd|{5c&3݌iDjѫnNYcu{h0'֋5ek^ze.CiO[t9XcIOK R]NTS,Ykr_Vur[$'Uh?4C(yz.vGlzy۔r YqoxYWx[ yÊ |/Q`Lf,35=[wx;u׷΅N M&iq83X*.V,>=p:͢vv~{,;;;-l t|ϡ3c0{՛2^om(xG`0z >A˻Y'k 2ġ::bi;, f+ӪB6*¡?T;A D0>#?,929\8Բ=>.@=+DC4@p7C8\p[PCdC:Tt˾|@KDDTƋ EC-˲ Gl?$n@GsGmydr|Fx :t\@gGzTBzœE +Q_ !(T<%oʿ}ce#GuG]ǑCy<ɓDDIy<{iIL=uDIvGwɅAjəGFDIt$ʀ"ExE2쥙Y%*`[6Eh*5K1U;HJ>ƖlI|Go,sTLIKâ,ʣE|<,L}I$Ev~lLń@s3dDSLGtLütDebJ[ |)I˴j͗ZKbTHLN܋t!\1μ̾ˤ Id0kLfTʚTɹLD JBGIK éL;(tjI͉φ\?̦ 3K-NgJ$Oz\ΗLzlKO̞ν< IфNLDL=L PG}4ı+4ũj%5R˭!ѯd&Tjm з #]Q47˹Sę=LPL$@E S-CNVtD,E<=;mDD=-5\OX,;/O sVJK|Bˏj̃MHXIO$! wL[\ݠTPg]s;3]-F]$&|ORާJ;iʥ ]OYMץΡL=S\P\M{ѱe\B7T\_\_7A}RgZ#̘pgNYuQ81[2[uM\Jl%^4=`y_0m#ܬ @^N[ &CU_ Q-Q(5dԓ!R\al N݄f9[5c'1Hr.t{EPQ%QBm)A]:4aZѣr6BiұB #Fs͛)F&±޳hZ4ҶdBe&}C)-E#Sx;_ [.V$`bdeM%e:nV`ah.1bNYcVT U,UhLrWU|fv6WLo]- Ђֿ,}ËM_c~VUW} "u4>Xΰ0fUc~h*}Vg(Fh"醊T&K/lB&:֪j,d#5-jh >K|Ķn뤆b]j)e* EQzì<6#Uve]漹FD.3+5܀z~Kc6ީ"Ni}^in@\Pʖ\iF'-c'>aՐ'%]-ckBVlFlsm 6t٦OZM-k[mm0vJ%h@~nǎ['nO ZzS3]&e`V^gVp۠lblipY% KTkMK.2jRRWUFXQ'`@^`RBT vg. L-f rmz$t`q(GX{rann'op)ru1ߎ,-^/gAq%83eWno<V*=o#@OAbČ'7./lWs>-k/CIJErgQsiA'xYD@^{VCsMWsW{uyvuO0/bw>uYK\Du6Ptutj*6Acw3>j/=,K@$USVq_KTZL0.oMS;7^xx`DzWDXy~o+3cq  qUtW %Nngneo;X|4Q@n?ؕ/O>xllWyzy]_z6%k`c+ z|lyLщye㡯5_y5 z>P&۵MIﳿnb&uwį?jWtk,4OoD$EwͶ_gz=}ԾO||z}ez3yg7{5_i|> j _Fwp$.֟P{ئ7}ZOyHH e}i uy~4ooYU퇀!b[gie dˊj,!K8, !`|BRqjb-1l>5F JgSyxi q(z0<0Y1PB.Vzv:pR^ZNv fRb~ fFҮѽMSW[_cgkosw{Cř (^6!Lp!ÆBf\r!8pcb? )r$ɒL _Œ)s&͚6R$cسP *t(ѢF"M*eNB*u*Շ9\xJK+Ӹl4>mW7k옢lm,'fj2{(]6 ".ީL~\mxD{}@6;5 lT r jMdB.9EqA|FBt眧޶H#s˷h Z7u]o+<~h1x:حozc/ _Y5mHi((]ʙP7HC*s\y+ |Y{g >8sL|#MUf4H Ed0:G?&d O//+F|_ NED'×PA nP"/DObZ\"(/1$]^h31ָh1r#h2Ez#6v iC"2ӪGB FHEb2d!x:08%)KuC,]юHzt8ˣm M+Qx˱ |Jd%#"3Δ\&3Da.EQ9d.URK$ !tEbEBfw*7~X/$ @&'> :," 3(BPX$HÃrd:D&&COpFҐ-4bVHSXzK/DKg$& /XҨYI>M[r+Ejիb9ubͅF{g6& j4&|EóM Jlj˄enbniy_kb5,JlG_ ܧSEnö٣纶ֽ&4vk=V/laXfT}x\.BV].s%jdz5`uzViDNn!mU[=ѪP>tjXh^yw %`P_gwqwQ 82R{ GXxE% xիd /avw%Ɯ1ˬL rpeO,9ij': jbWp܂RU#ָY]X;Tjc#;'C(gC[y΂mkc;ۍhxh;<"Cj`ٕ$.ݚ*O^ɱ|&b4L~. 7 gfvoY!]IDpI&ng>y2 n;sl>|1f'poc|﷡E9ы.r"dyN*Ո8uMY7~TTs)}Ӱ/0!aYW 5v߷xda,+?e2[Ś!./q~w!-jk;o~zRy<[ol>x%?T;m^n=7)Uyc@xMyxT3 6LRBbؔ+Xt_̛ ֭]ctT-ޔAp[r1`AK-iO-y\QMa^Sui`vN 6 |%- A z U)うL >W_UGr\O0anܗiH}!`pYչTfRXa^JЕݕV/ kYzUKݙ+@"!~]&rLb)bF'* '^A((,Ң(]*b.r+Z,/c0b1!/N/ 22c3JHAy%%|4@r96F#*I 1#::c8naQ5p_5R_O68‰͹ܼcB*Y ;R >=#.#P @ʩ(΁El-I6eMp UOH5*1OGƤ&DQaRdUZe/AK!W*?^ɣM Lc9><%`Fɕ##~aY[ Uf`bD&ЁeWreX&aBe%tXŒɈLdBeFZ\]~^^6ݤf)`fkGUWҦbfWrf d6fVdL[༘Xfnzf&faZ{L\>f{Jf<[g ʧ!%sg'j>aQu (;NL A٩ ٘o^pKdMGn^r(Jc~Q0U"FE]h&*A|ni2JsJ闂ibjiFH隲)QiEi ⩴)7i&;jhY2j$%iJ.;DFfjjD Rjj6deQnjƓ}HFjnx* ⪨½o(Zhk)=)kvCiRk'kj k*hemkk9c~k{kkufNhokBQhI#):A *bl[PlǞRƊzNQN ʲl˺llllm m"m*2B#R-lbmjrmzׂm؊ؒmlFb)ôch=$­mjզ\ ,Ժm:m>&6n,,2..JnBnZfn.Ң-ZL^6Zj-F$GFݾ+~noo&n/ /FoJ-| Lk#EJQ\6fyҮ\n}Zol:.-~-oV/ok. @ANCKp+N0XݨtlPn0rcP(wѵ/J6 p/.Kn np*1## 0+ڰ01?ng㮱-@A1PrKf>`*ҍ 6*2!07nq;%W2˱_rs2&0(+/%'c.*2N/&orr*&2+202%k2+rq#$TEZ2h ZSnl-"kFLL02**1'/s-;:ϳ:=/=3sS<)sa6OCuRNGATd.sVceGWpXktGtGsy 6KY)J/Zk޵Db6cv+ vb6d3O6e o5pgs<eovR+;/`kqa;RZh=R3Sy3A{zo[5p4eJ3[K wptnDŽR1u+ n'qtwv/8;7wW٢1s7@o5)q1fcq2xvS88Mx1Fxx+3yngS9` cyksKy>VyOŕwyy{I6j3Z9rۭ{p{|#*e&z5f1ulT.B7v?wWn:i$7ޮ:fuE]ڱ|&z>u;;rc+gW:u/w{zya\jFvÅaJ{ǫ_;v)scokiw︲,Szvvb:/;7[ _~dp` CP)Z흿xu§xY{' 81+xWxO11< /1<˗#C>>k?ut䳶[}[\wnzze|dN=6u~3T;{uNctCAJo%{OA1<[49Mź}q0U)Wo,&Zw )wK3X^Y\t>qyM|nƳ $ 2))%1+'!EA7MG'>O]_acegikmogʈfx~X{}{ar͵ QKq-J/Q5j{rJX ?Sx࿆Uu3BYa)_I'QTiR_LmS"]:bH '6,|Lh ͹3m1Vyhҧߚfպyq죕ՔhImڱmڞy;QYs}m[O܋޶",0Iz:^1}„tφ=ti2-h"Q(ִmw(Q+sv#s!\5iw5Ow^|;{J?|B2z]?|׿4js, LP\!p β 1Ͱ 9,iA QO;QYlaQ0Hq̱xQ!п"0@%D'R)+2-/8I&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-2022.10.31/doc/writing_scripts.asciidoc000066400000000000000000000115561432757250600212610ustar00rootroot00000000000000Writing 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-2022.10.31/gdb/000077500000000000000000000000001432757250600143065ustar00rootroot00000000000000kakoune-2022.10.31/gdb/kakoune.py000066400000000000000000000136401432757250600163210ustar00rootroot00000000000000import 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["u"]["s"]["size"] & 1) != 1: ptr = data["u"]["l"]["ptr"] len = data["u"]["l"]["size"] else: ptr = data["u"]["s"]["string"] len = data["u"]["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-2022.10.31/libexec/000077500000000000000000000000001432757250600151655ustar00rootroot00000000000000kakoune-2022.10.31/libexec/kak/000077500000000000000000000000001432757250600157335ustar00rootroot00000000000000kakoune-2022.10.31/libexec/kak/kak000077700000000000000000000000001432757250600203252../../src/kakustar00rootroot00000000000000kakoune-2022.10.31/rc/000077500000000000000000000000001432757250600141565ustar00rootroot00000000000000kakoune-2022.10.31/rc/detection/000077500000000000000000000000001432757250600161345ustar00rootroot00000000000000kakoune-2022.10.31/rc/detection/editorconfig.kak000066400000000000000000000061571432757250600213110ustar00rootroot00000000000000# 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= -- ' $1 == "indent_style" { indent_style = $2 } $1 == "indent_size" { indent_size = $2 == "tab" ? 4 : $2 } $1 == "tab_width" { tab_width = $2 } $1 == "end_of_line" { end_of_line = $2 } $1 == "charset" { charset = $2 } $1 == "trim_trailing_whitespace" { trim_trailing_whitespace = $2 } $1 == "max_line_length" { max_line_length = $2 } END { if (indent_style == "tab") { print "set-option buffer indentwidth 0" } if (indent_style == "space") { print "set-option buffer indentwidth " indent_size } 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+$|\\n+\\zd} } }" } 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 } } complete-command editorconfig-load file kakoune-2022.10.31/rc/detection/file.kak000066400000000000000000000020741432757250600175460ustar00rootroot00000000000000define-command -hidden file-detection %{ 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/plain) exit ;; text/*) filetype="${mime#text/}" ;; application/x-shellscript) filetype="sh" ;; application/x-*) filetype="${mime#application/x-}" ;; application/*) filetype="${mime#application/}" ;; *) exit ;; esac if [ -n "${filetype}" ]; then printf "set-option buffer filetype '%s'\n" "${filetype}" fi fi } } hook -group file-detection global BufOpenFile .* file-detection hook -group file-detection global BufWritePost .* file-detection kakoune-2022.10.31/rc/detection/modeline.kak000066400000000000000000000116131432757250600204220ustar00rootroot00000000000000## ## 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{ kakquote() { printf "%s" "$*" | sed "s/'/''/g; 1s/^/'/; \$s/\$/'/"; } # Translate a vim option into the corresponding kakoune one translate_opt_vim() { local key="$1" local value="$2" case "${key}" in so|scrolloff) key="scrolloff"; value="${value},${kak_opt_scrolloff##*,}";; siso|sidescrolloff) key="scrolloff"; value="${kak_opt_scrolloff%%,*},${value}";; ts|tabstop) key="tabstop";; sw|shiftwidth) key="indentwidth";; tw|textwidth) key="autowrap_column";; ff|fileformat) key="eolformat"; case "${value}" in unix) value="lf";; dos) value="crlf";; *) printf '%s\n' "Unsupported file format: ${value}" >&2 return;; esac ;; ft|filetype) key="filetype";; bomb) key="BOM"; value="utf8";; nobomb) key="BOM"; value="none";; spelllang|spl) key="spell_lang"; value="${value%%,*}";; *) printf '%s\n' "Unsupported vim variable: ${key}" >&2 return;; esac printf 'set-option buffer %s %s\n' "${key}" "$(kakquote "${value}")" } # Pass a few whitelisted options to kakoune directly translate_opt_kakoune() { local readonly key="$1" local readonly value="$2" case "${key}" in scrolloff|tabstop|indentwidth|autowrap_column|eolformat|filetype|BOM|spell_lang);; *) printf 'echo -debug %s' "$(kakquote "Unsupported kakoune variable: ${key}")" \ | kak -p "${kak_session}" return;; esac printf 'set-option buffer %s %s\n' "${key}" "$(kakquote "${value}")" } case "${kak_selection}" in *vi:*|*vim:*) type_selection="vim";; *kak:*|*kakoune:*) type_selection="kakoune";; *) printf 'fail %s\n' "$(kakquote "Unsupported modeline format: ${kak_selection}")" 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]\([^:]*\).*$/\1/' \ -e 's/:[^a-zA-Z0-9_=-]*$//' \ -e 's/:/ /g' \ | tr ' ' '\n' \ | while read -r option; do name_option="${option%%=*}" value_option="${option#*=}" if [ -z "${option}" ]; then continue fi case "${type_selection}" in vim) translate_opt_vim "${name_option}" "${value_option}";; kakoune) translate_opt_kakoune "${name_option}" "${value_option}";; *) exit 1;; esac 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(?S)\A(.+\n){,%opt{modelines}}|(.+\n){,%opt{modelines}}\z" \ s^\S*?\s+?\w+:\s?[^\n]+ x evaluate-commands -draft -itersel modeline-parse-impl } } } kakoune-2022.10.31/rc/filetype/000077500000000000000000000000001432757250600157775ustar00rootroot00000000000000kakoune-2022.10.31/rc/filetype/arch-linux.kak000066400000000000000000000001551432757250600205420ustar00rootroot00000000000000# package build description file hook global BufCreate (.*/)?PKGBUILD %{ set-option buffer filetype sh } kakoune-2022.10.31/rc/filetype/asciidoc.kak000066400000000000000000000066331432757250600202550ustar00rootroot00000000000000# 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 # Delimited blocks # https://docs.asciidoctor.org/asciidoc/latest/blocks/delimited/ add-highlighter shared/asciidoc/ regex ^(-{4,})\n[^\n\h].*?\n(-{4,})$ 0:block add-highlighter shared/asciidoc/ regex ^(={4,})\n[^\n\h].*?\n(={4,})$ 0:block add-highlighter shared/asciidoc/ regex ^(~{4,})\n[^\n\h].*?\n(~{4,})$ 0:block add-highlighter shared/asciidoc/ regex ^(\*{4,})\n[^\n\h].*?\n(\*{4,})$ 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-2022.10.31/rc/filetype/awk.kak000066400000000000000000000066461432757250600172650ustar00rootroot00000000000000# 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 x s \h+$ d ] # indent after line ending in opening curly brace try %[ execute-keys -draft kx \{\h*(#.*)?$ j ] # deindent closing brace when after cursor try %[ execute-keys -draft x ^\h*\} gh / \} m 1 ] ] ] define-command -hidden awk-trim-indent %{ try %{ execute-keys -draft x s ^\h+$ d } } @ kakoune-2022.10.31/rc/filetype/c-family.kak000066400000000000000000000621041432757250600201730ustar00rootroot00000000000000# 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 x 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 kx 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 x ^\h+$ Hd > # indent after an opening brace or parenthesis at end of line try %< execute-keys -draft k x [{(]\h*$ j > # indent after a label try %< execute-keys -draft k x s[a-zA-Z0-9_-]+:\h*$ j > # indent after a statement not followed by an opening brace try %< execute-keys -draft k x s\)\h*(?://[^\n]+)?\n\z \ mB \A\b(if|for|while)\b j > try %< execute-keys -draft k x s \belse\b\h*(?://[^\n]+)?\n\z \ j > # deindent after a single line statement end try %< execute-keys -draft K x \;\h*(//[^\n]+)?$ \ K x s\)(\h+\w+)*\h*(//[^\n]+)?\n([^\n]*\n){2}\z \ MB \A\b(if|for|while)\b 1 > try %< execute-keys -draft K x \;\h*(//[^\n]+)?$ \ K x s \belse\b\h*(?://[^\n]+)?\n([^\n]*\n){2}\z \ 1 > # deindent closing brace(s) when after cursor try %< execute-keys -draft x ^\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 x 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 hmxBx \A[^\n]+\)\h*(\{|$) \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 x1s^\h*(//+\h*) y try %[ # if the previous comment isn't empty, create a new one execute-keys x^\h*//+\h*$ jxs^\h*P ] catch %[ # if there is no text in the previous comment, remove it completely execute-keys d ] ] # trim trailing whitespace on the previous line try %[ execute-keys -draft k x s\h+$ d ] ] try %[ # if the previous line isn't within a comment scope, break execute-keys -draft kx ^(\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 kx^\h*/\* execute-keys -draft i* ] catch %[ try %[ # if the next line is a comment line insert a star execute-keys -draft jx^\h+\* execute-keys -draft i* ] catch %[ try %[ # if the previous line is an empty comment line, close the comment scope execute-keys -draft kx^\h+\*\h+$ x1s\*(\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 k x s\h+$ d ] # align the new star with the previous one execute-keys Kx1s^[^*]*(\*)& ] ] ] # 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(?xs^.*/dxs\.r_A_INCLUDEDxyPPI#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 case "$alt_dir" in /*) altname="${alt_dir}/${file_noext}.${ext}" ;; *) altname="${dir}/${alt_dir}/${file_noext}.${ext}" ;; esac 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 case "$alt_dir" in /*) altname="${alt_dir}/${file_noext}.${ext}" ;; *) altname="${dir}/${alt_dir}/${file_noext}.${ext}" ;; esac 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-2022.10.31/rc/filetype/cabal.kak000066400000000000000000000061271432757250600175370ustar00rootroot00000000000000# 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-insert cabal-insert-on-new-line 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 x s \h+$ d } } define-command -hidden cabal-insert-on-new-line %[ evaluate-commands -draft -itersel %[ # copy '--' comment prefix and following white spaces try %[ execute-keys -draft k x s ^\h*\K--\h* y gh j P ] ] ] define-command -hidden cabal-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 : cabal-trim-indent ] # indent after lines ending with { or : try %[ execute-keys -draft , k x [:{]$ j ] # deindent closing brace when after cursor try %[ execute-keys -draft x \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-2022.10.31/rc/filetype/clojure.kak000066400000000000000000000304041432757250600201330ustar00rootroot00000000000000# 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-2022.10.31/rc/filetype/cmake.kak000066400000000000000000000025221432757250600175500ustar00rootroot00000000000000hook 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/comment region '#' '$' fill comment add-highlighter shared/cmake/argument/quoted region '"' '(? d } } } define-command -hidden coffee-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k x s '^\h*\K#\h*' y gh j P } } } define-command -hidden coffee-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 : coffee-trim-indent } # indent after start structure try %{ execute-keys -draft k x ^ \h * (case|catch|class|else|finally|for|function|if|switch|try|while|with) \b | (=|->) $ j } } } ] kakoune-2022.10.31/rc/filetype/conf.kak000066400000000000000000000015111432757250600174120ustar00rootroot00000000000000hook global BufCreate .+\.(repo|cfg|properties|desktop) %{ set-option buffer filetype conf } hook global WinCreate .+\.ini %{ try %{ execute-keys /^\h*# set-option buffer filetype conf } } hook global WinSetOption filetype=conf %{ require-module conf } hook -group conf-highlight global WinSetOption filetype=conf %{ add-highlighter window/conf ref conf hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/conf } } provide-module conf %{ add-highlighter shared/conf regions add-highlighter shared/conf/code default-region group add-highlighter shared/conf/comment region '(^|\h)\K#' $ fill comment add-highlighter shared/conf/code/ regex "(?S)^\h*(\[.+?\])\h*$" 1:title add-highlighter shared/conf/code/ regex "^\h*([^\[][^=\n]*)=([^\n]*)" 1:variable 2:value } kakoune-2022.10.31/rc/filetype/coq.kak000066400000000000000000000127601432757250600172570ustar00rootroot00000000000000 # Detection # -------- hook global BufCreate .*\.v %{ set-option buffer filetype coq } # Initialization # -------------- hook global WinSetOption filetype=coq %{ require-module coq hook window ModeChange pop:insert:.* -group coq-trim-indent coq-trim-indent 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 x s ^\h+ y gh j P } } } define-command -hidden coq-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } } } kakoune-2022.10.31/rc/filetype/crystal.kak000066400000000000000000000331061432757250600201530ustar00rootroot00000000000000# 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 ModeChange pop:insert:.* -group crystal-trim-indent crystal-trim-indent 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="(? d } } } define-command -hidden crystal-indent-on-char %{ evaluate-commands -no-hooks -draft -itersel %{ # align 'else' to 'if/case' try %{ execute-keys -draft x ^\h*else$ i ^\h*(?:if|case) 1 } # align 'elsif' to 'if' try %{ execute-keys -draft x ^\h*elsif$ i ^\h*(?:if) 1 } # align 'when' to 'case' try %{ execute-keys -draft x ^\h*when$ i ^\h*(?:case) 1 } # align 'rescue' to 'begin/def' try %{ execute-keys -draft x ^\h*rescue$ i ^\h*(?:begin|def) 1 } # align 'end' to opening structure try %{ execute-keys -draft x ^\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 :crystal-trim-indent } # Indent after start structure/opening statement try %{ execute-keys -draft k x ^\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 x s '^\h*\K#\h*' y j x P } # wisely add end structure evaluate-commands -save-regs x %[ try %{ execute-keys -draft k x s ^ \h + \" x y } catch %{ reg x '' } try %[ evaluate-commands -draft %[ # Check if previous line opens a block execute-keys -draft kx ^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 ^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-2022.10.31/rc/filetype/css.kak000066400000000000000000000172651432757250600172720ustar00rootroot00000000000000# 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-insert css-insert-on-new-line 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 '_' '-' set-face global cssLogicalOperator +i@keyword 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/code default-region group add-highlighter shared/css/attr_selector region \[ \] regions add-highlighter shared/css/double_string region '"' (? below # includes elements that cannot be styled, which is fine. # # https://developer.mozilla.org/en-US/docs/Web/HTML/Element html_tags='html body address article aside footer header h1 h2 h3 h4 h5 h6 main nav section blockquote dd div dl dt figcaption figure hr li ol p pre ul a abbr b bdi bdo br cite code data dfn em i kbd mark q rp rt ruby s samp small span strong sub sup time u var wbr area audio img map track video embed iframe object param picture portal source canvas noscript script del ins caption col colgroup table tbody td tfoot th thead tr button datalist fieldset form input label legend meter optgroup option output progress select textarea details dialog menu summary slot template acronym applet basefont bgsound big blink center content dir font frame frameset hgroup image keygen marquee menuitem nobr noembed noframes plaintext rb rtc shadow spacer strike tt xmp' # Units # ‾‾‾‾‾ # generated from the URL & below # includes #rgb, #rrggbb, #rrggbbaa as color values {3,8} # # https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Values_and_Units units='% cap ch cm deg dpcm dpi dppx em ex grad Hz ic in kHz lh mm ms pc pt px Q rad rem rlh s turn vb vh vi vmax vmin vw x' logical_ops='and not only from to' keywords='!important auto inherit initial unset none' media_types='all print screen speech' # easing_re='linear|ease(-(in-out|in|out))?|step-(start|end)' # combinators='+ > ~ ||' # attribute_op='= ~= |= ^= $= *=' join() { eval set -- $1; IFS="|"; echo "$*"; } # Selectors # ‾‾‾‾‾‾‾‾‾ # universal: *, ns|*, *|*, |* # class/id: .class, #id # type: element # attr: [attr=val] # order below matters printf %s " add-highlighter shared/css/code/tag_selectors regex \b($(join "${html_tags}"))((:[a-z:])|[\h.#,]) 1:keyword add-highlighter shared/css/code/functional_notation regex ([a-zA-Z0-9-_]+[a-zA-Z0-9])\( 1:keyword add-highlighter shared/css/code/logical_operators regex (\b($(join "${logical_ops}"))\b|$(join "${keywords}")) 1:cssLogicalOperator add-highlighter shared/css/code/media_types regex \b($(join "${media_types}"))\b 1:+i # (after functional notation as they may contain paranthesis) add-highlighter shared/css/code/pseudo regex (:{1,2})([a-z-]+) 0:attribute add-highlighter shared/css/code/at_rules regex @[a-z-]+ 0:function add-highlighter shared/css/code/css_property regex ([A-Za-z][A-Za-z0-9_-]*)\h*:\h 1:operator 1:+a add-highlighter shared/css/code/selectors regex (\*|[*]?[.][A-Za-z][A-Za-z0-9_-]+) 0:type add-highlighter shared/css/code/selectors_id regex (\*|[*]?[#][A-Za-z][A-Za-z0-9_-]+) 0:type 0:+i add-highlighter shared/css/code/hex_values regex (#[0-9A-Fa-f]{3,8})\b 0:value 0:+a add-highlighter shared/css/code/units regex \b(\d*\.)?\d+($(join "${units}"))?\b 0:value 0:+a " } # Attribute Selectors add-highlighter shared/css/attr_selector/base default-region group add-highlighter shared/css/attr_selector/base/ regex ([a-zA-Z0-9-]+) 1:attribute add-highlighter shared/css/attr_selector/base/ regex \h(i|s) 1:type add-highlighter shared/css/attr_selector/double_string region '"' (? d } } define-command -hidden css-indent-on-new-line %[ 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 kx 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 > # filter previous line try %< execute-keys -draft k x ^\h+$ Hd > # indent after lines ending with with { try %[ execute-keys -draft k x \{$ j ] # deindent closing brace when after cursor try %[ execute-keys -draft x ^\h*\} gh / \} m 1 ] ] ] define-command -hidden css-insert-on-new-line %[ evaluate-commands -draft -itersel %< execute-keys try %[ # if the previous line isn't within a comment scope, break execute-keys -draft kx ^(\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 kx^\h*/\* execute-keys -draft i* ] catch %[ try %[ # if the next line is a comment line insert a star execute-keys -draft jx^\h+\* execute-keys -draft i* ] catch %[ try %[ # if the previous line is an empty comment line, close the comment scope execute-keys -draft kx^\h+\*\h+$ x1s\*(\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 Kx1s^[^*]*(\*)& ] > ] 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-2022.10.31/rc/filetype/cucumber.kak000066400000000000000000000063341432757250600203020ustar00rootroot00000000000000# 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-insert cucumber-insert-on-new-line 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 x s \h+$ d } } define-command -hidden cucumber-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K#\h* y gh j P } } } define-command -hidden cucumber-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 : cucumber-trim-indent } # indent after lines containing : try %{ execute-keys -draft , k x : j } } } } kakoune-2022.10.31/rc/filetype/cue.kak000066400000000000000000000145701432757250600172520ustar00rootroot00000000000000# 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-insert cue-insert-on-new-line 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 x s \h+$ d } } define-command -hidden cue-insert-on-new-line %~ evaluate-commands -draft -itersel %< # copy // comments prefix and following white spaces try %{ execute-keys -draft kx s ^\h*\K//[!/]?\h* yP } > ~ define-command -hidden cue-indent-on-new-line %~ evaluate-commands -draft -itersel %< # preserve previous line indent try %{ execute-keys -draft K } try %< # only if we didn't copy a comment execute-keys -draft x ^\h*// # indent after lines ending with { or ( try %[ execute-keys -draft k x [{(]\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 x ^\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-2022.10.31/rc/filetype/d.kak000066400000000000000000000160451432757250600167200ustar00rootroot00000000000000# 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 xs^\h+$d } } hook window InsertChar \n -group d-insert d-insert-on-new-line 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 %{(?kx s ^\h*\K/{2,}\h* yP } = ~ define-command -hidden d-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 kx [{(]\h*$ j ] # cleanup trailing white spaces on the previous line try %{ execute-keys -draft kx s \h+$ d } # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # indent after a switch's case/default statements try %[ execute-keys -draft kx ^\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 x ^\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-2022.10.31/rc/filetype/dart.kak000066400000000000000000000123301432757250600174200ustar00rootroot00000000000000# 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 xs^\h+$d } } hook window InsertChar \n -group dart-insert dart-insert-on-new-line 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/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-insert-on-new-line %~ evaluate-commands -draft -itersel %= # copy // comments prefix and following white spaces try %{ execute-keys -draft kx s ^\h*\K/{2,}\h* yP } = ~ 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 kx [{(]\h*$ j ] # cleanup trailing white spaces on the previous line try %{ execute-keys -draft kx s \h+$ d } # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # indent after a switch's case/default statements try %[ execute-keys -draft kx ^\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 x ^\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-2022.10.31/rc/filetype/dhall.kak000066400000000000000000000074711432757250600175640ustar00rootroot00000000000000# 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 pop:insert:.* -group dhall-trim-indent dhall-trim-indent hook window InsertChar \n -group dhall-insert dhall-insert-on-new-line 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 x s \h+$ d } } define-command -hidden dhall-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comments prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K--\h* y gh j P } } } define-command -hidden dhall-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 : dhall-trim-indent } # indent after lines ending with let, : or = try %{ execute-keys -draft \; k x (\blet|:|=)$ j } } } ] kakoune-2022.10.31/rc/filetype/diff.kak000066400000000000000000000166471432757250600174150ustar00rootroot00000000000000hook global BufCreate .*\.(diff|patch) %{ set-option buffer filetype diff } hook global WinSetOption filetype=diff %{ require-module diff map buffer normal :diff-jump } hook -group diff-highlight global WinSetOption filetype=diff %{ add-highlighter window/diff ref diff hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/diff } } provide-module 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 # If any trailing whitespace was introduced in diff, show it with red background add-highlighter shared/diff/ regex "^\+[^\n]*?(\h+)\n" 1:default,red define-command diff-jump -params .. -docstring %{ diff-jump [] []: edit the diff's source file at the cursor position. Paths are resolved relative to , or the current working directory if unspecified. Switches: - jump to the old file instead of the new file - strip leading directory components, like -p in patch(1). Defaults to 1 if there is a 'diff' line (as printed by 'diff -r'), or 0 otherwise. } %{ evaluate-commands -draft -save-regs ac| %{ # Save the column because we will move the cursor. set-register c %val{cursor_column} # If there is a "diff" line, we don't need to look further back. try %{ execute-keys %{^(?:> )*diff\bx} } catch %{ # A single file diff won't have a diff line. Start parsing from # the buffer start, so we can tell if +++/--- lines are headers # or content. execute-keys Gk } set-register a %arg{@} set-register | %{ [ -n "$kak_reg_a" ] && eval set -- $kak_quoted_reg_a cmd=$(column=$kak_reg_c perl -we ' sub quote { $SQ = "'\''"; $token = shift; $token =~ s/$SQ/$SQ$SQ/g; return "$SQ$token$SQ"; } sub fail { $reason = shift; print "fail " . quote("diff-jump: $reason"); exit; } $version = "+", $other_version = "-"; $strip = undef; $directory = $ENV{PWD}; $seen_ddash = 0; foreach (@ARGV) { if ($seen_ddash or !m{^-}) { $directory = $_; } elsif ($_ eq "-") { $version = "-", $other_version = "+"; } elsif (m{^-(\d+)$}) { $strip = $1; } elsif ($_ eq "--") { $seen_ddash = 1; } else { fail "unknown option: $_"; } } $have_diff_line = 0; $state = "header"; while () { s/^(> )*//g; $last_line = $_; if (m{^diff\b}) { $state = "header"; $have_diff_line = 1; if (m{^diff -\S* (\S+) (\S+)$}) { $fallback_file = $version eq "+" ? $2 : $1; } next; } if ($state eq "header") { if (m{^[$version]{3} ([^\t\n]+)}) { $file = $1; next; } if (m{^[$other_version]{3} ([^\t\n]+)}) { $fallback_file = $1; next; } } if (m{^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@}) { $state = "contents"; $line = ($version eq "+" ? $2 : $1) - 1; } elsif (m{^[ $version]}) { $line++ if defined $line; } } if (not defined $file) { $file = $fallback_file; } if (not defined $file) { fail "missing diff header"; } if (not defined $strip) { # A "diff -r" or "git diff" adds "diff" lines to # the output. If no such line is present, we have # a plain diff between files (not directories), so # there should be no need to strip the directory. $strip = $have_diff_line ? 1 : 0; } if ($file !~ m{^/}) { $file =~ s,^([^/]+/+){$strip},, or fail "directory prefix underflow"; $file = "$directory/$file"; } if (defined $line) { $column = $ENV{column} - 1; # Account for [ +-] diff prefix. # If the cursor was on a hunk header, go to the section header if possible. if ($last_line =~ m{^(@@ -\d+(?:,\d+)? \+\d+(?:,\d+) @@ )([^\n]*)}) { $hunk_header_prefix = $1; $hunk_header_from_userdiff = $2; open FILE, "<", $file or fail "failed to open file: $!: $file"; @lines = ; for (my $i = $line - 1; $i >= 0 && $i < scalar @lines; $i--) { if ($lines[$i] !~ m{\Q$hunk_header_from_userdiff}) { next; } $line = $i + 1; # Re-add 1 because the @@ line does not have a [ +-] diff prefix. $column = $column + 1 - length $hunk_header_prefix; last; } } } printf "edit -existing -- %s $line $column", quote($file); ' -- "$@") echo "set-register c $cmd" >"$kak_command_fifo" } execute-keys evaluate-commands -client %val{client} %{ evaluate-commands -try-client %opt{jumpclient} %{ %reg{c} } } } } complete-command diff-jump file § 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-2022.10.31/rc/filetype/dockerfile.kak000066400000000000000000000035451432757250600206050ustar00rootroot00000000000000# http://docker.com # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # See https://docs.docker.com/reference/builder # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*/?Dockerfile(\..+)?$ %{ 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 x s \h+$ d } } define-command -hidden elixir-insert-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K#\h* y jgi P } # wisely add end structure evaluate-commands -save-regs x %[ try %{ execute-keys -draft k x s ^ \h + \" x y } catch %{ reg x '' } try %[ evaluate-commands -draft %[ # Check if previous line opens a block execute-keys -draft kx ^x(.+\bdo$) # Check that we do not already have an end for this indent level which is first set via `elixir-indent-on-new-line` hook execute-keys -draft }i J x ^x(end|else)[^0-9A-Za-z_!?] ] execute-keys -draft oxend # insert a new line with containing end ] ] ] ] define-command -hidden elixir-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # 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-2022.10.31/rc/filetype/elm.kak000066400000000000000000000067351432757250600172570ustar00rootroot00000000000000# 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-insert elm-insert-on-new-line 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 x 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-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comments prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K--\h* y gh j P } } } define-command -hidden elm-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # 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-2022.10.31/rc/filetype/elvish.kak000066400000000000000000000067041432757250600177700ustar00rootroot00000000000000# Syntax highlighting and indentation for Elvish (https://elv.sh) hook global BufCreate .*\.elv %{ set-option buffer filetype elvish } hook global WinSetOption filetype=elvish %< require-module elvish hook window ModeChange pop:insert:.* -group elvish-trim-indent elvish-trim-indent hook window InsertChar \n -group elvish-insert elvish-indent hook window InsertChar [\]})] -group elvish-insert elvish-deindent hook -once -always window WinSetOption filetype=.* %{ remove-hooks window elvish-.+ } > hook -group elvish-highlight global WinSetOption filetype=elvish %{ add-highlighter window/elvish ref elvish hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/elvish } } provide-module elvish %§ add-highlighter shared/elvish regions add-highlighter shared/elvish/code default-region group add-highlighter shared/elvish/double_string region '"' (?|>=|>=s|>s|all|assoc|base|bool|break|call|cd|compare|constantly|continue|count|defer|deprecate|dissoc|drop|each|eawk|echo|eq|eval|exact-num|exec|exit|external|fail|fg|float64|from-json|from-lines|from-terminated|get-env|has-env|has-external|has-key|has-value|is|keys|kind-of|make-map|multi-error|nop|not-eq|not|ns|num|one|only-bytes|only-values|order|peach|pprint|print|printf|put|rand|randint|range|read-line|read-upto|repeat|repr|resolve|return|run-parallel|search-external|set-env|show|sleep|slurp|src|styled|styled-segment|take|tilde-abbr|time|to-json|to-lines|to-string|to-terminated|unset-env|use-mod|wcswidth)(?![-:])\b 1:builtin add-highlighter shared/elvish/code/keyword regex (?:^|\{\s|\(|\||\;)\h*(use|var|set|tmp|del|and|or|coalesce|pragma|while|for|try|fn|if)(?![-:])\b 1:keyword add-highlighter shared/elvish/code/keyword_block regex \}\h+(catch|elif|else|except|finally)(?![-:])\b 1:keyword add-highlighter shared/elvish/code/metachar regex [*?|&\;<>()[\]{}] 0:operator define-command -hidden elvish-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } } define-command -hidden elvish-indent %< evaluate-commands -draft -itersel %< execute-keys try %< # if the previous line is a comment, copy indent, # and whitespace execute-keys -draft k x s^\h*#\h* yjP > catch %< # copy indent execute-keys -draft K # indent after { [ ( | try %< execute-keys -draft k x [[{(|]\h*$ j > > >> define-command -hidden elvish-deindent %< evaluate-commands -draft -itersel %< try %< # Deindent only when there is a lone closing character execute-keys -draft x ^\h*[^\h]$ > >> § kakoune-2022.10.31/rc/filetype/erlang.kak000066400000000000000000000062341432757250600177440ustar00rootroot00000000000000# Erlang/OTP # https://erlang.org # ---------------------- # Detection and Initialization sections were adapted from rc/filetype/elixir.kak # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](erl|hrl) %{ set-option buffer filetype erlang } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=erlang %{ require-module erlang hook -once -always window WinSetOption filetype=.* %{ remove-hooks window erlang-.+ } } hook -group erlang-highlight global WinSetOption filetype=erlang %{ add-highlighter window/erlang ref erlang hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/erlang } } provide-module erlang %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/erlang regions add-highlighter shared/erlang/default default-region group add-highlighter shared/erlang/comment region '(? add-highlighter shared/erlang/default/ref regex '#Ref<\d+\.\d+\.\d+\.\d+>' 0:value # e.g. #Port<0.1> add-highlighter shared/erlang/default/port regex '#Port<\d+\.\d+>' 0:value # e.g. <0.401.0> add-highlighter shared/erlang/default/pid regex '<\d+\.\d+\.\d+>' 0:value add-highlighter shared/erlang/default/base_number regex '\b(\d[_\d]*(?' ref ruby add-highlighter shared/eruby/simple-execution-tag region '<%' '%>' ref ruby add-highlighter shared/eruby/simple-comment-tag region '<%#' '%>' fill comment } kakoune-2022.10.31/rc/filetype/etc.kak000066400000000000000000000110261432757250600172420ustar00rootroot00000000000000# 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-2022.10.31/rc/filetype/exherbo.kak000066400000000000000000000201061432757250600201220ustar00rootroot00000000000000## 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-2022.10.31/rc/filetype/fennel.kak000066400000000000000000000114631432757250600177430ustar00rootroot00000000000000# http://fennel-lang.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.]fnl %{ set-option buffer filetype fennel } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=fennel %{ require-module fennel fennel-configure-window } hook -group fennel-highlight global WinSetOption filetype=fennel %{ add-highlighter window/fennel ref fennel hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/fennel } } provide-module fennel %{ require-module lisp # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/fennel regions add-highlighter shared/fennel/code default-region group add-highlighter shared/fennel/comment region '(?]' '(?![-\w?\\^_!$%&*+./@|<=>])' fill keyword add-highlighter shared/fennel/code/ regex \\(?:space|tab|newline|return|backspace|formfeed|u[0-9a-fA-F]{4}|o[0-3]?[0-7]{1,2}|.)\b 0:string evaluate-commands %sh{ # Grammar keywords="require-macros eval-compiler doc lua hashfn macro macros import-macros pick-args pick-values macroexpand macrodebug do values if when each for fn lambda λ partial while set global var local let tset set-forcibly! doto match or and not not= collect icollect accumulate rshift lshift bor band bnot bxor with-open" re_keywords='\\$ \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9 \\$\\.\\.\\.' builtins="_G _VERSION arg assert bit32 collectgarbage coroutine debug dofile error getfenv getmetatable io ipairs length load loadfile loadstring math next os package pairs pcall print rawequal rawget rawlen rawset require select setfenv setmetatable string table tonumber tostring type unpack xpcall" 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 fennel_static_words $(join "${keywords} ${builtins} false nil true" ' ')" # Highlight keywords printf %s " add-highlighter shared/fennel/code/keywords regex \b($(join "${keywords} ${re_keywords}" '|'))\b 0:keyword add-highlighter shared/fennel/code/builtins regex \b($(join "${builtins}" '|'))\b 0:builtin " } add-highlighter shared/fennel/code/operator regex (\.|\?\.|\+|\.\.|\^|-|\*|%|/|>|<|>=|<=|=|\.\.\.|:|->|->>|-\?>|-\?>>) 0:operator add-highlighter shared/fennel/code/value regex \b(false|nil|true|[0-9]+(:?\.[0-9])?(:?[eE]-?[0-9]+)?|0x[0-9a-fA-F])\b 0:value add-highlighter shared/fennel/code/function_declaration regex \((?:fn|lambda|λ)\s+([\S]+) 1:function add-highlighter shared/fennel/code/method_call regex (?:\w+|\$[0-9]{0,1}):(\S+)\b 1:function # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden fennel-configure-window %{ set-option window static_words %opt{fennel_static_words} hook window ModeChange pop:insert:.* -group fennel-trim-indent fennel-trim-indent hook window InsertChar \n -group fennel-indent fennel-indent-on-new-line set-option buffer extra_word_chars '_' . / * ? + - < > ! : "'" hook -once -always window WinSetOption filetype=.* %{ remove-hooks window fennel-.+ } } define-command -hidden fennel-trim-indent lisp-trim-indent declare-option \ -docstring 'regex matching the head of forms which have options *and* indented bodies' \ regex fennel_special_indent_forms \ '(?:if|when|each|for|fn|lambda|λ|partial|while|local|var|doto|let)' define-command -hidden fennel-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{fennel_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&,' } } } kakoune-2022.10.31/rc/filetype/fidl.kak000066400000000000000000000060201432757250600174030ustar00rootroot00000000000000# Detection hook global BufCreate .*\.fidl %{ set-option buffer filetype fidl } hook global WinSetOption filetype=fidl %< require-module fidl hook window ModeChange pop:insert:.* -group fidl-trim-indent fidl-trim-indent hook window InsertChar \n -group fidl-indent fidl-indent-on-new-line hook window InsertChar [)}] -group fidl-indent fidl-indent-on-closing hook -once -always window WinSetOption filetype=.* %{ remove-hooks window fidl-.+ } > hook -group fidl-highlight global WinSetOption filetype=fidl %{ add-highlighter window/fidl ref fidl hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/fidl } } provide-module fidl %§ # Highlighters add-highlighter shared/fidl regions add-highlighter shared/fidl/code default-region group add-highlighter shared/fidl/string region \" (? d } } define-command -hidden fidl-indent-on-new-line %~ evaluate-commands -draft -itersel %@ try %{ # line comment # copy the commenting prefix execute-keys -draft k x s ^\h*/{2,}\h* yjghP } catch %` # preserve previous line indent try %{ execute-keys -draft K } # align to opening ( or { if possible try %+ execute-keys -draft [)}] m 1 + catch %+ # indent after lines ending with ( or { try %! execute-keys -draft k x [({]$ j ! + ` # remove trailing white spaces try %{ execute-keys -draft k : fidl-trim-indent } @ ~ define-command -hidden fidl-indent-on-closing %~ evaluate-commands -draft -itersel %@ # align to opening ( or { when alone on a line try %< execute-keys -draft ^\h*[)}]$ m 1 > @ ~ § kakoune-2022.10.31/rc/filetype/fish.kak000066400000000000000000000067561432757250600174360ustar00rootroot00000000000000# http://fishshell.com # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](fish) %{ set-option buffer filetype fish } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=fish %{ require-module fish hook window ModeChange pop:insert:.* -group fish-trim-indent fish-trim-indent hook window InsertChar .* -group fish-indent fish-indent-on-char hook window InsertChar \n -group fish-insert fish-insert-on-new-line 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 (? 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 x^\h*(else)$^\h*(if)s\A|.\z1 } try %{ execute-keys -draft x^\h*(end)$^\h*(begin|for|function|if|switch|while)s\A|.\z1 } try %{ execute-keys -draft x^\h*(case)$^\h*(switch)s\A|.\z1 } } } define-command -hidden fish-insert-on-new-line %{ evaluate-commands -no-hooks -draft -itersel %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k x s ^\h*#\h* y jgh P } } } define-command -hidden fish-indent-on-new-line %{ evaluate-commands -no-hooks -draft -itersel %{ # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line try %{ execute-keys -draft k x s \h+$ d } # indent after start structure try %{ execute-keys -draft kx^\h*(begin|case|else|for|function|if|while)\bj } } } } kakoune-2022.10.31/rc/filetype/fsharp.kak000066400000000000000000000167251432757250600177650ustar00rootroot00000000000000# 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 ModeChange pop:insert:.* -group fsharp-trim-indent fsharp-trim-indent hook window InsertChar \n -group fsharp-insert fsharp-insert-on-new-line 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 %{(? d } } } define-command -hidden fsharp-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy // comments prefix and following white spaces try %{ execute-keys -draft k x s ^\h*//\h* y jgh P } } } define-command -hidden fsharp-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 x s \h+$ d } # indent after line ending with = try %{ execute-keys -draft , k x =$ j } # indent after line ending with "do" try %{ execute-keys -draft , k x \bdo$ j } } } § kakoune-2022.10.31/rc/filetype/gas.kak000066400000000000000000000114731432757250600172470ustar00rootroot00000000000000# Detection # --------- hook global BufCreate .*\.(s|S|asm)$ %{ set-option buffer filetype gas } hook global WinSetOption filetype=gas %{ require-module gas hook window ModeChange pop:insert:.* -group gas-trim-indent gas-trim-indent 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 '"' (? 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 x :$ j ] > ~ } kakoune-2022.10.31/rc/filetype/gdscript.kak000066400000000000000000000355541432757250600203220ustar00rootroot00000000000000# http://godotengine.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](gd) %{ set-option buffer filetype gdscript } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=gdscript %{ require-module gdscript set-option window static_words %opt{gdscript_static_words} hook window InsertChar \n -group gdscript-insert gdscript-insert-on-new-line hook window InsertChar \n -group gdscript-indent gdscript-indent-on-new-line # cleanup trailing whitespaces on current line insert end hook window ModeChange pop:insert:.* -group gdscript-trim-indent %{ try %{ execute-keys -draft x s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window gdscript-.+ } } hook -group gdscript-highlight global WinSetOption filetype=gdscript %{ add-highlighter window/gdscript ref gdscript hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/gdscript } } provide-module gdscript %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/gdscript regions add-highlighter shared/gdscript/code default-region group add-highlighter shared/gdscript/double_string region '"' (?]+?>)?\( 1:function add-highlighter shared/gdscript/code/ regex '(?:\+|-|\*|/|%|=|<|>|&|\||\^|~|:=)' 0:operator evaluate-commands %sh{ keywords="if elif else for while match break continue pass return class class_name extends is as self tool signal func static const enum var onready export setget breakpoint preload yield assert remote master puppet remotesync mastersync puppetsync PI TAU INF NAN" values="false true null" types="bool int float void null Vector2 Rect2 Vector3 Transform2D Plane Quat AABB Basis Transform Color NodePath RID Object Array Dictionary" builtin_classes="@GDScript @GlobalScope AABB AcceptDialog AnimatedSprite AnimatedSprite3D AnimatedTexture Animation AnimationNode AnimationNodeAdd2 AnimationNodeAdd3 AnimationNodeAnimation AnimationNodeBlend2 AnimationNodeBlend3 AnimationNodeBlendSpace1D AnimationNodeBlendSpace2D AnimationNodeBlendTree AnimationNodeOneShot AnimationNodeOutput AnimationNodeStateMachine AnimationNodeStateMachinePlayback AnimationNodeStateMachineTransition AnimationNodeTimeScale AnimationNodeTimeSeek AnimationNodeTransition AnimationPlayer AnimationRootNode AnimationTrackEditPlugin AnimationTree AnimationTreePlayer Area Area2D Array ArrayMesh ARVRAnchor ARVRCamera ARVRController ARVRInterface ARVRInterfaceGDNative ARVROrigin ARVRPositionalTracker ARVRServer AspectRatioContainer AStar AStar2D AtlasTexture AudioBusLayout AudioEffect AudioEffectAmplify AudioEffectBandLimitFilter AudioEffectBandPassFilter AudioEffectCapture AudioEffectChorus AudioEffectCompressor AudioEffectDelay AudioEffectDistortion AudioEffectEQ AudioEffectEQ10 AudioEffectEQ21 AudioEffectEQ6 AudioEffectFilter AudioEffectHighPassFilter AudioEffectHighShelfFilter AudioEffectInstance AudioEffectLimiter AudioEffectLowPassFilter AudioEffectLowShelfFilter AudioEffectNotchFilter AudioEffectPanner AudioEffectPhaser AudioEffectPitchShift AudioEffectRecord AudioEffectReverb AudioEffectSpectrumAnalyzer AudioEffectSpectrumAnalyzerInstance AudioEffectStereoEnhance AudioServer AudioStream AudioStreamGenerator AudioStreamGeneratorPlayback AudioStreamMicrophone AudioStreamMP3 AudioStreamOGGVorbis AudioStreamPlayback AudioStreamPlaybackResampled AudioStreamPlayer AudioStreamPlayer2D AudioStreamPlayer3D AudioStreamRandomPitch AudioStreamSample BackBufferCopy BakedLightmap BakedLightmapData BaseButton Basis BitMap BitmapFont Bone2D BoneAttachment bool BoxContainer BoxShape BulletPhysicsServer Button ButtonGroup Camera Camera2D CameraFeed CameraServer CameraTexture CanvasItem CanvasItemMaterial CanvasLayer CanvasModulate CapsuleMesh CapsuleShape CapsuleShape2D CenterContainer CharFXTransform CheckBox CheckButton CircleShape2D ClassDB ClippedCamera CollisionObject CollisionObject2D CollisionPolygon CollisionPolygon2D CollisionShape CollisionShape2D Color ColorPicker ColorPickerButton ColorRect ConcavePolygonShape ConcavePolygonShape2D ConeTwistJoint ConfigFile ConfirmationDialog Container Control ConvexPolygonShape ConvexPolygonShape2D CPUParticles CPUParticles2D Crypto CryptoKey CSGBox CSGCombiner CSGCylinder CSGMesh CSGPolygon CSGPrimitive CSGShape CSGSphere CSGTorus CSharpScript CubeMap CubeMesh Curve Curve2D Curve3D CurveTexture CylinderMesh CylinderShape DampedSpringJoint2D Dictionary DirectionalLight Directory DTLSServer DynamicFont DynamicFontData EditorExportPlugin EditorFeatureProfile EditorFileDialog EditorFileSystem EditorFileSystemDirectory EditorImportPlugin EditorInspector EditorInspectorPlugin EditorInterface EditorNavigationMeshGenerator EditorPlugin EditorProperty EditorResourceConversionPlugin EditorResourcePreview EditorResourcePreviewGenerator EditorSceneImporter EditorSceneImporterFBX EditorScenePostImport EditorScript EditorSelection EditorSettings EditorSpatialGizmo EditorSpatialGizmoPlugin EditorSpinSlider EditorVCSInterface EncodedObjectAsID Engine Environment Expression ExternalTexture File FileDialog FileSystemDock float Font FuncRef GDNative GDNativeLibrary GDScript GDScriptFunctionState Generic6DOFJoint Geometry GeometryInstance GIProbe GIProbeData GodotSharp Gradient GradientTexture GraphEdit GraphNode GridContainer GridMap GrooveJoint2D HashingContext HBoxContainer HeightMapShape HingeJoint HScrollBar HSeparator HSlider HSplitContainer HTTPClient HTTPRequest Image ImageTexture ImmediateGeometry Input InputEvent InputEventAction InputEventGesture InputEventJoypadButton InputEventJoypadMotion InputEventKey InputEventMagnifyGesture InputEventMIDI InputEventMouse InputEventMouseButton InputEventMouseMotion InputEventPanGesture InputEventScreenDrag InputEventScreenTouch InputEventWithModifiers InputMap InstancePlaceholder int InterpolatedCamera IP ItemList JavaClass JavaClassWrapper JavaScript JNISingleton Joint Joint2D JSON JSONParseResult JSONRPC KinematicBody KinematicBody2D KinematicCollision KinematicCollision2D Label LargeTexture Light Light2D LightOccluder2D Line2D LineEdit LineShape2D LinkButton Listener MainLoop MarginContainer Marshalls Material MenuButton Mesh MeshDataTool MeshInstance MeshInstance2D MeshLibrary MeshTexture MobileVRInterface MultiMesh MultiMeshInstance MultiMeshInstance2D MultiplayerAPI MultiplayerPeerGDNative Mutex NativeScript Navigation Navigation2D NavigationMesh NavigationMeshInstance NavigationPolygon NavigationPolygonInstance NetworkedMultiplayerENet NetworkedMultiplayerPeer NinePatchRect Node Node2D NodePath NoiseTexture Object OccluderPolygon2D OmniLight OpenSimplexNoise OptionButton OS PackedDataContainer PackedDataContainerRef PackedScene PacketPeer PacketPeerDTLS PacketPeerGDNative PacketPeerStream PacketPeerUDP Panel PanelContainer PanoramaSky ParallaxBackground ParallaxLayer Particles Particles2D ParticlesMaterial Path Path2D PathFollow PathFollow2D PCKPacker Performance PHashTranslation PhysicalBone Physics2DDirectBodyState Physics2DDirectSpaceState Physics2DServer Physics2DShapeQueryParameters Physics2DShapeQueryResult Physics2DTestMotionResult PhysicsBody PhysicsBody2D PhysicsDirectBodyState PhysicsDirectSpaceState PhysicsMaterial PhysicsServer PhysicsShapeQueryParameters PhysicsShapeQueryResult PinJoint PinJoint2D Plane PlaneMesh PlaneShape PluginScript PointMesh Polygon2D PolygonPathFinder PoolByteArray PoolColorArray PoolIntArray PoolRealArray PoolStringArray PoolVector2Array PoolVector3Array Popup PopupDialog PopupMenu PopupPanel Position2D Position3D PrimitiveMesh PrismMesh ProceduralSky ProgressBar ProjectSettings ProximityGroup ProxyTexture QuadMesh Quat RandomNumberGenerator Range RayCast RayCast2D RayShape RayShape2D Rect2 RectangleShape2D Reference ReferenceRect ReflectionProbe RegEx RegExMatch RemoteTransform RemoteTransform2D Resource ResourceFormatLoader ResourceFormatSaver ResourceImporter ResourceInteractiveLoader ResourceLoader ResourcePreloader ResourceSaver RichTextEffect RichTextLabel RID RigidBody RigidBody2D RootMotionView SceneState SceneTree SceneTreeTimer Script ScriptCreateDialog ScriptEditor ScrollBar ScrollContainer SegmentShape2D Semaphore Separator Shader ShaderMaterial Shape Shape2D ShortCut Skeleton Skeleton2D SkeletonIK Skin SkinReference Sky Slider SliderJoint SoftBody Spatial SpatialGizmo SpatialMaterial SpatialVelocityTracker SphereMesh SphereShape SpinBox SplitContainer SpotLight SpringArm Sprite Sprite3D SpriteBase3D SpriteFrames StaticBody StaticBody2D StreamPeer StreamPeerBuffer StreamPeerGDNative StreamPeerSSL StreamPeerTCP StreamTexture String StyleBox StyleBoxEmpty StyleBoxFlat StyleBoxLine StyleBoxTexture SurfaceTool TabContainer Tabs TCP_Server TextEdit TextFile Texture Texture3D TextureArray TextureButton TextureLayered TextureProgress TextureRect Theme Thread TileMap TileSet Timer ToolButton TouchScreenButton Transform Transform2D Translation TranslationServer Tree TreeItem TriangleMesh Tween UDPServer UndoRedo UPNP UPNPDevice Variant VBoxContainer Vector2 Vector3 VehicleBody VehicleWheel VideoPlayer VideoStream VideoStreamGDNative VideoStreamTheora VideoStreamWebm Viewport ViewportContainer ViewportTexture VisibilityEnabler VisibilityEnabler2D VisibilityNotifier VisibilityNotifier2D VisualInstance VisualScript VisualScriptBasicTypeConstant VisualScriptBuiltinFunc VisualScriptClassConstant VisualScriptComment VisualScriptComposeArray VisualScriptCondition VisualScriptConstant VisualScriptConstructor VisualScriptCustomNode VisualScriptDeconstruct VisualScriptEditor VisualScriptEmitSignal VisualScriptEngineSingleton VisualScriptExpression VisualScriptFunction VisualScriptFunctionCall VisualScriptFunctionState VisualScriptGlobalConstant VisualScriptIndexGet VisualScriptIndexSet VisualScriptInputAction VisualScriptIterator VisualScriptLists VisualScriptLocalVar VisualScriptLocalVarSet VisualScriptMathConstant VisualScriptNode VisualScriptOperator VisualScriptPreload VisualScriptPropertyGet VisualScriptPropertySet VisualScriptResourcePath VisualScriptReturn VisualScriptSceneNode VisualScriptSceneTree VisualScriptSelect VisualScriptSelf VisualScriptSequence VisualScriptSubCall VisualScriptSwitch VisualScriptTypeCast VisualScriptVariableGet VisualScriptVariableSet VisualScriptWhile VisualScriptYield VisualScriptYieldSignal VisualServer VisualShader VisualShaderNode VisualShaderNodeBooleanConstant VisualShaderNodeBooleanUniform VisualShaderNodeColorConstant VisualShaderNodeColorFunc VisualShaderNodeColorOp VisualShaderNodeColorUniform VisualShaderNodeCompare VisualShaderNodeCubeMap VisualShaderNodeCubeMapUniform VisualShaderNodeCustom VisualShaderNodeDeterminant VisualShaderNodeDotProduct VisualShaderNodeExpression VisualShaderNodeFaceForward VisualShaderNodeFresnel VisualShaderNodeGlobalExpression VisualShaderNodeGroupBase VisualShaderNodeIf VisualShaderNodeInput VisualShaderNodeIs VisualShaderNodeOuterProduct VisualShaderNodeOutput VisualShaderNodeScalarClamp VisualShaderNodeScalarConstant VisualShaderNodeScalarDerivativeFunc VisualShaderNodeScalarFunc VisualShaderNodeScalarInterp VisualShaderNodeScalarOp VisualShaderNodeScalarSmoothStep VisualShaderNodeScalarSwitch VisualShaderNodeScalarUniform VisualShaderNodeSwitch VisualShaderNodeTexture VisualShaderNodeTextureUniform VisualShaderNodeTextureUniformTriplanar VisualShaderNodeTransformCompose VisualShaderNodeTransformConstant VisualShaderNodeTransformDecompose VisualShaderNodeTransformFunc VisualShaderNodeTransformMult VisualShaderNodeTransformUniform VisualShaderNodeTransformVecMult VisualShaderNodeUniform VisualShaderNodeUniformRef VisualShaderNodeVec3Constant VisualShaderNodeVec3Uniform VisualShaderNodeVectorClamp VisualShaderNodeVectorCompose VisualShaderNodeVectorDecompose VisualShaderNodeVectorDerivativeFunc VisualShaderNodeVectorDistance VisualShaderNodeVectorFunc VisualShaderNodeVectorInterp VisualShaderNodeVectorLen VisualShaderNodeVectorOp VisualShaderNodeVectorRefract VisualShaderNodeVectorScalarMix VisualShaderNodeVectorScalarSmoothStep VisualShaderNodeVectorScalarStep VisualShaderNodeVectorSmoothStep VScrollBar VSeparator VSlider VSplitContainer WeakRef WebRTCDataChannel WebRTCDataChannelGDNative WebRTCMultiplayer WebRTCPeerConnection WebRTCPeerConnectionGDNative WebSocketClient WebSocketMultiplayerPeer WebSocketPeer WebSocketServer WebXRInterface WindowDialog World World2D WorldEnvironment X509Certificate XMLParser YSort" 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 gdscript_static_words $(join "${keywords} ${values} ${types} ${builtin_classes}" ' ')" printf %s " add-highlighter shared/gdscript/code/ regex '\b($(join "${keywords}" '|'))\b' 0:keyword add-highlighter shared/gdscript/code/ regex '\b($(join "${values}" '|'))\b' 0:value add-highlighter shared/gdscript/code/ regex '\b($(join "${types}" '|'))\b' 0:type add-highlighter shared/gdscript/code/ regex '\b($(join "${builtin_classes}" '|'))\b' 0:type " } # nodes add-highlighter shared/gdscript/code/ regex '\$[\w/]*' 0:module # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden gdscript-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k x s ^\h*#\h* y jgh P } } } define-command -hidden gdscript-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 x s \h+$ d } # indent after line ending with : try %{ execute-keys -draft , k x :$ ^\h*# j } # deindent closing brace/bracket when after cursor (for arrays and dictionaries) try %< execute-keys -draft x ^\h*[}\]] gh / [}\]] m 1 > > > § kakoune-2022.10.31/rc/filetype/gentoo-linux.kak000066400000000000000000000001361432757250600211170ustar00rootroot00000000000000# portage ebuild file hook global BufCreate .*\.ebuild %{ set-option buffer filetype sh } kakoune-2022.10.31/rc/filetype/git.kak000066400000000000000000000052141432757250600172540ustar00rootroot00000000000000hook 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 .*(\.git(config|modules)|git/config) %{ set-option buffer filetype ini } hook global BufCreate .*\.gitignore %{ set-option buffer filetype git-ignore } hook global BufCreate .*git-rebase-todo %{ set-option buffer filetype git-rebase } hook global WinSetOption filetype=git-(commit|ignore|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-ignore-highlight global WinSetOption filetype=git-ignore %{ add-highlighter window/git-ignore ref git-ignore hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-ignore } } 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 %{ require-module diff 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 ^# $ 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-ignore %{ add-highlighter shared/git-ignore group add-highlighter shared/git-ignore/glob regex '(? < <= ^ <*> <$> 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 x s \h+$ d } } define-command -hidden gluon-insert-on-new-line %~ evaluate-commands -draft -itersel %_ # copy // and /// comments prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K///?\h* y gh j P } _ ~ define-command -hidden gluon-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 : 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 x ^\h*[})\]] gh / \})\]] m 1 > _ ~ § kakoune-2022.10.31/rc/filetype/go.kak000066400000000000000000000157011432757250600171000ustar00rootroot00000000000000# 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 xs^\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 window InsertChar \n -group go-comment-insert go-insert-comment-on-new-line hook window InsertChar \n -group go-closing-delimiter-insert go-insert-closing-delimiter-on-new-line alias window alt go-alternative-file hook -once -always window WinSetOption filetype=.* %{ remove-hooks window go-.+ unalias window alt go-alternative-file } } 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 } # cleanup trailing white spaces on the previous line try %{ execute-keys -draft kx s \h+$ d } try %{ try %{ # line comment execute-keys -draft kx s ^\h*// } catch %{ # block comment execute-keys -draft /\* \*/ } } catch %{ # indent after lines with an unclosed { or ( try %< execute-keys -draft [c[({],[)}] \A[({][^\n]*\n[^\n]*\n?\z j > # indent after a switch's case/default statements try %[ execute-keys -draft kx ^\h*(case|default).*:$ j ] # deindent closing brace(s) when after cursor try %[ execute-keys -draft x ^\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 ] ] define-command -hidden go-insert-comment-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # copy // comments prefix and following white spaces try %{ execute-keys -draft kx s ^\h*\K/{2,}\h* yP } ] ] define-command -hidden go-insert-closing-delimiter-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # Wisely add '}'. evaluate-commands -save-regs x %[ # Save previous line indent in register x. try %[ execute-keys -draft kxs^\h+"xy ] catch %[ reg x '' ] try %[ # Validate previous line and that it is not closed yet. execute-keys -draft kx ^x.*\{\h*\(?\h*$ j}iJx ^x\)?\h*\} # Insert closing '}'. execute-keys -draft ox} # Delete trailing '}' on the line below the '{'. execute-keys -draft xs\}$d ] ] # Wisely add ')'. evaluate-commands -save-regs x %[ # Save previous line indent in register x. try %[ execute-keys -draft kxs^\h+"xy ] catch %[ reg x '' ] try %[ # Validate previous line and that it is not closed yet. execute-keys -draft kx ^x.*\(\h*$ J}iJx ^x\) # Insert closing ')'. execute-keys -draft ox) # Delete trailing ')' on the line below the '('. execute-keys -draft xs\)\h*\}?\h*$d ] ] ] ] § kakoune-2022.10.31/rc/filetype/graphql.kak000066400000000000000000000076221432757250600201340ustar00rootroot00000000000000# http://graphql.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](graphqls?) %{ set-option buffer filetype graphql } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=graphql %{ require-module graphql hook window ModeChange pop:insert:.* -group graphql-trim-indent graphql-trim-indent hook window InsertChar .* -group graphql-indent graphql-indent-on-char hook window InsertChar \n -group graphql-indent graphql-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window graphql-.+ } } hook -group graphql-highlight global WinSetOption filetype=graphql %{ add-highlighter window/graphql ref graphql hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/graphql } } provide-module graphql %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/graphql regions add-highlighter shared/graphql/code default-region group add-highlighter shared/graphql/line-description region '#' '\n' fill comment add-highlighter shared/graphql/block-description region '"""' '"""' fill comment add-highlighter shared/graphql/description region '"' '"\s*\n' fill comment add-highlighter shared/graphql/object region -recurse \{ [{] [}] regions # Objects add-highlighter shared/graphql/object/line-description region '#' '\n' fill comment add-highlighter shared/graphql/object/block-description region '"""' '"""' fill comment add-highlighter shared/graphql/object/field default-region group add-highlighter shared/graphql/object/field/ regex ([A-Za-z][A-Za-z0-9_-]*)(?:\([^)]*\))?\h*[:{] 1:attribute add-highlighter shared/graphql/object/field/ regex ^\h*([A-Za-z][A-Za-z0-9_-]*)\h*$ 1:attribute # Values add-highlighter shared/graphql/object/field/values regex \b(true|false|null|\d+(?:\.\d+)?(?:[eE][+-]?\d*)?)\b 0:value add-highlighter shared/graphql/object/field/variables regex \$[a-zA-Z0-9]+\b 0:variable # add-highlighter shared/graphql/object/field/string regex '"([^"]|\\")*"' 0:string add-highlighter shared/graphql/object/field/string regex '"(?:[^"\\]|\\.)*"' 0:string # Meta add-highlighter shared/graphql/object/field/directives regex @(?:include|skip) 0:meta # Attributes add-highlighter shared/graphql/object/field/required regex '(?<=[\w\]])(?!)' bang:operator add-highlighter shared/graphql/object/field/assignment regex '=' 0:operator # Keywords add-highlighter shared/graphql/code/top-level regex '\bschema\b' 0:keyword add-highlighter shared/graphql/code/keywords regex '\b(?enum|fragment|input|implements|interface|mutation|on|query|scalar|subscription|type|union)\h+(?:[A-Za-z]\w*)' name:keyword # Types add-highlighter shared/graphql/object/field/scalars regex \b(Boolean|Float|ID|Int|String)\b 0:type # Operators add-highlighter shared/graphql/object/field/expand-fragment regex '\.\.\.(?=\w)' 0:operator # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden graphql-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden graphql-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 graphql-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 : graphql-trim-indent } # indent after lines ending with opener token try %< execute-keys -draft k x [[{]\h*$ j > # deindent closer token(s) when after cursor try %< execute-keys -draft x ^\h*[}\]] gh / [}\]] m 1 > > > § kakoune-2022.10.31/rc/filetype/haml.kak000066400000000000000000000051121432757250600174070ustar00rootroot00000000000000# 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-insert haml-insert-on-new-line 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 (? d } } define-command -hidden haml-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '/' comment prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K/\h* y gh j P } } } define-command -hidden haml-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 : haml-trim-indent } # indent after lines beginning with : or - try %{ execute-keys -draft k x ^\h*[:-] j } } } ] kakoune-2022.10.31/rc/filetype/hare.kak000066400000000000000000000155431432757250600174160ustar00rootroot00000000000000# detection hook global BufCreate .*[.]ha %{ set-option buffer filetype hare } # initialisation hook global WinSetOption filetype=hare %{ require-module hare hook window ModeChange pop:insert:.* -group hare-trim-indent hare-trim-indent hook window InsertChar \n -group hare-indent hare-indent-on-new-line hook window InsertChar \n -group hare-insert hare-insert-on-new-line hook window InsertChar \{ -group hare-indent hare-indent-on-opening-curly-brace hook window InsertChar \} -group hare-indent hare-indent-on-closing-curly-brace } hook -group hare-highlight global WinSetOption filetype=hare %{ add-highlighter window/hare ref hare hook -once -always window WinSetOption filetype=*. %{ remove-highlighter window/hare } } # highlighters provide-module hare %§ add-highlighter shared/hare regions add-highlighter shared/hare/code default-region group add-highlighter shared/hare/comment region // $ fill comment add-highlighter shared/hare/rawstring region ` ` group add-highlighter shared/hare/rawstring/ fill string add-highlighter shared/hare/string region '"' (?|!|\?|&|\||\.\.(\.)?)" 0:operator # commands define-command -hidden hare-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve indentation on new lines try %{ execute-keys -draft K } # indent after lines ending with { or ( try %[ execute-keys -draft kx [{(]\h*$ j i ] # cleanup trailing white spaces on the previous line execute-keys -draft k :hare-trim-indent # indent after match/switch's case statements try %[ execute-keys -draft kx case\h.*=>\h*$ j ] # deindent closing brace(s) when after cursor try %[ execute-keys -draft x ^\h*[})] gh / [})] m 1 ] } } define-command -hidden hare-insert-on-new-line %{ evaluate-commands -draft -itersel %{ try %{ evaluate-commands -draft -save-regs '/"' %{ # copy the comment prefix execute-keys -save-regs '' k x s ^\h*\K//\h* y try %{ # paste the comment prefix execute-keys x j x s ^\h* P } } } try %{ # remove trailing whitespace on the above line execute-keys -draft k :hare-trim-indent } } } define-command -hidden hare-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 hare-indent-on-closing-curly-brace %[ # align to opening curly brace when alone on a line try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] define-command -hidden hare-trim-indent %{ evaluate-commands -draft -itersel %{ # remove trailing whitespace try %{ execute-keys -draft x s \h+$ d } } } § kakoune-2022.10.31/rc/filetype/haskell.kak000066400000000000000000000136431432757250600201210ustar00rootroot00000000000000# 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-insert haskell-insert-on-new-line 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 x s \h+$ d } } define-command -hidden haskell-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comments prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K--\h* y gh j P } } } define-command -hidden haskell-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # 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-2022.10.31/rc/filetype/hbs.kak000066400000000000000000000101001432757250600172330ustar00rootroot00000000000000# 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-insert hbs-insert-on-new-line 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 '"' (? 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-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '/' comment prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K/\h* y j p } } } define-command -hidden hbs-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 : hbs-trim-indent } # indent after lines beginning with : or - try %{ execute-keys -draft k x ^\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-2022.10.31/rc/filetype/html.kak000066400000000000000000000061371432757250600174420ustar00rootroot00000000000000# 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 '"' (? 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 x (?!area)(?!base)(?!br)(?!col)(?!command)(?!embed)(?!hr)(?!img)(?!input)(?!keygen)(?!link)(?!menuitem)(?!meta)(?!param)(?!source)(?!track)(?!wbr)(?!/)(?!>)[a-zA-Z0-9_-]+[^>]*?>$ jx^\s*/ } } } ] kakoune-2022.10.31/rc/filetype/i3.kak000066400000000000000000000114431432757250600170050ustar00rootroot00000000000000hook 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 xs^\h+$d } } hook window InsertChar \n -group i3-insert i3-insert-on-new-line 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_tab_title|focused|unfocused|urgent|inactive_workspace|urgent_workspace|focused_workspace|active_workspace|placeholder)" 1:attribute # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden i3-insert-on-new-line %~ evaluate-commands -draft -itersel %= # copy # comments prefix try %{ execute-keys -draft kx s ^\h*#\h* y jgh P } = ~ define-command -hidden i3-indent-on-new-line %~ evaluate-commands -draft -itersel %= # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with { try %[ execute-keys -draft kx \{\h*$ j ] # cleanup trailing white spaces on the previous line try %{ execute-keys -draft kx 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-2022.10.31/rc/filetype/ini.kak000066400000000000000000000012471432757250600172520ustar00rootroot00000000000000hook global BufCreate .+\.ini %{ 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-2022.10.31/rc/filetype/janet.kak000066400000000000000000000061721432757250600175760ustar00rootroot00000000000000# http://janet-lang.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](janet|jdn) %{ set-option buffer filetype janet } hook global WinSetOption filetype=janet %{ require-module janet hook window ModeChange pop:insert:.* -group janet-trim-indent janet-trim-indent hook window InsertChar \n -group janet-indent janet-indent-on-new-line set-option buffer extra_word_chars ! @ $ '%' ^ & * - _ + = : < > . ? hook -once -always window WinSetOption filetype=.* %{ remove-hooks window janet-.+ } } hook -group janet-highlight global WinSetOption filetype=janet %{ add-highlighter window/janet ref janet hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/janet } } provide-module janet %{ require-module lisp # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/janet regions add-highlighter shared/janet/code default-region group add-highlighter shared/janet/comment region '(?.?\w]+ 0:value add-highlighter shared/janet/code/number regex \W\K(?:[\-+]?\dx?[\der._+a-f]*)\b 0:value add-highlighter shared/janet/code/function-definition regex \((?:defn|fn)\s([!@$%\^&*\-_+=:<>.?\w]+) 1:function add-highlighter shared/janet/code/function-call regex \(([!@$%\^&*\-_+=:<>.?\w/]+) 1:function add-highlighter shared/janet/code/special regex \((def|defn|var|fn|do|quote|if|splice|while|break|set|quasiquote|unquote|upscope)\b\s 1:keyword add-highlighter shared/janet/code/ regex \W\K(&|&opt)\W 1:keyword # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden janet-trim-indent lisp-trim-indent declare-option \ -docstring 'regex matching the head of forms which have options *and* indented bodies' \ regex janet_special_indent_forms \ '(?:def.*|while|for|fn\*?|if(-.*|)|let.*|loop|seq|with(-.*|)|when(-.*|))|defer|do|match|var' define-command -hidden janet-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 j execute-keys -draft '"wze\A' %opt{janet_special_indent_forms} '\zs.\K.*;"i' } catch %{ # If not special and parameter appears on line 1, indent to parameter execute-keys -draft '"wzes\h\K[^\s].*;"i' } } try %{ execute-keys -draft '[rl"i' } try %{ execute-keys -draft '[Bl"i' } execute-keys -draft '"ia&,' } } } kakoune-2022.10.31/rc/filetype/java.kak000066400000000000000000000132571432757250600174200ustar00rootroot00000000000000hook global BufCreate .*\.java %{ set-option buffer filetype java } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=java %{ require-module java set-option window static_words %opt{java_static_words} # cleanup trailing whitespaces when exiting insert mode hook window ModeChange pop:insert:.* -group java-trim-indent %{ try %{ execute-keys -draft xs^\h+$d } } hook window InsertChar \n -group java-insert java-insert-on-new-line 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 %{(?kx s ^\h*\K/{2,}\h* yP } ] define-command -hidden java-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 kx [{(]\h*$ j ] # cleanup trailing white spaces on the previous line try %{ execute-keys -draft kx s \h+$ d } # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # indent after a switch's case/default statements try %[ execute-keys -draft kx ^\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 x ^\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 ] ] # Shell # ‾‾‾‾‾ # Oracle 2021, 3.9 Keywords, Chapter 3. Lexical Structure, Java Language Specification, Java SE 17, viewed 25 September 2021, # evaluate-commands %sh{ values='false null this true' types='boolean byte char double float int long short unsigned void' keywords='assert break case catch class continue default do else enum extends finally for if implements import instanceof interface new package return static strictfp super switch throw throws try var while yield' attributes='abstract final native non-sealed permits private protected public record sealed synchronized transient volatile' modules='exports module open opens provides requires to transitive uses with' # ---------------------------------------------------------------------------------------------- # join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } # ---------------------------------------------------------------------------------------------- # add_highlighter() { printf "add-highlighter shared/java/code/ regex %s %s\n" "$1" "$2"; } # ---------------------------------------------------------------------------------------------- # add_word_highlighter() { while [ $# -gt 0 ]; do words=$1 face=$2; shift 2 regex="\\b($(join "${words}" '|'))\\b" add_highlighter "$regex" "1:$face" done } # highlight: open not open() add_module_highlighter() { while [ $# -gt 0 ]; do words=$1 face=$2; shift 2 regex="\\b($(join "${words}" '|'))\\b(?=\\s)" add_highlighter "$regex" "1:$face" done } # ---------------------------------------------------------------------------------------------- # printf %s\\n "declare-option str-list java_static_words $(join "${values} ${types} ${keywords} ${attributes} ${modules}" ' ')" # ---------------------------------------------------------------------------------------------- # add_word_highlighter "$values" "value" "$types" "type" "$keywords" "keyword" "$attributes" "attribute" # ---------------------------------------------------------------------------------------------- # add_module_highlighter "$modules" "module" # ---------------------------------------------------------------------------------------------- # } § kakoune-2022.10.31/rc/filetype/javascript.kak000066400000000000000000000257631432757250600206520ustar00rootroot00000000000000# Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.][cm]?(js)x? %{ set-option buffer filetype javascript } hook global BufCreate .*[.][cm]?(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}-insert" javascript-insert-on-new-line 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 x 1s^(\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-insert-on-new-line %< evaluate-commands -draft -itersel %< execute-keys try %[ evaluate-commands -draft -save-regs '/"' %[ # copy the commenting prefix execute-keys -save-regs '' k x1s^\h*(//+\h*) y try %[ # if the previous comment isn't empty, create a new one execute-keys x^\h*//+\h*$ jxs^\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 kx ^(\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 kx^\h*/\* execute-keys -draft i* ] catch %[ try %[ # if the next line is a comment line insert a star execute-keys -draft jx^\h+\* execute-keys -draft i* ] catch %[ try %[ # if the previous line is an empty comment line, close the comment scope execute-keys -draft kx^\h+\*\h+$ x1s\*(\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 Kx1s^[^*]*(\*)& ] > > define-command -hidden javascript-indent-on-new-line %< 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 kx 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 x ^\h+$ Hd > # indent after an opening brace or parenthesis at end of line try %< execute-keys -draft k x [{(]\h*$ j > # indent after a label (works for case statements) try %< execute-keys -draft k x s[a-zA-Z0-9_-]+:\h*$ j > # indent after a statement not followed by an opening brace try %< execute-keys -draft k x s\)\h*(?://[^\n]+)?\n\z \ mB \A\b(if|for|while)\b j > try %< execute-keys -draft k x s \belse\b\h*(?://[^\n]+)?\n\z \ j > # deindent after a single line statement end try %< execute-keys -draft K x \;\h*(//[^\n]+)?$ \ K x s\)(\h+\w+)*\h*(//[^\n]+)?\n([^\n]*\n){2}\z \ MB \A\b(if|for|while)\b 1 > try %< execute-keys -draft K x \;\h*(//[^\n]+)?$ \ K x s \belse\b\h*(?://[^\n]+)?\n([^\n]*\n){2}\z \ 1 > # deindent closing brace(s) when after cursor try %< execute-keys -draft x ^\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 & > > > > # 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 # 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-2022.10.31/rc/filetype/jinja.kak000066400000000000000000000050451432757250600175660ustar00rootroot00000000000000# 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-2022.10.31/rc/filetype/json.kak000066400000000000000000000041631432757250600174440ustar00rootroot00000000000000# 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 '"' (? 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 x [[{]\h*$ j > # deindent closer token(s) when after cursor try %< execute-keys -draft x ^\h*[}\]] gh / [}\]] m 1 > > > ) kakoune-2022.10.31/rc/filetype/julia.kak000066400000000000000000000045321432757250600175770ustar00rootroot00000000000000# 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 '"' (? d } } } define-command -hidden just-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing white spaces on previous line try %{ execute-keys -draft kx s \h+$ "_d } # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k x s ^\h*//\h* y jgh P } } } # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/justfile regions add-highlighter shared/justfile/content default-region group add-highlighter shared/justfile/content/recipe regex '^@?([\w-]+)([^\n]*):(?!=)([^\n]*)' 1:function 2:meta 3:keyword add-highlighter shared/justfile/content/assignments regex ^([\w-]+\h*:=\h*[^\n]*) 1:meta add-highlighter shared/justfile/content/operator regex '((^@|:=|=|\+|\(|\)))' 1:operator add-highlighter shared/justfile/content/strings regions add-highlighter shared/justfile/content/strings/double 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 x 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="add-highlighter alias arrange-buffers buffer buffer-next buffer-previous catch change-directory colorscheme debug declare-option declare-user-mode define-command complete-command delete-buffer delete-buffer! echo edit edit! enter-user-mode evaluate-commands execute-keys fail hook info kill kill! map menu nop on-key prompt provide-module quit quit! remove-highlighter remove-hooks rename-buffer rename-client rename-session require-module select set-face set-option set-register source trigger-user-hook try unalias unmap unset-face unset-option update-option write write! write-all write-all-quit write-quit write-quit!" 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 str-to-str-map" 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/code/numbers regex \b\d+\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 add-highlighter shared/kak ref kakrc # 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 x 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 x s \h+$ d } # indent after line ending with %\w*[^\s\w] try %{ execute-keys -draft k x \%\w*[^\s\w]$ j } # deindent closing brace when after cursor try %_ execute-keys -draft -itersel x ^\h*([>)}\]]) gh / 1 m 1 _ # deindent closing char(s) try %{ execute-keys -draft -itersel x ^\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-2022.10.31/rc/filetype/kickstart.kak000066400000000000000000000042441432757250600204720ustar00rootroot00000000000000hook 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 '"' (?d } } hook window InsertChar \n -group kotlin-indent kotlin-insert-on-new-line hook window InsertChar \n -group kotlin-indent kotlin-indent-on-new-line hook window InsertChar \{ -group kotlin-indent kotlin-indent-on-opening-curly-brace hook window InsertChar \} -group kotlin-indent kotlin-indent-on-closing-curly-brace hook -once -always window WinSetOption filetype=.* %{ remove-hooks window kotlin-.+ } } hook -group kotlin-highlighter global WinSetOption filetype=kotlin %{ add-highlighter window/kotlin ref kotlin add-highlighter window/kdoc ref kdoc hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/kotlin remove-highlighter window/kdoc } } hook global BufSetOption filetype=kotlin %{ require-module kotlin set-option buffer comment_line '//' set-option buffer comment_block_begin '/*' set-option buffer comment_block_end '*/' hook -once -always buffer BufSetOption filetype=.* %{ remove-hooks buffer kotlin-.+ } } # Module ------------------------------------------------------------------------------------------- # # ‾‾‾‾‾‾ provide-module kotlin %§ add-highlighter shared/kotlin regions add-highlighter shared/kotlin/code default-region group add-highlighter shared/kotlin/string region %{(?](?=[^\(\{]) 1:function 2:function 3:function # Test suite functions: fun `this is a valid character function test`() add-highlighter shared/kotlin/code/fun_tests regex ^\h*?fun\s*?`(.[^<>:/\[\]\\\.]+?)`\h*?(?=\() 1:default+iuf add-highlighter shared/kotlin/code/delimiters regex (\(|\)|\[|\]|\{|\}|\;|') 1:operator add-highlighter shared/kotlin/code/operators regex (\+|-|\*|&|=|\\|\?|%|\|-|!|\||->|\.|,|<|>|:|\^|/) 1:operator add-highlighter shared/kotlin/code/numbers regex \b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)([LlFf])?\b 0:value # Generics need improvement, as after a colon will match as a constant only. # val program: IOU = XXXX; val cat: DOG = XXXX. matches IOU or DOG as a # CONSTANT when it could be generics. See: https://regex101.com/r/VPO5LE/10 add-highlighter shared/kotlin/code/constants_and_generics regex \b((?<==\h)\([A-Z][A-Z0-9_]+(?=[<:\;])|(?\)]))|\b((?\s]))\b 1:meta 2:type add-highlighter shared/kotlin/code/target regex @(delegate|field|file|get|param|property|receiver|set|setparam)(?=:) 0:meta add-highlighter shared/kotlin/code/soft regex \b(by|catch|constructor|dynamic|finally|get|import|init|set|where)\b 1:keyword add-highlighter shared/kotlin/code/hard regex \b(as|as\?|break|class|continue|do|else|false|for|fun|if|in|!in|interface|is|!is|null|object|package|return|super|this|throw|true|try|typealias|val|var|when|while)\b 1:keyword add-highlighter shared/kotlin/code/modifier regex \b(actual|abstract|annotation|companion|const|crossinline|data|enum|expect|external|final|infix|inline|inner|internal|lateinit|noinline|open|operator|out|override|private|protected|public|reified|sealed|suspend|tailrec|vararg)\b(?=[\s\n]) 1:attribute add-highlighter shared/kotlin/code/type regex \b(Annotation|Any|Boolean|BooleanArray|Byte|ByteArray|Char|Character|CharArray|CharSequence|Class|ClassLoader|Cloneable|Comparable|Compiler|DeprecationLevel|Double|DoubleArray|Enum|Float|FloatArray|Function|Int|IntArray|Integer|Lazy|LazyThreadSafetyMode|Long|LongArray|Math|Nothing|Number|Object|Package|Pair|Process|Runnable|Runtime|SecurityManager|Short|ShortArray|StackTraceElement|StrictMath|String|StringBuffer|System|Thread|ThreadGroup|ThreadLocal|Triple|Unit|Void)\b(?=[^<]) 1:type # Kdoc --------------------------------------------------------------------------------------------- # # ‾‾‾‾ add-highlighter shared/kdoc group add-highlighter shared/kdoc/tag regex \*(?:\s+)?(@(author|constructor|exception|param|property|receiver|return|sample|see|since|suppress|throws))\b 1:default+ui # Discolour ---------------------------------------------------------------------------------------- # # ‾‾‾‾‾‾‾‾‾ add-highlighter shared/kotlin/code/discolour regex ^(package|import)(?S)(.+) 2:default+fa # Commands ----------------------------------------------------------------------------------------- # # ‾‾‾‾‾‾‾‾ define-command -hidden kotlin-insert-on-new-line %[ # copy // comments prefix and following white spaces try %{ execute-keys -draft kx s ^\h*\K/{2,}\h* yP } ] define-command -hidden kotlin-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 kx [{(]\h*$ j ] # cleanup trailing white spaces on the previous line try %{ execute-keys -draft kx s \h+$ d } # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # indent after a pattern match on when/where statements try %[ execute-keys -draft kx ^\h*(when|where).*$ j ] # indent after term on an expression try %[ execute-keys -draft kx =\h*?$ j ] # indent after keywords try %[ execute-keys -draft )MB \A(catch|do|else|for|if|try|while)\h*\(.*\)\h*\n\h*\n?\z s \A|.\z 11 ] # deindent closing brace(s) when after cursor try %[ execute-keys -draft x ^\h*[})] gh / [})] m 1 ] > ~ define-command -hidden kotlin-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 kotlin-indent-on-closing-curly-brace %[ # align to opening curly brace when alone on a line try %[ execute-keys -itersel -draft ^\h+\}$hms\A|.\z1 ] ] # Exceptions, Errors, and Types -------------------------------------------------------------------- # # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # macro: 93lei evaluate-commands %sh{ kotlin_keywords='abstract actual annotation as break by catch class companion const constructor continue crossinline data delegate do dynamic else enum expect external false field file final finally for fun get if import in infix init inline inner interface internal is lateinit noinline null object open operator out override package param private property protected public receiver reified return sealed set setparam super suspend tailrec this throw true try typealias val var vararg when where while' kotlin_types='Annotation Any Boolean BooleanArray Byte ByteArray Char Character CharArray CharSequence Class ClassLoader Cloneable Comparable Compiler DeprecationLevel Double DoubleArray Enum Float FloatArray Function Int IntArray Integer Lazy LazyThreadSafetyMode Long LongArray Math Nothing Number Object Package Pair Process Runnable Runtime SecurityManager Short ShortArray StackTraceElement StrictMath String StringBuffer System Thread ThreadGroup ThreadLocal Triple Unit Void' # ------------------------------------------------------------------------------------------------ # kotlin_kdocs='author constructor exception param property receiver return sample see since suppress throws' # ------------------------------------------------------------------------------------------------ # kotlin_errors_exceptions='CharacterCodingException Error AssertionError NotImplementedError OutOfMemoryErrorIllegalCallableAccessException IllegalPropertyDelegateAccessException NoSuchPropertyException RuntimeException Throwable' # ------------------------------------------------------------------------------------------------ # join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; } # ------------------------------------------------------------------------------------------------ # printf %s\\n "declare-option str-list kotlin_static_words $(join "${kotlin_keywords} ${kotlin_types} ${kotlin_kdocs} ${kotlin_errors_exceptions}" ' ')" # ------------------------------------------------------------------------------------------------ # printf %s\\n "add-highlighter shared/kotlin/code/errors_exceptions regex \b($(join "${kotlin_errors_exceptions}" '|'))\b 0:type" } § # ------------------------------------------------------------------------------------------------- # kakoune-2022.10.31/rc/filetype/latex.kak000066400000000000000000000145361432757250600176150ustar00rootroot00000000000000# https://www.latex-project.org/ # # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*\.(tex|cls|sty|dtx) %{ set-option buffer filetype latex } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=latex %( require-module latex hook window InsertChar \n -group latex-indent %{ latex-indent-newline } hook window InsertChar \} -group latex-indent %{ latex-indent-closing-brace } hook window ModeChange pop:insert:.* -group latex-indent %{ latex-trim-indent } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window latex-indent } hook window InsertChar \n -group latex-insert latex-insert-on-new-line ) hook -group latex-highlight global WinSetOption filetype=latex %{ add-highlighter window/latex ref latex hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/latex } } provide-module latex %~ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/latex regions add-highlighter shared/latex/content default-region group # Region for control sequence (includes latex2e arguments and options) # starting with unescaped \ and ending : # - at eol, or # - at word boundaries not preceded nor followed by @ : \ { } [ ] *, or # - after an unescaped } add-highlighter shared/latex/cs region '(? d } } } define-command -hidden latex-indent-newline %( evaluate-commands -no-hooks -draft -itersel %( # copy '%' comment prefix and following white spaces try %{ execute-keys -draft kx 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 kx s\h+$ d } # indent after line ending with { try %( execute-keys -draft kx \{$ j ) # deindent closing brace(s) when after cursor try %( execute-keys -draft x ^\h*\} gh / \} m 1 ) # indent after line ending with \begin{...}[...]{...}, with multiple # sets of arguments possible try %( execute-keys -draft \ kx \ \\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 x_ \A\}\z m1 ) # Align \end{...} with corresponding \begin{...} try %( execute-keys -draft h 1s\\end\h*\{([^\}]+)\}\z \ \\begin\s*\{.\} 1 ) ) ) define-command -hidden latex-insert-on-new-line %( evaluate-commands -no-hooks -draft -itersel %( # Wisely add "\end{...}". evaluate-commands -save-regs xz %( # Save previous line indent in register x. try %( execute-keys -draft kxs^\h+"xy ) catch %( reg x '' ) # Save item of begin in register z. try %( execute-keys -draft kxs\{.*\}"zy ) catch %( reg z '' ) try %( # Validate previous line and that it is not closed yet. execute-keys -draft kx ^x\h*\\begin\{.*\} J}iJx ^x(\\end\z\}) # Auto insert "\end{...}". execute-keys -draft ox\endz ) ) ) ) ~ kakoune-2022.10.31/rc/filetype/ledger.kak000066400000000000000000000135211432757250600177330ustar00rootroot00000000000000# 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-highlighter shared/ledger/default default-region group # 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/default/ regex '^${cmd}\b' 0: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 x s \h+$ d ] # indent after the first line of a transaction try %[ execute-keys -draft kx ^[0-9] j ] ] ] define-command -hidden ledger-trim-indent %{ try %{ execute-keys -draft x s ^\h+$ d } } ] kakoune-2022.10.31/rc/filetype/lisp.kak000066400000000000000000000063351432757250600174450ustar00rootroot00000000000000# 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 x 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-2022.10.31/rc/filetype/lua.kak000066400000000000000000000140111432757250600172450ustar00rootroot00000000000000# http://lua.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](lua|rockspec) %{ set-option buffer filetype lua } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=lua %{ require-module lua hook window ModeChange pop:insert:.* -group lua-trim-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/keyword_operator regex \b(and|or|not)\b 0:operator add-highlighter shared/lua/code/module regex \b(_G|_ENV)\b 0:module add-highlighter shared/lua/code/attribute regex \B(<[a-zA-Z_]\w*>)\B 0:attribute # 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 x s \h+$ d ] ] define-command -hidden lua-indent-on-char %[ evaluate-commands -no-hooks -draft -itersel %[ # unindent middle and end structures try %[ execute-keys -draft \ ^\h*(\b(end|else|elseif|until)\b|[)}])$ \ :lua-indent-on-new-line \ ] ] ] define-command -hidden lua-indent-on-new-line %[ evaluate-commands -no-hooks -draft -itersel %[ # remove trailing white spaces from previous line try %[ execute-keys -draft k : lua-trim-indent ] # preserve previous non-empty line indent try %[ execute-keys -draft ,gh^[^\n]+$s\A|.\z) ] # add one indentation level if the previous line is not a comment and: # - starts with a block keyword that is not closed on the same line, # - or contains an unclosed function expression, # - or ends with an enclosed '(' or '{' try %[ execute-keys -draft \ , Kx \ \A\h*-- \ \A[^\n]*\b(end|until)\b \ \A(\h*\b(do|else|elseif|for|function|if|repeat|while)\b|[^\n]*[({]$|[^\n]*\bfunction\b\h*[(]) \ ] ] ] 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 kxs^\h*\K--\h* y gh j x P ] # wisely add end structure evaluate-commands -save-regs x %[ # save previous line indent in register x try %[ execute-keys -draft kxs^\h+"xy ] catch %[ reg x '' ] try %[ # check that starts with a block keyword that is not closed on the same line execute-keys -draft \ kx \ ^\h*\b(else|elseif|do|for|function|if|while)\b|[^\n]\bfunction\b\h*[(] \ \bend\b # check that the block is empty and is not closed on a different line execute-keys -draft i ^[^\n]+\n[^\n]+\n jx ^x\b(else|elseif|end)\b # auto insert end execute-keys -draft oxend # auto insert ) for anonymous function execute-keys -draft kx\([^)\n]*function\bjjA) ] ] ] ] § kakoune-2022.10.31/rc/filetype/mail.kak000066400000000000000000000015041432757250600174110ustar00rootroot00000000000000hook global BufCreate .+\.eml %{ set-option buffer filetype mail } hook global WinSetOption filetype=mail %{ require-module mail map buffer normal :diff-jump hook -once -always window WinSetOption filetype=.* %{ unmap buffer normal :diff-jump } } 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 %{ require-module diff 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-2022.10.31/rc/filetype/makefile.kak000066400000000000000000000050251432757250600202460ustar00rootroot00000000000000# 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 ModeChange pop:insert:.* -group makefile-trim-indent makefile-trim-indent 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 (? d } } } define-command -hidden makefile-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent try %{ execute-keys -draft K } ## If the line above is a target indent with a tab try %{ execute-keys -draft Z kx ^\S.*?(::|:|!)\s z i } # cleanup trailing white space son previous line try %{ execute-keys -draft kx s \h+$ d } # indent after some keywords try %{ execute-keys -draft Z kx ^\h*(ifeq|ifneq|ifdef|ifndef|else|define)\b z } } } } kakoune-2022.10.31/rc/filetype/markdown.kak000066400000000000000000000132071432757250600203140ustar00rootroot00000000000000# 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 ModeChange pop:insert:.* -group markdown-trim-indent markdown-trim-indent hook window InsertChar \n -group markdown-insert markdown-insert-on-new-line 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 %{ markdown-load-languages '%' } hook -group markdown-load-languages global WinSetOption filetype=markdown %{ hook -group markdown-load-languages window NormalIdle .* %{markdown-load-languages gtGbGl} hook -group markdown-load-languages window InsertIdle .* %{markdown-load-languages gtGbGl} } 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 add-highlighter shared/markdown/listblock region ^\h*[-*]\s ^(?=\S) regions add-highlighter shared/markdown/listblock/g default-region group add-highlighter shared/markdown/listblock/g/ ref markdown/inline add-highlighter shared/markdown/listblock/g/marker regex ^\h*([-*])\s 1:bullet add-highlighter shared/markdown/codeblock region -match-capture \ ^(\h*)```\h* \ ^(\h*)```\h*$ \ regions add-highlighter shared/markdown/codeblock/ default-region fill meta add-highlighter shared/markdown/listblock/codeblock region -match-capture \ ^(\h*)```\h* \ ^(\h*)```\h*$ \ regions add-highlighter shared/markdown/listblock/codeblock/ default-region fill meta add-highlighter shared/markdown/codeline region "^( {4}|\t)" "$" fill meta # https://spec.commonmark.org/0.29/#link-destination add-highlighter shared/markdown/angle_bracket_url region (?<=<)([a-z]+://|(mailto|magnet|xmpp):) (?!\\).(?=>)|\n fill link add-highlighter shared/markdown/inline/url region -recurse \( (\b[a-z]+://|(mailto|magnet|xmpp):) (?!\\).(?=\))|\s fill link add-highlighter shared/markdown/listblock/angle_bracket_url region (?<=<)(\b[a-z]+://|(mailto|magnet|xmpp):) (?!\\).(?=>)|\n fill link try %{ require-module html add-highlighter shared/markdown/inline/tag region (?i))) > ref html/tag } 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 (?\h*)+ 0:comment add-highlighter shared/markdown/inline/text/ regex "\H( {2,})$" 1:+r@meta # Commands # ‾‾‾‾‾‾‾‾ define-command markdown-load-languages -params 1 %{ evaluate-commands -draft %{ try %{ execute-keys "%arg{1}s```\h*\{?[.=]?\K\w+" # } evaluate-commands -itersel %{ try %{ require-module %val{selection} add-highlighter "shared/markdown/codeblock/%val{selection}" region -match-capture "^(\h*)```\h*(%val{selection}\b|\{[.=]?%val{selection}\})" ^(\h*)``` regions add-highlighter "shared/markdown/codeblock/%val{selection}/" default-region fill meta add-highlighter "shared/markdown/codeblock/%val{selection}/inner" region \A\h*```[^\n]*\K (?=```) ref %val{selection} add-highlighter "shared/markdown/listblock/codeblock/%val{selection}" region -match-capture "^(\h*)```\h*(%val{selection}\b|\{[.=]?%val{selection}\})" ^(\h*)``` regions add-highlighter "shared/markdown/listblock/codeblock/%val{selection}/" default-region fill meta add-highlighter "shared/markdown/listblock/codeblock/%val{selection}/inner" region \A\h*```[^\n]*\K (?=```) ref %val{selection} }} }} } define-command -hidden markdown-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } } define-command -hidden markdown-insert-on-new-line %{ try %{ execute-keys -draft -itersel k x s ^\h*\K((>\h*)+([*+-]\h)?|(>\h*)*[*+-]\h)\h* y gh j P } } define-command -hidden markdown-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent try %{ execute-keys -draft K } # remove trailing white spaces try %{ execute-keys -draft k x s \h+$ d } } } } kakoune-2022.10.31/rc/filetype/mercurial.kak000066400000000000000000000015031432757250600204510ustar00rootroot00000000000000# 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-2022.10.31/rc/filetype/mercury.kak000066400000000000000000000150701432757250600201600ustar00rootroot00000000000000# Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](m) %{ set-option buffer filetype mercury } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=mercury %{ require-module mercury set-option window static_words %opt{mercury_static_words} hook window InsertChar \n -group mercury-insert mercury-insert-on-new-line hook window InsertChar \n -group mercury-indent mercury-indent-on-new-line # cleanup trailing whitespaces on current line insert end hook window ModeChange pop:insert:.* -group mercury-trim-indent %{ try %{ execute-keys -draft x s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window mercury-.+ } } hook -group mercury-highlight global WinSetOption filetype=mercury %{ add-highlighter window/mercury ref mercury hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/mercury } } provide-module mercury %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/mercury regions add-highlighter shared/mercury/code default-region group add-highlighter shared/mercury/comment region '%' '$' fill comment add-highlighter shared/mercury/line_comment region '%' '$' fill comment add-highlighter shared/mercury/string region '"' (?>|\+|\+\+|-|--|/\\|\\/|\.\.|:=|=\^|<|=|=\.\.|=:=|=<|==|=\\=|>|>=|@<|@=<|@>|@>=|\\=|\\==|~=|\\\+|~|<=|<=>|=>|,|&|->|\;|::|==>|--->|-->|:-|\?-) 0:operator evaluate-commands %sh{ # Grammar values="true fail" # There is overlap between all of these. Not sure what to do about that. operators="event div mod rem for is and or impure semipure not when all arbitrary atomic disable_warning disable_warnings promise_equivalent_solutions promise_equivalent_solution_setspromise_exclusive promise_exclusive_exhaustive promise_exhaustive promise_impure promise_pure promise_semipure require_complete_switch require_switch_arms_det require_switch_arms_semidet require_switch_arms_multi require_switch_arms_nondet require_switch_arms_cc_multi require_switch_arms_cc_nondet require_switch_arms_erroneous require_switch_arms_failure require_det require_semidet require_multi require_nondet require_cc_multi require_cc_nondet require_erroneous require_failure trace try some or_else then if else where catch catch_any initialize finalize rule solver type pred func inst mode typeclass instance pragma promise initialise finalise mutable module import_module use_module include_module" modes="free bound in out di mdi uo muo" determinisms="erroneous failure det semidet multi cc_multi nondet cc_nondet" reserved_insts="any bound bound_unique clobbered clobbered_any free ground is mostly_clobbered mostly_unique mostly_unique_any not_reached unique unique_any" reserved_modes="any_func any_pred func is pred" reserved_types="int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float character string pred func pure semipure impure" declarations="type solver type pred func inst mode typeclass instance pragma promise initialise finalise mutable module interface implementation import_module use_module include_module end_module" 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 mercury_static_words $(join "${values} ${declarations} ${operators} ${determinisms} ${modes} ${reserved_insts} ${reserved_modes}" ' ')" # Highlight keywords printf %s " add-highlighter shared/mercury/code/ regex '\b($(join "${values}" '|'))\b' 0:value add-highlighter shared/mercury/code/ regex '^:-(\s+($(join "${declarations}" '|')))+\b' 1:keyword add-highlighter shared/mercury/code/ regex '\b($(join "${operators}" '|'))\b' 0:operator add-highlighter shared/mercury/code/ regex '\b($(join "${determinisms}" '|'))\b' 0:keyword add-highlighter shared/mercury/code/ regex '\b($(join "${modes}" '|'))\b' 0:keyword # These overlap with previous. Not sure what the solution is. # add-highlighter shared/mercury/code/ regex '\b($(join "${reserved_types}" '|'))\b' 0:type # add-highlighter shared/mercury/code/ regex '\b($(join "${reserved_insts}" '|'))\b' 0:builtin # add-highlighter shared/mercury/code/ regex '\b($(join "${reserved_modes}" '|'))\b' 0:builtin # Implementation-defined literals - don't know how to get these to work # add-highlighter shared/mercury/code/ regex '\$(file|line|module|pred)' 0:keyword " } define-command -hidden mercury-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '%' comment prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\%\h* y gh j P } } } define-command -hidden mercury-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 mercury-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 x s \h+$ d } # indent after line ending with :- try %{ execute-keys -draft , k x :-$ j } # deindent closing brace/bracket when after cursor try %< execute-keys -draft x ^\h*[}\])] gh / [}\])] m 1 > > > § kakoune-2022.10.31/rc/filetype/meson.kak000066400000000000000000000054451432757250600176200ustar00rootroot00000000000000# 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 set-option window static_words %opt{meson_static_words} 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 "\b(\w+)\(" 1:function evaluate-commands %sh{ values="true false" keywords="if else endif elif foreach endforeach break continue" builtins="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" 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 meson_static_words $(join "${values} ${keywords} ${builtins}" ' ')" # Highlight keywords printf %s " add-highlighter shared/meson/code/ regex '\b($(join "${values}" '|'))\b' 0:value add-highlighter shared/meson/code/ regex '\b($(join "${keywords}" '|'))\b' 0:keyword add-highlighter shared/meson/code/ regex '\b($(join "${builtins}" '|'))\b\(' 1:builtin " } § kakoune-2022.10.31/rc/filetype/mlb.kak000066400000000000000000000032771432757250600172520ustar00rootroot00000000000000# 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 '"' '(? d } } } define-command -hidden moon-indent-on-char %{ evaluate-commands -draft -itersel %{ # align _else_ statements to start try %{ execute-keys -draft x ^ \h * (else(if)?) $ ^ \h * (if|unless|when) s \A | \z ) } # align _when_ to _switch_ then indent try %{ execute-keys -draft x ^ \h * (when) $ ^ \h * (switch) s \A | \z ) ) , } # align _catch_ and _finally_ to _try_ try %{ execute-keys -draft x ^ \h * (catch|finally) $ ^ \h * (try) s \A | \z ) } } } define-command -hidden moon-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comment prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K--\h* y gh j P } } } define-command -hidden moon-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 : moon-trim-indent } # indent after start structure try %{ execute-keys -draft k x ^ \h * (class|else(if)?|for|if|switch|unless|when|while|with) \b | ([:=]|[-=]>) $ j } # deindent after return statements try %{ execute-keys -draft k x ^ \h * (break|return) \b j } } } ] kakoune-2022.10.31/rc/filetype/nim.kak000066400000000000000000000125571432757250600172640ustar00rootroot00000000000000# 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-insert nim-insert-on-new-line 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 x 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='[=+-/<>@$~&%|!?^.\\*]' letter='A-Za-z\u000080-\u10FFFF' customsuffix="'[${letter}](_?[${letter}0-9])*" suffix="(${customsuffix}|[iIuU](8|16|32|64)|[fF](32|64)?|[dDuU])?" floatsuffix="(${customsuffix}|[fF](32|64)?|[dD])?" 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 (? y jgh P } } } define-command -hidden nim-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent try %{ exec -draft K } # cleanup trailing whitespaces from previous line try %{ exec -draft k x s \h+$ d } # indent after line ending with enum, tuple, object, type, import, export, const, let, var, ':' or '=' try %{ exec -draft , k x (:|=|\b(?:enum|tuple|object|const|let|var|import|export|type))$ j } } } } kakoune-2022.10.31/rc/filetype/ninja.kak000066400000000000000000000074641432757250600176010ustar00rootroot00000000000000# ref: https://ninja-build.org/manual.html#ref_ninja_file # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .+\.ninja %{ set-option buffer filetype ninja } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=ninja %{ require-module ninja set-option window static_words %opt{ninja_static_words} hook window ModeChange pop:insert:.* -group ninja-trim-indent ninja-trim-indent hook window InsertChar \n -group ninja-insert ninja-insert-on-new-line hook window InsertChar \n -group ninja-indent ninja-indent-on-new-line # cleanup trailing whitespaces on current line insert end hook window ModeChange pop:insert:.* -group ninja-trim-indent %{ try %{ execute-keys -draft x s ^\h+$ d } } hook -once -always window WinSetOption filetype=.* %{ remove-hooks window ninja-.+ } } hook -group ninja-highlight global WinSetOption filetype=ninja %{ add-highlighter window/ninja ref ninja hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ninja } } provide-module ninja %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/ninja regions # `#` add-highlighter shared/ninja/comment region '#' '\n' fill comment # `subninja`, `include`, `rule`, `pool` and `default` declarations add-highlighter shared/ninja/sirpd region '^(subninja|include|rule|pool|default)\b' '[^$]\n' group add-highlighter shared/ninja/sirpd/default regex '^(subninja|include)\b' 0:module add-highlighter shared/ninja/sirpd/rulepool regex '^(rule|pool|default)\b' 0:keyword add-highlighter shared/ninja/sirpd/linebreak regex '\$$' 0:operator # `build` add-highlighter shared/ninja/build region '^build\b' '[^$]\n' group add-highlighter shared/ninja/build/build regex '^build\b' 0:keyword add-highlighter shared/ninja/build/rule regex ':\h+((\w|-)+)' 0:function add-highlighter shared/ninja/build/colonpipe regex ':|\||\|\|' 0:operator add-highlighter shared/ninja/build/linebreak regex '\$$' 0:operator add-highlighter shared/ninja/build/variables regex '\$(\w|-)+|\$\{(\w|-)+\}' 0:value # variables declarations add-highlighter shared/ninja/variable region '^\h*(\w|-)+\h*=' '[^$]\n' group add-highlighter shared/ninja/variable/declaredname regex '^\h*((\w|-)+)\h*(=)' 1:variable 0:operator add-highlighter shared/ninja/variable/linebreak regex '\$$' 0:operator add-highlighter shared/ninja/variable/variables regex '\$(\w|-)+|\$\{(\w|-)+\}' 0:value # keywords/builtin variable names evaluate-commands %sh{ keywords="rule build command default subninja include" reserved_names="builddir ninja_required_version pool depfile deps depfile msvc_deps_prefix description dyndep generator restat rspfile rspfile_content" printf %s " declare-option str-list ninja_static_words ${keywords} ${reserved_names} " reserved_names_regex="$(echo ${reserved_names} | tr ' ' '|')" printf %s " add-highlighter shared/ninja/variable/reserved_names regex '^\h*(${reserved_names_regex})\b' 0:meta " } # Indent # ‾‾‾‾‾‾ define-command -hidden ninja-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden ninja-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comments prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K--\h* y gh j P } } } define-command -hidden ninja-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 : ninja-trim-indent } # indent after lines begining with rule and pool try %{ execute-keys -draft \; k x ^(rule|pool|build)\b j } } } } kakoune-2022.10.31/rc/filetype/nix.kak000066400000000000000000000126341432757250600172730ustar00rootroot00000000000000# 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-insert nix-insert-on-new-line hook window InsertChar \n -group nix-indent nix-indent-on-new-line set-option buffer extra_word_chars _ - 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/_+.]*/[-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 x 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-insert-on-new-line %< evaluate-commands -draft -itersel %< # copy // comments prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K#\h* y gh j P } > > define-command -hidden nix-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 : nix-trim-indent } # indent after lines beginning / ending with opener token try %_ execute-keys -draft k x ^\h*[[{]|[[{]$ j _ # deindent closer token(s) when after cursor try %_ execute-keys -draft x ^\h*[}\]] gh / [}\]] m 1 _ > > § kakoune-2022.10.31/rc/filetype/ocaml.kak000066400000000000000000000115031432757250600175620ustar00rootroot00000000000000# 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 alias window alt ocaml-alternative-file hook -once -always window WinSetOption filetype=.* %{ unalias window alt ocaml-alternative-file 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 " } # Conveniences # ‾‾‾‾‾‾‾‾‾‾‾‾ # C has header and source files and you need to often switch between them. # Similarly OCaml has .ml (implementation) and .mli (interface files) and # one often needs to switch between them. # # This command provides a simple functionality that allows you to accomplish this. define-command ocaml-alternative-file -docstring 'Switch between .ml and .mli file or vice versa' %{ evaluate-commands %sh{ if [ "${kak_buffile##*.}" = 'ml' ]; then printf "edit -- '%s'" "$(printf %s "${kak_buffile}i" | sed "s/'/''/g")" elif [ "${kak_buffile##*.}" = 'mli' ]; then printf "edit -- '%s'" "$(printf %s "${kak_buffile%i}" | sed "s/'/''/g")" fi } } } # The OCaml comment is `(* Some comment *)`. Like the C-family this can be a multiline comment. # # Recognize when the user is trying to commence a comment when they type `(*` and # then automatically insert `*)` on behalf of the user. A small convenience. hook global WinSetOption filetype=ocaml %{ hook window InsertChar '\*' %{ try %{ execute-keys -draft 'HH\(\*' execute-keys ' *)' } } } kakoune-2022.10.31/rc/filetype/pascal.kak000066400000000000000000000246301432757250600177370ustar00rootroot00000000000000# https://www.freepascal.org/docs-html/ref/ref.html # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection, see https://wiki.freepascal.org/file_types hook global BufCreate .*\.(p|pp|pas|pascal)$ %{ set-option buffer filetype pascal } hook global BufCreate .*\.(dpr|dpk|dfm)$ %{ set-option buffer filetype delphi } hook global BufCreate .*\.(lpr|lfm)$ %{ set-option buffer filetype freepascal } hook global WinSetOption filetype=((free|object)?pascal|delphi) %[ require-module pascal hook window ModeChange pop:insert:.* -group pascal-trim-indent pascal-trim-indent hook window InsertChar \n -group pascal-indent pascal-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window pascal-.+ } set-option window static_words %opt{static_words} ] hook -group pascal-highlight global WinSetOption filetype=((free|object)?pascal|delphi) %[ add-highlighter window/pascal ref pascal hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/pascal } ] provide-module pascal %§ add-highlighter shared/pascal regions add-highlighter shared/pascal/code default-region group evaluate-commands %sh¶ # This might seem like a lot of effort to highlight routines and # properties correctly but it is worth it id='([_a-zA-Z][\w]{,126})\s*' # identifier for variables etc. id2="(?:$id\.)?$id(?:<.*?>)?" # (module|type).id id4="(?:$id\.)?(?:$id\.)?(?:$id\.)?$id" # type.type.type.id type=":\s*(specialize\s+)?(?:(array\s+of\s+)?$id2)" # 1:attribute 2:keyword 3:module 4:type cat <)?\s*\(" "\).*?;" regions add-highlighter shared/pascal/property region \ "\b(?i)property\s+$id4\[" "\].*?;" regions add-highlighter shared/pascal/routine/parameters region -recurse \( \( \) regions add-highlighter shared/pascal/property/parameters region -recurse \[ \[ \] regions EOF # Used to highlight "var1, var2, var3, var4 : type" declarations x="(?:$id,\s*)?" for r in property routine; do cat <@^*/+-]' 0:operator add-highlighter shared/pascal/$r/constants regex \ \b(?i)($(join "$constants"))\b 0:value # numbers (https://www.freepascal.org/docs-html/ref/refse6.html) add-highlighter shared/pascal/$r/decimal regex \b\d+([eE][+-]?\d+)?\b 0:value add-highlighter shared/pascal/$r/hex regex \\\$[\da-fA-F]+\b 0:value add-highlighter shared/pascal/$r/octal regex &[0-7]+\b 0:value add-highlighter shared/pascal/$r/binary regex \%[01]+\b 0:value add-highlighter shared/pascal/$r/char regex '#\d+\b' 0:value EOF done ¶ define-command -hidden pascal-trim-indent %{ evaluate-commands -no-hooks -draft -itersel %{ execute-keys x # remove trailing white spaces try %{ execute-keys -draft s \h + $ d } } } define-command -hidden pascal-indent-on-new-line %{ evaluate-commands -no-hooks -draft -itersel %{ # preserve previous line indent try %{ execute-keys -draft K } # cleanup trailing whitespaces from previous line try %{ execute-keys -draft k x s \h+$ d } # indent after certain keywords try %{ execute-keys -draft kx(?i)(asm|begin|const|else|except|exports|finalization|finally|label|of|otherwise|private|property|public|protected|published|record|repeat|resourcestring|threadvar|try|type|uses|var|:)\h*$j } } } § # Other syntax highlighters for reference: # https://github.com/pygments/pygments/blob/master/pygments/lexers/pascal.py # https://github.com/codemirror/CodeMirror/blob/master/mode/pascal/pascal.js # https://github.com/vim/vim/blob/master/runtime/syntax/pascal.vim # https://github.com/highlightjs/highlight.js/blob/master/src/languages/delphi.js kakoune-2022.10.31/rc/filetype/perl.kak000066400000000000000000000223151432757250600174340ustar00rootroot00000000000000# 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 xs^\h+$d } } hook window InsertChar \n -group perl-insert perl-insert-on-new-line 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 (? fill string add-highlighter shared/perl/quote_punct region -match-capture '\bq[qwx]?([:;!@#$%^&*|,.?/~=+-])' '(.)' fill string add-highlighter shared/perl/quote_regex region -match-capture '\bqr([:;!@#$%^&*|,.?/~=+-])' '(.)' fill meta add-highlighter shared/perl/double_heredoc region -match-capture <<~?\h*'(\w*)' ^\t*(\w*)$ fill string add-highlighter shared/perl/single_heredoc region -match-capture <<~?\h*"(\w*)" ^\t*(\w*)$ fill string add-highlighter shared/perl/bare_heredoc region -match-capture <<~?(\w+) ^\t*(\w+)$ fill string add-highlighter shared/perl/pod region ^=\w+ ^=cut\b fill string evaluate-commands %sh{ # Grammar keywords="else lock qw elsif lt qx eq exp ne sub for no my not tr goto and foreach or break exit unless cmp ge package until continue gt while if qq xor do le qr return" attributes="END AUTOLOAD BEGIN CHECK UNITCHECK INIT DESTROY length setpgrp endgrent link setpriority endhostent listen setprotoent endnetent local setpwent endprotoent localtime setservent endpwent log setsockopt endservent lstat shift eof map shmctl eval mkdir shmget exec msgctl shmread exists msgget shmwrite msgrcv shutdown fcntl msgsnd sin fileno sleep flock next socket fork socketpair format oct sort formline open splice getc opendir split getgrent ord sprintf getgrgid our sqrt getgrnam pack srand gethostbyaddr pipe stat gethostbyname pop state gethostent pos study getlogin print substr getnetbyaddr printf symlink abs getnetbyname prototype syscall accept getnetent push sysopen alarm getpeername quotemeta sysread atan2 getpgrp rand sysseek getppid read system getpriority readdir syswrite bind getprotobyname readline tell binmode getprotobynumber readlink telldir bless getprotoent readpipe tie getpwent recv tied caller getpwnam redo time chdir getpwuid ref times getservbyname rename truncate chmod getservbyport require uc chomp getservent reset ucfirst chop getsockname umask chown getsockopt reverse undef chr glob rewinddir chroot gmtime rindex unlink close rmdir unpack closedir grep say unshift connect hex scalar untie cos index seek use crypt seekdir utime dbmclose int select values dbmopen ioctl semctl vec defined join semget wait delete keys semop waitpid kill send wantarray die last setgrent warn dump lc sethostent write each lcfirst setnetent" values="ARGV STDERR STDOUT ARGVOUT STDIN __DATA__ __END__ __FILE__ __LINE__ __PACKAGE__" 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 perl_static_words $(join "${keywords} ${attributes} ${values}" ' ')" # Highlight keywords printf %s " add-highlighter shared/perl/code/ regex \b($(join "${keywords}" '|'))\b 0:keyword add-highlighter shared/perl/code/ regex \b($(join "${attributes}" '|'))\b 0:attribute add-highlighter shared/perl/code/ regex \b($(join "${values}" '|'))\b 0:value " } add-highlighter shared/perl/code/ regex (?!\$)-?([0-9]*\.(?!0[xXbB]))?\b([0-9]+|0[xX][0-9a-fA-F]+|0[bb][01_]+)\.?([eE][+-]?[0-9]+)?i?\b 0:value add-highlighter shared/perl/code/ regex %{\$!|\$"|\$#|\$\$|\$%|\$&|\$'|\$\(|\$\)|\$\*|\$\+|\$,|\$_|\$-|\$`|\$\.|\$/|\$:|\$;|\$<|\$=|\$>|\$\?|\$@|\$\[|\$\\|\$\]|\$\^|\$\||\$~|%!|@\+|@-|@_} 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-insert-on-new-line %~ evaluate-commands -draft -itersel %= # copy # comments prefix and following white spaces try %{ execute-keys -draft kx s ^\h*\K#\h* yP } = ~ 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 kx [{(]\h*$ j ] # cleanup trailing white spaces on the previous line try %{ execute-keys -draft kx s \h+$ d } # align to opening paren of previous line try %{ execute-keys -draft [( \A\([^\n]+\n[^\n]*\n?\z s \A\(\h*.|.\z '' & } # indent after a switch's case/default statements try %[ execute-keys -draft kx ^\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 x ^\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-2022.10.31/rc/filetype/php.kak000066400000000000000000000115411432757250600172600ustar00rootroot00000000000000# Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](phpt?) %{ 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-insert php-insert-on-new-line 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 x 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-insert-on-new-line %< evaluate-commands -draft -itersel %< # copy // comments or docblock * prefix and following white spaces try %{ execute-keys -draft s [^/] k x s ^\h*\K(?://|[*][^/])\h* y gh j P } # append " * " on lines starting a multiline /** or /* comment try %{ execute-keys -draft k x s ^\h*/[*][* ]? j gi i * } > > define-command -hidden php-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 : php-trim-indent } # indent after lines beginning / ending with opener token try %_ execute-keys -draft k x ^\h*[[{]|[[{]$ j _ # deindent closer token(s) when after cursor try %_ execute-keys -draft x ^\h*[})] gh / [})] m 1 _ > > § kakoune-2022.10.31/rc/filetype/pony.kak000066400000000000000000000100471432757250600174560ustar00rootroot00000000000000# 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-insert pony-insert-on-new-line 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 x 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-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy // comments prefix and following white spaces try %{ execute-keys -draft k x s ^\h*//\h* y jgh P } } } 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 x s \h+$ d } # 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-2022.10.31/rc/filetype/protobuf.kak000066400000000000000000000076521432757250600203410ustar00rootroot00000000000000# 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 window ModeChange pop:insert:.* -group protobuf-trim-indent protobuf-trim-indent 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 '"' (? d } } } define-command -hidden protobuf-indent-on-newline %~ evaluate-commands -draft -itersel %[ # preserve previous line indent try %{ execute-keys -draft K } # indent after lines ending with { try %[ execute-keys -draft kx \{\h*$ j ] # cleanup trailing white spaces on the previous line try %{ execute-keys -draft kx s \h+$ d } # copy // comments prefix try %{ execute-keys -draft kx s ^\h*\K/{2,}(\h*(?=\S))? yP } # deindent closing brace(s) when after cursor try %[ execute-keys -draft x ^\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-2022.10.31/rc/filetype/pug.kak000066400000000000000000000071651432757250600172730ustar00rootroot00000000000000# 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_-]*)*)?(? 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 x 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-2022.10.31/rc/filetype/purescript.kak000066400000000000000000000127601432757250600206750ustar00rootroot00000000000000# http://purescript.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Syntax reference # https://github.com/purescript/documentation/blob/master/language/Syntax.md # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](purs) %{ set-option buffer filetype purescript } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=purescript %{ require-module purescript set-option buffer extra_word_chars '_' "'" hook window ModeChange pop:insert:.* -group purescript-trim-indent purescript-trim-indent hook window InsertChar \n -group purescript-insert purescript-insert-on-new-line hook window InsertChar \n -group purescript-indent purescript-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window purescript-.+ } } hook -group purescript-highlight global WinSetOption filetype=purescript %{ add-highlighter window/purescript ref purescript hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/purescript } } provide-module purescript %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/purescript regions add-highlighter shared/purescript/code default-region group add-highlighter shared/purescript/string region (??@\\\^|~=]|$) $ fill comment add-highlighter shared/purescript/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/purescript/code/ regex \b([A-Z]['\w]*\.)*[A-Z]['\w]*(?!['\w])(?![.a-z]) 0:variable # matches infix identifier: `mod` `Apa._T'M` add-highlighter shared/purescript/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/purescript/code/ regex \b[A-Z]['\w]*\.[~<=>|:!?/.@$*&#%+\^\-\\]+ 0:operator # matches dot: . # not possibly incomplete import: a. # not other operators: !. .! add-highlighter shared/purescript/code/ regex (?|:!?/.@$*&#%+\^\-\\])\.(?![~<=>|:!?/.@$*&#%+\^\-\\]) 0:operator # matches other operators: ... > < <= ^ <*> <$> etc # not dot: . # not operator keywords: @ .. -> :: ~ add-highlighter shared/purescript/code/ regex (?|:!?/.@$*&#%+\^\-\\])[~<=>|:!?/.@$*&#%+\^\-\\]+ 0:operator # matches operator keywords: @ -> add-highlighter shared/purescript/code/ regex (?|:!?/.@$*&#%+\^\-\\])(@|~|<-|->|=>|::|=|:|[|])(?![~<=>|:!?/.@$*&#%+\^\-\\]) 1:keyword # matches: forall [..variables..] . # not the variables add-highlighter shared/purescript/code/ regex \b(forall|∀)\b[^.\n]*?(\.) 1:keyword 2:keyword # matches 'x' '\\' '\'' '\n' '\0' # not incomplete literals: '\' # not valid identifiers: w' _' add-highlighter shared/purescript/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/purescript/code/ regex ^\s*(?:where\s+|let\s+|default\s+)?([_a-z]['\w]*#?(?:,\s*[_a-z]['\w]*#?)*)\s+::\s 1:meta # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden purescript-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden purescript-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy -- comments prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K--\h* y gh j P } } } define-command -hidden purescript-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # 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 : purescript-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-2022.10.31/rc/filetype/python.kak000066400000000000000000000212111432757250600200050ustar00rootroot00000000000000# 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 x 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 ^\h*("""|''') (?>>|\.\.\.) \K' (?=''')|(?=""") 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" # Collected from `keyword.softkwlist` soft_keywords="_ case match" 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} ${soft_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 x 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 x s \h+$ d } # indent after line ending with : try %{ execute-keys -draft , k x :$ ^\h*# j } # deindent closing brace/bracket when after cursor (for arrays and dictionaries) try %< execute-keys -draft x ^\h*[}\]] gh / [}\]] m 1 > > > § kakoune-2022.10.31/rc/filetype/r.kak000066400000000000000000000155661432757250600167450ustar00rootroot00000000000000# 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}|~|\?|:{1,3}|\[{1,2}|\]{1,2}|={1,2}|<{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 x 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 kx 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 x ^\h+$ Hd > # indent after an opening brace or parenthesis at end of line try %< execute-keys -draft k x s[{(]\h*$ j > # indent after a statement not followed by an opening brace try %< execute-keys -draft k x s\)\h*(?:#[^\n]+)?\n\z \ mB \A\b(if|for|while)\b j > try %< execute-keys -draft k x s \belse\b\h*(?:#[^\n]+)?\n\z \ j > # deindent after a single line statement end try %< execute-keys -draft K x \;\h*(#[^\n]+)?$ \ K x s\)(\h+\w+)*\h*(#[^\n]+)?\n([^\n]*\n){2}\z \ MB \A\b(if|for|while)\b 1 > try %< execute-keys -draft K x \;\h*(#[^\n]+)?$ \ K x 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 x1s^\h*(#+\h*) y try %[ # if the previous comment isn't empty, create a new one execute-keys x^\h*#+\h*$ jxs^\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-2022.10.31/rc/filetype/ragel.kak000066400000000000000000000066231432757250600175700ustar00rootroot00000000000000# 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-insert ragel-insert-on-new-line 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 x 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-insert-on-new-line %< evaluate-commands -draft -itersel %< # copy _#_ comment prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K#\h* y gh j P } > > define-command -hidden ragel-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 : ragel-trim-indent } # indent after lines ending with opener token try %< execute-keys -draft k x [[{(*]$ j > # align closer token to its opener when after cursor try %< execute-keys -draft x ^\h*[})\]] gh / [})\]] m 1 > > > § kakoune-2022.10.31/rc/filetype/restructuredtext.kak000066400000000000000000000127631432757250600221400ustar00rootroot00000000000000# Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](rst) %{ set-option buffer filetype restructuredtext } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=restructuredtext %{ require-module restructuredtext } hook -group restructuredtext-load-languages global WinSetOption filetype=restructuredtext %{ restructuredtext-load-languages '%' } hook -group restructuredtext-load-languages global WinSetOption filetype=restructuredtext %{ hook -group restructuredtext-load-languages window NormalIdle .* %{restructuredtext-load-languages gtGbGl} hook -group restructuredtext-load-languages window InsertIdle .* %{restructuredtext-load-languages gtGbGl} } 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 # 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 define-command restructuredtext-load-languages -params 1 %{ evaluate-commands -draft %{ try %{ execute-keys "%arg{1}s^\.\.\h*code-block::\h*\K\w+" evaluate-commands -itersel %{ try %{ require-module %val{selection} add-highlighter "shared/restructuredtext/%val{selection}" region "\.\.\h*code-block::\h*%val{selection}\h*\n" '^(?=\S)' regions add-highlighter "shared/restructuredtext/%val{selection}/" default-region fill meta add-highlighter "shared/restructuredtext/%val{selection}/inner" region \A\.\.\h*code-block::[^\n]*\K '^(?=\S)' ref %val{selection} }} }} } } kakoune-2022.10.31/rc/filetype/ruby.kak000066400000000000000000000241421432757250600174530ustar00rootroot00000000000000# 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 ModeChange pop:insert:.* -group ruby-trim-indent ruby-trim-indent 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]?([^\s0-9A-Za-z\(\{\[<>\]\}\)])' ([^\s0-9A-Za-z\(\{\[<>\]\}\)]) fill string add-highlighter shared/ruby/ region -match-capture '%[isIS]([^\s0-9A-Za-z\(\{\[<>\]\}\)])' ([^\s0-9A-Za-z\(\{\[<>\]\}\)]) fill variable add-highlighter shared/ruby/ region -match-capture '%[rxRX]([^\s0-9A-Za-z\(\{\[<>\]\}\)])' ([^\s0-9A-Za-z\(\{\[<>\]\}\)]) fill meta add-highlighter shared/ruby/heredoc region -match-capture '<<[-~]?(?!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|require_relative|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 x # 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 x ^ \h * (else) $ i ^ \h * (if|case) 1 } try %{ execute-keys -draft x ^ \h * (elsif) $ i ^ \h * (if) 1 } try %{ execute-keys -draft x ^ \h * (when) $ i ^ \h * (case) 1 } try %{ execute-keys -draft x ^ \h * (rescue) $ i ^ \h * (begin|def) 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 x ^ \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 x s ^\h*\K#\h* y jgi P } # wisely add end structure evaluate-commands -save-regs x %[ try %{ execute-keys -draft k x s ^ \h + \" x y } catch %{ reg x '' } try %[ evaluate-commands -draft %[ # Check if previous line opens a block execute-keys -draft kx ^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 ^x(end|else|elsif|rescue|when)[^0-9A-Za-z_!?] ] execute-keys -draft oxend # insert a new line with containing end ] ] ] ] § kakoune-2022.10.31/rc/filetype/rust.kak000066400000000000000000000323761432757250600174770ustar00rootroot00000000000000# 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 %{(?|<|%)=? 0:operator add-highlighter shared/rust/code/operators_as regex \bas\b 0:operator add-highlighter shared/rust/code/ref_ref regex (&\h+[&~@*])[^)=\s\t\r\n] 1:type add-highlighter shared/rust/code/ref regex ([&~@*])[^)=\s\t\r\n] 1:type add-highlighter shared/rust/code/operators_logic regex &&|\|\| 0:operator add-highlighter shared/rust/code/lifetime_or_loop_label regex ('([a-zA-Z]\w+|_\w+))\b 1:meta add-highlighter shared/rust/code/namespace regex \b[a-zA-Z](\w+)?(\h+)?(?=::) 0:module add-highlighter shared/rust/code/mod_path_sep regex :: 0:meta add-highlighter shared/rust/code/question_mark regex \? 0:meta # 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/function_call regex _?[a-zA-Z]\w*\s*(?=\() 0:function add-highlighter shared/rust/code/generic_function_call regex _?[a-zA-Z]\w*\s*(?=::<) 0:function add-highlighter shared/rust/code/function_declaration regex (?:fn\h+)(_?\w+)(?:<[^>]+?>)?\( 1:function add-highlighter shared/rust/code/keywords regex \b(?:as|break|continue|crate|else|enum|extern|false|fn|for|if|impl|in|let|loop|match|mod|pub|return|self|Self|struct|super|trait|true|type|unsafe|use|where|while|async|await|dyn|abstract|become|box|do|try)\b 0:keyword add-highlighter shared/rust/code/storage regex \b(move|mut|ref|static|const)\b 0:type add-highlighter shared/rust/code/pub_with_scope regex \b(pub)\h*(\()\h*(crate|super|self|in\h+[\w:]+)\h*(\)) 1:keyword 2:meta 4:meta # after let can be an arbitrary pattern match add-highlighter shared/rust/code/macro regex \b\w+! 0:meta # the number literals syntax is defined here: # https://doc.rust-lang.org/reference/tokens.html#numb ers 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/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 by te 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 add-highlighter shared/rust/code/enum regex \b(Option|Result)\b 0:type add-highlighter shared/rust/code/enum_variant regex \b(Some|None|Ok|Err)\b 0:value add-highlighter shared/rust/code/std_traits regex \b(Copy|Send|Sized|Sync|Drop|Fn|FnMut|FnOnce|Box|ToOwned|Clone|PartialEq|PartialOrd|Eq|Ord|AsRef|AsMut|Into|From|Default|Iterator|Extend|IntoIterator|DoubleEndedIterator|ExactSizeIterator|SliceConcatExt|String|ToString|Vec)\b 0:type # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden rust-trim-indent %{ # remove trailing white spaces try %{ execute-keys -draft -itersel x 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 x s ^\h*//[!/]{0,2}\h* y try %[ # if the previous comment isn't empty, create a new one execute-keys x^\h*//[!/]{0,2}$ jxs^\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 kx ^(\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 kx^\h*/\* execute-keys -draft i* ] catch %[ try %[ # if the next line is a comment line insert a star execute-keys -draft jx^\h+\* execute-keys -draft i* ] catch %[ try %[ # if the previous line is an empty comment line, close the comment scope execute-keys -draft kx^\h+\*\h+$ x1s\*(\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 Kx1s^[^*]*(\*)& ] } catch %` # re-indent previous line if it starts with where to match previous block # string literal parsing within extern does not handle escape try %% execute-keys -draft k x ^\h*where\b hh ^\h*\b(impl|((|pub\ |pub\((crate|self|super|in\ (::)?([a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)(::[a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)*)\)\ )((async\ |const\ )?(unsafe\ )?(extern\ ("[^"]*"\ )?)?fn|struct|enum|union)))\b 1 % # preserve previous line indent try %{ execute-keys -draft K } # 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 after non-empty lines not starting with operator and not ending with , or ; or { # XXX simplify this into a single without s try %< execute-keys -draft k x s [^\h].+ \A[-+*/&|^})#] [,{](\h*/[/*].*|)$ j > # indent after lines ending with { try %+ execute-keys -draft k x \{$ j + # dedent after lines starting with . and ending with } or ) or , or ; or .await (} or ) or .await maybe with ?) try %_ execute-keys -draft k x ^\h*\. ([,]|(([})]|\.await)\?*))\h*$ j _ # dedent after lines ending with " => {}" - part of empty match try %# execute-keys -draft k x \ =>\ \{\}\h*$ j # # align to opening curly brace or paren when newline is inserted before a single closing try %< execute-keys -draft ^\h*[)}] h m 1 > # todo dedent additional unmatched parenthesis # try %& execute-keys -draft k x 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 ^\h*\b(impl|((|pub\ |pub\((crate|self|super|in\ (::)?([a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)(::[a-zA-Z][a-zA-Z0-9_]*|_[a-zA-Z0-9_]+)*)\)\ )((async\ |const\ )?(unsafe\ )?(extern\ ("[^"]*"\ )?)?fn|struct|enum|union))|if|for)\b \{ ll x ^\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-2022.10.31/rc/filetype/sass.kak000066400000000000000000000061471432757250600174500ustar00rootroot00000000000000# 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-insert sass-insert-on-new-line 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 '"' (? 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-insert-on-new-line %< evaluate-commands -draft -itersel %< # copy // comment prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K/{2,}\h* y gh j P } > > define-command -hidden sass-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 : sass-trim-indent } # avoid indent after properties and comments try %{ execute-keys -draft k x [:/] j } # deindent closing brace when after cursor try %[ execute-keys -draft x ^\h*\} gh / \} m 1 ] > > § kakoune-2022.10.31/rc/filetype/scala.kak000066400000000000000000000071221432757250600175540ustar00rootroot00000000000000# 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-insert scala-insert-on-new-line 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 x s \h+$ d } } define-command -hidden scala-insert-on-new-line %[ evaluate-commands -draft -itersel %[ # copy // comments prefix and following white spaces try %{ execute-keys -draft kx s ^\h*\K#\h* yP } ] ] define-command -hidden scala-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 : scala-trim-indent ] # indent after lines ending with { try %[ execute-keys -draft k x \{$ j ] # deindent closing brace when after cursor try %[ execute-keys -draft x ^\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-2022.10.31/rc/filetype/scheme.kak000066400000000000000000000212611432757250600177350ustar00rootroot00000000000000# http://www.scheme-reports.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate (.*/)?(.*\.(scm|ss|sld|sps|sls)) %{ 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 = "(? 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 x s ^\h*\K#\h* y gh j P } ] ] # Use custom object matching to copy indentation for the various logical # blocks. # # Note that we're using a weird non-ascii character instead of [ or { here # because the '[' and '{' characters need to be available for the commands. 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 x \bdo$ j } # copy the indentation of the matching for/when - matching on the do # statement, so we don't need to duplicate this for the two loop # structures. try %{ execute-keys -draft , k x \bdone$ gh [c\bdo\b,\bdone\b x 1 , 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 x \bthen$ j } # copy the indentation of the matching if try %{ execute-keys -draft , k x \bfi$ gh [c\bif\b,\bfi\b x 1 , j K } # copy the indentation of the matching if, and then re-indent afterwards try %{ execute-keys -draft , k x \belse$ gh [c\bif\b,\bfi\b x 1 , j K 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 x \bin$ j } # copy the indentation of the matching case try %{ execute-keys -draft , k x \besac$ gh [c\bcase\b,\besac\b x 1 , j K } # indent after ) try %{ execute-keys -draft , k x ^\s*\(?[^(]+[^)]\)$ j } # deindent after ;; try %{ execute-keys -draft , k x ^\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 x (\s|^)\{$ j = # deindent closing } try %= execute-keys -draft , k x ^\s*\}$ j K = # deindent closing } when after cursor try %= execute-keys -draft x ^\h*\} gh / \} m 1 = @ ¶ § kakoune-2022.10.31/rc/filetype/sml.kak000066400000000000000000000063571432757250600172750ustar00rootroot00000000000000# 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-2022.10.31/rc/filetype/svelte.kak000066400000000000000000000027351432757250600200000ustar00rootroot00000000000000hook global WinCreate .*\.svelte %[ set-option window filetype svelte ] hook global WinSetOption filetype=(svelte) %{ require-module html hook window ModeChange pop:insert:.* -group "svelte-trim-indent" html-trim-indent hook window InsertChar '>' -group "svelte-indent" html-indent-on-greater-than hook window InsertChar \n -group "svelte-indent" html-indent-on-new-line hook -once -always window WinSetOption "filetype=.*" " remove-hooks window ""svelte-.+"" " } hook -group svelte-highlight global WinSetOption filetype=(svelte) %{ add-highlighter "window/svelte" ref svelte hook -once -always window WinSetOption "filetype=.*" " remove-highlighter ""window/svelte"" " } add-highlighter shared/svelte regions add-highlighter shared/svelte/comment region fill comment add-highlighter shared/svelte/tag region < > regions add-highlighter shared/svelte/style region \K (?=) ref css add-highlighter shared/svelte/script region \K (?=) ref javascript add-highlighter shared/svelte/block region \{((#|:|/)\w+)? \} regions add-highlighter shared/svelte/block/ default-region fill meta add-highlighter shared/svelte/block/inner region -recurse \{ \{((#|:|/)\w+)?\K (?=\}) ref javascript add-highlighter shared/svelte/tag/base default-region ref html/tag add-highlighter shared/svelte/tag/block region -recurse \{ \{ \} ref svelte/block kakoune-2022.10.31/rc/filetype/swift.kak000066400000000000000000000035771432757250600176370ustar00rootroot00000000000000hook 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_multiline region %{(? d } } } define-command -hidden taskpaper-indent-on-new-line %{ evaluate-commands -draft -itersel %{ # preserve previous line indent try %{ execute-keys -draft K } ## If the line above is a project indent with a tab try %{ execute-keys -draft Z kx ^\h*([^:\n]+): z i } # cleanup trailing white spaces on previous line try %{ execute-keys -draft kx s \h+$ d } } } } kakoune-2022.10.31/rc/filetype/terraform.kak000066400000000000000000000107421432757250600204740ustar00rootroot00000000000000# 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 '"' '(? d } } define-command -hidden toml-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy # comments prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K#\h* y gh j P } } } define-command -hidden toml-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 : toml-trim-indent } } } } kakoune-2022.10.31/rc/filetype/troff.kak000066400000000000000000000024121432757250600176060ustar00rootroot00000000000000# 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 '(^\.)?\\".*?\n' 0:comment 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 '^\.\.$' 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-2022.10.31/rc/filetype/tupfile.kak000066400000000000000000000025231432757250600201410ustar00rootroot00000000000000# 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 '"' (?' -group twig-indent twig-indent-on-greater-than hook window InsertChar '#' -group twig-auto-close twig-auto-close-delim hook window InsertChar '%' -group twig-auto-close twig-auto-close-delim set-option buffer extra_word_chars '_' '-' hook -once -always window WinSetOption filetype=.* %{ remove-hooks window twig-.+ } ] hook -group twig-highlight global WinSetOption filetype=twig %{ add-highlighter window/twig ref twig hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/twig } } provide-module twig %[ require-module html # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/twig regions add-highlighter shared/twig/core default-region group add-highlighter shared/twig/comment region \{# [#]\} fill comment add-highlighter shared/twig/delim region \{([%]-?|\{) (-?[%]|\})\} regions add-highlighter shared/twig/core/ ref html add-highlighter shared/twig/delim/base default-region group add-highlighter shared/twig/delim/double_string region '"' (?hH\h*\{lyp execute-keys hihi ] ] ] define-command -hidden twig-insert-on-new-line %[ evaluate-commands -draft -itersel %/ execute-keys try %[ execute-keys -draft kx^\h*\{\[%#\{\]\h+$ execute-keys -draft jghd ] / ] ] kakoune-2022.10.31/rc/filetype/vhdl.kak000066400000000000000000000427771432757250600174450ustar00rootroot00000000000000# Based on IEEE Std 1076‐2019 # Detection hook global BufCreate .*[.](vhd[l]?) %[ set-option buffer filetype vhdl ] # Initialization hook global WinSetOption filetype=vhdl %[ require-module vhdl set-option window static_words %opt{vhdl_static_words} hook -group vhdl-indent window InsertChar \n vhdl-indent-on-new-line hook -group vhdl-indent window InsertChar \) vhdl-indent-on-closing-parenthesis hook -group vhdl-insert window InsertChar \n vhdl-insert-on-new-line # Cleanup trailing whitespaces on current line insert end. hook -group vhdl-trim-indent window ModeChange pop:insert:.* %[ try %[ execute-keys -draft x s ^\h+$ d ] ] hook -once -always window WinSetOption filetype=.* %[ remove-hooks window vhdl-.+ ] ] hook -group vhdl-highlight global WinSetOption filetype=vhdl %[ add-highlighter window/vhdl ref vhdl hook -once -always window WinSetOption filetype=.* %[ remove-highlighter window/vhdl ] ] provide-module vhdl %§ # Highlighters & Completion add-highlighter shared/vhdl regions add-highlighter shared/vhdl/code default-region group add-highlighter shared/vhdl/comment_line region '--' $ fill comment add-highlighter shared/vhdl/comment region /\* \*/ fill comment # Integer formats add-highlighter shared/vhdl/code/ regex '(?i)\b0b[01]+l?\b' 0:value add-highlighter shared/vhdl/code/ regex '(?i)\b0x[\da-f]+l?\b' 0:value add-highlighter shared/vhdl/code/ regex '(?i)\b0o?[0-7]+l?\b' 0:value add-highlighter shared/vhdl/code/ regex '(?i)\b([1-9]\d*|0)l?\b' 0:value # Float formats add-highlighter shared/vhdl/code/ regex '\b\d+[eE][+-]?\d+\b' 0:value add-highlighter shared/vhdl/code/ regex '(\b\d+)?\.\d+\b' 0:value add-highlighter shared/vhdl/code/ regex '\b\d+\.' 0:value # Imaginary formats add-highlighter shared/vhdl/code/ regex '\b\d+\+\d+[jJ]\b' 0:value evaluate-commands %sh[ values="true false note warning error failure nul" # LRM 5.2.4.1 units="fs ps ns us ms sec min hr Å nm um mm cm m km" # LRM 16.2 predefined_attributes=" base left right high low ascending length range reverse_range subtype image pos succ pred leftof rightof value val designated_subtype reflect high low index element delayed stable quiet transaction event active last_event last_active last_value driving driving_value simple_name instance_name path_name record signal converse " libraries="ieee std" packages=" math_real math_complex std_logic_1164 std_logic_textio numeric_bit numeric_std numeric_bit_unsigned numeric_std_unsigned fixed_float_types fixed_generic_pkg fixed_pkg float_generic_pkg float_pkg standard textio env " # LRM 15.10 reserved_words=" abs access after alias all and architecture array assert assume assume_guarantee attribute begin block body buffer bus case component configuration constant context cover default disconnect downto else elsif end entity exit fairness file for force function generate generic group guarded if impure in inertial inout is label library linkage literal loop map mod nand new next nor not null of on open or others out package parameter port postponed procedure process property protected pure range record register reject release rem report restrict restrict_guarantee return rol ror select sequence severity signal shared sla sll sra srl strong subtype then to transport type unaffected units until use variable view vpkg vmode vprop vunit wait when while with xnor xor " types=" bit bit_vector boolean boolean_vector character file_open_state file_origin_kind integer natural positive line line_vector real real_vector std_logic std_logic_vector std_ulogic std_ulogic_vector side signed unsigned string text time time_vector " functions=" find_leftmost find_rightmost divide reciprocal remainder modulo minimum maximum std_match add_carry scalb resize to_ufixed to_sfixed to_unsigned to_signed to_real to_integer to_slv to_std_logic_vector to_stdlogicvector to_sulv to_std_ulogic_vector to_std_ulogicvector to_01 is_x to_x01 to_ux01 to_x01z ufixed_high ufixed_low sfixed_high sfixed_low to_ufix to_sfix ufix_high ufix_low sfix_high sfix_low write read bwrite binary_write bread binary_read owrite oread octal_write octal_read hwrite hread hex_write hex_read to_string to_bstring to_binary_string to_ostring to_octal_string to_hstring to_hex_string from_string from_bstring from_binary_string from_ostring from_octal_string from_hstring from_hex_string rising_edge falling_edge " 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 vhdl_static_words $(join "${values} ${units} ${predefined_attributes} ${libraries} ${packages} ${reserved_words} ${types} ${functions}" ' ')" # Highlight keywords printf %s " add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${values}" '|'))\b' 0:value add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${units}" '|'))\b' 0:meta add-highlighter shared/vhdl/code/ regex \"'(?i)\b($(join "${predefined_attributes}" '|'))\b\" 0:attribute add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${libraries}" '|'))\b' 0:builtin add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${packages}" '|'))\b' 0:builtin add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${reserved_words}" '|'))\b' 0:keyword add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${functions}" '|'))\b\(' 1:builtin add-highlighter shared/vhdl/code/ regex '(?i)\b($(join "${types}" '|'))\b' 0:type add-highlighter shared/vhdl/code/ regex '^\h*(@[\w_.]+))' 1:attribute " ] add-highlighter shared/vhdl/code/ regex \(|\)|\;|\.|,|:|\| 0:attribute add-highlighter shared/vhdl/code/ regex \?\?|=|/=|<|<=|>|>=|\?=|\?/=|\?<|\?<=|\?>|\?>=|\+|-|&|\*|/|:= 0:operator # Meta values highlight. # The values 'U', 'X', 'W', and '–' are metalogical values; they define the behavior of the model itself rather than the behavior of the hardware being synthesized. add-highlighter shared/vhdl/code/ regex "(?i)'[U|X|W|-]'" 0:meta # Highlight other logical values. add-highlighter shared/vhdl/code/ regex "(?i)'[0|1|Z|L|H]'" 0:value # String add-highlighter shared/vhdl/code/ regex '"[^"]*"' 0:string # Binary vector. add-highlighter shared/vhdl/code/ regex '[bB]"[01_]*"' 0:value # Octal vector. add-highlighter shared/vhdl/code/ regex '[oO]"[01234567_]*"' 0:value # Hex vector. add-highlighter shared/vhdl/code/ regex '(?i)x"[0123456789abcdef_]*"' 0:value define-command -hidden vhdl-insert-on-new-line %[ # Handle comment lines. evaluate-commands -itersel %[ # Copy '--' comment prefix and following white spaces. try %[ # is needed because of "Preserve previous line indent" command. try %[ execute-keys -draft k x s ^\h*--\h* y j gh P ] ] ] evaluate-commands -save-regs x %[ # Save previous line indent in register x. try %[ execute-keys -draft kxs^\h+"xy ] catch %[ reg x '' ] # All "wisely add" commands share the same concept. # Only "end if" has extra comments. # Wisely add "end if;". evaluate-commands %[ try %[ # Validate previous line and that it is not closed yet. execute-keys -draft kx ^\h*(?i)((then|(.*:\h*)?if\b.*\bthen)$) j}ijx ^x(?i)(elsif|else|end)\b # Don't add for "if ... generate", it requires "end generate;". execute-keys -draft kx (?i)\bgenerate\b execute-keys -draft oxendif ] ] # Wisely add "end generate;". evaluate-commands %[ try %[ execute-keys -draft kx ^\h*(?i).*\bgenerate$ j}ijx ^x(?i)(begin|elsif|else|end)\b # Don't add in case of comment line. execute-keys -draft kx ^\h*-- execute-keys -draft oxendgenerate ] ] # Wisely add "when" and "end case;". evaluate-commands %[ try %[ # TODO: Case needs special handling. execute-keys -draft kx ^\h*(?i)(case|.*\h*:\h*case)\b jwx ^x(?i)(end|when) execute-keys -draft xoxendcasekAwhen ] ] # Wisely add "begin" and "end block;". evaluate-commands %[ try %[ execute-keys -draft kx ^\h*(?i)((block|.*:\h*block)\b) j}ijx ^x(?i)(begin|end)\b execute-keys -draft oxbeginxendblock ] ] # Wisely add "begin" and "end process;". evaluate-commands %[ try %[ execute-keys -draft kx ^\h*(?i)(.*:\h*)?(postponed\h+)?process\b j}ijx ^x(?i)(begin|end) execute-keys -draft oxbeginxendprocess ] ] # Wisely add "end loop;". evaluate-commands %[ try %[ execute-keys -draft kx ^\h*(?i)(.*\bloop|.*\h*:\h*(for|loop))$ j}ijx ^x(?i)(end) execute-keys -draft oxendloop ] ] # Wisely add "end protected;". evaluate-commands %[ try %[ execute-keys -draft kx ^\h*(?i)(type\b.*\bis\h+protected)$ j}ijx ^x(?i)(end) execute-keys -draft oxendprotected ] ] # Wisely add "end protected body;". evaluate-commands %[ try %[ execute-keys -draft kx ^(?i)(\h*type\h+\w+\h+is\h+protected\h+body$) j}ijx ^x(?i)end\h+protected\h+body\b execute-keys -draft oxendprotectedbody ] ] # Wisely add "end record;". evaluate-commands %[ try %[ execute-keys -draft kx ^\h*(?i)(type\b.*\bis\h+record\h*)$ j}ijx ^x(?i)(end) execute-keys -draft oxendrecord ] ] # Wisely add ");" for "type ... is (". evaluate-commands %[ try %[ execute-keys -draft kx ^\h*(?i)(type\b.*\bis\h+\(\h*)$ j}ijx ^x(\)) execute-keys -draft ox) ] ] # Wisely add "end entity;". evaluate-commands %[ try %[ execute-keys -draft kx ^(?i)\h*entity\b.*\bis$ j}ijx ^x(?i)(begin|end)\b execute-keys -draft oxendentity ] ] # Wisely add "begin" and "end function;". evaluate-commands %[ try %[ execute-keys -draft kx ^(?i)(\h*\)?\h*return\b.*\bis$) j}ijx ^x(?i)(begin|end)\b execute-keys -draft oxbeginxendfunction ] try %[ execute-keys -draft kx ^(?i)(\h*((pure|impure)\h+)?function\b.*\bis$) j}ijx ^x(?i)(begin|end)\b execute-keys -draft oxbeginxendfunction ] ] # Wisely add "begin" and "end procedure;". evaluate-commands %[ try %[ execute-keys -draft kx ^(?i)(\h*procedure\b.*\bis$) j}ijx ^x(?i)\b(begin|end)\b execute-keys -draft oxbeginxendprocedure ] try %[ execute-keys -draft kx ^(?i)\h*\)\h*\bis$ j}ijx ^x(?i)\b(begin|end)\b # Verify that line with opening parenthesis contains "procedure" keyword. execute-keys -draft kx s\) x (?i)\bprocedure\b execute-keys -draft oxbeginxendprocedure ] ] # Wisely add "end package;". evaluate-commands %[ try %[ execute-keys -draft kx ^(?i)(package\b) j}ijx ^x(?i)(end)\b # Make sure it is not package body. execute-keys -draft kx(?i)\bbody\b execute-keys -draft oendpackage ] ] # Wisely add "end package body;". evaluate-commands %[ try %[ execute-keys -draft kx ^(?i)(package\h+body\b) j}ijx ^x(?i)(end)\b execute-keys -draft oendpackagebody ] ] # Wisely add "begin" and "end architecture;". evaluate-commands %[ try %[ execute-keys -draft kx ^(?i)\h*architecture\b j}ijx ^x(?i)(begin|end)\b execute-keys -draft oxbeginxendarchitecture ] ] # Wisely add ");" for "port (". evaluate-commands %[ try %[ execute-keys -draft kx ^\h*(?i)port\h*\($ j}ijx ^x(\)\;) execute-keys -draft ox) ] ] # Wisely add ");" for "port map (". evaluate-commands %[ try %[ execute-keys -draft kx ^\h*(?i)port\h+map\h*\($ j}ijx ^x(\)\;) execute-keys -draft ox) ] ] # Wisely add ");" for "generic (". evaluate-commands %[ try %[ execute-keys -draft kx ^\h*(?i)generic\h*\($ j}ijx ^x(\)\;) execute-keys -draft ox) ] ] # Wisely add ")" for "generic map (". evaluate-commands %[ try %[ execute-keys -draft kx ^\h*(?i)generic\h+map\h*\($ j}ijx ^x(\)) execute-keys -draft ox) ] ] # Wisely add ") return ;" for "[pure|impure] function ... (". evaluate-commands %[ try %[ execute-keys -draft kx ^\h*(?i)(pure\b|impure\b)?\h*function\b.*\h*\($ j}ijx ^x(\)\h*return.*) execute-keys -draft ox)return ] ] # Wisely add ");" for "procedure ... (". evaluate-commands %[ try %[ execute-keys -draft kx ^\h*(?i)procedure\b.*\h*\($ j}ijx ^x(\)\h*\;) execute-keys -draft ox) ] ] ] ] define-command -hidden vhdl-indent-on-new-line %{ evaluate-commands -itersel %{ # Align "then" to previous "if|elsif". evaluate-commands -itersel -save-regs x %[ try %[ execute-keys -draft k x (?i)^\h*then$ try %[ execute-keys -draft (?i)\b(if|elsif)\bxs^\h+"xy ] catch %[ reg x '' ] try %[ execute-keys -draft k xs^\h+d ] catch %[ ] execute-keys -draft kgh ix ] ] # Align "generate" to previous "if|for". evaluate-commands -itersel -save-regs x %[ try %[ execute-keys -draft k x (?i)^\h*generate$ try %[ execute-keys -draft (?i)\b(if|for)\bxs^\h+"xy ] catch %[ reg x '' ] try %[ execute-keys -draft k xs^\h+d ] catch %[ ] execute-keys -draft kgh ix ] ] # Preserve previous line indent. try %[ execute-keys -draft K ] # Cleanup trailing whitespaces from previous line. try %[ execute-keys -draft k x s \h+$ d ] # Increase indent after some keywords. try %[ execute-keys -draft kx (?i)\b(begin|block|body|else|for|generate|if|is|loop|process|protected|record|select|then)$ # Do not indent if in comment line. execute-keys -draft kx(?i)^\h*-- # Do not indent for "case ... is". execute-keys -draft kx^\h*(?i)(case|.*\h*:\h*case)\b execute-keys -draft ] # Copy the indentation of the matching if. try %{ execute-keys -draft , k x ^\h*(elsif\b|else$) gh [c^\h*(\S*\h*:\h*)?if\b,\bend\sif\b x 1 , j K } # Increase indent after some operators. try %[ execute-keys -draft k x (\(|=>|<=|:=)$ j ] } } define-command vhdl-indent-on-closing-parenthesis %[ evaluate-commands -itersel %[ # Decrease indent after ")" at the beginning of line. try %[ execute-keys -draft x (^\h+\)$) ] ] ] § kakoune-2022.10.31/rc/filetype/void-linux.kak000066400000000000000000000001631432757250600205650ustar00rootroot00000000000000# Void Linux package template hook global BufCreate .*/?srcpkgs/.+/template %{ set-option buffer filetype sh } kakoune-2022.10.31/rc/filetype/yaml.kak000066400000000000000000000045711432757250600174400ustar00rootroot00000000000000# http://yaml.org # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Detection # ‾‾‾‾‾‾‾‾‾ hook global BufCreate .*[.](ya?ml) %{ set-option buffer filetype yaml } # Initialization # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ hook global WinSetOption filetype=yaml %{ require-module yaml hook window ModeChange pop:insert:.* -group yaml-trim-indent yaml-trim-indent hook window InsertChar \n -group yaml-insert yaml-insert-on-new-line hook window InsertChar \n -group yaml-indent yaml-indent-on-new-line hook -once -always window WinSetOption filetype=.* %{ remove-hooks window yaml-.+ } } hook -group yaml-highlight global WinSetOption filetype=yaml %{ add-highlighter window/yaml ref yaml hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/yaml } } provide-module yaml %{ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ add-highlighter shared/yaml regions add-highlighter shared/yaml/code default-region group add-highlighter shared/yaml/double_string region '"' (? d } } define-command -hidden yaml-insert-on-new-line %{ evaluate-commands -draft -itersel %{ # copy '#' comment prefix and following white spaces try %{ execute-keys -draft k x s ^\h*\K#\h* y gh j P } } } define-command -hidden yaml-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 : yaml-trim-indent } # indent after : try %{ execute-keys -draft , k x :$ j } # indent after - try %{ execute-keys -draft , k x ^\h*- j } } } } kakoune-2022.10.31/rc/filetype/zig.kak000066400000000000000000000144211432757250600172620ustar00rootroot00000000000000# 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-insert zig-insert-on-new-line 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 # strings and characters add-highlighter shared/zig/string region '"' (?|&|\||\^|~|\?|!)' 0:operator # builtin functions add-highlighter shared/zig/code/ regex "@(?:addWithOverflow|alignCast|alignOf|as|asyncCall|atomicLoad|atomicRmw|atomicStore|bitCast|bitOffsetOf|boolToInt|bitSizeOf|breakpoint|mulAdd|byteSwap|bitReverse|offsetOf|call|cDefine|cImport|cInclude|clz|cmpxchgStrong|cmpxchgWeak|compileError|compileLog|ctz|cUndef|divExact|divFloor|divTrunc|embedFile|enumToInt|errorName|errorReturnTrace|errorToInt|errSetCast|export|extern|fence|field|fieldParentPtr|floatCast|floatToInt|frame|Frame|frameAddress|frameSize|hasDecl|hasField|import|intCast|intToEnum|intToError|intToFloat|intToPtr|maximum|memcpy|memset|minimum|wasmMemorySize|wasmMemoryGrow|mod|mulWithOverflow|panic|popCount|prefetch|ptrCast|ptrToInt|rem|returnAddress|select|setAlignStack|setCold|setEvalBranchQuota|setFloatMode|setRuntimeSafety|shlExact|shlWithOverflow|shrExact|shuffle|sizeOf|splat|reduce|src|sqrt|sin|cos|exp|exp2|log|log2|log10|fabs|floor|ceil|trunc|round|subWithOverflow|tagName|This|truncate|Type|typeInfo|typeName|TypeOf|unionInit)\b" 0:function # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden zig-trim-indent %{ # delete trailing whitespace try %{ execute-keys -draft -itersel x s \h+$ d } } define-command -hidden zig-insert-on-new-line %< evaluate-commands -draft -itersel %< # copy // or /// comments prefix or \\ string literal prefix and following whitespace try %< execute-keys -draft k x s ^\h*\K(///?|\\\\)\h* y gh j P > > > define-command -hidden zig-indent-on-new-line %< evaluate-commands -draft -itersel %< # preserve indent level try %< execute-keys -draft K > try %< # only if we didn't copy a comment or multiline string execute-keys -draft x ^\h*(//|\\\\) # indent after lines ending in { try %< execute-keys -draft k x \{\h*$ j > # deindent closing } when after cursor try %< execute-keys -draft x ^\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-2022.10.31/rc/tools/000077500000000000000000000000001432757250600153165ustar00rootroot00000000000000kakoune-2022.10.31/rc/tools/autorestore.asciidoc000066400000000000000000000011551432757250600213740ustar00rootroot00000000000000= Automatically restore unsaved work after a crash. When Kakoune crashes, it automatically writes out unsaved changes to backup files with predictable names. When you edit a file, if such a backup file exists, this plugin will automatically load the content of the backup file instead. By default, backup files are deleted when restored. You can set the `autorestore_purge_restored` option to `false` to prevent this. If you don't want backups to be restored automatically, use the `autorestore-disable` command to disable the feature for the current session, or put it in your `kakrc` to disable the feature forever. kakoune-2022.10.31/rc/tools/autorestore.kak000066400000000000000000000060451432757250600203670ustar00rootroot00000000000000declare-option -docstring %{ Remove backups once they've been restored See `:doc autorestore` for details. } \ 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 See `:doc autorestore` for details. } \ %{ 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}\"jd} ## 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 See `:doc autorestore` for details. } \ %{ 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 See `:doc autorestore` for details. } \ %{ remove-hooks global autorestore } hook -group autorestore global BufCreate .* %{ autorestore-restore-buffer } kakoune-2022.10.31/rc/tools/autowrap.kak000066400000000000000000000042521432757250600176530ustar00rootroot00000000000000declare-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 "x^[^\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 'px|${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-2022.10.31/rc/tools/clang.kak000066400000000000000000000214211432757250600170720ustar00rootroot00000000000000hook -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 -method replace ${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 will be shown 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-2022.10.31/rc/tools/comment.kak000066400000000000000000000153511432757250600174550ustar00rootroot00000000000000# Line comments # If the language has no line comments, set to '' 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|protobuf|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|purescript) %{ 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=janet %{ 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=conf %{ set-option buffer comment_line '#' } 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=(fennel|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|mercury) %{ set-option buffer comment_line '%' } hook global BufSetOption filetype=ledger %{ set-option buffer comment_line ';' } hook global BufSetOption filetype=(lisp|scheme) %{ 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=(ocaml|coq) %{ set-option buffer comment_line '' set-option buffer comment_block_begin '(* ' set-option buffer comment_block_end ' *)' } hook global BufSetOption filetype=((free|object)?pascal|delphi) %{ 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|cue|hare) %{ 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=r %{ set-option buffer comment_line '#' } 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 -draft 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-2022.10.31/rc/tools/ctags.kak000066400000000000000000000205661432757250600171200ustar00rootroot00000000000000# 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-2022.10.31/rc/tools/doc.asciidoc000066400000000000000000000034741432757250600175730ustar00rootroot00000000000000= Kakoune's online documentation This is Kakoune's online documentation system. To see what documentation topics are available, type `:doc` and look at the completion menu. To view a particular topic, type its name or select it from the completion menu. Then hit Enter. Documentation will be displayed in the client named in the `docsclient` option. == Using the documentation browser Documentation buffers are like any other buffer, so you can scroll through them as normal, search within a topic with `/`, etc. However, they can also contain links: <>. Links can be followed by moving the cursor onto them and pressing Enter. If a link takes you to a different documentation topic, you can return to the original by using the `:buffer` command. == Writing documentation Documentation must be in AsciiDoc format, with the extension `.asciidoc`. It must be stored somewhere within <>. Kakoune's built-in documentation renderer does not necessarily support every feature, so don't go overboard with formatting. To create a link to another documentation topic, the URL should be the topic's name, just like `:doc` uses. Because topics are identified only by their basename, you should take care that your topic's name does not conflict with any of the names used either by other plugins or by Kakoune's standard library. == Sources The `:doc` command searches within the following locations for documents in the AsciiDoc format (`*.asciidoc`): * The user plugin directory, `"%val{config}/autoload"` * The system documentation directory, `"%val{runtime}/doc"` * The system plugin directory, `"%val{runtime}/rc"` It searches recursively, and follows symlinks. == Demonstration target Well done! You can <>! kakoune-2022.10.31/rc/tools/doc.kak000066400000000000000000000150511432757250600165550ustar00rootroot00000000000000declare-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_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} update-option buffer doc_render_ranges evaluate-commands -itersel %{ set-option -add buffer doc_links "%val{selection_desc}|%reg{1}" set-option -add buffer doc_render_ranges "%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 -hidden 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 -hidden 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 } # Go to beginning of file execute-keys 'gg' set-option buffer readonly true add-highlighter buffer/ ranges doc_render_ranges add-highlighter buffer/ wrap -word -indent map buffer normal :doc-follow-link } define-command doc -params 0..2 -menu -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 See `:doc doc` for details. } %{ evaluate-commands %sh{ topic="doc" if [ $# -ge 1 ]; then topic="$1" fi page=$( find -L \ "${kak_config}/autoload/" \ "${kak_runtime}/doc/" \ "${kak_runtime}/rc/" \ -type f -name "$topic.asciidoc" 2>/dev/null | head -1 ) 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' "$topic.asciidoc" fi } } complete-command doc shell-script-candidates %{ case "$kak_token_to_complete" in 0) find -L \ "${kak_config}/autoload/" \ "${kak_runtime}/doc/" \ "${kak_runtime}/rc/" \ -type f -name "*.asciidoc" 2>/dev/null | sed 's,.*/,,; s/\.[^.]*$//';; 1) page=$( find -L \ "${kak_config}/autoload/" \ "${kak_runtime}/doc/" \ "${kak_runtime}/rc/" \ -type f -name "$1.asciidoc" 2>/dev/null | head -1 ) if [ -f "${page}" ]; then awk ' /^==+ +/ { sub(/^==+ +/, ""); print } /^\[\[[^\]]+\]\]/ { sub(/^\[\[/, ""); sub(/\]\].*/, ""); print } ' < $page | tr '[A-Z ]' '[a-z-]' fi;; esac } alias global help doc kakoune-2022.10.31/rc/tools/format.kak000066400000000000000000000023771432757250600173070ustar00rootroot00000000000000declare-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 'e|' %{ set-register e nop 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 echo "set-register e fail formatter returned an error (exit code $?)" >"$kak_command_fifo" cat "$format_in" fi rm -f "$format_in" "$format_out" } execute-keys '|' %reg{e} } } alias global format format-buffer kakoune-2022.10.31/rc/tools/git.kak000066400000000000000000000342221432757250600165740ustar00rootroot00000000000000declare-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 %{ require-module diff 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 %{ require-module diff 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 } } hook -group git-show-branch-highlight global WinSetOption filetype=git-show-branch %{ require-module diff add-highlighter window/git-show-branch group add-highlighter window/git-show-branch/ regex '(\*)|(\+)|(!)' 1:red 2:green 3:green add-highlighter window/git-show-branch/ regex '(!\D+\{0\}\])|(!\D+\{1\}\])|(!\D+\{2\}\])|(!\D+\{3\}\])' 1:red 2:green 3:yellow 4:blue add-highlighter window/git-show-branch/ regex '(\B\+\D+\{0\}\])|(\B\+\D+\{1\}\])|(\B\+\D+\{2\}\])|(\B\+\D+\{3\}\])|(\B\+\D+\{1\}\^\])' 1:red 2:green 3:yellow 4:blue 5:magenta hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/git-show-branch} } 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-branch 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-branch\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 local map_diff_goto_source case "$1" in diff) map_diff_goto_source=true; filetype=diff ;; show) map_diff_goto_source=true; filetype=git-log ;; show-branch) filetype=git-show-branch ;; log) filetype=git-log ;; status) filetype=git-status ;; *) return 1 ;; esac output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-git.XXXXXXXX)/fifo mkfifo ${output} ( git "$@" > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null # We need to unmap in case an existing buffer changes type, # for example if the user runs "git show" and "git status". map_diff_goto_source=$([ -n "${map_diff_goto_source}" ] \ && printf %s "map buffer normal :git-diff-goto-source -docstring 'Jump to source from git diff'" \ || printf %s "unmap buffer normal :git-diff-goto-source") 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}) } } ${map_diff_goto_source} }" } 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(flush, text, i) { if (line == "") { return; } text=substr(sha,1,8) " " dates[sha] " " authors[sha] # gsub("|", "\\|", text) gsub("~", "~~", text) for ( i=0; i < count; i++ ) { flags = flags " %~" line+i "|" text "~" } now = systime() # Send roughly one update per second, to avoid creating too many kak processes. if (!flush && now - last_sent < 1) { return } cmd = "kak -p " ENVIRON["kak_session"] print "set-option -add buffer=" ENVIRON["kak_bufname"] " git_blame_flags " flags | cmd close(cmd) flags = "" last_sent = now } /^([0-9a-f]+) ([0-9]+) ([0-9]+) ([0-9]+)/ { send_flags(0) 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(1); }' ) > /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 --no-ext-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|show-branch|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 }} # Works within :git diff and :git show define-command git-diff-goto-source \ -docstring 'Navigate to source by pressing the enter key in hunks when git diff is displayed. Works within :git diff and :git show' %{ require-module diff diff-jump %sh{ git rev-parse --show-toplevel } } kakoune-2022.10.31/rc/tools/go/000077500000000000000000000000001432757250600157235ustar00rootroot00000000000000kakoune-2022.10.31/rc/tools/go/gopls.kak000066400000000000000000000052571432757250600175500ustar00rootroot00000000000000# gopls.kak: gopls bindings for kakoune define-command -params 1 -docstring %{ gopls : gopls command wrapper All commands are forwarded to gopls utility Available commands are: format imports definition references } -shell-script-candidates %{ printf "format\nimports\ndefinition\nreferences\n" } \ gopls %{ require-module gopls evaluate-commands %sh{ case "$1" in format|imports) printf %s\\n "gopls-cmd $1" ;; definition) printf %s\\n "gopls-def" ;; references) printf %s\\n "gopls-ref" ;; *) printf "fail Unknown gopls command '%s'\n" "$1" exit ;; esac } } provide-module gopls %§ evaluate-commands %sh{ if ! command -v gopls > /dev/null 2>&1; then echo "fail Please install gopls or add to PATH!" fi } # Temp dir preparation declare-option -hidden str gopls_tmp_dir define-command -hidden -params 0 gopls-prepare %{ evaluate-commands %sh{ dir=$(mktemp -d "${TMPDIR:-/tmp}"/kak-gopls.XXXXXXXX) printf %s\\n "set-option buffer gopls_tmp_dir ${dir}" } } # gopls format/imports define-command -hidden -params 1 gopls-cmd %{ gopls-prepare evaluate-commands %sh{ dir=${kak_opt_gopls_tmp_dir} gopls "$1" -w "${kak_buffile}" 2> "${dir}/stderr" if [ $? -ne 0 ]; then # show error messages in *debug* buffer printf %s\\n "echo -debug %file{${dir}/stderr}" fi } edit! nop %sh{ rm -rf "${kak_opt_gopls_tmp_dir}" } } # gopls definition define-command -hidden -params 0 gopls-def %{ evaluate-commands %sh{ jump=$( gopls definition "${kak_buffile}:${kak_cursor_line}:${kak_cursor_column}" 2> /dev/null \ |sed -e 's/-.*//; s/:/ /g; q' ) if [ -n "${jump}" ]; then printf %s\\n "evaluate-commands -try-client '${kak_opt_jumpclient}' %{ edit ${jump} }" fi } } # gopls references define-command -hidden -params 0 gopls-ref %{ gopls-prepare evaluate-commands %sh{ dir=${kak_opt_gopls_tmp_dir} mkfifo "${dir}/fifo" ( gopls references "${kak_buffile}:${kak_cursor_line}:${kak_cursor_column}" \ > "${dir}/fifo" 2> /dev/null & ) > /dev/null 2>&1 < /dev/null # using filetype=grep for nice hilight and mapping printf %s\\n "evaluate-commands -try-client '${kak_opt_toolsclient}' %{ edit! -fifo '${dir}/fifo' *gopls-refs* set-option buffer filetype grep hook -always -once buffer BufCloseFifo .* %{ nop %sh{ rm -r '${dir}' } } }" } } § kakoune-2022.10.31/rc/tools/grep.kak000066400000000000000000000062501432757250600167460ustar00rootroot00000000000000declare-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 .. -docstring %{ grep []: grep utility wrapper All 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}) } } }" }} complete-command grep file 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 'xs^((?:\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-2022.10.31/rc/tools/lint.asciidoc000066400000000000000000000022141432757250600177630ustar00rootroot00000000000000= Integrate with tools that check files for problems. Many file-formats have "lint" tools that check for common problems and point out where they occur. Most of these tools produce output in the traditional message 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. The `:lint-buffer` and `:lint-selections` commands will run the shell command specified in the `lintcmd` option, passing it the path to a temporary file containing the text to be linted. The results are collected in the `*lint-output*` buffer, and analyze it. If `toolsclient` is set, the `*lint-output*` buffer will be displayed in the named client. Each reported error or warning causes a marker to appear in the left-hand margin of the buffer that was checked. When the main cursor moves onto that line, the associated messages are displayed. If they get distracting, you can turn off the markers and messages with the `:lint-hide-diagnostics` command. You can also use `:lint-next-message` and `:lint-previous-message` to jump between the lines with messages. kakoune-2022.10.31/rc/tools/lint.kak000066400000000000000000000363071432757250600167650ustar00rootroot00000000000000declare-option \ -docstring %{ The shell command used by lint-buffer and lint-selections. See `:doc lint` for details. } \ 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 lint-open-output-buffer %{ evaluate-commands -try-client %opt{toolsclient} %{ edit! -fifo "%arg{1}/fifo" -debug *lint-output* set-option buffer filetype make set-option buffer make_current_error_line 0 } } 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) # 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" # A fifo to send the results back to a Kakoune buffer. mkfifo "$dir"/fifo # Send the results to kakoune if the session is still valid. if printf 'lint-open-output-buffer %s' "$(kakquote "$dir")" | kak -p "$kak_session"; then cat "$dir"/result > "$dir"/fifo fi # Clean up. 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. See `:doc lint` for details. } \ 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. See `:doc lint` for details. } \ 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-2022.10.31/rc/tools/make.kak000066400000000000000000000076251432757250600167350ustar00rootroot00000000000000declare-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} %{ buffer '*make*' 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} %{ buffer '*make*' execute-keys %opt{make_current_error_line}g } } } kakoune-2022.10.31/rc/tools/man.kak000066400000000000000000000115411432757250600165630ustar00rootroot00000000000000declare-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=$? if command -v col >/dev/null; then col -b -x > ${colout} < ${manout} else sed 's/.//g' > ${colout} < ${manout} fi 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 -hidden man-search -params 2 %{ set-register / %arg[1] try %{ execute-keys %arg[2] } catch %{ fail "Could not find man page link" } } 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] } define-command -docstring 'Try to jump to a man page' \ man-jump %{ try %{ execute-keys s %opt[man_link1] } 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 map global man 'g' -docstring 'Jump to a man page using selected man page link' :man-jump map global man 'j' -docstring 'Go to next man page link' :man-link-next map global man 'k' -docstring 'Go to previous man page link' :man-link-prev map global man 'm' -docstring 'Look up a man page' :man kakoune-2022.10.31/rc/tools/python/000077500000000000000000000000001432757250600166375ustar00rootroot00000000000000kakoune-2022.10.31/rc/tools/python/jedi.kak000066400000000000000000000061611432757250600202460ustar00rootroot00000000000000hook -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}) export PYTHONPATH="$kak_opt_jedi_python_path:$PYTHONPATH" python 2> "${dir}/fifo" -c 'if 1: import os dir = os.environ["kak_opt_jedi_tmp_dir"] buffile = os.environ["kak_buffile"] line = int(os.environ["kak_cursor_line"]) column = int(os.environ["kak_cursor_column"]) timestamp = os.environ["kak_timestamp"] client = os.environ["kak_client"] pipe_escape = lambda s: s.replace("|", "\\|") def quote(s): c = chr(39) # single quote return c + s.replace(c, c+c) + c import jedi script = jedi.Script(code=open(dir + "/buf", "r").read(), path=buffile) completions = ( quote( pipe_escape(str(c.name)) + "|" + pipe_escape("info -style menu -- " + quote(c.docstring())) + "|" + pipe_escape(str(c.name)) ) for c in script.complete(line=line, column=column-1) ) header = str(line) + "." + str(column) + "@" + timestamp cmds = [ "echo completed", " ".join(("set-option", quote("buffer=" + buffile), "jedi_completions", header, *completions)), ] print("evaluate-commands -client", quote(client), quote("\n".join(cmds))) ' | 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-2022.10.31/rc/tools/rust/000077500000000000000000000000001432757250600163135ustar00rootroot00000000000000kakoune-2022.10.31/rc/tools/rust/racer.kak000066400000000000000000000116471432757250600201100ustar00rootroot00000000000000hook -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-2022.10.31/rc/tools/spell.kak000066400000000000000000000135651432757250600171370ustar00rootroot00000000000000declare-option -hidden range-specs spell_regions declare-option -hidden str spell_last_lang 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{ 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)'" 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 printf 'eval -no-hooks write %s\n' "${kak_response_fifo}" > $kak_command_fifo { sed 's/^/^/' | 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 (/^[+-]/) { # required to ignore undocumented aspell functionality } 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 "|DiagnosticError" } 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) } ' } <$kak_response_fifo >/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 %{ prompt \ -shell-script-candidates %{ options="" if [ -n "$kak_opt_spell_last_lang" ]; then options="-l '$kak_opt_spell_last_lang'" fi printf %s "$kak_selection" | eval "aspell -a $options" | sed -n -e '/^&/ { s/^[^:]*: //; s/, /\n/g; p }' } \ "Replace with: " \ %{ evaluate-commands -save-regs a %{ set-register a %val{text} execute-keys c a } } } 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-2022.10.31/rc/windowing/000077500000000000000000000000001432757250600161635ustar00rootroot00000000000000kakoune-2022.10.31/rc/windowing/detection.kak000066400000000000000000000031231432757250600206300ustar00rootroot00000000000000# 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' 'sway' 'wayland' '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-2022.10.31/rc/windowing/iterm.kak000066400000000000000000000142061432757250600177760ustar00rootroot00000000000000# 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 # \ -> \\ # " -> \" do_esc() { printf %s "$*" | sed -e 's|\\|\\\\|g; s|"|\\"|g' } escaped=$(do_esc "$args") esc_path=$(do_esc "$PATH") esc_tmp=$(do_esc "$TMPDIR") cmd="env PATH='${esc_path}' TMPDIR='${esc_tmp}' $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.. -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{@} } complete-command iterm-terminal-vertical shell define-command iterm-terminal-horizontal -params 1.. -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{@} } complete-command iterm-terminal-horizontal shell define-command iterm-terminal-tab -params 1.. -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 } } complete-command iterm-terminal-tab shell define-command iterm-terminal-window -params 1.. -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 } } complete-command iterm-terminal-window shell define-command iterm-focus -params ..1 -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 " tell aWin" \ -e " select" \ -e " end tell" \ -e " tell aTab" \ -e " select" \ -e " end tell" \ -e " select" \ -e " end if" \ -e " end tell" \ -e " end repeat" \ -e " end repeat" \ -e "end repeat" fi } } complete-command -menu iterm-focus client alias global focus iterm-focus alias global terminal iterm-terminal-vertical } kakoune-2022.10.31/rc/windowing/kitty.kak000066400000000000000000000051731432757250600200250ustar00rootroot00000000000000# 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 (window|os-window)} str kitty_window_type window define-command kitty-terminal -params 1.. -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{ match="" if [ -n "$kak_client_env_KITTY_WINDOW_ID" ]; then match="--match=id:$kak_client_env_KITTY_WINDOW_ID" fi listen="" if [ -n "$kak_client_env_KITTY_LISTEN_ON" ]; then listen="--to=$kak_client_env_KITTY_LISTEN_ON" fi kitty @ $listen launch --no-response --type="$kak_opt_kitty_window_type" --cwd="$PWD" $match "$@" } } complete-command kitty-terminal shell define-command kitty-terminal-tab -params 1.. -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{ match="" if [ -n "$kak_client_env_KITTY_WINDOW_ID" ]; then match="--match=id:$kak_client_env_KITTY_WINDOW_ID" fi listen="" if [ -n "$kak_client_env_KITTY_LISTEN_ON" ]; then listen="--to=$kak_client_env_KITTY_LISTEN_ON" fi kitty @ $listen launch --no-response --type=tab --cwd="$PWD" $match "$@" } } complete-command kitty-terminal-tab shell define-command kitty-focus -params ..1 -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 match="" if [ -n "$kak_client_env_KITTY_WINDOW_ID" ]; then match="--match=id:$kak_client_env_KITTY_WINDOW_ID" fi listen="" if [ -n "$kak_client_env_KITTY_LISTEN_ON" ]; then listen="--to=$kak_client_env_KITTY_LISTEN_ON" fi kitty @ $listen focus-window --no-response $match fi } } complete-command -menu kitty-focus client alias global terminal kitty-terminal alias global terminal-tab kitty-terminal-tab alias global focus kitty-focus } kakoune-2022.10.31/rc/windowing/new-client.kak000066400000000000000000000005161432757250600207220ustar00rootroot00000000000000define-command new -params .. -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' \ %{ terminal kak -c %val{session} -e "%arg{@}" } complete-command -menu new command kakoune-2022.10.31/rc/windowing/repl/000077500000000000000000000000001432757250600171255ustar00rootroot00000000000000kakoune-2022.10.31/rc/windowing/repl/dtach.kak000066400000000000000000000022411432757250600206770ustar00rootroot00000000000000provide-module dtach-repl %{ # test if dtach is installed evaluate-commands %sh{ [ -n "$(command -v dtach)" ] || echo 'fail dtach not found' } declare-option -docstring "id of the REPL" str dtach_repl_id define-command -docstring %{ dtach-repl []: create a new terminal window for repl interaction All optional parameters are forwarded to the new terminal window } \ -params .. \ dtach-repl %{ terminal sh -c %{ file="$(mktemp -u -t kak_dtach_repl.XXXXX)" trap 'rm -f "${file}"' EXIT printf "evaluate-commands -try-client $1 \ 'set-option current dtach_repl_id ${file}'" | kak -p "$2" shift 2 dtach -c "${file}" -E sh -c "${@:-$SHELL}" || "${@:-$SHELL}" } -- %val{client} %val{session} %arg{@} } complete-command dtach-repl shell define-command dtach-send-text -params 0..1 -docstring %{ dtach-send-text [text]: Send text to the REPL. If no text is passed, then the selection is used } %{ nop %sh{ printf "%s" "${@:-$kak_selection}" | dtach -p "$kak_opt_dtach_repl_id" } } alias global repl-new dtach-repl alias global repl-send-text dtach-send-text } kakoune-2022.10.31/rc/windowing/repl/kitty.kak000066400000000000000000000025641432757250600207700ustar00rootroot00000000000000hook global ModuleLoaded kitty %{ require-module kitty-repl } provide-module kitty-repl %{ define-command -params .. \ -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 match="" if [ -n "$kak_client_env_KITTY_WINDOW_ID" ]; then match="--match=id:$kak_client_env_KITTY_WINDOW_ID" fi listen="" if [ -n "$kak_client_env_KITTY_LISTEN_ON" ]; then listen="--to=$kak_client_env_KITTY_LISTEN_ON" fi kitty @ $listen launch --no-response --keep-focus --type="$kak_opt_kitty_window_type" --title=kak_repl_window --cwd="$PWD" $match $cmd } } complete-command kitty-repl shell 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 --match=title:kak_repl_window "$text" } } alias global repl-new kitty-repl alias global repl-send-text kitty-send-text } kakoune-2022.10.31/rc/windowing/repl/tmux.kak000066400000000000000000000057631432757250600206250ustar00rootroot00000000000000# 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 current tmux_repl_id '%s'" $(tmux display-message -p '#{session_id}:#{window_id}.#{pane_id}') } } define-command tmux-repl-vertical -params 0.. -docstring "Create a new vertical pane for repl interaction" %{ tmux-repl-impl 'split-window -v' %arg{@} } complete-command tmux-repl-vertical shell define-command tmux-repl-horizontal -params 0.. -docstring "Create a new horizontal pane for repl interaction" %{ tmux-repl-impl 'split-window -h' %arg{@} } complete-command tmux-repl-horizontal shell define-command tmux-repl-window -params 0.. -docstring "Create a new window for repl interaction" %{ tmux-repl-impl 'new-window' %arg{@} } complete-command tmux-repl-window shell define-command -params 0..1 tmux-repl-set-pane -docstring %{ tmux-repl-set-pane [pane number]: Set an existing tmux pane for repl interaction If the address of new pane is not given, next pane is used (To get the pane number in tmux, use 'tmux display-message -p '#{pane_id}'" in that pane) } %{ evaluate-commands %sh{ if [ -z "$TMUX" ]; then echo 'fail This command is only available in a tmux session' exit fi if [ $# -eq 0 ]; then curr_pane="$(tmux display-message -p '#{pane_id}')" curr_pane_no="${curr_pane:1}" tgt_pane=$((curr_pane_no+1)) else tgt_pane="$1" fi curr_win="$(tmux display-message -p '#{window_id}')" curr_win_no="${curr_win:1}" current=$(tmux list-panes -t $curr_win_no -F \#D) if [[ "$current" =~ "%"$tgt_pane ]]; then printf "set-option current tmux_repl_id '%s'" $(tmux display-message -p '#{session_id}:#{window_id}.')%$tgt_pane else echo 'fail The correct pane is not there. Activate using tmux-terminal-* or some other way' fi } } define-command -hidden tmux-send-text -params 0..1 -docstring %{ tmux-send-text [text]: Send text 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-new tmux-repl-horizontal alias global repl-send-text tmux-send-text } kakoune-2022.10.31/rc/windowing/repl/x11.kak000066400000000000000000000026711432757250600202340ustar00rootroot00000000000000hook global ModuleLoaded x11 %{ require-module x11-repl } provide-module x11-repl %{ declare-option -docstring "window id of the REPL window" str x11_repl_id define-command -docstring %{ x11-repl []: create a new window for repl interaction All optional parameters are forwarded to the new window } \ -params .. \ x11-repl %{ x11-terminal sh -c %{ winid="${WINDOWID:-$(xdotool search --pid ${PPID} | tail -1)}" printf "evaluate-commands -try-client $1 \ 'set-option current x11_repl_id ${winid}'" | kak -p "$2" shift 2; [ "$1" ] && "$@" || "$SHELL" } -- %val{client} %val{session} %arg{@} } complete-command x11-repl shell define-command x11-send-text -params 0..1 -docstring %{ x11-send-text [text]: Send text to the REPL window. If no text is passed, then the selection is used } %{ evaluate-commands %sh{ ([ "$#" -gt 0 ] && printf "%s" "$1" || printf "%s" "${kak_selection}" ) | xsel -i || echo 'fail x11-send-text: failed to run xsel, see *debug* buffer for details' && kak_winid=$(xdotool getactivewindow) && xdotool windowactivate "${kak_opt_x11_repl_id}" key --clearmodifiers Shift+Insert && xdotool windowactivate "${kak_winid}" || echo 'fail x11-send-text: failed to run xdotool, see *debug* buffer for details' } } alias global repl-new x11-repl alias global repl-send-text x11-send-text } kakoune-2022.10.31/rc/windowing/screen.kak000066400000000000000000000052361432757250600201400ustar00rootroot00000000000000# 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.. -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{@} } complete-command screen-terminal-vertical shell define-command screen-terminal-horizontal -params 1.. -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{@} } complete-command screen-terminal-horizontal shell define-command screen-terminal-window -params 1.. -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" } } complete-command screen-terminal-window shell define-command screen-focus -params ..1 -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 } } complete-command -menu screen-focus client alias global focus screen-focus alias global terminal screen-terminal-vertical } kakoune-2022.10.31/rc/windowing/sway.kak000066400000000000000000000027231432757250600176420ustar00rootroot00000000000000provide-module sway %{ # Ensure we're actually in Sway evaluate-commands %sh{ [ -z "${kak_opt_windowing_modules}" ] || [ -n "$SWAYSOCK" ] || echo 'fail SWAYSOCK is not set' } require-module 'wayland' define-command sway-focus-pid -hidden %{ evaluate-commands %sh{ pid=$kak_client_pid # Try to focus a window with the current PID, walking up the tree of # parent processes until the focus eventually succeeds while ! swaymsg [pid=$pid] focus > /dev/null 2> /dev/null ; do # Replace the current PID with its parent PID pid=$(ps -p $pid -o ppid=) # If we couldn't get a PPID for some reason, or it's 1 or less, we # should just fail. if [ -z $pid ] || [ $pid -le 1 ]; then echo "fail Can't find PID for Sway window to focus" break fi done } } define-command sway-focus -params ..1 -docstring ' sway-focus []: focus a given client''s window. If no client is passed, then the current client is used' \ %{ # Quick branch to make sure we're calling sway-focus-pid from the client # the user wants to focus on. evaluate-commands %sh{ if [ $# -eq 1 ]; then printf "evaluate-commands -client '%s' sway-focus-pid" "$1" else echo sway-focus-pid fi } } complete-command -menu sway-focus client unalias global focus alias global focus sway-focus } kakoune-2022.10.31/rc/windowing/tmux.kak000066400000000000000000000060751432757250600176600ustar00rootroot00000000000000# 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 if [ -n "$TMPDIR" ]; then TMUX=$tmux tmux $tmux_args env TMPDIR="$TMPDIR" "$@" < /dev/null > /dev/null 2>&1 & else TMUX=$tmux tmux $tmux_args "$@" < /dev/null > /dev/null 2>&1 & fi } } define-command tmux-terminal-vertical -params 1.. -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{@} } complete-command tmux-terminal-vertical shell define-command tmux-terminal-horizontal -params 1.. -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{@} } complete-command tmux-terminal-horizontal shell define-command tmux-terminal-window -params 1.. -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{@} } complete-command tmux-terminal-window shell define-command tmux-focus -params ..1 -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 # select-pane makes the pane active in the window, but does not select the window. Both select-pane # and select-window should be invoked in order to select a pane on a currently not focused window. TMUX="${kak_client_env_TMUX}" tmux select-window -t "${kak_client_env_TMUX_PANE}" \; \ select-pane -t "${kak_client_env_TMUX_PANE}" > /dev/null fi } } complete-command -menu tmux-focus client ## 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-2022.10.31/rc/windowing/wayland.kak000066400000000000000000000037371432757250600203240ustar00rootroot00000000000000# wayland provide-module wayland %{ # ensure that we're running in the right environment evaluate-commands %sh{ [ -z "${kak_opt_windowing_modules}" ] || [ -n "$WAYLAND_DISPLAY" ] || echo 'fail WAYLAND_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' \ 'foot sh -c' \ 'termite -e ' \ 'wterm -e sh -c' \ '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 wayland-terminal -params 1.. -docstring ' wayland-terminal []: create a new terminal as a Wayland 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 & } } } complete-command wayland-terminal shell define-command wayland-focus -params ..1 -docstring ' wayland-focus []: focus a given client''s window If no client is passed, then the current client is used' \ %{ fail 'Focusing specific windows in most Wayland window managers is unsupported' } complete-command -menu wayland-focus client alias global focus wayland-focus alias global terminal wayland-terminal } kakoune-2022.10.31/rc/windowing/x11.kak000066400000000000000000000045561432757250600172760ustar00rootroot00000000000000# 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 -x sh -c' \ '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.. -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 & } } } complete-command x11-terminal shell define-command x11-focus -params ..1 -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 } } complete-command -menu x11-focus client alias global focus x11-focus alias global terminal x11-terminal } kakoune-2022.10.31/share/000077500000000000000000000000001432757250600146545ustar00rootroot00000000000000kakoune-2022.10.31/share/kak/000077500000000000000000000000001432757250600154225ustar00rootroot00000000000000kakoune-2022.10.31/share/kak/autoload000077700000000000000000000000001432757250600201252../../rcustar00rootroot00000000000000kakoune-2022.10.31/share/kak/colors000077700000000000000000000000001432757250600205132../../colorsustar00rootroot00000000000000kakoune-2022.10.31/share/kak/doc000077700000000000000000000000001432757250600204012../../doc/pages/ustar00rootroot00000000000000kakoune-2022.10.31/share/kak/gdb000077700000000000000000000000001432757250600172602../../gdb/ustar00rootroot00000000000000kakoune-2022.10.31/share/kak/kakrc000066400000000000000000000027341432757250600164460ustar00rootroot00000000000000def -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 ${1}.kak'" 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-2022.10.31/share/kak/rc000077700000000000000000000000001432757250600167212../../rcustar00rootroot00000000000000kakoune-2022.10.31/src/000077500000000000000000000000001432757250600143415ustar00rootroot00000000000000kakoune-2022.10.31/src/.gdbinit000066400000000000000000000000611432757250600157570ustar00rootroot00000000000000set print pretty break Kakoune::on_assert_failed kakoune-2022.10.31/src/Makefile000066400000000000000000000122371432757250600160060ustar00rootroot00000000000000debug ?= 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)) ifeq ($(static),yes) LDFLAGS += -static -pthread endif PREFIX ?= /usr/local DESTDIR ?= # root dir bindir := $(DESTDIR)$(PREFIX)/bin libexecdir := $(DESTDIR)$(PREFIX)/libexec/kak sharedir := $(DESTDIR)$(PREFIX)/share/kak docdir := $(DESTDIR)$(PREFIX)/share/doc/kak mandir := $(DESTDIR)$(PREFIX)/share/man/man1 os := $(shell uname) ifeq ($(os),Darwin) CPPFLAGS += -I/opt/local/include LDFLAGS += -L/opt/local/lib else ifeq ($(os),FreeBSD) CPPFLAGS += -I/usr/local/include LDFLAGS += -L/usr/local/lib else ifeq ($(os),Haiku) LIBS += -lnetwork -lbe else ifeq ($(os),OpenBSD) CPPFLAGS += -D'KAK_BIN_PATH="$(bindir)/kak"' -I/usr/local/include LDFLAGS += -L/usr/local/lib mandir := $(DESTDIR)$(PREFIX)/man/man1 else ifneq (,$(findstring _NT,$(os))) # Both Cygwin and MSYS2 have "_NT" in their uname. CPPFLAGS += -D_XOPEN_SOURCE=700 LIBS += -ldbghelp else ifeq ($(os),SunOS) LDFLAGS += -lsocket -rdynamic else LDFLAGS += -rdynamic endif CXXFLAGS += -pedantic -std=c++2a -g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-address compiler := $(shell $(CXX) --version) ifneq (,$(findstring clang,$(compiler))) CXXFLAGS += -frelaxed-template-template-args -Wno-ambiguous-reversed-operator 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 $@ $< .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) .version.cc .version.o 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) \ $(libexecdir) \ $(sharedir)/rc \ $(sharedir)/colors \ $(sharedir)/doc \ $(docdir) \ $(mandir) ifeq ($(debug),yes) install -d $(sharedir)/gdb endif install: kak man installdirs install -m 0755 kak $(bindir) ln -sf ../../bin/kak $(libexecdir)/kak 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 ifeq ($(debug),yes) install -m 0644 ../gdb/kakoune.py $(sharedir)/gdb endif install-strip: install strip -s $(bindir)/kak uninstall: rm -rf $(bindir)/kak \ $(libexecdir) \ $(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-2022.10.31/src/alias_registry.cc000066400000000000000000000021251432757250600176710ustar00rootroot00000000000000#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-2022.10.31/src/alias_registry.hh000066400000000000000000000024711432757250600177070ustar00rootroot00000000000000#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-2022.10.31/src/array_view.hh000066400000000000000000000050721432757250600170360ustar00rootroot00000000000000#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 requires (sizeof(decltype(*std::declval().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-2022.10.31/src/assert.cc000066400000000000000000000023571432757250600161600ustar00rootroot00000000000000#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' '{}'", replace(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-2022.10.31/src/assert.hh000066400000000000000000000020321432757250600161600ustar00rootroot00000000000000#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-2022.10.31/src/backtrace.cc000066400000000000000000000035001432757250600165650ustar00rootroot00000000000000#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-2022.10.31/src/backtrace.hh000066400000000000000000000004541432757250600166040ustar00rootroot00000000000000#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-2022.10.31/src/buffer.cc000066400000000000000000000600011432757250600161160ustar00rootroot00000000000000#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 { Buffer::HistoryNode::HistoryNode(HistoryId parent) : parent{parent}, committed{Clock::now()} {} Buffer::Buffer(String name, Flags flags, BufferLines lines, ByteOrderMark bom, EolFormat eolformat, FsStatus fs_status) : 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_status} { #ifdef KAK_DEBUG for (auto& line : lines) kak_assert(not (line->length == 0) and line->data()[line->length-1] == '\n'); #endif static_cast(m_lines) = std::move(lines); m_changes.push_back({ Change::Insert, {0,0}, line_count() }); options().get_local_option("eolformat").set(eolformat); options().get_local_option("BOM").set(bom); // 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