From f003b2f813054a289a5fa5c7de7a47965bbdf7cd Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Sun, 7 Apr 2024 21:00:36 +0800 Subject: [PATCH] chore(plugins): tidying up This commit mainly tweaks the loading events of some plugins to align with upstream specifications. Additionally, there have been enhancements made to certain documentation. Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/keymap/editor.lua | 30 +++--- lua/modules/configs/completion/neoconf.lua | 29 +----- lua/modules/configs/editor/align.lua | 11 +++ .../configs/editor/local-highlight.lua | 7 +- lua/modules/configs/editor/mini-align.lua | 8 -- lua/modules/configs/editor/smart-splits.lua | 92 ------------------- lua/modules/configs/editor/splits.lua | 14 +++ lua/modules/configs/ui/catppuccin.lua | 2 +- lua/modules/configs/ui/lualine.lua | 2 +- lua/modules/configs/ui/todo.lua | 42 +++++++++ lua/modules/plugins/completion.lua | 2 +- lua/modules/plugins/editor.lua | 13 ++- lua/modules/plugins/ui.lua | 5 +- 13 files changed, 104 insertions(+), 153 deletions(-) create mode 100644 lua/modules/configs/editor/align.lua delete mode 100644 lua/modules/configs/editor/mini-align.lua delete mode 100644 lua/modules/configs/editor/smart-splits.lua create mode 100644 lua/modules/configs/editor/splits.lua create mode 100644 lua/modules/configs/ui/todo.lua diff --git a/lua/keymap/editor.lua b/lua/keymap/editor.lua index 76845a616..9b0271cee 100644 --- a/lua/keymap/editor.lua +++ b/lua/keymap/editor.lua @@ -68,28 +68,36 @@ local plug_map = { ["n|"] = map_cu("SmartCursorMoveDown"):with_silent():with_noremap():with_desc("window: Focus down"), ["n|"] = map_cu("SmartCursorMoveUp"):with_silent():with_noremap():with_desc("window: Focus up"), ["n|"] = map_cu("SmartCursorMoveRight"):with_silent():with_noremap():with_desc("window: Focus right"), - ["n|Wh"] = map_cu("SmartSwapLeft"):with_silent():with_noremap():with_desc("window: Move window to left"), - ["n|Wj"] = map_cu("SmartSwapDown"):with_silent():with_noremap():with_desc("window: Move window to down"), - ["n|Wk"] = map_cu("SmartSwapUp"):with_silent():with_noremap():with_desc("window: Move window to up"), - ["n|Wl"] = map_cu("SmartSwapRight"):with_silent():with_noremap():with_desc("window: Move window to right"), + ["n|Wh"] = map_cu("SmartSwapLeft"):with_silent():with_noremap():with_desc("window: Move window leftward"), + ["n|Wj"] = map_cu("SmartSwapDown"):with_silent():with_noremap():with_desc("window: Move window downward"), + ["n|Wk"] = map_cu("SmartSwapUp"):with_silent():with_noremap():with_desc("window: Move window upward"), + ["n|Wl"] = map_cu("SmartSwapRight"):with_silent():with_noremap():with_desc("window: Move window rightward"), -- Plugin: nvim-spectre - ["n|Ss"] = map_cmd([[lua require("spectre").toggle()]]) + ["n|Ss"] = map_callback(function() + require("spectre").toggle() + end) :with_silent() :with_noremap() - :with_desc("editn: Toggle search&replace panel"), - ["n|Sp"] = map_cmd([[lua require("spectre").open_visual({select_word=true})]]) + :with_desc("editn: Toggle search & replace panel"), + ["n|Sp"] = map_callback(function() + require("spectre").open_visual({ select_word = true }) + end) :with_silent() :with_noremap() :with_desc("editn: search&replace current word (project)"), - ["v|Sp"] = map_cmd([[lua require("spectre").open_visual()]]) + ["v|Sp"] = map_callback(function() + require("spectre").open_visual() + end) :with_silent() :with_noremap() - :with_desc("edit: search&replace current word (project)"), - ["n|Sf"] = map_cmd([[lua require("spectre").open_file_search({select_word=true})]]) + :with_desc("edit: search & replace current word (project)"), + ["n|Sf"] = map_callback(function() + require("spectre").open_file_search({ select_word = true }) + end) :with_silent() :with_noremap() - :with_desc("editn: search&replace current word (file)"), + :with_desc("editn: search & replace current word (file)"), -- Plugin: nvim-treehopper ["o|m"] = map_cu("lua require('tsht').nodes()"):with_silent():with_desc("jump: Operate across syntax tree"), diff --git a/lua/modules/configs/completion/neoconf.lua b/lua/modules/configs/completion/neoconf.lua index 4deef7695..4db9cc75f 100644 --- a/lua/modules/configs/completion/neoconf.lua +++ b/lua/modules/configs/completion/neoconf.lua @@ -2,6 +2,8 @@ local M = {} M.setup = function() require("modules.utils").load_plugin("neoconf", { + -- send new configuration to lsp clients when changing json settings + live_reload = true, -- name of the local settings files local_settings = ".neoconf.json", -- name of the global settings file in your Neovim config directory @@ -12,33 +14,6 @@ M.setup = function() 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 diff --git a/lua/modules/configs/editor/align.lua b/lua/modules/configs/editor/align.lua new file mode 100644 index 000000000..43c50d8dc --- /dev/null +++ b/lua/modules/configs/editor/align.lua @@ -0,0 +1,11 @@ +return function() + require("modules.utils").load_plugin("mini.align", { + -- Whether to disable showing non-error feedback + silent = false, + -- Module mappings. Use `''` (empty string) to disable one. + mappings = { + start = "gea", + start_with_preview = "geA", + }, + }) +end diff --git a/lua/modules/configs/editor/local-highlight.lua b/lua/modules/configs/editor/local-highlight.lua index 022440396..f8c001f3d 100644 --- a/lua/modules/configs/editor/local-highlight.lua +++ b/lua/modules/configs/editor/local-highlight.lua @@ -1,11 +1,6 @@ return function() require("modules.utils").load_plugin("local-highlight", { - file_types = nil, - hlgroup = "Search", - cw_hlgroup = nil, - -- Whether to display highlights in INSERT mode or not + hlgroup = "IlluminatedWordText", insert_mode = false, - min_match_len = 1, - max_match_len = math.huge, }) end diff --git a/lua/modules/configs/editor/mini-align.lua b/lua/modules/configs/editor/mini-align.lua deleted file mode 100644 index 4cbf7fed6..000000000 --- a/lua/modules/configs/editor/mini-align.lua +++ /dev/null @@ -1,8 +0,0 @@ -return function() - require("mini.align").setup({ - mappings = { - start = "gea", - start_with_preview = "geA", - }, - }) -end diff --git a/lua/modules/configs/editor/smart-splits.lua b/lua/modules/configs/editor/smart-splits.lua deleted file mode 100644 index 3ea0ceb44..000000000 --- a/lua/modules/configs/editor/smart-splits.lua +++ /dev/null @@ -1,92 +0,0 @@ -return function() - require("modules.utils").load_plugin("smart-splits", { - -- Ignored buffer types (only while resizing) - ignored_buftypes = { - "nofile", - "quickfix", - "prompt", - }, - -- Ignored filetypes (only while resizing) - ignored_filetypes = { "NvimTree" }, - -- the default number of lines/columns to resize by at a time - default_amount = 3, - -- Desired behavior when your cursor is at an edge and you - -- are moving towards that same edge: - -- 'wrap' => Wrap to opposite side - -- 'split' => Create a new split in the desired direction - -- 'stop' => Do nothing - -- function => You handle the behavior yourself - -- NOTE: If using a function, the function will be called with - -- a context object with the following fields: - -- { - -- mux = { - -- type:'tmux'|'wezterm'|'kitty' - -- current_pane_id():number, - -- is_in_session(): boolean - -- current_pane_is_zoomed():boolean, - -- -- following methods return a boolean to indicate success or failure - -- current_pane_at_edge(direction:'left'|'right'|'up'|'down'):boolean - -- next_pane(direction:'left'|'right'|'up'|'down'):boolean - -- resize_pane(direction:'left'|'right'|'up'|'down'):boolean - -- split_pane(direction:'left'|'right'|'up'|'down',size:number|nil):boolean - -- }, - -- direction = 'left'|'right'|'up'|'down', - -- split(), -- utility function to split current Neovim pane in the current direction - -- wrap(), -- utility function to wrap to opposite Neovim pane - -- } - -- NOTE: `at_edge = 'wrap'` is not supported on Kitty terminal - -- multiplexer, as there is no way to determine layout via the CLI - at_edge = "wrap", - -- when moving cursor between splits left or right, - -- place the cursor on the same row of the *screen* - -- regardless of line numbers. False by default. - -- Can be overridden via function parameter, see Usage. - move_cursor_same_row = false, - -- whether the cursor should follow the buffer when swapping - -- buffers by default; it can also be controlled by passing - -- `{ move_cursor = true }` or `{ move_cursor = false }` - -- when calling the Lua function. - cursor_follows_swapped_bufs = false, - -- resize mode options - resize_mode = { - -- key to exit persistent resize mode - quit_key = "", - -- keys to use for moving in resize mode - -- in order of left, down, up' right - resize_keys = { "h", "j", "k", "l" }, - -- set to true to silence the notifications - -- when entering/exiting persistent resize mode - silent = false, - -- must be functions, they will be executed when - -- entering or exiting the resize mode - hooks = { - on_enter = nil, - on_leave = nil, - }, - }, - -- ignore these autocmd events (via :h eventignore) while processing - -- smart-splits.nvim computations, which involve visiting different - -- buffers and windows. These events will be ignored during processing, - -- and un-ignored on completed. This only applies to resize events, - -- not cursor movement events. - ignored_events = { - "BufEnter", - "WinEnter", - }, - -- enable or disable a multiplexer integration; - -- automatically determined, unless explicitly disabled or set, - -- by checking the $TERM_PROGRAM environment variable, - -- and the $KITTY_LISTEN_ON environment variable for Kitty - multiplexer_integration = "tmux", - -- disable multiplexer navigation if current multiplexer pane is zoomed - -- this functionality is only supported on tmux and Wezterm due to kitty - -- not having a way to check if a pane is zoomed - disable_multiplexer_nav_when_zoomed = true, - -- Supply a Kitty remote control password if needed, - -- or you can also set vim.g.smart_splits_kitty_password - -- see https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.remote_control_password - kitty_password = nil, - -- default logging level, one of: 'trace'|'debug'|'info'|'warn'|'error'|'fatal' - log_level = "info", - }) -end diff --git a/lua/modules/configs/editor/splits.lua b/lua/modules/configs/editor/splits.lua new file mode 100644 index 000000000..891d01eaf --- /dev/null +++ b/lua/modules/configs/editor/splits.lua @@ -0,0 +1,14 @@ +return function() + require("modules.utils").load_plugin("smart-splits", { + -- Ignored buffer types (only while resizing) + ignored_buftypes = { + "nofile", + "quickfix", + "prompt", + }, + -- Ignored filetypes (only while resizing) + ignored_filetypes = { "NvimTree" }, + -- the default number of lines/columns to resize by at a time + default_amount = 3, + }) +end diff --git a/lua/modules/configs/ui/catppuccin.lua b/lua/modules/configs/ui/catppuccin.lua index 4eec738ed..9d1e8400e 100644 --- a/lua/modules/configs/ui/catppuccin.lua +++ b/lua/modules/configs/ui/catppuccin.lua @@ -64,7 +64,7 @@ return function() harpoon = false, headlines = false, hop = true, - illuminate = false, + illuminate = true, indent_blankline = { enabled = true, colored_indent_levels = false }, leap = false, lightspeed = false, diff --git a/lua/modules/configs/ui/lualine.lua b/lua/modules/configs/ui/lualine.lua index d5108ed8a..34d0d187c 100644 --- a/lua/modules/configs/ui/lualine.lua +++ b/lua/modules/configs/ui/lualine.lua @@ -218,7 +218,7 @@ return function() tabwidth = { function() - return icons.ui.Tab .. vim.api.nvim_get_option_value("shiftwidth", { scope = "local" }) + return icons.ui.Tab .. vim.api.nvim_get_option_value("tabstop", { scope = "local" }) end, padding = 1, }, diff --git a/lua/modules/configs/ui/todo.lua b/lua/modules/configs/ui/todo.lua new file mode 100644 index 000000000..1fbd248e2 --- /dev/null +++ b/lua/modules/configs/ui/todo.lua @@ -0,0 +1,42 @@ +return function() + local icons = { + diagnostics = require("modules.utils.icons").get("diagnostics"), + ui = require("modules.utils.icons").get("ui"), + } + + require("modules.utils").load_plugin("todo-comments", { + signs = false, -- show icons in the signs column + keywords = { + FIX = { + icon = icons.ui.Bug, + color = "error", + alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, + }, + TODO = { icon = icons.ui.Accepted, color = "info" }, + -- HACK = { icon = icons.ui.Fire, color = "warning" }, + WARN = { icon = icons.diagnostics.Warning, color = "warning", alt = { "WARNING", "XXX" } }, + PERF = { icon = icons.ui.Perf, alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } }, + NOTE = { icon = icons.ui.Note, color = "hint", alt = { "INFO" } }, + }, + gui_style = { + fg = "NONE", + bg = "BOLD", + }, + merge_keywords = true, + highlight = { + multiline = false, + keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. + after = "", + comments_only = true, + max_line_len = 500, + exclude = { "big_file_disabled_ft" }, + }, + colors = { + error = { "DiagnosticError", "ErrorMsg", "#DC2626" }, + warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" }, + info = { "DiagnosticInfo", "#2563EB" }, + hint = { "DiagnosticHint", "#F5C2E7" }, + default = { "Conditional", "#7C3AED" }, + }, + }) +end diff --git a/lua/modules/plugins/completion.lua b/lua/modules/plugins/completion.lua index 7928615a8..d4b5d088d 100644 --- a/lua/modules/plugins/completion.lua +++ b/lua/modules/plugins/completion.lua @@ -63,7 +63,7 @@ completion["hrsh7th/nvim-cmp"] = { { "f3fora/cmp-spell" }, { "hrsh7th/cmp-buffer" }, { "kdheepak/cmp-latex-symbols" }, - { "ray-x/cmp-treesitter" }, + { "ray-x/cmp-treesitter", commit = "c8e3a74" }, -- { "tzachar/cmp-tabnine", build = "./install.sh", config = require("completion.tabnine") }, -- { -- "jcdickinson/codeium.nvim", diff --git a/lua/modules/plugins/editor.lua b/lua/modules/plugins/editor.lua index 3d0fdd93e..7a102e12a 100644 --- a/lua/modules/plugins/editor.lua +++ b/lua/modules/plugins/editor.lua @@ -51,8 +51,9 @@ editor["sindrets/diffview.nvim"] = { config = require("editor.diffview"), } editor["echasnovski/mini.align"] = { - version = false, - config = require("editor.mini-align"), + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("editor.align"), } editor["smoka7/hop.nvim"] = { lazy = true, @@ -78,14 +79,18 @@ editor["tpope/vim-sleuth"] = { lazy = true, event = "BufReadPre", } +editor["tpope/vim-sleuth"] = { + lazy = true, + event = { "BufNewFile", "BufReadPost", "BufFilePost" }, +} editor["nvim-pack/nvim-spectre"] = { lazy = true, - cmd = { "Spectre" }, + cmd = "Spectre", } editor["mrjones2014/smart-splits.nvim"] = { lazy = true, event = { "CursorHoldI", "CursorHold" }, - config = require("editor.smart-splits"), + config = require("editor.splits"), } ---------------------------------------------------------------------- diff --git a/lua/modules/plugins/ui.lua b/lua/modules/plugins/ui.lua index e94201294..062f2b0b5 100644 --- a/lua/modules/plugins/ui.lua +++ b/lua/modules/plugins/ui.lua @@ -59,8 +59,9 @@ ui["folke/paint.nvim"] = { } ui["folke/todo-comments.nvim"] = { lazy = true, - event = { "BufReadPost" }, - opts = {}, + event = { "CursorHold", "CursorHoldI" }, + config = require("ui.todo"), + dependencies = { "nvim-lua/plenary.nvim" }, } ui["dstein64/nvim-scrollview"] = { lazy = true,