Giter VIP home page Giter VIP logo

nvim-lsputils's Introduction

nvim-lsputils

Neovim built-in LSP client implementation is so lightweight and awesome. However, default settings for actions like go-to-definition, code-quickfix, etc may not seem user friendly for many users. But neovim LSP client is highly extensible with lua. This plugin focuses on making such LSP actions highly user friendly.

Features

  • Floating popup for code actions
  • Preview window for references
  • Preview window for definition, declaration, type-definition, implementation
  • Preview window for document symbol and workspace symbol
  • Fuzzy finding of symbols, references, defintion and codeActions [optional]
  • , , opens tabs, vertical split and horizontal split for location and symbol actions

Demo

Code Action:

References:

Custom theming (See below for more details)

Fuzzy search:

Future goals

  • LspSearch command to search symbol over workspace and list it in a window.

Fuzzy finding feature is optional for the time being. This is because fuzzy engine of popfix is still in developement. However, it usually doesn't crash and work as expected. For using it read custom options section. For the code snippet read sample theming section.

Prerequisite

  • Neovim nightly

Installation

This plugin utilizes RishabhRD/popfix plugin for managing underlying popups and previews. It can be installed with any plugin manager. For example with vim-plug:

Plug 'RishabhRD/popfix'
Plug 'RishabhRD/nvim-lsputils'

Setup

Add following to init.vim lua chunk as:

lua <<EOF
if vim.fn.has('nvim-0.5.1') == 1 then
    vim.lsp.handlers['textDocument/codeAction'] = require'lsputil.codeAction'.code_action_handler
    vim.lsp.handlers['textDocument/references'] = require'lsputil.locations'.references_handler
    vim.lsp.handlers['textDocument/definition'] = require'lsputil.locations'.definition_handler
    vim.lsp.handlers['textDocument/declaration'] = require'lsputil.locations'.declaration_handler
    vim.lsp.handlers['textDocument/typeDefinition'] = require'lsputil.locations'.typeDefinition_handler
    vim.lsp.handlers['textDocument/implementation'] = require'lsputil.locations'.implementation_handler
    vim.lsp.handlers['textDocument/documentSymbol'] = require'lsputil.symbols'.document_handler
    vim.lsp.handlers['workspace/symbol'] = require'lsputil.symbols'.workspace_handler
else
    local bufnr = vim.api.nvim_buf_get_number(0)

    vim.lsp.handlers['textDocument/codeAction'] = function(_, _, actions)
        require('lsputil.codeAction').code_action_handler(nil, actions, nil, nil, nil)
    end

    vim.lsp.handlers['textDocument/references'] = function(_, _, result)
        require('lsputil.locations').references_handler(nil, result, { bufnr = bufnr }, nil)
    end

    vim.lsp.handlers['textDocument/definition'] = function(_, method, result)
        require('lsputil.locations').definition_handler(nil, result, { bufnr = bufnr, method = method }, nil)
    end

    vim.lsp.handlers['textDocument/declaration'] = function(_, method, result)
        require('lsputil.locations').declaration_handler(nil, result, { bufnr = bufnr, method = method }, nil)
    end

    vim.lsp.handlers['textDocument/typeDefinition'] = function(_, method, result)
        require('lsputil.locations').typeDefinition_handler(nil, result, { bufnr = bufnr, method = method }, nil)
    end

    vim.lsp.handlers['textDocument/implementation'] = function(_, method, result)
        require('lsputil.locations').implementation_handler(nil, result, { bufnr = bufnr, method = method }, nil)
    end

    vim.lsp.handlers['textDocument/documentSymbol'] = function(_, _, result, _, bufn)
        require('lsputil.symbols').document_handler(nil, result, { bufnr = bufn }, nil)
    end

    vim.lsp.handlers['textDocument/symbol'] = function(_, _, result, _, bufn)
        require('lsputil.symbols').workspace_handler(nil, result, { bufnr = bufn }, nil)
    end
end
EOF

Default keymaps

For codeaction

In normal mode:

Key Action
<CR> Applies the codeaction
<Esc> Quits the menu without applying codeaction
q Quits the menu without applying codeaction
j Selects next item
k Selects previous item
<Down> Selects next item
<Up> Selects previous item

In insert mode(Fuzzy search mode):

Key Action
<CR> Applies the codeaction
<C-c> Quits the menu without applying codeaction
<C-n> Selects next item
<C-p> Selects previous item
<Down> Selects next item
<Up> Selects previous item

For symbols, references, and defintions

(document symbols + workspace symbols + references + defintions)

In normal mode:

Key Action
<CR> Jump to location in same window
<C-v> Jump to location in a vertical split
<C-x> Jump to location in a horizontal split
<C-t> Jump to location in a new tab
<Esc> Quits the menu without jumping to location
q Quits the menu without jumping to location
j Selects next item
k Selects previous item
<Down> Selects next item
<Up> Selects previous item

In insert mode(Fuzzy search mode):

Key Action
<CR> Jump to location in same window
<C-v> Jump to location in a vertical split
<C-x> Jump to location in a horizontal split
<C-t> Jump to location in a new tab
<C-c> Quits the menu without jumping to location
<C-n> Selects next item
<C-p> Selects previous item
<Down> Selects next item
<Up> Selects previous item

Custom Filetypes

nvim-lsputils export some custom filetypes for their created buffer. This enables users to do customization for nvim-lsputil buffers.

Custom filetypes are:

  • For codeaction:

    • lsputil_codeaction_list (Represents codeaction list)
    • lsputil_codeaction_prompt (Represents codeaction prompt) (If enabled)
  • For symbols (workspace and document symbols):

    • lsputil_symbols_list (Represents symbols list)
    • lsputil_symbols_preview (Represents symbols preview)
    • lsputil_symbols_prompt (Represents symbols prompt)
  • For locations (definition, declaration, references, implementation):

    • lsputil_locations_list (Represents locations list)
    • lsputil_locations_preview (Represents locations preview)
    • lsputil_locations_prompt (Represents locations prompt)

Custom Options

NOTE: EACH attribute of custom opts is optional. If not provided, a suitable default is used in place of it.

nvim-lsputils provides 3 global variables:

  • lsp_utils_location_opts
  • lsp_utils_symbols_opts
  • lsp_utils_codeaction_opts

These 3 variables are supposed to have vimscript dictionary values (Lua tables)

lsp_utils_location_opts defines options for:

  • definition handler
  • references handler
  • declaration handler
  • implementation handler
  • type_definition hander

lsp_utils_symbols_opts defines options for:

  • workspace symbol handler
  • files symbols handler

lsp_utils_codeaction_opts defines options for:

  • code_action handler

lsp_utils_location_opts and lsp_utils_symbols_opts takes following key-value pairs:

  • height (integer) (Defines height of window) if value is 0 then a suitable default height is provided. (Specially for editor mode)
  • width (integer) (Defines width of window)
  • mode (string)
    • split (for split previews (default))
    • editor (for floating previews)
  • list (vimscript dictionary / Lua tables) Accepts following key/value pairs:
    • border (boolean) (borders in floating mode)
    • numbering (boolean) (vim window numbering active or not)
    • title (boolean) (title for window)
    • border_chars (vimscript dictionary/ Lua table) (border characters for list) Sample border_chars example:
       border_chars = {
       	TOP_LEFT = '┌',
       	TOP_RIGHT = '┐',
       	MID_HORIZONTAL = '─',
       	MID_VERTICAL = '│',
       	BOTTOM_LEFT = '└',
       	BOTTOM_RIGHT = '┘',
       }
      
      If any of shown key of border_chars is missing then a space character is used instead of it.
  • preview (vimscript dictionary / Lua tables) Accepts following key/value pairs:
    • border (boolean) (borders in floating mode)
    • numbering (boolean) (vim window numbering active or not)
    • title (string) (title for window)
    • border_chars (vimscript dictionary/ Lua table) (border characters for preview window) Sample border_chars example:
       border_chars = {
       	TOP_LEFT = '┌',
       	TOP_RIGHT = '┐',
       	MID_HORIZONTAL = '─',
       	MID_VERTICAL = '│',
       	BOTTOM_LEFT = '└',
       	BOTTOM_RIGHT = '┘',
       }
       If any of shown key of border_chars is missing then a space character
       is used instead of it.
      
  • keymaps (vimscript dictionary / Lua tables) Additional keymaps. See https://github.com/RishabhRD/popfix to read about keymaps documentation.

lsp_utils_codeaction_opts takes following key-value pairs:

  • height (integer) (Defines height of window) if value is 0 then a suitable default height is provided. (Specially for editor mode)
  • width (integer) (Defines width of window)
  • mode (string)
    • split (for split previews (default))
    • editor (for floating previews)
  • list (vimscript dictionary / Lua tables) Accepts following key/value pairs:
    • border (boolean) (borders in floating mode)
    • numbering (boolean) (vim window numbering active or not)
    • title (string) (title for window)
    • border_chars (vimscript dictionary/ Lua table) (border characters for list) Sample border_chars example:
       border_chars = {
       	TOP_LEFT = '┌',
       	TOP_RIGHT = '┐',
       	MID_HORIZONTAL = '─',
       	MID_VERTICAL = '│',
       	BOTTOM_LEFT = '└',
       	BOTTOM_RIGHT = '┘',
       }
      
      If any of shown key of border_chars is missing then a space character is used instead of it.
  • prompt (table) (optional and may break)
    • border (boolean) (borders in floating mode)
    • numbering (boolean) (vim window numbering active or not)
    • border_chars (vimscript dictionary/ Lua table) (border characters for list) Sample border_chars example:
       border_chars = {
       	TOP_LEFT = '┌',
       	TOP_RIGHT = '┐',
       	MID_HORIZONTAL = '─',
       	MID_VERTICAL = '│',
       	BOTTOM_LEFT = '└',
       	BOTTOM_RIGHT = '┘',
       }
      
      If any of shown key of border_chars is missing then a space character is used instead of it.

See https://github.com/RishabhRD/popfix for more documentation of options.

These options helps to get better theme that suits your need.

Sample themeing with lua

local border_chars = {
	TOP_LEFT = '┌',
	TOP_RIGHT = '┐',
	MID_HORIZONTAL = '─',
	MID_VERTICAL = '│',
	BOTTOM_LEFT = '└',
	BOTTOM_RIGHT = '┘',
}
vim.g.lsp_utils_location_opts = {
	height = 24,
	mode = 'editor',
	preview = {
		title = 'Location Preview',
		border = true,
		border_chars = border_chars
	},
	keymaps = {
		n = {
			['<C-n>'] = 'j',
			['<C-p>'] = 'k',
		}
	}
}
vim.g.lsp_utils_symbols_opts = {
	height = 24,
	mode = 'editor',
	preview = {
		title = 'Symbols Preview',
		border = true,
		border_chars = border_chars
	},
	prompt = {},
}

Symbols would have fuzzy find features with these configuration

Advanced configuration

nvim-lsputils provides some extension in handler function definition so that it can be integrated with some other lsp plugins easily.

Currently codeaction supports this extended defintion. Codeaction handler signature is something like:

code_action_handler(_, _, actions, _, _, _, customSelectionHandler)

customSelectionHandler is not defined by standard docs. However, nvim-lsputils provide it for easy extension and use with other plugins. customSelectionHandler is expected to be a function that accepts the selection action(from all codeactions) as parameter. If provided to the function, the function executes this customSelectionHandler with selected action instead of applying codeaction directly.

A simple customSelectionHandler can look like:

local function customSelectionHandler(selectedAction)
  print("Action selected: ", selectedAction)
end

One simple example is integration with nvim-jdtls.

local jdtls_ui = require'jdtls.ui'
function jdtls_ui.pick_one_async(items, _, _, cb)
  require'lsputil.codeAction'.code_action_handler(nil, nil, items, nil, nil, nil, cb)
end

This code snippet modifies the nvim-jdtls UI to make use of nvim-lsputils UI. With this code snippet, nvim-lsputils would provide the UI but the action would be decided by the functin parameter cb.

nvim-lsputils's People

Contributors

necabo avatar rishabhrd avatar spindensity avatar tonywu20 avatar unkorunk avatar vieiraa 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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar

nvim-lsputils's Issues

Behavior changed in new version?

Hi, RishabhRD

It seems that the plugin behavior changed in recent version.
If I do "reference". The plugin shows the reference and preview.
But if I open the file by hitting
The plugin will prompt

1 buffer wiped out
2 buffer wiped out
Press ENTER or type command to continue

Options 1 and 2 are same.
Is there configuration I need to add so it could bring me directly to the file/line I selected?

Also I find that each time this plugin was triggered, it will create a no-name buffer, it is a bit annoying as I need to "bdelete" manually from time to time. Is there a way it could be delete automatically after preview closed?

Also, Is there a way I could open new buffer in a vsplit view?

Improve UI: add filename to the top of split

Hello!
Thanks for the awesome plugin!
I have a small UX issue and suggestion for resolving that:
When I try to find code references sometimes it's hard to understand filenames:
image
Usually, filenames are hidden due to long code strings (red lines in the picture) and I cannot find out where the code is located.
Maybe add filename here? (green line):
image

Add filetype to floating windows

Hey, just started using this and really enjoying it 👍🏿 . I've got an issue though which is that the code actions menu numbering is being hidden by my relative number autocommands. I'm wondering if these buffers can be given a custom filetype so I can use it as a hook to exclude these windows from my autocommands. Alternatively if you know a better way that these can be ignored inside the floating windows i.e. can something like eventsignore be used to ignore custom user commands etc.

I appreciate this relates to my setup but interestingly I don't see this issue with coc floating windows the code actions one still shows numbers although I think it doesn't use line numbers and those numbers are written into the buffer maybe

Error executing vim.schedule lua callback: .../.config/nvim/plugged/nvim-lsputils/lua/lsputil/util.lua:89: attempt to index local 'var' (a userdata value)

Hello
Thank you for this useful plugin.
But I got a problem and I don't know why?

my lsputils.lua

vim.lsp.handlers['textDocument/codeAction'] = require'lsputil.codeAction'.code_action_handler
vim.lsp.handlers['textDocument/references'] = require'lsputil.locations'.references_handler
vim.lsp.handlers['textDocument/definition'] = require'lsputil.locations'.definition_handler
vim.lsp.handlers['textDocument/declaration'] = require'lsputil.locations'.declaration_handler
vim.lsp.handlers['textDocument/typeDefinition'] = require'lsputil.locations'.typeDefinition_handler
vim.lsp.handlers['textDocument/implementation'] = require'lsputil.locations'.implementation_handler
vim.lsp.handlers['textDocument/documentSymbol'] = require'lsputil.symbols'.document_handler
vim.lsp.handlers['workspace/symbol'] = require'lsputil.symbols'.workspace_handler

When I type gr in normal, I got a error.
image

I don't know why. It's that the latest neovim bug or something I got wrong? Please let me know. Thank you.

Some Info:
nvim-lsputils commit id : b68862a
NVIM v0.5.0-dev+1342-gde96626ad
Build type: Release
LuaJIT 2.1.0-beta3

Feature request UI option config

I would like to config the UI through vimrc. Personally following config works for me: It would be great to pass the opts (at least some of the fields e.g height, mode) to plugin.
Also did not find how to control the ratio of the symbols list and preview window, e.g I would like the window looks like this, in which more space left for preview window.

symbols             preview            

Current opts I am using:

  local opts = {
    mode = 'editor',
    data = data,
    height = 24,
    keymaps = keymaps,
    additional_keymaps = additionalKeymaps,
    callbacks = {
      select = selection_handler,
      close = close_handler
    },
    list = {
      numbering = true
    },
    preview = {
      type = 'terminal',
      border = false,
      title = 'Preview',
    }
  }

Handle range code action properly

First, thank you for the awesome plugin. Definitely improves nvim lsp experience !

When using vim.lsp.buf.range_code_action(), the cursor didn't place on its proper place.

Test using rust-analyzer

bugreport

Unable to load lsputil.codeAction module

Hi,

I tried setting up the plugin as described in the readme.
I have installed the nvim-lsputils and and popfix plugins using minpac and added the Lua snippet from the Readme.

When I source my init.vim, I get the following message:

Error executing lua [string ":lua"]:1: loop or previous error loading module 'lsputil.codeAction'

Neovim build:

NVIM v0.5.0-dev+1274-gbb3372792
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3

Opening reference handler in a horizontal split

Hi, how can we configure the plugin so that when it opens the quick fix list when we call

vim.lsp.handlers['textDocument/references'] = require'lsputil.locations'.references_handler

the preview appears on top (horizontal split) instead of on the right (vertical split)

quickfix list disappear in reference preview window

image

nvim version(latest):

NVIM v0.5.0-861-gcd691f2b6
Build type: Debug
LuaJIT 2.1.0-beta3

nvim-lsputils commit( git log --pretty=format:'%h' -n 1):
6abfc54

reproduce config:

" {{{ Vim-Plug Plugin Manager
if has('nvim')
        if system('uname -s') =~ 'Darwin'
                        let autoload_plug_path = stdpath('config') . '/autoload/plug.vim'
                        let plug_path = stdpath('config') . '/plugged'
        else
                        let autoload_plug_path = stdpath('data') . '/site/autoload/plug.vim'
                        let plug_path = stdpath('data') . '/plugged'
        endif
else
                let autoload_plug_path = '~/.vim/autoload/plug.vim'
                let plug_path = '~/.vim/plugged'
endif


if !filereadable(expand(autoload_plug_path))
 silent execute '!curl -fLo ' . autoload_plug_path . '  --create-dirs
      \ "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"'
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" }}}

call plug#begin(plug_path)

" Collection of common configurations for the Nvim LSP client
Plug 'neovim/nvim-lspconfig'

" Extentions to built-in LSP, for example, providing type inlay hints
Plug 'tjdevries/lsp_extensions.nvim'

" Autocompletion framework for built-in LSP
Plug 'nvim-lua/completion-nvim'

Plug 'RishabhRD/popfix'
Plug 'RishabhRD/nvim-lsputils'

call plug#end()

syntax enable
filetype plugin indent on


" Set completeopt to have a better completion experience
set completeopt=menuone,noinsert,noselect

" Avoid showing extra messages when using completion
set shortmess+=c


" Configure lsp
" https://github.com/neovim/nvim-lspconfig#rust_analyzer
lua <<EOF

-- nvim_lsp object
local nvim_lsp = require'lspconfig'

-- function to attach completion
-- when setting up lsp
local on_attach = function(client)
    require'completion'.on_attach(client)
    print("server attached")
end

-- Enable rust_analyzer
nvim_lsp.rust_analyzer.setup({ on_attach=on_attach })

-- Enalbe gopls
nvim_lsp.gopls.setup{ on_attach=on_attach }

-- Enable pyls
nvim_lsp.pyls.setup{ on_attach=on_attach }

vim.lsp.handlers['textDocument/codeAction'] = require'lsputil.codeAction'.code_action_handler
vim.lsp.handlers['textDocument/references'] = require'lsputil.locations'.references_handler
vim.lsp.handlers['textDocument/definition'] = require'lsputil.locations'.definition_handler
vim.lsp.handlers['textDocument/declaration'] = require'lsputil.locations'.declaration_handler
vim.lsp.handlers['textDocument/typeDefinition'] = require'lsputil.locations'.typeDefinition_handler
vim.lsp.handlers['textDocument/implementation'] = require'lsputil.locations'.implementation_handler
vim.lsp.handlers['textDocument/documentSymbol'] = require'lsputil.symbols'.document_handler
vim.lsp.handlers['workspace/symbol'] = require'lsputil.symbols'.workspace_handler

EOF

" Code navigation shortcuts
" as found in :help lsp
nnoremap <silent> gd    <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> K     <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <silent> gi    <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <silent> <c-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
nnoremap <silent> gtd   <cmd>lua vim.lsp.buf.type_definition()<CR>
nnoremap <silent> gr    <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <silent> g0    <cmd>lua vim.lsp.buf.document_symbol()<CR>
nnoremap <silent> gW    <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
" rust-analyzer does not yet support goto declaration
" re-mapped `gd` to definition
" nnoremap <silent> gd    <cmd>lua vim.lsp.buf.definition()<CR>
"nnoremap <silent> gd    <cmd>lua vim.lsp.buf.declaration()<CR>

" Trigger completion with <tab>
" found in :help completion
function! s:check_back_space() abort
    let col = col('.') - 1
    return !col || getline('.')[col - 1]  =~ '\s'
endfunction

inoremap <silent><expr> <TAB>
  \ pumvisible() ? "\<C-n>" :
  \ <SID>check_back_space() ? "\<TAB>" :
  \ completion#trigger_completion()

" Visualize diagnostics
let g:diagnostic_enable_virtual_text = 1
let g:diagnostic_trimmed_virtual_text = '40'
" Don't show diagnostics while in insert mode
let g:diagnostic_insert_delay = 1

" have a fixed column for the diagnostics to appear in
" this removes the jitter when warnings/errors flow in
set signcolumn=yes

" Set updatetime for CursorHold
" 300ms of no cursor movement to trigger CursorHold
set updatetime=300
" Show diagnostic popup on cursor hover
autocmd CursorHold * lua vim.lsp.diagnostic.show_line_diagnostics()

" Goto previous/next diagnostic warning/error
nnoremap <silent> g[ <cmd>PrevDiagnosticCycle<cr>
nnoremap <silent> g] <cmd>NextDiagnosticCycle<cr>

" Enable type inlay hints
autocmd CursorMoved,InsertLeave,BufEnter,BufWinEnter,TabEnter,BufWritePost *
\ lua require'lsp_extensions'.inlay_hints{ prefix = '', highlight = "Comment" }

Document dependency on bat

It seems like some of the features in nvim-lsputils depend on bat being installed, but I couldn't find any description of this in the readme.

If I haven't missed it somewhere, perhaps it could be added?

Sorting of code actions

Would it be possible to add a way to sort the code actions by lsp server?

My use case is I want the actions from null-ls to be below any other lsp

We could have a option that explicitly designates low priority servers (null, efm etc)

or more flexibly a function that takes a code action and returns the priority. Then we sort those using a stable sort so ties will be shown in the same order

Preview window is broken

On my system (nvim 0.5, Windows 10), the preview window (for example when searching for references), contains a bat error:

error: Found argument '-R' which wasn't expected, or isn't valid in this context

USAGE:
    bat.exe --color <when> --number --pager <command> --paging <when> --plain

For more information try --help

[Process exited 1]

I believe using double quotes instead of single quotes in the pager parameter of the following line would fix this issue:

local cmd = string.format('bat %s --color=always --paging=always --plain -n --pager=\'less -RS\' -H %s -r %s:', item.filename, item.lnum, startPoint)

Thank you. :-)

Colours in preview different than in a normal buffer

Hi, thanks for the plugin! I'm just trying it out and like it a lot, but the difference between colours in normal buffers and, say, reference previews, is distracting:
image

I'm using Treesitter; it looks like it's not applied to the preview.

module 'popfix.action' not found:`

I've added this to my init.vim

Plug 'RishabhRD/popfix' " to manage underlying popup and previews
Plug 'RishabhRD/nvim-lsputils' " for lsp codeactions

Installed/updated
but on startup I get
E5113: Error while calling lua chunk: .../share/nvim/site/nvim-lsputils/lua/lsputil/locations.lua:4: module 'popfix.action' not found:

CodeAction: expected 0 arguments

Issue

Been doing some Java and when invoking for CodeActions I get the following error and no popup appears:

Error executing vim.schedule lua callback: ...ig/nvim/plugged/nvim-lsputils/lua/lsputil/codeAction.lua:86: Expected 0 arguments

Code actions do work in other situations. What characterizes that specific one is that when I removed lsp-utils I saw 50 code actions in total that are presented by default with less. It may be a limitation of the current implementation that doesn't allow more than a certain amount of results. If you wanna simulate this many code actions, use JDTLS. Call for List<T> and run code actions to import the library.

List<Integer> numbers;

image

Expected result:

Code actions popup to appear

Configuration

  1. JDTLS installed with jdtls-launcher
  2. LSP config: require("lspconfig").jdtls.setup{ cmd = { "jdtls" } }
  3. Code actions config: vim.lsp.handlers['textDocument/codeAction'] = require'lsputil.codeAction'.code_action_handler

[Bug] Ubuntu does not recognize bat

Hi.
Nvim 0.5.1
Ubuntu 21.10
Ubuntu does not recognize the command bat. I read that it was changed to batcat. The program its name is bat but the command is batcat.

Edit:

local cmd = string.format('bat %s --color=always --paging=always --plain -n --pager=\'less -RS\' -H %s -r %s:', item.filename, item.lnum, startPoint)

Custom key-bindings

Is it possible to have custom key-bindings for functions such as code-action menu? Please tell me if there's a way to do this.

Moving down menu highlights options

Hello, with the last couple updates to this plugin, I noticed that when navigating the code action menu, options that I scroll over stay highlighted instead of just the current action.

For example, this is what it looks like when I trigger a code action and press j three times:
image

I am on the latest nvim nightly, arch, and using the latest version of this plugin.

Thanks for your work!

Rename handler

Hi,

any chance to introduce rename handler? CoC for example shows floating window at cursor to enter new name, and triggers lsp rename on enter.
I tried doing this myself, but popfix doesn't allow setting modifiable on the floating buffer.

Go to location in preview windows

Hi.

This is more a request than an issue.
Is it possible, when inside the preview windows (for example in References), to jump to the currently displayed file in the main windows? Something which resembles a quickfix list.

10x

Feature Request: Show filename in Reference window

When I use the native references quickfix window, I can see the reference filename clearly:

image

But with nvim-lsputils, the reference filename is hidden. When there are many references, it is difficult for me to identify which a reference comes from quickly.

image

Can you provide an option to display the filename in Reference window plz?

Thanks.

[Question] Popups for other LSP features

Hello and thank you for this great plugin!

I was wondering, if you had plans for other features, such as a popup for diagnostics (virtual text is horrible when it comes to multiline diagnostics) or maybe better hover? If so, I'll gladly create separate issues for the features I think would be usefull and help with some of them (the codebase seems simple enough for my level of expertise).

`codeAction` tries to spawn a popfix `floating_win` with negative height

I have the following override in place

vim.lsp.handlers['textDocument/codeAction'] = require'lsputil.codeAction'.code_action_handler

And, since yesterday, whenever I try to do

lua vim.lsp.buf.code_action()

I get the following error:

Error executing vim.schedule lua callback: .../.config/nvim/plugged/popfix/lua/popfix/floatin_win.lua:37: 'height' key must be a positive Integer

Feature Request: find references - wrap lines in search window

Hi, when I run find references on a long function and/or file path the result is getting cut off.
Screen Shot 2022-03-03 at 13 39 26

Can you add a configuration to warp lines in the references window? or alternatively provide an example on how to:

  1. configure find references and preview windows display vertically instead of horizontally?
  2. sort references by file:
- file 1
  - ref1.1
  - ref1.2
- file 2
 - ref2.1

Thanks!

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.