From 4611552b1590072abc099e42f674a812d57be4d2 Mon Sep 17 00:00:00 2001 From: Anthony Cicchetti Date: Thu, 17 Aug 2023 09:45:37 -0400 Subject: [PATCH] telescope, no more ctrl-p --- nix/home-manager/flake.lock | 12 +-- nix/home-manager/modules/packages/neovim.nix | 74 ++++++++++++------- .../modules/packages/neovim/core.lua | 5 -- .../modules/packages/neovim/telescope.lua | 20 +++++ 4 files changed, 74 insertions(+), 37 deletions(-) create mode 100644 nix/home-manager/modules/packages/neovim/telescope.lua diff --git a/nix/home-manager/flake.lock b/nix/home-manager/flake.lock index d0c7537..a20abec 100644 --- a/nix/home-manager/flake.lock +++ b/nix/home-manager/flake.lock @@ -118,11 +118,11 @@ ] }, "locked": { - "lastModified": 1692131549, - "narHash": "sha256-MFjI8NL63/6HjMZpvJgnB/Pgg2dht22t45jOYtipZig=", + "lastModified": 1692260837, + "narHash": "sha256-2FpkX1zl+7ni7djK7NeE1ZGupRUwZgjW+RPCSBgDf4k=", "owner": "nix-community", "repo": "home-manager", - "rev": "75cfe974e2ca05a61b66768674032b4c079e55d4", + "rev": "6a94c1a59737783c282c4031555a289c28b961e4", "type": "github" }, "original": { @@ -333,11 +333,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1692084312, - "narHash": "sha256-Za++qKVK6ovjNL9poQZtLKRM/re663pxzbJ+9M4Pgwg=", + "lastModified": 1692174805, + "narHash": "sha256-xmNPFDi/AUMIxwgOH/IVom55Dks34u1g7sFKKebxUm0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "8353344d3236d3fda429bb471c1ee008857d3b7c", + "rev": "caac0eb6bdcad0b32cb2522e03e4002c8975c62e", "type": "github" }, "original": { diff --git a/nix/home-manager/modules/packages/neovim.nix b/nix/home-manager/modules/packages/neovim.nix index cbd84ec..f2c44fa 100644 --- a/nix/home-manager/modules/packages/neovim.nix +++ b/nix/home-manager/modules/packages/neovim.nix @@ -16,6 +16,9 @@ onedark.enable = true; }; plugins = { + fugitive = { + enable = true; + }; lsp = { enable = true; servers = { @@ -26,6 +29,33 @@ rust-analyzer.enable = true; }; }; + mini = { + enable = true; + ai.enable = true; + align.enable = true; + animate.enable = true; + comment.enable = true; + completion.enable = true; + indentscope.enable = true; + jump.enable = true; + jump2d = { + enable = true; + extraConfig = { + mappings.start_jumping = "a"; + }; + }; + splitjoin.enable = true; + surround.enable = true; + }; + project-nvim = { + enable = true; + }; + telescope = { + enable = true; + extraLua = { + post = builtins.readFile ./neovim/telescope.lua; + }; + }; treesitter = { enable = true; indent = true; @@ -34,46 +64,32 @@ enable = true; }; }; - mini = { - enable = true; - ai.enable = true; - align.enable = true; - animate.enable = true; - comment.enable = true; - jump.enable = true; - jump2d = { - enable = true; - extraConfig = { - mappings.start_jumping = "a"; - }; - }; - surround.enable = true; - }; - fugitive = { - enable = true; - }; undotree = { enable = true; }; which-key = { enable = true; - }; - project-nvim = { - enable = true; + groups = { + normal = { + "f" = "Telescope - Find"; + "r" = "View registers"; + "p" = "Telescope - LSP"; + }; + }; }; }; extraPlugins = ( with pkgs.vimPlugins; [ - vim-ReplaceWithRegister - ctrlp-vim - vim-dispatch-neovim - vim-bbye editorconfig-nvim + leap-nvim + telescope-zf-native-nvim + vim-ReplaceWithRegister + vim-bbye + vim-dispatch-neovim vim-expand-region vim-signify vim-terraform - leap-nvim ] ) ++ (with pkgs.vimExtraPlugins; [ @@ -83,18 +99,23 @@ normal = { "u" = { action = "vim.cmd.UndotreeToggle"; + desc = "Toggle undotree"; }; "h" = { action = "function() vim.api.nvim_command('wincmd h') end"; + desc = "Cursor - Window left"; }; "j" = { action = "function() vim.api.nvim_command('wincmd j') end"; + desc = "Cursor - Window down"; }; "k" = { action = "function() vim.api.nvim_command('wincmd k') end"; + desc = "Cursor - Window up"; }; "l" = { action = "function() vim.api.nvim_command('wincmd l') end"; + desc = "Cursor - Window right"; }; "" = { action = "''"; @@ -104,6 +125,7 @@ }; "n" = { action = "function() vim.api.nvim_command('nohl') end"; + desc = "nohl"; }; }; visual = { diff --git a/nix/home-manager/modules/packages/neovim/core.lua b/nix/home-manager/modules/packages/neovim/core.lua index e44b3ad..558347b 100644 --- a/nix/home-manager/modules/packages/neovim/core.lua +++ b/nix/home-manager/modules/packages/neovim/core.lua @@ -27,8 +27,3 @@ vim.o.wildmode = "list:longest,full" vim.api.nvim_create_autocmd('TextYankPost', { callback = function() vim.highlight.on_yank() end }) - --- Ctrlp -vim.g.ctrlp_map = "p" -vim.g.ctrlp_cmd = "CtrlPMixed" -vim.g.ctrlp_user_command = "rg --files %s" diff --git a/nix/home-manager/modules/packages/neovim/telescope.lua b/nix/home-manager/modules/packages/neovim/telescope.lua new file mode 100644 index 0000000..f251858 --- /dev/null +++ b/nix/home-manager/modules/packages/neovim/telescope.lua @@ -0,0 +1,20 @@ +require("telescope").load_extension("zf-native") + +local builtin = require('telescope.builtin') + +-- greps +vim.keymap.set("n", 'ff', builtin.find_files, {desc = 'Find Files'}) +vim.keymap.set("n", 'fg', builtin.live_grep, {desc = 'Live Grep'}) +vim.keymap.set("n", 'fb', builtin.buffers, {desc = 'Buffers'}) + +-- register reading +vim.keymap.set("n", 'r', builtin.registers, {desc = 'View registers'}) + +-- lsp stuff +vim.keymap.set('n', 'pr', builtin.lsp_references, {desc = 'References'}) +vim.keymap.set('n', 'pi', builtin.lsp_implementations, {desc = 'Implementations'}) +vim.keymap.set('n', 'pd', builtin.lsp_definitions, {desc = 'Definitions'}) +vim.keymap.set('n', 'ps', builtin.lsp_document_symbols, {desc = 'Document Symbols'}) +vim.keymap.set('n', 'pws', builtin.lsp_workspace_symbols, {desc = 'Workspace Symbols'}) +vim.keymap.set('n', 'pwd', builtin.lsp_dynamic_workspace_symbols, {desc = 'Dynamic Workspace Symbols'}) +