• Stars
    star
    259
  • Rank 156,914 (Top 4 %)
  • Language
    Lua
  • License
    GNU General Publi...
  • Created almost 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

Create key-bindings and watch them with telescope πŸ”­

πŸ”­ telescope-command-palette.nvim

telescope-command-palette.nvim is a neovim plugin written entirely in lua that will help you to access your custom commands/function/key-bindings.

Demo

Demo

Installation

Vim-Plug

Plug "nvim-telescope/telescope.nvim"
Plug "LinArcX/telescope-command-palette.nvim"

Packer

use { "nvim-telescope/telescope.nvim" }
use { "LinArcX/telescope-command-palette.nvim" }

Setup and Configuration

First set up your commands in your Telescope config:

require('telescope').setup({
  extensions = {
    command_palette = {
      {"File",
        { "entire selection (C-a)", ':call feedkeys("GVgg")' },
        { "save current file (C-s)", ':w' },
        { "save all files (C-A-s)", ':wa' },
        { "quit (C-q)", ':qa' },
        { "file browser (C-i)", ":lua require'telescope'.extensions.file_browser.file_browser()", 1 },
        { "search word (A-w)", ":lua require('telescope.builtin').live_grep()", 1 },
        { "git files (A-f)", ":lua require('telescope.builtin').git_files()", 1 },
        { "files (C-f)",     ":lua require('telescope.builtin').find_files()", 1 },
      },
      {"Help",
        { "tips", ":help tips" },
        { "cheatsheet", ":help index" },
        { "tutorial", ":help tutor" },
        { "summary", ":help summary" },
        { "quick reference", ":help quickref" },
        { "search help(F1)", ":lua require('telescope.builtin').help_tags()", 1 },
      },
      {"Vim",
        { "reload vimrc", ":source $MYVIMRC" },
        { 'check health', ":checkhealth" },
        { "jumps (Alt-j)", ":lua require('telescope.builtin').jumplist()" },
        { "commands", ":lua require('telescope.builtin').commands()" },
        { "command history", ":lua require('telescope.builtin').command_history()" },
        { "registers (A-e)", ":lua require('telescope.builtin').registers()" },
        { "colorshceme", ":lua require('telescope.builtin').colorscheme()", 1 },
        { "vim options", ":lua require('telescope.builtin').vim_options()" },
        { "keymaps", ":lua require('telescope.builtin').keymaps()" },
        { "buffers", ":Telescope buffers" },
        { "search history (C-h)", ":lua require('telescope.builtin').search_history()" },
        { "paste mode", ':set paste!' },
        { 'cursor line', ':set cursorline!' },
        { 'cursor column', ':set cursorcolumn!' },
        { "spell checker", ':set spell!' },
        { "relative number", ':set relativenumber!' },
        { "search highlighting (F12)", ':set hlsearch!' },
      }
    }
  }
})

And then load the extension:

require('telescope').load_extension('command_palette')

The idea is that you declare some categories("Help", "Vim", etc..) and inside each category, you define your commands. Each command has three parts:

  • description(mandatory)
  • command(mandatory)
  • insert_mode/normal_mode flag(optional) (indicates that whether you want to be in insert_mode after run the command or not. 1 means: insert mode. everything else is normal mode)

Tip: CpMenu is just a simple table.

Per project configurations

If you're working on different projects and want to have special key_bindings per project, you can create a .nvimrc file in root of your project and append items to CpMenu like this:

table.insert(require('command_palette').CpMenu,
  {"Dap",
    { "pause", ":lua require'dap'.pause()" },
    { "step into", ":lua require'dap'.step_into()" },
    { "step back", ":lua require'dap'.step_back()" },
    { "step over", ":lua require'dap'.step_over()" },
    { "step out", ":lua require'dap'.step_out()" },
    { "frames", ":lua require'telescope'.extensions.dap.frames{}" },
    { "current scopes", ":lua ViewCurrentScopes(); vim.cmd(\"wincmd w|vertical resize 40\")" },
    { "current scopes floating window", ":lua ViewCurrentScopesFloatingWindow()" },
    { "current value floating window", ":lua ViewCurrentValueFloatingWindow()" },
    { "commands", ":lua require'telescope'.extensions.dap.commands{}" },
    { "configurations", ":lua require'telescope'.extensions.dap.configurations{}" },
    { "repl", ":lua require'dap'.repl.open(); vim.cmd(\"wincmd w|resize 12\")" },
    { "close", ":lua require'dap'.close(); require'dap'.repl.close()" },
    { "run to cursor", ":lua require'dap'.run_to_cursor()" },
    { "continue", ":lua require'dap'.continue()" },
    { "clear breakpoints", ":lua require('dap.breakpoints').clear()" },
    { "brakpoints", ":lua require'telescope'.extensions.dap.list_breakpoints{}" },
    { "toggle breakpoint", ":lua require'dap'.toggle_breakpoint()" },
  })

Default mappings (insert mode):

Key Description
c-b go back to categories

Default mappings (normal mode):

Key Description
c-b go back to categories

Usage

:Telescope command_palette.

Contribution

If you have any idea to improve this project, please create a pull-request for it. To make changes consistent, i have some rules:

  1. Before submit your work, please format it with StyLua.

    1. Just go to root of the project and call: stylua .
  2. There should be a one-to-one relation between features and pull requests. Please create separate pull-requests for each feature.

  3. Please use snake_case for function names and local variables

  4. If your PR have more than one commit, please squash them into one.

  5. Use meaningful name for variables and functions. Don't use abbreviations as far as you can.

Roadmap πŸš™

  • βœ”οΈ use modules and setup function. (Thanks to: mrjones2014)
  • let users chose the separator icon.
  • make categories per os/distro.
  • allow users to define keybindings for items in categories/commands.
  • remember the selected item in come back to categories.
  • show frequently commands based on frecency algorithm.
  • add options to make telescope-command-palette.nvim more like vscode command-palatte. (like: @, ...)

More Repositories

1

kindd

A kindful dd, written in qt-quick.
QML
121
star
2

telescope-env.nvim

watch environment variables with telescope πŸ”­
Lua
72
star
3

wmenu

A dmenu clone for windows operating system written with pure win32 API.
C++
55
star
4

giti

Permanent observer of your git directories
Vala
53
star
5

mpi

minimal (n)vim plugins - icons (Under 200 LOC)
Vim Script
34
star
6

soha

A modern calendar written in qt-quick.
QML
27
star
7

mpbtl

minimal (n)vim plugins - buffer tabline(Under 200 LOC)
Vim Script
17
star
8

mpsl

minimal (n)vim plugins - status line(Under 200 LOC)
Vim Script
15
star
9

TvDoon

Show Information About Tv Show's, Ratings And So Many Cool Fatures!
Python
14
star
10

nixbox

Nixos operations in the box!
Shell
14
star
11

telescope-ports.nvim

Watch open ports on your system with telescope
Lua
13
star
12

winconf

Tips & Tricks to make windows less bloated and more productive :)
Vim Script
11
star
13

Gnulium

A Graphical Ui for managing scripts and ideas!
QML
9
star
14

telescope-scriptnames.nvim

Telescope extension wrapper around `:scriptnames`
Lua
9
star
15

telescope-changes.nvim

About Telescope extension wrapper around `:changes`
Lua
7
star
16

pardis

My attempt to learn how to write an operating system from scratch
C++
7
star
17

captain-ballard

Watches your git directories periodically and reports the latest changes
C
7
star
18

wingpanel-indicator-calendar

Wingpanel Calendar Indicator
Vala
3
star
19

memento

A personal approach to controlling rogue time
2
star
20

AsemanOs

Source Code of Aseman Os - https://asemanos.gitlab.io/
Python
2
star
21

BarCodeReader

encode and decode every BarCode you Want!
Java
2
star
22

iproc

A cross-platform utility (linux, windows for now) that help you gather information (cpu_usage, memory_usage, ...) from a particular process.
C
2
star
23

neodm

Simple and lightweight download manager written in c++/ncurses.
C++
2
star
24

badreads

Good guys use badreads!
C
1
star
25

mpg123.yazi

play audio files in yazi
Lua
1
star
26

trinity

Multi Purpose Code Generator.
QML
1
star
27

QGL

OpenGl Components for Qt/Quick applicatoins.
C++
1
star
28

SmartLabel

A Composit Smart View
Java
1
star
29

ogllearning

Learning OpneGL with GLFW+GLAD / SDL+GLEW
C++
1
star
30

nfm

Neo file manager written by PDCurses library for windows.
C
1
star
31

wingpanel-indicator-disk-usage

Wingpanel Disk-Usage Indicator
Vala
1
star
32

mdv

markdown viewer written in c
C
1
star
33

scrum-sprint.nvim

Lua
1
star