From 535de78034b347a3407aa6ff5287a1b4897172ea Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Fri, 22 Mar 2024 01:25:05 +0100 Subject: First commit! --- lua/user/init.lua | 31 ++++++++++++++++ lua/user/lazy.lua | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ lua/user/map.lua | 78 +++++++++++++++++++++++++++++++++++++++++ lua/user/set.lua | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 308 insertions(+) create mode 100644 lua/user/init.lua create mode 100644 lua/user/lazy.lua create mode 100644 lua/user/map.lua create mode 100644 lua/user/set.lua (limited to 'lua') diff --git a/lua/user/init.lua b/lua/user/init.lua new file mode 100644 index 0000000..2b94d59 --- /dev/null +++ b/lua/user/init.lua @@ -0,0 +1,31 @@ +require("user.set") +require("user.map") +require("user.lazy") + +local autocmd = vim.api.nvim_create_autocmd + +local function augroup(name) + return vim.api.nvim_create_augroup("user_" .. name, { clear = true }) +end + +-- [[ Highlight on yank ]] +autocmd("TextYankPost", { + group = augroup("highlight_yank"), + callback = function() + vim.highlight.on_yank() + end, +}) + +-- [[ Auto create parent directory if it doesn't exist ]] +autocmd({ "BufWritePre" }, { + group = augroup("auto_create_dir"), + callback = function(event) + if event.match:match("^%w%w+://") then + return + end + local file = vim.loop.fs_realpath(event.match) or event.match + vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") + end, +}) + +vim.cmd("colorscheme nord") diff --git a/lua/user/lazy.lua b/lua/user/lazy.lua new file mode 100644 index 0000000..8c4fc3d --- /dev/null +++ b/lua/user/lazy.lua @@ -0,0 +1,103 @@ +-- bootstraping +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", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +-- plugins installation and configuration +require("lazy").setup({ + -- lsp setup + { + -- LSP Support + "neovim/nvim-lspconfig", + -- lsp download manager + "williamboman/mason.nvim", + -- automatic lsp setup + "williamboman/mason-lspconfig.nvim", + -- additional formater support + "stevearc/conform.nvim", + -- additional linter support + "mfussenegger/nvim-lint", + -- mason autoinstaller for formatter's and linter's + "WhoIsSethDaniel/mason-tool-installer.nvim", + -- minimal snippet's support + "dcampos/nvim-snippy", + -- basic snippet's + "honza/vim-snippets", + -- cmp for autocompletion + "hrsh7th/nvim-cmp", + -- cmp nvim-lsp plugin + "hrsh7th/cmp-nvim-lsp", + -- cmp snippy support + "dcampos/cmp-snippy", + -- path comletion + "hrsh7th/cmp-path", + -- kind icons + "onsails/lspkind.nvim", + }, + -- Adds git related signs to the gutter, as well as utilities for managing changes + "lewis6991/gitsigns.nvim", + + -- better ntrw + "tpope/vim-vinegar", + + -- integration with tmux keybinds + "christoomey/vim-tmux-navigator", + + -- nord color theme + "shaunsingh/nord.nvim", + + -- auto close brackets + "m4xshen/autoclose.nvim", + + -- Fuzzy Finder (files, lsp, etc) + { + "nvim-telescope/telescope.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope-ui-select.nvim", + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + }, + }, + }, + + { + -- Highlight, edit, and navigate code + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + }, + + { + -- harpoon your way around code + { + "ThePrimeagen/harpoon", + branch = "harpoon2", + requires = { "nvim-lua/plenary.nvim", lazy = true }, + }, + }, + + -- Minimal neovim modules for a lot of things + { "echasnovski/mini.nvim" }, +}, { + performance = { + rtp = { + disabled_plugins = { + "gzip", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}) diff --git a/lua/user/map.lua b/lua/user/map.lua new file mode 100644 index 0000000..7bcee2f --- /dev/null +++ b/lua/user/map.lua @@ -0,0 +1,78 @@ +local map = vim.keymap.set + +-- Leader +vim.g.mapleader = " " +vim.g.maplocalleader = ";" + +-- Move text easilly +map("v", "J", ":m '>+1gv=gv", { desc = "Move selected text up" }) +map("v", "K", ":m '<-2gv=gv", { desc = "Move selected text down" }) + +-- better find next and previous +map("n", "n", "nzzzv", { desc = "Keep cursor in middle with search" }) +map("n", "N", "Nzzzv", { desc = "Keep cursor in middle with search" }) + +map("n", "J", "mzJ`z", { desc = "Move up next line with space in between" }) + +-- greatest remap ever +map("x", "p", [["_dP]], { desc = "Paste while keeping the registry" }) + +-- moving +vim.keymap.set("i", "", "I", { noremap = true }) +vim.keymap.set("i", "", "A", { noremap = true }) +vim.keymap.set("i", "", "D", { noremap = true }) + +-- buffers +vim.keymap.set("n", "gb", "buffers:buffer", { noremap = true }) +vim.keymap.set("n", "q", "q!", { noremap = true }) +vim.keymap.set("n", "Q", "qa!", { noremap = true }) +-- close all except focused buffer +vim.keymap.set("n", "1", "%bd|e#", { noremap = true }) +-- next tab +vim.keymap.set("n", "+", "tabe .", { noremap = true }) + +-- better indenting +map("v", "<", "", ">gv") + +-- allow for use of system clipboard fast +map({ "n", "v" }, "y", [["+y]]) +map("n", "Y", [["+Y]]) +map({ "n", "v" }, "P", [["+p]]) + +map({ "n", "v" }, "d", [["_d]]) + + +-- templates +vim.keymap.set("n", "rt", ":-1r " .. vim.fn.stdpath("config") .. "/templates", { noremap = true }) + +-- hide all +local s = {hidden_all = 0} +vim.keymap.set("n", "", function () + s.hidden_all = 1 - s.hidden_all + local opt = s.hidden_all == 0 + vim.opt.showmode = opt + vim.opt.ruler = opt + vim.opt.nu = opt + vim.opt.rnu = opt + vim.opt.showcmd = opt + vim.opt.laststatus = opt and 2 or 0 + vim.opt.signcolumn = opt and "yes" or "no" +end, { noremap = true }) + +-- write +vim.keymap.set("n", "w", "write", { noremap = true }) +vim.keymap.set("n", "W", "write!", { noremap = true }) +vim.keymap.set("n", "e", "edit", { noremap = true }) +vim.keymap.set("n", "s", function () + vim.cmd.source() + print("sourced.") +end, { noremap = true }) + +-- Lazy +vim.keymap.set("n", "P", "Lazy", { noremap = true }) + +-- spelling +vim.keymap.set("n", "s", "setlocal spell!", { noremap = true }) +vim.keymap.set("n", "g", "z=1", { noremap = true }) + diff --git a/lua/user/set.lua b/lua/user/set.lua new file mode 100644 index 0000000..2767143 --- /dev/null +++ b/lua/user/set.lua @@ -0,0 +1,96 @@ +local opt = vim.opt + +-- Don't highlight on search +opt.hlsearch = false +opt.incsearch = true + +-- Enable line numbers by default +opt.number = true +opt.relativenumber = true + +-- Tab settings +opt.tabstop = 4 +opt.softtabstop = 4 +opt.shiftwidth = 4 +opt.expandtab = true + +-- Enable smart indenting +opt.smartindent = true + +-- Enable break indent +opt.breakindent = true + +-- History settings +opt.undofile = true +opt.undodir = os.getenv("HOME") .. "/.local/state/nvim" +opt.swapfile = true +opt.swapfile = true + +-- Case-insensitive searching UNLESS \C or capital in search +opt.ignorecase = true +opt.smartcase = true + +-- Keep signcolumn on by default +opt.signcolumn = "yes" + +-- Decrease update time +opt.updatetime = 50 +opt.timeoutlen = 300 + +-- Set completeopt to have a better completion experience +opt.completeopt = "menuone,noselect" + +-- Enable true color support +opt.termguicolors = true + +-- Enable scroll off +opt.scrolloff = 8 + +-- Don't show mode I'm in, already have a nice status line for that +opt.showmode = false + +-- Better split options +opt.splitbelow = true +opt.splitright = true + +-- shared clipboard +opt.clipboard = "unnamed" +-- do not highlight matched bracket +opt.showmatch = false +-- highlight line at cursor +opt.cursorline = true + +-- status line +-- show ruler +opt.ruler = true +-- show command +opt.showcmd = true + +opt.wildmenu = true + +opt.mouse = "" + +opt.backspace = "indent,eol,start" + +opt.laststatus = 2 +opt.history = 200 +opt.encoding = "utf-8" +opt.fileencoding = "utf-8" + +opt.smartindent = true +opt.scrolloff = 8 + +opt.spelllang = "en_us,nl" +opt.formatoptions = "cqrnj" + +-- Get the current working directory, replace the $HOME portion of the path with ~, +-- and extract the last three directories +local cwd = vim.fn.getcwd():gsub(os.getenv('HOME'), '~') +local last_dirs = string.match(cwd, "[^/]+/[^/]+/[^/]+/?$") +if last_dirs then + opt.titlestring = last_dirs .. " -> %t" +else + opt.titlestring = cwd .. " -> %t" +end + +opt.title = true -- cgit v1.2.3