diff --git a/nvim/.config/nvim/lua/lsp.lua b/nvim/.config/nvim/lua/lsp.lua index 09236f2..6e0fe11 100644 --- a/nvim/.config/nvim/lua/lsp.lua +++ b/nvim/.config/nvim/lua/lsp.lua @@ -5,6 +5,19 @@ local ts_utils = require("nvim-lsp-ts-utils") local null_ls = require("null-ls") local util = require("lspconfig/util") +-- https://github.com/neovim/nvim-lspconfig/wiki/User-contributed-tips +local function preview_location_callback(_, result) + if result == nil or vim.tbl_isempty(result) then + return nil + end + vim.lsp.util.preview_location(result[1]) +end + +function PeekDefinition() + local params = vim.lsp.util.make_position_params() + return vim.lsp.buf_request(0, 'textDocument/definition', params, preview_location_callback) +end + local on_attach = function(client, bufnr) signature.on_attach({ bind = true, @@ -33,6 +46,7 @@ local on_attach = function(client, bufnr) vim.api.nvim_buf_set_keymap(bufnr, 'n', '1gd' , 'lua vim.lsp.buf.document_symbol()' , opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', '1gD' , 'lua vim.lsp.buf.workspace_symbol()', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gR' , 'lua vim.lsp.buf.rename()' , opts) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'pd' , 'lua PeekDefinition()' , opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d', 'lua vim.lsp.diagnostic.goto_prev { wrap = false }', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d', 'lua vim.lsp.diagnostic.goto_next { wrap = false }', opts)