From be41c8120cdcc2657c3460b0a92ed88b2bafbafd Mon Sep 17 00:00:00 2001 From: Warwick Date: Wed, 16 Aug 2023 16:52:25 +0100 Subject: [PATCH] Added indent lines and moved over to better whichkey implementation --- lua/core/keymaps.lua | 3 ++ lua/core/plugin_config/indent-blankline.lua | 6 +++ lua/core/plugin_config/init.lua | 3 +- lua/core/plugin_config/whichkey.lua | 44 ++++++++++----------- lua/core/plugins.lua | 14 +++++-- 5 files changed, 41 insertions(+), 29 deletions(-) create mode 100644 lua/core/plugin_config/indent-blankline.lua diff --git a/lua/core/keymaps.lua b/lua/core/keymaps.lua index 33e3ad2..8f332f2 100644 --- a/lua/core/keymaps.lua +++ b/lua/core/keymaps.lua @@ -14,3 +14,6 @@ vim.opt.tabstop = 2 -- Seems to be default for most lsp's now vim.opt.shiftwidth = 2 vim.opt.shiftround = true vim.opt.expandtab = true + +-- line numbers are handy +vim.opt.number = true diff --git a/lua/core/plugin_config/indent-blankline.lua b/lua/core/plugin_config/indent-blankline.lua new file mode 100644 index 0000000..370650e --- /dev/null +++ b/lua/core/plugin_config/indent-blankline.lua @@ -0,0 +1,6 @@ +require("indent_blankline").setup { + -- for example, context is off by default, use this to turn it on + show_current_context = false, + show_current_context_start = false, +} +vim.cmd [[colorscheme gruvbox]] diff --git a/lua/core/plugin_config/init.lua b/lua/core/plugin_config/init.lua index 5bb71a3..3731a53 100644 --- a/lua/core/plugin_config/init.lua +++ b/lua/core/plugin_config/init.lua @@ -1,4 +1,3 @@ -require("core.plugin_config.gruvbox") require("core.plugin_config.lualine") require("core.plugin_config.nvim-tree") require("core.plugin_config.telescope") @@ -7,3 +6,5 @@ require("core.plugin_config.lsp_config") require("core.plugin_config.completions") require("core.plugin_config.terminal") require("core.plugin_config.whichkey") +require("core.plugin_config.indent-blankline") +require("core.plugin_config.gruvbox") diff --git a/lua/core/plugin_config/whichkey.lua b/lua/core/plugin_config/whichkey.lua index 43264e4..58b444a 100644 --- a/lua/core/plugin_config/whichkey.lua +++ b/lua/core/plugin_config/whichkey.lua @@ -1,35 +1,31 @@ -local whichkey = require("whichkey_setup") --- lsp format -vim.g.formatfix = function() - vim.lsp.buf.format { async = true } -end +local whichkey = require("which-key") -- TODO fix based instructions local keymap = { t = 'Toggle Terminal', l = { name = '+lsp', - e = { "vim.diagnostic.open_float", 'Diagnostic Float' }, - n = { "vim.diagnostic.goto_next", 'Next Diagnostic' }, - N = { "vim.diagnostic.goto_prev", 'Previous Diagnostic' }, - j = { "vim.diagnostic.setloclist", 'Diagnostic List' }, + e = { "lua vim.diagnostic.open_float()", 'Diagnostic Float' }, + n = { "lua vim.diagnostic.goto_next()", 'Next Diagnostic' }, + N = { "lua vim.diagnostic.goto_prev()", 'Previous Diagnostic' }, + j = { "lua vim.diagnostic.setloclist()", 'Diagnostic List' }, --- Dynamic to each buffer potential TODO? - D = { "vim.lsp.buf.declaration", 'Declaration' }, - d = { "vim.lsp.buf.definition", 'Definition' }, - k = { "vim.lsp.buf.hover", 'Hover' }, - i = { "vim.lsp.buf.implementation", 'Implementation' }, - t = { "vim.lsp.buf.type_definition", 'Type Definition' }, - R = { "vim.lsp.buf.rename", 'Rename' }, - a = { "vim.lsp.buf.code_action", 'Code Action' }, - r = { "vim.lsp.buf.references", 'References' }, - f = { "lua vim.g.formatfix()", 'Format' }, + D = { "lua vim.lsp.buf.declaration()", 'Declaration' }, + d = { "lua vim.lsp.buf.definition()", 'Definition' }, + k = { "lua vim.lsp.buf.hover()", 'Hover' }, + i = { "lua vim.lsp.buf.implementation()", 'Implementation' }, + t = { "lua vim.lsp.buf.type_definition()", 'Type Definition' }, + R = { "lua vim.lsp.buf.rename()", 'Rename' }, + a = { "lua vim.lsp.buf.code_action()", 'Code Action' }, + r = { "lua vim.lsp.buf.references()", 'References' }, + f = { function() vim.lsp.buf.format { async = true } end, 'Format' }, }, f = { name = '+find (telescope)', - f = {"Telescope find_files",'Find'}, - o = {"Telescope oldfiles",'Old Files'}, - g = {"Telescope live_grep",'Grep'}, - h = {"Telescope help_tags",'Help Tags'}, + f = { "Telescope find_files", 'Find' }, + o = { "Telescope oldfiles", 'Old Files' }, + g = { "Telescope live_grep", 'Grep' }, + h = { "Telescope help_tags", 'Help Tags' }, }, g = { name = '+git', @@ -39,7 +35,7 @@ local keymap = { } } -whichkey.config { +whichkey.setup { hide_statusline = false, default_keymap_settings = { silent = true, @@ -48,4 +44,4 @@ whichkey.config { default_mode = 'n', } -whichkey.register_keymap('leader', keymap) +whichkey.register(keymap, { prefix = '' }) diff --git a/lua/core/plugins.lua b/lua/core/plugins.lua index aefda02..cf29dcc 100644 --- a/lua/core/plugins.lua +++ b/lua/core/plugins.lua @@ -18,20 +18,26 @@ local plugins = { 'nvim-tree/nvim-web-devicons', 'nvim-lualine/lualine.nvim', 'nvim-treesitter/nvim-treesitter', - {'windwp/nvim-autopairs', + { + 'windwp/nvim-autopairs', event = "InsertEnter", opts = {} -- this is equalent to setup({}) function }, 'akinsho/toggleterm.nvim', { - 'AckslD/nvim-whichkey-setup.lua', - dependencies = {'liuchengxu/vim-which-key'}, + "folke/which-key.nvim", + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + end, }, + "lukas-reineke/indent-blankline.nvim", -- fzf { 'nvim-telescope/telescope.nvim', branch = "0.1.x", - dependencies = {{'nvim-lua/plenary.nvim'}} + dependencies = { { 'nvim-lua/plenary.nvim' } } }, -- Lsp {