refactor(nvim): split init & config
This commit is contained in:
parent
dd93643652
commit
e738954f46
8 changed files with 174 additions and 158 deletions
|
@ -1,94 +1,5 @@
|
|||
vim.g.mapleader = " "
|
||||
-- netrw is handled by nvim-tree
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
-- true colors
|
||||
vim.o.termguicolors = true
|
||||
vim.o.cmdheight = 0
|
||||
-- line numbers
|
||||
vim.o.mouse = "nv"
|
||||
vim.o.number = true
|
||||
vim.o.relativenumber = true
|
||||
-- scroll offsets
|
||||
vim.o.scrolloff = 5
|
||||
vim.o.sidescrolloff = 15
|
||||
-- always show status
|
||||
vim.o.laststatus = 3
|
||||
-- hide tab line
|
||||
vim.o.showtabline = 0
|
||||
vim.g.termguicolors = false
|
||||
-- completion height
|
||||
vim.o.pumheight = 15
|
||||
-- split directions
|
||||
vim.o.splitbelow = true
|
||||
vim.o.splitright = true
|
||||
vim.o.wrap = false
|
||||
-- redefine word boundaries - '_' is a word separator, this helps with snake_case
|
||||
vim.opt.iskeyword:remove("_")
|
||||
-- indentations settings
|
||||
vim.o.shiftwidth = 2
|
||||
vim.o.tabstop = 2
|
||||
vim.o.softtabstop = 0
|
||||
vim.o.expandtab = true
|
||||
vim.o.signcolumn = "yes:1"
|
||||
vim.opt.shortmess:append("sI")
|
||||
-- double box drawing characters for splits
|
||||
vim.opt.fillchars:append({
|
||||
horiz = "═",
|
||||
horizup = "╩",
|
||||
horizdown = "╦",
|
||||
vert = "║",
|
||||
vertright = "╠",
|
||||
vertleft = "╣",
|
||||
verthoriz = "╬",
|
||||
})
|
||||
|
||||
pcall(require, "plugins")
|
||||
pcall(require, "binds")
|
||||
|
||||
vim.api.nvim_create_autocmd("VimResized", {
|
||||
pattern = "*",
|
||||
command = "wincmd =",
|
||||
desc = "Automatically resize windows when the host window size changes.",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
vim.highlight.on_yank({ higroup = "IncSearch", timeout = 200 })
|
||||
end,
|
||||
desc = "Highlight yanked text",
|
||||
})
|
||||
|
||||
local trnuGroup = vim.api.nvim_create_augroup("toggleRnu", {})
|
||||
vim.api.nvim_create_autocmd("InsertEnter,BufLeave,WinLeave,FocusLost", {
|
||||
callback = function()
|
||||
vim.opt_local.relativenumber = false
|
||||
end,
|
||||
group = trnuGroup,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("InsertLeave,BufEnter,WinEnter,FocusGained", {
|
||||
callback = function()
|
||||
vim.opt_local.relativenumber = true
|
||||
end,
|
||||
group = trnuGroup,
|
||||
})
|
||||
|
||||
if vim.g.neovide then
|
||||
vim.g.neovide_refresh_rate = 60
|
||||
vim.g.neovide_refresh_rate_idle = 5
|
||||
vim.g.neovide_cursor_vfx_mode = "ripple"
|
||||
vim.g.neovide_scroll_animation_length = 0.3
|
||||
vim.g.neovide_input_macos_alt_is_meta = true
|
||||
vim.g.neovide_hide_mouse_when_typing = true
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"<M-CR>",
|
||||
":let g:neovide_fullscreen = !g:neovide_fullscreen<CR>",
|
||||
{
|
||||
noremap = true,
|
||||
silent = true,
|
||||
}
|
||||
)
|
||||
vim.opt.guifont = { "BerkeleyMono Nerd Font", "h14", "#e-subpixelantialias" }
|
||||
if vim.g.vscode then
|
||||
pcall(require, "config.vscode")
|
||||
else
|
||||
require("config")
|
||||
end
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
"nvim-navic": { "branch": "master", "commit": "cdd24539bcf114a499827e9b32869fe74836efe7" },
|
||||
"nvim-surround": { "branch": "main", "commit": "177c95c12542cf20a422b19a87ba1ae80254445a" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "bbb6d4891009de7dab05ad8fc2d39f272d7a751c" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "11b2d430e6f501e29e6851aaf1bd6fa338072be6" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "079a50f66ea9f2d3b9827bdba82ba3b255155621" },
|
||||
"nvim-ts-autotag": { "branch": "main", "commit": "fdefe46c6807441460f11f11a167a2baf8e4534b" },
|
||||
"nvim-ts-rainbow2": { "branch": "master", "commit": "6bcb1472c321a15eef5a7a015b4fefa8758e6513" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "4af94fec29f508159ceab5413383e5dedd6c24e3" },
|
||||
|
|
27
home/apps/neovim/lua/config/autocmds.lua
Normal file
27
home/apps/neovim/lua/config/autocmds.lua
Normal file
|
@ -0,0 +1,27 @@
|
|||
vim.api.nvim_create_autocmd("VimResized", {
|
||||
pattern = "*",
|
||||
command = "wincmd =",
|
||||
desc = "Automatically resize windows when the host window size changes.",
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
vim.highlight.on_yank({ higroup = "IncSearch", timeout = 200 })
|
||||
end,
|
||||
desc = "Highlight yanked text",
|
||||
})
|
||||
|
||||
local trnuGroup = vim.api.nvim_create_augroup("toggleRnu", {})
|
||||
vim.api.nvim_create_autocmd("InsertEnter,BufLeave,WinLeave,FocusLost", {
|
||||
callback = function()
|
||||
vim.opt_local.relativenumber = false
|
||||
end,
|
||||
group = trnuGroup,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("InsertLeave,BufEnter,WinEnter,FocusGained", {
|
||||
callback = function()
|
||||
vim.opt_local.relativenumber = true
|
||||
end,
|
||||
group = trnuGroup,
|
||||
})
|
|
@ -1,15 +1,6 @@
|
|||
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",
|
||||
"--single-branch",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
lazypath,
|
||||
})
|
||||
end
|
||||
vim.opt.runtimepath:prepend(lazypath)
|
||||
require("config.autocmds")
|
||||
require("config.mappings")
|
||||
require("config.options")
|
||||
|
||||
local plugins = {
|
||||
{ "catppuccin/nvim", name = "catppuccin" },
|
||||
|
@ -157,55 +148,4 @@ local plugins = {
|
|||
{ "nvim-neorg/neorg", build = ":Neorg sync-parsers" },
|
||||
}
|
||||
|
||||
require("lazy").setup(plugins, {
|
||||
install = { colorscheme = { "catppuccin" } },
|
||||
performance = {
|
||||
rtp = {
|
||||
disabled_plugins = {
|
||||
"2html_plugin",
|
||||
"bugreport",
|
||||
"compiler",
|
||||
"ftplugin",
|
||||
"fzf",
|
||||
"getscript",
|
||||
"getscriptPlugin",
|
||||
"gzip",
|
||||
"logipat",
|
||||
"matchit",
|
||||
"netrw",
|
||||
"netrwFileHandlers",
|
||||
"netrwPlugin",
|
||||
"netrwSettings",
|
||||
"optwin",
|
||||
"rplugin",
|
||||
"rrhelper",
|
||||
"spellfile_plugin",
|
||||
"synmenu",
|
||||
"syntax",
|
||||
"tar",
|
||||
"tarPlugin",
|
||||
"tutor",
|
||||
"vimball",
|
||||
"vimballPlugin",
|
||||
"zip",
|
||||
"zipPlugin",
|
||||
},
|
||||
},
|
||||
},
|
||||
ui = {
|
||||
icons = {
|
||||
cmd = " ",
|
||||
config = "",
|
||||
event = " ",
|
||||
ft = " ",
|
||||
init = " ",
|
||||
keys = " ",
|
||||
plugin = " ",
|
||||
runtime = " ",
|
||||
source = " ",
|
||||
start = " ",
|
||||
task = " ",
|
||||
},
|
||||
border = "double",
|
||||
},
|
||||
})
|
||||
require("config.plugins").setup(plugins)
|
63
home/apps/neovim/lua/config/options.lua
Normal file
63
home/apps/neovim/lua/config/options.lua
Normal file
|
@ -0,0 +1,63 @@
|
|||
vim.g.mapleader = " "
|
||||
-- netrw is handled by nvim-tree
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
-- true colors
|
||||
vim.o.termguicolors = true
|
||||
vim.o.cmdheight = 0
|
||||
-- line numbers
|
||||
vim.o.mouse = "nv"
|
||||
vim.o.number = true
|
||||
vim.o.relativenumber = true
|
||||
-- scroll offsets
|
||||
vim.o.scrolloff = 5
|
||||
vim.o.sidescrolloff = 15
|
||||
-- always show status
|
||||
vim.o.laststatus = 3
|
||||
-- hide tab line
|
||||
vim.o.showtabline = 0
|
||||
vim.g.termguicolors = false
|
||||
-- completion height
|
||||
vim.o.pumheight = 15
|
||||
-- split directions
|
||||
vim.o.splitbelow = true
|
||||
vim.o.splitright = true
|
||||
vim.o.wrap = false
|
||||
-- redefine word boundaries - '_' is a word separator, this helps with snake_case
|
||||
vim.opt.iskeyword:remove("_")
|
||||
-- indentations settings
|
||||
vim.o.shiftwidth = 2
|
||||
vim.o.tabstop = 2
|
||||
vim.o.softtabstop = 0
|
||||
vim.o.expandtab = true
|
||||
vim.o.signcolumn = "yes:1"
|
||||
vim.opt.shortmess:append("sI")
|
||||
-- double box drawing characters for splits
|
||||
vim.opt.fillchars:append({
|
||||
horiz = "═",
|
||||
horizup = "╩",
|
||||
horizdown = "╦",
|
||||
vert = "║",
|
||||
vertright = "╠",
|
||||
vertleft = "╣",
|
||||
verthoriz = "╬",
|
||||
})
|
||||
|
||||
if vim.g.neovide then
|
||||
vim.g.neovide_refresh_rate = 60
|
||||
vim.g.neovide_refresh_rate_idle = 5
|
||||
vim.g.neovide_cursor_vfx_mode = "ripple"
|
||||
vim.g.neovide_scroll_animation_length = 0.3
|
||||
vim.g.neovide_input_macos_alt_is_meta = true
|
||||
vim.g.neovide_hide_mouse_when_typing = true
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"<M-CR>",
|
||||
":let g:neovide_fullscreen = !g:neovide_fullscreen<CR>",
|
||||
{
|
||||
noremap = true,
|
||||
silent = true,
|
||||
}
|
||||
)
|
||||
vim.opt.guifont = { "BerkeleyMono Nerd Font", "h14", "#e-subpixelantialias" }
|
||||
end
|
71
home/apps/neovim/lua/config/plugins.lua
Normal file
71
home/apps/neovim/lua/config/plugins.lua
Normal file
|
@ -0,0 +1,71 @@
|
|||
local M = {}
|
||||
|
||||
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",
|
||||
lazypath,
|
||||
})
|
||||
end
|
||||
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
|
||||
|
||||
M.setup = function(plugins)
|
||||
require("lazy").setup(plugins, {
|
||||
install = { colorscheme = { "catppuccin" } },
|
||||
performance = {
|
||||
rtp = {
|
||||
disabled_plugins = {
|
||||
"2html_plugin",
|
||||
"bugreport",
|
||||
"compiler",
|
||||
"ftplugin",
|
||||
"fzf",
|
||||
"getscript",
|
||||
"getscriptPlugin",
|
||||
"gzip",
|
||||
"logipat",
|
||||
"matchit",
|
||||
"netrw",
|
||||
"netrwFileHandlers",
|
||||
"netrwPlugin",
|
||||
"netrwSettings",
|
||||
"optwin",
|
||||
"rplugin",
|
||||
"rrhelper",
|
||||
"spellfile_plugin",
|
||||
"synmenu",
|
||||
"syntax",
|
||||
"tar",
|
||||
"tarPlugin",
|
||||
"tutor",
|
||||
"vimball",
|
||||
"vimballPlugin",
|
||||
"zip",
|
||||
"zipPlugin",
|
||||
},
|
||||
},
|
||||
},
|
||||
ui = {
|
||||
icons = {
|
||||
cmd = " ",
|
||||
config = "",
|
||||
event = " ",
|
||||
ft = " ",
|
||||
init = " ",
|
||||
keys = " ",
|
||||
plugin = " ",
|
||||
runtime = " ",
|
||||
source = " ",
|
||||
start = " ",
|
||||
task = " ",
|
||||
},
|
||||
border = "double",
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
4
home/apps/neovim/lua/config/vscode.lua
Normal file
4
home/apps/neovim/lua/config/vscode.lua
Normal file
|
@ -0,0 +1,4 @@
|
|||
require("config.mappings")
|
||||
require("config.options")
|
||||
|
||||
require("config.plugins").setup()
|
Loading…
Reference in a new issue