summaryrefslogtreecommitdiffstats
path: root/modules/by-name/nv/nvim/plgs/telescope/extensions/ext
diff options
context:
space:
mode:
authorSoispha Peetz <soispha@b-peetz.de>2026-11-26 01:07:25 +0100
committerSoispha Peetz <soispha@b-peetz.de>2026-11-28 23:58:38 +0100
commit4fc9dd3bbb56a0f976733b5169be58820ed5be6f (patch)
tree10f50bcfeee265d526e9471829c7db6ac0f5e9f7 /modules/by-name/nv/nvim/plgs/telescope/extensions/ext
parentmodules/dns: Also use a resolving dns server (diff)
downloadnixos-config-4fc9dd3bbb56a0f976733b5169be58820ed5be6f.zip
modules/nvim: Import all the modules via mkMerge
This means that we use only one `lib.mkIf cfg.enable`, so when there is no nixvim module loaded it does not error.
Diffstat (limited to 'modules/by-name/nv/nvim/plgs/telescope/extensions/ext')
-rw-r--r--modules/by-name/nv/nvim/plgs/telescope/extensions/ext/bibtex/default.nix34
-rw-r--r--modules/by-name/nv/nvim/plgs/telescope/extensions/ext/bibtex/tex.lua70
-rw-r--r--modules/by-name/nv/nvim/plgs/telescope/extensions/ext/frecency/default.nix31
-rw-r--r--modules/by-name/nv/nvim/plgs/telescope/extensions/ext/fzy-native/default.nix14
-rw-r--r--modules/by-name/nv/nvim/plgs/telescope/extensions/ext/rooter/default.nix16
-rw-r--r--modules/by-name/nv/nvim/plgs/telescope/extensions/ext/rooter/lua/rooter.lua86
6 files changed, 251 insertions, 0 deletions
diff --git a/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/bibtex/default.nix b/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/bibtex/default.nix
new file mode 100644
index 00000000..c2fea575
--- /dev/null
+++ b/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/bibtex/default.nix
@@ -0,0 +1,34 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+{...}: {
+ # TODO: Re-enable this, once the plugin is merged into nixpkgs <2025-03-29>
+ # home-manager.users.soispha.programs.nixvim = lib.mkIf cfg.enable {
+ # extraPlugins = [
+ # pkgs.vimExtraPlugins.telescope-bibtex-nvim
+ # ];
+ #
+ # # Only activate this in tex files.
+ # extraFiles = {
+ # "ftplugin/tex.lua".text = ''
+ # ${lib.strings.fileContents ./tex.lua}
+ # '';
+ # };
+ #
+ # keymaps = [
+ # {
+ # key = "<space>ib";
+ # # This is registered in the ftplugin file, so we set this to null here
+ # action = "<Nop>";
+ # mode = "n";
+ # options.desc = "[i]nsert a [b]atex citation";
+ # }
+ # ];
+ # };
+}
diff --git a/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/bibtex/tex.lua b/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/bibtex/tex.lua
new file mode 100644
index 00000000..fbe7c993
--- /dev/null
+++ b/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/bibtex/tex.lua
@@ -0,0 +1,70 @@
+-- nixos-config - My current NixOS configuration
+--
+-- Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+-- SPDX-License-Identifier: GPL-3.0-or-later
+--
+-- This file is part of my nixos-config.
+--
+-- You should have received a copy of the License along with this program.
+-- If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+
+-- local used = false;
+-- vim.keymap.set('n', '<leader>t', function()
+-- used = not used;
+-- if used then
+-- require('nvim-treesitter.configs').setup {
+-- highlight = {
+-- additional_vim_regex_highlighting = { "latex", "markdown" },
+-- },
+-- }
+-- else
+-- require('nvim-treesitter.configs').setup {
+-- highlight = {
+-- additional_vim_regex_highlighting = { "" },
+-- },
+-- }
+-- end
+-- end
+-- );
+--
+--
+
+-- Set tex specific telescope extension
+require("telescope").setup({
+ extensions = {
+ bibtex = {
+ -- Depth for the *.bib file
+ depth = 1,
+ -- Path to global bibliographies (placed outside of the project)
+ global_files = {},
+ -- Define the search keys to use in the picker
+ search_keys = { "author", "year", "title" },
+ -- Template for the formatted citation
+ citation_format = "{{author}} ({{year}}), {{title}}.",
+ -- Only use initials for the authors first name
+ citation_trim_firstname = true,
+ -- Max number of authors to write in the formatted citation
+ -- following authors will be replaced by "et al."
+ citation_max_auth = 2,
+ -- Wrapping in the preview window is disabled by default
+ wrap = false,
+ -- Custom format for citation label
+ custom_formats = {
+ { id = "tex_autocite", cite_marker = "\\autocite{%s}" },
+ },
+ format = "tex_autocite",
+ -- Use context awareness
+ context = true,
+ -- Fallback to global/directory .bib files if context not found
+ -- This setting has no effect if context = false
+ context_fallback = true,
+ },
+ },
+})
+require("telescope").load_extension("bibtex")
+vim.keymap.set(
+ "n",
+ "<leader>ib",
+ function() require("telescope").extensions.bibtex.bibtex() end,
+ { noremap = true, silent = true, desc = "list bibtex entries in telescope" }
+)
diff --git a/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/frecency/default.nix b/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/frecency/default.nix
new file mode 100644
index 00000000..83a4ed3d
--- /dev/null
+++ b/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/frecency/default.nix
@@ -0,0 +1,31 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+{...}: {
+ home-manager.users.soispha.programs.nixvim = {
+ keymaps = [
+ {
+ key = "gff";
+ mode = "n";
+ action.__raw = "function() require('telescope').extensions.frecency.frecency() end";
+ options.desc = "activate the frecency file selection";
+ }
+ ];
+ plugins.telescope = {
+ extensions.frecency = {
+ enable = true;
+ settings = {
+ show_scores = true;
+ db_safe_mode = false;
+ default_workspace = "CWD"; # or 'LSP'
+ };
+ };
+ };
+ };
+}
diff --git a/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/fzy-native/default.nix b/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/fzy-native/default.nix
new file mode 100644
index 00000000..1b173516
--- /dev/null
+++ b/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/fzy-native/default.nix
@@ -0,0 +1,14 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+{...}: {
+ home-manager.users.soispha.programs.nixvim.plugins.telescope.extensions.fzy-native = {
+ enable = true;
+ };
+}
diff --git a/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/rooter/default.nix b/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/rooter/default.nix
new file mode 100644
index 00000000..de1aa929
--- /dev/null
+++ b/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/rooter/default.nix
@@ -0,0 +1,16 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+{lib, ...}: {
+ home-manager.users.soispha.programs.nixvim = {
+ extraConfigLuaPost = ''
+ ${lib.strings.fileContents ./lua/rooter.lua}
+ '';
+ };
+}
diff --git a/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/rooter/lua/rooter.lua b/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/rooter/lua/rooter.lua
new file mode 100644
index 00000000..b6542429
--- /dev/null
+++ b/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/rooter/lua/rooter.lua
@@ -0,0 +1,86 @@
+-- nixos-config - My current NixOS configuration
+--
+-- Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+-- SPDX-License-Identifier: GPL-3.0-or-later
+--
+-- This file is part of my nixos-config.
+--
+-- You should have received a copy of the License along with this program.
+-- If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+
+-- Taken from: https://github.com/desdic/telescope-rooter.nvim/blob/69423216c75a5f1f1477bbf8faf6b0dc8af04099/lua/telescope/_extensions/rooter.lua
+local has_telescope, telescope = pcall(require, "telescope")
+if not has_telescope then
+ error("This extension requires telescope.nvim")
+ return
+end
+
+local has_plenary, plenary = pcall(require, "plenary")
+if not has_plenary then
+ error("This extension requires plenary")
+ return
+end
+
+local log = plenary.log.new({ plugin = "telescope_rooter", level = "info" })
+
+-- TODO: expose this function
+local toggle = function(_)
+ vim.g["Telescope#rooter#enabled"] = not vim.g["Telescope#rooter#enabled"]
+ print("Telescope#rooter#enabled=" .. vim.inspect(vim.g["Telescope#rooter#enabled"]))
+end
+
+local config = { patterns = { ".git" }, enable = true, debug = false }
+
+-- default enabled
+vim.g["Telescope#rooter#enabled"] = vim.F.if_nil(config.enable, true)
+
+-- redefine log if debug enabled
+if vim.F.if_nil(config.debug, false) then log = plenary.log.new({ plugin = "telescope_rooter", level = "debug" }) end
+
+local group = vim.api.nvim_create_augroup("TelescopeRooter", { clear = true })
+
+vim.api.nvim_create_autocmd({ "DirChangedPre" }, {
+ callback = function()
+ if vim.g["Telescope#rooter#enabled"] ~= true then return end
+
+ if vim.g["Telescope#rooter#oldpwd"] == nil then
+ vim.g["Telescope#rooter#oldpwd"] = vim.loop.cwd()
+ log.debug("before " .. vim.inspect(vim.loop.cwd()))
+ end
+ end,
+ group = group,
+})
+
+vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
+ callback = function()
+ if vim.g["Telescope#rooter#enabled"] ~= true then return end
+
+ vim.schedule(function()
+ if vim.bo.filetype == "TelescopePrompt" then
+ local rootdir = vim.fs.dirname(vim.fs.find(config.patterns, { upward = true })[1])
+ if rootdir ~= nil then
+ vim.api.nvim_set_current_dir(rootdir)
+ log.debug("changing dir to " .. rootdir)
+ end
+ end
+ end)
+ end,
+ group = group,
+})
+
+vim.api.nvim_create_autocmd({ "BufWinLeave" }, {
+ callback = function()
+ if vim.g["Telescope#rooter#enabled"] ~= true then return end
+
+ vim.schedule(function()
+ if vim.bo.filetype ~= "TelescopePrompt" then
+ if vim.g["Telescope#rooter#oldpwd"] ~= nil then
+ log.debug("restoring " .. vim.g["Telescope#rooter#oldpwd"])
+ vim.api.nvim_set_current_dir(vim.g["Telescope#rooter#oldpwd"])
+ vim.g["Telescope#rooter#oldpwd"] = nil
+ end
+ end
+ end)
+ end,
+ group = group,
+})