Initial commit
This commit is contained in:
parent
2850bcab1f
commit
0383a26c91
51
init.lua
Normal file
51
init.lua
Normal file
@ -0,0 +1,51 @@
|
||||
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" } },
|
||||
})
|
||||
|
||||
-- 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, -- Small width
|
||||
side = "left",
|
||||
},
|
||||
filters = {
|
||||
dotfiles = false,
|
||||
custom = { ".git", "zig-cache", "zig-out" }, -- Hide build clutter
|
||||
},
|
||||
})
|
||||
|
||||
-- 5. Modern LSP Setup (Neovim 0.11+)
|
||||
vim.lsp.config('zls', {
|
||||
cmd = { 'zls' },
|
||||
filetypes = { 'zig', 'zir' },
|
||||
root_markers = { 'build.zig', 'zls.json', '.git' },
|
||||
})
|
||||
vim.lsp.enable('zls')
|
||||
|
||||
-- 6. Auto-format
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
pattern = "*.zig",
|
||||
callback = function() vim.lsp.buf.format() end,
|
||||
})
|
||||
|
||||
require("keymaps")
|
||||
10
lazy-lock.json
Normal file
10
lazy-lock.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"catppuccin": { "branch": "main", "commit": "beaf41a30c26fd7d6c386d383155cbd65dd554cd" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "f4e9d367d4e067d7a5fabc9fd3f1349b291eb718" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "c0b18e4879f7b29a17a240ad49f733af7a7fb348" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "746ffbb17975ebd6c40142362eee1b0249969c5c" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }
|
||||
}
|
||||
51
lua/keymaps.lua
Normal file
51
lua/keymaps.lua
Normal file
@ -0,0 +1,51 @@
|
||||
local wk = require("which-key")
|
||||
local builtin = require('telescope.builtin')
|
||||
|
||||
wk.add({
|
||||
-- Essentials
|
||||
{ "<leader>w", "<cmd>w<cr>", desc = "Save File" },
|
||||
{ "<leader>q", "<cmd>q<cr>", desc = "Quit" },
|
||||
{ "<leader>e", "<cmd>NvimTreeToggle<cr>", desc = "Toggle Explorer (Tree)" },
|
||||
|
||||
-- Navigation / Buffers
|
||||
{ "<leader>[", "<cmd>bprevious<cr>", desc = "Prev Buffer" },
|
||||
{ "<leader>]", "<cmd>bnext<cr>", desc = "Next Buffer" },
|
||||
{ "<leader>b", builtin.buffers, desc = "List Buffers (Telescope)" },
|
||||
{ "<leader>x", "<cmd>bdelete<cr>", desc = "Close Buffer" },
|
||||
|
||||
-- File Group
|
||||
{ "<leader>f", group = "File" },
|
||||
{ "<leader>fn", function()
|
||||
local name = vim.fn.input("New file/dir: ")
|
||||
if name == "" then return end
|
||||
if name:sub(-1) == "/" then
|
||||
vim.fn.mkdir(name, "p")
|
||||
else
|
||||
local dir = vim.fn.fnamemodify(name, ":h")
|
||||
if vim.fn.isdirectory(dir) == 0 then vim.fn.mkdir(dir, "p") end
|
||||
vim.cmd("edit " .. name)
|
||||
end
|
||||
end, desc = "New File/Dir" },
|
||||
|
||||
{ "<leader>fd", function()
|
||||
local current_file = vim.api.nvim_buf_get_name(0)
|
||||
if current_file == "" then return end
|
||||
if vim.fn.confirm("Delete " .. current_file .. "?", "&Yes\n&No", 2) == 1 then
|
||||
os.remove(current_file)
|
||||
vim.api.nvim_buf_delete(0, { force = true })
|
||||
end
|
||||
end, desc = "Delete Current File" },
|
||||
|
||||
-- Search Group
|
||||
{ "<leader>s", group = "Search" },
|
||||
{ "<leader>sf", builtin.find_files, desc = "Files" },
|
||||
{ "<leader>sw", builtin.live_grep, desc = "Word (Global)" },
|
||||
|
||||
-- Symbol Searching
|
||||
{ "<leader>ss", builtin.lsp_dynamic_workspace_symbols, desc = "Workspace Symbols" },
|
||||
{ "<leader>sl", builtin.lsp_document_symbols, desc = "Document Symbols (Current File)" },
|
||||
|
||||
-- LSP
|
||||
{ "gd", vim.lsp.buf.definition, desc = "Go to Definition" },
|
||||
{ "K", vim.lsp.buf.hover, desc = "Hover Documentation" },
|
||||
})
|
||||
17
lua/lsp.lua
Normal file
17
lua/lsp.lua
Normal file
@ -0,0 +1,17 @@
|
||||
local configs = require 'nvim_lsp/configs'
|
||||
local util = require 'nvim_lsp/util'
|
||||
|
||||
configs.zls = {
|
||||
default_config = {
|
||||
cmd = {"/usr/local/bin/zls"};
|
||||
filetypes = {"zig"};
|
||||
root_dir = util.root_pattern("build.zig", ".git");
|
||||
};
|
||||
docs = {
|
||||
description = [[ ]];
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("build.zig", ".git")]];
|
||||
};
|
||||
};
|
||||
}
|
||||
-- vim:et ts=2 sw=2
|
||||
19
lua/telescope.lua
Normal file
19
lua/telescope.lua
Normal file
@ -0,0 +1,19 @@
|
||||
local builtin = require('telescope.builtin')
|
||||
|
||||
-- 1. Search for words across all files (Project-wide grep)
|
||||
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Find by Grep' })
|
||||
|
||||
-- 2. General File Search
|
||||
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Find Files' })
|
||||
|
||||
-- 3. Targeted Struct/Model Search
|
||||
-- This opens Telescope filtered specifically to your models.zig file
|
||||
vim.keymap.set('n', '<leader>fm', function()
|
||||
builtin.live_grep({
|
||||
search_dirs = { "src/models.zig" }, -- Adjust path if necessary
|
||||
prompt_title = "Search Structs in Models",
|
||||
})
|
||||
end, { desc = 'Search in models.zig' })
|
||||
|
||||
-- 4. LSP Symbol Search (Great for finding structs in the current file)
|
||||
vim.keymap.set('n', '<leader>fs', builtin.lsp_document_symbols, { desc = 'Find Symbols' })
|
||||
Loading…
x
Reference in New Issue
Block a user