initial commit

This commit is contained in:
Hirad 2024-07-08 07:37:54 +03:30
parent 0a76b1a8f8
commit f555d223d3
40 changed files with 2314 additions and 0 deletions

View file

@ -0,0 +1,4 @@
vim.api.nvim_create_autocmd('FileType', {
pattern = 'sh',
command = 'setlocal shiftwidth=4 tabstop=4'
})

View file

@ -0,0 +1,70 @@
local opts = { noremap = true, silent = true }
local term_opts = { silent = true }
-- Shorten function name
local keymap = vim.api.nvim_set_keymap
--Remap space as leader key
keymap("", "<Space>", "<Nop>", opts)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- Modes
-- normal_mode = "n",
-- insert_mode = "i",
-- visual_mode = "v",
-- visual_block_mode = "x",
-- term_mode = "t",
-- command_mode = "c",
-- Normal --
-- Better window navigation
keymap("n", "<C-h>", "<C-w>h", opts)
keymap("n", "<C-j>", "<C-w>j", opts)
keymap("n", "<C-k>", "<C-w>k", opts)
keymap("n", "<C-l>", "<C-w>l", opts)
-- Resize with arrows
keymap("n", "<C-Up>", ":resize -2<CR>", opts)
keymap("n", "<C-Down>", ":resize +2<CR>", opts)
keymap("n", "<C-Left>", ":vertical resize -2<CR>", opts)
keymap("n", "<C-Right>", ":vertical resize +2<CR>", opts)
-- Navigate buffers
keymap("n", "<S-l>", ":bnext<CR>", opts)
keymap("n", "<S-h>", ":bprevious<CR>", opts)
-- Move text up and down
keymap("n", "<A-j>", "<Esc>:m .+1<CR>==gi", opts)
keymap("n", "<A-k>", "<Esc>:m .-2<CR>==gi", opts)
-- Insert --
-- Press jk fast to exit insert mode
keymap("i", "jk", "<ESC>", opts)
keymap("i", "kj", "<ESC>", opts)
-- Visual --
-- Stay in indent mode
keymap("v", "<", "<gv", opts)
keymap("v", ">", ">gv", opts)
-- Move text up and down
keymap("v", "<A-j>", ":m .+1<CR>==", opts)
keymap("v", "<A-k>", ":m .-2<CR>==", opts)
keymap("v", "p", '"_dP', opts)
-- Visual Block --
-- Move text up and down
keymap("x", "J", ":move '>+1<CR>gv-gv", opts)
keymap("x", "K", ":move '<-2<CR>gv-gv", opts)
keymap("x", "<A-j>", ":move '>+1<CR>gv-gv", opts)
keymap("x", "<A-k>", ":move '<-2<CR>gv-gv", opts)
-- Terminal --
-- Better terminal navigation
-- keymap("t", "<C-h>", "<C-\\><C-N><C-w>h", term_opts)
-- keymap("t", "<C-j>", "<C-\\><C-N><C-w>j", term_opts)
-- keymap("t", "<C-k>", "<C-\\><C-N><C-w>k", term_opts)
-- keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", term_opts)

View file

@ -0,0 +1,50 @@
local options = {
backup = false,
clipboard = "unnamedplus",
cmdheight = 2,
completeopt = { "menuone", "noselect" },
conceallevel = 0,
fileencoding = "utf-8",
hlsearch = true,
ignorecase = true,
mouse = "a",
pumheight = 10,
showmode = false,
showtabline = 2,
smartcase = true,
smartindent = true,
splitbelow = true,
splitright = true,
swapfile = true,
-- termguicolors = true,
timeoutlen = 300,
undofile = true,
updatetime = 300,
writebackup = false,
expandtab = true,
shiftwidth = 2,
tabstop = 2,
cursorline = true,
number = true,
relativenumber = false,
numberwidth = 4,
signcolumn = "yes",
wrap = false,
linebreak = true,
scrolloff = 8,
sidescrolloff = 8,
guifont = "Hirad Iosevka:h17",
whichwrap = "bs<>[]hl",
}
for k, v in pairs(options) do
vim.opt[k] = v
end
-- vim.opt.shortmess = "ilmnrx" -- flags to shorten vim messages, see :help 'shortmess'
vim.opt.shortmess:append "c" -- don't give |ins-completion-menu| messages
vim.opt.iskeyword:append "-" -- hyphenated words recognized by searches
vim.opt.formatoptions:remove({ "c", "r", "o" }) -- don't insert the current comment leader automatically for auto-wrapping comments using 'textwidth', hitting <Enter> in insert mode, or hitting 'o' or 'O' in normal mode.
vim.opt.runtimepath:remove("/usr/share/vim/vimfiles") -- separate vim plugins from neovim in case vim still in use

View file

@ -0,0 +1,99 @@
local fn = vim.fn
-- Automatically install packer
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then
PACKER_BOOTSTRAP = fn.system({
"git",
"clone",
"--depth",
"1",
"https://github.com/wbthomason/packer.nvim",
install_path,
})
print("Installing packer close and reopen NeoVIM...")
vim.cmd([[packadd packer.nvim]])
end
-- Autocommand that reloads neovim whenever you save the plugins.lua file
vim.cmd([[
augroup packer_user_config
autocmd!
autocmd BufWritePost plugins.lua source <afile> | PackerSync
augroup end
]])
-- Use a protected call so we don't error out on first use
local status_ok, packer = pcall(require, "packer")
if not status_ok then
return
end
-- Have packer use a popup window
packer.init({
display = {
open_fn = function()
return require("packer.util").float({ border = "rounded" })
end,
},
})
-- Install plugins here
return packer.startup(function(use)
use { "wbthomason/packer.nvim" }
use { "nvim-lua/plenary.nvim" }
use { "windwp/nvim-autopairs" }
use { "numToStr/Comment.nvim" }
use { "JoosepAlviste/nvim-ts-context-commentstring" }
use { "kyazdani42/nvim-web-devicons" }
use { "kyazdani42/nvim-tree.lua" }
use { "akinsho/bufferline.nvim" }
use { "moll/vim-bbye" }
use { "nvim-lualine/lualine.nvim" }
use { "akinsho/toggleterm.nvim" }
use { "ahmedkhalf/project.nvim" }
use { "lewis6991/impatient.nvim" }
use { "lukas-reineke/indent-blankline.nvim" }
use { "goolord/alpha-nvim" }
use { "folke/which-key.nvim" }
use { "karb94/neoscroll.nvim" }
-- Colorschemes
use { "folke/tokyonight.nvim" }
use { "lunarvim/darkplus.nvim" }
use { "navarasu/onedark.nvim" }
use { "Mofiqul/dracula.nvim" }
-- cmp
use { "hrsh7th/nvim-cmp" }
use { "hrsh7th/cmp-buffer" }
use { "hrsh7th/cmp-path" }
use { "saadparwaiz1/cmp_luasnip" }
use { "hrsh7th/cmp-nvim-lsp" }
use { "hrsh7th/cmp-nvim-lua" }
-- Snippets
use { "L3MON4D3/LuaSnip" }
use { "rafamadriz/friendly-snippets" }
-- LSP
use { "neovim/nvim-lspconfig" }
use { "williamboman/mason.nvim" }
use { "williamboman/mason-lspconfig.nvim" }
use { "jose-elias-alvarez/null-ls.nvim" }
use { "RRethy/vim-illuminate" }
-- Telescope
use { "nvim-telescope/telescope.nvim" }
-- Treesitter
use { "nvim-treesitter/nvim-treesitter" }
-- Git
use { "lewis6991/gitsigns.nvim" }
--Automatically setup configuration after cleaning packer.nvim
if PACKER_BOOTSTRAP then
require("packer").sync()
end
end)

View file

@ -0,0 +1,22 @@
function EscapePair()
local closers = {")", "]", "}", ">", "'", '"', "`", ","}
local line = vim.api.nvim_get_current_line()
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
local after = line:sub(col + 1, -1)
local closer_col = #after + 1
local closer_i = nil
for i, closer in ipairs(closers) do
local cur_index, _ = after:find(closer)
if cur_index and (cur_index < closer_col) then
closer_col = cur_index
closer_i = i
end
end
if closer_i then
vim.api.nvim_win_set_cursor(0, {row, col + closer_col})
else
vim.api.nvim_win_set_cursor(0, {row, col + 1})
end
end
vim.api.nvim_set_keymap('i', '<C-l>', '<cmd>lua EscapePair()<CR>', { noremap = true, silent = true})