Added neovim config
This commit is contained in:
commit
1449181ce4
1 changed files with 123 additions and 0 deletions
123
nvim/init.lua
Normal file
123
nvim/init.lua
Normal file
|
|
@ -0,0 +1,123 @@
|
||||||
|
-- ===================================
|
||||||
|
-- | General Neovim Configuration |
|
||||||
|
-- ===================================
|
||||||
|
vim.opt.number = true -- Show line numbers
|
||||||
|
vim.opt.relativenumber = true -- Show relative line numbers
|
||||||
|
vim.opt.tabstop = 4 -- A tab is 4 spaces
|
||||||
|
vim.opt.shiftwidth = 4 -- Indent is 4 spaces
|
||||||
|
vim.opt.expandtab = true -- Use spaces instead of tabs
|
||||||
|
vim.opt.termguicolors = true -- Enable terminal colors
|
||||||
|
vim.opt.scrolloff = 8 -- Lines above/below cursor
|
||||||
|
vim.opt.signcolumn = "yes" -- Always show the sign column
|
||||||
|
|
||||||
|
-- Set the leader key to space. This is a crucial step for custom mappings.
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
|
||||||
|
-- ===================================
|
||||||
|
-- | Plugin Management with lazy.nvim|
|
||||||
|
-- ===================================
|
||||||
|
-- The configuration below bootstraps lazy.nvim if it's not already installed.
|
||||||
|
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", lazypath
|
||||||
|
})
|
||||||
|
end
|
||||||
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
|
-- Setup the plugins you need.
|
||||||
|
require("lazy").setup({
|
||||||
|
-- === The colorscheme plugin is specified here. ===
|
||||||
|
-- Gruvbox theme plugin. It will be automatically installed by lazy.nvim.
|
||||||
|
{ 'ellisonleao/gruvbox.nvim', config = function()
|
||||||
|
-- Ensure the background is set to 'dark' for the gruvbox colorscheme.
|
||||||
|
vim.o.background = 'dark'
|
||||||
|
-- Load the colorscheme.
|
||||||
|
vim.cmd.colorscheme("gruvbox")
|
||||||
|
end },
|
||||||
|
|
||||||
|
-- Treesitter plugin for syntax highlighting.
|
||||||
|
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
|
||||||
|
|
||||||
|
-- Autocomplete plugins
|
||||||
|
{ "hrsh7th/nvim-cmp" },
|
||||||
|
{ "hrsh7th/cmp-nvim-lsp" },
|
||||||
|
{ "L3MON4D3/LuaSnip" },
|
||||||
|
{ "neovim/nvim-lspconfig" },
|
||||||
|
|
||||||
|
-- Plugin to automatically close paired characters like (), {}, [], and ""
|
||||||
|
{ 'echasnovski/mini.pairs' },
|
||||||
|
|
||||||
|
-- File tree and icon plugins
|
||||||
|
{
|
||||||
|
'nvim-tree/nvim-tree.lua',
|
||||||
|
version = '*',
|
||||||
|
lazy = false,
|
||||||
|
dependencies = {
|
||||||
|
'nvim-tree/nvim-web-devicons',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
-- The setup call for the nvim-tree plugin.
|
||||||
|
require('nvim-tree').setup {}
|
||||||
|
end
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Treesitter configuration.
|
||||||
|
require("nvim-treesitter.configs").setup({
|
||||||
|
highlight = { enable = true },
|
||||||
|
-- auto_install = false,
|
||||||
|
-- You can specify languages to install with `ensure_installed`.
|
||||||
|
-- e.g., ensure_installed = { "lua", "python", "javascript" },
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Autocomplete (cmp) configuration.
|
||||||
|
local cmp = require("cmp")
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
expand = function(args) require("luasnip").lsp_expand(args.body) end,
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
["<Tab>"] = cmp.mapping.select_next_item(),
|
||||||
|
["<S-Tab>"] = cmp.mapping.select_prev_item(),
|
||||||
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||||
|
}),
|
||||||
|
sources = {
|
||||||
|
{ name = "nvim_lsp" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Mini.pairs configuration.
|
||||||
|
-- This simple setup is all that's needed for the basic functionality.
|
||||||
|
require('mini.pairs').setup({})
|
||||||
|
|
||||||
|
-- ===================================
|
||||||
|
-- | Custom Keymaps |
|
||||||
|
-- ===================================
|
||||||
|
-- Keymaps are custom commands mapped to a specific key combination.
|
||||||
|
-- The "<leader>" prefix will be replaced with your leader key, which is "space".
|
||||||
|
|
||||||
|
-- Normal mode keymaps
|
||||||
|
-- Save the current file.
|
||||||
|
vim.keymap.set('n', '<leader>w', ':w<CR>', { desc = 'Save file' })
|
||||||
|
|
||||||
|
-- Force quit the current window without saving.
|
||||||
|
vim.keymap.set('n', '<leader>q', ':q!<CR>', { desc = 'Force quit window' })
|
||||||
|
|
||||||
|
-- Save and quit.
|
||||||
|
vim.keymap.set('n', '<leader>x', ':wq<CR>', { desc = 'Save and quit' })
|
||||||
|
|
||||||
|
-- Save all open buffers.
|
||||||
|
vim.keymap.set('n', '<leader>wa', ':wa<CR>', { desc = 'Save all buffers' })
|
||||||
|
|
||||||
|
-- Close all windows except the current one.
|
||||||
|
vim.keymap.set('n', '<leader>o', ':only<CR>', { desc = 'Close all other windows' })
|
||||||
|
|
||||||
|
-- Toggle the file tree.
|
||||||
|
vim.keymap.set('n', '<leader>e', ':NvimTreeToggle<CR>', { desc = 'Toggle file tree' })
|
||||||
|
|
||||||
|
-- Select the entire file content.
|
||||||
|
vim.keymap.set('n', '<leader>a', 'ggVG', { desc = 'Select entire file' })
|
||||||
|
|
||||||
|
-- You can add more keymaps here as you get more comfortable!
|
||||||
Loading…
Add table
Add a link
Reference in a new issue