almost everything
This commit is contained in:
44
lua/config/autocmd.lua
Normal file
44
lua/config/autocmd.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
-- Autocommand to check git status
|
||||
vim.api.nvim_create_autocmd("VimEnter", {
|
||||
callback = function()
|
||||
-- Verify if the current directory is a git repo
|
||||
local is_git = os.execute("git rev-parse --is-inside-work-tree > /dev/null 2>&1")
|
||||
if is_git ~= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
-- Perform an async fetch to avoid startup lag
|
||||
vim.fn.jobstart("git fetch", {
|
||||
on_exit = function()
|
||||
-- Get the number of commits the remote is ahead of local HEAD
|
||||
local count = vim.fn.system("git rev-list --count HEAD..@{u} 2>/dev/null"):gsub("%s+", "")
|
||||
|
||||
if count ~= "" and tonumber(count) > 0 then
|
||||
vim.schedule(function()
|
||||
vim.notify(
|
||||
" " .. count .. " new commit(s) available on remote.",
|
||||
vim.log.levels.INFO,
|
||||
{ title = "Git Status", icon = "" }
|
||||
)
|
||||
end)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
local cursorline_group = vim.api.nvim_create_augroup("CursorLineControl", { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd({ "WinEnter", "BufEnter" }, {
|
||||
group = cursorline_group,
|
||||
callback = function()
|
||||
vim.opt_local.cursorline = true
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "WinLeave" }, {
|
||||
group = cursorline_group,
|
||||
callback = function()
|
||||
vim.opt_local.cursorline = false
|
||||
end,
|
||||
})
|
||||
34
lua/config/binds.lua
Normal file
34
lua/config/binds.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
-- Keymap function
|
||||
function Keymap(mode, key, binding, opts)
|
||||
local options = { noremap = true, silent = true }
|
||||
if opts then
|
||||
options = vim.tbl_extend("force", options, opts)
|
||||
end
|
||||
vim.keymap.set(mode, key, binding, options)
|
||||
end
|
||||
|
||||
Keymap("n", "q:", ":") -- remove nonsense command
|
||||
Keymap("n", "<leader>bd", function() -- delete buffer
|
||||
vim.cmd("bd")
|
||||
vim.cmd("echo 'Buffer deleted'")
|
||||
end)
|
||||
|
||||
for _, bind in ipairs({ "i", "a", "A" }) do
|
||||
-- Pass { expr = true } as the fourth argument
|
||||
Keymap("n", bind, function()
|
||||
if vim.fn.getline("."):match("^%s*$") then
|
||||
return [["_cc]]
|
||||
else
|
||||
return bind
|
||||
end
|
||||
end, { expr = true })
|
||||
end
|
||||
|
||||
Keymap("i", "<C-BS>", "<C-W>") -- C-Backscpace for whole words
|
||||
|
||||
-- Open Lazygit
|
||||
Keymap("n", "<leader>l", function()
|
||||
Snacks.lazygit.open()
|
||||
end)
|
||||
|
||||
Keymap("n", "<leader>d", "<cmd>lua vim.diagnostic.open_float()<CR>") -- Diagnostics for Linter
|
||||
14
lua/plugins/completion/conform.lua
Normal file
14
lua/plugins/completion/conform.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
vim.pack.add({ { src = "https://github.com/stevearc/conform.nvim", name = "conform" } })
|
||||
|
||||
require("conform").setup({
|
||||
formatters_by_ft = {
|
||||
lua = { "stylua" },
|
||||
javascript = { "prettier" },
|
||||
python = { "black" },
|
||||
nix = { "nixfmt" },
|
||||
css = { "prettier" },
|
||||
rust = { "rustfmt" },
|
||||
},
|
||||
format_on_save = true,
|
||||
undojoin = true,
|
||||
})
|
||||
85
lua/plugins/completion/lspconfig.lua
Normal file
85
lua/plugins/completion/lspconfig.lua
Normal file
@@ -0,0 +1,85 @@
|
||||
vim.pack.add({
|
||||
{ src = "https://github.com/neovim/nvim-lspconfig", name = "lspconfig" },
|
||||
{ src = "https://github.com/saghen/blink.cmp", name = "blink" },
|
||||
})
|
||||
|
||||
vim.lsp.config("lua_ls", {
|
||||
settings = {
|
||||
Lua = {
|
||||
-- Tell the server to let Neovim handle snippet expansion
|
||||
completion = {
|
||||
callSnippet = "Replace",
|
||||
},
|
||||
-- Use LuaJIT (which Neovim uses)
|
||||
runtime = {
|
||||
version = "LuaJIT",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.lsp.config("emmet_ls", {
|
||||
-- capabilities = require("cmp_nvim_lsp").default_capabilities(),
|
||||
filetypes = { "html", "css", "javascriptreact", "typescriptreact" },
|
||||
init_options = {
|
||||
html = {
|
||||
options = {
|
||||
["bem.enabled"] = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
vim.lsp.enable({
|
||||
"lua_ls",
|
||||
"ts_ls",
|
||||
"pylsp",
|
||||
"cssls",
|
||||
"nixd",
|
||||
"rust_analyzer",
|
||||
"emmet_ls",
|
||||
})
|
||||
|
||||
vim.o.pumborder = "rounded"
|
||||
|
||||
require("blink.cmp").setup({
|
||||
-- Snippet configuration
|
||||
-- snippets = {
|
||||
-- preset = "luasnip", -- Tells blink.cmp to use LuaSnip
|
||||
-- },
|
||||
|
||||
fuzzy = { implementation = "lua" },
|
||||
|
||||
signature = {
|
||||
enabled = true,
|
||||
},
|
||||
|
||||
completion = {
|
||||
list = {
|
||||
selection = {
|
||||
preselect = false,
|
||||
auto_insert = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Keymaps
|
||||
keymap = {
|
||||
["<Tab>"] = { "select_next", "snippet_forward", "fallback" },
|
||||
},
|
||||
sources = {
|
||||
default = {
|
||||
"lsp", -- (Equivalent to cmp-nvim-lsp)
|
||||
"snippets", -- (Handled by the snippets config, replaces cmp_luasnip source)
|
||||
"buffer", -- (Equivalent to cmp-buffer)
|
||||
"path", -- (Equivalent to cmp-path)
|
||||
-- "cmdline", -- Generally configured separately, but often included by default
|
||||
},
|
||||
providers = {
|
||||
-- lazydev = {
|
||||
-- name = "LazyDev",
|
||||
-- module = "lazydev.integrations.blink",
|
||||
-- -- make lazydev completions top priority (see `:h blink.cmp`)
|
||||
-- score_offset = 100,
|
||||
-- },
|
||||
},
|
||||
},
|
||||
})
|
||||
24
lua/plugins/completion/treesitter.lua
Normal file
24
lua/plugins/completion/treesitter.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
vim.pack.add({ { src = "https://github.com/nvim-treesitter/nvim-treesitter", name = "treesitter" } })
|
||||
|
||||
require("nvim-treesitter").setup({
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
})
|
||||
|
||||
require("nvim-treesitter").install({
|
||||
"bash",
|
||||
"html",
|
||||
"latex",
|
||||
"javascript",
|
||||
"json",
|
||||
"lua",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"query",
|
||||
"regex",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"python",
|
||||
"vim",
|
||||
"yaml",
|
||||
})
|
||||
35
lua/plugins/init.lua
Normal file
35
lua/plugins/init.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
local plugins = {}
|
||||
|
||||
-- 1. Setup paths
|
||||
local lua_path = vim.fn.stdpath("config") .. "/lua"
|
||||
local plugin_dir = lua_path .. "/plugins"
|
||||
|
||||
-- 2. Use ** to search recursively for all .lua files
|
||||
local files = vim.fn.split(vim.fn.globpath(plugin_dir, "**/*.lua"), "\n")
|
||||
|
||||
for _, file in ipairs(files) do
|
||||
-- Get path relative to the 'lua' directory
|
||||
-- Example: /home/user/.config/nvim/lua/plugins/ui/statusline.lua
|
||||
-- Becomes: plugins/ui/statusline.lua
|
||||
local relative_path = file:sub(#lua_path + 2)
|
||||
|
||||
-- Remove the .lua extension
|
||||
local module_path = relative_path:gsub("%.lua$", "")
|
||||
|
||||
-- Convert path slashes to Lua dots (plugins/ui/statusline -> plugins.ui.statusline)
|
||||
module_path = module_path:gsub("/", ".")
|
||||
|
||||
-- 3. The Guard: Don't require the current file (plugins.init)
|
||||
if not module_path:match("%.init$") and module_path ~= "plugins" then
|
||||
local status_ok, module_content = pcall(require, module_path)
|
||||
|
||||
if status_ok then
|
||||
table.insert(plugins, module_content)
|
||||
else
|
||||
-- Optional: notify if a file failed to load
|
||||
vim.notify("Error loading " .. module_path .. ": " .. module_content, vim.log.levels.ERROR)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return plugins
|
||||
10
lua/plugins/ui/catppuccin.lua
Normal file
10
lua/plugins/ui/catppuccin.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
vim.pack.add({ { src = "https://github.com/catppuccin/nvim", name = "catppuccin" } })
|
||||
|
||||
require("catppuccin").setup({
|
||||
transparent_background = true, -- disables setting the background color.
|
||||
float = {
|
||||
transparent = true, -- enable transparent floating windows
|
||||
solid = false, -- use solid styling for floating windows, see |winborder|
|
||||
},
|
||||
show_end_of_buffer = true, -- shows the '~' characters after the end of buffers
|
||||
})
|
||||
71
lua/plugins/ui/lualine.lua
Normal file
71
lua/plugins/ui/lualine.lua
Normal file
@@ -0,0 +1,71 @@
|
||||
vim.pack.add({
|
||||
{ src = "https://github.com/nvim-lualine/lualine.nvim", name = "lualine" },
|
||||
{ src = "https://github.com/nvim-tree/nvim-web-devicons", name = "devicons" },
|
||||
{ src = "https://github.com/archibate/lualine-time", name = "lualine-time" },
|
||||
})
|
||||
|
||||
require("lualine").setup({
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = "auto",
|
||||
component_separators = { left = "", right = "" },
|
||||
section_separators = { left = "", right = "" },
|
||||
disabled_filetypes = {
|
||||
statusline = {},
|
||||
winbar = {},
|
||||
},
|
||||
ignore_focus = {},
|
||||
always_divide_middle = true,
|
||||
always_show_tabline = true,
|
||||
globalstatus = false,
|
||||
refresh = {
|
||||
statusline = 1000,
|
||||
tabline = 1000,
|
||||
winbar = 1000,
|
||||
refresh_time = 16, -- ~60fps
|
||||
events = {
|
||||
"WinEnter",
|
||||
"BufEnter",
|
||||
"BufWritePost",
|
||||
"SessionLoadPost",
|
||||
"FileChangedShellPost",
|
||||
"VimResized",
|
||||
"Filetype",
|
||||
"CursorMoved",
|
||||
"CursorMovedI",
|
||||
"ModeChanged",
|
||||
},
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {
|
||||
"mode",
|
||||
{
|
||||
function()
|
||||
local reg = vim.fn.reg_recording()
|
||||
if reg == "" then
|
||||
return ""
|
||||
end -- not recording
|
||||
return "MACRO " .. string.upper(tostring(reg))
|
||||
end,
|
||||
},
|
||||
},
|
||||
lualine_b = { "branch", "diff", "diagnostics" },
|
||||
lualine_c = { "filename" },
|
||||
lualine_x = { "filetype" },
|
||||
lualine_y = { "lsp_status" },
|
||||
lualine_z = { "ctime" },
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = { "branch", "diff", "diagnostics" },
|
||||
lualine_c = { "filename" },
|
||||
lualine_x = { "location" },
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
tabline = {},
|
||||
winbar = {},
|
||||
inactive_winbar = {},
|
||||
extensions = {},
|
||||
})
|
||||
41
lua/plugins/ui/noice.lua
Normal file
41
lua/plugins/ui/noice.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
vim.pack.add({
|
||||
{ src = "https://github.com/folke/noice.nvim", name = "noice" },
|
||||
{ src = "https://github.com/MunifTanjim/nui.nvim", name = "nui" },
|
||||
{ src = "https://github.com/rcarriga/nvim-notify", name = "notify" },
|
||||
})
|
||||
|
||||
vim.notify = require("notify").setup({
|
||||
background_colour = "#000000",
|
||||
render = "compact",
|
||||
stages = "slide",
|
||||
})
|
||||
require("noice").setup({
|
||||
messages = {
|
||||
enabled = true,
|
||||
view = "mini",
|
||||
view_error = "notify", -- view for errors
|
||||
view_warn = "notify", -- view for warnings
|
||||
view_history = "messages", -- view for :messages
|
||||
view_search = "virtualtext", -- view for search count messages. Set to `false` to disable
|
||||
},
|
||||
notify = {
|
||||
enabled = true,
|
||||
view = "notify",
|
||||
},
|
||||
hover = {
|
||||
enabled = false,
|
||||
},
|
||||
lsp = {
|
||||
hover = {
|
||||
enabled = false,
|
||||
},
|
||||
signature = {
|
||||
enabled = false,
|
||||
},
|
||||
},
|
||||
presets = {
|
||||
long_message_to_split = true, -- long messages will be sent to a split
|
||||
inc_rename = false, -- enables an input dialog for inc-rename.nvim
|
||||
lsp_doc_border = false, -- add a border to hover docs and signature help
|
||||
},
|
||||
})
|
||||
52
lua/plugins/utils/mini.lua
Normal file
52
lua/plugins/utils/mini.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
vim.pack.add({ { src = "https://github.com/echasnovski/mini.nvim", name = "mini" } })
|
||||
|
||||
require("mini.pairs").setup() -- Bracket pairs and stuff
|
||||
|
||||
require("mini.ai").setup() -- Around and In extension for visual mode
|
||||
|
||||
require("mini.cursorword").setup() -- Underline current word below cursor (makes it easier to c and d)
|
||||
|
||||
require("mini.indentscope").setup({ -- shows indents
|
||||
symbol = "│",
|
||||
draw = {
|
||||
delay = 10,
|
||||
animation = require("mini.indentscope").gen_animation.linear({
|
||||
duration = 15,
|
||||
unit = "step",
|
||||
easing = "out",
|
||||
}),
|
||||
},
|
||||
})
|
||||
|
||||
require("mini.trailspace").setup() -- Shows useless spaces
|
||||
|
||||
require("mini.sessions").setup({ -- dir based session management
|
||||
autoread = true,
|
||||
autowrite = true,
|
||||
file = ".session",
|
||||
force = { read = false, write = true, delete = true },
|
||||
})
|
||||
|
||||
require("mini.surround").setup() -- Suround selections with characters
|
||||
|
||||
require("mini.move").setup({ -- move selection in visual mode
|
||||
mappings = {
|
||||
down = "J",
|
||||
up = "K",
|
||||
},
|
||||
})
|
||||
|
||||
require("mini.icons").setup() -- Icon provider
|
||||
|
||||
local animate = require("mini.animate") -- animations ovs
|
||||
require("mini.animate").setup({
|
||||
cursor = {
|
||||
enable = false,
|
||||
},
|
||||
scroll = {
|
||||
-- Animate for 200 milliseconds with linear easing
|
||||
timing = animate.gen_timing.linear({ duration = 100, unit = "total" }),
|
||||
-- Animate equally but with at most 120 steps instead of default 60
|
||||
subscroll = animate.gen_subscroll.equal({ max_output_steps = 60 }),
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user