about summary refs log tree commit diff stats
path: root/modules/by-name/nv/nvim/plgs/telescope/extensions/bibtex/tex.lua
blob: fbe7c993c5d8b3a326fec981b67d741a05afcf0b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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" }
)