nvim: lsp/plugins: Add support for automatically showing fn signature

This commit is contained in:
Sanchayan Maity 2021-05-07 13:03:23 +05:30
parent 2f911b8e34
commit 91604ca16c
2 changed files with 10 additions and 1 deletions

View file

@ -1,5 +1,6 @@
local nvim_lsp = require('lspconfig')
local protocol = require('vim.lsp.protocol')
local signature = require('lsp_signature')
-- Taken from https://www.reddit.com/r/neovim/comments/gyb077/nvimlsp_peek_defination_javascript_ttserver/
function preview_location(location, context, before_context)
@ -44,6 +45,14 @@ function peek_definition()
end
local on_attach = function(client, bufnr)
signature.on_attach({
bind = true,
hint_enable = true,
hint_prefix = "🐼 ",
hint_scheme = "String",
handler_opts = { border = "single" },
decorator = {"`", "`"}
})
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
if client.config.flags then
@ -58,7 +67,6 @@ local on_attach = function(client, bufnr)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'ga', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '1gd', '<cmd>lua vim.lsp.buf.document_symbol()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '1gD', '<cmd>lua vim.lsp.buf.workspace_symbol()<CR>', opts)

View file

@ -113,6 +113,7 @@ local init = function ()
-- LSP
use {
'neovim/nvim-lspconfig',
'ray-x/lsp_signature.nvim'
}
-- Language support & syntax highlighting
-- Haskell