This commit is contained in:
2025-11-04 21:14:52 -05:00
parent d79133a5c8
commit ed70e76056
2 changed files with 140 additions and 57 deletions

View File

@@ -1,3 +1,5 @@
vim.g.mapleader = " "
vim.opt.number = true vim.opt.number = true
vim.opt.relativenumber = true vim.opt.relativenumber = true
vim.opt.swapfile = false vim.opt.swapfile = false
@@ -5,70 +7,139 @@ vim.opt.wrap = false
vim.opt.splitright = true vim.opt.splitright = true
vim.opt.splitbelow = true vim.opt.splitbelow = true
vim.g.mapleader = " "
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
for _, k in ipairs({ "h", "j", "k", "l" }) do
vim.keymap.set({ "n", "i", "v" }, "<C-" .. k .. ">", "<C-w><C-" .. k .. ">")
end
vim.keymap.set("n", "<Esc>", ":nohlsearch<CR>") vim.keymap.set("n", "<Esc>", ":nohlsearch<CR>")
vim.keymap.set("n", "<leader>en", ":edit $MYVIMRC<CR>") vim.keymap.set("n", "<leader>en", ":edit $MYVIMRC<CR>")
vim.keymap.set("n", "<leader>ez", ":edit ~/.zshrc<CR>") vim.keymap.set("n", "<leader>ez", ":edit ~/.zshrc<CR>")
vim.pack.add { vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
{ src = "https://github.com/nvim-lua/plenary.nvim" }, vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
{ src = "https://github.com/nvim-telescope/telescope.nvim" },
{ src = "https://github.com/nvim-telescope/telescope-ui-select.nvim" },
{ src = "https://github.com/neovim/nvim-lspconfig" },
{ src = "https://github.com/blazkowolf/gruber-darker.nvim" },
}
local telescope = require("telescope") for _, k in ipairs({ "h", "j", "k", "l" }) do
telescope.setup({ vim.keymap.set({ "n", "i", "v" }, "<C-" .. k .. ">", "<C-w><C-" .. k .. ">")
defaults = { end
preview = { treesitter = false },
color_devicons = true,
sorting_strategy = "ascending",
borderchars = {
"", -- top
"", -- right
"", -- bottom
"", -- left
"", -- top-left
"", -- top-right
"", -- bottom-right
"", -- bottom-left
},
path_displays = { "smart" },
layout_config = {
height = 100,
width = 400,
prompt_position = "top",
preview_cutoff = 40,
}
}
})
telescope.load_extension("ui-select")
local builtin = require('telescope.builtin') local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
vim.keymap.set('n', '<leader>sf', builtin.find_files) if not vim.loop.fs_stat(lazypath) then
vim.keymap.set('n', '<leader>sg', builtin.live_grep) vim.fn.system({
vim.keymap.set('n', '<leader>sb', builtin.buffers) "git",
vim.keymap.set('n', '<leader>sh', builtin.help_tags) "clone",
vim.keymap.set('n', '<leader>sm', builtin.man_pages) "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
vim.api.nvim_create_autocmd("FileType", { require("lazy").setup({
pattern = { "c", "cpp", "h", "hpp" }, {
callback = function() "blazkowolf/gruber-darker.nvim",
vim.lsp.start { priority = 1000,
name = "clangd", config = function()
cmd = { "clangd", "--background-index", "--clang-tidy", "--completion-style=detailed", "--header-insertion=iwyu" }, vim.cmd.colorscheme("gruber-darker")
root_dir = vim.fs.dirname(vim.fs.find({ ".git", "Makefile", "makefile", "README" }, { upward = true })[1]), end,
} },
end, {
"williamboman/mason.nvim",
build = ":MasonUpdate",
config = function()
require("mason").setup()
end,
},
{
"williamboman/mason-lspconfig.nvim",
dependencies = { "williamboman/mason.nvim", "neovim/nvim-lspconfig" },
config = function()
local ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
local capabilities = ok and cmp_nvim_lsp.default_capabilities() or
vim.lsp.protocol.make_client_capabilities()
local servers = { "lua_ls", "clangd", "pyright", "gopls" }
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = servers,
})
for _, name in ipairs(servers) do
local cfg = { capabilities = capabilities }
if name == "lua_ls" then
cfg.settings = {
Lua = {
diagnostics = { globals = { "vim" } },
workspace = { library = vim.api.nvim_get_runtime_file("", true) },
},
}
end
local server_cfg = vim.lsp.config[name]
if not server_cfg then
vim.notify("LSP server config not found: " .. name, vim.log.levels.WARN)
else
local cmd = server_cfg.cmd or { name }
vim.lsp.start(vim.tbl_extend("force", cfg, {
name = name,
cmd = cmd,
root_dir = vim.fs.root(0, { ".git", "Makefile", "main.c", "go.mod" }),
settings = cfg.settings,
}))
end
end
end,
},
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
},
config = function()
local cmp = require("cmp")
cmp.setup({
mapping = cmp.mapping.preset.insert({
["<C-y>"] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(),
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-p>"] = cmp.mapping.select_prev_item(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "buffer" },
{ name = "path" },
}),
})
end,
},
{
"folke/snacks.nvim",
priority = 1000,
lazy = false,
opts = {
bigfile = { enabled = true },
picker = { enabled = true },
quickfile = { enabled = true },
terminal = {
enabled = true,
float = {
border = "rounded",
width = 0.8,
height = 0.8,
},
},
},
config = function(_, opts)
require("snacks").setup(opts)
vim.keymap.set("n", "<C-_>", function()
require("snacks.terminal").toggle(nil, { float = true })
end)
vim.keymap.set("t", "<C-_>", function()
require("snacks.terminal").toggle(nil, { float = true })
end)
end,
},
}) })
vim.diagnostic.config { virtual_text = true, underline = true, signs = false } vim.diagnostic.config { virtual_text = true, underline = true, signs = false }
vim.cmd.colorscheme("gruber-darker")

View File

@@ -0,0 +1,12 @@
{
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
"cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" },
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
"gruber-darker.nvim": { "branch": "main", "commit": "98a2e141981cbd5a194a97eae024bf55af854579" },
"lazy.nvim": { "branch": "main", "commit": "e6a8824858757ca9cd4f5ae1a72d845fa5c46a39" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "d7b5feb6e769e995f7fcf44d92f49f811c51d10c" },
"mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" },
"nvim-cmp": { "branch": "main", "commit": "106c4bcc053a5da783bf4a9d907b6f22485c2ea0" },
"nvim-lspconfig": { "branch": "master", "commit": "2010fc6ec03e2da552b4886fceb2f7bc0fc2e9c0" },
"snacks.nvim": { "branch": "main", "commit": "6121b40a2d2fc07beee040209d59e579aad51d98" }
}