From 6abe9e49ee74b4745af8ba40c13c0a50d478e752 Mon Sep 17 00:00:00 2001 From: Warwick Date: Tue, 15 Aug 2023 15:09:39 +0100 Subject: [PATCH] Attempted to add whichkey, bit jank rn --- lua/core/plugin_config/init.lua | 1 + lua/core/plugin_config/lsp_config.lua | 15 ++++---- lua/core/plugin_config/telescope.lua | 4 +-- lua/core/plugin_config/whichkey.lua | 51 +++++++++++++++++++++++++++ lua/core/plugins.lua | 4 +++ 5 files changed, 66 insertions(+), 9 deletions(-) create mode 100644 lua/core/plugin_config/whichkey.lua diff --git a/lua/core/plugin_config/init.lua b/lua/core/plugin_config/init.lua index 3746157..5bb71a3 100644 --- a/lua/core/plugin_config/init.lua +++ b/lua/core/plugin_config/init.lua @@ -6,3 +6,4 @@ require("core.plugin_config.treesitter") require("core.plugin_config.lsp_config") require("core.plugin_config.completions") require("core.plugin_config.terminal") +require("core.plugin_config.whichkey") diff --git a/lua/core/plugin_config/lsp_config.lua b/lua/core/plugin_config/lsp_config.lua index 7701daa..37890d2 100644 --- a/lua/core/plugin_config/lsp_config.lua +++ b/lua/core/plugin_config/lsp_config.lua @@ -1,6 +1,6 @@ require("mason").setup() require("mason-lspconfig").setup({ - ensure_installed = {"lua_ls", "clangd", "cmake", "ltex"} + ensure_installed = { "lua_ls", "clangd", "cmake", "ltex" } }) -- gloabal mappings vim.keymap.set('n', 'le', vim.diagnostic.open_float) @@ -27,10 +27,10 @@ vim.api.nvim_create_autocmd('LspAttach', { --vim.keymap.set('n', 'wl', function() -- print(vim.inspect(vim.lsp.buf.list_workspace_folders())) --end, opts) - vim.keymap.set('n', 'ltd', vim.lsp.buf.type_definition, opts) - vim.keymap.set('n', 'lrn', vim.lsp.buf.rename, opts) + vim.keymap.set('n', 'lt', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', 'lR', vim.lsp.buf.rename, opts) vim.keymap.set({ 'n', 'v' }, 'la', vim.lsp.buf.code_action, opts) - vim.keymap.set('n', 'lrf', vim.lsp.buf.references, opts) + vim.keymap.set('n', 'lr', vim.lsp.buf.references, opts) vim.keymap.set('n', 'lf', function() vim.lsp.buf.format { async = true } end, opts) @@ -54,6 +54,7 @@ require("lspconfig").lua_ls.setup { workspace = { -- Make the server aware of Neovim runtime files library = vim.api.nvim_get_runtime_file("", true), + checkThirdParty = false, }, -- Do not send telemetry data containing a randomized but unique identifier telemetry = { @@ -62,6 +63,6 @@ require("lspconfig").lua_ls.setup { }, }, } -require("lspconfig").clangd.setup {capabilities = capabilities} -require("lspconfig").cmake.setup {capabilities = capabilities} -require("lspconfig").ltex.setup {capabilities = capabilities} +require("lspconfig").clangd.setup { capabilities = capabilities } +require("lspconfig").cmake.setup { capabilities = capabilities } +require("lspconfig").ltex.setup { capabilities = capabilities } diff --git a/lua/core/plugin_config/telescope.lua b/lua/core/plugin_config/telescope.lua index 8174253..8cb950c 100644 --- a/lua/core/plugin_config/telescope.lua +++ b/lua/core/plugin_config/telescope.lua @@ -1,6 +1,6 @@ local builtin = require('telescope.builtin') -vim.keymap.set('n', '', builtin.find_files, {}) -vim.keymap.set('n', '', builtin.oldfiles, {}) +vim.keymap.set('n', 'ff', builtin.find_files, {}) +vim.keymap.set('n', 'fo', builtin.oldfiles, {}) vim.keymap.set('n', 'fg', builtin.live_grep, {}) vim.keymap.set('n', 'fh', builtin.help_tags, {}) diff --git a/lua/core/plugin_config/whichkey.lua b/lua/core/plugin_config/whichkey.lua new file mode 100644 index 0000000..43264e4 --- /dev/null +++ b/lua/core/plugin_config/whichkey.lua @@ -0,0 +1,51 @@ +local whichkey = require("whichkey_setup") +-- lsp format +vim.g.formatfix = function() + vim.lsp.buf.format { async = true } +end +-- 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' }, + --- 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' }, + + }, + 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'}, + }, + g = { + name = '+git', + g = { 'Telescope git_commits', 'Commits' }, + b = { 'Telescope git_branches', 'Branches' }, + s = { 'Telescope git_status', 'Status' }, + } +} + +whichkey.config { + hide_statusline = false, + default_keymap_settings = { + silent = true, + noremap = true, + }, + default_mode = 'n', +} + +whichkey.register_keymap('leader', keymap) diff --git a/lua/core/plugins.lua b/lua/core/plugins.lua index 51a9d15..aefda02 100644 --- a/lua/core/plugins.lua +++ b/lua/core/plugins.lua @@ -23,6 +23,10 @@ local plugins = { opts = {} -- this is equalent to setup({}) function }, 'akinsho/toggleterm.nvim', + { + 'AckslD/nvim-whichkey-setup.lua', + dependencies = {'liuchengxu/vim-which-key'}, + }, -- fzf { 'nvim-telescope/telescope.nvim',