feat: nvim config

This commit is contained in:
Rasyidan Akbar F. 2025-10-28 15:59:39 +07:00
commit 03507560de
23 changed files with 685 additions and 328 deletions

View file

@ -1,8 +1,9 @@
-- 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
-- with `vim.api.nvim_create_autocmd`
--
-- Or remove existing autocmds by their group name (which is prefixed with `lazyvim_` for the defaults)
-- e.g. vim.api.nvim_del_augroup_by_name("lazyvim_wrap_spell")
-- Essential autocommands (minimal)
local autocmd = vim.api.nvim_create_autocmd
-- Highlight on yank
autocmd("TextYankPost", {
callback = function()
vim.highlight.on_yank()
end,
})

View file

@ -1,3 +1,9 @@
-- 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
-- Essential keymaps (minimal improvements over default Vim)
local keymap = vim.keymap
-- Clear search highlight with <esc>
keymap.set("n", "<esc>", "<cmd>noh<cr>", { desc = "Clear search highlight" })
-- Better indenting (stay in visual mode)
keymap.set("v", "<", "<gv")
keymap.set("v", ">", ">gv")

View file

@ -13,38 +13,27 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
end
end
vim.opt.rtp:prepend(lazypath)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
require("lazy").setup({
spec = {
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- import/override with your plugins
{ import = "plugins" },
{ import = "config.lazyvim" },
},
-- Put the lockfile somewhere writable when the config directory is managed by Nix
lockfile = vim.fn.stdpath("state") .. "/lazy-lock.json",
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, -- check for plugin updates periodically
notify = false, -- notify on update
}, -- automatically check for plugin updates
install = { colorscheme = { "gruvbox", "habamax" } },
checker = { enabled = false },
change_detection = { notify = false },
performance = {
rtp = {
-- disable some rtp plugins
disabled_plugins = {
"gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
"matchit",
"matchparen",
"netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",

View file

@ -0,0 +1,70 @@
-- Enable language servers defined in nvim-lspconfig using the Nvim 0.11 API.
return {
{
"mason-org/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
local ensure = {
"clangd",
"gopls",
"lua-language-server",
"nil",
"pyright",
"rust-analyzer",
"typescript-language-server",
}
for _, tool in ipairs(ensure) do
if not vim.tbl_contains(opts.ensure_installed, tool) then
table.insert(opts.ensure_installed, tool)
end
end
end,
},
{
"neovim/nvim-lspconfig",
event = { "BufReadPre", "BufNewFile" },
opts = function(_, opts)
opts.servers = vim.tbl_deep_extend(
"force",
{
lua_ls = {},
nil_ls = {},
pyright = {},
ts_ls = {},
rust_analyzer = {},
gopls = {},
clangd = {},
},
opts.servers or {}
)
end,
config = function(_, opts)
if vim.fn.has("nvim-0.11") == 0 then
vim.notify("nvim-lspconfig requires Neovim 0.11+ for vim.lsp.config", vim.log.levels.ERROR)
return
end
for name, server_opts in pairs(opts.servers or {}) do
if server_opts ~= false then
local config = type(server_opts) == "table" and vim.deepcopy(server_opts) or {}
if config.enabled ~= false then
config.enabled = nil
-- Integrate blink.cmp capabilities with LSP
local has_blink, blink = pcall(require, "blink.cmp")
if has_blink then
config.capabilities = blink.get_lsp_capabilities(config.capabilities)
end
if next(config) ~= nil then
vim.lsp.config(name, config)
end
vim.lsp.enable(name)
end
end
end
end,
},
}

View file

@ -1,3 +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
-- Minimal essential options
local opt = vim.opt
-- Leader keys
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Line numbers
opt.number = true
opt.relativenumber = true
-- Indentation
opt.tabstop = 2
opt.shiftwidth = 2
opt.expandtab = true
opt.smartindent = true
-- Search
opt.ignorecase = true
opt.smartcase = true
-- UI
opt.termguicolors = true
opt.signcolumn = "yes"
opt.cursorline = true
-- Splits
opt.splitbelow = true
opt.splitright = true
-- Clipboard
opt.clipboard = "unnamedplus"
-- Undo
opt.undofile = true
-- Mouse
opt.mouse = "a"

View file

@ -0,0 +1,84 @@
return {
-- Auto pairs
-- Automatically inserts a matching closing character
-- when you type an opening character like `"`, `[`, or `(`.
{
"nvim-mini/mini.pairs",
event = "VeryLazy",
opts = {
modes = { insert = true, command = true, terminal = false },
-- skip autopair when next character is one of these
skip_next = [=[[%w%%%'%[%"%%.%`%$]]=],
-- skip autopair when the cursor is inside these treesitter nodes
skip_ts = { "string" },
-- skip autopair when next character is closing pair
-- and there are more closing pairs than opening pairs
skip_unbalanced = true,
-- better deal with markdown code blocks
markdown = true,
},
config = function(_, opts)
LazyVim.mini.pairs(opts)
end,
},
-- Improves comment syntax, lets Neovim handle multiple
-- types of comments for a single language, and relaxes rules
-- for uncommenting.
{
"folke/ts-comments.nvim",
event = "VeryLazy",
opts = {},
},
-- Extends the a & i text objects, this adds the ability to select
-- arguments, function calls, text within quotes and brackets
{
"nvim-mini/mini.ai",
event = "VeryLazy",
opts = function()
local ai = require("mini.ai")
return {
n_lines = 500,
custom_textobjects = {
o = ai.gen_spec.treesitter({
a = { "@block.outer", "@conditional.outer", "@loop.outer" },
i = { "@block.inner", "@conditional.inner", "@loop.inner" },
}),
f = ai.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }),
c = ai.gen_spec.treesitter({ a = "@class.outer", i = "@class.inner" }),
t = { "<(%p%w-)%f[^<%w][^<>]->.*()</[^/]->$" },
d = { "%f[%d]%d+" },
e = { { "%u[%l%d]+%f[^%l%d]", "%f[%S][%l%d]+%f[^%l%d]" }, "^().*()$" },
g = LazyVim.mini.ai_buffer,
u = ai.gen_spec.function_call(),
U = ai.gen_spec.function_call({ name_pattern = "[%w_]" }),
},
}
end,
config = function(_, opts)
require("mini.ai").setup(opts)
LazyVim.on_load("which-key.nvim", function()
vim.schedule(function()
LazyVim.mini.ai_whichkey(opts)
end)
end)
end,
},
-- Configures LuaLS to support auto-completion and type checking
-- while editing your Neovim configuration.
{
"folke/lazydev.nvim",
ft = "lua",
cmd = "LazyDev",
opts = {
library = {
{ path = "${3rd}/luv/library", words = { "vim.uv" } },
{ path = "LazyVim", words = { "LazyVim" } },
{ path = "snacks.nvim", words = { "Snacks" } },
{ path = "lazy.nvim", words = { "LazyVim" } },
},
},
},
}

View file

@ -1,15 +1,71 @@
return {
-- gruvbox
{
"ellisonleao/gruvbox.nvim",
lazy = true,
priority = 1000,
opts = {},
},
-- tokyonight
{
"folke/tokyonight.nvim",
lazy = true,
opts = { style = "moon" },
},
-- catppuccin
{
"catppuccin/nvim",
lazy = false,
priority = 1000,
name = "catppuccin",
opts = {
terminal_colors = true,
transparent_mode = false,
lsp_styles = {
underlines = {
errors = { "undercurl" },
hints = { "undercurl" },
warnings = { "undercurl" },
information = { "undercurl" },
},
},
-- integrations = {
-- aerial = true,
-- alpha = true,
-- cmp = true,
-- dashboard = true,
-- flash = true,
-- fzf = true,
-- grug_far = true,
-- gitsigns = true,
-- headlines = true,
-- illuminate = true,
-- indent_blankline = { enabled = true },
-- leap = true,
-- lsp_trouble = true,
-- mason = true,
-- mini = true,
-- navic = { enabled = true, custom_bg = "lualine" },
-- neotest = true,
-- neotree = true,
-- noice = true,
-- notify = true,
-- snacks = true,
-- telescope = true,
-- treesitter_context = true,
-- which_key = true,
-- },
},
config = function(_, opts)
require("gruvbox").setup(opts)
vim.o.background = "dark"
vim.cmd.colorscheme("gruvbox")
end,
-- specs = {
-- {
-- "akinsho/bufferline.nvim",
-- optional = true,
-- opts = function(_, opts)
-- if (vim.g.colors_name or ""):find("catppuccin") then
-- opts.highlights = require("catppuccin.special.bufferline").get_theme()
-- end
-- end,
-- },
-- },
},
}

View file

@ -0,0 +1,44 @@
return {
-- Modern completion engine with built-in fuzzy matching
{
"saghen/blink.cmp",
dependencies = {
"rafamadriz/friendly-snippets",
},
version = "1.*",
event = "InsertEnter",
opts = {
-- Keymap preset options: 'default' | 'super-tab' | 'enter'
keymap = { preset = "default" },
appearance = {
-- Use mono nerd font variant
nerd_font_variant = "mono",
},
-- Default completion sources
sources = {
default = { "lsp", "path", "snippets", "buffer" },
},
completion = {
documentation = {
auto_show = true,
auto_show_delay_ms = 500,
},
menu = {
draw = {
columns = { { "label", "label_description", gap = 1 }, { "kind_icon", "kind" } },
},
},
},
-- Fuzzy matching implementation
-- Options: "prefer_rust_with_warning" | "rust" | "lua"
fuzzy = {
implementation = "prefer_rust_with_warning",
},
},
opts_extend = { "sources.default" },
},
}

View file

@ -0,0 +1,60 @@
return {
-- Telescope - Fuzzy finder over lists
{
"nvim-telescope/telescope.nvim",
tag = "0.1.8",
dependencies = {
"nvim-lua/plenary.nvim",
},
cmd = "Telescope",
keys = {
{ "<leader>ff", "<cmd>Telescope find_files<cr>", desc = "Find Files" },
{ "<leader>fg", "<cmd>Telescope live_grep<cr>", desc = "Live Grep" },
{ "<leader>fb", "<cmd>Telescope buffers<cr>", desc = "Buffers" },
{ "<leader>fh", "<cmd>Telescope help_tags<cr>", desc = "Help Tags" },
},
opts = {
defaults = {
mappings = {
i = {
["<C-h>"] = "which_key",
},
},
},
},
},
-- Telescope FZF native - Better sorting performance
{
"nvim-telescope/telescope-fzf-native.nvim",
build = "make",
dependencies = { "nvim-telescope/telescope.nvim" },
config = function()
require("telescope").load_extension("fzf")
end,
},
-- Neo-tree - File explorer tree
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
"nvim-tree/nvim-web-devicons",
},
cmd = "Neotree",
keys = {
{ "<leader>e", "<cmd>Neotree toggle<cr>", desc = "Toggle Neo-tree" },
{ "<leader>o", "<cmd>Neotree focus<cr>", desc = "Focus Neo-tree" },
},
opts = {
filesystem = {
follow_current_file = {
enabled = true,
},
use_libuv_file_watcher = true,
},
},
},
}

View file

@ -0,0 +1,48 @@
return {
{
"mfussenegger/nvim-lint",
event = { "BufReadPost", "BufNewFile", "BufWritePost" },
opts = {
events = { "BufWritePost", "BufReadPost", "InsertLeave" },
linters_by_ft = {
-- Add linters per filetype here
-- fish = { "fish" },
-- javascript = { "eslint_d" },
-- python = { "ruff" },
},
linters = {},
},
config = function(_, opts)
local lint = require("lint")
-- Merge custom linter configs
for name, linter in pairs(opts.linters) do
if type(linter) == "table" and type(lint.linters[name]) == "table" then
lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name], linter)
else
lint.linters[name] = linter
end
end
lint.linters_by_ft = opts.linters_by_ft
-- Debounced lint function
local function debounce_lint()
local timer = vim.uv.new_timer()
return function()
timer:start(100, 0, vim.schedule_wrap(lint.try_lint))
end
end
local lint_fn = debounce_lint()
-- Create autocommand for linting
vim.api.nvim_create_autocmd(opts.events, {
group = vim.api.nvim_create_augroup("nvim-lint", { clear = true }),
callback = function()
lint_fn()
end,
})
end,
},
}

View file

@ -1,29 +0,0 @@
-- Declare language servers provided via Nix so LazyVim skips Mason installs.
return {
{
"mason-org/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = {}
end,
},
{
"neovim/nvim-lspconfig",
opts = function(_, opts)
opts.servers = opts.servers or {}
local servers = {
lua_ls = { mason = false },
nil_ls = { mason = false },
pyright = { mason = false },
tsserver = { mason = false },
rust_analyzer = { mason = false },
gopls = { mason = false },
clangd = { mason = false },
}
for server, server_opts in pairs(servers) do
local existing = opts.servers[server] or {}
opts.servers[server] = vim.tbl_deep_extend("force", existing, server_opts)
end
end,
},
}

View file

@ -1,6 +0,0 @@
-- Override mini.pick with the new repository location
return {
{
"nvim-mini/mini.pick",
},
}

View file

@ -1,6 +0,0 @@
return {
{
"sphamba/smear-cursor.nvim",
opts = {},
},
}

View file

@ -0,0 +1,42 @@
return {
{
"nvim-treesitter/nvim-treesitter",
version = false,
build = ":TSUpdate",
event = { "BufReadPost", "BufNewFile" },
cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" },
opts = {
highlight = { enable = true },
indent = { enable = true },
ensure_installed = {
"bash",
"c",
"diff",
"html",
"javascript",
"jsdoc",
"json",
"jsonc",
"lua",
"luadoc",
"luap",
"markdown",
"markdown_inline",
"printf",
"python",
"query",
"regex",
"toml",
"tsx",
"typescript",
"vim",
"vimdoc",
"xml",
"yaml",
},
},
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
end,
},
}

View file

@ -0,0 +1,174 @@
return {
-- Better UI for messages, cmdline and the popupmenu
{
"folke/noice.nvim",
event = "VeryLazy",
opts = {
lsp = {
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true,
},
},
routes = {
{
filter = {
event = "msg_show",
any = {
{ find = "%d+L, %d+B" },
{ find = "; after #%d+" },
{ find = "; before #%d+" },
},
},
view = "mini",
},
},
presets = {
bottom_search = true,
command_palette = true,
long_message_to_split = true,
},
},
keys = {
{ "<leader>sn", "", desc = "+noice" },
{ "<leader>snl", function() require("noice").cmd("last") end, desc = "Noice Last Message" },
{ "<leader>snh", function() require("noice").cmd("history") end, desc = "Noice History" },
{ "<leader>sna", function() require("noice").cmd("all") end, desc = "Noice All" },
{ "<leader>snd", function() require("noice").cmd("dismiss") end, desc = "Dismiss All" },
},
dependencies = {
"MunifTanjim/nui.nvim",
},
},
-- Statusline
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
opts = function()
return {
options = {
theme = "auto",
globalstatus = true,
disabled_filetypes = { statusline = { "dashboard", "alpha", "starter" } },
},
sections = {
lualine_a = { "mode" },
lualine_b = { "branch" },
lualine_c = {
{
"diagnostics",
symbols = {
error = " ",
warn = " ",
info = " ",
hint = " ",
},
},
{ "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } },
{ "filename", path = 1, symbols = { modified = " ", readonly = "", unnamed = "" } },
},
lualine_x = {
{
"diff",
symbols = {
added = " ",
modified = " ",
removed = " ",
},
},
},
lualine_y = {
{ "progress", separator = " ", padding = { left = 1, right = 0 } },
{ "location", padding = { left = 0, right = 1 } },
},
lualine_z = {
function()
return " " .. os.date("%R")
end,
},
},
extensions = { "lazy" },
}
end,
},
-- Bufferline
{
"akinsho/bufferline.nvim",
event = "VeryLazy",
keys = {
{ "<leader>bp", "<Cmd>BufferLineTogglePin<CR>", desc = "Toggle Pin" },
{ "<leader>bP", "<Cmd>BufferLineGroupClose ungrouped<CR>", desc = "Delete Non-Pinned Buffers" },
{ "<leader>bo", "<Cmd>BufferLineCloseOthers<CR>", desc = "Delete Other Buffers" },
{ "<leader>br", "<Cmd>BufferLineCloseRight<CR>", desc = "Delete Buffers to the Right" },
{ "<leader>bl", "<Cmd>BufferLineCloseLeft<CR>", desc = "Delete Buffers to the Left" },
{ "<S-h>", "<cmd>BufferLineCyclePrev<cr>", desc = "Prev Buffer" },
{ "<S-l>", "<cmd>BufferLineCycleNext<cr>", desc = "Next Buffer" },
{ "[b", "<cmd>BufferLineCyclePrev<cr>", desc = "Prev Buffer" },
{ "]b", "<cmd>BufferLineCycleNext<cr>", desc = "Next Buffer" },
},
opts = {
options = {
close_command = function(n) require("mini.bufremove").delete(n, false) end,
right_mouse_command = function(n) require("mini.bufremove").delete(n, false) end,
diagnostics = "nvim_lsp",
always_show_bufferline = false,
offsets = {
{
filetype = "neo-tree",
text = "Neo-tree",
highlight = "Directory",
text_align = "left",
},
},
},
},
dependencies = {
{
"nvim-mini/mini.bufremove",
keys = {
{ "<leader>bd", function() require("mini.bufremove").delete(0, false) end, desc = "Delete Buffer" },
{ "<leader>bD", function() require("mini.bufremove").delete(0, true) end, desc = "Delete Buffer (Force)" },
},
opts = {},
},
},
},
-- Indent guides
{
"lukas-reineke/indent-blankline.nvim",
event = { "BufReadPost", "BufNewFile" },
opts = {
indent = {
char = "",
tab_char = "",
},
scope = { show_start = false, show_end = false },
exclude = {
filetypes = {
"help",
"alpha",
"dashboard",
"neo-tree",
"Trouble",
"trouble",
"lazy",
"mason",
"notify",
"toggleterm",
"lazyterm",
},
},
},
main = "ibl",
},
-- Icons
{
"nvim-tree/nvim-web-devicons",
lazy = true,
},
}