All Projects → andreyorst → smarttab.kak

andreyorst / smarttab.kak

Licence: MIT License
Automatic handling different styles of indentation and alignment.

Programming Languages

KakouneScript
24 projects

Projects that are alternatives of or similar to smarttab.kak

kakoune-ghci-bridge
Get intellisense for Haskell in Kakoune via ghci
Stars: ✭ 13 (-75%)
Mutual labels:  kakoune
a11y-accordion-tabs
A script for an accessible accordion tabs component
Stars: ✭ 50 (-3.85%)
Mutual labels:  tabs
vuepress-plugin-tabs
Vuepress plugin - Tabs Container for Vuepress
Stars: ✭ 33 (-36.54%)
Mutual labels:  tabs
vue-slim-tabs
A slim tab component for Vue.js (1.3 kB minified)
Stars: ✭ 104 (+100%)
Mutual labels:  tabs
kakoune-themes
Color schemes for kakoune , extra syntax highlighting and my config
Stars: ✭ 25 (-51.92%)
Mutual labels:  kakoune
tabs
pure javascript tabs for ES6
Stars: ✭ 11 (-78.85%)
Mutual labels:  tabs
kakoune-sudo-write
Write to files using 'sudo'
Stars: ✭ 24 (-53.85%)
Mutual labels:  kakoune
luar
Script Kakoune using Lua
Stars: ✭ 33 (-36.54%)
Mutual labels:  kakoune
kakoune-edit-or-dir
File browser for Kakoune
Stars: ✭ 18 (-65.38%)
Mutual labels:  kakoune
tabbis.js
Pure vanilla javascript tabs with nesting
Stars: ✭ 44 (-15.38%)
Mutual labels:  tabs
tagbar.kak
Tag viewer for Kakoune
Stars: ✭ 19 (-63.46%)
Mutual labels:  kakoune
joplin-note-tabs
Allows to open several notes at once in tabs and pin them.
Stars: ✭ 150 (+188.46%)
Mutual labels:  tabs
rc-dock
Dock Layout for React Component
Stars: ✭ 318 (+511.54%)
Mutual labels:  tabs
guitar-tabs-to-MIDI
A program that converts Guitar Tabs into MIDI files.
Stars: ✭ 38 (-26.92%)
Mutual labels:  tabs
ak-vue3
组件库包含了 AutoForm 自动表单、BackTop 返回顶部、Breadcrumb 面包屑、 Button 按钮、Cascader 级联选择器、Checkbox 多选框、Collapse 折叠面板、ColorPicker 颜色选择器、DataPicker 时间选择器、Dialog 弹层对话框、Alert 弹框、Echarts 图形图表、Form 表单、Input 输入框、Lazy 图片延时加载、Loading 加载等待、Menu 菜单、Pagination 分页、Progress 进度条、Radio 单选框、Select 选择器、Steps 步骤条、Swiper 图片轮播、Switch 开关、Table 表格、Tabs 标签页、Textarea 文本框、Tooltip 提示、Tr…
Stars: ✭ 24 (-53.85%)
Mutual labels:  tabs
kakoune-gdb
gdb integration plugin
Stars: ✭ 44 (-15.38%)
Mutual labels:  kakoune
Excited-Gem
An Extension to manage your tabs and other browser-related features.
Stars: ✭ 18 (-65.38%)
Mutual labels:  tabs
embed-client
🎼 Sheet Music & Tabs Embed JavaScript Client
Stars: ✭ 43 (-17.31%)
Mutual labels:  tabs
a11y tab widget
Accessible Tab Widget built with ARIA
Stars: ✭ 25 (-51.92%)
Mutual labels:  tabs
kakoune-snippets
Snippet support for kakoune
Stars: ✭ 35 (-32.69%)
Mutual labels:  kakoune

smarttab.kak

license

smarttab.kak is a plugin for Kakoune editor. It provides three different ways of handling indentation and alignment with tab key.

Installation

With plug.kak (recommended)

Add this to your kakrc:

plug "andreyorst/smarttab.kak"

Source your kakrc or restart Kakoune, and execute :plug-install. Or if you don't want to source configuration file or restart Kakoune, simply run plug-install andreyorst/smarttab.kak. It will be enabled automatically.

Without plugin manager

Clone this repo somewhere

git clone https://github.com/andreyorst/smarttab.kak.git

You can put this repo to your autoload directory, or manually source the smarttab.kak script in your configuration file.

After that you can use smarttab.kak.

Usage

This plugin adds these three commands to toggle different policy when using Tab and > keys:

  • noexpandtab - use tab for everything. Tab will insert \t character, and > will use \t character when indenting. Aligning cursors with & uses \t character.
  • expandtab - use space for everything. Tab will insert %opt{indentwidth} amount of spaces, and > will indent with spaces.
  • smarttab - indent with tab, align with space. Tab will insert \t character if your cursor is inside indentation area, e.g. before any non-whitespace character, and insert spaces if cursor is after any non-whitespace character. Aligning cursors with & uses space.
  • autoconfigtab - choose the above based upon one of the existing settings (see later section).

By default smarttab.kak affects only Tab and > keys. If you want to deindent lines that are being indented with the spaces by hitting Backspace, you can set softtabstop option. This option describes how many spaces should be treated as single tab character when deleting spaces with backspace.

In order to automatically enable different modes for different languages you can use hooks like so:

hook global WinSetOption filetype=c smarttab
hook global WinSetOption filetype=rust expandtab

To adjust smarttab.kak related options you need to use ModuleLoaded hook, because all options are defined withing the smarttab module:

hook global ModuleLoaded smarttab %{
    set-option global softtabstop 4
    # you can configure text that is being used to represent curent active mode
    set-option global smarttab_expandtab_mode_name 'exp'
    set-option global smarttab_noexpandtab_mode_name 'noexp'
    set-option global smarttab_smarttab_mode_name 'smart'
}

If you've used plug.kak for installation, it's better to configure smarttab.kak it within the plug command, because it can handle lazy loading of configurations for the plugin, and configure editor behavior:

plug "andreyorst/smarttab.kak" defer smarttab %{
    # when `backspace' is pressed, 4 spaces are deleted at once
    set-option global softtabstop 4
} config %{
    # these languages will use `expandtab' behavior
    hook global WinSetOption filetype=(rust|markdown|kak|lisp|scheme|sh|perl) expandtab
    # these languages will use `noexpandtab' behavior
    hook global WinSetOption filetype=(makefile|gas) noexpandtab
    # these languages will use `smarttab' behavior
    hook global WinSetOption filetype=(c|cpp) smarttab
}

autoconfigtab configuration

If you just want to set the behavior based upon your editorconfig settings, you can use the autoconfigtab setting:

hook global BufCreate .* %{
    editorconfig-load
    autoconfigtab
}

This config will choose expandtab or noexpandtab based upon the indent_style setting as space or tab respectively.

If you'd prefer to use smarttab instead of noexpandtab for indent_style = tab (without affecting indent_style = space), you can manually override the aligntab option to false before running autoconfigtab, as seen in the below config:

hook global BufCreate .* %{
    editorconfig-load
    set-option buffer aligntab false
    autoconfigtab
}

Currently, autoconfigtab does not cover the case where indentwidth is nonzero but aligntab is set to true, as this would mean indenting with spaces and aligning with tabs. In this particular case, tab alignment takes priority and noexpandtab is chosen.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].