From 1622e731e44bb3ebe4805511cb5da7199172b28b Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 25 Dec 2024 19:14:39 +0100 Subject: [PATCH] Add telescope --- nvim/default.nix | 7 +++++ nvim/lua/plugins/colors.lua | 7 +++-- nvim/lua/plugins/telescope.lua | 49 ++++++++++++++++++++++++++++++++++ nvim/mknvim.nix | 4 ++- 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 nvim/lua/plugins/telescope.lua diff --git a/nvim/default.nix b/nvim/default.nix index f11d7fc..098846d 100644 --- a/nvim/default.nix +++ b/nvim/default.nix @@ -19,12 +19,19 @@ in lz-n catppuccin-nvim nvim-treesitter.withAllGrammars + plenary-nvim ]; opts = [ + telescope-nvim + telescope-fzf-native-nvim ]; }; extraPackages = with pkgs; [ + # telescope helpers + fd + ripgrep + # lsp # see for helpers https://github.com/dundalek/lazy-lsp.nvim/blob/master/lua/lazy-lsp/servers.lua haskell-language-server diff --git a/nvim/lua/plugins/colors.lua b/nvim/lua/plugins/colors.lua index b22e322..2c59b4b 100644 --- a/nvim/lua/plugins/colors.lua +++ b/nvim/lua/plugins/colors.lua @@ -2,11 +2,14 @@ return { { "catppuccin-nvim", -- colorscheme = "catppuccin", - load = function()end, + load = function() end, priority = 1000, opt = { integrations = { - treesitter = true + telescope = { + enabled = true, + style = "nvchad" + } }, }, after = function(plug) diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..78fb940 --- /dev/null +++ b/nvim/lua/plugins/telescope.lua @@ -0,0 +1,49 @@ +return { + { + "telescope.nvim", + cmd = "Telescope", + keys = { + { "f", "Telescope find_files", desc = "Find Files" }, + { "F", "Telescope live_grep theme=ivy", desc = "Grep" }, + { "gl", "Telescope git_commits", desc = "Git log" }, + { "gh", "Telescope git_bcommits", desc = "Git history" }, + { "gB", "Telescope git_branches", desc = "Git branches" }, + { "gs", "Telescope git_status", desc = "Git status" }, + { "gc", "Telescope git_show", desc = "Show last commit" }, + { "zh", "Telescope help_tags", desc = "Read help" }, + }, + after = function() + local actions = require("telescope.actions") + + local telescope = require("telescope") + telescope.setup({ + defaults = { + prompt_prefix = " ", + selection_caret = " ", + sorting_strategy = "ascending", + layout_config = { + horizontal = { + prompt_position = "top", + } + }, + mappings = { + i = { + [""] = actions.close, + [""] = actions.close, + }, + } + }, + pickers = { + find_files = { + hidden = true, + -- remove .git directory + find_command = { "fd", "--type", "f", "--strip-cwd-prefix", "-E", ".git" }, + }, + }, + }) + + vim.cmd.packadd("telescope-fzf-native.nvim") + telescope.load_extension("fzf") + end + }, +} diff --git a/nvim/mknvim.nix b/nvim/mknvim.nix index 8d2482c..ede4aae 100644 --- a/nvim/mknvim.nix +++ b/nvim/mknvim.nix @@ -48,8 +48,10 @@ nvim = builder.byteCompileVim package; + removeDependencies = p: p // {plugin = p.plugin.overrideAttrs (prev: prev // {dependencies = [];});}; + start = map (p: lib.pipe p [(normalize false) builder.byteCompile]) plugins.start; - opts = map (p: lib.pipe p [(normalize true) builder.byteCompile]) plugins.opts; + opts = map (p: lib.pipe p [(normalize true) removeDependencies builder.byteCompile]) plugins.opts; startPacked = pack.packPlugins start; in pkgs.wrapNeovimUnstable nvim {