From 0a9e065b4de2c33dca912f3f89bf459d50ac063b Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Sat, 23 Nov 2024 08:26:26 -0500 Subject: [PATCH] fix: Fixes some keymap collisions in nvim --- nvim/m-housh/lua/user/keymaps.lua | 21 --- nvim/m-housh/lua/user/plugin/lazygit.lua | 21 +-- nvim/m-housh/lua/user/plugin/telescope.lua | 20 +++ .../m-housh/lua/user/plugin/todo-comments.lua | 7 +- nvim/m-housh/lua/user/plugin/treesitter.lua | 152 +++++++++--------- nvim/m-housh/lua/user/plugin/trouble.lua | 7 +- 6 files changed, 115 insertions(+), 113 deletions(-) diff --git a/nvim/m-housh/lua/user/keymaps.lua b/nvim/m-housh/lua/user/keymaps.lua index c2233ec..a486023 100755 --- a/nvim/m-housh/lua/user/keymaps.lua +++ b/nvim/m-housh/lua/user/keymaps.lua @@ -3,19 +3,12 @@ vim.g.maplocalleader = " " local keymap = vim.keymap.set local default_options = { noremap = true, silent = true } -local telescope = require("telescope.builtin") local wk = require("which-key") local wk_add = function(mode, keymaps) wk.add(keymaps, { mode = mode, silent = true }) end -local find_files = function(dir) - return function() - telescope.find_files({ cwd = dir, hidden = true, no_ignore = true }) - end -end - -------------------------------------------------------------------------------- -- Insert Mode -------------------------------------------------------------------------------- @@ -41,20 +34,6 @@ wk_add("n", { { "J", ":move .+1==", desc = "Move line down" }, { "K", ":move .-2==", desc = "Move line up" }, - -- Git - { "gg", ":LazyGit", desc = "Open [G]it" }, - { "gf", ":Telescope git_files", desc = "Find [G]it [F]ile" }, - --{ "t", ":ToggleTerm", desc = "Open [T]erminal" }, - - -- Telescope keymaps - { "ff", telescope.find_files, desc = "[F]ind [F]iles" }, - { "fg", telescope.live_grep, desc = "[F]ind [G]rep" }, - { "fb", telescope.buffers, desc = "[F]ind [B]uffers" }, - { "fh", telescope.help_tags, desc = "[F]ind [H]elp" }, - { "fd", find_files("$DOTFILES"), desc = "[F]ind [D]otfiles" }, - { "fn", find_files("$DOTFILES/nvim/m-housh"), desc = "[F]ind [N]vim file" }, - { "fs", find_files("$DOTFILES/scripts/scripts"), desc = "[F]ind [S]cript" }, - { "fz", find_files("$DOTFILES/zsh/config"), desc = "[F]ind [Z]sh config file" }, { "z", ":ZenMode", desc = "[Z]en Mode" }, }) diff --git a/nvim/m-housh/lua/user/plugin/lazygit.lua b/nvim/m-housh/lua/user/plugin/lazygit.lua index cf77818..cc1473e 100755 --- a/nvim/m-housh/lua/user/plugin/lazygit.lua +++ b/nvim/m-housh/lua/user/plugin/lazygit.lua @@ -1,10 +1,11 @@ -return { - "kdheepak/lazygit.nvim", - dependencies = { - "nvim-telescope/telescope.nvim", - "nvim-lua/plenary.nvim" - }, - config = function() - require("telescope").load_extension("lazygit") - end, -} +return {} +-- return { +-- "kdheepak/lazygit.nvim", +-- dependencies = { +-- "nvim-telescope/telescope.nvim", +-- "nvim-lua/plenary.nvim" +-- }, +-- config = function() +-- require("telescope").load_extension("lazygit") +-- end, +-- } diff --git a/nvim/m-housh/lua/user/plugin/telescope.lua b/nvim/m-housh/lua/user/plugin/telescope.lua index 40854a3..560c506 100755 --- a/nvim/m-housh/lua/user/plugin/telescope.lua +++ b/nvim/m-housh/lua/user/plugin/telescope.lua @@ -77,6 +77,26 @@ return { }, }) + local map = function(keys, action, desc) + local opts = { silent = true, noremap = true, desc = desc } + vim.keymap.set("n", keys, action, opts) + end + + local find_files = function(dir) + return function() + builtin.find_files({ cwd = dir, hidden = true, no_ignore = true }) + end + end + vim.keymap.set("n", "", builtin.jumplist, { silent = true, noremap = true, desc = "Open [J]ump List." }) + map("ff", builtin.find_files, "[F]ind [F]iles") + map("fg", builtin.live_grep, "[F]ind [G]rep") + map("fb", builtin.buffers, "[F]ind [B]uffers") + map("fh", builtin.help_tags, "[F]ind [H]elp") + map("fd", find_files("$DOTFILES"), "[F]ind [D]otfiles") + map("fn", find_files("$DOTFILES/nvim/m-housh"), "[F]ind [N]vim file") + map("fs", find_files("$DOTFILES/scripts/scripts"), "[F]ind [S]cript") + map("fz", find_files("$DOTFILES/zsh/config"), "[F]ind [Z]sh config file") + map("gf", builtin.git_files, "Find [G]it [F]iles") end, } diff --git a/nvim/m-housh/lua/user/plugin/todo-comments.lua b/nvim/m-housh/lua/user/plugin/todo-comments.lua index f64812f..3e03127 100644 --- a/nvim/m-housh/lua/user/plugin/todo-comments.lua +++ b/nvim/m-housh/lua/user/plugin/todo-comments.lua @@ -1,13 +1,16 @@ return { "folke/todo-comments.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, + dependencies = { + "nvim-lua/plenary.nvim", + "folke/trouble.nvim", + }, opts = {}, config = function() local todos = require("todo-comments") todos.setup({}) - vim.keymap.set("n", "tq", "TodoQuickFix", { desc = "[T]odo [Q]uick fix list." }) + vim.keymap.set("n", "tq", "Trouble todo toggle", { desc = "[T]odo [Q]uick fix list." }) vim.keymap.set("n", "t", "TodoTelescope", { desc = "[T]odo telescope list." }) vim.keymap.set("n", "tl", "TodoLocList", { desc = "[T]odo [L]ocation list." }) vim.keymap.set("n", "]t", function() diff --git a/nvim/m-housh/lua/user/plugin/treesitter.lua b/nvim/m-housh/lua/user/plugin/treesitter.lua index ecd97c2..8ec0090 100755 --- a/nvim/m-housh/lua/user/plugin/treesitter.lua +++ b/nvim/m-housh/lua/user/plugin/treesitter.lua @@ -1,78 +1,78 @@ return { - "nvim-treesitter/nvim-treesitter", - dependencies = { - 'nvim-telescope/telescope-fzf-native.nvim', - 'nvim-treesitter/nvim-treesitter-textobjects', - }, - build = ':TSUpdate', - event = { 'BufReadPre', 'BufNewFile' }, - config = function() - require('nvim-treesitter.configs').setup { - ensure_installed = { - "bash", - "cmake", - "dockerfile", - "go", - "hcl", - "html", - "java", - "javascript", - "json", - "latex", - "ledger", - "llvm", - "lua", - "make", - "markdown", - "python", - "swift", - "toml", - "xml", - "yaml" - }, -- one of "all", "maintained" (parsers with maintainers), or a list of languages - ignore_install = {}, -- List of parsers to ignore installing - highlight = { - enable = true, -- false will disable the whole extension - disable = {} -- list of language that will be disabled - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - scope_incremental = "", - node_incremental = "", - node_decremental = "" - } - }, - indent = {enable = true}, - autopairs = {{enable = true}}, - textobjects = { - select = { - enable = true, - -- Automatically jump forward to textobj, similar to targets.vim - lookahead = true, - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - ["al"] = "@loop.outer", - ["il"] = "@loop.inner", - ["ib"] = "@block.inner", - ["ab"] = "@block.outer", - ["ir"] = "@parameter.inner", - ["ar"] = "@parameter.outer", - ["a="] = "@assignment.outer", - ["i="] = "@assignment.inner", - } - } - }, - rainbow = { - enable = true, - extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean - max_file_lines = 2000 -- Do not enable for files with more than specified lines - } - } - end + "nvim-treesitter/nvim-treesitter", + dependencies = { + "nvim-telescope/telescope-fzf-native.nvim", + "nvim-treesitter/nvim-treesitter-textobjects", + }, + build = ":TSUpdate", + event = { "BufReadPre", "BufNewFile" }, + config = function() + require("nvim-treesitter.configs").setup({ + ensure_installed = { + "bash", + "cmake", + "dockerfile", + "go", + "hcl", + "html", + "java", + "javascript", + "json", + "latex", + "ledger", + "llvm", + "lua", + "make", + "markdown", + "python", + "swift", + "toml", + "xml", + "yaml", + }, -- one of "all", "maintained" (parsers with maintainers), or a list of languages + ignore_install = {}, -- List of parsers to ignore installing + highlight = { + enable = true, -- false will disable the whole extension + disable = {}, -- list of language that will be disabled + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + scope_incremental = "", + node_incremental = "", + node_decremental = "", + }, + }, + indent = { enable = true }, + autopairs = { { enable = true } }, + textobjects = { + select = { + enable = true, + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + ["al"] = "@loop.outer", + ["il"] = "@loop.inner", + ["ib"] = "@block.inner", + ["ab"] = "@block.outer", + ["ir"] = "@parameter.inner", + ["ar"] = "@parameter.outer", + ["a="] = "@assignment.outer", + ["i="] = "@assignment.inner", + }, + }, + }, + rainbow = { + enable = true, + extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean + max_file_lines = 2000, -- Do not enable for files with more than specified lines + }, + }) + end, } diff --git a/nvim/m-housh/lua/user/plugin/trouble.lua b/nvim/m-housh/lua/user/plugin/trouble.lua index 12e10e9..b55d730 100644 --- a/nvim/m-housh/lua/user/plugin/trouble.lua +++ b/nvim/m-housh/lua/user/plugin/trouble.lua @@ -3,10 +3,9 @@ return { dependencies = { "nvim-tree/nvim-web-devicons" }, event = { "BufReadPre", "BufNewFile" }, keys = { - { "t", "Trouble diagnostics toggle", { desc = "[T]rouble diagnostics" } }, - -- FIX: - These collide with todo-comment keymaps. - --{ "tq", "Trouble quickfix toggle", { desc = "Open a quickfix" } }, - --{ "tl", "Trouble loclist toggle", { desc = "[T]rouble [L]ocation list" } }, + { "d", "Trouble diagnostics toggle", { desc = "Trouble [D]iagnostics" } }, + { "dq", "Trouble quickfix toggle", { desc = "Trouble [Q]uikfix." } }, + { "dl", "Trouble loclist toggle", { desc = "Trouble [L]ocation list" } }, }, opts = {},