summaryrefslogtreecommitdiffstats
path: root/modules/by-name/nv/nvim/plgs/telescope/extensions/ext/bibtex
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/bibtex
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/bibtex')
-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
2 files changed, 104 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" }
+)