From 9308fa14a5e7aefc5ff1984df8f8cf154e139638 Mon Sep 17 00:00:00 2001 From: agres Date: Sat, 4 Oct 2025 23:47:12 +0200 Subject: [PATCH] Updated Neovim config to lua, cleaned up unneccecary plugins --- alacritty/alacritty.toml | 14 --- alacritty/alacritty.yml | 15 --- nvim/init.lua | 16 ++++ nvim/init.vim | 162 --------------------------------- nvim/lazy-lock.json | 25 +++++ nvim/lua/config/cmp.lua | 74 +++++++++++++++ nvim/lua/config/keymaps.lua | 34 +++++++ nvim/lua/config/lsp.lua | 34 +++++++ nvim/lua/config/options.lua | 10 ++ nvim/lua/config/plugins.lua | 94 +++++++++++++++++++ nvim/lua/config/telescope.lua | 25 +++++ nvim/lua/config/treesitter.lua | 16 ++++ 12 files changed, 328 insertions(+), 191 deletions(-) delete mode 100755 alacritty/alacritty.toml delete mode 100755 alacritty/alacritty.yml create mode 100644 nvim/init.lua delete mode 100644 nvim/init.vim create mode 100644 nvim/lazy-lock.json create mode 100644 nvim/lua/config/cmp.lua create mode 100644 nvim/lua/config/keymaps.lua create mode 100644 nvim/lua/config/lsp.lua create mode 100644 nvim/lua/config/options.lua create mode 100644 nvim/lua/config/plugins.lua create mode 100644 nvim/lua/config/telescope.lua create mode 100644 nvim/lua/config/treesitter.lua diff --git a/alacritty/alacritty.toml b/alacritty/alacritty.toml deleted file mode 100755 index 132a6b5..0000000 --- a/alacritty/alacritty.toml +++ /dev/null @@ -1,14 +0,0 @@ -[font] -size = 11.0 - -[font.bold] -family = "JetBrains Mono Nerd Font" -style = "Bold" - -[font.italic] -family = "JetBrains Mono Nerd Font" -style = "Italic" - -[font.normal] -family = "JetBrains Mono Nerd Font" -style = "Regular" diff --git a/alacritty/alacritty.yml b/alacritty/alacritty.yml deleted file mode 100755 index c4d23c7..0000000 --- a/alacritty/alacritty.yml +++ /dev/null @@ -1,15 +0,0 @@ -font: - normal: - family: "JetBrains Mono" - style: "Regular" - - bold: - family: "JetBrains Mono" - style: "Bold" - - italic: - family: "JetBrains Mono" - style: "Italic" - - size: 10.0 # Adjust the font size as needed - diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..4bcc78c --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,16 @@ +-- Set leader key to Space +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +-- Load basic settings +require("config.options") +require("config.keymaps") + +-- Load plugins (lazy.nvim will be auto-installed) +require("config.plugins") + +-- Plugin-specific configuration +require("config.lsp") +require("config.treesitter") +require("config.telescope") +require("config.cmp") diff --git a/nvim/init.vim b/nvim/init.vim deleted file mode 100644 index 79b3412..0000000 --- a/nvim/init.vim +++ /dev/null @@ -1,162 +0,0 @@ -call plug#begin('~/.local/share/nvim/plugged') - -Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} -Plug 'nvim-telescope/telescope.nvim', {'tag': '0.1.0', 'do': ':TSUpdate'} -Plug 'neovim/nvim-lspconfig' -Plug 'lukas-reineke/indent-blankline.nvim' -Plug 'nvim-tree/nvim-tree.lua' - -Plug 'nvim-tree/nvim-web-devicons' " Recommended (for coloured icons) -Plug 'akinsho/bufferline.nvim', { 'tag': '*' } -Plug 'nvim-lualine/lualine.nvim' - -Plug 'lervag/vimtex' " Main LaTeX plugin for compilation and preview -Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} " Ensure Treesitter is installed -Plug 'nvim-treesitter/nvim-treesitter-textobjects' " Better text objects in LaTeX -Plug 'nvim-lua/plenary.nvim' " Dependency for some features -Plug 'nvim-telescope/telescope-bibtex.nvim' " For searching bibliography files -Plug 'godlygeek/tabular' " Table formatting (useful for LaTeX tables) -Plug 'dpelle/vim-LanguageTool' " Grammar and spell checking (supports German) -Plug 'aspeddro/cmp-pandoc.nvim' " Completion for citations in LaTeX - -" LSP and Autocompletion plugins -Plug 'neovim/nvim-lspconfig' " LSP configuration -Plug 'hrsh7th/nvim-cmp' " Completion engine -Plug 'hrsh7th/cmp-nvim-lsp' " LSP completion source -Plug 'hrsh7th/cmp-buffer' " Buffer completion source -Plug 'hrsh7th/cmp-path' " Path completion source -Plug 'saadparwaiz1/cmp_luasnip' " Snippet completion source -Plug 'L3MON4D3/LuaSnip' " Snippet engine -Plug 'onsails/lspkind.nvim' " LSP completion icons - -" Git integration for showing git diff signs -Plug 'airblade/vim-gitgutter' - -let g:indentLine_enabled = 1 -set number - -call plug#end() - -let g:vimtex_view_method = 'zathura' " Use Zathura as PDF viewer (change if needed) -let g:vimtex_compiler_method = 'latexmk' " Continuous compilation -let g:vimtex_quickfix_mode = 0 " Disable quickfix window popups - -" Automatically open quickfix if errors occur -autocmd User VimtexEventCompileFailed cwindow - -set spell -set spelllang=de,en " Enable German and English spell checking - -" Enable treesitter syntax highlighting -lua << EOF - require'nvim-treesitter.configs'.setup { - highlight = { - enable = true, -- Enable highlighting - disable = {}, -- List of languages to disable highlighting (optional) - }, - ensure_installed = { "python", "go", "latex" } -- Automatically install parsers for Python - } -EOF - -" Enable LSP and autocompletion -lua << EOF - -- Set up nvim-cmp (autocompletion) - local cmp = require'cmp' - local lspkind = require'lspkind' - - cmp.setup({ - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) -- For snippet expansion - end, - }, - mapping = { - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm({ select = true }), - }, - sources = { - { name = 'nvim_lsp' }, - { name = 'buffer' }, - { name = 'path' }, - { name = 'luasnip' }, - }, - formatting = { - format = lspkind.cmp_format({ with_text = true, maxwidth = 50 }), - }, - }) - - -- Set up LSP (pyright for Python) - local lspconfig = require'lspconfig' - - -- Python LSP setup - lspconfig.pyright.setup({ - on_attach = function(client, bufnr) - -- Enable diagnostics (squiggles for errors) - vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = true, -- Enable inline error messages (squiggles) - signs = true, -- Enable error/warning signs in the gutter - update_in_insert = false, -- Don't update diagnostics while typing - } - ) - end - }) - - -- Set up Go LSP - lspconfig.gopls.setup({ - on_attach = function(client, bufnr) - vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = true, - signs = true, - update_in_insert = false, - } - ) - end, - settings = { - gopls = { - analyses = { - unusedparams = true, - }, - staticcheck = true, - }, - }, - }) - -EOF - -lua << EOF --- lualine (statusline) -require('lualine').setup() - --- bufferline (tabs) -require('bufferline').setup{} - -require('nvim-web-devicons').setup { - default = true; -- Enables default icons -} - -require("nvim-tree").setup { - view = { - width = 30, - side = "left", - }, - renderer = { - icons = { - show = { - file = true, - folder = true, - folder_arrow = true, - git = true, - }, - }, - }, -} - - -EOF - - diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json new file mode 100644 index 0000000..6d00e0d --- /dev/null +++ b/nvim/lazy-lock.json @@ -0,0 +1,25 @@ +{ + "LuaSnip": { "branch": "master", "commit": "73813308abc2eaeff2bc0d3f2f79270c491be9d7" }, + "barbar.nvim": { "branch": "master", "commit": "549ee11d97057eae207bafa2c23c315942cca097" }, + "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, + "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" }, + "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, + "gitsigns.nvim": { "branch": "main", "commit": "1ee5c1fd068c81f9dd06483e639c2aa4587dc197" }, + "lazy.nvim": { "branch": "main", "commit": "59334064f8604ca073791c25dcc5c9698865406e" }, + "lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" }, + "mini.nvim": { "branch": "main", "commit": "79654ef28182986dcdd9e2d3506d1728fc7c4f79" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "9130e58424ad95bf2dd8b40afbb8cf04d648638c" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, + "nvim-lspconfig": { "branch": "master", "commit": "e688b486fe9291f151eae7e5c0b5a5c4ef980847" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-web-devicons": { "branch": "master", "commit": "b8221e42cf7287c4dcde81f232f58d7b947c210d" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "render-markdown.nvim": { "branch": "main", "commit": "7e6af36c846017122e07e68803bbf95f3c729ca3" }, + "sonokai": { "branch": "master", "commit": "cf50520d1cddf7a4e7bccae650cdf0a6dd362a10" }, + "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, + "tokyonight.nvim": { "branch": "main", "commit": "4d159616aee17796c2c94d2f5f87d2ee1a3f67c7" } +} diff --git a/nvim/lua/config/cmp.lua b/nvim/lua/config/cmp.lua new file mode 100644 index 0000000..fb06f13 --- /dev/null +++ b/nvim/lua/config/cmp.lua @@ -0,0 +1,74 @@ +-- Completion setup for Neovim using nvim-cmp and LuaSnip + +-- Safely import modules +local cmp_status, cmp = pcall(require, "cmp") +if not cmp_status then + return +end + +local snip_status, luasnip = pcall(require, "luasnip") +if not snip_status then + return +end + +-- Load friendly-snippets (optional, prebuilt snippets) +require("luasnip.loaders.from_vscode").lazy_load() + +-- Setup nvim-cmp +cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.complete(), -- Trigger completion menu + [""] = cmp.mapping.confirm({ select = true }), -- Confirm selection + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + + sources = cmp.config.sources({ + { name = "nvim_lsp" }, -- LSP completion + { name = "luasnip" }, -- Snippets + }, { + { name = "buffer" }, -- Words in current buffer + { name = "path" }, -- File system paths + }), + + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + + formatting = { + format = function(entry, vim_item) + vim_item.menu = ({ + nvim_lsp = "[LSP]", + luasnip = "[Snip]", + buffer = "[Buf]", + path = "[Path]", + })[entry.source.name] + return vim_item + end, + }, +}) + diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..13f7859 --- /dev/null +++ b/nvim/lua/config/keymaps.lua @@ -0,0 +1,34 @@ +local map = vim.api.nvim_set_keymap +local opts = { noremap = true, silent = true } + +-- Tabs shortcuts +map('n', '', 'BufferPrevious', opts) +map('n', '', 'BufferNext', opts) +map('n', '', 'BufferGoto 1', opts) +map('n', '', 'BufferGoto 2', opts) +map('n', '', 'BufferGoto 3', opts) +map('n', '', 'BufferGoto 4', opts) +map('n', '', 'BufferGoto 5', opts) +map('n', '', 'BufferGoto 6', opts) +map('n', '', 'BufferGoto 7', opts) +map('n', '', 'BufferGoto 8', opts) +map('n', '', 'BufferGoto 9', opts) +map('n', '', 'BufferLast', opts) + +map('n', '', 'BufferClose', opts) + +map('n', '', 'BufferPick', opts) +map('n', '', 'BufferPickDelete', opts) + +map('n', 'bb', 'BufferOrderByBufferNumber', opts) +map('n', 'bn', 'BufferOrderByName', opts) +map('n', 'bd', 'BufferOrderByDirectory', opts) +map('n', 'bl', 'BufferOrderByLanguage', opts) +map('n', 'bw', 'BufferOrderByWindowNumber', opts) + +-- Toggle Neotree +map('n', 'e', ':Neotree toggle', opts) + +-- Terminal +map('n', 't', ':terminal', opts) + diff --git a/nvim/lua/config/lsp.lua b/nvim/lua/config/lsp.lua new file mode 100644 index 0000000..ce9d652 --- /dev/null +++ b/nvim/lua/config/lsp.lua @@ -0,0 +1,34 @@ +-- Common on_attach handler +local on_attach = function(client, bufnr) + local opts = { buffer = bufnr } + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, opts) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, opts) +end + +-- Configure all your servers +vim.lsp.config("lua_ls", { + on_attach = on_attach, + settings = { + Lua = { diagnostics = { globals = { "vim" } } }, + }, +}) + +vim.lsp.config("pyright", { on_attach = on_attach }) +vim.lsp.config("gopls", { on_attach = on_attach }) +vim.lsp.config("clangd", { on_attach = on_attach }) +vim.lsp.config("omnisharp", { on_attach = on_attach }) +vim.lsp.config("jdtls", { on_attach = on_attach }) +vim.lsp.config("ts_ls", { on_attach = on_attach }) +vim.lsp.config("jsonls", { on_attach = on_attach }) +vim.lsp.config("yamlls", { on_attach = on_attach }) + +-- Enable them all +for _, server in ipairs({ + "lua_ls", "pyright", "gopls", "clangd", + "omnisharp", "jdtls", "ts_ls", "jsonls", "yamlls", +}) do + vim.lsp.enable(server) +end + diff --git a/nvim/lua/config/options.lua b/nvim/lua/config/options.lua new file mode 100644 index 0000000..c1f8b3e --- /dev/null +++ b/nvim/lua/config/options.lua @@ -0,0 +1,10 @@ +vim.opt.number = true +vim.opt.relativenumber = false +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.termguicolors = true +vim.opt.cursorline = true +vim.opt.mouse = "a" +vim.opt.clipboard = "unnamedplus" + diff --git a/nvim/lua/config/plugins.lua b/nvim/lua/config/plugins.lua new file mode 100644 index 0000000..627e077 --- /dev/null +++ b/nvim/lua/config/plugins.lua @@ -0,0 +1,94 @@ +-- Bootstrap lazy.nvim if not installed +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", "clone", "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + lazypath + }) +end +vim.opt.rtp:prepend(lazypath) + +-- Plugins +require("lazy").setup({ + -- Core + "nvim-lua/plenary.nvim", + + -- UI + "nvim-lualine/lualine.nvim", + "nvim-tree/nvim-web-devicons", + + -- Treesitter + { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" }, + + -- Telescope + "nvim-telescope/telescope.nvim", + + -- LSP + "neovim/nvim-lspconfig", + + -- Themes + "folke/tokyonight.nvim", + { + 'sainnhe/sonokai', + lazy = false, + priority = 1000, + config = function() + -- Optionally configure and load the colorscheme + -- directly inside the plugin declaration. + vim.g.sonokai_enable_italic = true + vim.cmd.colorscheme('sonokai') + end + }, + + -- Autocomplete + { + "hrsh7th/nvim-cmp", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + "rafamadriz/friendly-snippets", + }, + + -- Markdown Preview Page + { + 'MeanderingProgrammer/render-markdown.nvim', + dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-mini/mini.nvim'}, -- if you use the mini.nvim suite + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-mini/mini.icons' }, -- if you use standalone mini plugins + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons + ---@module 'render-markdown' + ---@type render.md.UserConfig + opts = {}, + }, + + -- Tabs + { 'romgrk/barbar.nvim', + dependencies = { + 'lewis6991/gitsigns.nvim', -- OPTIONAL: for git status + 'nvim-tree/nvim-web-devicons', -- OPTIONAL: for file icons + }, + init = function() vim.g.barbar_auto_setup = false end, + opts = { + -- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default: + -- animation = true, + -- insert_at_start = true, + -- …etc. + }, + }, + + { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + "nvim-tree/nvim-web-devicons", -- optional, but recommended + }, + lazy = false, -- neo-tree will lazily load itself + }, + +}) + diff --git a/nvim/lua/config/telescope.lua b/nvim/lua/config/telescope.lua new file mode 100644 index 0000000..7d4e087 --- /dev/null +++ b/nvim/lua/config/telescope.lua @@ -0,0 +1,25 @@ +local telescope = require("telescope") + +telescope.setup({ + defaults = { + prompt_prefix = "🔍 ", + selection_caret = " ", + path_display = { "smart" }, + sorting_strategy = "ascending", + layout_config = { prompt_position = "top" }, + }, + pickers = { + find_files = { + hidden = true, -- show hidden files + }, + }, +}) + +-- Optional: keymaps for quick access +local builtin = require("telescope.builtin") +vim.keymap.set("n", "ff", builtin.find_files, { desc = "Find files" }) +vim.keymap.set("n", "fg", builtin.live_grep, { desc = "Grep text" }) +vim.keymap.set("n", "fb", builtin.buffers, { desc = "Find buffers" }) +vim.keymap.set("n", "fh", builtin.help_tags, { desc = "Find help" }) +vim.keymap.set("n", "fr", builtin.oldfiles, { desc = "Recent files" }) + diff --git a/nvim/lua/config/treesitter.lua b/nvim/lua/config/treesitter.lua new file mode 100644 index 0000000..45685ba --- /dev/null +++ b/nvim/lua/config/treesitter.lua @@ -0,0 +1,16 @@ +require("nvim-treesitter.configs").setup({ + ensure_installed = { + -- Programming Languages + "lua", "python", "bash", "javascript", "typescript", + "go", "java", "c", "cpp", "c_sharp", "rust", + + -- Web Languages + "html", "css", "scss", "json", "yaml", "toml", "xml", + + -- Other formats + "markdown", "markdown_inline", "sql", "dockerfile", "gitignore" + }, + highlight = { enable = true }, + indent = { enable = true }, +}) +