New: NVIM Config
This commit is contained in:
@@ -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" })
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -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
|
||||
}),
|
||||
})
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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 = '',
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user