All Projects → ray-x → lsp_signature.nvim

ray-x / lsp_signature.nvim

Licence: Apache-2.0 license
LSP signature hint as you type

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to lsp signature.nvim

Lsp Status.nvim
Utility functions for getting diagnostic status and progress messages from LSP servers, for use in the Neovim statusline
Stars: ✭ 201 (-78.03%)
Mutual labels:  neovim-plugin, lsp
Kotlin Language Server
Intelligent Kotlin support for any editor/IDE using the Language Server Protocol
Stars: ✭ 650 (-28.96%)
Mutual labels:  autocomplete, lsp
Coc.nvim
Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Stars: ✭ 18,268 (+1896.5%)
Mutual labels:  neovim-plugin, lsp
Coc Fzf
fzf ❤️ coc.nvim
Stars: ✭ 261 (-71.48%)
Mutual labels:  neovim-plugin, lsp
nvim-lsp-ts-utils
Utilities to improve the TypeScript development experience for Neovim's built-in LSP client.
Stars: ✭ 437 (-52.24%)
Mutual labels:  neovim-plugin, lsp
Completor.vim
Async completion framework made ease.
Stars: ✭ 1,158 (+26.56%)
Mutual labels:  neovim-plugin, lsp
Vim Language Server
VImScript language server, LSP for vim script
Stars: ✭ 264 (-71.15%)
Mutual labels:  autocomplete, lsp
Coc Flutter
flutter support for (Neo)vim
Stars: ✭ 259 (-71.69%)
Mutual labels:  autocomplete, lsp
nvim-config
My neovim config
Stars: ✭ 63 (-93.11%)
Mutual labels:  neovim-plugin, lsp
Ale
Check syntax in Vim asynchronously and fix files, with Language Server Protocol (LSP) support
Stars: ✭ 11,380 (+1143.72%)
Mutual labels:  autocomplete, neovim-plugin
null-ls.nvim
Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
Stars: ✭ 965 (+5.46%)
Mutual labels:  neovim-plugin, lsp
navigator.lua
Source code analysis & navigation plugin for Neovim. Navigate codes like a breeze🎐. Exploring LSP and 🌲Treesitter symbols a piece of 🍰. Take control like a boss 🦍.
Stars: ✭ 781 (-14.64%)
Mutual labels:  neovim-plugin, lsp
aurora
24-bit dark theme for (Neo)vim. Optimized for treesitter, LSP.
Stars: ✭ 141 (-84.59%)
Mutual labels:  neovim-plugin, lsp
Nvim Lsputils
Better defaults for nvim-lsp actions
Stars: ✭ 142 (-84.48%)
Mutual labels:  neovim-plugin, lsp
coc-tailwind-intellisense
Coc.nvim extension for Tailwind CSS IntelliSense
Stars: ✭ 117 (-87.21%)
Mutual labels:  neovim-plugin, lsp
Coc Angular
Angular Language Service coc extension for (neo)vim
Stars: ✭ 95 (-89.62%)
Mutual labels:  autocomplete, lsp
coc-svelte
svelte support for (Neo)Vim
Stars: ✭ 156 (-82.95%)
Mutual labels:  autocomplete, lsp
aerial.nvim
Neovim plugin for a code outline window
Stars: ✭ 485 (-46.99%)
Mutual labels:  neovim-plugin, lsp
fzf-lsp.nvim
Enable the power of fzf fuzzy search for the neovim built in lsp
Stars: ✭ 143 (-84.37%)
Mutual labels:  lsp
react-native-dropdown-autocomplete
Autocomplete input with dropdown modal component for React native. Useful for pages with multiple autocomplete's.
Stars: ✭ 97 (-89.4%)
Mutual labels:  autocomplete

lsp_signature.nvim

Show function signature when you type

  • This nvim plugin is made for completion plugins that do not support signature help. Need neovim-0.6.1+ and enable nvim-lsp. (check neovim-0.5 branch for earlier version support)

  • Inspired by completion-nvim, which does have lots of cool features.

  • Fully asynchronous lsp buf request.

  • Virtual text available

Golang with markdown

Highlight with "Search"

signature2.mov
Lua

lua

The plugin also re-write the builtin lsp signature allow the parameter highlight

signature_with_virtual_hint

Using virtual text to show the next parameter

virtual_hint

Virtual text only mode

(from @fdioguardi)

virtual_text_only

Multiple signatures

In case some of the languages allow function overload, the plugin will show all available signatures

multiple_signature

signature2

Install:

" dein
dein#add('ray-x/lsp_signature.nvim')

" plug
Plug 'ray-x/lsp_signature.nvim'

" Packer
use {
  "ray-x/lsp_signature.nvim",
}

Setup / Attach the plugin

In your init.lua, call setup()

cfg = {...}  -- add you config here
require "lsp_signature".setup(cfg)

Alternatively, call on_attach() when the LSP client attaches to a buffer

e.g. gopls:

local golang_setup = {
  on_attach = function(client, bufnr)
    ...
    require "lsp_signature".on_attach()  -- Note: add in lsp client on-attach
    ...
  end,
  ...
}

require'lspconfig'.gopls.setup(golang_setup)

Configure

Floating window borders

If you have a recent enough build of Neovim, you can configure borders in the signature help floating window(Thanks @Gabriel Sanches for the PR):

local example_setup = {
  on_attach = function(client, bufnr)
    ...
    require "lsp_signature".on_attach({
      bind = true, -- This is mandatory, otherwise border config won't get registered.
      handler_opts = {
        border = "rounded"
      }
    }, bufnr)
    ...
  end,
  ...
}

Or:

  require'lspconfig'.gopls.setup()
  require "lsp_signature".setup({
    bind = true, -- This is mandatory, otherwise border config won't get registered.
    handler_opts = {
      border = "rounded"
    }
  })

Full configuration (with default values)

 cfg = {
  debug = false, -- set to true to enable debug logging
  log_path = vim.fn.stdpath("cache") .. "/lsp_signature.log", -- log dir when debug is on
  -- default is  ~/.cache/nvim/lsp_signature.log
  verbose = false, -- show debug line number

  bind = true, -- This is mandatory, otherwise border config won't get registered.
               -- If you want to hook lspsaga or other signature handler, pls set to false
  doc_lines = 10, -- will show two lines of comment/doc(if there are more than two lines in doc, will be truncated);
                 -- set to 0 if you DO NOT want any API comments be shown
                 -- This setting only take effect in insert mode, it does not affect signature help in normal
                 -- mode, 10 by default

  floating_window = true, -- show hint in a floating window, set to false for virtual text only mode

  floating_window_above_cur_line = true, -- try to place the floating above the current line when possible Note:
  -- will set to true when fully tested, set to false will use whichever side has more space
  -- this setting will be helpful if you do not want the PUM and floating win overlap

  floating_window_off_x = 1, -- adjust float windows x position.
  floating_window_off_y = 1, -- adjust float windows y position.


  fix_pos = false,  -- set to true, the floating window will not auto-close until finish all parameters
  hint_enable = true, -- virtual hint enable
  hint_prefix = "🐼 ",  -- Panda for parameter
  hint_scheme = "String",
  hi_parameter = "LspSignatureActiveParameter", -- how your parameter will be highlight
  max_height = 12, -- max height of signature floating_window, if content is more than max_height, you can scroll down
                   -- to view the hiding contents
  max_width = 80, -- max_width of signature floating_window, line will be wrapped if exceed max_width
  handler_opts = {
    border = "rounded"   -- double, rounded, single, shadow, none
  },

  always_trigger = false, -- sometime show signature on new line or in middle of parameter can be confusing, set it to false for #58

  auto_close_after = nil, -- autoclose signature float win after x sec, disabled if nil.
  extra_trigger_chars = {}, -- Array of extra characters that will trigger signature completion, e.g., {"(", ","}
  zindex = 200, -- by default it will be on top of all floating windows, set to <= 50 send it to bottom

  padding = '', -- character to pad on left and right of signature can be ' ', or '|'  etc

  transparency = nil, -- disabled by default, allow floating win transparent value 1~100
  shadow_blend = 36, -- if you using shadow as border use this set the opacity
  shadow_guibg = 'Black', -- if you using shadow as border use this set the color e.g. 'Green' or '#121315'
  timer_interval = 200, -- default timer check interval set to lower value if you want to reduce latency
  toggle_key = nil -- toggle signature on and off in insert mode,  e.g. toggle_key = '<M-x>'
}

-- recommended:
require'lsp_signature'.setup(cfg) -- no need to specify bufnr if you don't use toggle_key

-- You can also do this inside lsp on_attach
-- note: on_attach deprecated
require'lsp_signature'.on_attach(cfg, bufnr) -- no need to specify bufnr if you don't use toggle_key

Signature in status line

Sample config

API

require("lsp_signature").status_line(max_width)

return a table

{
  label = 'func fun_name(arg1, arg2...)'
  hint = 'arg2'
}
local current_signature = function(width)
  if not packer_plugins["lsp_signature.nvim"] or packer_plugins["lsp_signature.nvim"].loaded == false then
    return ""
  end
  local sig = require("lsp_signature").status_line(width)
  return sig.label .. "🐼" .. sig.hint
end

signature in status line

Should signature floating windows fixed

fix_pos can be a function, it took two element, first is the signature result for your signature, second is lsp client.

You can provide a function.

e.g.

fix_pos = function(signatures, lspclient)
   if signatures[1].activeParameter >= 0 and #signatures[1].parameters == 1 then
     return false
   end
   if lspclient.name == 'sumneko_lua' then
     return true
   end
   return false
end

Sample config with cmp, luasnipet and autopair

init.lua

Q&A:

Q: What is the default colorscheme in screenshot:

A: aurora

Q: I can not see border after enable border = "single"/"rounded"

A: Try another colorscheme (e.g. colorscheme aurora, or colorscheme luna). If issue persists, please submit an issue

Q: It is not working 😡

A: Here is some trouble shooting: #1

If you are using JDTLS, please read this: issue #97

Q:I do not like the pop window background highlight, how to change it?

A: Redefine your NormalFloat and FloatBorder, esp if your colorscheme dose not define it.

Q: How to change parameter highlight

A: By default, the highlight is using "LspSignatureActiveParameter" defined in your colorscheme, you can either override "LspSignatureActiveParameter" or define, e.g. use IncSearch setup({ hi_parameter = "IncSearch"})

Q: I can not see 🐼 in virtual text

A: It is emoji, not nerdfont. Please check how to enable emoji for your terminal.

Q: Working with cmp/coq. The floating windows block cmp/coq

A: A few options here, z-index, floating_window_above_cur_line, floating_window_off_x/y, toggle_key. You can find the best setup for your workflow.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].