From fd28f928338c3beb258aab0ed24f71e5fb639548 Mon Sep 17 00:00:00 2001 From: tiyn Date: Fri, 8 Mar 2024 03:23:37 +0100 Subject: [PATCH] nvim: added preview for lsp --- .config/nvim/lazy-lock.json | 2 + .config/nvim/lua/keymap.lua | 11 +++- .config/nvim/lua/plugins/goto-preview.lua | 6 +++ .config/nvim/lua/plugins/lualine.lua | 64 ++++++++++++++--------- 4 files changed, 56 insertions(+), 27 deletions(-) create mode 100644 .config/nvim/lua/plugins/goto-preview.lua diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index a562335..41c85ea 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,4 +1,5 @@ { + "action-hints.nvim": { "branch": "main", "commit": "ab10fef255dd4bc933c92d8f9969828f2f856e71" }, "aerial.nvim": { "branch": "master", "commit": "31fbd369bbbeb53080c4b1ead9e76be322725ef5" }, "barbecue": { "branch": "main", "commit": "cd7e7da622d68136e13721865b4d919efd6325ed" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, @@ -13,6 +14,7 @@ "fzy-lua-native": { "branch": "master", "commit": "820f745b7c442176bcc243e8f38ef4b985febfaf" }, "git-blame.nvim": { "branch": "master", "commit": "a0282d05adbee80aaf4e2ff35b81b52940b67bed" }, "gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" }, + "goto-preview": { "branch": "main", "commit": "527fd81a827234e26ca47891abe90497215db2a6" }, "indent-blankline.nvim": { "branch": "master", "commit": "821a7acd88587d966f7e464b0b3031dfe7f5680c" }, "knap": { "branch": "main", "commit": "d4ea571d2d4e139d288b758c5bab31788d30eea3" }, "lazy.nvim": { "branch": "main", "commit": "83493db50a434a4c5c648faf41e2ead80f96e478" }, diff --git a/.config/nvim/lua/keymap.lua b/.config/nvim/lua/keymap.lua index 2b45b51..58580f6 100644 --- a/.config/nvim/lua/keymap.lua +++ b/.config/nvim/lua/keymap.lua @@ -12,6 +12,7 @@ local m = require 'mapx'.setup { global = true, whichkey = true } -- setup keymap groups m.nname("g", "LSP: goto") +m.nname("gp", "LSP: preview") m.cname("w", "Write") m.cname("w!", "Write: overwrite") m.nname("g", "Git") @@ -89,11 +90,19 @@ m.nmap("x", ":TroubleToggle", "LSP: toggle error list") m.nnoremap("gd", vim.lsp.buf.definition(), "LSP: goto definition") m.nnoremap("gD", vim.lsp.buf.declaration(), "LSP: goto declaration") m.nnoremap("gi", vim.lsp.buf.implementation(), "LSP: list implementation") -m.nnoremap("gr", vim.lsp.buf.references(), "LSP: list references") +m.nnoremap("gr", function() vim.lsp.buf.references() end, "LSP: list references") m.nnoremap("gy", vim.lsp.buf.type_definition(), "LSP: goto type definition") m.nnoremap("K", vim.lsp.buf.hover(), "LSP: show documentation") m.nnoremap("", function() require("conform").format({ async = true, lsp_fallback = true }) end, "LSP: format") +-- rmagatti/goto-preview +m.nnoremap("gpd", function() require('goto-preview').goto_preview_definition() end, "LSP: preview definition") +m.nnoremap("gpy", function() require('goto-preview').goto_preview_type_definition() end, "LSP: preview type definition") +m.nnoremap("gpi", function() require('goto-preview').goto_preview_implementation() end, "LSP: list preview implementation") +m.nnoremap("gpD", function() require('goto-preview').goto_preview_declaration() end, "LSP: preview declaration") +m.nnoremap("gpr", function() require('goto-preview').goto_preview_references() end, "LSP: list preview references") +m.nnoremap("gpc", function() require('goto-preview').close_all_win() end, "LSP: close all preview windows") + -- filipdutescu/renamer.nvim m.nnoremap("", function() require("renamer").rename() end, "LSP: rename") diff --git a/.config/nvim/lua/plugins/goto-preview.lua b/.config/nvim/lua/plugins/goto-preview.lua new file mode 100644 index 0000000..a3fb692 --- /dev/null +++ b/.config/nvim/lua/plugins/goto-preview.lua @@ -0,0 +1,6 @@ +return { + "rmagatti/goto-preview", + config = function() + require("goto-preview").setup({}) + end, +} diff --git a/.config/nvim/lua/plugins/lualine.lua b/.config/nvim/lua/plugins/lualine.lua index c6ccff0..3bb2e6d 100644 --- a/.config/nvim/lua/plugins/lualine.lua +++ b/.config/nvim/lua/plugins/lualine.lua @@ -1,53 +1,65 @@ return { -- statusline { - 'nvim-lualine/lualine.nvim', + "nvim-lualine/lualine.nvim", dependencies = { { - 'nvim-tree/nvim-web-devicons', - lazy = true + "nvim-tree/nvim-web-devicons", + lazy = true, }, { - 'f-person/git-blame.nvim', + "f-person/git-blame.nvim", config = function() vim.g.gitblame_display_virtual_text = 0 - end + end, + }, + { "tiyn/tccs.nvim" }, + { + "roobert/action-hints.nvim", + config = function() + require("action-hints").setup({ + template = { + definition = { text = "D", color = "#add8e6" }, + references = { text = "R%s", color = "#ff6666" }, + }, + }) + end, }, - { 'tiyn/tccs.nvim' }, }, config = function() - require('lualine').setup({ + require("lualine").setup({ options = { globalstatus = true, symbols = { error = Error_sign, warn = Warn_sign, hint = Hint_sign, - info = Info_sign + info = Info_sign, }, - theme = 'tccs', - component_separators = { left = '', right = '' }, - section_separators = { left = '', right = '' } + theme = "tccs", + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, }, sections = { lualine_b = { { - require('gitblame').get_current_blame_text, - cond = require('gitblame').is_blame_text_available - } + require("gitblame").get_current_blame_text, + cond = require("gitblame").is_blame_text_available, + }, }, lualine_c = {}, lualine_x = { - 'encoding', - 'fileformat', + require("action-hints").statusline, + "encoding", + "fileformat", { - 'filetype', - icon_only = true - } + "filetype", + icon_only = true, + }, }, lualine_y = { { - 'filename', + "filename", file_status = true, newfile_status = true, path = 1, @@ -57,12 +69,12 @@ return { readonly = Lualine_signs["readonly"], unnamed = Lualine_signs["unnamed"], newfile = Lualine_signs["newfile"], - } - } + }, + }, }, - lualine_z = { 'progress', 'location' }, - } + lualine_z = { "progress", "location" }, + }, }) - end - } + end, + }, }