Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gustavo-hms/objetiva

Some new object selections for Kakoune
https://github.com/gustavo-hms/objetiva

kakoune lua plugin

Last synced: 28 days ago
JSON representation

Some new object selections for Kakoune

Awesome Lists containing this project

README

        

# Objetiva

Objetiva is a plugin for the [Kakoune](http://kakoune.org/) editor that defines some new [object selections](https://github.com/mawww/kakoune/blob/master/doc/pages/keys.asciidoc#object-selection).

## Usage

To use it, you first need to require the `objetiva` module:

```kak
require-module objetiva
```

Then, read the sections bellow to know how to define mappings for its object selections.

## Line object

A line object is defined with the command `objetiva-line`. You may wonder why a line object is needed if we already have the `x` key. Well, the `x` key defines a *movement* whereas `objetiva-line` defines an *object selection*, allowing you to select, for instance, an *inner line* (a line without the surrounding whitespaces), or select to the line end using the `]` key (instead of having to learn yet another key combination like `Gl`).

Also, if you are in an empty line, the `x` key moves the cursor to the *next line* instead of staying in the current one. This command, on the other hand, makes the cursor stays in the current line.

Suggested mapping:

```kak
map global object x 'objetiva-line' -docstring line
```

That mapping allows you to select a line with `x`, or select to the inner line start with `x`

## Matching object

A matching object is like the `m` key for object selections. The command `objetiva-matching` selects the text enclosed by matching characters (respecting the built-in option `matching_pairs`).

Suggested mapping:

```kak
map global object m 'objetiva-matching' -docstring matching
```

Now, you can use, say, `m` to select everything inside parentheses (or braces, or whatever is defined by the option `matching_pairs`) but excluding the parentheses themselves, or `m` to select *including* parentheses. In the same vein, `]m` selects from the cursor to the end of the region enclosed by parentheses.

## Case object

The command `objetiva-case` selects a segment of a word written in any of the following conventions: camelCase, snake_case and kebab-case. The plugin detects automatically the convention used for each word and behaves accordingly. So, you can have a single file with many case conventions and everything will work as expected.

Suggested mapping:

```kak
map global object 'objetiva-case' -docstring case
```

Now you can use `-` to select a segment of a word and `-` to select the segment excluding `_` (for snake case words) and `-` (for kebab case words).

## Case movement

Although not an object selection, this plugin also defines commands for a *case movement* since it comes in handy. If you define the following mappings:

```kak
map global normal ': objetiva-case-move'
map global normal _ ': objetiva-case-expand'
map global normal ': objetiva-case-move-previous'
map global normal ': objetiva-case-expand-previous'
```

You can move between segments of words in the forward direction using `` and in the backward direction using ``. You can also expand selection in the forward direction using `_` and in the backward direction using ``.

## Installation

Objetiva depends on the [luar](https://github.com/gustavo-hms/luar) plugin. If you use [plug.kak](https://github.com/robertmeta/plug.kak) to manage your plugins, you can install both by adding the following to your `kakrc`:

```kak
plug "gustavo-hms/luar" %{
plug "gustavo-hms/objetiva" %{
require-module objetiva

# Suggested mappings

map global object x 'objetiva-line' -docstring line
map global object m 'objetiva-matching' -docstring matching
map global object 'objetiva-case' -docstring case
map global normal ': objetiva-case-move'
map global normal _ ': objetiva-case-expand'
map global normal ': objetiva-case-move-previous'
map global normal ': objetiva-case-expand-previous'
}
}
```