better vimtex forward search with zathura

This commit is contained in:
2025-05-14 16:49:27 +02:00
parent 0f8973d074
commit 5c7fae4de6
3 changed files with 53 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
require'nvim-treesitter.configs'.setup {
-- A list of parser names, or "all" (the five listed parsers should always be installed)
ensure_installed = { "bash", "bibtex", "c", "cpp", "latex", "lua", "markdown", "python", "vim", "vimdoc" },
ensure_installed = { "bash", "bibtex", "c", "cpp", "lua", "markdown", "python", "vim", "vimdoc" },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
@@ -25,16 +25,46 @@ require'nvim-treesitter.configs'.setup {
}
local vim = vim
vim.o.foldmethod = 'expr'
-- Default to treesitter folding
vim.o.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
-- Prefer LSP folding if client supports it
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client:supports_method('textDocument/foldingRange') then
local win = vim.api.nvim_get_current_win()
vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()'
-- vim.o.foldmethod = 'expr'
-- -- Default to treesitter folding
-- vim.o.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
-- -- Prefer LSP folding if client supports it
-- vim.api.nvim_create_autocmd('LspAttach', {
-- callback = function(args)
-- local client = vim.lsp.get_client_by_id(args.data.client_id)
-- if client:supports_method('textDocument/foldingRange') then
-- local win = vim.api.nvim_get_current_win()
-- vim.wo[win][0].foldexpr = 'v:lua.vim.lsp.foldexpr()'
-- end
-- end,
-- })
local opt = vim.opt
local api = vim.api
local M = {}
opt.foldmethod = "expr"
opt.foldexpr = "nvim_treesitter#foldexpr()"
-- function to create a list of commands and convert them to autocommands
-------- This function is taken from https://github.com/norcalli/nvim_utils
function M.nvim_create_augroups(definitions)
for group_name, definition in pairs(definitions) do
api.nvim_command('augroup '..group_name)
api.nvim_command('autocmd!')
for _, def in ipairs(definition) do
local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ')
api.nvim_command(command)
end
end,
})
api.nvim_command('augroup END')
end
end
local autoCommands = {
-- other autocommands
open_folds = {
{"BufReadPost,FileReadPost", "*", "normal zR"}
}
}
M.nvim_create_augroups(autoCommands)

View File

@@ -41,7 +41,15 @@ require('pckr').add{
'lukas-reineke/indent-blankline.nvim';
'JoosepAlviste/nvim-ts-context-commentstring';
'numToStr/Comment.nvim';
'lervag/vimtex';
{
'lervag/vimtex';
config = function()
vim.cmd([[
let g:vimtex_view_method = 'zathura_simple'
let g:vimtex_view_automatic = 0
]])
end,
};
{
'neovim/nvim-lspconfig',
requires = {

View File

@@ -8,6 +8,7 @@ local M = {}
-- Set leader key to space
vim.g.mapleader = " "
vim.g.maplocalleader = ";"
-- Set Explorer keybind to leader-"e"
vim.keymap.set("n","<leader>e", vim.cmd.Ex)