From 2f8f5911db9722ae077f6b02377eed69efff4e43 Mon Sep 17 00:00:00 2001 From: pfm Date: Tue, 14 Feb 2023 08:52:35 -0600 Subject: [PATCH] Added which-key support for Neovim --- .config/nvim/init.lua | 11 +++-------- .config/nvim/lua/general.lua | 7 ++++++- .config/nvim/lua/keymap.lua | 3 ++- .config/nvim/lua/plugin_management.lua | 9 +++++++++ 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 8eb6e5a..2721131 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -1,14 +1,9 @@ --- Change leader to a comma, ensure this happens before packages are loaded. -vim.g.mapleader = ',' - --- Disable netrw in favor of nvim-tree -vim.g.loaded_netrw = 1 -vim.g.loaded_netrwPlugin = 1 - -- Configure basic Neovim settings. require('general') --- Configure key mappings not defined for plugins. +-- Configure key mappings not defined for plugins. This also establishes the +-- leader keys, which are important for plugins. Must be present before plugins +-- are loaded. require('keymap') -- This loads (lazily) all plugins and configures things like plugin-specific diff --git a/.config/nvim/lua/general.lua b/.config/nvim/lua/general.lua index 8174740..1620aaa 100644 --- a/.config/nvim/lua/general.lua +++ b/.config/nvim/lua/general.lua @@ -13,7 +13,8 @@ opt.termguicolors = true -- Note that this setting is important for which-key. Also don't reduce it too -- low, or the behavior will start getting wonky and always show which-key. -opt.timeoutlen = 500 -- Time in ms to wait for a sequnece to complete +opt.timeout = true +opt.timeoutlen = 300 -- Time in ms to wait for a sequnece to complete opt.shortmess:remove("F") vim.opt_global.shortmess:remove("F") @@ -25,6 +26,10 @@ opt.wildignore = { '*/.bloop/*', '*/.bsp/*', '*/node_modules/*' } +-- Disable netrw in favor of nvim-tree +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + ----------------------------------------------------------- -- Completion ----------------------------------------------------------- diff --git a/.config/nvim/lua/keymap.lua b/.config/nvim/lua/keymap.lua index d023248..c67962d 100644 --- a/.config/nvim/lua/keymap.lua +++ b/.config/nvim/lua/keymap.lua @@ -9,6 +9,7 @@ local map = vim.keymap.set +vim.g.mapleader = ',' vim.g.maplocalleader = ' ' -- Clear search highlighting @@ -41,8 +42,8 @@ map('n', 'gr', vim.lsp.buf.references, { desc = 'Go To References' }) map('n', 'gds', vim.lsp.buf.document_symbol, { desc = 'Document Symbol' }) map('n', 'gws', vim.lsp.buf.workspace_symbol, { desc = 'Workspace Symbol' }) map('n', 'gd', vim.lsp.buf.definition, { desc = 'Go To Definition' }) +map('n', 'gD', vim.lsp.buf.type_definition, { desc = 'Go To Type Definition' }) map('n', 'cl', vim.lsp.codelens.run, { desc = 'Code Lens' }) -map('n', 'D', vim.lsp.buf.type_definition, { desc = 'Type Definition' }) map('n', 'rn', vim.lsp.buf.rename, { desc = 'Rename' }) map('n', 'ca', vim.lsp.buf.code_action, { desc = 'Code Action' }) map('n', '[c', 'lua vim.diagnostic.goto_prev({ wrap = false })', { desc = 'prev diagnostic' }) diff --git a/.config/nvim/lua/plugin_management.lua b/.config/nvim/lua/plugin_management.lua index d631c28..e3f58c7 100644 --- a/.config/nvim/lua/plugin_management.lua +++ b/.config/nvim/lua/plugin_management.lua @@ -63,6 +63,15 @@ require("lazy").setup({ -- Common dependency for many plugins (visual) 'nvim-tree/nvim-web-devicons', + { + "folke/which-key.nvim", + config = function() + require("which-key").setup({ + -- customize as desired + }) + end, + }, + -- Fuzzy finder (files, buffers, live grep, etc.) -- Includes a native build based on FZF for performance. {