Skip to content

Commit

Permalink
add snacks.nvim
Browse files Browse the repository at this point in the history
  • Loading branch information
fcying committed Nov 11, 2024
1 parent 12416c2 commit 9c995fe
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 72 deletions.
2 changes: 1 addition & 1 deletion etc/atuin/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ search_mode = "skim"

## which filter mode to use
## possible values: global, host, session, directory
filter_mode = "global"
filter_mode = "host"

## With workspace filtering enabled, Atuin will filter for commands executed
## in any directory within a git repository tree (default: false)
Expand Down
3 changes: 2 additions & 1 deletion lua/_lazy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ local plugins = {
{ import = "plugins.colorscheme" },
{ import = "plugins.suda" },
{ import = "plugins.mini" },
{ import = "plugins.snacks" },
{ import = "plugins.misc" },

-- editor {{{
Expand Down Expand Up @@ -48,7 +49,7 @@ local plugins = {
{ "fcying/vim-plugin-AnsiEsc", cmd = { "AnsiEsc", "AnsiEscClear" } },
{ "stevearc/dressing.nvim", opts = {} },
-- { import = "plugins.noice" },
{ import = "plugins.nvim_notify" },
-- { import = "plugins.nvim_notify" },
-- { import = "plugins.ZFVimIM" },
-- { import = "plugins.ZFVimDirDiff" },
{ import = "plugins.fugitive" },
Expand Down
8 changes: 1 addition & 7 deletions lua/keymap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ map("", "<esc>", function()
if vim.v.hlsearch == 1 then
vim.cmd("noh")
end
require("notify").dismiss({})
-- require("notify").dismiss({})
end)

-- cmd-line window dd {{{
Expand Down Expand Up @@ -152,12 +152,6 @@ noremap <silent><leader>9 :tabn 9<cr>
noremap <silent><leader>0 :tabn 10<cr>
]])


map("n", "<F2>", ":set number! number?<CR>")
map("n", "<F3>", ":set list! list?<CR>")
map("n", "<F4>", ":set wrap! wrap?<CR>")
map("n", "<F6>", ":exec exists('syntax_on') ? 'syn off' : 'syn on'<CR>")

-- quickfix {{{
map("n", "]q", ":cnext<CR>")
map("n", "[q", ":cprev<CR>")
Expand Down
13 changes: 0 additions & 13 deletions lua/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@ Formats = {
},
}

local diagnostics_on = true
function M.diagnostic_toggle()
if diagnostics_on then
vim.notify("disable diagnostics")
vim.diagnostic.enable(false)
else
vim.notify("enable diagnostics")
vim.diagnostic.enable(true)
end
diagnostics_on = not diagnostics_on
end

---@diagnostic disable-next-line unused-local
local function diagnostics_config(enable)
if enable == nil then
Expand Down Expand Up @@ -306,7 +294,6 @@ function M.setup()
map("n", "<leader>la", function() require("actions-preview").code_actions() end, opts)
map("n", "<leader>ld", "<cmd>Telescope diagnostics bufnr=0<cr>", opts)
map("n", "<leader>ls", "<cmd>Telescope lsp_workspace_symbols<cr>", opts)
map("n", "<leader>ltd", '<cmd>lua require("lsp").diagnostic_toggle()<CR>', opts)
map("n", "<leader>lr", "<cmd>LspRestart<CR>", opts)
map("n", "<leader>lf", "<cmd>lua require('lsp').format()<CR>", opts)
map("v", "<leader>lf", "<cmd>lua require('lsp').format()<CR><ESC>", opts)
Expand Down
14 changes: 0 additions & 14 deletions lua/option.lua
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,3 @@ else
}
-- end
end

-- large file {{{
vim.cmd([[
let g:LargeFile = 1024 * 1024 * 10
autocmd myau BufReadPre * let f=getfsize(expand("<afile>")) | if f > g:LargeFile || f == -2 | call LargeFile() | endif
function! LargeFile()
"set binary
setlocal eventignore+=FileType "no syntax highlighting etc
setlocal bufhidden=unload "save memory when other file is viewed
setlocal undolevels=-1 "no undo possible
" display message
autocmd myau VimEnter * echo "The file is larger than " . (g:LargeFile / 1024 / 1024) . " MB, so some options are changed (see vim config for details)."
endfunction
]])
7 changes: 0 additions & 7 deletions lua/plugins/mini.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
return {
{
"echasnovski/mini.bufremove",
keys = { { "<leader>q", function() require("mini.bufremove").delete() end, desc = "Quit Buffer" } },
config = function()
require("mini.bufremove").setup()
end
},
{
"echasnovski/mini.surround",
keys = { "<leader>s" },
Expand Down
20 changes: 5 additions & 15 deletions lua/plugins/misc.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
return {
{ "wsdjeg/vim-fetch", lazy = false },
-- { "ojroques/nvim-osc52", opts = { silent = true, trim = false } },
{
"mbbill/fencview",
cmd = { "FencView", "FencAutoDetect" },
Expand All @@ -10,21 +9,12 @@ return {
end,
},
{
"ethanholz/nvim-lastplace",
lazy = false,
config = function()
require("nvim-lastplace").setup {
lastplace_ignore_buftype = { "quickfix", "nofile", "help" },
lastplace_ignore_filetype = { "gitcommit", "gitrebase", "svn", "hgcommit" },
lastplace_open_folds = true
}
"farmergreg/vim-lastplace",
init = function ()
vim.g.lastplace_ignore = "gitcommit,gitrebase,hgcommit,svn,xxd"
vim.g.lastplace_ignore_buftype = "help,nofile,quickfix"
vim.g.lastplace_open_folds = 0
end
},
-- {
-- "karb94/neoscroll.nvim",
-- config = function()
-- require("neoscroll").setup({})
-- end
-- },
--{ 'simnalamburt/vim-mundo', event = 'VimEnter' },
}
2 changes: 1 addition & 1 deletion lua/plugins/multicursor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ return {
if vim.v.hlsearch == 1 then
vim.cmd("noh")
end
require("notify").dismiss({})
-- require("notify").dismiss({})
end
end)

Expand Down
81 changes: 81 additions & 0 deletions lua/plugins/snacks.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
return {
"folke/snacks.nvim",
priority = 1000,
lazy = false,
keys = {
{ "<leader>un", function() Snacks.notifier.hide() end, desc = "Dismiss All Notifications" },
{ "<leader>q", function() Snacks.bufdelete() end, desc = "Delete Buffer" },
{ "<leader>gg", function() Snacks.lazygit() end, desc = "Lazygit" },
{ "<leader>gb", function() Snacks.git.blame_line() end, desc = "Git Blame Line" },
{ "<leader>gB", function() Snacks.gitbrowse() end, desc = "Git Browse" },
{ "<leader>gf", function() Snacks.lazygit.log_file() end, desc = "Lazygit Current File History" },
{ "<leader>gl", function() Snacks.lazygit.log() end, desc = "Lazygit Log (cwd)" },
{
"<leader>N",
desc = "Neovim News",
function()
Snacks.win({
file = vim.api.nvim_get_runtime_file("doc/news.txt", false)[1],
width = 0.6,
height = 0.6,
wo = { spell = false, wrap = false, signcolumn = "yes", statuscolumn = " ", conceallevel = 3, },
})
end,
}
},
---@module 'snacks'
---@type snacks.Config
opts = {
bigfile = {
notify = true,
size = 1.5 * 1024 * 1024,
---@param ctx {buf: number, ft:string}
setup = function(ctx)
vim.b.minianimate_disable = true
vim.schedule(function()
vim.bo[ctx.buf].syntax = ctx.ft
end)
end,
},
notifier = {
enabled = true,
timeout = 3000,
},
quickfile = { enabled = true },
statuscolumn = { enabled = true },
words = { enabled = false },
styles = {
notification = {
wo = { wrap = true } -- Wrap notifications
}
}
},
init = function()
vim.api.nvim_create_autocmd("User", {
pattern = "VeryLazy",
callback = function()
-- Setup some globals for debugging (lazy-loaded)
_G.dd = function(...)
Snacks.debug.inspect(...)
end
_G.bt = function()
Snacks.debug.backtrace()
end
vim.print = _G.dd -- Override print to use snacks for `:=` command

-- Create some toggle mappings
Snacks.toggle.option("spell", { name = "Spelling" }):map("<leader>us")
Snacks.toggle.option("wrap", { name = "Wrap" }):map("<leader>uw")
Snacks.toggle.option("relativenumber", { name = "Relative Number" }):map("<leader>uL")
Snacks.toggle.diagnostics():map("<leader>ud")
Snacks.toggle.line_number():map("<leader>ul")
Snacks.toggle.option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 })
:map("<leader>uc")
Snacks.toggle.treesitter():map("<leader>uT")
Snacks.toggle.option("background", { off = "light", on = "dark", name = "Dark Background" }):map(
"<leader>ub")
Snacks.toggle.inlay_hints():map("<leader>uh")
end,
})
end,
}
4 changes: 2 additions & 2 deletions lua/plugins/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ M.setup = { --{{{
{ "fl", "<cmd>Telescope current_buffer_fuzzy_find<cr>", desc = "line" },
{ "fo", "<cmd>Telescope oldfiles<cr>", desc = "mru" },
{ "fm", "<cmd>Telescope marks<cr>", desc = "marks" },
{ "fn", "<cmd>Telescope notify<cr>", desc = "notify" },
{ "fn", "<cmd>lua Snacks.notifier.show_history({})<cr>", desc = "notify" },
{ "fr", "<cmd>Telescope resume<cr>", desc = "resume" },
{ "ft", "<cmd>Telescope tags<cr>", desc = "tag" },
{ "f/", function() require("util").live_grep() end, mode = {"n", "x"}, desc = "live grep" },
Expand Down Expand Up @@ -218,7 +218,7 @@ M.setup = { --{{{
},
},
})
require("telescope").load_extension("notify")
-- require("telescope").load_extension("notify")
require("telescope").load_extension("fzf")
require("telescope").load_extension("ctags_outline")
require("telescope").load_extension("live_grep_args")
Expand Down
11 changes: 0 additions & 11 deletions lua/plugins/toggleterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ return {
float_opts = float_opts,
clear_env = true,
})
local lazygit = require("toggleterm.terminal").Terminal:new {
cmd = "lazygit",
hidden = true,
direction = "float",
float_opts = float_opts,
on_create = function(t)
local bufnr = t.bufnr
vim.keymap.set("t", "<Esc>", "<Esc>", { buffer = bufnr })
end,
}
local toggle = function()
if vim.bo.filetype == "toggleterm" then
vim.cmd("ToggleTerm direction=float")
Expand All @@ -43,7 +33,6 @@ return {
{ "<leader>tt", "<cmd>ToggleTerm<CR>", desc = "ToggleTerm" },
{ "<leader>tf", "<cmd>ToggleTerm direction=float<CR>", desc = "ToggleTerm float" },
{ "<leader>gt", function() tig:toggle() end, desc = "tig" },
{ "<leader>gl", function() lazygit:toggle() end, desc = "lazygit" },
}
end,
config = function()
Expand Down

0 comments on commit 9c995fe

Please sign in to comment.