diff --git a/home/modules/neovim/default.nix b/home/modules/neovim/default.nix index d5dcce9e..7dc71b84 100644 --- a/home/modules/neovim/default.nix +++ b/home/modules/neovim/default.nix @@ -80,8 +80,8 @@ in { }; programs.nixvim = { - enable = true; defaultEditor = true; + enable = true; enableMan = false; # Nixvim man pages luaLoader.enable = true; # NOTE: Experimental viAlias = neovim.alias; @@ -228,25 +228,6 @@ in { end ''; } - - # This breaks if the preview buffer does not refer to a file, e.g. when showing previous notifications - # { - # desc = "Enable line wrapping in telescope preview"; - # event = ["User"]; - # pattern = ["TelescopePreviewerLoaded"]; - # callback.__raw = '' - # -- The callback arg is of this format: - # -- { - # -- title: string, # preview window title - # -- filetype: string, - # -- bufname: string, - # -- } - - # function(args) - # vim.wo.wrap = true - # end - # ''; - # } ]; keymaps = import ./mappings.nix {inherit lib mylib;}; @@ -541,34 +522,6 @@ in { }; }; - # TODO: Don't autosave, but if a session exists, update it (using should_autosave) - _persisted = { - name = "persisted"; - pkg = pkgs.vimPlugins.persisted-nvim; - dependencies = [telescope]; - lazy = true; - cmd = ["SessionSave" "SessionDelete" "Telescope persisted"]; - config = '' - function(_, opts) - require("persisted").setup(opts) - - require("telescope").load_extension("persisted") - end - ''; - opts = { - silent = false; - use_git_branch = false; - autosave = false; - autoload = false; - follow_cwd = true; - ignored_dirs = [ - "/" - "~/" - "~/Projects/" - ]; - }; - }; - direnv = { name = "direnv"; pkg = pkgs.vimPlugins.direnv-vim; @@ -627,7 +580,6 @@ in { filetypesDenylist = [ "DressingSelect" "Outline" - "TelescopePrompt" "alpha" "harpoon" "toggleterm" @@ -1004,7 +956,7 @@ in { } ''; in { - extensions = ["fzf" "lazy" "neo-tree" "oil" "quickfix" "toggleterm" "trouble"]; + extensions = ["fzf" "lazy" "quickfix" "toggleterm" "trouble"]; options = { # theme = "catppuccin"; @@ -1256,6 +1208,28 @@ in { }; }; + # TODO: Don't autosave, but if a session exists, update it (using should_save) + # TODO: No idea which opts below really exist... + persisted = rec { + name = "persisted"; + pkg = pkgs.vimPlugins.persisted-nvim; + lazy = false; + config = mkDefaultConfig name; + opts = { + silent = false; + use_git_branch = false; + autostart = false; + autosave = false; + autoload = false; + follow_cwd = true; + ignored_dirs = [ + "/" + "~/" + "~/Projects/" + ]; + }; + }; + presence = rec { name = "presence"; pkg = pkgs.vimPlugins.presence-nvim; @@ -1349,7 +1323,6 @@ in { pkg = pkgs.vimPlugins.snacks-nvim; dependencies = [ web-devicons - _persisted ]; lazy = false; priority = 1000; @@ -1396,7 +1369,7 @@ in { icon = " "; key = "s"; desc = "Restore Session"; - action = "Telescope persisted"; + action = "lua require('persisted').select()"; } { icon = "󰒲 "; @@ -1428,6 +1401,27 @@ in { enabled = true; replace_netrw = true; }; + + picker = let + defaultLayout = '' + --- Use the default layout or vertical if the window is too narrow + function() + return vim.o.columns >= 120 and "default" or "vertical" + end + ''; + in { + enabled = true; + layout = { + cycle = true; + preset.__raw = defaultLayout; + }; + + sources = { + lines = { + layout.__raw = defaultLayout; + }; + }; + }; }; }; @@ -1483,98 +1477,11 @@ in { }; _plenary = { - name = "plenary"; # For telescope + name = "plenary"; pkg = pkgs.vimPlugins.plenary-nvim; lazy = true; }; - _telescope-fzf-native = { - name = "telescope-fzf-native"; - pkg = pkgs.vimPlugins.telescope-fzf-native-nvim; - lazy = true; - }; - - # TODO: Build broken - # _telescope-tabs = { - # name = "telescope-tabs"; - # pkg = pkgs.vimUtils.buildVimPlugin { - # name = "telescope-tabs"; - # src = pkgs.fetchFromGitHub { - # owner = "LukasPietzschmann"; - # repo = "telescope-tabs"; - # rev = "0a678eefcb71ebe5cb0876aa71dd2e2583d27fd3"; - # sha256 = "sha256-IvxZVHPtApnzUXIQzklT2C2kAxgtAkBUq3GNxwgPdPY="; - # }; - # }; - # lazy = true; - # }; - - _telescope-undo = { - name = "telescope-undo"; - pkg = pkgs.vimPlugins.telescope-undo-nvim; - lazy = true; - }; - - _telescope-ui-select = { - name = "telescope-ui-select"; - pkg = pkgs.vimPlugins.telescope-ui-select-nvim; - lazy = true; - }; - - telescope = { - name = "telescope"; - pkg = pkgs.vimPlugins.telescope-nvim; - lazy = true; - cmd = ["Telescope"]; - dependencies = [ - _plenary - _telescope-fzf-native - # _telescope-tabs - _telescope-undo - _telescope-ui-select - ]; - config = let - extensions = mylib.generators.toLuaObject [ - "undo" - "ui-select" - "fzf" - # "telescope-tabs" - ]; - in '' - function(_, opts) - local telescope = require("telescope") - telescope.setup(opts) - - for i, extension in ipairs(${extensions}) do - telescope.load_extension(extension) - end - end - ''; - opts = { - defaults = { - wrap_results = false; # Do wrapping in the preview instead, see autoCmd - preview = { - treesitter = true; - }; - mappings = { - i = { - # TODO: This mappings throws an error. - # Doesn't matter if defined as function or like " = "which_key";. - "" = {__raw = ''function(...) return require("telescope.actions").which_key(...) end'';}; - "" = {__raw = ''function(...) return require("telescope.actions").close(...) end'';}; - }; - }; - }; - pickers = { - buffers = { - # See :h telescope.builtin.buffers() for opts - ignore_current_buffer = true; - sort_mru = true; - }; - }; - }; - }; - todo-comments = rec { name = "todo-comments"; pkg = pkgs.vimPlugins.todo-comments-nvim; @@ -1975,6 +1882,7 @@ in { # overseer # Run tasks from within neovim (e.g. cargo) # TODO: + persisted # Session management presence # Discord rich presence quickfix-reflector # Make the quickfix list editable and saveable to apply changes rainbow-delimiters # Bracket/Paren colorization @@ -1985,7 +1893,6 @@ in { snacks # Lots of QoL tabby # Nicer tabline (only showing tabpages) - telescope # Option picker frontend todo-comments # Highlight TODOs toggleterm # Integrated terminal treesitter # AST based syntax highlighting + indentation diff --git a/home/modules/neovim/mappings.nix b/home/modules/neovim/mappings.nix index 98cdd147..625c0918 100644 --- a/home/modules/neovim/mappings.nix +++ b/home/modules/neovim/mappings.nix @@ -1,4 +1,4 @@ -{...}: let +_: let # TODO: Doesn't work reliably. I think they are rebound by plugins after? Try setting in extraConfigLuaPost... disabled-mappings = let mkDisabledMapping = mapping: { @@ -268,14 +268,8 @@ { mode = "n"; key = "/"; - action = "Telescope current_buffer_fuzzy_find"; - options.desc = "Grep Buffer"; - } - { - mode = "v"; - key = "?"; - action = "Telescope grep_string"; - options.desc = "Find Selection"; + action = "lua Snacks.picker.lines()"; + options.desc = "Find in Buffer"; } { mode = "n"; @@ -310,46 +304,52 @@ action = "Navbuddy"; options.desc = "Toggle NavBuddy"; } + { + mode = "n"; + key = "p"; + action = "lua Snacks.picker.pickers()"; + options.desc = "Show Pickers"; + } { mode = "n"; key = "N"; - action = "Telescope notify"; - options.desc = "Telescope Notify"; + action = "lua Snacks.picker.notifications()"; + options.desc = "Notifications Picker"; } { mode = "n"; key = "r"; - action = "Telescope resume"; - options.desc = "Last Telescope"; + action = "lua Snacks.picker.resume()"; + options.desc = "Last Picker"; + } + { + mode = "n"; + key = ";"; + action = "lua Snacks.picker.command_history()"; + options.desc = "Command History"; } - # { - # mode = "n"; - # key = ";"; - # action = "Telescope command_history"; - # options.desc = "Last Commands"; - # } { mode = "n"; key = ":"; - action = "Telescope commands"; - options.desc = "Telescope Command"; - } - { - mode = "n"; - key = "M"; - action = "Telescope marks"; - options.desc = "Telescope Marks"; + action = "lua Snacks.picker.commands()"; + options.desc = "Commands Picker"; } # { # mode = "n"; + # key = "M"; + # action = "lua Snacks.picker.marks()"; + # options.desc = "Marks Picker"; + # } + # { + # mode = "n"; # key = "J"; - # action = "Telescope jumplist"; - # options.desc = "Telescope Jumps"; + # action = "lua Snacks.picker.jumps()"; + # options.desc = "Jumps Picker"; # } { mode = "n"; key = "d"; - action = "TodoTelescope"; + action = "lua Snacks.picker.todo_comments()"; options.desc = "List TODOs"; } { @@ -361,13 +361,13 @@ { mode = "n"; key = "/"; - action = "Telescope live_grep"; + action = "lua Snacks.picker.grep()"; options.desc = "Find in Project"; } { mode = "n"; key = "Q"; - action = "Telescope quickfixhistory"; + action = "lua Snacks.picker.qflist()"; options.desc = "Quickfix History"; } # { @@ -393,13 +393,13 @@ { mode = "n"; key = "ff"; - action = "Telescope find_files"; + action = "lua Snacks.picker.files()"; options.desc = "Find File"; } { mode = "n"; key = "fl"; - action = "Telescope oldfiles"; + action = "lua Snacks.picker.recent()"; options.desc = "Last Files"; } { @@ -417,8 +417,8 @@ { mode = "n"; key = "fu"; - action = "Telescope undo"; - options.desc = "Telescope Undo"; + action = "lua Snacks.picker.und()"; + options.desc = "Undo Picker"; } { mode = "n"; @@ -445,29 +445,29 @@ key = "h"; action = "+help"; } - { - mode = "n"; - key = "hv"; - action = "Telescope vim_options"; - options.desc = "Telescope Vimopts"; - } + # { + # mode = "n"; + # key = "hv"; + # action = "Telescope vim_options"; + # options.desc = "Telescope Vimopts"; + # } { mode = "n"; key = "hk"; - action = "Telescope keymaps"; - options.desc = "Telescope Keys"; + action = "lua Snacks.picker.keymaps()"; + options.desc = "Keymaps Picker"; } { mode = "n"; key = "hm"; - action = "Telescope man_pages"; - options.desc = "Telescope Manpages"; + action = "lua Snacks.picker.man()"; + options.desc = "Manpages Picker"; } { mode = "n"; key = "hh"; - action = "Telescope help_tags"; - options.desc = "Telescope Helptags"; + action = "lua Snacks.picker.help()"; + options.desc = "Helptags Picker"; } ]; @@ -500,7 +500,7 @@ { mode = "n"; key = "sl"; - action = "Telescope persisted"; + action = "lua require('persisted').select()"; options.desc = "Restore Session"; } { @@ -526,14 +526,14 @@ { mode = "n"; key = "bb"; - action = "Telescope buffers"; - options.desc = "List Buffers"; + action = "lua Snacks.picker.buffers()"; + options.desc = "Buffers Picker"; } { mode = "n"; key = ""; - action = "Telescope buffers"; - options.desc = "List Buffers"; + action = "lua Snacks.picker.buffers()"; + options.desc = "Buffers Picker"; } { mode = "n"; @@ -567,18 +567,18 @@ key = "t"; action = "+tab"; } - { - mode = "n"; - key = "tt"; - action = "Telescope telescope-tabs list_tabs"; - options.desc = "List Tabpages"; - } - { - mode = "n"; - key = ""; - action = "Telescope telescope-tabs list_tabs"; - options.desc = "List Tabpages"; - } + # { + # mode = "n"; + # key = "tt"; + # action = "Telescope telescope-tabs list_tabs"; + # options.desc = "List Tabpages"; + # } + # { + # mode = "n"; + # key = ""; + # action = "Telescope telescope-tabs list_tabs"; + # options.desc = "List Tabpages"; + # } { mode = "n"; key = "tn"; @@ -697,25 +697,25 @@ { mode = "n"; key = "gs"; - action = "Telescope git_status"; + action = "lua Snacks.picker.git_status()"; options.desc = "Git Status"; } { mode = "n"; key = "gl"; - action = "Telescope git_commits"; + action = "lua Snacks.picker.git_log()"; options.desc = "Git Log"; } { mode = "n"; key = "gb"; - action = "Telescope git_branches"; + action = "lua Snacks.picker.git_branches()"; options.desc = "Git Branches"; } { mode = "n"; key = "gf"; - action = "Telescope git_bcommits"; + action = "lua Snacks.picker.git_log_file()"; options.desc = "Git File History"; } { @@ -748,7 +748,7 @@ { mode = "n"; key = "cD"; - action = "Telescope diagnostics"; + action = "lua Snacks.picker.diagnostics()"; options.desc = "List Diagnostics"; } @@ -764,18 +764,18 @@ action = "lua vim.lsp.buf.code_action()"; options.desc = "Code Actions"; } - { - mode = "n"; - key = "cI"; - action = "Telescope lsp_incoming_calls"; - options.desc = "LSP Incoming Calls"; - } - { - mode = "n"; - key = "cO"; - action = "Telescope lsp_outgoing_calls"; - options.desc = "LSP Outgoing Calls"; - } + # { + # mode = "n"; + # key = "cI"; + # action = "Telescope lsp_incoming_calls"; + # options.desc = "LSP Incoming Calls"; + # } + # { + # mode = "n"; + # key = "cO"; + # action = "Telescope lsp_outgoing_calls"; + # options.desc = "LSP Outgoing Calls"; + # } { mode = "n"; key = "cC"; @@ -835,26 +835,26 @@ { mode = "n"; key = "cgr"; - action = "Telescope lsp_references"; + action = "lua Snacks.picker.lsp_references()"; options.desc = "LSP References"; } { mode = "n"; key = "cgd"; - action = "Telescope lsp_definitions"; - options.desc = "LSP Definition"; + action = "lua Snacks.picker.lsp_definitions()"; + options.desc = "LSP Definitions"; } { mode = "n"; key = "cgi"; - action = "Telescope lsp_implementations"; - options.desc = "LSP Implementation"; + action = "lua Snacks.picker.lsp_implementations()"; + options.desc = "LSP Implementations"; } { mode = "n"; key = "cgt"; - action = "Telescope lsp_type_definitions"; - options.desc = "LSP Type Definition"; + action = "lua Snacks.picker.lsp_type_definitions()"; + options.desc = "LSP Type Definitions"; } { mode = "n";