Skip to content

Instantly share code, notes, and snippets.

@anisur3036
Last active October 16, 2024 06:51
Show Gist options
  • Save anisur3036/85f0839e72395ac3dec8562471b13b94 to your computer and use it in GitHub Desktop.
Save anisur3036/85f0839e72395ac3dec8562471b13b94 to your computer and use it in GitHub Desktop.
nvim-config
-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.cmd("imap jj <Esc>")
vim.g.mapleader = ','
vim.g.maplocalleader = ','
-- --------Opening Closing--------------------
vim.cmd("inoremap { {}<Esc>ha")
vim.cmd("inoremap ( ()<Esc>ha")
vim.cmd("inoremap [ []<Esc>ha")
vim.cmd('inoremap " ""<Esc>ha')
vim.cmd("inoremap ' ''<Esc>ha")
vim.cmd("inoremap ` ``<Esc>ha")
-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = false
-- [[ Setting options ]]
-- See `:help vim.opt`
-- NOTE: You can change these options as you wish!
-- For more options, you can see `:help option-list`
-- Make line numbers default
vim.opt.number = true
-- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it!
-- vim.opt.relativenumber = true
-- Enable mouse mode, can be useful for resizing splits for example!
vim.opt.mouse = 'a'
-- Don't show the mode, since it's already in the status line
vim.opt.showmode = false
-- Sync clipboard between OS and Neovim.
-- Schedule the setting after `UiEnter` because it can increase startup-time.
-- Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
vim.schedule(function()
vim.opt.clipboard = 'unnamedplus'
end)
-- Enable break indent
vim.opt.breakindent = true
-- Save undo history
vim.opt.undofile = true
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
vim.opt.ignorecase = true
vim.opt.smartcase = true
-- Keep signcolumn on by default
vim.opt.signcolumn = 'yes'
-- Decrease update time
vim.opt.updatetime = 250
-- Decrease mapped sequence wait time
-- Displays which-key popup sooner
vim.opt.timeoutlen = 300
-- Configure how new splits should be opened
vim.opt.splitright = true
vim.opt.splitbelow = true
-- Sets how neovim will display certain whitespace characters in the editor.
-- See `:help 'list'`
-- and `:help 'listchars'`
vim.opt.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
-- Preview substitutions live, as you type!
vim.opt.inccommand = 'split'
-- Show which line your cursor is on
vim.opt.cursorline = true
-- Minimal number of screen lines to keep above and below the cursor.
vim.opt.scrolloff = 10
-- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()`
-- Clear highlights on search when pressing <Esc> in normal mode
-- See `:help hlsearch`
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
vim.scriptencoding="utf-8"
vim.opt.encoding="utf-8"
vim.opt.fileencoding="utf-8"
vim.opt.title=true
vim.opt.autoindent=true
vim.opt.smartindent=true
vim.opt.backup=false
vim.opt.backup=false
vim.opt.expandtab=true
vim.opt.smarttab=true
vim.opt.shiftwidth=2
vim.opt.tabstop=2
vim.opt.wrap=false
vim.opt.backspace = {"start", "eol", "indent"}
vim.opt.path:append({"**"})
vim.opt.wildignore:append({"*/node_modules/*"})
vim.opt.splitkeep="cursor"
vim.keymap.set("n", "+", "<C-a>")
vim.keymap.set("n", "-", "<C-x>")
vim.keymap.set("n", "<C-a>", "gg<S-v>G")
-- Tabs
-- vim.keymap.set("n", "te", ":tabedit")
-- [[ Install `lazy.nvim` plugin manager ]]
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
if vim.v.shell_error ~= 0 then
error('Error cloning lazy.nvim:\n' .. out)
end
end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath)
local plugins = {
{ "catppuccin/nvim", name = "catppuccin", priority = 1000 },
{
'nvim-telescope/telescope.nvim', tag = '0.1.8',
dependencies = { 'nvim-lua/plenary.nvim' }
},
{
'nvim-treesitter/nvim-treesitter', build = ':TSUpdate'
},
{
"nvim-tree/nvim-tree.lua", version = "*", lazy = false,
dependencies = {
"nvim-tree/nvim-web-devicons",
},}
}
local opts = {}
require('lazy').setup(plugins, opts)
require("nvim-tree").setup()
vim.cmd("imap <c-b> <Esc>:NvimTreeToggle<CR>")
vim.cmd("nmap <c-b> <Esc>:NvimTreeToggle<CR>")
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<C-p>', builtin.find_files, {})
local config = require('nvim-treesitter.configs')
config.setup({
ensure_installed = {},
highlight = { enable = true },
indent = { enable = true },
})
require('catppuccin').setup()
vim.cmd.colorscheme 'catppuccin'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment