# This is a combination of 4 commits.
# This is the 1st commit message: nvim: Restructure lua dir Moved plugins into individual component module files which are automatically required by lazy.nvim. Should make everything a tiny bit more modular, or at least prepare the way for true modularity if I ever have the time on my hands to ensure everything works with missing modules. Moved core settings into their own directory (`core`), and created a `personal` folder which contains functions/plugins I wrote that do not necessarily have to be their own imported plugin yet. Finally, extended the utility functions a little, so we can detect if a plugin exists and change e.g. key maps based on that (once again, extending modularity a little more). Some simple attempts have been made at that in the `mappings.lua` file, though it is nowhere near extensive yet - most keymaps are still set regardless of plugin availability. However, with this slimmer base to work off of, I feel more confident in changing future things about this setup a little more ad-hoc without having as many ripple repercussions as before. # This is the commit message #2: Update settings file with 0.9 options # This is the commit message #3: Move lazy.nvim setup into core module # This is the commit message #4: Rename maps.lua to mappings.lua
This commit is contained in:
parent
5f93ecba7c
commit
f343b1a76d
7 changed files with 74 additions and 29 deletions
|
@ -4,31 +4,18 @@ local api = vim.api
|
||||||
|
|
||||||
api.nvim_exec2("runtime abbrev.vim", {})
|
api.nvim_exec2("runtime abbrev.vim", {})
|
||||||
|
|
||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
for _, source in ipairs({
|
||||||
if not vim.loop.fs_stat(lazypath) then
|
"core.settings",
|
||||||
vim.fn.system({
|
"core.lazy",
|
||||||
"git",
|
"core.autocmds",
|
||||||
"clone",
|
"core.mappings",
|
||||||
"--filter=blob:none",
|
"core.look",
|
||||||
"https://github.com/folke/lazy.nvim.git",
|
}) do
|
||||||
"--branch=stable", -- latest stable release
|
local status_ok, fault = pcall(require, source)
|
||||||
lazypath,
|
if not status_ok then
|
||||||
})
|
vim.api.nvim_err_writeln("Failed to load " .. source .. "\n\n" .. fault)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
vim.opt.rtp:prepend(lazypath)
|
|
||||||
|
|
||||||
-- set our leader key to space since with hjkl, space is largely useless
|
|
||||||
-- needs to be set before lazy.nvim is loaded
|
|
||||||
vim.g.mapleader = " "
|
|
||||||
|
|
||||||
require("settings")
|
|
||||||
require("autocmds")
|
|
||||||
require("lazy").setup("plugins", {
|
|
||||||
defaults = { version = "*" },
|
|
||||||
performance = { rtp = { disabled_plugins = { "netrw", "netrwPlugin" } } },
|
|
||||||
})
|
|
||||||
require("look")
|
|
||||||
require("maps")
|
|
||||||
|
|
||||||
-- to include e.g. the spell dictionaries for vim
|
-- to include e.g. the spell dictionaries for vim
|
||||||
vim.opt.rtp:append(vim.fn.stdpath("data") .. "/site")
|
vim.opt.rtp:append(vim.fn.stdpath("data") .. "/site")
|
||||||
|
|
38
nvim/.config/nvim/lua/core/lazy.lua
Normal file
38
nvim/.config/nvim/lua/core/lazy.lua
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
|
-- inspired from astronvim lazy bootstrapping
|
||||||
|
if not vim.loop.fs_stat(lazypath) then
|
||||||
|
local output = vim.fn.system({
|
||||||
|
"git",
|
||||||
|
"clone",
|
||||||
|
"--filter=blob:none",
|
||||||
|
"https://github.com/folke/lazy.nvim.git",
|
||||||
|
"--branch=stable",
|
||||||
|
lazypath,
|
||||||
|
})
|
||||||
|
if vim.api.nvim_get_vvar("shell_error") ~= 0 then
|
||||||
|
vim.api.nvim_err_writeln("Error cloning lazy.nvim repository...\n\n" .. output)
|
||||||
|
end
|
||||||
|
local oldcmdheight = vim.opt.cmdheight:get()
|
||||||
|
vim.opt.cmdheight = 1
|
||||||
|
vim.notify("Please wait while plugins are installed...")
|
||||||
|
vim.api.nvim_create_autocmd("User", {
|
||||||
|
desc = "Load Mason and Treesitter after Lazy installs plugins",
|
||||||
|
once = true,
|
||||||
|
pattern = "LazyInstall",
|
||||||
|
callback = function()
|
||||||
|
vim.cmd.bw()
|
||||||
|
vim.opt.cmdheight = oldcmdheight
|
||||||
|
vim.tbl_map(function(module)
|
||||||
|
pcall(require, module)
|
||||||
|
end, { "nvim-treesitter", "mason" })
|
||||||
|
vim.notify("Mason is installing packages if configured, check status with :Mason")
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
|
require("lazy").setup({
|
||||||
|
spec = { { import = "plugins" } },
|
||||||
|
defaults = { lazy = true, version = "*" },
|
||||||
|
performance = { rtp = { disabled_plugins = { "netrw", "netrwPlugin" } } },
|
||||||
|
})
|
|
@ -4,8 +4,13 @@ local disable_builtins = function(builtins)
|
||||||
vim.g["loaded_" .. plugin] = 1
|
vim.g["loaded_" .. plugin] = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
disable_builtins(default_builtins_disabled)
|
||||||
|
|
||||||
local o = {
|
if vim.fn.has("nvim-0.9") == 1 then
|
||||||
|
vim.opt.diffopt:append("linematch:60")
|
||||||
|
end
|
||||||
|
|
||||||
|
local options = {
|
||||||
termguicolors = true,
|
termguicolors = true,
|
||||||
-- sets tabs to be 2 characters, expanded into spaces, but still removable with
|
-- sets tabs to be 2 characters, expanded into spaces, but still removable with
|
||||||
-- one press of backspace.
|
-- one press of backspace.
|
||||||
|
@ -47,6 +52,7 @@ local o = {
|
||||||
-- set to use treesitter in treesitter config
|
-- set to use treesitter in treesitter config
|
||||||
foldlevel = 2,
|
foldlevel = 2,
|
||||||
conceallevel = 2,
|
conceallevel = 2,
|
||||||
|
foldcolumn = vim.fn.has("nvim-0.9") == 1 and "auto:1" or nil,
|
||||||
-- enable mouse, doesn't bug me and might come in useful at some point
|
-- enable mouse, doesn't bug me and might come in useful at some point
|
||||||
mouse = "a",
|
mouse = "a",
|
||||||
-- pump all clippings into the system clipboard
|
-- pump all clippings into the system clipboard
|
||||||
|
@ -60,11 +66,25 @@ local o = {
|
||||||
splitbelow = true,
|
splitbelow = true,
|
||||||
-- remove command line if no command is currently present
|
-- remove command line if no command is currently present
|
||||||
cmdheight = 0,
|
cmdheight = 0,
|
||||||
|
-- try to cleverly manage indents by preserving them from line to line
|
||||||
|
breakindent = true,
|
||||||
|
copyindent = true,
|
||||||
|
preserveindent = true,
|
||||||
|
smartindent = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v in pairs(o) do
|
for o, v in pairs(options) do
|
||||||
vim.opt[k] = v
|
vim.opt[o] = v
|
||||||
end
|
end
|
||||||
|
vim.opt.shortmess:append({ s = true, I = true })
|
||||||
|
vim.opt.backspace:append({ "nostop" })
|
||||||
|
|
||||||
vim.api.nvim_set_var("tex_flavor", "latex")
|
local globals = {
|
||||||
disable_builtins(default_builtins_disabled)
|
mapleader = " ",
|
||||||
|
maplocalleader = ",",
|
||||||
|
tex_flavor = "latex",
|
||||||
|
}
|
||||||
|
|
||||||
|
for o, v in pairs(globals) do
|
||||||
|
vim.g[o] = v
|
||||||
|
end
|
Loading…
Reference in a new issue