From f1e18ce6b1ba4271f1292ef6712570c3b93aae46 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sat, 22 Feb 2025 16:41:28 +0000 Subject: [PATCH 1/7] Migrate to snacks nvim --- nvim/lua/plugs/fzf.lua | 71 ----------------------------- nvim/lua/plugs/indent_blankline.lua | 32 ------------- nvim/lua/plugs/noice.lua | 9 ---- nvim/lua/plugs/smear_cursor.lua | 19 -------- nvim/lua/plugs/snacks.lua | 63 +++++++++++++++++++++++++ 5 files changed, 63 insertions(+), 131 deletions(-) delete mode 100644 nvim/lua/plugs/fzf.lua delete mode 100644 nvim/lua/plugs/indent_blankline.lua delete mode 100644 nvim/lua/plugs/smear_cursor.lua create mode 100644 nvim/lua/plugs/snacks.lua diff --git a/nvim/lua/plugs/fzf.lua b/nvim/lua/plugs/fzf.lua deleted file mode 100644 index 3aa8088..0000000 --- a/nvim/lua/plugs/fzf.lua +++ /dev/null @@ -1,71 +0,0 @@ -return { - "ibhagwan/fzf-lua", - dependencies = { "nvim-tree/nvim-web-devicons" }, - opts = { - "telescope", - winopts = { - preview = { - default = "bat" - } - }, - lsp = { - workspace_symbols = { - symbol_kinds = { "Variable", "Function", "Method", "Class", "Struct", "Interface" }, - }, - }, - previewers = { - builtin = { - -- turn off syntax highlighting for files with more than 100KB - -- this avoid hanging when previewing large files (due to treesitter parsing on minified files) - syntax_limit_b = 1024 * 100, -- 100KB - } - } - }, - config = function() - local fzf = require("fzf-lua") - local pickers = { - { - mapping = "o", - action = function() - fzf.files({ - git_icons = false, - }) - end - }, - { - mapping = "a", - action = function() - fzf.live_grep_native({ - git_icons = false, - rg_opts = "--hidden --column --line-number --no-heading --color=always --smart-case", - fzf_opts = { - ['--exact'] = false, -- Disable exact matching - }, - }) - end - }, - { - mapping = "g", - action = function() - fzf.git_bcommits({}) - end - }, - { - mapping = "s", - action = function() - fzf.lsp_live_workspace_symbols({}) - end - } - } - - local keymaps = {} - keymaps.n = {} - for _, picker in ipairs(pickers) do - keymaps.n["t" .. picker.mapping] = { - cmd = picker.action - } - end - - require("utils").add_keymaps(keymaps) - end -} diff --git a/nvim/lua/plugs/indent_blankline.lua b/nvim/lua/plugs/indent_blankline.lua deleted file mode 100644 index e009902..0000000 --- a/nvim/lua/plugs/indent_blankline.lua +++ /dev/null @@ -1,32 +0,0 @@ -return { - "lukas-reineke/indent-blankline.nvim", - main = "ibl", - event = "BufRead", - config = function() - local ibl = require("ibl") - ibl.setup({ - debounce = 100, - indent = { - char = "▏", - }, - scope = { - enabled = true, - char = "▏", - show_start = false, - show_end = false, - highlight = { "IblScope" }, - }, - }) - - local colors = require("ayu.colors") - colors.generate(true) - local highlights = { - { "IblScope", { fg = colors.keyword } }, - { "@ibl.scope.char.1", { fg = colors.keyword } }, - } - - for _, hl in ipairs(highlights) do - vim.api.nvim_set_hl(0, hl[1], hl[2]) - end - end -} diff --git a/nvim/lua/plugs/noice.lua b/nvim/lua/plugs/noice.lua index e15c16a..f31c47b 100644 --- a/nvim/lua/plugs/noice.lua +++ b/nvim/lua/plugs/noice.lua @@ -4,15 +4,6 @@ return { lazy = true, dependencies = { { "MunifTanjim/nui.nvim", lazy = true }, - { - "rcarriga/nvim-notify", - opts = { - background_colour = "#24273a", - fps = 1, - render = "compact", - stages = "static" - } - } }, opts = { lsp = { diff --git a/nvim/lua/plugs/smear_cursor.lua b/nvim/lua/plugs/smear_cursor.lua deleted file mode 100644 index 63984b1..0000000 --- a/nvim/lua/plugs/smear_cursor.lua +++ /dev/null @@ -1,19 +0,0 @@ -return { - "sphamba/smear-cursor.nvim", - opts = { - smear_between_buffers = true, - - min_horizontal_distance_smear = 3, - min_vertical_distance_smear = 2, - - scroll_buffer_space = true, - smear_insert_mode = false, - - cursor_color = "#FFCC66", - transparent_bg_fallback_color = "#303030", - - stiffness = 0.85, - trailing_stiffness = 0.7, - distance_stop_animating = 0.5, - }, -} diff --git a/nvim/lua/plugs/snacks.lua b/nvim/lua/plugs/snacks.lua new file mode 100644 index 0000000..27bed99 --- /dev/null +++ b/nvim/lua/plugs/snacks.lua @@ -0,0 +1,63 @@ +return { + "folke/snacks.nvim", + priority = 1000, + lazy = false, + opts = { + gitbrowse = { enabled = true, }, + picker = { enabled = true, }, + dashboard = { enabled = true, }, + debug = { enabled = true, }, + indent = { + enabled = true, + animate = { + enabled = false, + }, + }, + input = { enabled = true, }, + notifier = { enabled = true, }, + quickfile = { enabled = true, }, + scroll = { + enabled = true, + animate = { + duration = { step = 7, total = 250 }, + easing = "outCirc", + }, + animate_repeat = { + delay = 100, + duration = { step = 3, total = 50 }, + easing = "outCirc", + }, + }, + words = { + enabled = true, + debounce = 100, + }, + zen = { + enabled = true, + toggles = { dim = false, } + }, + }, + keys = { + { "z", function() Snacks.zen() end, }, + + { "to", function() Snacks.picker.smart() end, }, + { "ta", function() Snacks.picker.grep() end, }, + { "tg", function() Snacks.picker.git_log_file() end, }, + { "ts", function() Snacks.picker.lsp_workspace_symbols() end, }, + { "tn", function() Snacks.picker.notifications() end }, + }, + init = function() + vim.api.nvim_create_autocmd("User", { + pattern = "VeryLazy", + callback = function() + _G.inspect = function(...) + Snacks.debug.inspect(...) + end + _G.backtrace = function() + Snacks.debug.backtrace() + end + vim.print = _G.inspect + end, + }) + end +} From 9f358708703a4cbf1e51166e5284347beefc681e Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 23 Feb 2025 01:31:43 +0000 Subject: [PATCH 2/7] Change gutter space from 1 > 2 --- nvim/lua/vim_opt.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvim/lua/vim_opt.lua b/nvim/lua/vim_opt.lua index 80c2924..d76611a 100644 --- a/nvim/lua/vim_opt.lua +++ b/nvim/lua/vim_opt.lua @@ -22,7 +22,7 @@ opt.softtabstop = 4 opt.shortmess:append("sI") -- Signcolumn -opt.signcolumn = "yes:1" -- Adds a spacing to the left which can contain gutter icons +opt.signcolumn = "yes:2" -- Adds a spacing to the left which can contain gutter icons opt.fillchars = { eob = " " } -- Remove the fill character for empty lines which defaults to: "~" -- Search From 7b53280164dd69e6c533a044f4c10bbc0ef807c0 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 23 Feb 2025 01:32:20 +0000 Subject: [PATCH 3/7] Local system stuff --- nix/local_home.nix | 4 ++-- nix/local_system.nix | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/nix/local_home.nix b/nix/local_home.nix index 7882628..cad7a94 100644 --- a/nix/local_home.nix +++ b/nix/local_home.nix @@ -6,7 +6,7 @@ # accordingly, and then commit it. home = { # Stub values for demonstration. Override these in local branch. - username = "larssonmartin1998-mac"; - homeDirectory = "/Users/larssonmartin1998-mac"; + username = "nixos"; + homeDirectory = "/home/nixos"; }; } diff --git a/nix/local_system.nix b/nix/local_system.nix index fd440f0..6bdfb5f 100644 --- a/nix/local_system.nix +++ b/nix/local_system.nix @@ -3,8 +3,6 @@ }: { system = { - stateVersion = 5; + stateVersion = "24.11"; }; - - nix-homebrew.user = "larssonmartin1998-mac"; } From 1cd86b9921359225dc1a314bd4d7ae0d26641f95 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 23 Feb 2025 02:01:10 +0000 Subject: [PATCH 4/7] Remap leap keymappings as we exit debug mode --- nvim/lua/leap_keymap_handler.lua | 25 +++++++++++++++++++++++++ nvim/lua/plugs/leap.lua | 19 ++----------------- nvim/lua/plugs/nvim-dap.lua | 1 + 3 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 nvim/lua/leap_keymap_handler.lua diff --git a/nvim/lua/leap_keymap_handler.lua b/nvim/lua/leap_keymap_handler.lua new file mode 100644 index 0000000..55b791c --- /dev/null +++ b/nvim/lua/leap_keymap_handler.lua @@ -0,0 +1,25 @@ +local M = {} + +local function leap_across_windows() + require("leap").leap({ + target_windows = require("leap.user").get_focusable_windows() + }) +end + +local function leap_in_current_buffer() + require("leap").leap({ + target_windows = { vim.api.nvim_get_current_win() } + }) +end + +function M.set_leap_keymapping() + require("utils").foreach({ + { "n", "m", leap_across_windows }, + { "v", "m", leap_in_current_buffer }, + { "o", "m", leap_in_current_buffer } + }, function(mapping) + vim.keymap.set(mapping[1], mapping[2], mapping[3]) + end) +end + +return M diff --git a/nvim/lua/plugs/leap.lua b/nvim/lua/plugs/leap.lua index 76ca034..2ec7a66 100644 --- a/nvim/lua/plugs/leap.lua +++ b/nvim/lua/plugs/leap.lua @@ -1,15 +1,3 @@ -local function leap_across_windows() - require("leap").leap({ - target_windows = require("leap.user").get_focusable_windows() - }) -end - -local function leap_in_current_buffer() - require("leap").leap({ - target_windows = { vim.api.nvim_get_current_win() } - }) -end - local saved_hlsearch = false local saved_highlights = {} local colors = require("ayu.colors") @@ -32,11 +20,6 @@ return { event = "VeryLazy", lazy = true, opts = {}, - keys = { - { "m", function() leap_across_windows() end, mode = "n" }, - { "m", function() leap_in_current_buffer() end, mode = "v" }, - { "m", function() leap_in_current_buffer() end, mode = "o" }, - }, init = function() local leap = require("leap") @@ -71,5 +54,7 @@ return { for _, cmd in ipairs(autocmds) do utils.create_user_event_cb(cmd.event_name, cmd.cb, leap_augroup_name) end + + require("leap_keymap_handler").set_leap_keymapping() end, } diff --git a/nvim/lua/plugs/nvim-dap.lua b/nvim/lua/plugs/nvim-dap.lua index 5756f97..63afd26 100644 --- a/nvim/lua/plugs/nvim-dap.lua +++ b/nvim/lua/plugs/nvim-dap.lua @@ -67,6 +67,7 @@ return { if are_stepping_keymaps_active then utils.del_keymap_list(stepping_keymaps) are_stepping_keymaps_active = false + require("leap_keymap_handler").set_leap_keymapping() end inlay_hints_handler.restore() From 5fbf788a4044f2a470ee6f60c31e64c82c82ff15 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 23 Feb 2025 02:01:37 +0000 Subject: [PATCH 5/7] Add keymap for gitbrowse and set it to browse to repo --- nvim/lua/plugs/snacks.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nvim/lua/plugs/snacks.lua b/nvim/lua/plugs/snacks.lua index 27bed99..1247d8a 100644 --- a/nvim/lua/plugs/snacks.lua +++ b/nvim/lua/plugs/snacks.lua @@ -3,7 +3,10 @@ return { priority = 1000, lazy = false, opts = { - gitbrowse = { enabled = true, }, + gitbrowse = { + enabled = true, + what = "repo", + }, picker = { enabled = true, }, dashboard = { enabled = true, }, debug = { enabled = true, }, @@ -38,6 +41,8 @@ return { }, }, keys = { + { "gB", function() Snacks.gitbrowse() end, }, + { "z", function() Snacks.zen() end, }, { "to", function() Snacks.picker.smart() end, }, From dcd14d7eecf7fd8f1cc48d9b490640c5b56f1fa0 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 23 Feb 2025 02:01:58 +0000 Subject: [PATCH 6/7] Add Snacks as globals in lua lsp --- nvim/.luarc.json | 3 ++- nvim/lua/lsp/servers/lua_ls.lua | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nvim/.luarc.json b/nvim/.luarc.json index 1e1765c..f82b794 100644 --- a/nvim/.luarc.json +++ b/nvim/.luarc.json @@ -1,5 +1,6 @@ { "diagnostics.globals": [ "vim" + "Snacks" ] -} \ No newline at end of file +} diff --git a/nvim/lua/lsp/servers/lua_ls.lua b/nvim/lua/lsp/servers/lua_ls.lua index 4a9f57a..780383e 100644 --- a/nvim/lua/lsp/servers/lua_ls.lua +++ b/nvim/lua/lsp/servers/lua_ls.lua @@ -30,7 +30,7 @@ return { version = "LuaJIT" }, diagnostics = { - globals = { "vim" }, + globals = { "vim", "Snacks" }, }, -- Make the server aware of Neovim runtime files workspace = { From 334b18e3092dba9121c2ad9b979a6a175cc80c48 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Sun, 23 Feb 2025 02:09:55 +0000 Subject: [PATCH 7/7] Fix so zen mode doesnt exit when leaping in normal mode. --- nvim/lua/leap_keymap_handler.lua | 10 +++++++++- nvim/lua/plugs/snacks.lua | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/nvim/lua/leap_keymap_handler.lua b/nvim/lua/leap_keymap_handler.lua index 55b791c..609d77f 100644 --- a/nvim/lua/leap_keymap_handler.lua +++ b/nvim/lua/leap_keymap_handler.lua @@ -12,9 +12,17 @@ local function leap_in_current_buffer() }) end +local function normal_mode_leap() + if _G["snacks_zen_mode"] then + leap_in_current_buffer() + else + leap_across_windows() + end +end + function M.set_leap_keymapping() require("utils").foreach({ - { "n", "m", leap_across_windows }, + { "n", "m", normal_mode_leap }, { "v", "m", leap_in_current_buffer }, { "o", "m", leap_in_current_buffer } }, function(mapping) diff --git a/nvim/lua/plugs/snacks.lua b/nvim/lua/plugs/snacks.lua index 1247d8a..418b207 100644 --- a/nvim/lua/plugs/snacks.lua +++ b/nvim/lua/plugs/snacks.lua @@ -37,7 +37,13 @@ return { }, zen = { enabled = true, - toggles = { dim = false, } + toggles = { dim = false, }, + on_open = function() + _G["snacks_zen_mode"] = true + end, + on_close = function() + _G["snacks_zen_mode"] = false + end, }, }, keys = {