From e870d7408b5b47bb0ba80e0749a35c428c9f2bde Mon Sep 17 00:00:00 2001 From: Thomas Naderer Date: Wed, 18 Dec 2024 16:45:53 +0100 Subject: [PATCH] Working NeoVim-Configuration, this should be the base for further enhancements --- nvim/init.lua | 132 ++++++++++++++++++++++++++++++++ nvim/lua/plugins/lualine.lua | 42 ++++++++++ nvim/lua/plugins/nvim-tree.lua | 73 ++++++++++++++++++ nvim/lua/plugins/treesitter.lua | 25 ++++++ nvim/lua/plugins/vimtex.lua | 50 ++++++++++++ 5 files changed, 322 insertions(+) create mode 100644 nvim/init.lua create mode 100644 nvim/lua/plugins/lualine.lua create mode 100644 nvim/lua/plugins/nvim-tree.lua create mode 100644 nvim/lua/plugins/treesitter.lua create mode 100644 nvim/lua/plugins/vimtex.lua diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..f225ba8 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,132 @@ +-- Initialize packer +vim.cmd [[packadd packer.nvim]] +vim.g.mapleader = " " -- Set the leader key to space +vim.cmd [[colorscheme tokyonight]] +require('packer').startup(function(use) + use 'wbthomason/packer.nvim' -- Packer manages itself + -- VIM AutoSave + use({ + "okuuva/auto-save.nvim", + tag = 'v1*', + config = function() + require("auto-save").setup({ + -- your config goes here + -- or just leave it empty :) + }) + end, + }) + -- Headlines for Markdown and TeX + use { + "lukas-reineke/headlines.nvim", + after = "nvim-treesitter", + config = function() + require("headlines").setup() + end, + } + -- Nvim-Tree + use { + 'nvim-tree/nvim-tree.lua', + config = function() + require("nvim-tree").setup() + end + } + -- Themes + use 'gruvbox-community/gruvbox' -- Gruvbox theme + use 'folke/tokyonight.nvim' -- Tokyo Night theme + + -- Treesitter + use { + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate' -- Keep parsers up to date + } + use 'HiPhish/rainbow-delimiters.nvim' + + -- Git Integration + use 'lewis6991/gitsigns.nvim' -- Git decorations in the gutter + use 'tpope/vim-fugitive' -- Git commands in Neovim + + -- Status Line + use { + 'nvim-lualine/lualine.nvim', + requires = { 'kyazdani42/nvim-web-devicons', opt = true } -- Optional icons + } + -- FZF + use { + 'junegunn/fzf', + run = function() vim.fn['fzf#install']() end + } + use 'junegunn/fzf.vim' + + -- Cool Startup Dashboard + use { + 'glepnir/dashboard-nvim', + requires = { 'kyazdani42/nvim-web-devicons' } + } + + -- Productivity + use 'numToStr/Comment.nvim' -- Easy commenting + use 'windwp/nvim-autopairs' -- Auto-close brackets, quotes, etc. + use 'tpope/vim-surround' -- Surround text objects with quotes, brackets, etc. + + --LaTeX + use 'lervag/vimtex' + require('plugins.vimtex') + -- Telescope + use { + 'nvim-telescope/telescope.nvim', + requires = { {'nvim-lua/plenary.nvim'} }, + config = function() + -- Leader key mappings for Telescope + vim.api.nvim_set_keymap('n', 'ff', ':Telescope find_files', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'fg', ':Telescope live_grep', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'fb', ':Telescope buffers', { noremap = true, silent = true }) + vim.api.nvim_set_keymap('n', 'fh', ':Telescope help_tags', { noremap = true, silent = true }) + end + } + + +-- This module contains a number of default definitions +local rainbow_delimiters = require 'rainbow-delimiters' + +---@type rainbow_delimiters.config +vim.g.rainbow_delimiters = { + strategy = { + [''] = rainbow_delimiters.strategy['global'], + vim = rainbow_delimiters.strategy['local'], + }, + query = { + [''] = 'rainbow-delimiters', + lua = 'rainbow-blocks', + }, + priority = { + [''] = 110, + lua = 210, + }, + highlight = { + 'RainbowDelimiterRed', + 'RainbowDelimiterYellow', + 'RainbowDelimiterBlue', + 'RainbowDelimiterOrange', + 'RainbowDelimiterGreen', + 'RainbowDelimiterViolet', + 'RainbowDelimiterCyan', + }, +} +use { + 'hedyhli/outline.nvim', + config = function() + require('outline').setup({ + -- You can customize the plugin options here + show_guides = true, -- Show outline guides + auto_close = false, -- Do not auto-close the outline + auto_open = true, -- Automatically open the outline + preview_lines = 10, -- Number of preview lines + keymaps = { -- Custom key mappings for the outline + jump = 'o', -- Jump to the selected item + expand_collapse = 'u', -- Expand or collapse an item + }, + }) + end +} +end +) diff --git a/nvim/lua/plugins/lualine.lua b/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..4b3de12 --- /dev/null +++ b/nvim/lua/plugins/lualine.lua @@ -0,0 +1,42 @@ +require('lualine').setup { + options = { + icons_enabled = true, + theme = 'auto', + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + always_show_tabline = true, + globalstatus = false, + refresh = { + statusline = 100, + tabline = 100, + winbar = 100, + } + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'fileformat', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} +} + diff --git a/nvim/lua/plugins/nvim-tree.lua b/nvim/lua/plugins/nvim-tree.lua new file mode 100644 index 0000000..d6ebeec --- /dev/null +++ b/nvim/lua/plugins/nvim-tree.lua @@ -0,0 +1,73 @@ +-- File: ~/.config/nvim/lua/plugins/nvim-tree.lua + +-- Keybinding to toggle Nvim Tree +vim.api.nvim_set_keymap('n', 'e', ':NvimTreeToggle', { noremap = true, silent = true }) + +-- Nvim Tree Configuration +require("nvim-tree").setup({ + view = { + width = 35, + side = "left", + adaptive_size = true, + mappings = { + list = { + { key = "l", action = "edit" }, + { key = "h", action = "close_node" }, + { key = "v", action = "vsplit" }, + { key = "a", action = "create" }, + { key = "d", action = "remove" }, + { key = "r", action = "rename" }, + }, + }, + }, + renderer = { + highlight_git = true, + highlight_opened_files = "all", + icons = { + glyphs = { + default = "", + symlink = "", + folder = { + arrow_closed = "", + arrow_open = "", + default = "", + open = "", + }, + git = { + unstaged = "✗", + staged = "✓", + unmerged = "", + renamed = "➜", + untracked = "★", + deleted = "", + ignored = "◌", + }, + }, + }, + indent_markers = { + enable = true, + }, + }, + diagnostics = { + enable = true, + show_on_dirs = true, + icons = { + hint = "", + info = "", + warning = "", + error = "", + }, + }, + filters = { + dotfiles = false, + }, + actions = { + open_file = { + quit_on_open = true, + }, + }, + git = { + enable = true, + ignore = false, + }, +}) diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..f7932b2 --- /dev/null +++ b/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,25 @@ +require'nvim-treesitter.configs'.setup { + ensure_installed = { "c", "lua", "python", "javascript", "markdown", "html", "css"}, -- Add languages you use + sync_install = false, -- Install parsers asynchronously + auto_install = true, -- Automatically install missing parsers + + highlight = { + enable = true, -- Enable syntax highlighting + additional_vim_regex_highlighting = false, -- Avoid slow fallback regex highlighting + }, + + indent = { + enable = true -- Enable indentation support + }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, +} + diff --git a/nvim/lua/plugins/vimtex.lua b/nvim/lua/plugins/vimtex.lua new file mode 100644 index 0000000..7b4eb8b --- /dev/null +++ b/nvim/lua/plugins/vimtex.lua @@ -0,0 +1,50 @@ +-- File: ~/.config/nvim/lua/plugins/vimtex.lua + +-- VimTeX Configuration +vim.g.vimtex_view_method = 'skim' -- Use Skim as the PDF viewer +vim.g.vimtex_view_skim_sync = 1 -- Enable forward search with Skim +vim.g.vimtex_view_skim_activate = 1 -- Activate Skim on compilation + +vim.g.vimtex_compiler_method = 'latexmk' -- Use latexmk for LaTeX compilation +vim.g.vimtex_quickfix_mode = 0 -- Disable automatic quickfix window +vim.g.vimtex_syntax_enabled = 1 -- Enable VimTeX syntax highlighting + +-- Custom TeX Engine Commands +vim.api.nvim_create_user_command( + 'LuaTeX', + '!lualatex %', + { nargs = 0 } +) + +vim.api.nvim_create_user_command( + 'XeTeX', + '!xelatex %', + { nargs = 0 } +) + +vim.api.nvim_create_user_command( + 'PdfLaTeX', + '!pdflatex %', + { nargs = 0 } +) + +-- View PDF Command +vim.api.nvim_create_user_command( + 'ViewPDF', + '!open -a Skim ' .. vim.fn.expand('%:r') .. '.pdf', + { nargs = 0 } +) + +-- Check for Errors in Log File +vim.api.nvim_create_user_command( + 'CheckErrors', + '!grep -i error %.log || echo "No errors found!"', + { nargs = 0 } +) + +-- Keybindings for TeX Workflow +vim.keymap.set('n', 'll', ':LuaTeX', { noremap = true, silent = true }) +vim.keymap.set('n', 'lx', ':XeTeX', { noremap = true, silent = true }) +vim.keymap.set('n', 'lp', ':PdfLaTeX', { noremap = true, silent = true }) +vim.keymap.set('n', 'lv', ':ViewPDF', { noremap = true, silent = true }) +vim.keymap.set('n', 'le', ':CheckErrors', { noremap = true, silent = true })