feat: nvim new configs

This commit is contained in:
Rasyidan Akbar F. 2025-10-28 20:32:32 +07:00
commit 553ef00fa9
17 changed files with 447 additions and 96 deletions

View file

@ -17,12 +17,21 @@ vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
require("lazy").setup({
spec = {
{
"LazyVim/LazyVim",
import = "lazyvim.plugins",
},
{ import = "plugins" },
{ import = "config.lazyvim" },
},
defaults = {
lazy = false,
version = false,
},
install = { colorscheme = { "gruvbox", "habamax" } },
checker = { enabled = false },

View file

@ -0,0 +1,53 @@
-- LazyVim utilities module
-- Provides helper functions for plugin configuration
local M = {}
-- Mini module utilities
M.mini = {}
-- Setup mini.pairs with given options
function M.mini.pairs(opts)
require("mini.pairs").setup(opts)
end
-- Text object for entire buffer
M.mini.ai_buffer = function(ai)
local n_lines = vim.fn.line("$")
local start_line, end_line = 1, n_lines
if n_lines == 0 then
return { from = { line = 0, col = 0 } }
end
local start_col, end_col = 1, math.max(vim.fn.getline(end_line):len(), 1)
return {
from = { line = start_line, col = start_col },
to = { line = end_line, col = end_col },
}
end
-- Text object hints are now handled by mini.clue
-- Run callback when plugin is loaded
function M.on_load(name, fn)
local Config = require("lazy.core.config")
if Config.plugins[name] and Config.plugins[name]._.loaded then
vim.schedule(function()
fn(name)
end)
else
vim.api.nvim_create_autocmd("User", {
pattern = "LazyLoad",
callback = function(event)
if event.data == name then
fn(name)
return true
end
end,
})
end
end
-- Make LazyVim global
_G.LazyVim = M
return M

View file

@ -1,70 +1,106 @@
-- Enable language servers defined in nvim-lspconfig using the Nvim 0.11 API.
-- LSP configuration using Nix-managed servers
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,
},
-- Disable Mason plugins (we use Nix-managed servers instead)
{ "mason-org/mason.nvim", enabled = false },
{ "mason-org/mason-lspconfig.nvim", enabled = false },
{ "jay-babu/mason-null-ls.nvim", enabled = false },
{ "jay-babu/mason-nvim-dap.nvim", enabled = false },
{
"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 = {},
dependencies = {
"saghen/blink.cmp", -- For LSP capabilities
},
config = function()
-- Get blink.cmp capabilities
local capabilities = require("blink.cmp").get_lsp_capabilities()
-- Common LSP attach keybindings
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
local opts = { buffer = ev.buf }
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts)
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
end,
})
-- Configure each LSP server
local lspconfig = require("lspconfig")
-- Lua
lspconfig.lua_ls.setup({
capabilities = capabilities,
settings = {
Lua = {
runtime = { version = "LuaJIT" },
diagnostics = { globals = { "vim" } },
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
checkThirdParty = false,
},
telemetry = { enable = false },
},
},
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 {}
-- Nix
lspconfig.nil_ls.setup({
capabilities = capabilities,
settings = {
["nil"] = {
formatting = { command = { "nixfmt" } },
},
},
})
if config.enabled ~= false then
config.enabled = nil
-- Python
lspconfig.pyright.setup({
capabilities = capabilities,
settings = {
python = {
analysis = {
typeCheckingMode = "basic",
autoSearchPaths = true,
useLibraryCodeForTypes = true,
},
},
},
})
-- 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
-- TypeScript/JavaScript
lspconfig.ts_ls.setup({
capabilities = capabilities,
})
if next(config) ~= nil then
vim.lsp.config(name, config)
end
-- Rust
lspconfig.rust_analyzer.setup({
capabilities = capabilities,
settings = {
["rust-analyzer"] = {
checkOnSave = { command = "clippy" },
},
},
})
vim.lsp.enable(name)
end
end
end
-- Go
lspconfig.gopls.setup({
capabilities = capabilities,
})
-- C/C++
lspconfig.clangd.setup({
capabilities = capabilities,
})
end,
},
}

View file

@ -58,11 +58,7 @@ return {
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)
-- mini.clue handles text object hints automatically
end,
},

View file

@ -2,9 +2,13 @@ return {
-- gruvbox
{
"ellisonleao/gruvbox.nvim",
lazy = true,
lazy = false,
priority = 1000,
opts = {},
config = function()
require("gruvbox").setup({})
vim.cmd.colorscheme("gruvbox")
end,
},
-- tokyonight
@ -17,7 +21,7 @@ return {
-- catppuccin
{
"catppuccin/nvim",
lazy = false,
lazy = true,
priority = 1000,
name = "catppuccin",
opts = {

View file

@ -1,5 +1,6 @@
return {
-- Modern completion engine with built-in fuzzy matching
-- Note: Installed via Nix with pre-built Rust backend (see neovim.nix)
{
"saghen/blink.cmp",
dependencies = {
@ -7,6 +8,7 @@ return {
},
version = "1.*",
event = "InsertEnter",
build = nil, -- Disable build since Nix provides pre-compiled version
opts = {
-- Keymap preset options: 'default' | 'super-tab' | 'enter'
keymap = { preset = "default" },
@ -34,9 +36,11 @@ return {
},
-- Fuzzy matching implementation
-- Options: "prefer_rust_with_warning" | "rust" | "lua"
-- Using "rust" since Nix provides pre-built native module
fuzzy = {
implementation = "prefer_rust_with_warning",
use_typo_resistance = true,
use_frecency = true,
use_proximity = true,
},
},
opts_extend = { "sources.default" },

View file

@ -15,19 +15,15 @@ return {
},
opts = {
defaults = {
mappings = {
i = {
["<C-h>"] = "which_key",
},
},
-- Removed which_key mapping - mini.clue handles keybind hints globally
},
},
},
-- Telescope FZF native - Better sorting performance
-- Note: Installed via Nix (see neovim.nix) to avoid build issues
{
"nvim-telescope/telescope-fzf-native.nvim",
build = "make",
dependencies = { "nvim-telescope/telescope.nvim" },
config = function()
require("telescope").load_extension("fzf")

View file

@ -0,0 +1,59 @@
return {
{
"stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo" },
keys = {
{
"<leader>cf",
function()
require("conform").format({ async = true, lsp_fallback = true })
end,
mode = { "n", "v" },
desc = "Format buffer",
},
},
opts = {
formatters_by_ft = {
lua = { "stylua" },
nix = { "nixfmt" },
python = { "ruff_format", "ruff_organize_imports" },
javascript = { "prettierd", "prettier", stop_after_first = true },
typescript = { "prettierd", "prettier", stop_after_first = true },
javascriptreact = { "prettierd", "prettier", stop_after_first = true },
typescriptreact = { "prettierd", "prettier", stop_after_first = true },
json = { "prettierd", "prettier", stop_after_first = true },
jsonc = { "prettierd", "prettier", stop_after_first = true },
yaml = { "prettierd", "prettier", stop_after_first = true },
markdown = { "prettierd", "prettier", stop_after_first = true },
html = { "prettierd", "prettier", stop_after_first = true },
css = { "prettierd", "prettier", stop_after_first = true },
scss = { "prettierd", "prettier", stop_after_first = true },
rust = { "rustfmt" },
go = { "gofumpt" },
sh = { "shfmt" },
bash = { "shfmt" },
zsh = { "shfmt" },
},
-- Format on save
format_on_save = {
timeout_ms = 500,
lsp_fallback = true,
},
-- Customize formatters
formatters = {
shfmt = {
prepend_args = { "-i", "2" }, -- 2 space indent
},
ruff_format = {
command = "ruff",
args = { "format", "--stdin-filename", "$FILENAME" },
},
ruff_organize_imports = {
command = "ruff",
args = { "check", "--select", "I", "--fix", "--stdin-filename", "$FILENAME" },
},
},
},
},
}

View file

@ -5,10 +5,13 @@ return {
opts = {
events = { "BufWritePost", "BufReadPost", "InsertLeave" },
linters_by_ft = {
-- Add linters per filetype here
-- fish = { "fish" },
-- javascript = { "eslint_d" },
-- python = { "ruff" },
javascript = { "eslint" },
typescript = { "eslint" },
javascriptreact = { "eslint" },
typescriptreact = { "eslint" },
python = { "ruff" },
sh = { "shellcheck" },
bash = { "shellcheck" },
},
linters = {},
},
@ -26,21 +29,28 @@ return {
lint.linters_by_ft = opts.linters_by_ft
-- Debounced lint function
-- Debounced lint function with proper timer management
local timer = vim.uv.new_timer()
local function debounce_lint()
local timer = vim.uv.new_timer()
return function()
timer:start(100, 0, vim.schedule_wrap(lint.try_lint))
end
-- Stop existing timer before starting new one to prevent EALREADY error
timer:stop()
timer:start(100, 0, vim.schedule_wrap(lint.try_lint))
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 = debounce_lint,
})
-- Clean up timer on exit
vim.api.nvim_create_autocmd("VimLeavePre", {
group = vim.api.nvim_create_augroup("nvim-lint-cleanup", { clear = true }),
callback = function()
lint_fn()
if timer and not timer:is_closing() then
timer:stop()
timer:close()
end
end,
})
end,

View file

@ -1,42 +1,51 @@
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",
"cpp",
"css",
"diff",
"dockerfile",
"git_config",
"git_rebase",
"gitcommit",
"gitignore",
"go",
"gomod",
"gosum",
"html",
"javascript",
"jsdoc",
"json",
"jsonc",
"latex",
"lua",
"luadoc",
"luap",
"markdown",
"markdown_inline",
"nix",
"norg",
"printf",
"python",
"query",
"regex",
"rust",
"scss",
"svelte",
"toml",
"tsx",
"typescript",
"typst",
"vim",
"vimdoc",
"vue",
"xml",
"yaml",
},
},
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
end,
},
}

View file

@ -0,0 +1,78 @@
return {
-- Disable which-key (we use mini.clue instead)
{ "folke/which-key.nvim", enabled = false },
-- mini.clue - Lightweight keybind hints
{
"nvim-mini/mini.clue",
event = "VeryLazy",
config = function()
local miniclue = require("mini.clue")
miniclue.setup({
triggers = {
-- Leader triggers
{ mode = "n", keys = "<Leader>" },
{ mode = "x", keys = "<Leader>" },
-- Built-in completion
{ mode = "i", keys = "<C-x>" },
-- `g` key
{ mode = "n", keys = "g" },
{ mode = "x", keys = "g" },
-- Marks
{ mode = "n", keys = "'" },
{ mode = "n", keys = "`" },
{ mode = "x", keys = "'" },
{ mode = "x", keys = "`" },
-- Registers
{ mode = "n", keys = '"' },
{ mode = "x", keys = '"' },
{ mode = "i", keys = "<C-r>" },
{ mode = "c", keys = "<C-r>" },
-- Window commands
{ mode = "n", keys = "<C-w>" },
-- `z` key
{ mode = "n", keys = "z" },
{ mode = "x", keys = "z" },
-- Bracketed commands
{ mode = "n", keys = "[" },
{ mode = "n", keys = "]" },
},
clues = {
-- Enhance this by adding descriptions for <Leader> mapping groups
miniclue.gen_clues.builtin_completion(),
miniclue.gen_clues.g(),
miniclue.gen_clues.marks(),
miniclue.gen_clues.registers(),
miniclue.gen_clues.windows(),
miniclue.gen_clues.z(),
-- Custom leader key descriptions
{ mode = "n", keys = "<Leader>b", desc = "+buffer" },
{ mode = "n", keys = "<Leader>c", desc = "+code" },
{ mode = "n", keys = "<Leader>d", desc = "+diagnostics" },
{ mode = "n", keys = "<Leader>e", desc = "+explorer" },
{ mode = "n", keys = "<Leader>f", desc = "+find" },
{ mode = "n", keys = "<Leader>o", desc = "+open" },
{ mode = "n", keys = "<Leader>r", desc = "+rename" },
{ mode = "n", keys = "<Leader>s", desc = "+search" },
},
window = {
delay = 300, -- Show hints after 300ms
config = {
width = "auto",
border = "rounded",
},
},
})
end,
},
}