Initial
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
-- To avoid neotree from crashing all vim, closes the tab
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.bufremove(buf)
|
||||
buf = buf or 0
|
||||
buf = buf == 0 and vim.api.nvim_get_current_buf() or buf
|
||||
if vim.bo.modified then
|
||||
local choice = vim.fn.confirm(("Save changes to %q?"):format(vim.fn.bufname()), "&Yes\n&No\n&Cancel")
|
||||
if choice == 0 or choice == 3 then -- 0 for <Esc>/<C-c> and 3 for Cancel
|
||||
return
|
||||
end
|
||||
if choice == 1 then -- Yes
|
||||
vim.cmd.write()
|
||||
end
|
||||
end
|
||||
for _, win in ipairs(vim.fn.win_findbuf(buf)) do
|
||||
vim.api.nvim_win_call(win, function()
|
||||
if not vim.api.nvim_win_is_valid(win) or vim.api.nvim_win_get_buf(win) ~= buf then
|
||||
return
|
||||
end
|
||||
-- Try using alternate buffer
|
||||
local alt = vim.fn.bufnr("#")
|
||||
if alt ~= buf and vim.fn.buflisted(alt) == 1 then
|
||||
vim.api.nvim_win_set_buf(win, alt)
|
||||
return
|
||||
end
|
||||
-- Try using previous buffer
|
||||
local has_previous = pcall(vim.cmd, "bprevious")
|
||||
if has_previous and buf ~= vim.api.nvim_win_get_buf(win) then
|
||||
return
|
||||
end
|
||||
-- Create new listed buffer
|
||||
local new_buf = vim.api.nvim_create_buf(true, false)
|
||||
vim.api.nvim_win_set_buf(win, new_buf)
|
||||
end)
|
||||
end
|
||||
if vim.api.nvim_buf_is_valid(buf) then
|
||||
pcall(vim.cmd, "bdelete! " .. buf)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -0,0 +1,56 @@
|
||||
local M = {}
|
||||
|
||||
|
||||
function M.bufonly()
|
||||
vim.cmd('silent! execute "%bd|e#|bd#"')
|
||||
end
|
||||
|
||||
function M.remove_trailing_whitespace()
|
||||
local saved_search = vim.fn.getreg('/')
|
||||
vim.cmd([[%s/\s\+$//e]])
|
||||
vim.fn.setreg('/', saved_search)
|
||||
end
|
||||
|
||||
|
||||
-- To avoid neotree from crashing all vim, closes the tab
|
||||
function M.bufremove(buf)
|
||||
buf = buf or 0
|
||||
buf = buf == 0 and vim.api.nvim_get_current_buf() or buf
|
||||
if vim.bo.modified then
|
||||
local choice = vim.fn.confirm(("Save changes to %q?"):format(vim.fn.bufname()), "&Yes\n&No\n&Cancel")
|
||||
if choice == 0 or choice == 3 then -- 0 for <Esc>/<C-c> and 3 for Cancel
|
||||
return
|
||||
end
|
||||
if choice == 1 then -- Yes
|
||||
vim.cmd.write()
|
||||
end
|
||||
end
|
||||
for _, win in ipairs(vim.fn.win_findbuf(buf)) do
|
||||
vim.api.nvim_win_call(win, function()
|
||||
if not vim.api.nvim_win_is_valid(win) or vim.api.nvim_win_get_buf(win) ~= buf then
|
||||
return
|
||||
end
|
||||
-- Try using alternate buffer
|
||||
local alt = vim.fn.bufnr("#")
|
||||
if alt ~= buf and vim.fn.buflisted(alt) == 1 then
|
||||
vim.api.nvim_win_set_buf(win, alt)
|
||||
return
|
||||
end
|
||||
-- Try using previous buffer
|
||||
local has_previous = pcall(vim.cmd, "bprevious")
|
||||
if has_previous and buf ~= vim.api.nvim_win_get_buf(win) then
|
||||
return
|
||||
end
|
||||
-- Create new listed buffer
|
||||
local new_buf = vim.api.nvim_create_buf(true, false)
|
||||
vim.api.nvim_win_set_buf(win, new_buf)
|
||||
end)
|
||||
end
|
||||
if vim.api.nvim_buf_is_valid(buf) then
|
||||
pcall(vim.cmd, "bdelete! " .. buf)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
local opts = { noremap = true, silent = true }
|
||||
-- Require functions file
|
||||
local functions = require('functions')
|
||||
|
||||
|
||||
vim.keymap.set("n", "<leader><TAB>", ":bnext<CR>") -- Tab next
|
||||
vim.keymap.set({"x",'v','n'}, "E", "ge") -- go back
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv") -- move block
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv") -- move block
|
||||
vim.keymap.set("n", "<leader>r", [[:%s#\<<C-r><C-w>\>#<C-r><C-w>#gI<Left><Left><Left>]]) -- global remap
|
||||
vim.keymap.set("n", "J", "mzJ`z") -- append line
|
||||
vim.keymap.set("n", "<C-d>", "<C-d>zz") --move half page
|
||||
vim.keymap.set("n", "<C-u>", "<C-u>zz") --move half page
|
||||
|
||||
-- Close all buffers (tabs) but the current one
|
||||
vim.keymap.set('n', '<leader>b', functions.bufonly, opts)
|
||||
|
||||
|
||||
-- ############################
|
||||
-- Default behavior overrides #
|
||||
-- ############################
|
||||
|
||||
vim.keymap.set("n", "x", [["_x]]) --void x
|
||||
vim.keymap.set("x", "p", [["_dP]]) -- void paste
|
||||
vim.keymap.set('n', 'Q', 'q', opts) -- Remap 'Q' to start recording macros
|
||||
vim.keymap.set('x', 'W', 'iW', opts) -- remaps viW to just vW
|
||||
vim.keymap.set('v', 'w', 'iw', opts) -- remaps viw to just vw
|
||||
vim.keymap.set('n', 'P', 'o<Esc>p', opts) --void P
|
||||
vim.keymap.set('n', 'd', '"_d', opts) --void d
|
||||
vim.keymap.set('v', 'd', '"_d', opts)
|
||||
vim.keymap.set('n', '<leader>d', 'daw', opts)
|
||||
vim.keymap.set('n', 'cw', 'ciw', { noremap = true, nowait = true, silent = true }) -- cw = ciw
|
||||
|
||||
|
||||
-- Disable
|
||||
vim.keymap.set({'x','v','n'}, '<F1>', '<Nop>', opts)
|
||||
vim.keymap.set('n', 's', '<Nop>', opts)
|
||||
vim.keymap.set('n', 'S', '<Nop>', opts)
|
||||
vim.keymap.set('n', 'q', '<Nop>', opts)
|
||||
|
||||
-- ############################
|
||||
-- Plugins keymaps #
|
||||
-- ############################
|
||||
|
||||
vim.cmd([[nnoremap \ :Neotree toggle<cr>]])
|
||||
|
||||
-- To avoid neotree from crashing all vim, closes the tab
|
||||
vim.keymap.set("n", "<leader>q", functions.bufremove, { desc = "Delete buffer" })
|
||||
|
||||
--telescope
|
||||
vim.keymap.set('n', '<leader>ff', "<cmd>lua require'telescope.builtin'.find_files({ find_command = {'rg', '--files', '--hidden', '-g', '!.git' }})<cr>")
|
||||
vim.keymap.set('n', '<leader>fr', "<cmd>lua require'telescope.builtin'.buffers({ show_all_buffers = true })<cr>")
|
||||
vim.keymap.set('n', '<leader>fg', "<cmd>lua require('telescope.builtin').live_grep()<cr>")
|
||||
|
||||
vim.keymap.set('n', '<leader>u', ':UndotreeToggle<CR>', opts)
|
||||
vim.keymap.set('n', '<leader>-', ':IBLToggle<CR>', opts)
|
||||
|
||||
|
||||
|
||||
-- ########
|
||||
-- Macros #
|
||||
-- ########
|
||||
@@ -0,0 +1,59 @@
|
||||
vim.diagnostic.config({
|
||||
virtual_text = true,
|
||||
signs = true,
|
||||
update_in_insert = false,
|
||||
underline = true,
|
||||
severity_sort = false,
|
||||
float = true,
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
--"'''''''''''''''''''Tree sitter highlight''''''''''''''''''''''''''''''
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
-- A list of parser names, or "all"
|
||||
ensure_installed = { "c", "lua","bash","python"},
|
||||
sync_install = false,
|
||||
indent = {
|
||||
enable = true,
|
||||
disable = function(lang, bufnr)
|
||||
local enabled_langs = { "html", "javascript", "tsx" } -- Enable auto indent only for these languages
|
||||
return not vim.tbl_contains(enabled_langs, lang)
|
||||
end,
|
||||
},
|
||||
auto_install = true,
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
lookahead = true,
|
||||
keymaps = {
|
||||
["af"] = "@function.outer",
|
||||
["if"] = "@function.inner",
|
||||
["ac"] = "@class.outer",
|
||||
["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" },
|
||||
["as"] = { query = "@local.scope", query_group = "locals", desc = "Select language scope" },
|
||||
},
|
||||
selection_modes = {
|
||||
['@parameter.outer'] = 'v', -- charwise
|
||||
['@function.outer'] = 'V', -- linewise
|
||||
['@class.outer'] = '<c-v>', -- blockwise
|
||||
},
|
||||
include_surrounding_whitespace = true,
|
||||
},
|
||||
move = {
|
||||
enable = true,
|
||||
set_jumps = true,
|
||||
goto_next_start = {
|
||||
["<C-f>"] = "@function.outer", -- jump to next function
|
||||
},
|
||||
goto_previous_start = {
|
||||
["<A-f>"] = "@function.outer", -- jump to previous function
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.clipboard:append('unnamedplus')
|
||||
vim.cmd('filetype plugin on')
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||
vim.opt.scrolloff = 7
|
||||
vim.opt.backspace = { 'indent', 'eol', 'start' }
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.softtabstop = 4
|
||||
vim.opt.shiftwidth = 4
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.autoindent = true
|
||||
vim.g.mapleader = ' '
|
||||
vim.opt.encoding = 'utf-8'
|
||||
vim.opt.termguicolors = true
|
||||
|
||||
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
|
||||
-- Spell generall options
|
||||
vim.opt.spelllang = 'en_us'
|
||||
vim.opt.spell = false
|
||||
vim.opt.hlsearch = false
|
||||
|
||||
vim.opt.showmode = false
|
||||
vim.opt.showtabline = 2
|
||||
@@ -0,0 +1,152 @@
|
||||
|
||||
-- Bootstrap lazy.nvim
|
||||
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
|
||||
vim.api.nvim_echo({
|
||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||
{ out, "WarningMsg" },
|
||||
{ "\nPress any key to exit..." },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
local plugins = {
|
||||
|
||||
-- Indent guides
|
||||
{
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
main = "ibl",
|
||||
opts = {},
|
||||
},
|
||||
|
||||
-- Color highlighting
|
||||
{ "catgoose/nvim-colorizer.lua"},
|
||||
|
||||
-- Undo tree viewer
|
||||
{ "mbbill/undotree" },
|
||||
|
||||
-- Devicons
|
||||
{ "nvim-tree/nvim-web-devicons", opts = {} },
|
||||
|
||||
-- Neo-tree file explorer
|
||||
{
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
branch = "v3.x",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"MunifTanjim/nui.nvim",
|
||||
},
|
||||
lazy = false,
|
||||
opts = { },
|
||||
},
|
||||
|
||||
|
||||
-- Telescope fuzzy finder
|
||||
{
|
||||
'nvim-telescope/telescope.nvim', tag = '0.1.8',
|
||||
dependencies = { 'nvim-lua/plenary.nvim' }
|
||||
},
|
||||
|
||||
|
||||
-- Treesitter
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
build = ":TSUpdate",
|
||||
},
|
||||
{ "nvim-treesitter/nvim-treesitter-textobjects" },
|
||||
|
||||
|
||||
-- Autopairs
|
||||
{
|
||||
'windwp/nvim-autopairs',
|
||||
event = "InsertEnter",
|
||||
config = true
|
||||
},
|
||||
|
||||
-- Commenting utility
|
||||
{ "tpope/vim-commentary" },
|
||||
|
||||
-- Catppuccin theme
|
||||
{ "catppuccin/nvim",
|
||||
name = "catppuccin",
|
||||
priority = 1000 },
|
||||
|
||||
-- Surround plugin
|
||||
{ "tpope/vim-surround" },
|
||||
|
||||
-- Treesitter auto-closing tags
|
||||
{ "windwp/nvim-ts-autotag" },
|
||||
|
||||
-- Signature marks
|
||||
{ "kshenoy/vim-signature" },
|
||||
|
||||
-- Oil file explorer
|
||||
{
|
||||
'stevearc/oil.nvim',
|
||||
opts = {},
|
||||
dependencies = { { "echasnovski/mini.icons", opts = {} } },
|
||||
lazy = false,
|
||||
},
|
||||
|
||||
-- Rainbow delimiters
|
||||
{ "HiPhish/rainbow-delimiters.nvim" },
|
||||
|
||||
|
||||
-- Completion engine
|
||||
{ "hrsh7th/nvim-cmp" },
|
||||
{ "hrsh7th/cmp-buffer" },
|
||||
{ "hrsh7th/cmp-path" },
|
||||
{ "saadparwaiz1/cmp_luasnip" },
|
||||
{ "hrsh7th/cmp-nvim-lsp" },
|
||||
{ "hrsh7th/cmp-nvim-lua" },
|
||||
|
||||
|
||||
-- Lualine
|
||||
{ 'nvim-lualine/lualine.nvim',
|
||||
dependencies = { 'nvim-tree/nvim-web-devicons' } },
|
||||
|
||||
-- File icons
|
||||
{ "ryanoasis/vim-devicons" },
|
||||
|
||||
-- barbar
|
||||
{
|
||||
'romgrk/barbar.nvim',
|
||||
dependencies = {
|
||||
'nvim-tree/nvim-web-devicons'
|
||||
},
|
||||
init = function()
|
||||
vim.g.barbar_auto_setup = false -- disable auto-setup
|
||||
end,
|
||||
opts = {},
|
||||
},
|
||||
-- highlight
|
||||
{
|
||||
'tzachar/local-highlight.nvim',
|
||||
},
|
||||
|
||||
-- buffer vacuum
|
||||
{
|
||||
'ChuufMaster/buffer-vacuum',
|
||||
opts = {
|
||||
max_buffers = 2,
|
||||
count_pinned_buffers = false,
|
||||
enable_messages = false,
|
||||
},
|
||||
},
|
||||
|
||||
-- telescope pluggin
|
||||
{'nvim-telescope/telescope-ui-select.nvim' },
|
||||
|
||||
|
||||
}
|
||||
|
||||
local opts = {}
|
||||
require('lazy').setup(plugins, opts)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
require'nvim-web-devicons'.setup {
|
||||
-- DevIcon will be appended to `name`
|
||||
override = {
|
||||
zsh = {
|
||||
icon = " ",
|
||||
color = "#428850",
|
||||
cterm_color = "65",
|
||||
name = "Zsh"
|
||||
}
|
||||
};
|
||||
color_icons = true;
|
||||
default = true;
|
||||
strict = true;
|
||||
variant = "light|dark";
|
||||
override_by_filename = {
|
||||
[".gitignore"] = {
|
||||
icon = " ",
|
||||
color = "#f1502f",
|
||||
name = "Gitignore"
|
||||
}
|
||||
};
|
||||
override_by_extension = {
|
||||
["log"] = {
|
||||
icon = " ",
|
||||
color = "#81e043",
|
||||
name = "Log"
|
||||
}
|
||||
};
|
||||
override_by_operating_system = {
|
||||
["apple"] = {
|
||||
icon = " ",
|
||||
color = "#A2AAAD",
|
||||
cterm_color = "248",
|
||||
name = "Apple",
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user