diff --git a/lua/autocmd.lua b/lua/autocmd.lua index de2f54d..97d252b 100644 --- a/lua/autocmd.lua +++ b/lua/autocmd.lua @@ -13,8 +13,11 @@ autocmd("VimLeave", { command = "set guicursor=a:ver25-Cursor" }) -autocmd({ "CursorHold" }, { - callback = function() - vim.diagnostic.open_float(nil, { focus = false }) - end +autocmd("BufWritePre", { + callback = function() + local ok = pcall(function() + vim.cmd "undojoin" + end) + vim.cmd "Neoformat" + end, }) diff --git a/lua/config/TID.lua b/lua/config/TID.lua new file mode 100644 index 0000000..f10bf72 --- /dev/null +++ b/lua/config/TID.lua @@ -0,0 +1 @@ +require("tiny-inline-diagnostic").setup({}) diff --git a/lua/config/actions-preview.lua b/lua/config/actions-preview.lua new file mode 100644 index 0000000..fae87d1 --- /dev/null +++ b/lua/config/actions-preview.lua @@ -0,0 +1,73 @@ +require("actions-preview").setup { + -- options for vim.diff(): https://neovim.io/doc/user/lua.html#vim.diff() + diff = { + ctxlen = 3, + }, + + highlight_command = { + -- require("actions-preview.highlight").delta(), + -- require("actions-preview.highlight").diff_so_fancy(), + -- require("actions-preview.highlight").diff_highlight(), + }, + + -- priority list of preferred backend + backend = { "snacks", "nui" }, + + -- options related to telescope.nvim + telescope = vim.tbl_extend( + "force", + require("telescope.themes").get_dropdown(), + -- a table for customizing content + { + -- a function to make a table containing the values to be displayed. + -- fun(action: Action): { title: string, client_name: string|nil } + make_value = nil, + + -- a function to make a function to be used in `display` of a entry. + -- see also `:h telescope.make_entry` and `:h telescope.pickers.entry_display`. + -- fun(values: { index: integer, action: Action, title: string, client_name: string }[]): function + make_make_display = nil, + } + ), + + -- options for nui.nvim components + nui = { + -- component direction. "col" or "row" + dir = "col", + -- keymap for selection component: https://github.com/MunifTanjim/nui.nvim/tree/main/lua/nui/menu#keymap + keymap = nil, + -- options for nui Layout component: https://github.com/MunifTanjim/nui.nvim/tree/main/lua/nui/layout + layout = { + position = "50%", + size = { + width = "60%", + height = "100%", + }, + min_width = 40, + min_height = 10, + relative = "editor", + }, + -- options for preview area: https://github.com/MunifTanjim/nui.nvim/tree/main/lua/nui/popup + preview = { + size = "80%", + border = { + style = "rounded", + padding = { 0, 1 }, + }, + }, + -- options for selection area: https://github.com/MunifTanjim/nui.nvim/tree/main/lua/nui/menu + select = { + size = "20%", + border = { + style = "rounded", + padding = { 0, 1 }, + }, + }, + }, + + --- options for snacks picker + ---@type snacks.picker.Config + snacks = { + layout = { rpreset = "default" }, + }, +} diff --git a/lua/mappings.lua b/lua/mappings.lua index 7f5a36e..98307fa 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -3,6 +3,8 @@ local map = vim.keymap.set map("n", "", "BufferLineCycleNext") map("n", "", "BufferLineCyclePrev") +map({"n", "v"}, "ap", require("actions-preview").code_actions) + map("n", ";", ":", { desc = "CMD enter command mode" }) -- Move selected text up diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 220f52f..24e260b 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -280,4 +280,22 @@ return { require("config.tmux") end, }, + { + "rachartier/tiny-inline-diagnostic.nvim", + config = function () + require("config.TID") + end, + }, + { + "aznhe21/actions-preview.nvim", + config = function() + require("config.actions-preview") + end, + }, + { + "sbdchd/neoformat", + -- config = function() + -- require("config.neoformat") + -- end, + }, }