feat(nvim): migrate to LazyVim

This commit is contained in:
Stefan Imhoff
2023-02-10 12:43:10 +01:00
parent 91874608bf
commit a274746a8a
147 changed files with 2059 additions and 2806 deletions

View File

@@ -0,0 +1,46 @@
-- Autocmds are automatically loaded on the VeryLazy event
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
-- Add any additional autocmds here
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = { "*tmux.conf" },
command = "execute 'silent !tmux source <afile> --silent'",
})
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = { ".yabairc" },
command = "!brew services restart yabai",
})
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = { ".skhdrc" },
command = "!brew services restart skhd",
})
vim.api.nvim_create_autocmd({ "BufNewFile", "BufFilePre", "BufRead" }, {
pattern = { "*.mdx", "*.md" },
callback = function()
vim.cmd([[set filetype=markdown wrap linebreak nolist]])
end,
})
vim.api.nvim_create_autocmd({ "BufRead" }, {
pattern = { "gitmux.conf" },
callback = function()
vim.cmd([[set filetype=sh]])
end,
})
vim.api.nvim_create_autocmd({ "VimResized" }, {
pattern = { "*" },
callback = function()
vim.cmd([[tabdo wincmd =]])
end,
})
vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, {
pattern = { "*.rss" },
callback = function()
vim.cmd([[set filetype=xml]])
end,
})

View File

@@ -0,0 +1,34 @@
-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
vim.keymap.set("n", "<leader>j", ":b#<CR>", { desc = "Toggle between buffers", noremap = true, silent = true })
vim.keymap.set("n", ";;", "A;<ESC>", { desc = "Add semicolon to the end of the line", noremap = true, silent = true })
vim.keymap.set("n", ",,", "A,<ESC>", { desc = "Add comma to the end of the line", noremap = true, silent = true })
-- stylua: ignore
vim.keymap.set("v", "y", "myy`y", { desc = "Maintain the cursor position when yanking a visual selection", noremap = true, silent = true })
vim.keymap.set("n", "+", "<C-a>", { desc = "Increment", noremap = true, silent = true })
vim.keymap.set("n", "-", "<C-x>", { desc = "Decrement", noremap = true, silent = true })
vim.keymap.set("n", "<leader>bx", ":bufdo bdelete<CR>", { desc = "Delete all buffers", noremap = true, silent = true })
vim.keymap.set("n", "<leader>ut", ":set list!<CR>", { desc = "Toggle list", noremap = true, silent = true })
vim.keymap.set("n", "Y", "yg$", { desc = "Copy to the end of the line", noremap = true, silent = true })
-- stylua: ignore
vim.keymap.set("n", "n", "nzzzv", { desc = "Keep the window centered (next search result)", noremap = true, silent = true })
-- stylua: ignore
vim.keymap.set("n", "N", "Nzzzv", { desc = "Keep the window centered (previous search result)", noremap = true, silent = true })
-- stylua: ignore
vim.keymap.set("n", "<expr> j", "(v:count == 0 ? 'gj' : 'j')", { desc = "Move by rows in wrapped mode (down)", noremap = true, silent = true })
-- stylua: ignore
vim.keymap.set("n", "<expr> k", "(v:count == 0 ? 'gk' : 'k')", { desc = "Move by rows in wrapped mode (up)", noremap = true, silent = true })
vim.keymap.set("n", "gP", "`[v`]", { desc = "Visuall select of just pasted content", noremap = true, silent = true })
vim.keymap.set("n", "gy", "`[v`]y", { desc = "Visuall select of just pasted content", noremap = true, silent = true })
-- stylua: ignore
vim.keymap.set("n", "<leader>wi", ":silent !open -a iA\\ Writer.app '%:p'<CR>", { desc = "Open in iA Writer", noremap = true, silent = true })
vim.keymap.set("n", "<C-h>", require("smart-splits").move_cursor_left)
vim.keymap.set("n", "<C-j>", require("smart-splits").move_cursor_down)
vim.keymap.set("n", "<C-k>", require("smart-splits").move_cursor_up)
vim.keymap.set("n", "<C-l>", require("smart-splits").move_cursor_right)
-- Visual Mode
vim.keymap.set("v", "<", "<gv", { desc = "Stay in indent mode (left)", noremap = true, silent = true })
vim.keymap.set("v", ">", ">gv", { desc = "Stay in indent mode (right)", noremap = true, silent = true })

46
nvim/lua/config/lazy.lua Normal file
View File

@@ -0,0 +1,46 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
-- bootstrap lazy.nvim
-- stylua: ignore
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
require("lazy").setup({
spec = {
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- import any extras modules here
{ import = "lazyvim.plugins.extras.lang.typescript" },
{ import = "lazyvim.plugins.extras.lang.json" },
{ import = "lazyvim.plugins.extras.ui.mini-animate" },
-- import/override with your plugins
{ import = "plugins" },
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
lazy = false,
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
-- have outdated releases, which may break your Neovim install.
version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver
},
install = { colorscheme = { "tokyonight", "habamax" } },
checker = { enabled = true }, -- automatically check for plugin updates
performance = {
rtp = {
-- disable some rtp plugins
disabled_plugins = {
"gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})

View File

@@ -0,0 +1,38 @@
-- Options are automatically loaded before lazy.nvim startup
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
-- Add any additional options here
vim.opt.autowrite = true
vim.opt.backspace = { "indent", "eol", "start" } -- Intuitive backspacing
vim.opt.copyindent = true
vim.opt.foldlevel = 2
vim.opt.foldlevelstart = 99
vim.opt.foldmethod = "indent"
vim.opt.foldnestmax = 10
vim.opt.grepprg = "rg --vimgrep --no-heading --smart-case"
vim.opt.listchars = { tab = "", trail = "·", nbsp = ".", extends = "", precedes = "" }
vim.opt.showbreak = ""
vim.opt.shiftwidth = 4
vim.opt.softtabstop = 4
vim.opt.tabstop = 4
vim.opt.title = true
vim.opt.swapfile = false
vim.opt.virtualedit = "all"
vim.opt.iskeyword:append("-") -- Add dashes to words
vim.opt.wildignore:append({ "*/node_modules/*" }) -- Wildignore
vim.opt.complete:append({ "i", "k", "s", "kspell" })
-- FIXME: When using "vim.opt.spellfile:append("~/.config/…) the file is not writable"
vim.cmd([[
" Spell Checker
set spellfile+=~/.config/nvim/spell/en.utf-8.add
" Custom Dictionaries (<C-x> <C-k>)
set dictionary+=~/.config/nvim/dictionary/de_user.txt
set dictionary+=~/.config/nvim/dictionary/de_neu.txt
set dictionary+=~/.config/nvim/dictionary/en_us.txt
" Custom Thesauri (Synonyms) (<C-x> <C-t>)
set thesaurus+=~/.config/nvim/thesaurus/de_user.txt
set thesaurus+=~/.config/nvim/thesaurus/de_openthesaurus.txt
]])