diff --git a/.config/nvim/after/plugin/treesitter.lua b/.config/nvim/after/plugin/treesitter.lua index 12f5b00..9acf937 100644 --- a/.config/nvim/after/plugin/treesitter.lua +++ b/.config/nvim/after/plugin/treesitter.lua @@ -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) diff --git a/.config/nvim/lua/config/pckr.lua b/.config/nvim/lua/config/pckr.lua index 073bd48..ab280f6 100644 --- a/.config/nvim/lua/config/pckr.lua +++ b/.config/nvim/lua/config/pckr.lua @@ -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 = { diff --git a/.config/nvim/lua/config/remap.lua b/.config/nvim/lua/config/remap.lua index dd9653c..db3ee7f 100644 --- a/.config/nvim/lua/config/remap.lua +++ b/.config/nvim/lua/config/remap.lua @@ -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","e", vim.cmd.Ex)