diff --git a/files/system/etc/xdg/nvim/init.lua b/files/system/etc/xdg/nvim/init.lua new file mode 100644 index 0000000..dbbc983 --- /dev/null +++ b/files/system/etc/xdg/nvim/init.lua @@ -0,0 +1,4 @@ +#!/usr/bin/env lua +require("options") +require("keymaps") +require("config.lazy") diff --git a/files/system/etc/xdg/nvim/lua/config/lazy.lua b/files/system/etc/xdg/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..9cc363d --- /dev/null +++ b/files/system/etc/xdg/nvim/lua/config/lazy.lua @@ -0,0 +1,34 @@ +-- 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) + +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +vim.g.mapleader = " " +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + -- automatically check for plugin updates + checker = { enabled = true }, +}) diff --git a/files/system/etc/xdg/nvim/lua/keymaps.lua b/files/system/etc/xdg/nvim/lua/keymaps.lua new file mode 100644 index 0000000..0e3ec5e --- /dev/null +++ b/files/system/etc/xdg/nvim/lua/keymaps.lua @@ -0,0 +1,31 @@ +-- define comon options +local opts = { + noremap = true, -- non-recursive + silent = true, -- do not show message +} + +----------------- +-- Normal mode -- +----------------- + +-- check `:h vim.map.set()` to get better idea of what this does +-- Better window navigation +vim.keymap.set('n', '', 'h', opts) +vim.keymap.set('n', '', 'j', opts) +vim.keymap.set('n', '', 'k', opts) +vim.keymap.set('n', '', 'l', opts) + +-- Resize with arrows +-- delta: 2 lines +vim.keymap.set('n', '', ':resize -2', opts) +vim.keymap.set('n', '', ':resize +2', opts) +vim.keymap.set('n', '', ':vertical resize -2', opts) +vim.keymap.set('n', '', ':vertical resize +2', opts) + +----------------- +-- Visual mode -- +----------------- + +-- start visual mode with same area as previous area and same mode +vim.keymap.set('v', '<', '', '>gv', opts) diff --git a/files/system/etc/xdg/nvim/lua/options.lua b/files/system/etc/xdg/nvim/lua/options.lua new file mode 100644 index 0000000..5f48391 --- /dev/null +++ b/files/system/etc/xdg/nvim/lua/options.lua @@ -0,0 +1,25 @@ +-- use `:h