Giter Site home page Giter Site logo

tabs.kak's Introduction

tabs.kak

View open buffers in status line, like tabs, and navigate between them quickly.

Demo

asciicast

Keybindings

The recommended key bindings can be set by calling tabs-recommended-keys:

define-command tabs-recommended-keys -docstring "set the recommended kak-tabs bindings" %{
  map global normal q b
  map global normal Q B
  map global normal b ': enter-user-mode tabs<ret>' -docstring 'tabs'
  map global normal B ': enter-user-mode -lock tabs<ret>' -docstring 'tabs (lock)'
}

Within the tabs mode, the keybindings are as follows:

a: ↔ (alternate)      return to the previously focused buffer
h: ← (previous)       navigate to the buffer on the left
l: → (next)           navigate to the buffer on the right
s:   (*scratch*)      open the *scratch* buffer
u:   (*debug*)        open the *debug* buffer
H: ← (drag left)      swap this buffer to the left
L: → (drag right)     swap this buffer to the right
d:   (delete current) delete the current buffer

Configuration

Example Configuration

set-option global tabs_modelinefmt '%val{cursor_line}:%val{cursor_char_column} {{mode_info}} '
set-option global tabs_options --minified

Options

  • tabs_modelinefmt: when set to a modelinefmt string, it is placed in the space preceding the tabs

  • tabs_options: a list of switches that affect tabs' appearance.

    • --minified
      • this will cause tabs to show as little of their paths as possible while still being unique. For example, if the currently open buffers are
        projects/1/src/main.rs projects/2/src/main.rs projects/2/Cargo.toml
        
        then the rendered tabs will be
        | 1/src/main.rs | 2/src/main.rs | Cargo.toml |
        
        because these are the smallest unique suffixes of each buffer.

Installation

  1. Install the rc/tabs.kak so your kakoune instance auto-loads it.
  2. Install the kak-tabs rust crate.

TODO

  • the order of tabs changes how the disambiguation of files with the same names work. for example:
    • we have a buflist that looks like:
      • | *debug* | xml.rs | pypi/mirror/mod.rs | cargo/mirror/mod.rs | mod.rs |
    • swapping the last two buffers yields the following tabs:
      • | *debug* | xml.rs | mirror/mod.rs | api/mod.rs | mod.rs |
  • tabs should shrink when there's not enough space
  • add more buffer deletion options, see: #3

Originally inspired by Delapouite's kakoune-buffers.

Warning This plugin is incompatible with powerline.kak, see here for why.

tabs.kak's People

Contributors

enricozb avatar mralusw avatar postsolar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tabs.kak's Issues

No tabs bar

Hi!
I'm trying out tabs.kak becaouse it looks promising.
However, I don't see a tab bar.

kakrc

# Plugins

# source custom plugins
source "~/git/pandoc.kak/rc/pandoc.kak"

# source plug.kak script
source "%val{config}/plugins/plug.kak/rc/plug.kak"

# call plug.kak with `plug' command
plug "robertmeta/plug.kak" noload config %{
    # configure plug.kak here
}        
plug "ul/kak-lsp" do %{
    cargo build --release --locked
    cargo install --force --path .
} config %{

    # uncomment to enable debugging
    # eval %sh{echo ${kak_opt_lsp_cmd} >> /tmp/kak-lsp.log}
    # set global lsp_cmd "kak-lsp -s %val{session} -vvv --log /tmp/kak-lsp.log"

    # this is not necessary; the `lsp-enable-window` will take care of it
    # eval %sh{${kak_opt_lsp_cmd} --kakoune -s $kak_session}

    set global lsp_diagnostic_line_error_sign '║'
    set global lsp_diagnostic_line_warning_sign '┊'

    define-command ne -docstring 'go to next error/warning from lsp' %{ lsp-find-error --include-warnings }
    define-command pe -docstring 'go to previous error/warning from lsp' %{ lsp-find-error --previous --include-warnings }
    define-command ee -docstring 'go to current error/warning from lsp' %{ lsp-find-error --include-warnings; lsp-find-error --previous --include-warnings }

    define-command lsp-restart -docstring 'restart lsp server' %{ lsp-stop; lsp-start }
    hook global WinSetOption filetype=(c|cpp|cc|rust|javascript|typescript) %{
        set-option window lsp_auto_highlight_references true
        set-option window lsp_hover_anchor false
        lsp-auto-hover-enable
        echo -debug "Enabling LSP for filtetype %opt{filetype}"
        lsp-enable-window
    }

    hook global WinSetOption filetype=(rust) %{
        set window lsp_server_configuration rust.clippy_preference="on"
    }

    hook global WinSetOption filetype=rust %{
        hook window BufWritePre .* %{
            evaluate-commands %sh{
                test -f rustfmt.toml && printf lsp-formatting-sync
            }
        }
    }

    hook global KakEnd .* lsp-exit
}

# plug 'delapouite/kakoune-buffers' %{
#     # Suggested hook

#     hook global WinDisplay .* info-buffers

#     # Suggested mappings

#     map global user b ':enter-buffers-mode<ret>'              -docstring 'buffers…'
#     map global user B ':enter-user-mode -lock buffers<ret>'   -docstring 'buffers (lock)…'

#     # Suggested aliases

#     alias global bd delete-buffer
#     alias global bf buffer-first
#     alias global bl buffer-last
#     alias global bo buffer-only
#     alias global bo! buffer-only-force
# }
plug "enricozb/tabs.kak" %{
  set-option global modelinefmt_tabs '%val{cursor_line}:%val{cursor_char_column} {{context_info}} {{mode_info}}'
  map global user b ': enter-user-mode tabs<ret>' -docstring 'tabs'
  map global user B ': enter-user-mode -lock tabs<ret>' -docstring 'tabs (lock)'
}
# plug "jdugan6240/powerline.kak" defer powerline %{
#     # set-option global powerline_format 'git bufname filetype mode_info line_column position'
#     # powerline-toggle line_column off
#     powerline-separator triangle
#     powerline-theme gruvbox
# } config %{
#     powerline-start
# }
plug "caksoylar/kakoune-smooth-scroll" config %{
     hook global WinCreate .* %{ hook -once window WinDisplay .* smooth-scroll-enable }
}
plug "alexherbo2/prelude.kak"
plug "alexherbo2/connect.kak" %{
    require-module connect
    require-module connect-nnn
}
plug 'alexherbo2/palette.kak'
plug 'occivink/kakoune-sudo-write '
plug 'evanrelf/number-toggle.kak' %{
    set-option global number_toggle_params -hlcursor
}
plug 'alexherbo2/surround.kak' %{
    require-module surround
    ## Quoting
    map -docstring 'Surround' global normal q ': enter-user-mode surround<ret>'
    map -docstring 'Surround insert' global normal Q ': surround-enter-insert-mode<ret>'

    ## Move macros to ^
    map -docstring 'Play macro' global normal ^ q
    map -docstring 'Record macro' global normal <a-^> Q
}
plug 'alexherbo2/auto-pairs.kak' %{
    require-module auto-pairs
    hook global WinCreate .* %{ auto-pairs-enable }
}
plug 'laelath/kakoune-show-matching-insert'
plug 'alexherbo2/snippets.kak'

plug "jbomanson/search-doc.kak" config %{
        require-module search-doc
}

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=.* 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|java) smarttab
}
plug "andreyorst/fzf.kak"

# Key Mappings

## quick safe

map global user w -docstring 'safe file' ':w<ret>'

## edit kakrc
map global user <,> -docstring 'edit kakrc' ':e "%val{config}/kakrc"<ret>'
map global user <a-,> -docstring 'source kakrc' ':source "%val{config}/kakrc"<ret>'

map global user <a-<> -docstring 'source current buffer' ':source "%val{buffile}<ret>'

## jj to escape
hook global InsertChar j %{ try %{
  exec -draft hH <a-k>jj<ret> d
  exec <esc>
}}

## commenting

map global user c -docstring '(un-)comment line' ':comment-line<ret>'
map global user C -docstring '(un-)comment block' ':comment-block<ret>'

## Mac Clipboard
hook global NormalKey y|d|c %{ nop %sh{
      printf %s "$kak_main_reg_dquote" | pbcopy
}}
map global user P -docstring 'Paste above' '!pbpaste<ret>'
map global user p -docstring 'Paste below' '<a-!>pbpaste<ret>'
map global user R -docstring 'Replace' '|pbpaste<ret>'

# general Configuration

##verbose autoinfo
set-option -add global autoinfo normal

## case insensitive search by default
map global normal / "/(?i)"

# Pandoc
set-option global pandoc_options "-d default"
 
# Appearance

colorscheme gruvbox

add-highlighter global/ number-lines -relative -hlcursor
add-highlighter global/ show-whitespaces

add-highlighter global/ line '%val{cursor_line}' default,rgb:3c3735
add-highlighter global/ column 81 default,red
add-highlighter global/ wrap -indent -word -marker ' … '

Handle weird ClientCreate WinDisplay behavior

In the client-scope branch, we have client-specific buflists.

As of kakoune v2024.05.18, the behavior of ClientCreate and WinDisplay is a strange.

When a client is created (eg kak Y) the order of the ClientCreate and WinDisplay hooks seems to vary between two possible orders. The first is:

  • WinDisplay [random buffer X]
  • ClientCreate [random buffer X]
  • WinDisplay [correct buffer Y]

The second is:

  • WinDisplay [correct buffer Y]
  • ClientCreate [correct buffer Y]

I couldn't find any register or value that could be read to distinguish between these two scenarios, so kakoune clients should be started with -e 'tabs only', which will run after both of these possible hook firings.

tab bar does not scroll horizontally

When there are more buffers open than can fit into the bar, the ellipsis just stays at the beginning, and does not attempt to move so that you can see the current buffer highlighted. It should probably instead move which section of the bar is hidden with ellipses, so that when you are looking at a buffer near the beginning of the list, the ellipses are shown at the end, and if you are in the middle of a long list, ellipses should be shown at both left and right ends.

NormalIdle hook

Is the NormalIdle hook actually necessary? I've removed it, and it doesn't seem to make tabs.kak any worse (or better — I see issues with *buffers*). If the WinDisplay hook is sufficient, I'd like to remove the idle call in my #5 PR

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.