129 lines
3.5 KiB
Lua
129 lines
3.5 KiB
Lua
vim.g.mapleader = " "
|
|
vim.g.maplocalleader = " "
|
|
|
|
-- 1. Lazy.nvim Bootstrapping
|
|
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(lazypath)
|
|
|
|
-- 2. Plugins
|
|
require("lazy").setup({
|
|
{ "catppuccin/nvim", name = "catppuccin", priority = 1000 },
|
|
{ "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" } },
|
|
{ "neovim/nvim-lspconfig" },
|
|
{ "folke/which-key.nvim", event = "VeryLazy" },
|
|
{ "nvim-tree/nvim-tree.lua", dependencies = { "nvim-tree/nvim-web-devicons" } },
|
|
|
|
-- [NEW] Autocomplete & Snippets
|
|
{
|
|
"hrsh7th/nvim-cmp",
|
|
dependencies = {
|
|
"hrsh7th/cmp-nvim-lsp", -- Connects LSP to completion
|
|
"L3MON4D3/LuaSnip", -- Snippet engine (Required for arguments)
|
|
"saadparwaiz1/cmp_luasnip",
|
|
},
|
|
},
|
|
|
|
{
|
|
'akinsho/toggleterm.nvim',
|
|
version = "*",
|
|
config = function()
|
|
require("toggleterm").setup({
|
|
size = 20,
|
|
open_mapping = [[<C-q>]], -- This sets the trigger
|
|
direction = 'float', -- This makes it floating
|
|
float_opts = {
|
|
border = 'curved', -- Options: 'single', 'double', 'shadow', 'curved'
|
|
},
|
|
})
|
|
end
|
|
}
|
|
})
|
|
|
|
-- 3. Theme & Settings
|
|
vim.cmd.colorscheme "catppuccin-mocha"
|
|
vim.opt.number = true
|
|
vim.opt.relativenumber = true
|
|
|
|
-- 4. Tree Setup (Small & Minimal)
|
|
require("nvim-tree").setup({
|
|
view = { width = 30, side = "left" },
|
|
filters = { dotfiles = false, custom = { ".git", "zig-cache", "zig-out" } },
|
|
})
|
|
|
|
-- 5. Autocomplete Setup
|
|
local cmp = require('cmp')
|
|
local luasnip = require('luasnip')
|
|
|
|
-- This is the "secret sauce" that tells ZLS your editor can handle
|
|
-- the advanced "return ." and "self." completion data.
|
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
|
|
|
cmp.setup({
|
|
snippet = {
|
|
expand = function(args) luasnip.lsp_expand(args.body) end,
|
|
},
|
|
completion = {
|
|
autocomplete = { cmp.TriggerEvent.TextChanged },
|
|
keyword_length = 1,
|
|
},
|
|
mapping = cmp.mapping.preset.insert({
|
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
elseif luasnip.expand_or_jumpable() then
|
|
luasnip.expand_or_jump()
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" }),
|
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_prev_item()
|
|
elseif luasnip.jumpable(-1) then
|
|
luasnip.jump(-1)
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" }),
|
|
}),
|
|
sources = cmp.config.sources({
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'luasnip' },
|
|
}),
|
|
window = {
|
|
completion = cmp.config.window.bordered(),
|
|
documentation = cmp.config.window.bordered(),
|
|
},
|
|
})
|
|
|
|
-- 6. Modern LSP Setup (Neovim 0.11 native)
|
|
-- We define the config, then enable it.
|
|
vim.lsp.enable('zls')
|
|
vim.lsp.config('zls', {
|
|
cmd = { 'zls' },
|
|
filetypes = { 'zig', 'zir' },
|
|
root_markers = { 'build.zig', '.git' },
|
|
-- Pass the capabilities and ZLS-specific settings here:
|
|
capabilities = capabilities,
|
|
settings = {
|
|
zls = {
|
|
enable_snippets = true,
|
|
enable_argument_placeholders = true,
|
|
operator_completions = true,
|
|
enable_autofix = true,
|
|
},
|
|
},
|
|
})
|
|
|
|
-- 7. Auto-format on Save
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
pattern = "*.zig",
|
|
callback = function() vim.lsp.buf.format() end,
|
|
})
|
|
|
|
require("keymaps")
|