Skip to content

Commit

Permalink
feat: vim-plug changed as favor of packer.nvim
Browse files Browse the repository at this point in the history
  • Loading branch information
mthnglac committed Jul 18, 2022
1 parent fd2e3d9 commit 99d2ad0
Show file tree
Hide file tree
Showing 89 changed files with 2,404 additions and 1,649 deletions.
19 changes: 8 additions & 11 deletions nvim/init.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
-- vim-plug settings & plugins
require('install-plugins')

-- speed up loading Lua modules
if pcall(require, 'impatient') then
require('impatient').enable_profile()
if pcall(require, "impatient") then
require("impatient").enable_profile()
else
print("Failed to load impatient.")
print("Failed to load impatient.")
end

-- packer settings & plugins
require("install-plugins")

-- generics
require('utils')
require("utils")

-- vim core settings
require('general')

-- vim plugins settings
require('plugins')
require("general")
42 changes: 21 additions & 21 deletions nvim/lua/general/autocmds.lua
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
-- highlight on yank!!!
vim.api.nvim_create_autocmd('TextYankPost', {
pattern = "*",
callback = function()
require("vim.highlight").on_yank({ timeout = 400 })
end
vim.api.nvim_create_autocmd("TextYankPost", {
pattern = "*",
callback = function()
require("vim.highlight").on_yank({ timeout = 400 })
end,
})

--local groupCursorEffect = vim.api.nvim_create_augroup("HighlighMyCursor", { clear = true })
--vim.api.nvim_create_autocmd({'WinEnter,BufWinEnter,VimEnter'},
--{
--pattern = "*",
--callback = function()
--vim.wo.cursorline = true
--vim.wo.cursorcolumn = true
--end,
--group = groupCursorEffect
--}
--{
--pattern = "*",
--callback = function()
--vim.wo.cursorline = true
--vim.wo.cursorcolumn = true
--end,
--group = groupCursorEffect
--}
--)
--vim.api.nvim_create_autocmd('WinLeave',
--{
--pattern = "*",
--callback = function()
--vim.wo.cursorline = false
--vim.wo.cursorcolumn = false
--end,
--group = groupCursorEffect
--}
--{
--pattern = "*",
--callback = function()
--vim.wo.cursorline = false
--vim.wo.cursorcolumn = false
--end,
--group = groupCursorEffect
--}
--)
12 changes: 8 additions & 4 deletions nvim/lua/general/functions.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
-- clear all registers
vim.api.nvim_exec(
[[
[[
fun! EmptyRegisters()
let regs=split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/-"', '\zs')
for r in regs
call setreg(r, [])
endfor
endfun
]], true)
]],
true
)

-- removes any extraneous whitespace at the end of the lines
vim.api.nvim_exec(
[[
[[
fun! TrimWhitespace()
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
endfun
]], true)
]],
true
)
4 changes: 2 additions & 2 deletions nvim/lua/general/highlights.lua
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
vim.api.nvim_set_hl(0, "ActivePreviewWindow", {bg = "#17252c"})
vim.api.nvim_set_hl(0, "InActivePreviewWindow", {bg = "#0D1B22"})
vim.api.nvim_set_hl(0, "ActivePreviewWindow", { bg = "#17252c" })
vim.api.nvim_set_hl(0, "InActivePreviewWindow", { bg = "#0D1B22" })
14 changes: 7 additions & 7 deletions nvim/lua/general/init.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require('general.reloads')
require('general.options')
require('general.autocmds')
require('general.variables')
require('general.keybinds')
require('general.functions')
require('general.highlights')
require("general.reloads")
require("general.options")
require("general.autocmds")
require("general.variables")
require("general.keybinds")
require("general.functions")
require("general.highlights")
117 changes: 55 additions & 62 deletions nvim/lua/general/keybinds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,134 +4,127 @@ Keybind.g({
# CONFIG #
#-------------------------------------------------------------------------#
--]]
-- reload nvim configuration file
{ 'n', '<Leader><CR>', ':luafile $MYVIMRC<CR>', { noremap = true } },

-- reload nvim configuration file
{ "n", "<Leader><CR>", ":luafile $MYVIMRC<CR>", { noremap = true } },

--[[
#-------------------------------------------------------------------------#
# CURSOR MOVE #
#-------------------------------------------------------------------------#
--]]
-- [ space + h ] move cursor to left window
{ 'n', '<Leader>h', '<Cmd>wincmd h<CR>', { noremap = true } },

-- [ space + l ] move cursor to bottom window
{ 'n', '<Leader>j', '<Cmd>wincmd j<CR>', { noremap = true } },
-- [ space + h ] move cursor to left window
{ "n", "<Leader>h", "<Cmd>wincmd h<CR>", { noremap = true } },

-- [ space + j ] move cursor to top window
{ 'n', '<Leader>k', '<Cmd>wincmd k<CR>', { noremap = true } },
-- [ space + l ] move cursor to bottom window
{ "n", "<Leader>j", "<Cmd>wincmd j<CR>", { noremap = true } },

-- [ space + k ] move cursor to right window
{ 'n', '<Leader>l', '<Cmd>wincmd l<CR>', { noremap = true } },
-- [ space + j ] move cursor to top window
{ "n", "<Leader>k", "<Cmd>wincmd k<CR>", { noremap = true } },

-- [ space + c ] highlight cursorline
{ 'n', '<Leader>c', [[<Cmd>set cursorline! cursorcolumn!<CR>]], { noremap = true } },
-- [ space + k ] move cursor to right window
{ "n", "<Leader>l", "<Cmd>wincmd l<CR>", { noremap = true } },

-- [ space + c ] highlight cursorline
{ "n", "<Leader>c", [[<Cmd>set cursorline! cursorcolumn!<CR>]], { noremap = true } },

--[[
#-------------------------------------------------------------------------#
# CUT COPY PASTE #
#-------------------------------------------------------------------------#
--]]
-- what in the hell ????? (╯°□°)╯︵ ┻━┻
-- delete without registering word
{ 'v', 'X', '"_d', { noremap = true } },
-- what in the hell ????? (╯°□°)╯︵ ┻━┻
-- delete without registering word
{ "v", "X", '"_d', { noremap = true } },

-- delete&local-paste without registering
{ 'v', '<Leader>p', '"_dP', { noremap = true } },
-- delete&local-paste without registering
{ "v", "<Leader>p", '"_dP', { noremap = true } },

-- yank it to global register
{ 'n', '<Leader>y', '"+y', { noremap = true } },
{ 'v', '<Leader>y', '"+y', { noremap = true } },
-- yank it to global register
{ "n", "<Leader>y", '"+y', { noremap = true } },
{ "v", "<Leader>y", '"+y', { noremap = true } },

-- ????????
{ 'n', '<Leader>d', '"_d', { noremap = true } },
{ 'v', '<Leader>d', '"_d', { noremap = true } },
-- ????????
{ "n", "<Leader>d", '"_d', { noremap = true } },
{ "v", "<Leader>d", '"_d', { noremap = true } },

-- yank all the content of file to global register ?? (╯°□°)╯︵ ┻━┻
{ 'n', '<Leader>Y', 'gg"+yG', { noremap = true } },

-- yank from the cursor position to the end of the line
{ 'n', 'Y', 'yg$', { noremap = true } },
-- yank all the content of file to global register ?? (╯°□°)╯︵ ┻━┻
{ "n", "<Leader>Y", 'gg"+yG', { noremap = true } },

-- yank from the cursor position to the end of the line
{ "n", "Y", "yg$", { noremap = true } },

--[[
#-------------------------------------------------------------------------#
# RESIZE WINDOW #
#-------------------------------------------------------------------------#
--]]

-- resize window
{ 'n', '<Leader>+', '<Cmd>vertical resize +5<CR>', { noremap = true } },
{ 'n', '<Leader>-', '<Cmd>vertical resize -5<CR>', { noremap = true } },
{ 'n', '<Leader>rp', '<Cmd>resize 100<CR>', { noremap = true } },

-- resize window
{ "n", "<Leader>+", "<Cmd>vertical resize +5<CR>", { noremap = true } },
{ "n", "<Leader>-", "<Cmd>vertical resize -5<CR>", { noremap = true } },
{ "n", "<Leader>rp", "<Cmd>resize 100<CR>", { noremap = true } },

--[[
#-------------------------------------------------------------------------#
# JUMP LIST MUTATIONS #
#-------------------------------------------------------------------------#
--]]

{ 'n', 'j', [[(v:count > 1 ? "m'" . v:count : '') . 'j']], { expr = true, noremap = true } },
{ 'n', 'k', [[(v:count > 1 ? "m'" . v:count : '') . 'k']], { expr = true, noremap = true } },
{ "n", "j", [[(v:count > 1 ? "m'" . v:count : '') . 'j']], { expr = true, noremap = true } },
{ "n", "k", [[(v:count > 1 ? "m'" . v:count : '') . 'k']], { expr = true, noremap = true } },

--[[
#-------------------------------------------------------------------------#
# MOVE LINE #
#-------------------------------------------------------------------------#
--]]

-- move selected line to up/down
{ 'v', 'J', [[:m '>+1<CR>gv=gv]], { noremap = true } },
{ 'v', 'K', [[:m '<-2<CR>gv=gv]], { noremap = true } },
{ 'n', 'J', [[mzJ`z]], { noremap = true } },

-- move selected line to up/down
{ "v", "J", [[:m '>+1<CR>gv=gv]], { noremap = true } },
{ "v", "K", [[:m '<-2<CR>gv=gv]], { noremap = true } },
{ "n", "J", [[mzJ`z]], { noremap = true } },

--[[
#-------------------------------------------------------------------------#
# UNDO #
#-------------------------------------------------------------------------#
--]]

-- undo break points
{ 'i', ',', ',<c-g>u', { noremap = true } },
{ 'i', '.', '.<c-g>u', { noremap = true } },
{ 'i', '!', '!<c-g>u', { noremap = true } },
{ 'i', '?', '?<c-g>u', { noremap = true } },
-- undo break points
{ "i", ",", ",<c-g>u", { noremap = true } },
{ "i", ".", ".<c-g>u", { noremap = true } },
{ "i", "!", "!<c-g>u", { noremap = true } },
{ "i", "?", "?<c-g>u", { noremap = true } },

--[[
#-------------------------------------------------------------------------#
# SEARCH WORD #
#-------------------------------------------------------------------------#
--]]

-- search with next with centralized cursor
{ 'n', 'n', 'nzzzv', { noremap = true } },
{ 'n', 'N', 'Nzzzv', { noremap = true } },

-- search with next with centralized cursor
{ "n", "n", "nzzzv", { noremap = true } },
{ "n", "N", "Nzzzv", { noremap = true } },

--[[
#-------------------------------------------------------------------------#
# TERMINAL #
#-------------------------------------------------------------------------#
--]]
-- open terminal
{ 'n', '<Leader>\\t', '<Cmd>terminal<CR>', { noremap = true } },
-- turn terminal to normal mode with escape
{ 't', '<Esc>', '<C-\\><C-n>', { noremap = true } },
-- open neovim terminal
{ 'n', '<c-n>', '<Cmd>call OpenTerminal()<CR>', { noremap = true } },

-- open terminal
{ "n", "<Leader>\\t", "<Cmd>terminal<CR>", { noremap = true } },
-- turn terminal to normal mode with escape
{ "t", "<Esc>", "<C-\\><C-n>", { noremap = true } },
-- open neovim terminal
{ "n", "<c-n>", "<Cmd>call OpenTerminal()<CR>", { noremap = true } },

--[[
#-------------------------------------------------------------------------#
# OTHER #
#-------------------------------------------------------------------------#
--]]
-- hit twice the spacebar if you want highlight to gone!
{ 'n', '<Leader>', '<Cmd>nohlsearch<Bar>:echo<CR>', { noremap = true, silent = true } },
-- ctrl-c
{ 'i', '<C-c>', '<esc>', { noremap = true } },
-- hit twice the spacebar if you want highlight to gone!
{ "n", "<Leader>", "<Cmd>nohlsearch<Bar>:echo<CR>", { noremap = true, silent = true } },
-- ctrl-c
{ "i", "<C-c>", "<esc>", { noremap = true } },
})
10 changes: 4 additions & 6 deletions nvim/lua/general/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,17 @@ Option.g({
backup = false,
writebackup = true,

-- write changes to swap file after "n" ms
-- write changes to swap file after "n" ms
updatetime = 50,

-- controls how short messages are displayed in status bar section
shortmess = vim.o.shortmess .. 'c',
shortmess = vim.o.shortmess .. "c",

-- open completion menu even for single item
-- open completion menu even for single item
-- do not auto insert items from completion menu
-- @warning - preview is removed. when it's on, default lsp opens a vertical tab
--completeopt = 'menuone,noinsert,noselect',


--[[
#-------------------------------------------------------------------------#
# EDITING #
Expand Down Expand Up @@ -92,7 +91,6 @@ Option.g({
--clipboard='unnamedplus',
})


Option.w({
--[[
#-------------------------------------------------------------------------#
Expand All @@ -113,7 +111,7 @@ Option.w({
-- error signs and warnings will be displayed in the number line
-- usually it adds new column when signs, moving buffer to right side.
-- adding a column create weird effect that's little bit hard for the eye
signcolumn = 'yes',
signcolumn = "yes",

-- vim try to keep 100 lines below and above when scrolling
-- if buffer cannot display more than 200 lines, cursor will stay in center
Expand Down
6 changes: 3 additions & 3 deletions nvim/lua/general/reloads.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Reload.reload_module('general')
Reload.reload_module('install-plugins')
Reload.reload_module('plugins')
Reload.reload_module("general")
Reload.reload_module("install-plugins")
Reload.reload_module("plugins")
26 changes: 13 additions & 13 deletions nvim/lua/general/variables.lua
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Variable.g({
loaded_matchparen = 1,
mapleader = ' ',
loaded_matchparen = 1,
mapleader = " ",
})

Variable.g({
-- neoformat
neoformat_enabled_python = { 'black' },
-- Enable alignment
neoformat_basic_format_align = 1,
-- Enable tab to spaces conversion
neoformat_basic_format_retab = 1,
-- Enable trimmming of trailing whitespace
neoformat_basic_format_trim = 1,
-- neoformat
neoformat_enabled_python = { "black" },
-- Enable alignment
neoformat_basic_format_align = 1,
-- Enable tab to spaces conversion
neoformat_basic_format_retab = 1,
-- Enable trimmming of trailing whitespace
neoformat_basic_format_trim = 1,
})

Variable.g({
vim_be_good_log_file = 1,
vim_apm_lig = 1,
python3_host_prog = tostring(os.getenv("HOME")) .. '/.asdf/shims/python',
vim_be_good_log_file = 1,
vim_apm_lig = 1,
python3_host_prog = tostring(os.getenv("HOME")) .. "/.asdf/shims/python",
})
Loading

0 comments on commit 99d2ad0

Please sign in to comment.