New: NVIM Config

This commit is contained in:
Afonso Clerigo Mendes de Sousa 2025-10-15 12:28:49 +01:00
commit 8b3409c88b
9 changed files with 357 additions and 0 deletions

108
init.lua Normal file
View File

@ -0,0 +1,108 @@
-- BOOTSTRAP LAZY.NVIM
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)
-- LAZY SETUP
require("lazy").setup({
-- 🧠 CORE UTILITIES
{ "nvim-lua/plenary.nvim" },
{ "ldelossa/nvim-ide" },
{ "folke/which-key.nvim" },
{
"akinsho/bufferline.nvim",
version = "*",
dependencies = { "nvim-tree/nvim-web-devicons" },
},
-- 📁 FILE NAVIGATION
{ "nvim-telescope/telescope.nvim", tag = "0.1.5", dependencies = { "nvim-lua/plenary.nvim" } },
-- 🎨 COLORSCHEME
{ "nvim-lualine/lualine.nvim" },
{ "projekt0n/github-nvim-theme", priority = 1000 },
-- 💡 LSP + AUTOCOMPLETE
{ "neovim/nvim-lspconfig" },
{ "williamboman/mason.nvim", build = ":MasonUpdate" },
{ "williamboman/mason-lspconfig.nvim" },
{ "hrsh7th/nvim-cmp" },
{ "hrsh7th/cmp-nvim-lsp" },
{ "hrsh7th/cmp-buffer" },
{ "hrsh7th/cmp-path" },
{ "hrsh7th/cmp-cmdline" },
{ "L3MON4D3/LuaSnip" },
{ "saadparwaiz1/cmp_luasnip" },
-- 🌳 TREESITTER
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
{ "nvim-tree/nvim-tree.lua" },
{ "nvim-tree/nvim-web-devicons" },
-- 🔧 GIT SUPPORT
{ "tpope/vim-fugitive" },
{ "lewis6991/gitsigns.nvim" },
-- 📊 STATUSLINE
{ "nvim-lualine/lualine.nvim" },
-- 💻 TERMINAL
{ "akinsho/toggleterm.nvim", version = "*" },
-- 🤖 COPILOT
{ "github/copilot.vim" },
{
"CopilotC-Nvim/CopilotChat.nvim",
dependencies = {
{ "zbirenbaum/copilot.lua" }, -- required core
{ "nvim-lua/plenary.nvim" }, -- required
},
opts = {
show_help = true,
auto_insert_mode = true,
},
cmd = "CopilotChat",
keys = {
{ "<leader>cc", "<cmd>CopilotChatToggle<cr>", desc = "Copilot Chat" },
{ "<leader>cq", "<cmd>CopilotChatExplain<cr>", desc = "Explain code" },
{ "<leader>cf", "<cmd>CopilotChatFix<cr>", desc = "Fix code" },
},
},
}, {})
require("plugins.lualine")
require("plugins.bufferline")
require("which-key").setup {}
require("core.options")
require("core.keymaps")
require("plugins.colorscheme")
require("plugins.cmp")
require("plugins.lsp")
require("nvim-tree").setup({
sort = {
sorter = "case_sensitive",
},
view = {
width = 30,
},
renderer = {
group_empty = true,
},
filters = {
dotfiles = true,
},
})

29
lazy-lock.json Normal file
View File

@ -0,0 +1,29 @@
{
"CopilotChat.nvim": { "branch": "main", "commit": "f68deee85b8d734db1a9fbf63ce17a8164921267" },
"LuaSnip": { "branch": "master", "commit": "73813308abc2eaeff2bc0d3f2f79270c491be9d7" },
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
"cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" },
"cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" },
"cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"copilot.lua": { "branch": "master", "commit": "92e08cd472653beaece28ad9c8508a851a613358" },
"copilot.vim": { "branch": "release", "commit": "da369d90cfd6c396b1d0ec259836a1c7222fb2ea" },
"github-nvim-theme": { "branch": "main", "commit": "c106c9472154d6b2c74b74565616b877ae8ed31d" },
"gitsigns.nvim": { "branch": "main", "commit": "1ee5c1fd068c81f9dd06483e639c2aa4587dc197" },
"lazy.nvim": { "branch": "main", "commit": "1ea3c4085785f460fb0e46d2fe1ee895f5f9e7c1" },
"lualine.nvim": { "branch": "master", "commit": "b8c23159c0161f4b89196f74ee3a6d02cdc3a955" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "6bdb14f230de0904229ec367b410fb817e59b072" },
"mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" },
"nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
"nvim-ide": { "branch": "main", "commit": "fb6d6fe65be188bc80559d377e72831a373085bd" },
"nvim-lspconfig": { "branch": "master", "commit": "623bcf08d5f9ff4ee3ce2686fa1f1947a045b1a5" },
"nvim-tree.lua": { "branch": "master", "commit": "e397756d2a79d74314ea4cd3efc41300e91c0ff0" },
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
"nvim-web-devicons": { "branch": "master", "commit": "b8221e42cf7287c4dcde81f232f58d7b947c210d" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" },
"toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" },
"vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" },
"which-key.nvim": { "branch": "main", "commit": "b4177e3eaf15fe5eb8357ebac2286d488be1ed00" }
}

36
lua/core/keymaps.lua Normal file
View File

@ -0,0 +1,36 @@
-- lua/core/keymaps.lua
local keymap = vim.keymap
-- Set space as leader key
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- General keymaps
keymap.set("n", "<leader>e", ":Lex 30<CR>", { desc = "Open file explorer" })
keymap.set("n", "<leader>w", ":w<CR>", { desc = "Save file" })
keymap.set("n", "<leader>q", ":q<CR>", { desc = "Quit" })
keymap.set("n", "<leader>h", ":nohlsearch<CR>", { desc = "Clear search highlight" })
-- Telescope keymaps
keymap.set("n", "<leader>tf", "<cmd>Telescope find_files<cr>", { desc = "Find Files" })
keymap.set("n", "<leader>tg", "<cmd>Telescope live_grep<cr>", { desc = "Live Grep" })
keymap.set("n", "<leader>tb", "<cmd>Telescope buffers<cr>", { desc = "Find Buffers" })
keymap.set("n", "<leader>th", "<cmd>Telescope help_tags<cr>", { desc = "Help Tags" })
-- Editor format
keymap.set("n", "<leader>f", function() vim.lsp.buf.format({ async = true }) end, { desc = "Format Document" })
-- Window navigation
keymap.set("n", "<C-h>", "<C-w>h", { desc = "Move Left" })
keymap.set("n", "<C-j>", "<C-w>j", { desc = "Move Down" })
keymap.set("n", "<C-k>", "<C-w>k", { desc = "Move Up" })
keymap.set("n", "<C-l>", "<C-w>l", { desc = "Move Right" })
-- Resize with arrows
keymap.set("n", "<C-Up>", ":resize -2<CR>", { desc = "Resize Up" })
keymap.set("n", "<C-Down>", ":resize +2<CR>", { desc = "Resize Down" })
keymap.set("n", "<C-Left>", ":vertical resize -2<CR>", { desc = "Resize Left" })
keymap.set("n", "<C-Right>", ":vertical resize +2<CR>", { desc = "Resize Right" })

43
lua/core/options.lua Normal file
View File

@ -0,0 +1,43 @@
-- lua/core/options.lua
local opt = vim.opt
-- Line numbers
opt.number = true -- Show absolute line number
opt.relativenumber = false -- Show relative line numbers
-- Tabs & indentation
opt.tabstop = 4 -- 1 tab = 4 spaces
opt.shiftwidth = 4 -- Indent by 4 spaces
opt.expandtab = true -- Convert tabs to spaces
opt.smartindent = true -- Autoindent new lines
-- Line wrapping
opt.wrap = false -- Don't wrap long lines
-- Search
opt.ignorecase = true -- Ignore case when searching...
opt.smartcase = true -- ...unless you use caps
-- Cursor
opt.cursorline = true -- Highlight the current line
-- Appearance
opt.termguicolors = true -- True color support
opt.scrolloff = 8 -- Keep 8 lines above/below cursor
opt.colorcolumn = "160" -- Show a line at 160 chars
-- Clipboard
opt.clipboard = "unnamedplus" -- Use system clipboard
-- Split windows
opt.splitright = true -- Vertical split to the right
opt.splitbelow = true -- Horizontal split below
-- Backup & Swap
opt.swapfile = false
opt.backup = false
opt.undofile = true -- Save undo history
-- Mouse
opt.mouse = "a" -- Enable mouse in all modes

View File

@ -0,0 +1,13 @@
-- lua/plugins/bufferline.lua
require("bufferline").setup({
options = {
mode = "buffers", -- show buffers, not tabs
diagnostics = "nvim_lsp",
show_buffer_close_icons = false,
show_close_icon = false,
separator_style = "thin",
always_show_bufferline = true,
},
})

50
lua/plugins/cmp.lua Normal file
View File

@ -0,0 +1,50 @@
-- lua/plugins/cmp.lua
local cmp = require("cmp")
local luasnip = require("luasnip")
-- Setup nvim-cmp.
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
luasnip.lsp_expand(args.body) -- Use LuaSnip to expand snippets
end,
},
mapping = cmp.mapping.preset.insert({
['<C-k>'] = cmp.mapping.select_prev_item(), -- Move up on suggestion list
['<C-j>'] = cmp.mapping.select_next_item(), -- Move down on suggestion list
['<C-b>'] = cmp.mapping.scroll_docs(-4), -- Scroll docs up
['<C-f>'] = cmp.mapping.scroll_docs(4), -- Scroll docs down
['<C-Space>'] = cmp.mapping.complete(), -- Trigger completion menu
['<C-e>'] = cmp.mapping.abort(), -- Close completion window
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Enter to confirm selection
['<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' }, -- LSP suggestions (your language servers)
{ name = 'luasnip' }, -- Snippets suggestions
{ name = 'buffer' }, -- Words from open buffers
{ name = 'path' }, -- File paths
}),
})

View File

@ -0,0 +1,14 @@
-- lua/plugins/colorscheme.lua
require('github-theme').setup({
})
vim.cmd("colorscheme github_dark_default")
-- Optional: set contrast, italic comments, etc
vim.g.gruvbox_contrast_dark = "hard" -- options: "soft", "medium", "hard"
vim.g.gruvbox_invert_selection = "0"
vim.g.gruvbox_italic = 1
vim.g.gruvbox_bold = 1

52
lua/plugins/lsp.lua Normal file
View File

@ -0,0 +1,52 @@
-- Modern LSP setup for Neovim 0.11+
-- Compatible with LazyVim and nvim-lspconfig >= v0.2.1
-- Load Mason to manage LSP servers
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = { "lua_ls", "ts_ls", "pyright", "clangd" },
})
-- New Neovim 0.11 API for configuring LSPs
local lsp = vim.lsp
local configs = lsp.configs
local util = require("lspconfig.util")
-- Function that runs when an LSP attaches
local on_attach = function(client, bufnr)
local opts = { buffer = bufnr, noremap = true, silent = true }
local map = vim.keymap.set
map("n", "gd", vim.lsp.buf.definition, opts, { desc = "Go to definition" })
map("n", "K", vim.lsp.buf.hover, opts, { desc = "Hover documentation" })
map("n", "<leader>rn", vim.lsp.buf.rename, opts, { desc = "Rename symbol" })
map("n", "<leader>ca", vim.lsp.buf.code_action, opts, { desc = "Code action" })
map("n", "gr", vim.lsp.buf.references, opts, { desc = "Go to references" })
map("n", "<leader>e", vim.diagnostic.open_float, opts, { desc = "Show diagnostics" })
end
-- Default capabilities (for autocompletion)
local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Configure LSP servers
local servers = {
lua_ls = { cmd = { "lua-language-server" } },
ts_ls = { cmd = { "typescript-language-server", "--stdio" } },
pyright = { cmd = { "pyright-langserver", "--stdio" } },
clangd = {
cmd = { "clangd" },
on_attach = on_attach,
capabilities = capabilities,
init_options = {
clangdFileStatus = true,
fallbackFlags = { "-style={UseTab: ForIndentation}" },
}
},
}
for name, config in pairs(servers) do
vim.lsp.config[name] = vim.tbl_extend("force", {
on_attach = on_attach,
capabilities = capabilities,
}, config)
vim.lsp.start(vim.lsp.config[name])
end

12
lua/plugins/lualine.lua Normal file
View File

@ -0,0 +1,12 @@
-- lua/plugins/lualine.lua
require("lualine").setup({
options = {
theme = "auto", -- this auto-syncs with your colorscheme
icons_enabled = true,
section_separators = '',
component_separators = '',
}
})