• Stars
    star
    537
  • Rank 80,549 (Top 2 %)
  • Language
    Lua
  • License
    MIT License
  • Created over 2 years ago
  • Updated 12 months ago

Reviews

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

Repository Details

Pop-up menu for code actions to show meta-information and diff preview

NeoVim Code Action Menu

NOTE: This is still a beta version. Though it runs quite stable since some months, it has not been tested with many language servers. Moreover there is a good amount of documentation missing.

gscreenshot_2021-09-28-094359

This plugin provides a handy pop-up menu for code actions. Its key competence is to provide the user with more detailed insights for each available code action. Such include meta data as well as a preview diff for certain types of actions. These includes:

  • descriptive title (usually shown by all code action "menu" solutions)
  • kind of the action (e.g. refactor, command, quickfix, organize imports, ...)
  • name of the action
  • if the action is the preferred one according to the server (preferred actions get automatically sorted to the top of the menu)
  • if the action is disabled (disabled actions can be used and get automatically sorted to the bottom of the menu with a special hightlight)
  • a preview of the changes this action will do in a diff view for all affected files (includes a diff count box visualization as GitHub pul requests do)
  • ...more will come, especially when servers start to use the dataSupport capability for the code action provider

The experience for all these features might vary according to the implementation of the used language server. Especially for the diff view, do some servers still use the old code action data scheme from older Language Server Protocol versions which include less information for the clients. However this plugin tries to inspect those actions more deeply and try to parse as much information as possible.

This plugin is just a menu for code actions. Nothing more and nothing less. It is a minimal plugin that focuses on one single task. It tries to be a contrast to other plugins which also provide a code action menu but being more advanced a do not provide any other functionality.

Installation

Install the plugin with your favorite manager tool. Here is an example using packer.nvim:

require('packer').use({
  'weilbith/nvim-code-action-menu',
  cmd = 'CodeActionMenu',
})

It is recommended to use the nvim-lspconfig plugin to attach language clients to your buffers.

Furthermore is quite handy to also use the nvim-lightbulb plugin. It will automatically inform the user visually if any code actions are available for the current cursor location.

Please note that LSP and other features for this plugin require you to have at least v0.5.0 of NeoVim.

Usage

The plugin has a single command only: CodeActionMenu This command works in normal mode, as well as visual mode. For the latter mode it will switch to the code range mode automatically. The menu can be navigated as usual with j and k. The docked windows will always display further information for the currently selected action. Hitting <CR> will execute the currently selected code action. Alternatively you can type the number in front of the list entry to jump directly to this action and apply it right away. In any case the menu window will close itself. If you want to manually close the window without selecting an action, just hit <Esc> or q.

This plugin only supports nvim_lsp, if you are using coc.nvim, you can install coc-code-action-menu.nvim to add support for coc.nvim.

Customization

The plugin allows for a bunch of customization. While there is no classic configuration (yet) it can be adapted by using traditional (Neo)Vim techniques. Each part of the menu uses its own filetype. This gets used to separate the logic implementation in Lua from other parts like highlighting, buffer options and mappings. As beautiful side effect is that the user can do so too. This means you can just define some after/{ftplugin,syntax}/code-action-menu-{menu,details,diff,warning}.{vim,lua} files yourself and get the full power of customization.

At the current state of documentation I must redirect you to the syntax files in the source code of the plugin to get a list of available highlight groups. The user can simply overwrite any of the default mappings to his liking.

Window Appearance

The following global variables can be set to alternate the appearance of the windows:

vim.g.code_action_menu_window_border = 'single'
let g:code_action_menu_window_border = 'single'

Disable parts of the UI

The following global variables can be set to disable parts of the user interface:

vim.g.code_action_menu_show_details = false
vim.g.code_action_menu_show_diff = false
vim.g.code_action_menu_show_action_kind = false
let g:code_action_menu_show_details = v:false
let g:code_action_menu_show_diff = v:false
let g:code_action_menu_show_action_kind = v:false

More Repositories

1

nvim-lsp-smag

Seamless integration of language server locations into NeoVim
Lua
77
star
2

nvim-floating-tag-preview

Preview tags in a floating window
Lua
24
star
3

nvim-lsp-bacomp

A NeoVim plugin for using language server capabilites with backward compatibility in mind
Lua
14
star
4

nerdtree_choosewin-plugin

NERDTree extension which let you choose the window to open the new file.
Vim Script
14
star
5

dotfiles

My private dotfiles to configure different applications. Used as backup, distribution and exchange.
Shell
12
star
6

nvim-lsp-diamove

Navigation for LSP diagnostics in NeoVim
Lua
11
star
7

vim-blueplanet

My very personal and awesome Vim scripts and configuration.
Lua
9
star
8

nvim-lsp-denite

Aditional denite.nvim sources by the Language Server Protocol
Python
8
star
9

vue-device-detector

A Vue plugin that add global functionality to check the device type, the client is displayed on.
JavaScript
7
star
10

vim-localrc

Local runtime configuration for Vim the better way. Safe, convinient, but simple.
Vim Script
4
star
11

notmuch-python-bindings

Python binding of the notmuch mail search and indexing library.
Python
4
star
12

vim-quickname

Vim plugin to name your quickfix lists and make them easily recoverable
Vim Script
3
star
13

keyboard_firmware

C
3
star
14

notmuch2-python-bindings

Pythonic bindings for the notmuch mail database using CFFI.
Python
3
star
15

vim-qfloc-moves

Vim plugin to move around quickfix and location windows
Vim Script
3
star
16

vim-loche

Vim plugin to tie location list to buffers not windows
Vim Script
2
star
17

AUR

A collection of custom PKGBUILD files to build packages for ArchLinux
Shell
2
star
18

vim-qfloc-edit

Editing quickfix and location lists
Vim Script
2
star
19

vim-qfloc-tailor

Vim plugin to automatically adjust your quickfix and location list windows size and position
Vim Script
2
star
20

scripts

My private scripts for i3, device control and more...
Shell
1
star