• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    Lua
  • License
    MIT License
  • Created about 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This plugins prompts the user to pick a window and returns the window id of the picked window

nvim-window-picker

hint = 'floating-big-letter'

window-picker-float-demo.mp4

hint = 'statusline-winbar'

window-picker-winbar-demo.mp4

This plugins prompts the user to pick a window and returns the window id of the picked window.

Install

lazy

{
    's1n7ax/nvim-window-picker',
    name = 'window-picker',
    event = 'VeryLazy',
    version = '2.*',
    config = function()
        require'window-picker'.setup()
    end,
}

packer

use {
    's1n7ax/nvim-window-picker',
    tag = 'v2.*',
    config = function()
        require'window-picker'.setup()
    end,
}

How to use

local picked_window_id = require('window-picker').pick_window()

You can put the picked window id to good use

Configuration

If you want to have custom properties just for one time, you can pass any of following directly to pick_window() function itself to override the default behaviour.

require 'window-picker'.setup({
    -- type of hints you want to get
    -- following types are supported
    -- 'statusline-winbar' | 'floating-big-letter'
    -- 'statusline-winbar' draw on 'statusline' if possible, if not 'winbar' will be
    -- 'floating-big-letter' draw big letter on a floating window
    -- used
    hint = 'statusline-winbar',

    -- when you go to window selection mode, status bar will show one of
    -- following letters on them so you can use that letter to select the window
    selection_chars = 'FJDKSLA;CMRUEIWOQP',

    -- This section contains picker specific configurations
    picker_config = {
        statusline_winbar_picker = {
            -- You can change the display string in status bar.
            -- It supports '%' printf style. Such as `return char .. ': %f'` to display
            -- buffer file path. See :h 'stl' for details.
            selection_display = function(char, windowid)
                return '%=' .. char .. '%='
            end,

            -- whether you want to use winbar instead of the statusline
            -- "always" means to always use winbar,
            -- "never" means to never use winbar
            -- "smart" means to use winbar if cmdheight=0 and statusline if cmdheight > 0
            use_winbar = 'never', -- "always" | "never" | "smart"
        },

        floating_big_letter = {
            -- window picker plugin provides bunch of big letter fonts
            -- fonts will be lazy loaded as they are being requested
            -- additionally, user can pass in a table of fonts in to font
            -- property to use instead

            font = 'ansi-shadow', -- ansi-shadow |
        },
    },

    -- whether to show 'Pick window:' prompt
    show_prompt = true,

    -- prompt message to show to get the user input
    prompt_message = 'Pick window: ',

    -- if you want to manually filter out the windows, pass in a function that
    -- takes two parameters. You should return window ids that should be
    -- included in the selection
    -- EX:-
    -- function(window_ids, filters)
    --    -- folder the window_ids
    --    -- return only the ones you want to include
    --    return {1000, 1001}
    -- end
    filter_func = nil,

    -- following filters are only applied when you are using the default filter
    -- defined by this plugin. If you pass in a function to "filter_func"
    -- property, you are on your own
    filter_rules = {
        -- when there is only one window available to pick from, use that window
        -- without prompting the user to select
        autoselect_one = true,

        -- whether you want to include the window you are currently on to window
        -- selection or not
        include_current_win = false,

        -- filter using buffer options
        bo = {
            -- if the file type is one of following, the window will be ignored
            filetype = { 'NvimTree', 'neo-tree', 'notify' },

            -- if the file type is one of following, the window will be ignored
            buftype = { 'terminal' },
        },

        -- filter using window options
        wo = {},

        -- if the file path contains one of following names, the window
        -- will be ignored
        file_path_contains = {},

        -- if the file name contains one of following names, the window will be
        -- ignored
        file_name_contains = {},
    },

    -- You can pass in the highlight name or a table of content to set as
    -- highlight
    highlights = {
        statusline = {
            focused = {
                fg = '#ededed',
                bg = '#e35e4f',
                bold = true,
            },
            unfocused = {
                fg = '#ededed',
                bg = '#44cc41',
                bold = true,
            },
        },
        winbar = {
            focused = {
                fg = '#ededed',
                bg = '#e35e4f',
                bold = true,
            },
            unfocused = {
                fg = '#ededed',
                bg = '#44cc41',
                bold = true,
            },
        },
    },
})
require('window-picker').pick_window({
    hint = 'floating-big-letter'
})

Theming

If you just want to define the colors using Neovim Highlights, then it's totally possible. You can set following highlights manually.

  • WindowPickerStatusLine (currently focused window statusline highlights)
  • WindowPickerStatusLineNC (currently unfocused window statusline highlights)
  • WindowPickerWinBar (currently focused window winbar highlights)
  • WindowPickerWinBarNC (currently unfocused window winbar highlights)

Breaking changes in v2.0.0

Before: return value from selection_display will be wrapped by '%=' and '%=' to fill the empty space of status line or winbar.

After: return value of selection_display will be passed directly to the status line or winbar. This allows all the customizations available from statusline syntax. You can check :help statusline for more info.

More Repositories

1

dotnvim

Neovim Lua configuration pre-configured for Java, JavaScript, Typescript etc...
Lua
113
star
2

nvim-terminal

A Lua-Neovim plugin that toggles a terminal
Lua
105
star
3

nvim-comment-frame

Detects the language using treesitter and adds a comment block
Lua
91
star
4

nvim-react

Reactive UI framework for neovim
Lua
47
star
5

nvim-search-and-replace

Really simple plugin to search and replace multiple files
Lua
42
star
6

neovim-lua-plugin-boilerplate

Starter template for creating Neovim Lua plugins
Lua
31
star
7

keyboard-layout-analyzer

Calculates the number of finger movements required to type something using different keyboard layouts.
Rust
19
star
8

keyboard-layout-status

Calculates the number of finger movements required to type something using different keyboard layouts.
Python
14
star
9

dotvim

Vim (vimscript) configuration for React JS, Typescript and many other languages
12
star
10

dwm-status

simple and flexible dwm status bar application
Python
11
star
11

youtube-neovim-treesitter-query

Presentation related to my Youtube tutorial
Lua
10
star
12

nvim-snips

My custom luasnip snippets mainly targeting my development work
Lua
6
star
13

nvim-ts-utils

Some useful tree-sitter utils I don't want keep inside my neovim configuration
Lua
6
star
14

youtube-java-debugging

Absolute minimal configuration for Neovim that is just enough to debug Java application
Lua
6
star
15

open-unicode-converter

open unicode converter implementation
JavaScript
6
star
16

youtube-treesitter

4
star
17

st

simple terminal with some of my favorite patches
C
3
star
18

projectdot-ide

TypeScript
3
star
19

book-designing-object-oriented-software

Just maintaining a summary + important stuff of the "Book Designing Object-Oriented Software" by Rebecca Wirfs-Brock
2
star
20

cypress-commons

Reusable components, commands & more to make your day easier
JavaScript
2
star
21

nvim-lazy-inner-block

Remap inner block operations without letter i
Lua
2
star
22

dwm

dwm with some of my favorite patches
C
1
star
23

my-website

my website written in web assembly
Rust
1
star
24

facebook-manager

Predefined UI automation to manager private Facebook profile
TypeScript
1
star
25

linux-common

1
star
26

nvim-actions

Text manipulate but faster
Lua
1
star
27

nix-shell-tensorflow-with-cuda

nix-shell created for using tensorflow-with-cuda
Nix
1
star
28

demo-dotnvim

Don't use this!!! This is a Neovim config with few plugins, keymaps, options for my Youtube tutorials.
Lua
1
star
29

lazyvim-dotnvim

Lua
1
star
30

dothome

Python
1
star
31

silenium

Java
1
star
32

nvim-treesitter-format

Formats files using treesitter syntax tree
Lua
1
star
33

youtube-generate-java-doc-comment-using-treesitter

This repository is related to two YouTube videos I have done
Lua
1
star
34

nvim-session

simple wrapper around mksession to auto save and load the session
Lua
1
star
35

nvim-settings

Persistent store for settings
Lua
1
star
36

simple-message-router

Router (https://www.npmjs.com/package/router) that has nothing to do with http
JavaScript
1
star
37

git-cheat-sheet

1
star
38

dmenu

dmenu with my favorite patches
C
1
star
39

pytorch-basics

Jupyter Notebook
1
star
40

http-client-testing-server

simple server designed to test http clients
JavaScript
1
star
41

yolov4-training-google-colab-workflow

Google colab notebook script to build the colab environment and start training in one click
Jupyter Notebook
1
star