From e2a4b535cda6230495554e3a7e162305e8b3203b Mon Sep 17 00:00:00 2001 From: Nicola Belluti Date: Thu, 6 Aug 2026 22:58:57 +0200 Subject: [PATCH] Added lazy.nvim and treesitter --- home/private_dot_config/nvim/init.lua | 60 +---------------- .../private_dot_config/nvim/lua/lazy-nvim.lua | 30 +++++++++ .../nvim/lua/plugins/treesitter.lua | 6 ++ home/private_dot_config/nvim/lua/settings.lua | 64 +++++++++++++++++++ 4 files changed, 102 insertions(+), 58 deletions(-) create mode 100644 home/private_dot_config/nvim/lua/lazy-nvim.lua create mode 100644 home/private_dot_config/nvim/lua/plugins/treesitter.lua create mode 100644 home/private_dot_config/nvim/lua/settings.lua diff --git a/home/private_dot_config/nvim/init.lua b/home/private_dot_config/nvim/init.lua index 63caa23..e10a774 100644 --- a/home/private_dot_config/nvim/init.lua +++ b/home/private_dot_config/nvim/init.lua @@ -1,60 +1,4 @@ --- Enable relative line numbers -vim.opt.number = true -vim.opt.relativenumber = true +require("settings") --- GUI stuff -vim.opt.cursorline = true -- Highlight the current line -vim.opt.colorcolumn = "80,120" -- Show vertical ruler -vim.opt.scrolloff = 8 -- Keep at least 8 lines between the cursor and the borders -vim.opt.wrap = false -- Don't wrap long lines - --- Show whitespace characters (tabs, trailing spaces, etc.) -vim.opt.list = true -vim.opt.listchars = { tab = '» ', trail = '·', multispace = '·', nbsp = '␣' } - --- Strip trailing whitespace and extra blank lines at end of file on save -local trim_group = vim.api.nvim_create_augroup('TrimOnSave', { clear = true }) -vim.api.nvim_create_autocmd('BufWritePre', { - group = trim_group, - pattern = '*', - callback = function() - local save_view = vim.fn.winsaveview() - vim.cmd([[%s/\s\+$//e]]) -- Remove trailing whitespace on every line - vim.cmd([[%s/\n\+\%$//e]]) -- Remove all trailing blank lines - vim.fn.append(vim.fn.line('$'), '') -- Always append exactly one blank line at the end - vim.fn.setpos('.', save_cursor) -- Restore the window to where it was before the edits - end, -}) - --- Remove background opacity -vim.api.nvim_set_hl(0, 'Normal', { bg = 'none' }) -vim.api.nvim_set_hl(0, 'NormalFloat', { bg = 'none' }) - --- Remember old sessions -vim.opt.undofile = true -local restore_cursor_group = vim.api.nvim_create_augroup('RestoreCursor', { clear = true }) -vim.api.nvim_create_autocmd('BufReadPost', { - group = restore_cursor_group, - callback = function() - local mark = vim.api.nvim_buf_get_mark(0, '"') - local last_line = vim.api.nvim_buf_line_count(0) - if mark[1] > 0 and mark[1] <= last_line then - vim.schedule(function() - vim.api.nvim_win_set_cursor(0, mark) - vim.cmd.normal({ 'zz', bang = true }) - end) - end - end, -}) - --- Indentation -vim.opt.tabstop = 4 -- Visual width of a tab character -vim.opt.softtabstop = 4 -- Spaces inserted/deleted per Tab/Backspace in insert mode -vim.opt.shiftwidth = 4 -- Width used by >>, <<, and autoindent -vim.opt.expandtab = true -- Typed tabs become spaces -vim.opt.smartindent = true -- Auto-indent new lines based on syntax (e.g. after '{') - --- Search -vim.opt.ignorecase = true -- Case-insensitive search... -vim.opt.smartcase = true -- ...unless you type an explicit uppercase letter +require("lazy-nvim") diff --git a/home/private_dot_config/nvim/lua/lazy-nvim.lua b/home/private_dot_config/nvim/lua/lazy-nvim.lua new file mode 100644 index 0000000..078ad35 --- /dev/null +++ b/home/private_dot_config/nvim/lua/lazy-nvim.lua @@ -0,0 +1,30 @@ +-- https://lazy.folke.io/installation + +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- Import `plugins/` dir + { import = "plugins" }, + }, + + -- Automatically check for plugin updates + checker = { enabled = true }, +}) + diff --git a/home/private_dot_config/nvim/lua/plugins/treesitter.lua b/home/private_dot_config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..71b8277 --- /dev/null +++ b/home/private_dot_config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,6 @@ +return { + 'nvim-treesitter/nvim-treesitter', + lazy = false, + build = ':TSUpdate' +} + diff --git a/home/private_dot_config/nvim/lua/settings.lua b/home/private_dot_config/nvim/lua/settings.lua new file mode 100644 index 0000000..0ff1dac --- /dev/null +++ b/home/private_dot_config/nvim/lua/settings.lua @@ -0,0 +1,64 @@ +-- Leader key +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Enable relative line numbers +vim.opt.number = true +vim.opt.relativenumber = true + +-- GUI stuff +vim.opt.cursorline = true -- Highlight the current line +vim.opt.colorcolumn = "80,120" -- Show vertical ruler +vim.opt.scrolloff = 8 -- Keep at least 8 lines between the cursor and the borders +vim.opt.wrap = false -- Don't wrap long lines + +-- Show whitespace characters (tabs, trailing spaces, etc.) +vim.opt.list = true +vim.opt.listchars = { tab = '» ', trail = '·', multispace = '·', nbsp = '␣' } + +-- Strip trailing whitespace and extra blank lines at end of file on save +local trim_group = vim.api.nvim_create_augroup('TrimOnSave', { clear = true }) +vim.api.nvim_create_autocmd('BufWritePre', { + group = trim_group, + pattern = '*', + callback = function() + local save_view = vim.fn.winsaveview() + vim.cmd([[%s/\s\+$//e]]) -- Remove trailing whitespace on every line + vim.cmd([[%s/\n\+\%$//e]]) -- Remove all trailing blank lines + vim.fn.append(vim.fn.line('$'), '') -- Always append exactly one blank line at the end + vim.fn.setpos('.', save_cursor) -- Restore the window to where it was before the edits + end, +}) + +-- Remove background opacity +vim.api.nvim_set_hl(0, 'Normal', { bg = 'none' }) +vim.api.nvim_set_hl(0, 'NormalFloat', { bg = 'none' }) + +-- Remember old sessions +vim.opt.undofile = true +local restore_cursor_group = vim.api.nvim_create_augroup('RestoreCursor', { clear = true }) +vim.api.nvim_create_autocmd('BufReadPost', { + group = restore_cursor_group, + callback = function() + local mark = vim.api.nvim_buf_get_mark(0, '"') + local last_line = vim.api.nvim_buf_line_count(0) + if mark[1] > 0 and mark[1] <= last_line then + vim.schedule(function() + vim.api.nvim_win_set_cursor(0, mark) + vim.cmd.normal({ 'zz', bang = true }) + end) + end + end, +}) + +-- Indentation +vim.opt.tabstop = 4 -- Visual width of a tab character +vim.opt.softtabstop = 4 -- Spaces inserted/deleted per Tab/Backspace in insert mode +vim.opt.shiftwidth = 4 -- Width used by >>, <<, and autoindent +vim.opt.expandtab = true -- Typed tabs become spaces +vim.opt.smartindent = true -- Auto-indent new lines based on syntax (e.g. after '{') + +-- Search +vim.opt.ignorecase = true -- Case-insensitive search... +vim.opt.smartcase = true -- ...unless you type an explicit uppercase letter +