Skip to content

Commit

Permalink
refactor(plugins): iterate plugins (#1198)
Browse files Browse the repository at this point in the history
This PR introduces BREAKING CHANGE about plugins and keymaps.
Plugins removed:
1. `rainbowhxch/accelerated-jk.nvim`
2. `max397574/better-escape.nvim`
3. `sindrets/diffview.nvim`
4. `abecodes/tabout.nvim`
5. `edluffy/specs.nvim`
Plugins replaced:
1. `junegunn/vim-easy-align` to `echasnovski/mini.align`
2. `RRethy/vim-illuminate` to `tzachar/local-highlight.nvim`
3. `gelguy/wilder.nvim` to `hrsh7th/cmp-cmdline`
Plugins added:
1. `folke/neoconf.nvim` for pre project custom lsp config.
2. `tpope/vim-sleuth` for smart tab size.
3. `nvim-pack/nvim-spectre` for project-level plain text search and replace.
4. `mrjones2014/smart-splits.nvim` for smart window splits with terminal multiplexers.
5. `folke/todo-comments.nvim` for highlight of TODO, NOTE, etc.
6. `nvim-neotest/nvim-nio` for dependency of `nvim-dap-ui`.
Keymaps modifications:
1. `n|<A-j>` and `n|<A-k>` are mapped to resize window vertically.
2. `n|<A-h>` and `n|<A-l>` are mapped to resize window horizontally.
3. `n|<A-i>` and `n|<A-o>` are mapped to switch opened buffers/tabs.
4. `n|<A-S-i>` and `n|<A-S-o>` are mapped to move opened buffers/tabs.
5. `n|<leader>Ss`, `n|<leader>Sp`, `v|<leader>Sp` and `n|<leader>Sf` are mapped to project-level text search and replace, you can use `<C-p>` to check the detailed descriptions.
6. `n|<leader>Wh`, `n|<leader>Wj`, `n|<leader>Wk` and `n|<leader>Wl` are mapped to move splitted windows.
7. `n|<leader>gd`, `n|<leader>gD`, `n|<A-[>`, `n|<A-]>`, `n|<A-;>`, `n|<A-'>`, `n|gea`, `n|<A-S-j>`, `n|<A-S-k>`,  `i|<A-l>` and `i|<A-h>` are unmapped, they are free now!
  • Loading branch information
ayamir authored Mar 22, 2024
1 parent b51a2f4 commit 61c817f
Show file tree
Hide file tree
Showing 26 changed files with 273 additions and 812 deletions.
2 changes: 1 addition & 1 deletion lua/core/event.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Now use `<A-k>` or `<A-1>` to back to the `dotstutor`.
-- Now use `<A-o>` or `<A-1>` to back to the `dotstutor`.
local autocmd = {}

function autocmd.nvim_create_augroups(definitions)
Expand Down
8 changes: 4 additions & 4 deletions lua/core/mapping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ local core_map = {
["t|<C-w>l"] = map_cmd("<Cmd>wincmd l<CR>"):with_silent():with_noremap():with_desc("window: Focus right"),
["t|<C-w>j"] = map_cmd("<Cmd>wincmd j<CR>"):with_silent():with_noremap():with_desc("window: Focus down"),
["t|<C-w>k"] = map_cmd("<Cmd>wincmd k<CR>"):with_silent():with_noremap():with_desc("window: Focus up"),
["n|<A-[>"] = map_cr("vertical resize -5"):with_silent():with_desc("window: Resize -5 vertically"),
["n|<A-]>"] = map_cr("vertical resize +5"):with_silent():with_desc("window: Resize +5 vertically"),
["n|<A-;>"] = map_cr("resize -2"):with_silent():with_desc("window: Resize -2 horizontally"),
["n|<A-'>"] = map_cr("resize +2"):with_silent():with_desc("window: Resize +2 horizontally"),
["n|<A-h>"] = map_cr("vertical resize -3"):with_silent():with_desc("window: Resize -3 vertically"),
["n|<A-l>"] = map_cr("vertical resize +3"):with_silent():with_desc("window: Resize +3 vertically"),
["n|<A-j>"] = map_cr("resize -3"):with_silent():with_desc("window: Resize -3 horizontally"),
["n|<A-k>"] = map_cr("resize +3"):with_silent():with_desc("window: Resize +3 horizontally"),
["n|<C-q>"] = map_cr("wq"):with_desc("edit: Save file and quit"),
["n|<A-S-q>"] = map_cr("q!"):with_desc("edit: Force quit"),
["n|<leader>o"] = map_cr("setlocal spell! spelllang=en_us"):with_desc("edit: Toggle spell check"),
Expand Down
55 changes: 34 additions & 21 deletions lua/keymap/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ local map_callback = bind.map_callback
local et = bind.escape_termcode

local plug_map = {
-- Plugin: accelerate-jk
["n|j"] = map_callback(function()
return et("<Plug>(accelerated_jk_gj)")
end):with_expr(),
["n|k"] = map_callback(function()
return et("<Plug>(accelerated_jk_gk)")
end):with_expr(),

-- Plugin persisted.nvim
["n|<leader>ss"] = map_cu("SessionSave"):with_noremap():with_silent():with_desc("session: Save"),
["n|<leader>sl"] = map_cu("SessionLoad"):with_noremap():with_silent():with_desc("session: Load current"),
Expand Down Expand Up @@ -56,26 +48,47 @@ local plug_map = {
:with_noremap()
:with_desc("edit: Toggle comment for block with selection"),

-- Plugin: diffview
["n|<leader>gd"] = map_cr("DiffviewOpen"):with_silent():with_noremap():with_desc("git: Show diff"),
["n|<leader>gD"] = map_cr("DiffviewClose"):with_silent():with_noremap():with_desc("git: Close diff"),

-- Plugin: vim-easy-align
["nx|gea"] = map_cr("EasyAlign"):with_desc("edit: Align with delimiter"),

-- Plugin: hop
-- Plugin: hop.nvim
["nv|<leader>w"] = map_cmd("<Cmd>HopWordMW<CR>"):with_noremap():with_desc("jump: Goto word"),
["nv|<leader>j"] = map_cmd("<Cmd>HopLineMW<CR>"):with_noremap():with_desc("jump: Goto line"),
["nv|<leader>k"] = map_cmd("<Cmd>HopLineMW<CR>"):with_noremap():with_desc("jump: Goto line"),
["nv|<leader>c"] = map_cmd("<Cmd>HopChar1MW<CR>"):with_noremap():with_desc("jump: Goto one char"),
["nv|<leader>C"] = map_cmd("<Cmd>HopChar2MW<CR>"):with_noremap():with_desc("jump: Goto two chars"),

-- Plugin: treehopper
["o|m"] = map_cu("lua require('tsht').nodes()"):with_silent():with_desc("jump: Operate across syntax tree"),
-- Plugin: smart-splits.nvim
["n|<A-h>"] = map_cu("SmartResizeLeft"):with_silent():with_noremap():with_desc("window: Resize -3 horizontally"),
["n|<A-j>"] = map_cu("SmartResizeDown"):with_silent():with_noremap():with_desc("window: Resize -3 vertically"),
["n|<A-k>"] = map_cu("SmartResizeUp"):with_silent():with_noremap():with_desc("window: Resize +3 vertically"),
["n|<A-l>"] = map_cu("SmartResizeRight"):with_silent():with_noremap():with_desc("window: Resize +3 horizontally"),
["n|<C-h>"] = map_cu("SmartCursorMoveLeft"):with_silent():with_noremap():with_desc("window: Focus left"),
["n|<C-j>"] = map_cu("SmartCursorMoveDown"):with_silent():with_noremap():with_desc("window: Focus down"),
["n|<C-k>"] = map_cu("SmartCursorMoveUp"):with_silent():with_noremap():with_desc("window: Focus up"),
["n|<C-l>"] = map_cu("SmartCursorMoveRight"):with_silent():with_noremap():with_desc("window: Focus right"),
["n|<leader>Wh"] = map_cu("SmartSwapLeft"):with_silent():with_noremap():with_desc("window: Move window to left"),
["n|<leader>Wj"] = map_cu("SmartSwapDown"):with_silent():with_noremap():with_desc("window: Move window to down"),
["n|<leader>Wk"] = map_cu("SmartSwapUp"):with_silent():with_noremap():with_desc("window: Move window to up"),
["n|<leader>Wl"] = map_cu("SmartSwapRight"):with_silent():with_noremap():with_desc("window: Move window to right"),

-- Plugin: nvim-spectre
["n|<leader>Ss"] = map_cmd([[<Cmd>lua require("spectre").toggle()<CR>]])
:with_silent()
:with_noremap()
:with_desc("editn: Toggle search&replace panel"),
["n|<leader>Sp"] = map_cmd([[<Cmd>lua require("spectre").open_visual({select_word=true})<CR>]])
:with_silent()
:with_noremap()
:with_desc("editn: search&replace current word (project)"),
["v|<leader>Sp"] = map_cmd([[<Esc><Cmd>lua require("spectre").open_visual()<CR>]])
:with_silent()
:with_noremap()
:with_desc("edit: search&replace current word (project)"),
["n|<leader>Sf"] = map_cmd([[<Cmd>lua require("spectre").open_file_search({select_word=true})<CR>]])
:with_silent()
:with_noremap()
:with_desc("editn: search&replace current word (file)"),

-- Plugin: tabout
["i|<A-l>"] = map_cmd("<Plug>(TaboutMulti)"):with_silent():with_noremap():with_desc("edit: Goto end of pair"),
["i|<A-h>"] = map_cmd("<Plug>(TaboutBackMulti)"):with_silent():with_noremap():with_desc("edit: Goto begin of pair"),
-- Plugin: nvim-treehopper
["o|m"] = map_cu("lua require('tsht').nodes()"):with_silent():with_desc("jump: Operate across syntax tree"),

-- Plugin suda.vim
["n|<A-s>"] = map_cu("SudaWrite"):with_silent():with_noremap():with_desc("editn: Save file using sudo"),
Expand Down
10 changes: 5 additions & 5 deletions lua/keymap/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ local map_cr = bind.map_cr
-- local map_callback = bind.map_callback

local plug_map = {
-- Plugin: bufferline
["n|<A-j>"] = map_cr("BufferLineCycleNext"):with_noremap():with_silent():with_desc("buffer: Switch to next"),
["n|<A-k>"] = map_cr("BufferLineCyclePrev"):with_noremap():with_silent():with_desc("buffer: Switch to prev"),
["n|<A-S-j>"] = map_cr("BufferLineMoveNext"):with_noremap():with_silent():with_desc("buffer: Move current to next"),
["n|<A-S-k>"] = map_cr("BufferLineMovePrev"):with_noremap():with_silent():with_desc("buffer: Move current to prev"),
-- Plugin: bufferline.nvim
["n|<A-i>"] = map_cr("BufferLineCycleNext"):with_noremap():with_silent():with_desc("buffer: Switch to next"),
["n|<A-o>"] = map_cr("BufferLineCyclePrev"):with_noremap():with_silent():with_desc("buffer: Switch to prev"),
["n|<A-S-i>"] = map_cr("BufferLineMoveNext"):with_noremap():with_silent():with_desc("buffer: Move current to next"),
["n|<A-S-o>"] = map_cr("BufferLineMovePrev"):with_noremap():with_silent():with_desc("buffer: Move current to prev"),
["n|<leader>be"] = map_cr("BufferLineSortByExtension"):with_noremap():with_desc("buffer: Sort by extension"),
["n|<leader>bd"] = map_cr("BufferLineSortByDirectory"):with_noremap():with_desc("buffer: Sort by direrctory"),
["n|<A-1>"] = map_cr("BufferLineGoToBuffer 1"):with_noremap():with_silent():with_desc("buffer: Goto buffer 1"),
Expand Down
19 changes: 19 additions & 0 deletions lua/modules/configs/completion/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,25 @@ return function()
}

local cmp = require("cmp")
cmp.setup.cmdline("/", {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = "buffer" },
},
})
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "path" },
}, {
{
name = "cmdline",
option = {
ignore_cmds = { "Man", "!" },
},
},
}),
})
require("modules.utils").load_plugin("cmp", {
preselect = cmp.PreselectMode.Item,
window = {
Expand Down
1 change: 1 addition & 0 deletions lua/modules/configs/completion/lsp.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
return function()
local nvim_lsp = require("lspconfig")
require("completion.neoconf").setup()
require("completion.mason").setup()
require("completion.mason-lspconfig").setup()

Expand Down
45 changes: 45 additions & 0 deletions lua/modules/configs/completion/neoconf.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
local M = {}

M.setup = function()
require("modules.utils").load_plugin("neoconf", {
-- name of the local settings files
local_settings = ".neoconf.json",
-- name of the global settings file in your Neovim config directory
global_settings = "neoconf.json",
-- import existing settings from other plugins
import = {
vscode = true, -- local .vscode/settings.json
coc = true, -- global/local coc-settings.json
nlsp = true, -- global/local nlsp-settings.nvim json settings
},
-- send new configuration to lsp clients when changing json settings
live_reload = true,
-- set the filetype to jsonc for settings files, so you can use comments
-- make sure you have the jsonc treesitter parser installed!
filetype_jsonc = true,
plugins = {
-- configures lsp clients with settings in the following order:
-- - lua settings passed in lspconfig setup
-- - global json settings
-- - local json settings
lspconfig = {
enabled = true,
},
-- configures jsonls to get completion in .nvim.settings.json files
jsonls = {
enabled = true,
-- only show completion in json settings for configured lsp servers
configured_servers_only = true,
},
-- configures lua_ls to get completion of lspconfig server settings
lua_ls = {
-- by default, lua_ls annotations are only enabled in your neovim config directory
enabled_for_neovim_config = true,
-- explicitely enable adding annotations. Mostly relevant to put in your local .nvim.settings.json file
enabled = false,
},
},
})
end

return M
11 changes: 0 additions & 11 deletions lua/modules/configs/editor/accelerated-jk.lua

This file was deleted.

12 changes: 0 additions & 12 deletions lua/modules/configs/editor/better-escape.lua

This file was deleted.

1 change: 0 additions & 1 deletion lua/modules/configs/editor/bigfile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ return function()
pattern = { "*" }, -- autocmd pattern
features = { -- features to disable
"lsp",
"illuminate",
"treesitter",
"syntax",
"vimopts",
Expand Down
Loading

0 comments on commit 61c817f

Please sign in to comment.