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"